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