Skip to content

Commit 5f5cf5c

Browse files
Store + reapply client window pos for synced windows (#80)
* Store + reapply client window pos for synced windows * update * reviews + rework logic * cleanup * fix * update * Update ModularUIContext.java --------- Co-authored-by: Martin Robertz <dream-master@gmx.net>
1 parent 9bae907 commit 5f5cf5c

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

dependencies.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
dependencies {
44
api("org.jetbrains:annotations:23.0.0")
55

6-
api("com.github.GTNewHorizons:NotEnoughItems:2.6.35-GTNH:dev")
6+
api("com.github.GTNewHorizons:NotEnoughItems:2.6.38-GTNH:dev")
77

8-
implementation("com.github.GTNewHorizons:GTNHLib:0.5.5:dev") { transitive = false }
9-
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.5.60:dev") { transitive = false }
10-
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.49.84:dev") {
8+
implementation("com.github.GTNewHorizons:GTNHLib:0.5.11:dev") { transitive = false }
9+
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.5.62:dev") { transitive = false }
10+
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.49.111:dev") {
1111
transitive = false
1212
exclude group:"com.github.GTNewHorizons", module:"ModularUI"
1313
}

src/main/java/com/gtnewhorizons/modularui/api/screen/ModularUIContext.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class ModularUIContext {
4545
private final Deque<ModularWindow> windows = new LinkedList<>();
4646
private final BiMap<Integer, ModularWindow> syncedWindows = HashBiMap.create(4);
4747
private final Map<ModularWindow, Pos2d> lastWindowPos = new HashMap<>();
48+
private final Map<Integer, Pos2d> lastSyncedWindowPos = new HashMap<>();
4849
private ModularWindow mainWindow;
4950

5051
@SideOnly(Side.CLIENT)
@@ -270,7 +271,12 @@ public void closeAllButMain() {
270271

271272
public void storeWindowPos(ModularWindow window, Pos2d pos) {
272273
if (windows.contains(window)) {
273-
this.lastWindowPos.put(window, pos);
274+
Integer id = syncedWindows.inverse().get(window);
275+
if (id != null) {
276+
this.lastSyncedWindowPos.put(id, pos);
277+
} else {
278+
this.lastWindowPos.put(window, pos);
279+
}
274280
}
275281
}
276282

@@ -279,6 +285,12 @@ public boolean tryApplyStoredPos(ModularWindow window) {
279285
if (this.lastWindowPos.containsKey(window)) {
280286
window.setPos(this.lastWindowPos.get(window));
281287
return true;
288+
} else {
289+
Integer id = syncedWindows.inverse().get(window);
290+
if (id != null && this.lastSyncedWindowPos.containsKey(id)) {
291+
window.setPos(this.lastSyncedWindowPos.get(id));
292+
return true;
293+
}
282294
}
283295
return false;
284296
}

0 commit comments

Comments
 (0)