Fix sluggish scrolling on GuiScrollList's and fix small rendering issue with scroll bar on certian screen sizes.
This commit is contained in:
parent
8fdd76bae1
commit
26b5059396
|
@ -56,6 +56,7 @@ import net.minecraftforge.fml.common.versioning.ComparableVersion;
|
|||
import static net.minecraft.util.text.TextFormatting.*;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
|
@ -312,6 +313,18 @@ public class GuiModList extends GuiScreen
|
|||
search.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() throws IOException
|
||||
{
|
||||
int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
|
||||
int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
|
||||
|
||||
super.handleMouseInput();
|
||||
if (this.modInfo != null)
|
||||
this.modInfo.handleMouseInput(mouseX, mouseY);
|
||||
this.modList.handleMouseInput(mouseX, mouseY);
|
||||
}
|
||||
|
||||
Minecraft getMinecraftInstance()
|
||||
{
|
||||
return mc;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
package net.minecraftforge.fml.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -71,6 +72,7 @@ public abstract class GuiScrollingList
|
|||
this.screenHeight = screenHeight;
|
||||
}
|
||||
|
||||
@Deprecated // Unused, remove in 1.9.3?
|
||||
public void func_27258_a(boolean p_27258_1_)
|
||||
{
|
||||
this.highlightSelected = p_27258_1_;
|
||||
|
@ -120,6 +122,7 @@ public abstract class GuiScrollingList
|
|||
*/
|
||||
protected void drawScreen(int mouseX, int mouseY) { func_27257_b(mouseX, mouseY); }
|
||||
|
||||
@Deprecated // Unused, Remove in 1.9.3?
|
||||
public int func_27256_c(int x, int y)
|
||||
{
|
||||
int left = this.left + 1;
|
||||
|
@ -175,6 +178,21 @@ public abstract class GuiScrollingList
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void handleMouseInput(int mouseX, int mouseY) throws IOException
|
||||
{
|
||||
boolean isHovering = mouseX >= this.left && mouseX <= this.left + this.listWidth &&
|
||||
mouseY >= this.top && mouseY <= this.bottom;
|
||||
if (!isHovering)
|
||||
return;
|
||||
|
||||
int scroll = Mouse.getEventDWheel();
|
||||
if (scroll != 0)
|
||||
{
|
||||
this.scrollDistance += (float)((-1 * scroll / 120.0F) * this.slotHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.mouseX = mouseX;
|
||||
|
@ -246,18 +264,6 @@ public abstract class GuiScrollingList
|
|||
}
|
||||
else
|
||||
{
|
||||
while (isHovering && Mouse.next())
|
||||
{
|
||||
int scroll = Mouse.getEventDWheel();
|
||||
if (scroll != 0)
|
||||
{
|
||||
if (scroll > 0) scroll = -1;
|
||||
else if (scroll < 0) scroll = 1;
|
||||
|
||||
this.scrollDistance += (float)(scroll * this.slotHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
this.initialMouseClickY = -1.0F;
|
||||
}
|
||||
|
||||
|
@ -330,10 +336,10 @@ public abstract class GuiScrollingList
|
|||
|
||||
GlStateManager.disableDepth();
|
||||
|
||||
int extraHeight = this.getContentHeight() - viewHeight - border;
|
||||
int extraHeight = (this.getContentHeight() + border) - viewHeight;
|
||||
if (extraHeight > 0)
|
||||
{
|
||||
int height = viewHeight * viewHeight / this.getContentHeight();
|
||||
int height = (viewHeight * viewHeight) / this.getContentHeight();
|
||||
|
||||
if (height < 32) height = 32;
|
||||
|
||||
|
|
Loading…
Reference in New Issue