delay repo view sorting to once per tick

This commit is contained in:
PrototypeTrousers
2022-09-25 14:35:13 -03:00
parent 86a42e970f
commit d9588441b0
2 changed files with 19 additions and 12 deletions
@@ -99,6 +99,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
private int currentMouseY = 0; private int currentMouseY = 0;
private boolean delayedUpdate; private boolean delayedUpdate;
private boolean updateView = true;
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0; protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
public GuiMEMonitorable(final InventoryPlayer inventoryPlayer, final ITerminalHost te) { public GuiMEMonitorable(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
@@ -157,8 +158,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
} }
if (!this.delayedUpdate) { if (!this.delayedUpdate) {
this.repo.updateView(); this.updateView = true;
this.setScrollBar();
} }
} }
@@ -315,8 +315,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.searchField.setText(memoryText); this.searchField.setText(memoryText);
this.searchField.selectAll(); this.searchField.selectAll();
this.repo.setSearchString(memoryText); this.repo.setSearchString(memoryText);
this.repo.updateView(); this.updateView = true;
this.setScrollBar();
} }
craftingGridOffsetX = Integer.MAX_VALUE; craftingGridOffsetX = Integer.MAX_VALUE;
@@ -377,8 +376,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) { if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
this.searchField.setText(""); this.searchField.setText("");
this.repo.setSearchString(""); this.repo.setSearchString("");
this.repo.updateView(); this.updateView = true;
this.setScrollBar();
} }
super.mouseClicked(xCoord, yCoord, btn); super.mouseClicked(xCoord, yCoord, btn);
@@ -472,8 +470,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
if (this.searchField.textboxKeyTyped(character, key)) { if (this.searchField.textboxKeyTyped(character, key)) {
this.repo.setSearchString(this.searchField.getText()); this.repo.setSearchString(this.searchField.getText());
this.repo.updateView(); this.updateView = true;
this.setScrollBar();
// tell forge the key event is handled and should not be sent out // tell forge the key event is handled and should not be sent out
this.keyHandled = mouseInGui; this.keyHandled = mouseInGui;
} else { } else {
@@ -500,7 +497,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.delayedUpdate = false; this.delayedUpdate = false;
} }
} }
if (!this.delayedUpdate) { if (!this.delayedUpdate && updateView) {
this.repo.updateView(); this.repo.updateView();
this.setScrollBar(); this.setScrollBar();
} }
@@ -536,7 +533,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE)); this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE));
} }
this.repo.updateView(); this.updateView = true;
} }
int getReservedSpace() { int getReservedSpace() {
@@ -54,6 +54,8 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
private GuiImgButton units; private GuiImgButton units;
private int tooltip = -1; private int tooltip = -1;
private boolean updateView = true;
public GuiNetworkStatus(final InventoryPlayer inventoryPlayer, final INetworkTool te) { public GuiNetworkStatus(final InventoryPlayer inventoryPlayer, final INetworkTool te) {
super(new ContainerNetworkStatus(inventoryPlayer, te)); super(new ContainerNetworkStatus(inventoryPlayer, te));
final GuiScrollbar scrollbar = new GuiScrollbar(); final GuiScrollbar scrollbar = new GuiScrollbar();
@@ -202,9 +204,17 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
for (final IAEItemStack is : list) { for (final IAEItemStack is : list) {
this.repo.postUpdate(is); this.repo.postUpdate(is);
} }
this.updateView = true;
}
this.repo.updateView(); @Override
this.setScrollBar(); public void updateScreen() {
if (updateView) {
this.repo.updateView();
this.setScrollBar();
updateView = false;
}
super.updateScreen();
} }
private void setScrollBar() { private void setScrollBar() {