ui
@@ -1,6 +1,7 @@
|
||||
package org.saturnclient.saturnclient;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
|
||||
import org.saturnclient.saturnclient.cloaks.Cloaks;
|
||||
import org.saturnclient.saturnclient.event.KeyInputHandler;
|
||||
@@ -15,6 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||
public class SaturnClient implements ModInitializer {
|
||||
public static final String MOD_ID = "saturnclient";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
public static int COLOR = ColorHelper.getArgb(255, 251, 60, 79);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class MainMenu extends SaturnUi {
|
||||
client.setScreen(new SettingsMenu());
|
||||
}).setX((width - buttonWidth) / 2).setY((height - buttonHeight) / 2).setWidth(buttonWidth)
|
||||
.setHeight(buttonHeight)
|
||||
.setAnimation(SaturnAnimation.FADE_SLIDE.distance(15)));
|
||||
.setAnimation(SaturnAnimation.FADE_SLIDE.offset(15).speed(0.1f)));
|
||||
|
||||
draw(
|
||||
new SaturnImageButton(Textures.EMOTE, 14, 14,
|
||||
@@ -34,7 +34,7 @@ public class MainMenu extends SaturnUi {
|
||||
.setY((height - buttonHeight) / 2)
|
||||
.setWidth(buttonHeight)
|
||||
.setHeight(buttonHeight)
|
||||
.setAnimation(SaturnAnimation.FADE_SLIDE.distance(15)));
|
||||
.setAnimation(SaturnAnimation.FADE_SLIDE.offset(15).speed(0.1f)));
|
||||
|
||||
draw(
|
||||
new SaturnImageButton(Textures.COSMETICS, 14, 14,
|
||||
@@ -45,6 +45,6 @@ public class MainMenu extends SaturnUi {
|
||||
.setY((height - buttonHeight) / 2)
|
||||
.setWidth(buttonHeight)
|
||||
.setHeight(buttonHeight)
|
||||
.setAnimation(SaturnAnimation.FADE_SLIDE.distance(15)));
|
||||
.setAnimation(SaturnAnimation.FADE_SLIDE.offset(15).speed(0.1f)));
|
||||
}
|
||||
}
|
||||
@@ -2,37 +2,52 @@ package org.saturnclient.saturnclient.menus;
|
||||
|
||||
import org.saturnclient.ui.SaturnUi;
|
||||
import org.saturnclient.ui.Textures;
|
||||
import org.saturnclient.ui.widgets.SaturnImageButton;
|
||||
import org.saturnclient.ui.widgets.SaturnInputBox;
|
||||
import org.saturnclient.ui.widgets.SaturnClickableImage;
|
||||
import org.saturnclient.ui.widgets.SaturnTexture;
|
||||
import org.saturnclient.ui.SaturnAnimation;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class SettingsMenu extends SaturnUi {
|
||||
public SaturnImageButton searchButton;
|
||||
public SaturnInputBox searchInputBox;
|
||||
|
||||
public SettingsMenu() {
|
||||
super(Text.literal("Settings"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
searchInputBox = new SaturnInputBox("Search", 10, 10, 100, 20);
|
||||
searchInputBox.visible = false;
|
||||
draw(searchInputBox);
|
||||
int rectWidth = 330;
|
||||
int rectHeight = 228;
|
||||
int modsX = (width - rectWidth) / 2;
|
||||
int modsY = (height - rectHeight) / 2;
|
||||
|
||||
searchButton = (SaturnImageButton) new SaturnImageButton(Textures.SEARCH, 10,
|
||||
10,
|
||||
() -> {
|
||||
searchInputBox.visible = !searchInputBox.visible;
|
||||
if (searchInputBox.visible) {
|
||||
searchButton.sprite = Textures.CLOSE;
|
||||
} else {
|
||||
searchInputBox.clearText();
|
||||
searchButton.sprite = Textures.SEARCH;
|
||||
}
|
||||
}).setWidth(30).setHeight(30).setX(30).setY(30);
|
||||
draw(new SaturnTexture(Textures.SETTINGS_BG)
|
||||
.setX(modsX)
|
||||
.setY(modsY)
|
||||
.setWidth(rectWidth)
|
||||
.setHeight(rectHeight)
|
||||
.setAnimation(SaturnAnimation.FADE_SLIDE));
|
||||
|
||||
draw(searchButton);
|
||||
draw(new SaturnTexture(Textures.TABS)
|
||||
.setX((width - 43) / 2)
|
||||
.setY(modsY - 16)
|
||||
.setWidth(43)
|
||||
.setHeight(15)
|
||||
.setAnimation(SaturnAnimation.FADE_SLIDE));
|
||||
|
||||
int modX = modsX + 15;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
draw(new SaturnClickableImage(Textures.MOD, () -> {
|
||||
System.out.println("Pressed");
|
||||
})
|
||||
.setBackground(false)
|
||||
.setX(modX)
|
||||
.setY(modsY + 10)
|
||||
.setWidth(86)
|
||||
.setHeight(20)
|
||||
.setAnimation(SaturnAnimation.FADE_SLIDE.offset(40)));
|
||||
|
||||
modX += 86 + 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,30 +5,37 @@ public enum SaturnAnimation {
|
||||
SLIDE,
|
||||
FADE_SLIDE;
|
||||
|
||||
public int distance = 0;
|
||||
public int widgetY = 0;
|
||||
public int offset = 10;
|
||||
public float speed = 0.05f;
|
||||
|
||||
public void apply(SaturnWidget widget) {
|
||||
switch (this) {
|
||||
case FADE:
|
||||
widget.alpha = Math.min(widget.alpha + 0.05f, 1.0f);
|
||||
widget.alpha = Math.min(widget.alpha + speed, 1.0f);
|
||||
break;
|
||||
case SLIDE:
|
||||
if (widgetY < widget.y) {
|
||||
widget.y -= 1;
|
||||
if (offset > 0) {
|
||||
widget.y--;
|
||||
offset--;
|
||||
}
|
||||
break;
|
||||
case FADE_SLIDE:
|
||||
widget.alpha = Math.min(widget.alpha + 0.05f, 1.0f);
|
||||
if (widgetY < widget.y) {
|
||||
widget.y -= 1;
|
||||
widget.alpha = Math.min(widget.alpha + speed, 1.0f);
|
||||
if (offset > 0) {
|
||||
widget.y--;
|
||||
offset--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public SaturnAnimation distance(int distance) {
|
||||
this.distance = distance;
|
||||
public SaturnAnimation offset(int offset) {
|
||||
this.offset = offset;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SaturnAnimation speed(float speed) {
|
||||
this.speed = speed;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,19 +50,8 @@ public class SaturnWidget {
|
||||
|
||||
public SaturnWidget setAnimation(SaturnAnimation animation) {
|
||||
this.animation = animation;
|
||||
switch (animation) {
|
||||
case FADE:
|
||||
this.alpha = 0.0f;
|
||||
break;
|
||||
case SLIDE:
|
||||
this.animation.widgetY = y;
|
||||
y += animation.distance;
|
||||
break;
|
||||
case FADE_SLIDE:
|
||||
this.animation.widgetY = y;
|
||||
y += animation.distance;
|
||||
this.alpha = 0.0f;
|
||||
break;
|
||||
if (this.animation == SaturnAnimation.FADE || this.animation == SaturnAnimation.FADE_SLIDE) {
|
||||
this.alpha = 0.0f;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@ public class Textures {
|
||||
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");
|
||||
|
||||
// Button Textures
|
||||
public static final Identifier BUTTON_BORDER = Identifier.ofVanilla("widget/saturn/button_border");
|
||||
public static final Identifier BUTTON = Identifier.ofVanilla("widget/saturn/button");
|
||||
// Widgets
|
||||
public static final Identifier BUTTON_BORDER = Identifier.ofVanilla("saturn/button_border");
|
||||
public static final Identifier BUTTON = Identifier.ofVanilla("saturn/button");
|
||||
public static final Identifier SETTINGS_BG = Identifier.ofVanilla("saturn/settings_bg");
|
||||
public static final Identifier TABS = Identifier.ofVanilla("saturn/tabs");
|
||||
public static final Identifier MOD = Identifier.of("saturnclient", "textures/gui/components/mod.png");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.saturnclient.ui.widgets;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.ui.SaturnWidget;
|
||||
import org.saturnclient.ui.Textures;
|
||||
|
||||
@@ -16,6 +17,7 @@ public class SaturnButton extends SaturnWidget {
|
||||
public boolean active = true;
|
||||
public String text;
|
||||
public Runnable onPress;
|
||||
public boolean background = true;
|
||||
|
||||
public SaturnButton(String text, Runnable onPress) {
|
||||
this.text = text;
|
||||
@@ -26,22 +28,24 @@ public class SaturnButton extends SaturnWidget {
|
||||
public void render(DrawContext context, boolean hovering) {
|
||||
MinecraftClient minecraftClient = MinecraftClient.getInstance();
|
||||
|
||||
RenderSystem.setShaderTexture(0, Textures.BUTTON);
|
||||
RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
|
||||
if (background) {
|
||||
RenderSystem.setShaderTexture(0, Textures.BUTTON);
|
||||
RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
|
||||
|
||||
context.drawGuiTexture(RenderLayer::getGuiTextured, Textures.BUTTON, this.x,
|
||||
this.y, this.width, this.height, ColorHelper.getWhite(this.alpha));
|
||||
context.drawGuiTexture(RenderLayer::getGuiTextured, Textures.BUTTON, this.x,
|
||||
this.y, this.width, this.height, ColorHelper.getWhite(this.alpha));
|
||||
|
||||
if (hovering) {
|
||||
context.drawGuiTexture(RenderLayer::getGuiTextured, Textures.BUTTON_BORDER, this.x,
|
||||
this.y, this.width, this.height, ColorHelper.getArgb(255, 251, 60, 79));
|
||||
if (hovering) {
|
||||
context.drawGuiTexture(RenderLayer::getGuiTextured, Textures.BUTTON_BORDER, this.x,
|
||||
this.y, this.width, this.height, SaturnClient.COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
int i = this.active ? 16777215 : 10526880;
|
||||
context.drawText(minecraftClient.textRenderer, this.text,
|
||||
this.x + ((this.width - minecraftClient.textRenderer.getWidth(this.text)) / 2),
|
||||
this.y + ((this.height - minecraftClient.textRenderer.fontHeight + 1) / 2),
|
||||
i | MathHelper.ceil(this.alpha * 255.0F) << 24, false);
|
||||
hovering ? SaturnClient.COLOR : i | MathHelper.ceil(this.alpha * 255.0F) << 24, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.saturnclient.ui.widgets;
|
||||
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
|
||||
public class SaturnClickableImage extends SaturnButton {
|
||||
public Identifier sprite;
|
||||
public boolean selected = false;
|
||||
|
||||
public SaturnClickableImage(Identifier sprite, Runnable onPress) {
|
||||
super("", onPress);
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, boolean hovering) {
|
||||
context.drawTexture(RenderLayer::getGuiTextured, sprite, x, y, 0, 0, width, height, width,
|
||||
height, hovering || selected ? SaturnClient.COLOR : ColorHelper.getWhite(alpha));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click() {
|
||||
this.onPress.run();
|
||||
}
|
||||
|
||||
public SaturnClickableImage setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SaturnClickableImage setBackground(boolean background) {
|
||||
this.background = background;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.saturnclient.ui.widgets;
|
||||
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -20,14 +21,18 @@ public class SaturnImageButton extends SaturnButton {
|
||||
@Override
|
||||
public void render(DrawContext context, boolean hovering) {
|
||||
super.render(context, hovering);
|
||||
|
||||
context.drawTexture(RenderLayer::getGuiTextured, sprite, x + (width - imageWidth) / 2,
|
||||
y + (height - imageHeight) / 2, 0, 0, imageWidth, imageHeight, imageWidth,
|
||||
imageHeight, ColorHelper.getWhite(alpha));
|
||||
imageHeight, hovering ? SaturnClient.COLOR : ColorHelper.getWhite(alpha));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click() {
|
||||
this.onPress.run();
|
||||
}
|
||||
|
||||
public SaturnImageButton setBackground(boolean background) {
|
||||
this.background = background;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.saturnclient.ui.widgets;
|
||||
|
||||
import org.saturnclient.ui.SaturnWidget;
|
||||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -15,7 +16,7 @@ public class SaturnTexture extends SaturnWidget {
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, boolean hovering) {
|
||||
context.drawTexture(RenderLayer::getGuiTextured, sprite, x, y, 0, 0, width, height, width, height,
|
||||
ColorHelper.getWhite(alpha));
|
||||
context.drawGuiTexture(RenderLayer::getGuiTextured, sprite, this.x,
|
||||
this.y, this.width, this.height, ColorHelper.getWhite(this.alpha));
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 391 B After Width: | Height: | Size: 391 B |
|
Before Width: | Height: | Size: 421 B After Width: | Height: | Size: 421 B |
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"gui": {
|
||||
"scaling": {
|
||||
"type": "nine_slice",
|
||||
"width": 228,
|
||||
"height": 228,
|
||||
"border": 13
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 523 B |
|
After Width: | Height: | Size: 3.1 KiB |