Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Sep 17, 2024
1 parent 26aafc5 commit 0a5158a
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class ModularUIContext {
private final Deque<ModularWindow> windows = new LinkedList<>();
private final BiMap<Integer, ModularWindow> syncedWindows = HashBiMap.create(4);
private final Map<ModularWindow, Pos2d> lastWindowPos = new HashMap<>();
private final Map<Integer, Pos2d> lastSyncedWindowPos = new HashMap<>();
private ModularWindow mainWindow;

@SideOnly(Side.CLIENT)
Expand Down Expand Up @@ -271,6 +272,10 @@ public void closeAllButMain() {
public void storeWindowPos(ModularWindow window, Pos2d pos) {
if (windows.contains(window)) {
this.lastWindowPos.put(window, pos);
Integer id = syncedWindows.inverse().get(window);
if (id != null) {
this.lastSyncedWindowPos.put(id, pos);
}
}
}

Expand All @@ -279,15 +284,16 @@ public boolean tryApplyStoredPos(ModularWindow window) {
if (this.lastWindowPos.containsKey(window)) {
window.setPos(this.lastWindowPos.get(window));
return true;
} else {
Integer id = syncedWindows.inverse().get(window);
if (id != null && this.lastSyncedWindowPos.containsKey(id)) {
window.setPos(this.lastSyncedWindowPos.get(id));
return true;
}
}
return false;
}

public boolean tryApplyStoredPos(int windowId) {
ModularWindow window = syncedWindows.get(windowId);
return window != null && tryApplyStoredPos(window);
}

@SideOnly(Side.CLIENT)
public Pos2d getMousePos() {
return screen.getMousePos();
Expand Down

0 comments on commit 0a5158a

Please sign in to comment.