added toggle component
This commit is contained in:
@@ -8,8 +8,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");
|
||||
public static final Identifier MODS_TAB = Identifier.of("saturnclient", "textures/gui/components/mods_tab.png");
|
||||
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 TOGGLE_INDICATOR = Identifier.of("saturnclient", "textures/gui/components/toggle_indicator.png");
|
||||
public static final Identifier TOGGLE_BG = Identifier.of("saturnclient", "textures/gui/components/toggle_bg.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");
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.saturnclient.ui.components;
|
||||
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.saturnclient.config.Property;
|
||||
import org.saturnclient.ui.SaturnWidget;
|
||||
import org.saturnclient.ui.Textures;
|
||||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
|
||||
public class SaturnToggle extends SaturnWidget {
|
||||
Property<Boolean> prop;
|
||||
|
||||
public SaturnToggle(Property<Boolean> prop) {
|
||||
this.prop = prop;
|
||||
width = 16;
|
||||
height = 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, boolean hovering, int mouseX, int mouseY) {
|
||||
int color = prop.value ? SaturnClient.COLOR : ColorHelper.getWhite(alpha);
|
||||
int w = 16;
|
||||
int h = 6;
|
||||
int s = 8;
|
||||
|
||||
context.drawTexture(RenderLayer::getGuiTextured, Textures.TOGGLE_BG, x,
|
||||
y + 1, 0, 0, w, h, w, h, color);
|
||||
|
||||
context.drawTexture(RenderLayer::getGuiTextured, Textures.TOGGLE_INDICATOR, prop.value ? x + 8 : x,
|
||||
y, 0, 0, s, s, s, s, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(int mouseX, int mouseY) {
|
||||
prop.value = !prop.value;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 427 B |
Binary file not shown.
|
After Width: | Height: | Size: 477 B |
Reference in New Issue
Block a user