Skip to content

Commit

Permalink
Fix issue with save state of a map not being tracked.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen Wilke committed Jan 1, 2020
1 parent 126abda commit d95c73a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions utiliti/src/de/gurkenlabs/utiliti/UndoManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ public static UndoManager instance() {
return instance.get(Game.world().environment().getMap().getName());
}

UndoManager newUndoManager = new UndoManager(Game.world().environment().getMap().getName());
instance.put(Game.world().environment().getMap().getName(), newUndoManager);
final String mapName = Game.world().environment().getMap().getName();
UndoManager newUndoManager = new UndoManager(mapName);
instance.put(mapName, newUndoManager);
return newUndoManager;
}

Expand Down Expand Up @@ -269,6 +270,7 @@ public static boolean hasChanges(IMap map) {
public static void save(IMap map) {
if (instance.containsKey(map.getName())) {
instance.get(map.getName()).saved = true;
UI.getMapController().refresh();
}
}

Expand Down
13 changes: 7 additions & 6 deletions utiliti/src/de/gurkenlabs/utiliti/components/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -647,18 +647,19 @@ private String saveGameFile(String target) {
new Object[] { this.getGameFile().getMaps().size(), this.getGameFile().getSpriteSheets().size(), this.getGameFile().getTilesets().size(), this.getGameFile().getEmitters().size(), this.getGameFile().getBluePrints().size(), this.getGameFile().getSounds().size(), this.currentResourceFile });
this.setCurrentStatus(Resources.strings().get("status_gamefile_saved"));

if (preferences().syncMaps()) {
this.saveMaps();
}
this.saveMaps();
return saveFile;
}

private void saveMaps() {
for (TmxMap map : this.getChangedMaps()) {
UndoManager.save(map);
for (String file : FileUtilities.findFilesByExtension(new ArrayList<>(), Paths.get(FileUtilities.combine(this.getProjectPath(), "maps")), map.getName() + "." + TmxMap.FILE_EXTENSION)) {
File newFile = XmlUtilities.save(map, file, TmxMap.FILE_EXTENSION);
log.log(Level.INFO, "synchronized map {0}", new Object[] { newFile });

if (preferences().syncMaps()) {
for (String file : FileUtilities.findFilesByExtension(new ArrayList<>(), Paths.get(FileUtilities.combine(this.getProjectPath(), "maps")), map.getName() + "." + TmxMap.FILE_EXTENSION)) {
File newFile = XmlUtilities.save(map, file, TmxMap.FILE_EXTENSION);
log.log(Level.INFO, "synchronized map {0}", new Object[] { newFile });
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public TmxMap getCurrentMap() {
@Override
public void refresh() {
this.list.revalidate();
this.list.repaint();

UI.getEntityController().refresh();
UI.getLayerController().refresh();
}
Expand Down

0 comments on commit d95c73a

Please sign in to comment.