scaling, but click issue
This commit is contained in:
@@ -7,6 +7,7 @@ import org.saturnclient.saturnclient.config.Property;
|
||||
import org.saturnclient.ui.SaturnUi;
|
||||
import org.saturnclient.ui.Textures;
|
||||
import org.saturnclient.ui.animations.Slide;
|
||||
import org.saturnclient.ui.components.SaturnFloat;
|
||||
import org.saturnclient.ui.components.SaturnInteger;
|
||||
import org.saturnclient.ui.components.SaturnToggle;
|
||||
import org.saturnclient.ui.widgets.SaturnScroll;
|
||||
@@ -30,14 +31,14 @@ public class ConfigEditor extends SaturnUi {
|
||||
int rectX = (width - rectWidth) / 2;
|
||||
int rectY = (height - rectHeight + 15) / 2;
|
||||
|
||||
// draw(
|
||||
// new SaturnSprite(Textures.SETTINGS_BG)
|
||||
// .setX(rectX)
|
||||
// .setY(rectY)
|
||||
// .setWidth(rectWidth)
|
||||
// .setHeight(rectHeight)
|
||||
// .setAnimations(new Slide(1, 10))
|
||||
// );
|
||||
draw(
|
||||
new SaturnSprite(Textures.SETTINGS_BG)
|
||||
.setX(rectX)
|
||||
.setY(rectY)
|
||||
.setWidth(rectWidth)
|
||||
.setHeight(rectHeight)
|
||||
.setAnimations(new Slide(1, 10))
|
||||
);
|
||||
|
||||
int tabsX = (width - 43) / 2;
|
||||
int tabsY = rectY - 17;
|
||||
@@ -72,7 +73,7 @@ public class ConfigEditor extends SaturnUi {
|
||||
}
|
||||
|
||||
int modX = ((rectWidth / 2) - 17) * col;
|
||||
int modY = 12 * row;
|
||||
int modY = 14 * row;
|
||||
|
||||
switch (prop.getType()) {
|
||||
case BOOLEAN:
|
||||
@@ -88,6 +89,7 @@ public class ConfigEditor extends SaturnUi {
|
||||
)
|
||||
.setX(modX + 18)
|
||||
.setY(modY)
|
||||
.setScale(0.8f)
|
||||
);
|
||||
break;
|
||||
case INTEGER:
|
||||
@@ -98,6 +100,7 @@ public class ConfigEditor extends SaturnUi {
|
||||
)
|
||||
.setX(modX)
|
||||
.setY(modY)
|
||||
.setScale(0.8f)
|
||||
);
|
||||
|
||||
configScroll.draw(
|
||||
@@ -105,7 +108,27 @@ public class ConfigEditor extends SaturnUi {
|
||||
(Property<Integer>) prop,
|
||||
(rectWidth / 2) - 17,
|
||||
modY,
|
||||
40
|
||||
70
|
||||
)
|
||||
);
|
||||
break;
|
||||
case FLOAT:
|
||||
configScroll.draw(
|
||||
new SaturnText(
|
||||
propName.substring(0, 1).toUpperCase() +
|
||||
propName.substring(1)
|
||||
)
|
||||
.setX(modX)
|
||||
.setY(modY)
|
||||
.setScale(0.8f)
|
||||
);
|
||||
|
||||
configScroll.draw(
|
||||
new SaturnFloat(
|
||||
(Property<Float>) prop,
|
||||
(rectWidth / 2) - 17,
|
||||
modY,
|
||||
70
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -1,18 +1,55 @@
|
||||
package org.saturnclient.saturnmods;
|
||||
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.saturnclient.menus.HudEditor;
|
||||
import org.saturnclient.saturnmods.mods.ArmorDisplay;
|
||||
import org.saturnclient.saturnmods.mods.Coordinates;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.saturnclient.menus.HudEditor;
|
||||
import org.saturnclient.saturnmods.mods.ArmorDisplay;
|
||||
import org.saturnclient.saturnmods.mods.Coordinates;
|
||||
|
||||
public class ModManager {
|
||||
|
||||
public static SaturnMod[] MODS = {
|
||||
new Coordinates(),
|
||||
new ArmorDisplay()
|
||||
new Coordinates(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
new ArmorDisplay(),
|
||||
};
|
||||
|
||||
public static void init() {
|
||||
@@ -20,7 +57,10 @@ public class ModManager {
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
TextRenderer textRenderer = client.textRenderer;
|
||||
|
||||
if (textRenderer != null && !(client.currentScreen instanceof HudEditor)) {
|
||||
if (
|
||||
textRenderer != null &&
|
||||
!(client.currentScreen instanceof HudEditor)
|
||||
) {
|
||||
SaturnClient.textRenderer = textRenderer;
|
||||
|
||||
for (SaturnMod m : MODS) {
|
||||
|
||||
@@ -7,11 +7,13 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
|
||||
public class SaturnUi extends Screen {
|
||||
|
||||
@@ -66,7 +68,25 @@ public class SaturnUi extends Screen {
|
||||
widget.x + widget.width > mouseX &&
|
||||
widget.y < mouseY &&
|
||||
widget.y + widget.height > mouseY;
|
||||
widget.render(context, isMouseInside, mouseX, mouseY);
|
||||
|
||||
SaturnClient.LOGGER.info(
|
||||
"Render mouse X: " +
|
||||
(mouseX - widget.x) +
|
||||
", mouse Y: " +
|
||||
(mouseY - widget.y)
|
||||
);
|
||||
|
||||
MatrixStack matrices = context.getMatrices();
|
||||
matrices.push();
|
||||
matrices.translate(widget.x, widget.y, 0);
|
||||
matrices.scale(widget.scale, widget.scale, 1.0f);
|
||||
widget.render(
|
||||
context,
|
||||
isMouseInside,
|
||||
mouseX - widget.x,
|
||||
mouseY - widget.y
|
||||
);
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,14 +97,27 @@ public class SaturnUi extends Screen {
|
||||
widget.focused = false;
|
||||
if (!widget.visible) continue;
|
||||
|
||||
double adjustedMouseX = (mouseX - widget.x) / widget.scale;
|
||||
double adjustedMouseY = (mouseY - widget.y) / widget.scale;
|
||||
boolean isMouseInside =
|
||||
widget.x < mouseX &&
|
||||
widget.x + widget.width > mouseX &&
|
||||
widget.y < mouseY &&
|
||||
widget.y + widget.height > mouseY;
|
||||
adjustedMouseX >= 0 &&
|
||||
adjustedMouseX <= widget.width &&
|
||||
adjustedMouseY >= 0 &&
|
||||
adjustedMouseY <= widget.height;
|
||||
|
||||
SaturnClient.LOGGER.info(
|
||||
"CLick mouse X: " +
|
||||
adjustedMouseX +
|
||||
", mouse Y: " +
|
||||
adjustedMouseY
|
||||
);
|
||||
|
||||
if (isMouseInside) {
|
||||
widget.focused = true;
|
||||
widget.click((int) mouseX, (int) mouseY);
|
||||
widget.click(
|
||||
((int) mouseX) - widget.x,
|
||||
((int) mouseY) - widget.y
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,16 +148,18 @@ public class SaturnUi extends Screen {
|
||||
double verticalAmount
|
||||
) {
|
||||
for (SaturnWidget widget : new ArrayList<>(widgets)) {
|
||||
double adjustedMouseX = (mouseX - widget.x) / widget.scale;
|
||||
double adjustedMouseY = (mouseY - widget.y) / widget.scale;
|
||||
boolean isMouseInside =
|
||||
widget.x < mouseX &&
|
||||
widget.x + widget.width > mouseX &&
|
||||
widget.y < mouseY &&
|
||||
widget.y + widget.height > mouseY;
|
||||
adjustedMouseX >= 0 &&
|
||||
adjustedMouseX <= widget.width &&
|
||||
adjustedMouseY >= 0 &&
|
||||
adjustedMouseY <= widget.height;
|
||||
|
||||
if (isMouseInside) {
|
||||
widget.mouseScrolled(
|
||||
(int) mouseX,
|
||||
(int) mouseY,
|
||||
((int) mouseX) - widget.x,
|
||||
((int) mouseY) - widget.y,
|
||||
horizontalAmount,
|
||||
verticalAmount
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ public class SaturnWidget {
|
||||
public int width = 0;
|
||||
public int height = 0;
|
||||
public float alpha = 1.0f;
|
||||
public float scale = 1.0f;
|
||||
public SaturnAnimation[] animations = null;
|
||||
public boolean visible = true;
|
||||
public boolean focused = false;
|
||||
@@ -72,4 +73,9 @@ public class SaturnWidget {
|
||||
this.visible = visible;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SaturnWidget setScale(float scale) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class SaturnInteger extends SaturnWidget {
|
||||
this.prop = prop;
|
||||
this.text = String.valueOf(prop.value);
|
||||
this.height = textRenderer.fontHeight + 4;
|
||||
this.scale = 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +40,7 @@ public class SaturnInteger extends SaturnWidget {
|
||||
for (int i = 0; i < visibleText.length(); i++) {
|
||||
textWidth = textRenderer.getWidth(visibleText.substring(0, i + 1));
|
||||
|
||||
if (textWidth > (mouseX - x)) {
|
||||
if (textWidth > mouseX) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -102,12 +103,12 @@ public class SaturnInteger extends SaturnWidget {
|
||||
) {
|
||||
context.drawGuiTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
Textures.BUTTON,
|
||||
this.x,
|
||||
this.y,
|
||||
Textures.BUTTON_BORDER,
|
||||
0,
|
||||
0,
|
||||
this.width,
|
||||
this.height,
|
||||
SaturnClient.getWhite(this.alpha)
|
||||
focused ? SaturnClient.COLOR : SaturnClient.getWhite(this.alpha)
|
||||
);
|
||||
|
||||
int scrollOffset = getScrollOffset();
|
||||
@@ -117,15 +118,14 @@ public class SaturnInteger extends SaturnWidget {
|
||||
context.drawText(
|
||||
textRenderer,
|
||||
SaturnUi.text(visibleText),
|
||||
x + 2,
|
||||
y + 2,
|
||||
2,
|
||||
2,
|
||||
textColor,
|
||||
false
|
||||
);
|
||||
|
||||
if (focused) {
|
||||
int cursorX =
|
||||
x +
|
||||
2 +
|
||||
textRenderer.getWidth(
|
||||
SaturnUi.text(
|
||||
@@ -134,9 +134,9 @@ public class SaturnInteger extends SaturnWidget {
|
||||
);
|
||||
context.fill(
|
||||
cursorX,
|
||||
y + 2,
|
||||
2,
|
||||
cursorX + 1,
|
||||
y + textRenderer.fontHeight + 4,
|
||||
textRenderer.fontHeight + 4,
|
||||
0xFFFFFFFF
|
||||
);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ public class SaturnModComp extends SaturnWidget {
|
||||
context.drawTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
Textures.MOD_BG,
|
||||
x,
|
||||
y,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
86,
|
||||
@@ -55,8 +55,8 @@ public class SaturnModComp extends SaturnWidget {
|
||||
context.drawTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
Textures.MOD,
|
||||
x,
|
||||
y,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
86,
|
||||
@@ -69,8 +69,8 @@ public class SaturnModComp extends SaturnWidget {
|
||||
context.drawTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
mod.getIconTexture(),
|
||||
x + 4,
|
||||
y + 4,
|
||||
4,
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
size,
|
||||
@@ -83,8 +83,8 @@ public class SaturnModComp extends SaturnWidget {
|
||||
context.drawText(
|
||||
SaturnClient.textRenderer,
|
||||
SaturnUi.text(mod.getName()),
|
||||
x + 20,
|
||||
y + (21 - SaturnClient.textRenderer.fontHeight) / 2,
|
||||
20,
|
||||
(21 - SaturnClient.textRenderer.fontHeight) / 2,
|
||||
color,
|
||||
false
|
||||
);
|
||||
@@ -92,8 +92,8 @@ public class SaturnModComp extends SaturnWidget {
|
||||
context.drawTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
Textures.SETTINGS,
|
||||
x + 77,
|
||||
y + 11,
|
||||
77,
|
||||
11,
|
||||
0,
|
||||
0,
|
||||
7,
|
||||
@@ -117,8 +117,8 @@ public class SaturnModComp extends SaturnWidget {
|
||||
}
|
||||
|
||||
public boolean settingsHovering(int mouseX, int mouseY) {
|
||||
int sX = x + 77;
|
||||
int sY = y + 11;
|
||||
int sX = 77;
|
||||
int sY = 11;
|
||||
int size = 7;
|
||||
|
||||
return (
|
||||
|
||||
@@ -35,8 +35,8 @@ public class SaturnToggle extends SaturnWidget {
|
||||
context.drawTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
Textures.TOGGLE_BG,
|
||||
x,
|
||||
y + 1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
w,
|
||||
@@ -49,8 +49,8 @@ public class SaturnToggle extends SaturnWidget {
|
||||
context.drawTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
Textures.TOGGLE_INDICATOR,
|
||||
prop.value ? x + 5 : x,
|
||||
y,
|
||||
prop.value ? 5 : 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
s,
|
||||
|
||||
@@ -54,8 +54,8 @@ public class SaturnButton extends SaturnWidget {
|
||||
context.drawGuiTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
Textures.BUTTON,
|
||||
this.x,
|
||||
this.y,
|
||||
0,
|
||||
0,
|
||||
this.width,
|
||||
this.height,
|
||||
SaturnClient.getWhite(this.alpha)
|
||||
@@ -65,8 +65,8 @@ public class SaturnButton extends SaturnWidget {
|
||||
context.drawGuiTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
Textures.BUTTON_BORDER,
|
||||
this.x,
|
||||
this.y,
|
||||
0,
|
||||
0,
|
||||
this.width,
|
||||
this.height,
|
||||
hoverColor
|
||||
@@ -79,13 +79,11 @@ public class SaturnButton extends SaturnWidget {
|
||||
context.drawText(
|
||||
minecraftClient.textRenderer,
|
||||
SaturnUi.text(text),
|
||||
this.x +
|
||||
((this.width -
|
||||
minecraftClient.textRenderer.getWidth(
|
||||
SaturnUi.text(text)
|
||||
)) /
|
||||
2),
|
||||
this.y +
|
||||
((this.height - minecraftClient.textRenderer.fontHeight + 1) /
|
||||
2),
|
||||
hovering
|
||||
|
||||
@@ -41,8 +41,8 @@ public class SaturnClickableImage extends SaturnWidget {
|
||||
context.drawTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
texture,
|
||||
x,
|
||||
y,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
|
||||
@@ -41,8 +41,8 @@ public class SaturnClickableSprite extends SaturnWidget {
|
||||
context.drawGuiTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
sprite,
|
||||
this.x,
|
||||
this.y,
|
||||
0,
|
||||
0,
|
||||
this.width,
|
||||
this.height,
|
||||
(hovering || selected ? hoverColor : color) |
|
||||
|
||||
@@ -25,8 +25,8 @@ public class SaturnImage extends SaturnWidget {
|
||||
context.drawTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
sprite,
|
||||
x,
|
||||
y,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
|
||||
@@ -53,8 +53,8 @@ public class SaturnImageButton extends SaturnButton {
|
||||
context.drawTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
sprite,
|
||||
(x + (width - imageWidth) / 2),
|
||||
(y + (height - imageHeight) / 2),
|
||||
((width - imageWidth) / 2),
|
||||
((height - imageHeight) / 2),
|
||||
0,
|
||||
0,
|
||||
imageWidth,
|
||||
|
||||
@@ -22,8 +22,8 @@ public class SaturnInputBox extends SaturnWidget {
|
||||
|
||||
public SaturnInputBox(
|
||||
String placeholder,
|
||||
int x,
|
||||
int y,
|
||||
int x,
|
||||
int width,
|
||||
int height
|
||||
) {
|
||||
@@ -83,8 +83,8 @@ public class SaturnInputBox extends SaturnWidget {
|
||||
context.drawGuiTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
Textures.BUTTON,
|
||||
this.x,
|
||||
this.y,
|
||||
0,
|
||||
0,
|
||||
this.width,
|
||||
this.height,
|
||||
SaturnClient.getWhite(this.alpha)
|
||||
@@ -97,28 +97,21 @@ public class SaturnInputBox extends SaturnWidget {
|
||||
context.drawText(
|
||||
textRenderer,
|
||||
SaturnUi.text(visibleText),
|
||||
x + 5,
|
||||
y + 5,
|
||||
5,
|
||||
5,
|
||||
textColor,
|
||||
false
|
||||
);
|
||||
|
||||
if (focused) {
|
||||
int cursorX =
|
||||
x +
|
||||
5 +
|
||||
textRenderer.getWidth(
|
||||
SaturnUi.text(
|
||||
visibleText.substring(0, cursorPosition - scrollOffset)
|
||||
)
|
||||
);
|
||||
context.fill(
|
||||
cursorX,
|
||||
y + 3,
|
||||
cursorX + 1,
|
||||
y + height - 3,
|
||||
0xFFFFFFFF
|
||||
);
|
||||
context.fill(cursorX, 3, cursorX + 1, height - 3, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.saturnclient.ui.widgets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.ui.SaturnWidget;
|
||||
|
||||
public class SaturnScroll extends SaturnWidget {
|
||||
@@ -18,6 +20,8 @@ public class SaturnScroll extends SaturnWidget {
|
||||
double horizontalAmount,
|
||||
double verticalAmount
|
||||
) {
|
||||
verticalAmount *= 2;
|
||||
|
||||
if (scroll - verticalAmount <= 0) {
|
||||
scroll = 0;
|
||||
} else if (scroll - verticalAmount >= maxScroll) {
|
||||
@@ -34,31 +38,32 @@ public class SaturnScroll extends SaturnWidget {
|
||||
int mouseX,
|
||||
int mouseY
|
||||
) {
|
||||
context.enableScissor(x, y, x + width, y + height);
|
||||
context.enableScissor(0, 0, width, height);
|
||||
|
||||
for (SaturnWidget child : children) {
|
||||
if (!child.visible) continue;
|
||||
|
||||
int xx = child.x;
|
||||
int yy = child.y;
|
||||
|
||||
child.x += x;
|
||||
child.y += y - scroll;
|
||||
|
||||
boolean isMouseInside =
|
||||
child.x < mouseX &&
|
||||
child.x + child.width > mouseX &&
|
||||
child.y < mouseY &&
|
||||
child.y + child.height > mouseY;
|
||||
|
||||
if (child.y < y + height && child.y + child.height > y) {
|
||||
child.render(context, isMouseInside, mouseX, mouseY);
|
||||
if (child.y - scroll < height && child.y + child.height > scroll) {
|
||||
MatrixStack matrices = context.getMatrices();
|
||||
matrices.push();
|
||||
matrices.translate(child.x, child.y - scroll, 0);
|
||||
matrices.scale(child.scale, child.scale, 1.0f);
|
||||
|
||||
child.render(
|
||||
context,
|
||||
isMouseInside,
|
||||
mouseX - child.x,
|
||||
mouseY - (child.y - scroll)
|
||||
);
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
child.x = xx;
|
||||
child.y = yy;
|
||||
}
|
||||
|
||||
context.disableScissor();
|
||||
}
|
||||
|
||||
@@ -89,28 +94,11 @@ public class SaturnScroll extends SaturnWidget {
|
||||
|
||||
@Override
|
||||
public void keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
System.out.println(
|
||||
"[SaturnScroll] Key Pressed: keyCode=" +
|
||||
keyCode +
|
||||
", scanCode=" +
|
||||
scanCode +
|
||||
", modifiers=" +
|
||||
modifiers
|
||||
);
|
||||
|
||||
for (SaturnWidget child : children) {
|
||||
if (!child.visible || !child.focused) {
|
||||
System.out.println(
|
||||
"[SaturnScroll] Skipping child " +
|
||||
child +
|
||||
" (Not visible or focused)"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
"[SaturnScroll] Passing key event to child: " + child
|
||||
);
|
||||
child.keyPressed(keyCode, scanCode, modifiers);
|
||||
break;
|
||||
}
|
||||
@@ -118,21 +106,11 @@ public class SaturnScroll extends SaturnWidget {
|
||||
|
||||
@Override
|
||||
public void charTyped(char typedChar) {
|
||||
System.out.println("[SaturnScroll] Char Typed: '" + typedChar + "'");
|
||||
|
||||
for (SaturnWidget child : children) {
|
||||
if (!child.visible || !child.focused) {
|
||||
System.out.println(
|
||||
"[SaturnScroll] Skipping child " +
|
||||
child +
|
||||
" (Not visible or focused)"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
"[SaturnScroll] Passing char event to child: " + child
|
||||
);
|
||||
child.charTyped(typedChar);
|
||||
break;
|
||||
}
|
||||
@@ -150,22 +128,20 @@ public class SaturnScroll extends SaturnWidget {
|
||||
for (SaturnWidget widget : children) {
|
||||
widget.focused = false;
|
||||
if (!widget.visible) {
|
||||
System.out.println(
|
||||
"[SaturnScroll] Skipping hidden child: " + widget
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
double adjustedMouseX = (mouseX - widget.x) / widget.scale;
|
||||
double adjustedMouseY = (mouseY - widget.y) / widget.scale;
|
||||
boolean isMouseInside =
|
||||
widget.x < mouseX &&
|
||||
widget.x + widget.width > mouseX &&
|
||||
widget.y < mouseY &&
|
||||
widget.y + widget.height > mouseY;
|
||||
adjustedMouseX >= 0 &&
|
||||
adjustedMouseX <= widget.width &&
|
||||
adjustedMouseY >= 0 &&
|
||||
adjustedMouseY <= widget.height;
|
||||
|
||||
if (isMouseInside) {
|
||||
System.out.println("[SaturnScroll] Child clicked: " + widget);
|
||||
widget.focused = true;
|
||||
widget.click(mouseX, mouseY);
|
||||
widget.click((int) adjustedMouseX, (int) adjustedMouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ public class SaturnSprite extends SaturnWidget {
|
||||
context.drawGuiTexture(
|
||||
RenderLayer::getGuiTextured,
|
||||
sprite,
|
||||
this.x,
|
||||
this.y,
|
||||
0,
|
||||
0,
|
||||
this.width,
|
||||
this.height,
|
||||
ColorHelper.getWhite(this.alpha)
|
||||
|
||||
@@ -30,8 +30,8 @@ public class SaturnText extends SaturnWidget {
|
||||
context.drawText(
|
||||
SaturnClient.textRenderer,
|
||||
SaturnUi.text(text),
|
||||
x,
|
||||
y,
|
||||
0,
|
||||
0,
|
||||
SaturnClient.getWhite(alpha),
|
||||
false
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user