diff --git a/src/main/java/mnm/mods/tabbychat/client/gui/component/GuiComponent.java b/src/main/java/mnm/mods/tabbychat/client/gui/component/GuiComponent.java index 6a7cf82..20c43e0 100644 --- a/src/main/java/mnm/mods/tabbychat/client/gui/component/GuiComponent.java +++ b/src/main/java/mnm/mods/tabbychat/client/gui/component/GuiComponent.java @@ -49,7 +49,8 @@ public GuiComponent() { * @param mouseY The mouse y * @param parTicks */ - public void render(int mouseX, int mouseY, float parTicks) { + @Override + public void renderButton(int mouseX, int mouseY, float parTicks) { } public void renderCaption(int x, int y) { @@ -139,6 +140,16 @@ public void onClosed() { } + @Override + protected boolean clicked(double x, double y) { + return isMouseOver(x, y); + } + + @Override + public boolean isMouseOver(double x, double y) { + return this.isEnabled() && this.isVisible() && getLocation().contains(x, y); + } + /** * Gets the current location of this component. * diff --git a/src/main/java/mnm/mods/tabbychat/client/gui/component/GuiScrollingPanel.java b/src/main/java/mnm/mods/tabbychat/client/gui/component/GuiScrollingPanel.java index 41fb254..dcc54d4 100644 --- a/src/main/java/mnm/mods/tabbychat/client/gui/component/GuiScrollingPanel.java +++ b/src/main/java/mnm/mods/tabbychat/client/gui/component/GuiScrollingPanel.java @@ -1,12 +1,11 @@ package mnm.mods.tabbychat.client.gui.component; -import static org.lwjgl.opengl.GL11.*; - import mnm.mods.tabbychat.client.gui.component.layout.BorderLayout; import mnm.mods.tabbychat.util.Dim; import mnm.mods.tabbychat.util.ILocation; import mnm.mods.tabbychat.util.Location; import mnm.mods.tabbychat.client.gui.component.layout.BorderLayout.Position; +import org.lwjgl.opengl.GL11; import javax.annotation.Nonnull; @@ -31,20 +30,26 @@ public GuiScrollingPanel() { @Override public void render(int mouseX, int mouseY, float parTicks) { + ILocation rect = getLocation(); + this.panel.setLocation(this.panel.getLocation().copy().setXPos(rect.getXPos())); + + double height = mc.mainWindow.getHeight(); + double scale = mc.mainWindow.getGuiScaleFactor(); - glEnable(GL_SCISSOR_TEST); - glScissor(rect.getXPos(), mc.mainWindow.getHeight() - rect.getYPos(), rect.getWidth(), rect.getHeight()); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + GL11.glScissor((int) ((rect.getXPos()) * scale), (int) (height - rect.getYHeight() * scale), + (int) (rect.getWidth() * scale + 1), (int) (rect.getHeight() * scale + 1)); super.render(mouseX, mouseY, parTicks); - glDisable(GL_SCISSOR_TEST); + GL11.glDisable(GL11.GL_SCISSOR_TEST); } @Override public boolean mouseScrolled(double x, double y, double scroll) { Location rect = panel.getLocation().copy(); - int scr = (int) (rect.getYPos() + scroll / 12); + int scr = (int) (rect.getYPos() + scroll * 8); rect.setYPos(scr); panel.getParent().map(GuiComponent::getLocation).ifPresent(prect -> { @@ -91,7 +96,7 @@ public void render(int mouseX, int mouseY, float parTicks) { float perc = ((float) scroll / (float) total) * ((float) size / (float) max); int pos = (int) (-perc * max); - fill(loc.getXPos()-1, loc.getYPos() + pos, loc.getXPos(), loc.getYPos() + pos + size - 1, -1); + fill(loc.getXPos() - 1, loc.getYPos() + pos, loc.getXPos(), loc.getYPos() + pos + size - 1, -1); super.render(mouseX, mouseY, parTicks); } } diff --git a/src/main/java/mnm/mods/tabbychat/client/gui/settings/GuiSettingsChannel.java b/src/main/java/mnm/mods/tabbychat/client/gui/settings/GuiSettingsChannel.java index 5952988..7a6ab6c 100644 --- a/src/main/java/mnm/mods/tabbychat/client/gui/settings/GuiSettingsChannel.java +++ b/src/main/java/mnm/mods/tabbychat/client/gui/settings/GuiSettingsChannel.java @@ -44,7 +44,6 @@ public GuiSettingsChannel(AbstractChannel channel) { this.setLayout(new BorderLayout()); this.setDisplayString(I18n.format(CHANNEL_TITLE)); this.setSecondaryColor(Color.of(0, 15, 100, 65)); - } @Override diff --git a/src/main/java/mnm/mods/tabbychat/client/gui/settings/GuiSettingsScreen.java b/src/main/java/mnm/mods/tabbychat/client/gui/settings/GuiSettingsScreen.java index 46a58fb..f39a558 100644 --- a/src/main/java/mnm/mods/tabbychat/client/gui/settings/GuiSettingsScreen.java +++ b/src/main/java/mnm/mods/tabbychat/client/gui/settings/GuiSettingsScreen.java @@ -3,6 +3,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import mnm.mods.tabbychat.TCMarkers; +import mnm.mods.tabbychat.client.AbstractChannel; import mnm.mods.tabbychat.client.ChatManager; import mnm.mods.tabbychat.client.DefaultChannel; import mnm.mods.tabbychat.TabbyChat; @@ -46,7 +47,7 @@ public class GuiSettingsScreen extends ComponentScreen { public GuiSettingsScreen(@Nullable Channel channel) { super(new StringTextComponent("Settings")); if (channel != DefaultChannel.INSTANCE) { - selectedSetting = new GuiSettingsChannel(); + selectedSetting = new GuiSettingsChannel((AbstractChannel) channel); } for (Map.Entry>, Supplier>> sett : settings.entrySet()) { @@ -65,7 +66,6 @@ public GuiSettingsScreen(@Nullable Channel channel) { @Override public void init() { - getPanel().add(panel = new GuiPanel(new BorderLayout())); int x = this.width / 2 - 300 / 2;