better mod ui
@@ -32,7 +32,7 @@ public class MainMenu extends SaturnUi {
|
|||||||
.setAnimations(new FadeIn(1)));
|
.setAnimations(new FadeIn(1)));
|
||||||
|
|
||||||
draw(
|
draw(
|
||||||
new SaturnImageButton(Textures.EMOTE, 14, 14,
|
new SaturnImageButton(Textures.HUD_ICON, 14, 14,
|
||||||
() -> {
|
() -> {
|
||||||
client.setScreen(new HudEditor());
|
client.setScreen(new HudEditor());
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package org.saturnclient.saturnmods;
|
package org.saturnclient.saturnmods;
|
||||||
|
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public interface SaturnMod {
|
public interface SaturnMod {
|
||||||
public boolean isEnabled();
|
public boolean isEnabled();
|
||||||
|
|
||||||
public void setEnabled(boolean e);
|
public void setEnabled(boolean e);
|
||||||
|
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
|
public Identifier getIconTexture();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,16 @@ import org.saturnclient.saturnclient.SaturnClient;
|
|||||||
import org.saturnclient.saturnmods.HudMod;
|
import org.saturnclient.saturnmods.HudMod;
|
||||||
import org.saturnclient.saturnmods.ModDimensions;
|
import org.saturnclient.saturnmods.ModDimensions;
|
||||||
import org.saturnclient.saturnmods.SaturnMod;
|
import org.saturnclient.saturnmods.SaturnMod;
|
||||||
|
import org.saturnclient.ui.Textures;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class ArmorDisplay implements SaturnMod, HudMod {
|
public class ArmorDisplay implements SaturnMod, HudMod {
|
||||||
private static ModDimensions dimensions = new ModDimensions(0, 0, 34, 75);
|
private static ModDimensions dimensions = new ModDimensions(0, 0, 34, 75);
|
||||||
@@ -23,9 +26,20 @@ public class ArmorDisplay implements SaturnMod, HudMod {
|
|||||||
|
|
||||||
context.drawItem(item, 0, y);
|
context.drawItem(item, 0, y);
|
||||||
|
|
||||||
if (item.getMaxDamage() > 0)
|
if (item.getMaxDamage() > 0) {
|
||||||
|
MatrixStack matrices = context.getMatrices();
|
||||||
|
|
||||||
|
matrices.push();
|
||||||
|
|
||||||
|
matrices.translate(17, y + 5, 0);
|
||||||
|
|
||||||
|
matrices.scale(0.8f, 0.8f, 0f);
|
||||||
|
|
||||||
context.drawText(SaturnClient.textRenderer, "" + (item.getMaxDamage() - item.getDamage()),
|
context.drawText(SaturnClient.textRenderer, "" + (item.getMaxDamage() - item.getDamage()),
|
||||||
16, y + 4, SaturnClient.WHITE, false);
|
0, 0, SaturnClient.WHITE, false);
|
||||||
|
|
||||||
|
matrices.pop();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -73,6 +87,11 @@ public class ArmorDisplay implements SaturnMod, HudMod {
|
|||||||
return "Armor display";
|
return "Armor display";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier getIconTexture() {
|
||||||
|
return Textures.getModIcon("armor");
|
||||||
|
}
|
||||||
|
|
||||||
public void setDimensions(ModDimensions d) {
|
public void setDimensions(ModDimensions d) {
|
||||||
dimensions = d;
|
dimensions = d;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import org.saturnclient.saturnclient.SaturnClient;
|
|||||||
import org.saturnclient.saturnmods.HudMod;
|
import org.saturnclient.saturnmods.HudMod;
|
||||||
import org.saturnclient.saturnmods.ModDimensions;
|
import org.saturnclient.saturnmods.ModDimensions;
|
||||||
import org.saturnclient.saturnmods.SaturnMod;
|
import org.saturnclient.saturnmods.SaturnMod;
|
||||||
|
import org.saturnclient.ui.Textures;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class Coordinates implements SaturnMod, HudMod {
|
public class Coordinates implements SaturnMod, HudMod {
|
||||||
private static ModDimensions dimensions = new ModDimensions();
|
private static ModDimensions dimensions = new ModDimensions();
|
||||||
@@ -42,6 +44,11 @@ public class Coordinates implements SaturnMod, HudMod {
|
|||||||
return "Coords";
|
return "Coords";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier getIconTexture() {
|
||||||
|
return Textures.getModIcon("coords");
|
||||||
|
}
|
||||||
|
|
||||||
public void setDimensions(ModDimensions d) {
|
public void setDimensions(ModDimensions d) {
|
||||||
dimensions = d;
|
dimensions = d;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ 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 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 EMOTE = Identifier.of("saturnclient", "textures/gui/components/emote.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");
|
||||||
@@ -20,8 +20,13 @@ public class Textures {
|
|||||||
public static final Identifier SETTINGS_BG = Identifier.ofVanilla("saturn/settings_bg");
|
public static final Identifier SETTINGS_BG = Identifier.ofVanilla("saturn/settings_bg");
|
||||||
public static final Identifier TABS = Identifier.ofVanilla("saturn/tabs");
|
public static final Identifier TABS = Identifier.ofVanilla("saturn/tabs");
|
||||||
public static final Identifier MOD = Identifier.of("saturnclient", "textures/gui/components/mod.png");
|
public static final Identifier MOD = Identifier.of("saturnclient", "textures/gui/components/mod.png");
|
||||||
|
public static final Identifier MOD_BG = Identifier.of("saturnclient", "textures/gui/components/mod_bg.png");
|
||||||
|
|
||||||
public static Identifier getCloakPreview(String cloak) {
|
public static Identifier getCloakPreview(String cloak) {
|
||||||
return Identifier.of("saturnclient", "textures/gui/cloak/" + cloak + ".png");
|
return Identifier.of("saturnclient", "textures/gui/cloak/" + cloak + ".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Identifier getModIcon(String modId) {
|
||||||
|
return Identifier.of("saturnclient", "textures/gui/mod/" + modId + ".png");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.saturnclient.ui.components;
|
|||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
import org.saturnclient.saturnmods.SaturnMod;
|
import org.saturnclient.saturnmods.SaturnMod;
|
||||||
|
import org.saturnclient.ui.SaturnUi;
|
||||||
import org.saturnclient.ui.SaturnWidget;
|
import org.saturnclient.ui.SaturnWidget;
|
||||||
import org.saturnclient.ui.Textures;
|
import org.saturnclient.ui.Textures;
|
||||||
|
|
||||||
@@ -18,14 +19,27 @@ public class SaturnModComp extends SaturnWidget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(DrawContext context, boolean hovering, int mouseX, int mouseY) {
|
public void render(DrawContext context, boolean hovering, int mouseX, int mouseY) {
|
||||||
int color = mod.isEnabled() || hovering ? SaturnClient.COLOR : ColorHelper.getWhite(alpha);
|
boolean enabled = mod.isEnabled();
|
||||||
|
|
||||||
context.drawText(SaturnClient.textRenderer, mod.getName(), x + 27,
|
int color = enabled || hovering ? SaturnClient.COLOR : ColorHelper.getWhite(alpha);
|
||||||
|
|
||||||
|
int size = 12;
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
context.drawTexture(RenderLayer::getGuiTextured, Textures.MOD_BG, x, y, 0, 0, 86, 20, 86,
|
||||||
|
20, SaturnClient.COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.drawTexture(RenderLayer::getGuiTextured, Textures.MOD, x, y, 0, 0, 86, 20, 86,
|
||||||
|
20, color);
|
||||||
|
|
||||||
|
context.drawTexture(RenderLayer::getGuiTextured, mod.getIconTexture(), x + 4, y + 4, 0, 0, size, size,
|
||||||
|
size,
|
||||||
|
size, color);
|
||||||
|
|
||||||
|
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.MOD, x, y, 0, 0, 86, 20, width,
|
|
||||||
height, color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ public class SaturnImageButton extends SaturnButton {
|
|||||||
|
|
||||||
int hoverColor = ((int) (alpha * 255) << 24) | (SaturnClient.COLOR & 0x00FFFFFF);
|
int hoverColor = ((int) (alpha * 255) << 24) | (SaturnClient.COLOR & 0x00FFFFFF);
|
||||||
|
|
||||||
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, hovering ? hoverColor : ColorHelper.getWhite(alpha));
|
imageHeight, hovering ? hoverColor : ColorHelper.getWhite(alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 455 B After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 619 B |
|
After Width: | Height: | Size: 645 B |
|
Before Width: | Height: | Size: 874 B After Width: | Height: | Size: 867 B |
|
After Width: | Height: | Size: 714 B |
|
After Width: | Height: | Size: 675 B |
|
After Width: | Height: | Size: 526 B |