aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorFalkreon <falkreon@gmail.com>2019-08-30 09:58:20 -0500
committerFalkreon <falkreon@gmail.com>2019-08-30 09:58:20 -0500
commitab75b7dafdcd147905f3d87c1e9c995aef39027c (patch)
tree2a7dbae5a51f9e70ea9f8c8626fac6271eadeefe /src/main/java/io
parente3631b3668a51317daa178a79d94c355b241678b (diff)
downloadLibGui-ab75b7dafdcd147905f3d87c1e9c995aef39027c.tar.gz
LibGui-ab75b7dafdcd147905f3d87c1e9c995aef39027c.tar.bz2
LibGui-ab75b7dafdcd147905f3d87c1e9c995aef39027c.zip
Update to 19w35a, rearrange ScreenDrawing, rename screens
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java (renamed from src/main/java/io/github/cottonmc/cotton/gui/client/ClientCottonScreen.java)7
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java (renamed from src/main/java/io/github/cottonmc/cotton/gui/client/CottonScreen.java)4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java106
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java20
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java6
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java16
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WSprite.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java22
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java2
13 files changed, 100 insertions, 101 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ClientCottonScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
index 16921cf..a1b95fa 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/ClientCottonScreen.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java
@@ -4,12 +4,11 @@ import io.github.cottonmc.cotton.gui.GuiDescription;
import io.github.cottonmc.cotton.gui.widget.WPanel;
import io.github.cottonmc.cotton.gui.widget.WWidget;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
-public class ClientCottonScreen extends Screen {
+public class CottonClientScreen extends Screen {
protected GuiDescription description;
protected int left = 0;
protected int top = 0;
@@ -18,12 +17,12 @@ public class ClientCottonScreen extends Screen {
protected WWidget lastResponder = null;
- public ClientCottonScreen(GuiDescription description) {
+ public CottonClientScreen(GuiDescription description) {
super(new LiteralText(""));
this.description = description;
}
- public ClientCottonScreen(Text title, GuiDescription description) {
+ public CottonClientScreen(Text title, GuiDescription description) {
super(title);
this.description = description;
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java
index bb9f665..0be2ecd 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonScreen.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java
@@ -10,13 +10,13 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Nameable;
-public class CottonScreen<T extends CottonScreenController> extends AbstractContainerScreen<T> {
+public class CottonInventoryScreen<T extends CottonScreenController> extends AbstractContainerScreen<T> {
protected CottonScreenController container;
public static final int PADDING = 8;
protected WWidget lastResponder = null;
protected WWidget focus = null;
- public CottonScreen(T container, PlayerEntity player) {
+ public CottonInventoryScreen(T container, PlayerEntity player) {
super(container, player.inventory, new LiteralText(""));
this.container = container;
width = 18*9;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
index b0c2b05..9c44e35 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java
@@ -2,8 +2,10 @@ package io.github.cottonmc.cotton.gui.client;
import org.lwjgl.opengl.GL11;
-import com.mojang.blaze3d.platform.GlStateManager;
+import com.mojang.blaze3d.systems.RenderSystem;
+import net.minecraft.class_4493.class_4534;
+import net.minecraft.class_4493.class_4535;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.BufferBuilder;
@@ -14,15 +16,11 @@ import net.minecraft.util.Identifier;
public class ScreenDrawing {
private ScreenDrawing() {}
- public static void rect(Identifier texture, int left, int top, int width, int height, int color) {
- rect(texture, left, top, width, height, 0, 0, 1, 1, color, 0);
+ public static void texturedRect(int left, int top, int width, int height, Identifier texture, int color) {
+ texturedRect(left, top, width, height, texture, 0, 0, 1, 1, color);
}
-
- public static void rect(Identifier texture, int left, int top, int width, int height, float u1, float v1, float u2, float v2, int color) {
- rect(texture, left, top, width, height, u1, v1, u2, v2, color, 0);
- }
-
- public static void rect(Identifier texture, int left, int top, int width, int height, float u1, float v1, float u2, float v2, int color, int z) {
+
+ public static void texturedRect(int left, int top, int width, int height, Identifier texture, float u1, float v1, float u2, float v2, int color) {
MinecraftClient.getInstance().getTextureManager().bindTexture(texture);
//float scale = 0.00390625F;
@@ -35,24 +33,24 @@ public class ScreenDrawing {
float b = (color & 255) / 255.0F;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBufferBuilder();
- GlStateManager.enableBlend();
+ RenderSystem.enableBlend();
//GlStateManager.disableTexture2D();
- GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
- GlStateManager.color4f(r, g, b, 1.0f);
+ RenderSystem.blendFuncSeparate(class_4535.SRC_ALPHA, class_4534.ONE_MINUS_SRC_ALPHA, class_4535.ONE, class_4534.ZERO);
+ RenderSystem.color4f(r, g, b, 1.0f);
buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_UV); //I thought GL_QUADS was deprecated but okay, sure.
- buffer.vertex(left, top + height, z).texture(u1, v2).next();
- buffer.vertex(left + width, top + height, z).texture(u2, v2).next();
- buffer.vertex(left + width, top, z).texture(u2, v1).next();
- buffer.vertex(left, top, z).texture(u1, v1).next();
+ buffer.vertex(left, top + height, 0).texture(u1, v2).next();
+ buffer.vertex(left + width, top + height, 0).texture(u2, v2).next();
+ buffer.vertex(left + width, top, 0).texture(u2, v1).next();
+ buffer.vertex(left, top, 0).texture(u1, v1).next();
tessellator.draw();
//GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
+ RenderSystem.disableBlend();
}
/**
* Draws an untextured rectangle of the specified RGB color.
*/
- public static void rect(int left, int top, int width, int height, int color) {
+ public static void coloredRect(int left, int top, int width, int height, int color) {
if (width <= 0) width = 1;
if (height <= 0) height = 1;
@@ -62,32 +60,32 @@ public class ScreenDrawing {
float b = (color & 255) / 255.0F;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBufferBuilder();
- GlStateManager.enableBlend();
- GlStateManager.disableTexture();
- GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
- GlStateManager.color4f(r, g, b, a);
+ RenderSystem.enableBlend();
+ RenderSystem.disableTexture();
+ RenderSystem.blendFuncSeparate(class_4535.SRC_ALPHA, class_4534.ONE_MINUS_SRC_ALPHA, class_4535.ONE, class_4534.ZERO);
+ RenderSystem.color4f(r, g, b, a);
buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION); //I thought GL_QUADS was deprecated but okay, sure.
buffer.vertex(left, top + height, 0.0D).next();
buffer.vertex(left + width, top + height, 0.0D).next();
buffer.vertex(left + width, top, 0.0D).next();
buffer.vertex(left, top, 0.0D).next();
tessellator.draw();
- GlStateManager.enableTexture();
- GlStateManager.disableBlend();
+ RenderSystem.enableTexture();
+ RenderSystem.disableBlend();
}
public static void maskedRect(Identifier mask, Identifier texture, int left, int top, int width, int height) {
- rect(mask, left, top, width, height, 0, 0, 1, 1, 0xFFFFFFFF, 7);
+ texturedRect(left, top, width, height, mask, 0, 0, 1, 1, 0xFFFFFFFF); //TODO: 7 Z
- GlStateManager.enableDepthTest();
- GlStateManager.depthFunc(GL11.GL_EQUAL);
+ RenderSystem.enableDepthTest();
+ RenderSystem.depthFunc(GL11.GL_EQUAL);
- rect(texture, left, top, width, height, 0, 0, 1, 1, 0xFFFFFFFF, 7);
+ texturedRect(left, top, width, height, texture, 0, 0, 1, 1, 0xFFFFFFFF); //, 7);
- GlStateManager.depthFunc(GL11.GL_LESS);
- GlStateManager.disableDepthTest();
+ RenderSystem.depthFunc(GL11.GL_LESS);
+ RenderSystem.disableDepthTest();
}
/**
@@ -144,25 +142,25 @@ public class ScreenDrawing {
}
public static void drawGuiPanel(int x, int y, int width, int height, int shadow, int panel, int hilight, int outline) {
- rect(x + 3, y + 3, width - 6, height - 6, panel); //Main panel area
-
- rect(x + 2, y + 1, width - 4, 2, hilight); //Top hilight
- rect(x + 2, y + height - 3, width - 4, 2, shadow); //Bottom shadow
- rect(x + 1, y + 2, 2, height - 4, hilight); //Left hilight
- rect(x + width - 3, y + 2, 2, height - 4, shadow); //Right shadow
- rect(x + width - 3, y + 2, 1, 1, panel); //Topright non-hilight/non-shadow transition pixel
- rect(x + 2, y + height - 3, 1, 1, panel); //Bottomleft non-hilight/non-shadow transition pixel
- rect(x + 3, y + 3, 1, 1, hilight); //Topleft round hilight pixel
- rect(x + width - 4, y + height - 4, 1, 1, shadow); //Bottomright round shadow pixel
-
- rect(x + 2, y, width - 4, 1, outline); //Top outline
- rect(x, y + 2, 1, height - 4, outline); //Left outline
- rect(x + width - 1, y + 2, 1, height - 4, outline); //Right outline
- rect(x + 2, y + height - 1, width - 4, 1, outline); //Bottom outline
- rect(x + 1, y + 1, 1, 1, outline); //Topleft round pixel
- rect(x + 1, y + height - 2, 1, 1, outline); //Bottomleft round pixel
- rect(x + width - 2, y + 1, 1, 1, outline); //Topright round pixel
- rect(x + width - 2, y + height - 2, 1, 1, outline); //Bottomright round pixel
+ coloredRect(x + 3, y + 3, width - 6, height - 6, panel); //Main panel area
+
+ coloredRect(x + 2, y + 1, width - 4, 2, hilight); //Top hilight
+ coloredRect(x + 2, y + height - 3, width - 4, 2, shadow); //Bottom shadow
+ coloredRect(x + 1, y + 2, 2, height - 4, hilight); //Left hilight
+ coloredRect(x + width - 3, y + 2, 2, height - 4, shadow); //Right shadow
+ coloredRect(x + width - 3, y + 2, 1, 1, panel); //Topright non-hilight/non-shadow transition pixel
+ coloredRect(x + 2, y + height - 3, 1, 1, panel); //Bottomleft non-hilight/non-shadow transition pixel
+ coloredRect(x + 3, y + 3, 1, 1, hilight); //Topleft round hilight pixel
+ coloredRect(x + width - 4, y + height - 4, 1, 1, shadow); //Bottomright round shadow pixel
+
+ coloredRect(x + 2, y, width - 4, 1, outline); //Top outline
+ coloredRect(x, y + 2, 1, height - 4, outline); //Left outline
+ coloredRect(x + width - 1, y + 2, 1, height - 4, outline); //Right outline
+ coloredRect(x + 2, y + height - 1, width - 4, 1, outline); //Bottom outline
+ coloredRect(x + 1, y + 1, 1, 1, outline); //Topleft round pixel
+ coloredRect(x + 1, y + height - 2, 1, 1, outline); //Bottomleft round pixel
+ coloredRect(x + width - 2, y + 1, 1, 1, outline); //Topright round pixel
+ coloredRect(x + width - 2, y + height - 2, 1, 1, outline); //Bottomright round pixel
}
/**
@@ -190,11 +188,11 @@ public class ScreenDrawing {
* @param bottomright color of the bottom/right bevel
*/
public static void drawBeveledPanel(int x, int y, int width, int height, int topleft, int panel, int bottomright) {
- rect(x, y, width, height, panel); //Center panel
- rect(x, y, width - 1, 1, topleft); //Top shadow
- rect(x, y + 1, 1, height - 2, topleft); //Left shadow
- rect(x + width - 1, y + 1, 1, height - 1, bottomright); //Right hilight
- rect(x + 1, y + height - 1, width - 1, 1, bottomright); //Bottom hilight
+ coloredRect(x, y, width, height, panel); //Center panel
+ coloredRect(x, y, width - 1, 1, topleft); //Top shadow
+ coloredRect(x, y + 1, 1, height - 2, topleft); //Left shadow
+ coloredRect(x + width - 1, y + 1, 1, height - 1, bottomright); //Right hilight
+ coloredRect(x + 1, y + height - 1, width - 1, 1, bottomright); //Bottom hilight
}
public static void drawString(String s, int x, int y, int color) {
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java
index 335c093..5a7e236 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java
@@ -2,7 +2,7 @@ package io.github.cottonmc.cotton.gui.client.modmenu;
import java.util.function.Function;
-import io.github.cottonmc.cotton.gui.client.ClientCottonScreen;
+import io.github.cottonmc.cotton.gui.client.CottonClientScreen;
import io.github.cottonmc.cotton.gui.client.LibGuiClient;
import io.github.prospector.modmenu.api.ModMenuApi;
import net.minecraft.client.gui.screen.Screen;
@@ -17,7 +17,7 @@ public class ModMenuSupport implements ModMenuApi {
@Override
public Function<Screen, ? extends Screen> getConfigScreenFactory() {
- return screen -> new ClientCottonScreen(new TranslatableText("options.libgui.libgui_settings"), new ConfigGui(screen)) {
+ return screen -> new CottonClientScreen(new TranslatableText("options.libgui.libgui_settings"), new ConfigGui(screen)) {
public void onClose() {
this.minecraft.openScreen(screen);
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java
index d68b1db..1428c1b 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java
@@ -98,7 +98,7 @@ public class WKirbSprite extends WWidget {
}
float offset = KIRB_WIDTH * currentFrame;
- ScreenDrawing.rect(KIRB, x, y+8, 32, 32, offset, 0, offset+KIRB_WIDTH, 1, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x, y+8, 32, 32, KIRB, offset, 0, offset+KIRB_WIDTH, 1, 0xFFFFFFFF);
long elapsed = now - lastFrame;
currentFrameTime += elapsed;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java
index 7c05189..0311a73 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java
@@ -65,9 +65,9 @@ public class WBar extends WWidget {
@Override
public void paintBackground(int x, int y) {
if (bg!=null) {
- ScreenDrawing.rect(bg, x, y, getWidth(), getHeight(), 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x, y, getWidth(), getHeight(), bg, 0xFFFFFFFF);
} else {
- ScreenDrawing.rect(x, y, getWidth(), getHeight(), ScreenDrawing.colorAtOpacity(0x000000, 0.25f));
+ ScreenDrawing.coloredRect(x, y, getWidth(), getHeight(), ScreenDrawing.colorAtOpacity(0x000000, 0.25f));
}
float percent = properties.get(field) / (float) properties.get(max);
@@ -87,25 +87,25 @@ public class WBar extends WWidget {
int top = y + getHeight();
top -= barSize;
if (bar!=null) {
- ScreenDrawing.rect(bar, left, top, getWidth(), barSize, 0, 1 - percent, 1, 1, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(left, top, getWidth(), barSize, bar, 0, 1 - percent, 1, 1, 0xFFFFFFFF);
} else {
- ScreenDrawing.rect(left, top, getWidth(), barSize, ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f));
+ ScreenDrawing.coloredRect(left, top, getWidth(), barSize, ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f));
}
break;
}
case RIGHT: {
if (bar!=null) {
- ScreenDrawing.rect(bar, x, y, barSize, getHeight(), 0, 0, percent, 1, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x, y, barSize, getHeight(), bar, 0, 0, percent, 1, 0xFFFFFFFF);
} else {
- ScreenDrawing.rect(x, y, barSize, getHeight(), ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f));
+ ScreenDrawing.coloredRect(x, y, barSize, getHeight(), ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f));
}
break;
}
case DOWN: {
if (bar!=null) {
- ScreenDrawing.rect(bar, x, y, getWidth(), barSize, 0, 0, 1, percent, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x, y, getWidth(), barSize, bar, 0, 0, 1, percent, 0xFFFFFFFF);
} else {
- ScreenDrawing.rect(x, y, getWidth(), barSize, ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f));
+ ScreenDrawing.coloredRect(x, y, getWidth(), barSize, ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f));
}
break;
}
@@ -114,9 +114,9 @@ public class WBar extends WWidget {
int top = y;
left -= barSize;
if (bar!=null) {
- ScreenDrawing.rect(bar, left, top, barSize, getHeight(), 1 - percent, 0, 1, 1, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(left, top, barSize, getHeight(), bar, 1 - percent, 0, 1, 1, 0xFFFFFFFF);
} else {
- ScreenDrawing.rect(left, top, barSize, getHeight(), ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f));
+ ScreenDrawing.coloredRect(left, top, barSize, getHeight(), ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f));
}
break;
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
index 32558a9..7c3a3b5 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java
@@ -48,8 +48,8 @@ public class WButton extends WWidget {
float buttonEndLeft = (200-(getWidth()/2)) * px;
- ScreenDrawing.rect(AbstractButtonWidget.WIDGETS_LOCATION, x, y, getWidth()/2, 20, buttonLeft, buttonTop, buttonLeft+buttonWidth, buttonTop+buttonHeight, 0xFFFFFFFF);
- ScreenDrawing.rect(AbstractButtonWidget.WIDGETS_LOCATION, x+(getWidth()/2), y, getWidth()/2, 20, buttonEndLeft, buttonTop, 200*px, buttonTop+buttonHeight, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x, y, getWidth()/2, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonLeft, buttonTop, buttonLeft+buttonWidth, buttonTop+buttonHeight, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x+(getWidth()/2), y, getWidth()/2, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonEndLeft, buttonTop, 200*px, buttonTop+buttonHeight, 0xFFFFFFFF);
if (label!=null) {
int color = 0xE0E0E0;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
index 37fe464..16a5f60 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabeledSlider.java
@@ -84,7 +84,7 @@ public class WLabeledSlider extends WAbstractSlider {
if (thumbState == 1 && isFocused()) {
float px = 1 / 32f;
- ScreenDrawing.rect(WSlider.TEXTURE, x + thumbX, y + thumbY, thumbWidth, thumbHeight, 24*px, 0*px, 32*px, 20*px, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x + thumbX, y + thumbY, thumbWidth, thumbHeight, WSlider.TEXTURE, 24*px, 0*px, 32*px, 20*px, 0xFFFFFFFF);
}
if (label != null) {
@@ -105,8 +105,8 @@ public class WLabeledSlider extends WAbstractSlider {
float buttonHeight = 20 * px;
float buttonEndLeft = (200 - halfWidth) * px;
- ScreenDrawing.rect(AbstractButtonWidget.WIDGETS_LOCATION, x, y, halfWidth, 20, buttonLeft, buttonTop, buttonLeft + buttonWidth, buttonTop + buttonHeight, 0xFFFFFFFF);
- ScreenDrawing.rect(AbstractButtonWidget.WIDGETS_LOCATION, x + halfWidth, y, halfWidth, 20, buttonEndLeft, buttonTop, 200 * px, buttonTop + buttonHeight, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x, y, halfWidth, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonLeft, buttonTop, buttonLeft + buttonWidth, buttonTop + buttonHeight, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x + halfWidth, y, halfWidth, 20, AbstractButtonWidget.WIDGETS_LOCATION, buttonEndLeft, buttonTop, 200 * px, buttonTop + buttonHeight, 0xFFFFFFFF);
}
@FunctionalInterface
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java
index 39c416c..26caa8b 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java
@@ -26,9 +26,9 @@ public class WScrollBar extends WWidget {
int color = 0xFF_FFFFFF;
if (axis==Axis.HORIZONTAL) {
- ScreenDrawing.rect(x+1+getHandlePosition(), y+1, getHandleSize(), height-2, color);
+ ScreenDrawing.coloredRect(x+1+getHandlePosition(), y+1, getHandleSize(), height-2, color);
} else {
- ScreenDrawing.rect(x+1, y+1+getHandlePosition(), width-2, getHandleSize(), color);
+ ScreenDrawing.coloredRect(x+1, y+1+getHandlePosition(), width-2, getHandleSize(), color);
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java
index c57b705..e9c862f 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java
@@ -63,27 +63,27 @@ public class WSlider extends WAbstractSlider {
thumbY = height - THUMB_SIZE + 1 - (int) (coordToValueRatio * (value - min));
thumbXOffset = 0;
- ScreenDrawing.rect(TEXTURE, trackX, y + 1, TRACK_WIDTH, 1, 16*px, 0*px, 22*px, 1*px, 0xFFFFFFFF);
- ScreenDrawing.rect(TEXTURE, trackX, y + 2, TRACK_WIDTH, height - 2, 16*px, 1*px, 22*px, 2*px, 0xFFFFFFFF);
- ScreenDrawing.rect(TEXTURE, trackX, y + height, TRACK_WIDTH, 1, 16*px, 2*px, 22*px, 3*px, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(trackX, y + 1, TRACK_WIDTH, 1, TEXTURE, 16*px, 0*px, 22*px, 1*px, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(trackX, y + 2, TRACK_WIDTH, height - 2, TEXTURE, 16*px, 1*px, 22*px, 2*px, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(trackX, y + height, TRACK_WIDTH, 1, TEXTURE, 16*px, 2*px, 22*px, 3*px, 0xFFFFFFFF);
} else {
int trackY = y + height / 2 - TRACK_WIDTH / 2;
thumbX = Math.round(coordToValueRatio * (value - min));
thumbY = height / 2 - THUMB_SIZE / 2;
thumbXOffset = 8;
- ScreenDrawing.rect(TEXTURE, x, trackY, 1, TRACK_WIDTH, 16*px, 3*px, 17*px, 9*px, 0xFFFFFFFF);
- ScreenDrawing.rect(TEXTURE, x + 1, trackY, width - 2, TRACK_WIDTH, 17*px, 3*px, 18*px, 9*px, 0xFFFFFFFF);
- ScreenDrawing.rect(TEXTURE, x + width - 1, trackY, 1, TRACK_WIDTH, 18*px, 3*px, 19*px, 9*px, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x, trackY, 1, TRACK_WIDTH, TEXTURE, 16*px, 3*px, 17*px, 9*px, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x + 1, trackY, width - 2, TRACK_WIDTH, TEXTURE, 17*px, 3*px, 18*px, 9*px, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x + width - 1, trackY, 1, TRACK_WIDTH, TEXTURE, 18*px, 3*px, 19*px, 9*px, 0xFFFFFFFF);
}
// thumbState values:
// 0: default, 1: dragging, 2: hovered
int thumbState = dragging ? 1 : (mouseX >= thumbX && mouseX <= thumbX + THUMB_SIZE && mouseY >= thumbY && mouseY <= thumbY + THUMB_SIZE ? 2 : 0);
- ScreenDrawing.rect(TEXTURE, x + thumbX, y + thumbY, THUMB_SIZE, THUMB_SIZE, thumbXOffset*px, 0*px + thumbState * 8*px, (thumbXOffset + 8)*px, 8*px + thumbState * 8*px, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x + thumbX, y + thumbY, THUMB_SIZE, THUMB_SIZE, TEXTURE, thumbXOffset*px, 0*px + thumbState * 8*px, (thumbXOffset + 8)*px, 8*px + thumbState * 8*px, 0xFFFFFFFF);
if (thumbState == 0 && isFocused()) {
- ScreenDrawing.rect(TEXTURE, x + thumbX, y + thumbY, THUMB_SIZE, THUMB_SIZE, 0*px, 24*px, 8*px, 32*px, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x + thumbX, y + thumbY, THUMB_SIZE, THUMB_SIZE, TEXTURE, 0*px, 24*px, 8*px, 32*px, 0xFFFFFFFF);
}
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSprite.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSprite.java
index b3ce4cf..44f8998 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSprite.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSprite.java
@@ -75,7 +75,7 @@ public class WSprite extends WWidget {
@Override
public void paintBackground(int x, int y) {
if (singleImage) {
- ScreenDrawing.rect(frames[0], x, y, getWidth(), getHeight(), tint);
+ ScreenDrawing.texturedRect(x, y, getWidth(), getHeight(), frames[0], tint);
} else {
//grab the system time at the very start of the frame.
long now = System.nanoTime() / 1_000_000L;
@@ -85,7 +85,7 @@ public class WSprite extends WWidget {
if (!inBounds) currentFrame = 0;
//assemble and draw the frame calculated last iteration.
Identifier currentFrameTex = frames[currentFrame];
- ScreenDrawing.rect(currentFrameTex, x, y, getWidth(), getHeight(), tint);
+ ScreenDrawing.texturedRect(x, y, getWidth(), getHeight(), currentFrameTex, tint);
//calculate how much time has elapsed since the last animation change, and change the frame if necessary.
long elapsed = now - lastFrame;
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java
index 99ea221..d8d5955 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java
@@ -8,14 +8,16 @@ import javax.annotation.Nullable;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
-import com.mojang.blaze3d.platform.GlStateManager;
+import com.mojang.blaze3d.systems.RenderSystem;
import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import net.minecraft.class_4493;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
+import net.minecraft.client.gl.GlProgramManager;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
@@ -313,8 +315,8 @@ public class WTextField extends WWidget {
if (this.font==null) this.font = MinecraftClient.getInstance().textRenderer;
int borderColor = (this.isFocused()) ? 0xFF_FFFFA0 : 0xFF_A0A0A0;
- ScreenDrawing.rect(x-1, y-1, width+2, height+2, borderColor);
- ScreenDrawing.rect(x, y, width, height, 0xFF000000);
+ ScreenDrawing.coloredRect(x-1, y-1, width+2, height+2, borderColor);
+ ScreenDrawing.coloredRect(x, y, width, height, 0xFF000000);
int textColor = this.editable ? this.enabledColor : this.uneditableColor;
@@ -368,7 +370,7 @@ public class WTextField extends WWidget {
//} else {
// caretLoc = textX+caretLoc-1;
//}
- ScreenDrawing.rect(preCursorAdvance-1, textY-2, 1, 12, 0xFFD0D0D0);
+ ScreenDrawing.coloredRect(preCursorAdvance-1, textY-2, 1, 12, 0xFFD0D0D0);
//if (boolean_3) {
// int var10001 = int_7 - 1;
// var10002 = int_9 + 1;
@@ -402,18 +404,18 @@ public class WTextField extends WWidget {
private void invertedRect(int x, int y, int width, int height) {
Tessellator tessellator_1 = Tessellator.getInstance();
BufferBuilder bufferBuilder_1 = tessellator_1.getBufferBuilder();
- GlStateManager.color4f(0.0F, 0.0F, 255.0F, 255.0F);
- GlStateManager.disableTexture();
- GlStateManager.enableColorLogicOp();
- GlStateManager.logicOp(GlStateManager.LogicOp.OR_REVERSE);
+ RenderSystem.color4f(0.0F, 0.0F, 255.0F, 255.0F);
+ RenderSystem.disableTexture();
+ RenderSystem.enableColorLogicOp();
+ RenderSystem.logicOp(class_4493.LogicOp.OR_REVERSE);
bufferBuilder_1.begin(GL11.GL_QUADS, VertexFormats.POSITION);
bufferBuilder_1.vertex(x, y+height, 0.0D).next();
bufferBuilder_1.vertex(x+width, y+height, 0.0D).next();
bufferBuilder_1.vertex(x+width, y, 0.0D).next();
bufferBuilder_1.vertex(x, y, 0.0D).next();
tessellator_1.draw();
- GlStateManager.disableColorLogicOp();
- GlStateManager.enableTexture();
+ RenderSystem.disableColorLogicOp();
+ RenderSystem.enableTexture();
}
public WTextField setTextPredicate(Predicate<String> predicate_1) {
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java
index 846f032..82813ca 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java
@@ -87,7 +87,7 @@ public class WToggleButton extends WWidget {
@Override
public void paintBackground(int x, int y) {
- ScreenDrawing.rect(isOn ? DEFAULT_ON_IMAGE : DEFAULT_OFF_IMAGE, x, y, 18, 18, 0xFFFFFFFF);
+ ScreenDrawing.texturedRect(x, y, 18, 18, isOn ? DEFAULT_ON_IMAGE : DEFAULT_OFF_IMAGE, 0xFFFFFFFF);
if (label!=null) {