Skip to content

Commit

Permalink
Fix mezz#1405 Center search bar not centered after toggling overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Nov 23, 2018
1 parent bd478c6 commit 4bea473
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/main/java/mezz/jei/gui/GuiEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ public GuiEventHandler(IngredientListOverlay ingredientListOverlay, RecipeRegist
@SubscribeEvent
public void onOverlayToggle(OverlayToggleEvent event) {
GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
ingredientListOverlay.updateScreen(currentScreen);
ingredientListOverlay.updateScreen(currentScreen, true);
}

@SubscribeEvent
public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) {
GuiScreen gui = event.getGui();
ingredientListOverlay.updateScreen(gui);
ingredientListOverlay.updateScreen(gui, false);
}

@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
GuiScreen gui = event.getGui();
ingredientListOverlay.updateScreen(gui);
ingredientListOverlay.updateScreen(gui, false);
}

@SubscribeEvent
public void onDrawBackgroundEventPost(GuiScreenEvent.BackgroundDrawnEvent event) {
GuiScreen gui = event.getGui();
ingredientListOverlay.updateScreen(gui);
ingredientListOverlay.updateScreen(gui, false);

drawnOnBackground = true;
ingredientListOverlay.drawScreen(gui.mc, event.getMouseX(), event.getMouseY(), gui.mc.getRenderPartialTicks());
Expand All @@ -64,7 +64,7 @@ public void onDrawForegroundEvent(GuiContainerEvent.DrawForeground event) {
public void onDrawScreenEventPost(GuiScreenEvent.DrawScreenEvent.Post event) {
GuiScreen gui = event.getGui();

ingredientListOverlay.updateScreen(gui);
ingredientListOverlay.updateScreen(gui, false);

if (!drawnOnBackground) {
ingredientListOverlay.drawScreen(gui.mc, event.getMouseX(), event.getMouseY(), gui.mc.getRenderPartialTicks());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mezz/jei/gui/overlay/ConfigButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public boolean handleMouseClick(int mouseX, int mouseY) {
} else {
if (minecraft.currentScreen != null) {
GuiScreen configScreen = new JEIModConfigGui(minecraft.currentScreen);
parent.updateScreen(configScreen);
parent.updateScreen(configScreen, false);
minecraft.displayGuiScreen(configScreen);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mezz/jei/gui/overlay/IngredientListOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static Rectangle getDisplayArea(IGuiProperties guiProperties) {
return new Rectangle(x, y, width, height);
}

public void updateScreen(@Nullable GuiScreen guiScreen) {
public void updateScreen(@Nullable GuiScreen guiScreen, boolean forceUpdate) {
JeiRuntime runtime = Internal.getRuntime();
if (runtime == null) {
return;
Expand All @@ -112,7 +112,7 @@ public void updateScreen(@Nullable GuiScreen guiScreen) {
setKeyboardFocus(false);
this.ghostIngredientDragManager.stopDrag();
}
} else if (this.guiProperties == null || !areGuiPropertiesEqual(this.guiProperties, guiProperties)) {
} else if (this.guiProperties == null || !areGuiPropertiesEqual(this.guiProperties, guiProperties) || forceUpdate) {
this.guiProperties = guiProperties;
this.displayArea = getDisplayArea(guiProperties);

Expand Down

0 comments on commit 4bea473

Please sign in to comment.