settings icon in the mods menu (not functional)
This commit is contained in:
@@ -24,8 +24,8 @@ public class MainMenu extends SaturnUi {
|
|||||||
int buttonHeight = 25;
|
int buttonHeight = 25;
|
||||||
|
|
||||||
draw(
|
draw(
|
||||||
new SaturnButton("Settings", () -> {
|
new SaturnButton("Mods", () -> {
|
||||||
client.setScreen(new SettingsMenu());
|
client.setScreen(new ModMenu());
|
||||||
}).setX((width - buttonWidth) / 2).setY((height - buttonHeight) /
|
}).setX((width - buttonWidth) / 2).setY((height - buttonHeight) /
|
||||||
2).setWidth(buttonWidth)
|
2).setWidth(buttonWidth)
|
||||||
.setHeight(buttonHeight)
|
.setHeight(buttonHeight)
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
package org.saturnclient.saturnclient.menus;
|
|
||||||
|
|
||||||
import org.saturnclient.saturnmods.ModManager;
|
|
||||||
import org.saturnclient.saturnmods.SaturnMod;
|
|
||||||
import org.saturnclient.ui.SaturnUi;
|
|
||||||
import org.saturnclient.ui.Textures;
|
|
||||||
import org.saturnclient.ui.animations.FadeIn;
|
|
||||||
import org.saturnclient.ui.animations.Slide;
|
|
||||||
import org.saturnclient.ui.components.SaturnModComp;
|
|
||||||
import org.saturnclient.ui.widgets.SaturnClickableImage;
|
|
||||||
import org.saturnclient.ui.widgets.SaturnScroll;
|
|
||||||
import org.saturnclient.ui.widgets.SaturnSprite;
|
|
||||||
import net.minecraft.text.Text;
|
|
||||||
|
|
||||||
public class SettingsMenu extends SaturnUi {
|
|
||||||
public SettingsMenu() {
|
|
||||||
super(Text.literal("Settings"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void init() {
|
|
||||||
int rectWidth = 330;
|
|
||||||
int rectHeight = 228;
|
|
||||||
int modsX = (width - rectWidth) / 2;
|
|
||||||
int modsY = (height - rectHeight + 15) / 2;
|
|
||||||
|
|
||||||
draw(new SaturnSprite(Textures.SETTINGS_BG)
|
|
||||||
.setX(modsX)
|
|
||||||
.setY(modsY)
|
|
||||||
.setWidth(rectWidth)
|
|
||||||
.setHeight(rectHeight)
|
|
||||||
.setAnimations(new Slide(1, 10)));
|
|
||||||
|
|
||||||
int tabsX = (width - 43) / 2;
|
|
||||||
int tabsY = modsY - 17;
|
|
||||||
|
|
||||||
draw(new SaturnSprite(Textures.TABS)
|
|
||||||
.setX(tabsX)
|
|
||||||
.setY(tabsY)
|
|
||||||
.setWidth(43)
|
|
||||||
.setHeight(15)
|
|
||||||
.setAnimations(new Slide(1, 10)));
|
|
||||||
|
|
||||||
int tabSize = 9;
|
|
||||||
tabsX = (width - tabSize) / 2;
|
|
||||||
draw(new SaturnClickableImage(Textures.SETTINGS_TAB, () -> {
|
|
||||||
System.out.println("Pressed");
|
|
||||||
})
|
|
||||||
.setX(tabsX)
|
|
||||||
.setY(tabsY + 3)
|
|
||||||
.setWidth(tabSize)
|
|
||||||
.setHeight(tabSize)
|
|
||||||
.setAnimations(new FadeIn(2))
|
|
||||||
.setAnimations(new Slide(1, 10)));
|
|
||||||
|
|
||||||
draw(new SaturnClickableImage(Textures.MODS_TAB, () -> {
|
|
||||||
System.out.println("Pressed");
|
|
||||||
})
|
|
||||||
.setX(tabsX - 12)
|
|
||||||
.setY(tabsY + 3)
|
|
||||||
.setWidth(tabSize)
|
|
||||||
.setHeight(tabSize)
|
|
||||||
.setAnimations(new FadeIn(2))
|
|
||||||
.setAnimations(new Slide(1, 10)));
|
|
||||||
|
|
||||||
draw(new SaturnClickableImage(Textures.SEARCH, () -> {
|
|
||||||
System.out.println("Pressed");
|
|
||||||
})
|
|
||||||
.setX(tabsX + 12)
|
|
||||||
.setY(tabsY + 3)
|
|
||||||
.setWidth(tabSize)
|
|
||||||
.setHeight(tabSize)
|
|
||||||
.setAnimations(new FadeIn(2))
|
|
||||||
.setAnimations(new Slide(1, 10)));
|
|
||||||
|
|
||||||
int modX = 0;
|
|
||||||
int modY = 0;
|
|
||||||
int col = 0;
|
|
||||||
|
|
||||||
SaturnScroll modsScroll = new SaturnScroll();
|
|
||||||
|
|
||||||
for (SaturnMod mod : ModManager.MODS) {
|
|
||||||
modsScroll.draw(new SaturnModComp(mod)
|
|
||||||
.setX(modX)
|
|
||||||
.setY(modY)
|
|
||||||
.setWidth(86)
|
|
||||||
.setHeight(20));
|
|
||||||
|
|
||||||
col++;
|
|
||||||
|
|
||||||
if (col < 3) {
|
|
||||||
modX += 86 + 18;
|
|
||||||
} else {
|
|
||||||
modX = 0;
|
|
||||||
modY += 20 + 20;
|
|
||||||
col = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
draw(modsScroll.setX(modsX + 17).setY(modsY + 10).setWidth(rectWidth - 17).setHeight(rectHeight - 10)
|
|
||||||
.setAnimations(new Slide(1, 10)));
|
|
||||||
|
|
||||||
super.init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,14 +3,13 @@ package org.saturnclient.ui;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class Textures {
|
public class Textures {
|
||||||
public static final Identifier SETTINGS = Identifier.of("saturnclient", "textures/gui/components/settings.png");
|
|
||||||
public static final Identifier COSMETICS = Identifier.of("saturnclient", "textures/gui/components/cosmetics.png");
|
public static final Identifier COSMETICS = Identifier.of("saturnclient", "textures/gui/components/cosmetics.png");
|
||||||
public static final Identifier HUD_ICON = Identifier.of("saturnclient", "textures/gui/components/hud.png");
|
public static final Identifier HUD_ICON = Identifier.of("saturnclient", "textures/gui/components/hud.png");
|
||||||
public static final Identifier SEARCH = Identifier.of("saturnclient", "textures/gui/components/search.png");
|
public static final Identifier SEARCH = Identifier.of("saturnclient", "textures/gui/components/search.png");
|
||||||
public static final Identifier CLOSE = Identifier.of("saturnclient", "textures/gui/components/close.png");
|
public static final Identifier CLOSE = Identifier.of("saturnclient", "textures/gui/components/close.png");
|
||||||
public static final Identifier MODS_TAB = Identifier.of("saturnclient", "textures/gui/components/mods_tab.png");
|
public static final Identifier MODS_TAB = Identifier.of("saturnclient", "textures/gui/components/mods_tab.png");
|
||||||
public static final Identifier SETTINGS_TAB = Identifier.of("saturnclient",
|
public static final Identifier SETTINGS = Identifier.of("saturnclient",
|
||||||
"textures/gui/components/settings_tab.png");
|
"textures/gui/components/settings.png");
|
||||||
public static final Identifier LOGO = Identifier.of("saturnclient", "textures/logo/logo.png");
|
public static final Identifier LOGO = Identifier.of("saturnclient", "textures/logo/logo.png");
|
||||||
public static final Identifier LOGO_TEXT = Identifier.of("saturnclient", "textures/logo/text.png");
|
public static final Identifier LOGO_TEXT = Identifier.of("saturnclient", "textures/logo/text.png");
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ public class SaturnModComp extends SaturnWidget {
|
|||||||
public void render(DrawContext context, boolean hovering, int mouseX, int mouseY) {
|
public void render(DrawContext context, boolean hovering, int mouseX, int mouseY) {
|
||||||
boolean enabled = mod.isEnabled();
|
boolean enabled = mod.isEnabled();
|
||||||
|
|
||||||
int color = enabled || hovering ? SaturnClient.COLOR : ColorHelper.getWhite(alpha);
|
boolean hovering_settings = settingsHovering(mouseX, mouseY);
|
||||||
|
|
||||||
|
int color = !hovering_settings && (enabled || hovering) ? SaturnClient.COLOR : ColorHelper.getWhite(alpha);
|
||||||
|
|
||||||
int size = 12;
|
int size = 12;
|
||||||
|
|
||||||
@@ -40,10 +42,26 @@ public class SaturnModComp extends SaturnWidget {
|
|||||||
context.drawText(SaturnClient.textRenderer, SaturnUi.text(mod.getName()), x + 20,
|
context.drawText(SaturnClient.textRenderer, SaturnUi.text(mod.getName()), x + 20,
|
||||||
y + (21 - SaturnClient.textRenderer.fontHeight) / 2,
|
y + (21 - SaturnClient.textRenderer.fontHeight) / 2,
|
||||||
color, false);
|
color, false);
|
||||||
|
|
||||||
|
context.drawTexture(RenderLayer::getGuiTextured, Textures.SETTINGS, x + 77,
|
||||||
|
y + 11, 0, 0, 7, 7, 7, 7, hovering_settings ? SaturnClient.COLOR : ColorHelper.getWhite(alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void click(int mouseX, int mouseY) {
|
public void click(int mouseX, int mouseY) {
|
||||||
mod.setEnabled(!mod.isEnabled());
|
if (settingsHovering(mouseX, mouseY)) {
|
||||||
|
// TODO: make a config thingy, and implement it on the mods
|
||||||
|
} else {
|
||||||
|
mod.setEnabled(!mod.isEnabled());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean settingsHovering(int mouseX, int mouseY) {
|
||||||
|
int sX = x + 77;
|
||||||
|
int sY = y + 11;
|
||||||
|
int size = 7;
|
||||||
|
|
||||||
|
return sX < mouseX && sX + size > mouseX
|
||||||
|
&& sY < mouseY && sY + size > mouseY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB |
Reference in New Issue
Block a user