More scrolling and dialog alignment fixes.

This commit is contained in:
Luis C.M committed 2022-06-03 15:33:20 -05:00
1 parent 2c84a527bf
commit c7b34dcf54
1 file changed
+26 -30
@@ -37,36 +37,35 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
private int selected = 0;
private List<TextBlockClient> lineBlocks = new ArrayList<TextBlockClient>();
private List<Integer> options = new ArrayList<Integer>();
private int rowStart = 0;
private int rowTotal = 0;
private int totalRows = 0;
private ScaledResolution scaledResolution;
private int renderDialogType = 1; //0 - Instant (classic), 1 - Gradual
private String gradualText = "";
private int currentBlock = 0;
private int currentLine = 0;
private int gradualTextTime = 0;
private static int gradualTextSpeed = 10;
private boolean showPreviousBlocks = true;
private int dialogWidth = 500;
private int dialogHeight = 200;
private int dialogTextBottom = 0;
private int textOffsetX, textOffsetY;
private int titleOffsetX, titleOffsetY;
private int optionSpaceX, optionSpaceY;
private int optionOffsetX, optionOffsetY;
private int scrollY;
private ResourceLocation wheel;
private ResourceLocation[] wheelparts;
private ResourceLocation indicator;
private boolean isGrabbed = false;
private int renderDialogType = 0; //0 - Instant (classic), 1 - Gradual
private boolean showPreviousBlocks = true;
private int dialogWidth = 500;
private int dialogHeight = 200;
private int textOffsetX, textOffsetY;
private int titleOffsetX, titleOffsetY;
private int optionSpaceX, optionSpaceY;
private int optionOffsetX, optionOffsetY;
public GuiDialogInteract(EntityNPCInterface npc, Dialog dialog){
super(npc);
@@ -248,7 +247,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
private int selectedY = 0;
private void drawWheel(){
int yoffset = scaledResolution.getScaledHeight() - 50 + optionOffsetY;
dialogTextBottom = yoffset - 100;
//dialogTextBottom = yoffset - 100;
GL11.glColor4f(1, 1, 1, 1);
mc.renderEngine.bindTexture(wheel);
drawTexturedModalRect((width/2) - 31 + optionOffsetX, yoffset, 0, 0, 63, 40);
@@ -303,7 +302,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
}
private void drawLinedOptions(int j){
int offset = scaledResolution.getScaledHeight() - (options.size() + 2) * ClientProxy.Font.height() + optionOffsetY - options.size() * optionSpaceY;
dialogTextBottom = offset - 100;
//dialogTextBottom = offset - 100;
if(j >= offset){
int selected = options.size() - (j - offset + optionSpaceY) / (ClientProxy.Font.height() + optionSpaceY);
if(selected < options.size())
@@ -328,9 +327,10 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
}
private void drawDialogString(String text, int left, int color, int count, boolean mainDialogText){
int height = count - rowStart;
int y = (height * ClientProxy.Font.height()) + dialogTextBottom + scrollY;
if (y < dialogTextBottom - dialogHeight || y > dialogTextBottom + ClientProxy.Font.height() * 8) {
int height = count - totalRows;
int midScreen = scaledResolution.getScaledHeight() / 2;
int y = (height * ClientProxy.Font.height()) + midScreen + scrollY;
if (y < midScreen - dialogHeight || y > midScreen - ClientProxy.Font.height()) {
return;
}
@@ -377,7 +377,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
gradualTextSpeed++;
}
if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201 && scrollY < rowStart * ClientProxy.Font.height()) {//Page up
if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201 && scrollY < (totalRows - 2) * ClientProxy.Font.height()) {//Page up
scrollY += ClientProxy.Font.height() * 2;
}
if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == 209 && scrollY > 0) {//Page down
@@ -462,25 +462,21 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
currentLine = 0;
gradualTextTime = 0;
for(int slot:dialog.options.keySet()){
for(int slot:dialog.options.keySet()){
DialogOption option = dialog.options.get(slot);
if(option == null || option.optionType == EnumOptionType.Disabled)
continue;
options.add(slot);
}
calculateRowHeight();
}
calculateRowHeight();
grabMouse(dialog.showWheel);
grabMouse(dialog.showWheel);
}
private void calculateRowHeight(){
rowTotal = 0;
totalRows = 0;
for(TextBlockClient block : lineBlocks){
rowTotal += block.lines.size() + 1;
totalRows += block.lines.size() + 1;
}
rowStart = rowTotal;
if(rowStart < 0)
rowStart = 0;
}
@Override