this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

world map editor update

clover 9dbd3b56 21eb317b

+394 -105
+2
CHANGELOG.md
··· 10 10 - (Sprite Editor) Timing information listed for commands in command list 11 11 - (Sprite Editor) Error highlighting for commands/components/etc 12 12 - (Map Editor) A wide array of import formats are now supported, including fbx and gltf 13 + - (World Map Editor) Undo/redo for all actions 13 14 14 15 ### Changed 15 16 - (Sprite Editor) UI reorganized and improved ··· 18 19 - (Sprite Editor) Proper keyframe support 19 20 - (Sprite Editor) Faster sprite loading 20 21 - Version checking will not open windows from command line and can be skipped 22 + - Dark theme used by default 21 23 - Faster startup 22 24 23 25 ### Fixed
+2 -2
src/main/java/app/Themes.java
··· 199 199 static { 200 200 if (!Environment.isCommandLine()) { 201 201 // @formatter:off 202 - DEFAULT_THEME = Theme.createBuiltIn("Flat Light", "com.formdev.flatlaf.FlatLightLaf"); 202 + DEFAULT_THEME = Theme.createBuiltIn("Flat Dark", "com.formdev.flatlaf.FlatDarkLaf"); 203 203 addTheme(DEFAULT_THEME); 204 204 205 - addTheme(Theme.createBuiltIn("Flat Dark", "com.formdev.flatlaf.FlatDarkLaf")); 205 + addTheme(Theme.createBuiltIn("Flat Light", "com.formdev.flatlaf.FlatLightLaf")); 206 206 addTheme(Theme.createBuiltIn("Arc Light", "com.formdev.flatlaf.intellijthemes.FlatArcIJTheme")); 207 207 addTheme(Theme.createBuiltIn("Arc Light Orange", "com.formdev.flatlaf.intellijthemes.FlatArcOrangeIJTheme")); 208 208 addTheme(Theme.createBuiltIn("Arc Dark", "com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme"));
+1 -1
src/main/java/app/config/Options.java
··· 21 21 GameVersion (true, Scope.Main, Type.String, "GameVersion", "us"), 22 22 23 23 LogDetails (true, Scope.Main, Type.Boolean, "LogDetails", "false"), 24 - Theme (true, Scope.Main, Type.String, "Theme", "FlatLight"), 24 + Theme (true, Scope.Main, Type.String, "Theme", "FlatDark"), 25 25 ExitToMenu (true, Scope.Main, Type.Boolean, "ExitToMenu", "true"), 26 26 CheckForUpdates (true, Scope.Main, Type.Boolean, "CheckForUpdates", "true"), 27 27
+14 -13
src/main/java/common/BaseEditor.java
··· 293 293 if (warmup) { 294 294 warmup = false; 295 295 LoadingBar.dismiss(); 296 + 297 + if (editorSettings.fullscreen) 298 + frame.setExtendedState(Frame.MAXIMIZED_BOTH); 299 + else 300 + frame.setBounds(0, 0, editorSettings.sizeX, editorSettings.sizeY); 301 + 296 302 frame.setVisible(true); 297 303 } 298 304 } ··· 344 350 Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(closingEvent); 345 351 } 346 352 347 - private final void createFrame(BaseEditorSettings windowSettings) 353 + private final void createFrame(BaseEditorSettings editorSettings) 348 354 { 349 355 frame = new StarRodFrame(); 350 356 351 - if (windowSettings.fullscreen) 352 - frame.setExtendedState(Frame.MAXIMIZED_BOTH); 353 - else 354 - frame.setBounds(0, 0, windowSettings.sizeX, windowSettings.sizeY); 355 - 356 - if (windowSettings.resizeable) 357 - frame.setMinimumSize(new Dimension(windowSettings.sizeX, windowSettings.sizeY)); 357 + if (editorSettings.resizeable) 358 + frame.setMinimumSize(new Dimension(editorSettings.sizeX, editorSettings.sizeY)); 358 359 359 360 frame.setLocationRelativeTo(null); 360 - frame.setTitle(windowSettings.title); 361 + frame.setTitle(editorSettings.title); 361 362 362 363 keyboard = new KeyboardInput(glCanvas); 363 364 mouse = new MouseInput(glCanvas); 364 365 365 - if (windowSettings.resizeable) 366 + if (editorSettings.resizeable) 366 367 glCanvas.setMinimumSize(new Dimension(1, 1)); 367 368 368 369 infoLabel = new FadingLabel(false, SwingConstants.LEFT, MESSAGE_HOLD_TIME, MESSAGE_FADE_TIME); ··· 372 373 ActionListener openLogAction = createOpenLogAction(); 373 374 374 375 JPanel toolPanel = new JPanel(new MigLayout()); 375 - toolPanel.setPreferredSize(new Dimension(windowSettings.sizeX, windowSettings.sizeY)); 376 + toolPanel.setPreferredSize(new Dimension(editorSettings.sizeX, editorSettings.sizeY)); 376 377 377 - if (windowSettings.hasMenuBar) { 378 + if (editorSettings.hasMenuBar) { 378 379 menuBar = new JMenuBar(); 379 380 frame.setJMenuBar(menuBar); 380 381 } ··· 385 386 contentPanel.add(toolPanel, "grow"); 386 387 387 388 frame.setContentPane(contentPanel); 388 - frame.setResizable(windowSettings.resizeable); 389 + frame.setResizable(editorSettings.resizeable); 389 390 390 391 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 391 392 frame.addWindowListener(new java.awt.event.WindowAdapter() {
+4 -4
src/main/java/game/sprite/editor/SpriteEditor.java
··· 58 58 import common.KeyboardInput.KeyInputEvent; 59 59 import common.commands.AbstractCommand; 60 60 import common.commands.CommandBatch; 61 + import common.commands.ThreadSafeCommandManager; 61 62 import game.map.editor.render.PresetColor; 62 63 import game.map.editor.render.TextureManager; 63 64 import game.map.editor.ui.dialogs.ChooseDialogResult; ··· 85 86 import game.sprite.editor.commands.SelectModesTab; 86 87 import game.sprite.editor.commands.SelectSpritesTab; 87 88 import game.sprite.editor.commands.SetOverridePalette; 88 - import game.sprite.editor.commands.SpriteCommandManager; 89 89 import game.sprite.editor.commands.ToggleDrawCurrent; 90 90 import game.sprite.editor.commands.TogglePaletteOverride; 91 91 import game.texture.Palette; ··· 245 245 public volatile boolean suppressCommands = false; 246 246 247 247 // handles comnmand execution and undo/redo 248 - private SpriteCommandManager commandManager; 248 + private ThreadSafeCommandManager commandManager; 249 249 250 250 private Sprite unloadSprite = null; 251 251 private Sprite loadSprite = null; ··· 347 347 spriteLoader = new SpriteLoader(); 348 348 spriteLoader.tryLoadingPlayerAssets(false); 349 349 350 - commandManager = new SpriteCommandManager(this, UNDO_LIMIT); 350 + commandManager = new ThreadSafeCommandManager(UNDO_LIMIT, modifyLock, this::onModified); 351 351 } 352 352 353 353 private void loadPreferences() ··· 1997 1997 1998 1998 // any modification of the Sprite flags it as potentially modified until 1999 1999 // either the app is closed or Save All operation is performed 2000 - public void notifyModified() 2000 + public void onModified() 2001 2001 { 2002 2002 if (sprite != null) 2003 2003 dirtyModifiedSprites.add(sprite);
+12 -17
src/main/java/game/sprite/editor/commands/SpriteCommandManager.java src/main/java/common/commands/ThreadSafeCommandManager.java
··· 1 - package game.sprite.editor.commands; 1 + package common.commands; 2 2 3 3 import java.util.Stack; 4 4 5 - import common.commands.AbstractCommand; 6 - import game.sprite.editor.SpriteEditor; 7 5 import util.EvictingStack; 8 6 import util.Logger; 9 7 10 - public class SpriteCommandManager 8 + public class ThreadSafeCommandManager 11 9 { 12 - private final SpriteEditor editor; 13 - 14 10 private EvictingStack<AbstractCommand> undoStack; 15 11 private Stack<AbstractCommand> redoStack; 16 12 17 - public SpriteCommandManager(SpriteEditor editor, int undoLimit) 13 + private final Object modifyLock; 14 + private final Runnable modifyCallback; 15 + 16 + public ThreadSafeCommandManager(int undoLimit, Object modifyLock, Runnable modifyCallback) 18 17 { 19 - this.editor = editor; 18 + this.modifyLock = modifyLock; 19 + this.modifyCallback = modifyCallback; 20 20 21 21 undoStack = new EvictingStack<>(undoLimit); 22 22 redoStack = new Stack<>(); ··· 32 32 if (!cmd.shouldExec()) 33 33 return; 34 34 35 - synchronized (editor.modifyLock) { 35 + synchronized (modifyLock) { 36 36 cmd.exec(); 37 37 38 38 undoStack.push(cmd); 39 39 redoStack.clear(); 40 40 41 41 if (cmd.modifiesData()) 42 - onModified(); 42 + modifyCallback.run(); 43 43 } 44 44 } 45 45 46 46 public void action_Undo() 47 47 { 48 48 if (undoStack.size() > 0) { 49 - synchronized (editor.modifyLock) { 49 + synchronized (modifyLock) { 50 50 AbstractCommand cmd = undoStack.pop(); 51 51 cmd.undo(); 52 52 redoStack.push(cmd); ··· 60 60 public void action_Redo() 61 61 { 62 62 if (redoStack.size() > 0) { 63 - synchronized (editor.modifyLock) { 63 + synchronized (modifyLock) { 64 64 AbstractCommand cmd = redoStack.pop(); 65 65 cmd.exec(); 66 66 undoStack.push(cmd); ··· 75 75 { 76 76 undoStack.clear(); 77 77 redoStack.clear(); 78 - } 79 - 80 - public void onModified() 81 - { 82 - editor.notifyModified(); 83 78 } 84 79 }
+145 -67
src/main/java/game/worldmap/WorldMapEditor.java
··· 24 24 import javax.swing.JPanel; 25 25 import javax.swing.JSlider; 26 26 import javax.swing.KeyStroke; 27 + import javax.swing.SwingUtilities; 27 28 28 29 import app.Environment; 29 30 import app.SwingUtils; ··· 31 32 import common.BaseEditor; 32 33 import common.BaseEditorSettings; 33 34 import common.BasicCamera; 34 - import common.BasicCommandManager; 35 - import common.BasicEditorCommand; 36 35 import common.KeyboardInput.KeyInputEvent; 37 36 import common.MouseInput.MouseManagerListener; 38 37 import common.MousePixelRead; 38 + import common.commands.AbstractCommand; 39 + import common.commands.CommandBatch; 40 + import common.commands.ThreadSafeCommandManager; 39 41 import game.ProjectDatabase; 40 42 import game.map.editor.render.PresetColor; 41 43 import game.map.editor.render.TextureManager; 44 + import game.worldmap.WorldMapModder.AddPathElem; 45 + import game.worldmap.WorldMapModder.RemovePathElem; 46 + import game.worldmap.WorldMapModder.SetLocName; 47 + import game.worldmap.WorldMapModder.SetLocStory; 48 + import game.worldmap.WorldMapModder.SetParent; 49 + import game.worldmap.WorldMapModder.SetPosition; 42 50 import game.worldmap.WorldMapModder.WorldLocation; 43 51 import game.worldmap.WorldMapModder.WorldMarker; 44 52 import game.worldmap.WorldMapModder.WorldPathElement; ··· 75 83 .setFramerate(60); 76 84 77 85 private static final int MAX_SIZE = 320; 86 + 87 + private static final int UNDO_LIMIT = 64; 78 88 79 89 private List<WorldLocation> locations; 80 90 ··· 84 94 private JComboBox<String> locationsBox; 85 95 private JComboBox<String> storyBox; 86 96 87 - private BasicCommandManager commandManager; 97 + private ThreadSafeCommandManager commandManager; 88 98 private final BasicCamera cam; 89 99 90 100 private boolean glTexDirty = true; ··· 105 115 private MousePixelRead framePick; 106 116 private WorldMarker mouseMarker; 107 117 private WorldMarker dragMarker; 108 - private WorldMarker parentingMarker; 118 + private WorldLocation parentingLoc; 109 119 private WorldLocation selectedLocation; 110 120 111 121 private JPanel sidePanel; ··· 113 123 114 124 private volatile boolean modified = false; 115 125 126 + public volatile boolean suppressCommands = false; 127 + 116 128 public WorldMapEditor() 117 129 { 118 130 super(EDITOR_SETTINGS); ··· 134 146 135 147 private void resetEditor() 136 148 { 137 - commandManager = new BasicCommandManager(32); 149 + commandManager = new ThreadSafeCommandManager(UNDO_LIMIT, modifyLock, this::onModified); 138 150 139 151 cbBackground.setSelected(bDrawBackground); 140 152 cbLines.setSelected(bDrawLines); ··· 145 157 146 158 mouseMarker = null; 147 159 dragMarker = null; 160 + 161 + suppressCommands = true; 148 162 setSelectedLocation(null); 163 + suppressCommands = false; 149 164 150 165 resetCam(); 151 166 } 152 167 153 - public void push(BasicEditorCommand cmd) 154 - { 155 - commandManager.pushCommand(cmd); 156 - modified = true; 157 - } 158 - 159 168 @Override 160 169 protected void createGui(JPanel toolPanel, Canvas glCanvas, JMenuBar menubar, JLabel infoLabel, 161 170 ActionListener openLogAction) ··· 173 182 String[] locNames = ProjectDatabase.ELocations.getValues(); 174 183 locationsBox = new JComboBox<>(WorldMapModder.stripAllPrefix(locNames, WorldMapModder.PREFIX_LOC)); 175 184 locationsBox.addActionListener((e) -> { 176 - if (selectedLocation != null) 177 - selectedLocation.name = (String) locationsBox.getSelectedItem(); 185 + if (selectedLocation != null && !suppressCommands) { 186 + String name = (String) locationsBox.getSelectedItem(); 187 + execute(new SetLocName(selectedLocation, name, this::refreshSelected)); 188 + } 178 189 }); 179 190 locationsBox.setMaximumRowCount(20); 180 191 SwingUtils.addBorderPadding(locationsBox); ··· 182 193 String[] storyNames = ProjectDatabase.EStoryProgress.getValues(); 183 194 storyBox = new JComboBox<>(WorldMapModder.stripAllPrefix(storyNames, WorldMapModder.PREFIX_STORY)); 184 195 storyBox.addActionListener((e) -> { 185 - if (selectedLocation != null) 186 - selectedLocation.descUpdate = (String) storyBox.getSelectedItem(); 196 + if (selectedLocation != null && !suppressCommands) { 197 + String name = (String) storyBox.getSelectedItem(); 198 + execute(new SetLocStory(selectedLocation, name, this::refreshSelected)); 199 + } 187 200 }); 188 201 storyBox.setMaximumRowCount(20); 189 202 SwingUtils.addBorderPadding(storyBox); ··· 231 244 menu.getPopupMenu().setLightWeightPopupEnabled(false); 232 245 menuBar.add(menu); 233 246 234 - //TODO implement commands for this editor 235 - /* 236 - item = new JMenuItem("Undo"); 237 - awtKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK); 238 - item.setAccelerator(awtKeyStroke); 239 - item.addActionListener((e) -> { 240 - undoEDT(); 241 - }); 242 - menu.add(item); 243 - 244 - item = new JMenuItem("Redo"); 245 - awtKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK); 246 - item.setAccelerator(awtKeyStroke); 247 - item.addActionListener((e) -> { 248 - redoEDT(); 249 - }); 250 - menu.add(item); 251 - 252 - menu.addSeparator(); 253 - */ 254 - 255 247 item = new JMenuItem("Reload"); 256 248 item.addActionListener((e) -> { 257 249 loadData(); 250 + flushUndoRedo(); 258 251 glTexDirty = true; 259 252 }); 260 253 menu.add(item); ··· 264 257 item.setAccelerator(awtKeyStroke); 265 258 item.addActionListener((e) -> { 266 259 saveChanges(); 260 + flushUndoRedo(); 267 261 }); 268 262 menu.add(item); 269 263 ··· 295 289 private void addEditorMenu(JMenuBar menuBar) 296 290 { 297 291 JMenuItem item; 292 + KeyStroke awtKeyStroke; 298 293 299 294 JMenu menu = new JMenu(String.format(" %-10s", "Editor")); 300 295 menu.getPopupMenu().setLightWeightPopupEnabled(false); 301 296 menuBar.add(menu); 297 + 298 + item = new JMenuItem("Undo"); 299 + awtKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK); 300 + item.setAccelerator(awtKeyStroke); 301 + item.addActionListener((e) -> { 302 + undoEDT(); 303 + }); 304 + menu.add(item); 305 + 306 + item = new JMenuItem("Redo"); 307 + awtKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK); 308 + item.setAccelerator(awtKeyStroke); 309 + item.addActionListener((e) -> { 310 + redoEDT(); 311 + }); 312 + menu.add(item); 313 + 314 + menu.addSeparator(); 302 315 303 316 item = new JMenuItem("View Controls"); 304 317 item.addActionListener((e) -> { ··· 442 455 } 443 456 } 444 457 458 + public void execute(AbstractCommand cmd) 459 + { 460 + commandManager.executeCommand(cmd); 461 + } 462 + 463 + public void flushUndoRedo() 464 + { 465 + commandManager.flush(); 466 + } 467 + 445 468 @Override 446 469 protected void undoEDT() 447 470 { 448 - invokeLater(() -> { 449 - commandManager.undo(); 450 - }); 471 + assert (SwingUtilities.isEventDispatchThread()); 472 + 473 + commandManager.action_Undo(); 451 474 } 452 475 453 476 @Override 454 477 protected void redoEDT() 455 478 { 456 - invokeLater(() -> { 457 - commandManager.redo(); 458 - }); 479 + assert (SwingUtilities.isEventDispatchThread()); 480 + 481 + commandManager.action_Redo(); 459 482 } 460 483 461 484 private void resetCam() ··· 523 546 // parenting lines 524 547 RenderState.setColor(PresetColor.TEAL); 525 548 for (WorldLocation loc : locations) { 526 - if (loc == parentingMarker) { 549 + if (loc == parentingLoc) { 527 550 if (framePick != null) { 528 551 LineRenderQueue.addLine( 529 552 LineRenderQueue.addVertex().setPosition(loc.getX(), loc.getY(), 0).getIndex(), ··· 714 737 } 715 738 } 716 739 740 + public void onModified() 741 + { 742 + // nothing to do 743 + } 744 + 717 745 @Override 718 746 protected boolean isModified() 719 747 { ··· 753 781 } 754 782 else { 755 783 if (mouseMarker == null || mouseMarker instanceof WorldLocation) 756 - setSelectedLocation((WorldLocation) mouseMarker); 784 + execute(new SetSelected(this, (WorldLocation) mouseMarker)); 757 785 } 758 786 } 759 787 ··· 778 806 public void stopHoldingLMB() 779 807 { 780 808 if (dragMarker != null) { 809 + 810 + CommandBatch batch = new CommandBatch("Set Position"); 811 + 781 812 for (WorldLocation loc : locations) { 782 813 if (loc.dragX != 0 || loc.dragY != 0) { 783 - loc.x += Math.round(loc.dragX); 784 - loc.y += Math.round(loc.dragY); 814 + int newX = loc.x + Math.round(loc.dragX); 815 + int newY = loc.y + Math.round(loc.dragY); 785 816 loc.dragX = 0; 786 817 loc.dragY = 0; 818 + 819 + batch.addCommand(new SetPosition(loc, newX, newY)); 787 820 } 788 821 789 822 for (WorldPathElement elem : loc.path) { 790 823 if (elem.dragX != 0 || elem.dragY != 0) { 791 - elem.x += Math.round(elem.dragX); 792 - elem.y += Math.round(elem.dragY); 824 + int newX = elem.x + Math.round(elem.dragX); 825 + int newY = elem.y + Math.round(elem.dragY); 793 826 elem.dragX = 0; 794 827 elem.dragY = 0; 828 + 829 + batch.addCommand(new SetPosition(elem, newX, newY)); 795 830 } 796 831 } 797 832 } 833 + 834 + execute(batch); 798 835 799 836 dragMarker = null; 800 837 } ··· 803 840 @Override 804 841 public void startHoldingRMB() 805 842 { 806 - if (mouseMarker != null && mouseMarker instanceof WorldLocation) { 807 - parentingMarker = mouseMarker; 843 + if (mouseMarker != null && mouseMarker instanceof WorldLocation mouseLoc) { 844 + parentingLoc = mouseLoc; 808 845 } 809 846 } 810 847 811 848 @Override 812 849 public void stopHoldingRMB() 813 850 { 814 - if (parentingMarker != null) { 851 + if (parentingLoc != null) { 815 852 if (mouseMarker != null) { 816 853 if (mouseMarker instanceof WorldLocation loc) 817 - ((WorldLocation) parentingMarker).parent = loc; 854 + execute(new SetParent(parentingLoc, loc)); 818 855 else if (mouseMarker instanceof WorldPathElement pathElem) 819 - ((WorldLocation) parentingMarker).parent = pathElem.owner; 856 + execute(new SetParent(parentingLoc, pathElem.owner)); 820 857 } 821 858 822 - parentingMarker = null; 859 + parentingLoc = null; 823 860 } 824 861 } 825 862 826 - private static void addPathPoint(WorldMarker marker) 863 + private void addPathPoint(WorldMarker marker) 827 864 { 828 865 if (marker instanceof WorldLocation) { 829 866 WorldLocation loc = (WorldLocation) marker; ··· 860 897 861 898 int dX = prev1X - prev2X; 862 899 int dY = prev1Y - prev2Y; 863 - loc.path.add(new WorldPathElement(loc, prev1X + dX, prev1Y + dY)); 900 + 901 + WorldPathElement elem = new WorldPathElement(loc, prev1X + dX, prev1Y + dY); 902 + execute(new AddPathElem(elem)); 864 903 } 865 904 else if (marker instanceof WorldPathElement) { 866 905 WorldPathElement elem = (WorldPathElement) marker; ··· 907 946 dY = (prev2Y - prev1Y) / 2; 908 947 } 909 948 910 - elem.owner.path.add(pos + 1, new WorldPathElement(elem.owner, prev1X + dX, prev1Y + dY)); 949 + WorldPathElement newElem = new WorldPathElement(elem.owner, prev1X + dX, prev1Y + dY); 950 + execute(new AddPathElem(newElem, pos + 1)); 911 951 } 912 952 } 913 953 914 - private static void removePathPoint(WorldMarker marker) 954 + private void removePathPoint(WorldMarker marker) 915 955 { 916 - if (marker instanceof WorldLocation) { 917 - WorldLocation loc = (WorldLocation) marker; 956 + if (marker instanceof WorldLocation loc) { 918 957 if (loc.path.size() == 0) { 919 958 Toolkit.getDefaultToolkit().beep(); 920 959 Logger.log("Path is empty!"); 921 960 return; 922 961 } 923 962 924 - loc.path.remove(loc.path.size() - 1); 963 + execute(new RemovePathElem(loc, loc.path.size() - 1)); 964 + } 965 + else if (marker instanceof WorldPathElement elem) { 966 + execute(new RemovePathElem(elem.owner, elem.owner.path.indexOf(elem))); 925 967 } 926 - else if (marker instanceof WorldPathElement) { 927 - WorldPathElement elem = (WorldPathElement) marker; 928 - elem.owner.path.remove(elem); 968 + } 969 + 970 + private void refreshSelected() 971 + { 972 + if (selectedLocation != null) { 973 + suppressCommands = true; 974 + locationsBox.setSelectedItem(selectedLocation.name); 975 + storyBox.setSelectedItem(selectedLocation.descUpdate); 976 + suppressCommands = false; 929 977 } 930 978 } 931 979 ··· 933 981 { 934 982 selectedLocation = loc; 935 983 selectedPanel.setVisible(selectedLocation != null); 936 - if (selectedLocation != null) { 937 - locationsBox.setSelectedItem(selectedLocation.name); 938 - storyBox.setSelectedItem(selectedLocation.descUpdate); 984 + refreshSelected(); 985 + } 986 + 987 + public static class SetSelected extends AbstractCommand 988 + { 989 + private WorldMapEditor editor; 990 + private final WorldLocation next; 991 + private final WorldLocation prev; 992 + 993 + public SetSelected(WorldMapEditor editor, WorldLocation selected) 994 + { 995 + super("Set Selected"); 996 + 997 + this.editor = editor; 998 + 999 + this.next = selected; 1000 + this.prev = editor.selectedLocation; 1001 + } 1002 + 1003 + @Override 1004 + public void exec() 1005 + { 1006 + super.exec(); 1007 + 1008 + editor.setSelectedLocation(next); 1009 + } 1010 + 1011 + @Override 1012 + public void undo() 1013 + { 1014 + super.undo(); 1015 + 1016 + editor.setSelectedLocation(prev); 939 1017 } 940 1018 } 941 1019 }
+214 -1
src/main/java/game/worldmap/WorldMapModder.java
··· 13 13 import app.Directories; 14 14 import app.StarRodMain; 15 15 import app.input.InputFileException; 16 + import common.commands.AbstractCommand; 16 17 import util.Logger; 17 18 import util.xml.XmlWrapper.XmlReader; 18 19 import util.xml.XmlWrapper.XmlTag; ··· 27 28 public static class WorldMarker 28 29 { 29 30 public boolean mouseOver; 31 + public float dragX, dragY; 30 32 31 33 protected int x, y; 32 - public float dragX, dragY; 33 34 34 35 public WorldMarker(int x, int y) 35 36 { ··· 221 222 out[i] = WorldMapModder.stripPrefix(in[i], prefix); 222 223 } 223 224 return out; 225 + } 226 + 227 + public static class SetParent extends AbstractCommand 228 + { 229 + private final WorldLocation loc; 230 + private final WorldLocation next; 231 + private final WorldLocation prev; 232 + 233 + public SetParent(WorldLocation loc, WorldLocation parent) 234 + { 235 + super("Set Parent"); 236 + 237 + this.loc = loc; 238 + 239 + prev = loc.parent; 240 + next = parent; 241 + } 242 + 243 + @Override 244 + public void exec() 245 + { 246 + super.exec(); 247 + 248 + loc.parent = next; 249 + } 250 + 251 + @Override 252 + public void undo() 253 + { 254 + super.undo(); 255 + 256 + loc.parent = prev; 257 + } 258 + } 259 + 260 + public static class SetLocName extends AbstractCommand 261 + { 262 + private final WorldLocation loc; 263 + private final Runnable callback; 264 + private final String next; 265 + private final String prev; 266 + 267 + public SetLocName(WorldLocation loc, String name, Runnable callback) 268 + { 269 + super("Set Parent"); 270 + 271 + this.loc = loc; 272 + this.callback = callback; 273 + 274 + prev = loc.name; 275 + next = name; 276 + } 277 + 278 + @Override 279 + public void exec() 280 + { 281 + super.exec(); 282 + 283 + loc.name = next; 284 + callback.run(); 285 + } 286 + 287 + @Override 288 + public void undo() 289 + { 290 + super.undo(); 291 + 292 + loc.name = prev; 293 + callback.run(); 294 + } 295 + } 296 + 297 + public static class SetLocStory extends AbstractCommand 298 + { 299 + private final WorldLocation loc; 300 + private final Runnable callback; 301 + private final String next; 302 + private final String prev; 303 + 304 + public SetLocStory(WorldLocation loc, String name, Runnable callback) 305 + { 306 + super("Set Parent"); 307 + 308 + this.loc = loc; 309 + this.callback = callback; 310 + 311 + prev = loc.descUpdate; 312 + next = name; 313 + } 314 + 315 + @Override 316 + public void exec() 317 + { 318 + super.exec(); 319 + 320 + loc.descUpdate = next; 321 + callback.run(); 322 + } 323 + 324 + @Override 325 + public void undo() 326 + { 327 + super.undo(); 328 + 329 + loc.descUpdate = prev; 330 + callback.run(); 331 + } 332 + } 333 + 334 + public static class SetPosition extends AbstractCommand 335 + { 336 + private final WorldMarker marker; 337 + private final int newX, newY; 338 + private final int oldX, oldY; 339 + 340 + public SetPosition(WorldMarker marker, int newX, int newY) 341 + { 342 + super("Set Position"); 343 + 344 + this.marker = marker; 345 + 346 + this.newX = newX; 347 + this.newY = newY; 348 + 349 + this.oldX = marker.x; 350 + this.oldY = marker.y; 351 + } 352 + 353 + @Override 354 + public void exec() 355 + { 356 + super.exec(); 357 + 358 + marker.x = newX; 359 + marker.y = newY; 360 + } 361 + 362 + @Override 363 + public void undo() 364 + { 365 + super.undo(); 366 + 367 + marker.x = oldX; 368 + marker.y = oldY; 369 + } 370 + } 371 + 372 + public static class AddPathElem extends AbstractCommand 373 + { 374 + private final WorldPathElement elem; 375 + private final int pos; 376 + 377 + public AddPathElem(WorldPathElement elem) 378 + { 379 + this(elem, elem.owner.path.size()); 380 + } 381 + 382 + public AddPathElem(WorldPathElement elem, int pos) 383 + { 384 + super("Add Path"); 385 + 386 + this.elem = elem; 387 + this.pos = pos; 388 + } 389 + 390 + @Override 391 + public void exec() 392 + { 393 + super.exec(); 394 + 395 + elem.owner.path.add(pos, elem); 396 + } 397 + 398 + @Override 399 + public void undo() 400 + { 401 + super.undo(); 402 + 403 + elem.owner.path.remove(pos); 404 + } 405 + } 406 + 407 + public static class RemovePathElem extends AbstractCommand 408 + { 409 + private final WorldLocation loc; 410 + private final WorldPathElement elem; 411 + private final int pos; 412 + 413 + public RemovePathElem(WorldLocation loc, int pos) 414 + { 415 + super("Remove Path"); 416 + 417 + this.loc = loc; 418 + this.elem = loc.path.get(pos); 419 + this.pos = pos; 420 + } 421 + 422 + @Override 423 + public void exec() 424 + { 425 + super.exec(); 426 + 427 + loc.path.remove(pos); 428 + } 429 + 430 + @Override 431 + public void undo() 432 + { 433 + super.undo(); 434 + 435 + loc.path.add(pos, elem); 436 + } 224 437 } 225 438 }