mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 01:27:27 +00:00
Fix misalignment
This commit is contained in:
1 parent
223e3216da
commit
a42d0ac6e8
2 files changed
+33
-20
No files matched your search
@@ -86,6 +86,7 @@ public abstract class GuiNPCInterface extends GuiScreen
|
||||
topbuttons.clear();
|
||||
scrolls.clear();
|
||||
sliders.clear();
|
||||
scrollableGuiInserts.clear();
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
}
|
||||
@Override
|
||||
@@ -236,6 +237,8 @@ public abstract class GuiNPCInterface extends GuiScreen
|
||||
drawBackground();
|
||||
}
|
||||
|
||||
int scrolled = Mouse.getDWheel();
|
||||
|
||||
boolean subGui = hasSubGui();
|
||||
drawCenteredString(fontRendererObj, title, width / 2, guiTop + 4, 0xffffff);
|
||||
for(GuiNpcLabel label : labels.values())
|
||||
@@ -245,7 +248,7 @@ public abstract class GuiNPCInterface extends GuiScreen
|
||||
}
|
||||
for(GuiCustomScroll scroll : scrolls.values()){
|
||||
scroll.updateSubGUI(subGui);
|
||||
scroll.drawScreen(i, j, f, !subGui && scroll.isMouseOver(i, j)?Mouse.getDWheel():0);
|
||||
scroll.drawScreen(i, j, f, !subGui && scroll.isMouseOver(i, j)?scrolled:0);
|
||||
}
|
||||
for(GuiScreen gui : extra.values())
|
||||
gui.drawScreen(i, j, f);
|
||||
@@ -261,7 +264,7 @@ public abstract class GuiNPCInterface extends GuiScreen
|
||||
}
|
||||
}
|
||||
for(GuiScrollable guiScrollable : scrollableGuiInserts.values()){
|
||||
guiScrollable.drawScreen(i, j, f, guiScrollable.isMouseOver(i,j)?Mouse.getDWheel():0);
|
||||
guiScrollable.drawScreen(i, j, f, guiScrollable.isMouseOver(i,j)?scrolled:0);
|
||||
}
|
||||
|
||||
if(subgui != null)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package noppes.npcs.client.gui.util;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -11,6 +13,9 @@ public class GuiScrollable extends GuiNPCInterface{
|
||||
public int clipWidth;
|
||||
public int clipHeight;
|
||||
|
||||
protected int xPos = 0;
|
||||
protected int yPos = 0;
|
||||
|
||||
protected int maxScrollY = 0;
|
||||
protected float scrollY = 0;
|
||||
protected float nextScrollY = 0;
|
||||
@@ -21,8 +26,8 @@ public class GuiScrollable extends GuiNPCInterface{
|
||||
|
||||
public GuiScrollable(EntityNPCInterface npc, int posX, int posY, int clipWidth, int clipHeight, int maxScroll){
|
||||
super(npc);
|
||||
this.guiLeft = posX;
|
||||
this.guiTop = posY;
|
||||
this.xPos = posX;
|
||||
this.yPos = posY;
|
||||
this.clipWidth = clipWidth;
|
||||
this.clipHeight = clipHeight;
|
||||
this.maxScrollY = maxScroll;
|
||||
@@ -36,8 +41,9 @@ public class GuiScrollable extends GuiNPCInterface{
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
|
||||
|
||||
addButton(new GuiNpcButton(0, 0, 0, "Testtt"));
|
||||
|
||||
float scrollPerc = 0;
|
||||
if((guiTop+clipHeight) != 0){
|
||||
@@ -65,8 +71,8 @@ public class GuiScrollable extends GuiNPCInterface{
|
||||
if(drawBackground)
|
||||
this.drawDefaultBackground();
|
||||
|
||||
GL11.glTranslatef(guiLeft, guiTop+scrollY, 0);
|
||||
super.drawScreen(mouseX-guiLeft, (int) (mouseY-scrollY-guiTop), partialTicks);
|
||||
GL11.glTranslatef(xPos, yPos+scrollY, 0);
|
||||
super.drawScreen(mouseX-xPos, (int) (mouseY-scrollY-yPos), partialTicks);
|
||||
|
||||
this.drawDefaultBackground = drawBackground;
|
||||
|
||||
@@ -78,39 +84,43 @@ public class GuiScrollable extends GuiNPCInterface{
|
||||
}
|
||||
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks, int mouseScroll){
|
||||
adjustScroll(mouseScroll);
|
||||
|
||||
this.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
public void adjustScroll(int mouseScroll) {
|
||||
nextScrollY -= (float) mouseScroll/25;
|
||||
if(nextScrollY < 0)
|
||||
nextScrollY = 0;
|
||||
if(nextScrollY > clipHeight) {
|
||||
nextScrollY = clipHeight;
|
||||
if(nextScrollY > maxScrollY) {
|
||||
nextScrollY = maxScrollY;
|
||||
}
|
||||
this.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonEvent(GuiButton button){
|
||||
mc.thePlayer.addChatMessage(new ChatComponentText("LOL"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton){
|
||||
super.mouseClicked(mouseX-guiLeft, (int) (mouseY-scrollY-guiTop), mouseButton);
|
||||
super.mouseClicked(mouseX-xPos, (int) (mouseY-yPos-scrollY), mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput(){
|
||||
super.handleMouseInput();
|
||||
|
||||
nextScrollY -= (float) Mouse.getEventDWheel()/25;
|
||||
if(nextScrollY < 0)
|
||||
nextScrollY = 0;
|
||||
if(nextScrollY > maxScrollY){
|
||||
nextScrollY = maxScrollY;
|
||||
}
|
||||
|
||||
adjustScroll(Mouse.getEventDWheel());
|
||||
}
|
||||
|
||||
public boolean isMouseOver(int mouseX, int mouseY){
|
||||
return mouseX >= guiLeft && mouseX <= xSize && mouseY >= guiTop && mouseY <= ySize;
|
||||
return mouseX >= xPos && mouseX <= clipWidth+xPos && mouseY >= yPos && mouseY <= clipHeight+yPos;
|
||||
}
|
||||
|
||||
protected void setClip(){
|
||||
setClip(guiLeft, guiTop, clipWidth, clipHeight);
|
||||
setClip(xPos, yPos, clipWidth, clipHeight);
|
||||
}
|
||||
|
||||
protected void setClip(int x, int y, int width, int height){
|
||||
|
||||
Reference in new issue
Block a user