├── editor ├── src │ ├── main │ │ ├── resources │ │ │ ├── editor │ │ │ │ ├── large │ │ │ │ │ ├── plus.png │ │ │ │ │ ├── image.png │ │ │ │ │ ├── application.ico │ │ │ │ │ ├── application.png │ │ │ │ │ ├── transparent.png │ │ │ │ │ ├── animation-play.png │ │ │ │ │ └── animation-stop.png │ │ │ │ ├── small │ │ │ │ │ ├── bomb.png │ │ │ │ │ ├── bug.png │ │ │ │ │ ├── cake.png │ │ │ │ │ ├── copy.png │ │ │ │ │ ├── cut.png │ │ │ │ │ ├── find.png │ │ │ │ │ ├── grid.png │ │ │ │ │ ├── help.png │ │ │ │ │ ├── item.png │ │ │ │ │ ├── key.png │ │ │ │ │ ├── menu.png │ │ │ │ │ ├── new.png │ │ │ │ │ ├── open.png │ │ │ │ │ ├── redo.png │ │ │ │ │ ├── run.png │ │ │ │ │ ├── save.png │ │ │ │ │ ├── stop.png │ │ │ │ │ ├── undo.png │ │ │ │ │ ├── battle.png │ │ │ │ │ ├── block.png │ │ │ │ │ ├── board.png │ │ │ │ │ ├── bricks.png │ │ │ │ │ ├── bucket.png │ │ │ │ │ ├── cheese.png │ │ │ │ │ ├── coins.png │ │ │ │ │ ├── cursor.png │ │ │ │ │ ├── delete.png │ │ │ │ │ ├── enemy.png │ │ │ │ │ ├── eraser.png │ │ │ │ │ ├── paste.png │ │ │ │ │ ├── pencil.png │ │ │ │ │ ├── project.png │ │ │ │ │ ├── replace.png │ │ │ │ │ ├── robot.png │ │ │ │ │ ├── zoom-in.png │ │ │ │ │ ├── animation.png │ │ │ │ │ ├── arrow-090.png │ │ │ │ │ ├── arrow-270.png │ │ │ │ │ ├── character.png │ │ │ │ │ ├── equipment.png │ │ │ │ │ ├── grid-snap.png │ │ │ │ │ ├── new-board.png │ │ │ │ │ ├── new-enemy.png │ │ │ │ │ ├── new-item.png │ │ │ │ │ ├── new-tile.png │ │ │ │ │ ├── save-all.png │ │ │ │ │ ├── selection.png │ │ │ │ │ ├── zoom-out.png │ │ │ │ │ ├── flag-checker.png │ │ │ │ │ ├── information.png │ │ │ │ │ ├── layer-vector.png │ │ │ │ │ ├── new-program.png │ │ │ │ │ ├── new-project.png │ │ │ │ │ ├── paint-brush.png │ │ │ │ │ ├── shape-curve.png │ │ │ │ │ ├── new-animation.png │ │ │ │ │ ├── new-character.png │ │ │ │ │ ├── flashlight-shine.png │ │ │ │ │ ├── new-special-move.png │ │ │ │ │ ├── new-status-effect.png │ │ │ │ │ ├── project-explorer.png │ │ │ │ │ ├── information-balloon.png │ │ │ │ │ ├── layer-shape-polyline.png │ │ │ │ │ └── program-shape-polyline.png │ │ │ │ └── properties │ │ │ │ │ └── editor.properties │ │ │ └── logback.xml │ │ └── java │ │ │ └── net │ │ │ └── rpgtoolkit │ │ │ └── editor │ │ │ ├── ui │ │ │ ├── ProjectPanel.java │ │ │ ├── actions │ │ │ │ ├── HelpAction.java │ │ │ │ ├── LightAction.java │ │ │ │ ├── ShowGridAction.java │ │ │ │ ├── NewProjectAction.java │ │ │ │ ├── OpenFileAction.java │ │ │ │ ├── ExitAction.java │ │ │ │ ├── ZoomOutAction.java │ │ │ │ ├── ZoomInAction.java │ │ │ │ ├── SpriteAction.java │ │ │ │ ├── StartPositionAction.java │ │ │ │ ├── BucketAction.java │ │ │ │ ├── SelectionAction.java │ │ │ │ ├── PencilAction.java │ │ │ │ ├── EraserAction.java │ │ │ │ ├── VectorAction.java │ │ │ │ ├── SaveAction.java │ │ │ │ ├── OpenProjectAction.java │ │ │ │ ├── StopAction.java │ │ │ │ └── RunAction.java │ │ │ ├── EditorButton.java │ │ │ ├── menu │ │ │ │ ├── ToolsMenu.java │ │ │ │ ├── HelpMenu.java │ │ │ │ ├── RunMenu.java │ │ │ │ ├── MainMenuBar.java │ │ │ │ ├── ViewMenu.java │ │ │ │ └── EditMenu.java │ │ │ ├── listeners │ │ │ │ ├── LayerChangeListener.java │ │ │ │ ├── TileSelectionListener.java │ │ │ │ ├── SnapToGridItemListener.java │ │ │ │ ├── ShowVectorsItemListener.java │ │ │ │ ├── ShowCoordinatesItemListener.java │ │ │ │ ├── ShowGridItemListener.java │ │ │ │ ├── PopupListFilesListener.java │ │ │ │ └── TileSetSelectionListener.java │ │ │ ├── ToolkitDesktopManager.java │ │ │ ├── DoubleField.java │ │ │ ├── SingleRootFileSystemView.java │ │ │ ├── IntegerField.java │ │ │ ├── resources │ │ │ │ └── Icons.java │ │ │ ├── ModelPanelFactory.java │ │ │ ├── WholeNumberField.java │ │ │ ├── EditorFactory.java │ │ │ ├── PropertiesPanel.java │ │ │ ├── AbstractModelPanel.java │ │ │ ├── AbstractImagePanel.java │ │ │ ├── TileSetTabbedPane.java │ │ │ └── AssetEditorWindow.java │ │ │ ├── editors │ │ │ ├── board │ │ │ │ ├── LayerChangedEvent.java │ │ │ │ ├── panels │ │ │ │ │ ├── BoardModelPanel.java │ │ │ │ │ └── BoardPanel.java │ │ │ │ ├── Brush.java │ │ │ │ ├── StartPositionBrush.java │ │ │ │ ├── SelectionBrush.java │ │ │ │ ├── AbstractBrush.java │ │ │ │ ├── NewBoardDialog.java │ │ │ │ ├── MultiLayerContainer.java │ │ │ │ ├── CustomBrush.java │ │ │ │ ├── BucketBrush.java │ │ │ │ └── ShapeBrush.java │ │ │ ├── ItemModelPanel.java │ │ │ ├── character │ │ │ │ └── CharacterModelPanel.java │ │ │ ├── TileSelectionEvent.java │ │ │ ├── TileRegionSelectionEvent.java │ │ │ ├── sprite │ │ │ │ ├── AnimationsTablePanel.java │ │ │ │ ├── listener │ │ │ │ │ ├── AddAnimationActionListener.java │ │ │ │ │ ├── BrowseAnimationActionListener.java │ │ │ │ │ ├── AnimationListSelectionListener.java │ │ │ │ │ └── RemoveAnimationActionListener.java │ │ │ │ ├── AnimationsTableModel.java │ │ │ │ └── ProfilePanel.java │ │ │ ├── tileset │ │ │ │ ├── TileSetUtil.java │ │ │ │ └── NewTilesetDialog.java │ │ │ ├── animation │ │ │ │ ├── AddSpriteSheetButton.java │ │ │ │ └── SpriteSheetImage.java │ │ │ ├── ItemEditor.java │ │ │ └── AnimationEditor.java │ │ │ ├── utilities │ │ │ ├── TransparentDrawer.java │ │ │ └── FileTools.java │ │ │ └── properties │ │ │ ├── EditorProperties.java │ │ │ └── EditorProperty.java │ └── test │ │ └── java │ │ └── net │ │ └── rpgtoolkit │ │ └── editor │ │ ├── UserInterfaceTest.java │ │ └── utilities │ │ └── FileToolsTest.java ├── licenseheader.txt └── pom.xml ├── CONTRIBUTORS.md ├── LICENSE.md ├── .gitignore ├── README.md └── pluginsystem ├── pom.xml └── src └── main └── java └── net └── rpgtoolkit └── pluginsystem └── Engine.java /editor/src/main/resources/editor/large/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/large/plus.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/bomb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/bomb.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/bug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/bug.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/cake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/cake.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/copy.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/cut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/cut.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/find.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/grid.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/help.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/item.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/key.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/menu.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/open.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/redo.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/run.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/save.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/stop.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/undo.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/large/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/large/image.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/battle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/battle.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/block.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/board.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/bricks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/bricks.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/bucket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/bucket.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/cheese.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/cheese.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/coins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/coins.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/cursor.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/delete.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/enemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/enemy.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/eraser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/eraser.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/paste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/paste.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/pencil.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/project.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/replace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/replace.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/robot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/robot.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/zoom-in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/zoom-in.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/animation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/animation.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/arrow-090.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/arrow-090.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/arrow-270.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/arrow-270.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/character.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/character.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/equipment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/equipment.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/grid-snap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/grid-snap.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new-board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new-board.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new-enemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new-enemy.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new-item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new-item.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new-tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new-tile.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/save-all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/save-all.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/selection.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/zoom-out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/zoom-out.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/large/application.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/large/application.ico -------------------------------------------------------------------------------- /editor/src/main/resources/editor/large/application.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/large/application.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/large/transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/large/transparent.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/flag-checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/flag-checker.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/information.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/information.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/layer-vector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/layer-vector.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new-program.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new-program.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new-project.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/paint-brush.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/paint-brush.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/shape-curve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/shape-curve.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/large/animation-play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/large/animation-play.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/large/animation-stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/large/animation-stop.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new-animation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new-animation.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new-character.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new-character.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/flashlight-shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/flashlight-shine.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new-special-move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new-special-move.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/new-status-effect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/new-status-effect.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/project-explorer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/project-explorer.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/information-balloon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/information-balloon.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/layer-shape-polyline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/layer-shape-polyline.png -------------------------------------------------------------------------------- /editor/src/main/resources/editor/small/program-shape-polyline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpgtoolkit/editor/HEAD/editor/src/main/resources/editor/small/program-shape-polyline.png -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # Contributors 2 | 3 | - [mariobadr](https://github.com/mariobadr) 4 | - [Chris Hutchinson](https://github.com/chutchinson) 5 | - [Joshua Michael Daly](https://github.com/swordmaster2k) 6 | - [goblinJoel](https://github.com/goblinJoel) 7 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # License 2 | 3 | Mozilla Public License 2.0 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v. 2.0. If a copy of the MPL was not distributed with this file, 7 | you can obtain one at http://mozilla.org/MPL/2.0/. -------------------------------------------------------------------------------- /editor/licenseheader.txt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of 5 | * the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 | */ -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/ProjectPanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import javax.swing.JPanel; 11 | 12 | /** 13 | * 14 | * @author Joshua Michael Daly 15 | */ 16 | public class ProjectPanel extends JPanel { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Source # 2 | ################### 3 | *.class 4 | 5 | # Package Files # 6 | ################# 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # Testing Folders # 12 | ################### 13 | #main/ 14 | #game/ 15 | #/dist/ 16 | /nbproject/private/ 17 | */nbproject/ 18 | /manifest.mf 19 | /build.xml 20 | /build/ 21 | /nbdist/ 22 | 23 | # Gradle # 24 | ################# 25 | 26 | .gradle/ 27 | build/ 28 | out/ 29 | /.nb-gradle/private/ 30 | /.nb-gradle/ 31 | /common/target/ 32 | /editor/target/ 33 | /deps/target/ 34 | /editor/nbactions.xml 35 | **/nb-configuration.xml 36 | /target/ 37 | 38 | # Log Files # 39 | ############## 40 | *.log 41 | 42 | /pluginsystem/target/ -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/HelpAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | 13 | /** 14 | * 15 | * @author Joshua Michael Daly 16 | */ 17 | public class HelpAction extends AbstractAction { 18 | 19 | @Override 20 | public void actionPerformed(ActionEvent e) { 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/LightAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | 13 | /** 14 | * 15 | * @author Joshua Michael Daly 16 | */ 17 | public class LightAction extends AbstractAction { 18 | 19 | @Override 20 | public void actionPerformed(ActionEvent e) { 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/EditorButton.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import javax.swing.*; 11 | 12 | /** 13 | * 14 | * @author Geoff Wilson 15 | * @author Joshua Michael Daly 16 | */ 17 | public class EditorButton extends JButton { 18 | 19 | public EditorButton() { 20 | super(); 21 | this.setBorder(null); 22 | this.setFocusable(false); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/menu/ToolsMenu.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.menu; 9 | 10 | import java.awt.event.KeyEvent; 11 | import javax.swing.JMenu; 12 | 13 | /** 14 | * 15 | * @author Joshua Michael Daly 16 | */ 17 | public final class ToolsMenu extends JMenu { 18 | 19 | public ToolsMenu() { 20 | super("Tools"); 21 | 22 | this.setMnemonic(KeyEvent.VK_T); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/LayerChangedEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board; 9 | 10 | import java.util.EventObject; 11 | 12 | /** 13 | * 14 | * 15 | * @author Joshua Michael Daly 16 | */ 17 | public class LayerChangedEvent extends EventObject { 18 | 19 | /** 20 | * 21 | * 22 | * @param layer 23 | */ 24 | public LayerChangedEvent(BoardLayerView layer) { 25 | super(layer); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/ShowGridAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | 13 | /** 14 | * 15 | * @author Joshua Michael Daly 16 | */ 17 | public class ShowGridAction extends AbstractAction { 18 | 19 | public ShowGridAction() { 20 | 21 | } 22 | 23 | @Override 24 | public void actionPerformed(ActionEvent e) { 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/ItemModelPanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors; 9 | 10 | import net.rpgtoolkit.common.assets.Item; 11 | import net.rpgtoolkit.editor.editors.sprite.AbstractSpriteModelPanel; 12 | 13 | /** 14 | * 15 | * @author Joshua Michael Daly 16 | */ 17 | public class ItemModelPanel extends AbstractSpriteModelPanel { 18 | 19 | private Item item; 20 | 21 | public ItemModelPanel(Item model) { 22 | super(model); 23 | item = model; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/listeners/LayerChangeListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.listeners; 9 | 10 | import java.util.EventListener; 11 | import net.rpgtoolkit.editor.editors.board.LayerChangedEvent; 12 | 13 | /** 14 | * 15 | * 16 | * @author Joshua Michael Daly 17 | */ 18 | public interface LayerChangeListener extends EventListener { 19 | 20 | /** 21 | * 22 | * 23 | * @param e 24 | */ 25 | public void layerChanged(LayerChangedEvent e); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/NewProjectAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | import net.rpgtoolkit.editor.MainWindow; 13 | 14 | /** 15 | * 16 | * @author Joshua Michael Daly 17 | */ 18 | public class NewProjectAction extends AbstractAction { 19 | 20 | @Override 21 | public void actionPerformed(ActionEvent e) { 22 | MainWindow.getInstance().createNewProject(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/OpenFileAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | import net.rpgtoolkit.editor.utilities.EditorFileManager; 13 | 14 | /** 15 | * 16 | * @author Joshua Michael Daly 17 | */ 18 | public class OpenFileAction extends AbstractAction { 19 | 20 | @Override 21 | public void actionPerformed(ActionEvent e) { 22 | EditorFileManager.openFile(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/character/CharacterModelPanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.character; 9 | 10 | import net.rpgtoolkit.common.assets.Player; 11 | import net.rpgtoolkit.editor.editors.sprite.AbstractSpriteModelPanel; 12 | 13 | /** 14 | * 15 | * @author Joshua Michael Daly 16 | */ 17 | public class CharacterModelPanel extends AbstractSpriteModelPanel { 18 | 19 | private final Player player; 20 | 21 | public CharacterModelPanel(Player model) { 22 | super(model); 23 | player = model; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/TileSelectionEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors; 9 | 10 | import java.util.EventObject; 11 | import net.rpgtoolkit.common.assets.Tile; 12 | 13 | /** 14 | * 15 | * 16 | * @author Joshua Michael Daly 17 | */ 18 | public class TileSelectionEvent extends EventObject { 19 | 20 | private final Tile tile; 21 | 22 | public TileSelectionEvent(Object source, Tile tile) { 23 | super(source); 24 | this.tile = tile; 25 | } 26 | 27 | public Tile getTile() { 28 | return tile; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/ExitAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import java.awt.event.WindowEvent; 12 | import javax.swing.AbstractAction; 13 | import net.rpgtoolkit.editor.MainWindow; 14 | 15 | /** 16 | * 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public class ExitAction extends AbstractAction { 21 | 22 | @Override 23 | public void actionPerformed(ActionEvent e) { 24 | MainWindow.getInstance().dispatchEvent(new WindowEvent(MainWindow.getInstance(), WindowEvent.WINDOW_CLOSING)); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/ZoomOutAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | import net.rpgtoolkit.editor.MainWindow; 13 | import net.rpgtoolkit.editor.editors.BoardEditor; 14 | 15 | /** 16 | * 17 | * @author Joshua Michael Daly 18 | */ 19 | public class ZoomOutAction extends AbstractAction { 20 | 21 | @Override 22 | public void actionPerformed(ActionEvent e) { 23 | BoardEditor editor = MainWindow.getInstance().getCurrentBoardEditor(); 24 | 25 | if (editor != null) { 26 | editor.zoomOut(); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/listeners/TileSelectionListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.listeners; 9 | 10 | import java.util.EventListener; 11 | import net.rpgtoolkit.editor.editors.TileRegionSelectionEvent; 12 | import net.rpgtoolkit.editor.editors.TileSelectionEvent; 13 | 14 | /** 15 | * 16 | * 17 | * @author Joshua Michael Daly 18 | */ 19 | public interface TileSelectionListener extends EventListener { 20 | 21 | /** 22 | * 23 | * @param e 24 | */ 25 | public void tileSelected(TileSelectionEvent e); 26 | 27 | /** 28 | * 29 | * @param e 30 | */ 31 | public void tileRegionSelected(TileRegionSelectionEvent e); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/ZoomInAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | import net.rpgtoolkit.editor.MainWindow; 13 | import net.rpgtoolkit.editor.editors.BoardEditor; 14 | 15 | /** 16 | * 17 | * @author Joshua Michael Daly 18 | */ 19 | public class ZoomInAction extends AbstractAction { 20 | 21 | /** 22 | * 23 | * @param e 24 | */ 25 | @Override 26 | public void actionPerformed(ActionEvent e) { 27 | BoardEditor editor = MainWindow.getInstance().getCurrentBoardEditor(); 28 | 29 | if (editor != null) { 30 | editor.zoomIn(); 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/utilities/TransparentDrawer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.utilities; 9 | 10 | import java.awt.Graphics; 11 | import java.awt.Image; 12 | import net.rpgtoolkit.editor.ui.resources.Icons; 13 | 14 | /** 15 | * 16 | * @author Joshua Michael Daly 17 | */ 18 | public class TransparentDrawer { 19 | 20 | public static void drawTransparentBackground(Graphics g, int width, int height) { 21 | Image tileImage = Icons.getIcon("transparent", Icons.Size.LARGE).getImage(); 22 | 23 | for (int x = 0; x < width; x += tileImage.getWidth(null)) { 24 | for (int y = 0; y < height; y += tileImage.getHeight(null)) { 25 | g.drawImage(tileImage, x, y, null); 26 | } 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/TileRegionSelectionEvent.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors; 9 | 10 | import java.util.EventObject; 11 | import net.rpgtoolkit.common.assets.Tile; 12 | 13 | /** 14 | * 15 | * 16 | * @author Joshua Michael Daly 17 | */ 18 | public class TileRegionSelectionEvent extends EventObject { 19 | 20 | private final Tile[][] tiles; 21 | 22 | /** 23 | * 24 | * @param source 25 | * @param tiles 26 | */ 27 | public TileRegionSelectionEvent(Object source, Tile[][] tiles) { 28 | super(source); 29 | this.tiles = tiles; 30 | } 31 | 32 | /** 33 | * 34 | * @return 35 | */ 36 | public Tile[][] getTiles() { 37 | return tiles; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/SpriteAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | import net.rpgtoolkit.editor.editors.BoardEditor; 13 | import net.rpgtoolkit.editor.editors.board.BoardSpriteBrush; 14 | import net.rpgtoolkit.editor.MainWindow; 15 | 16 | /** 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public class SpriteAction extends AbstractAction { 21 | 22 | @Override 23 | public void actionPerformed(ActionEvent e) { 24 | BoardEditor.toggleSelectedOnBoardEditor(); 25 | 26 | BoardSpriteBrush brush = new BoardSpriteBrush(); 27 | MainWindow.getInstance().setCurrentBrush(brush); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/StartPositionAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | import net.rpgtoolkit.editor.editors.BoardEditor; 13 | import net.rpgtoolkit.editor.editors.board.StartPositionBrush; 14 | import net.rpgtoolkit.editor.MainWindow; 15 | 16 | /** 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public class StartPositionAction extends AbstractAction { 21 | 22 | @Override 23 | public void actionPerformed(ActionEvent e) { 24 | BoardEditor.toggleSelectedOnBoardEditor(); 25 | 26 | StartPositionBrush brush = new StartPositionBrush(); 27 | MainWindow.getInstance().setCurrentBrush(brush); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/listeners/SnapToGridItemListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.listeners; 9 | 10 | import java.awt.event.ItemEvent; 11 | import java.awt.event.ItemListener; 12 | import javax.swing.JCheckBoxMenuItem; 13 | import net.rpgtoolkit.editor.MainWindow; 14 | 15 | /** 16 | * 17 | * @author Joshua Michael Daly 18 | */ 19 | public class SnapToGridItemListener implements ItemListener { 20 | 21 | @Override 22 | public void itemStateChanged(ItemEvent e) { 23 | JCheckBoxMenuItem snapToGridMenuItem = (JCheckBoxMenuItem) e.getItem(); 24 | 25 | if (snapToGridMenuItem.getState()) { 26 | MainWindow.getInstance().setSnapToGrid(true); 27 | } else { 28 | MainWindow.getInstance().setSnapToGrid(false); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/BucketAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | import net.rpgtoolkit.editor.editors.BoardEditor; 13 | import net.rpgtoolkit.editor.editors.board.BucketBrush; 14 | import net.rpgtoolkit.editor.MainWindow; 15 | 16 | /** 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public class BucketAction extends AbstractAction { 21 | 22 | @Override 23 | public void actionPerformed(ActionEvent e) { 24 | BoardEditor.toggleSelectedOnBoardEditor(); 25 | 26 | BucketBrush brush = new BucketBrush(); 27 | brush.setPourTile(MainWindow.getInstance().getLastSelectedTile()); 28 | MainWindow.getInstance().setCurrentBrush(brush); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/SelectionAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | import net.rpgtoolkit.common.assets.Tile; 13 | import net.rpgtoolkit.editor.editors.BoardEditor; 14 | import net.rpgtoolkit.editor.editors.board.SelectionBrush; 15 | import net.rpgtoolkit.editor.MainWindow; 16 | 17 | /** 18 | * 19 | * @author Joshua Michael Daly 20 | */ 21 | public class SelectionAction extends AbstractAction { 22 | 23 | @Override 24 | public void actionPerformed(ActionEvent e) { 25 | BoardEditor.toggleSelectedOnBoardEditor(); 26 | 27 | SelectionBrush brush = new SelectionBrush(new Tile[1][1]); 28 | MainWindow.getInstance().setCurrentBrush(brush); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/panels/BoardModelPanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board.panels; 9 | 10 | import net.rpgtoolkit.editor.editors.BoardEditor; 11 | import net.rpgtoolkit.editor.ui.AbstractModelPanel; 12 | import net.rpgtoolkit.editor.MainWindow; 13 | 14 | /** 15 | * 16 | * @author Joshua Michael Daly 17 | */ 18 | public class BoardModelPanel extends AbstractModelPanel { 19 | 20 | public BoardModelPanel(Object model) { 21 | super(model); 22 | } 23 | 24 | public BoardEditor getBoardEditor() { 25 | return MainWindow.getInstance().getCurrentBoardEditor(); 26 | } 27 | 28 | public void updateCurrentBoardView() { 29 | BoardEditor editor = MainWindow.getInstance().getCurrentBoardEditor(); 30 | 31 | if (editor != null) { 32 | editor.getBoardView().repaint(); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /editor/src/main/resources/editor/properties/editor.properties: -------------------------------------------------------------------------------- 1 | # Title. 2 | editor.ui.title=RPGToolkit 4.0.0 3 | 4 | # Plugins directory. 5 | editor.plugins.directory=plugins 6 | 7 | # UI Tooltips. 8 | editor.ui.tooltip.new=New File 9 | editor.ui.tooltip.open=Open File 10 | editor.ui.tooltip.save=Save File 11 | editor.ui.tooltip.saveall=Save All Files 12 | editor.ui.tooltip.cut=Cut 13 | editor.ui.tooltip.copy=Copy 14 | editor.ui.tooltip.paste=Paste 15 | editor.ui.tooltip.delete=Delete 16 | editor.ui.tooltip.undo=Undo 17 | editor.ui.tooltip.redo=Redo 18 | editor.ui.tooltip.drawtile=Draw Tile 19 | editor.ui.tooltip.selectregion=Select Region 20 | editor.ui.tooltip.fillregion=Fill Region 21 | editor.ui.tooltip.eraseregion=Erase Region 22 | editor.ui.tooltip.drawvector=Draw Vector 23 | editor.ui.tooltip.drawprogram=Draw Program 24 | editor.ui.tooltip.setboardsprite=Set Board Sprite 25 | editor.ui.tooltip.setboardlight=Set Board Light 26 | editor.ui.tooltip.setstartposition=Set Start Position 27 | editor.ui.tooltip.zoomin=Zoom In 28 | editor.ui.tooltip.zoomout=Zoom Out 29 | editor.ui.tooltip.rungame=Run Game 30 | editor.ui.tooltip.stopgame=Stop Game 31 | editor.ui.tooltip.help=Help -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0) 2 | 3 | ==================================== 4 | 5 | ### About RPGToolkit Editor 6 | - RPGToolkit Editor is an open-source RPG game editor designed to run with the RPGToolkit Engine. It is written in Java and is built using Maven. It is cross-platform and has been tested on both Windows and Linux debian based distributions. 7 | - For more information see the official website located at http://www.rpgtoolkit.net. 8 | 9 | ### Build 10 | - RPGToolkit Editor is compiled against Java 8. 11 | - This project uses Maven 3 as its build tool. 12 | - RPGToolkit Editor depends on [RPGToolkit Core](https://github.com/rpgtoolkit/core). 13 | 14 | ### Credits 15 | RPGToolkit Editor is an open source project, and is supported by its community. 16 | 17 | The RPGToolkit Editor team is composed of Chris Hutchinson, Joel Moore, and Joshua Michael Daly. 18 | 19 | Some icons by: 20 | 21 | * Yusuke Kamiyamane. Licensed under a Creative Commons Attribution 3.0 License. 22 | * Icons8. Licensed under a Creative Commons Attribution-NoDerivs 3.0 Unported. -------------------------------------------------------------------------------- /editor/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M:%L - %msg%n 8 | 9 | 10 | 11 | 12 | RPGToolkitEditor.log 13 | 14 | 15 | RPGToolkitEditor.log.%d{yyyy-MM-dd}.log 16 | 17 | 18 | 5 19 | 20 | 21 | 22 | %d{HH:mm:ss.SSS} %-4relative [%thread] %-5level %logger{35}.%M:%L - %msg%n 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/PencilAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.Rectangle; 11 | import java.awt.event.ActionEvent; 12 | import javax.swing.AbstractAction; 13 | import net.rpgtoolkit.editor.editors.BoardEditor; 14 | import net.rpgtoolkit.editor.editors.board.ShapeBrush; 15 | import net.rpgtoolkit.editor.MainWindow; 16 | 17 | /** 18 | * 19 | * @author Joshua Michael Daly 20 | */ 21 | public class PencilAction extends AbstractAction { 22 | 23 | @Override 24 | public void actionPerformed(ActionEvent e) { 25 | BoardEditor.toggleSelectedOnBoardEditor(); 26 | 27 | ShapeBrush brush = new ShapeBrush(); 28 | brush.setTile(MainWindow.getInstance().getLastSelectedTile()); 29 | brush.makeRectangleBrush(new Rectangle(0, 0, 1, 1)); 30 | MainWindow.getInstance().setCurrentBrush(brush); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/EraserAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.Rectangle; 11 | import java.awt.event.ActionEvent; 12 | import javax.swing.AbstractAction; 13 | import net.rpgtoolkit.common.assets.Tile; 14 | import net.rpgtoolkit.editor.editors.BoardEditor; 15 | import net.rpgtoolkit.editor.MainWindow; 16 | import net.rpgtoolkit.editor.editors.board.EraserBrush; 17 | 18 | /** 19 | * 20 | * @author Joshua Michael Daly 21 | */ 22 | public class EraserAction extends AbstractAction { 23 | 24 | @Override 25 | public void actionPerformed(ActionEvent e) { 26 | BoardEditor.toggleSelectedOnBoardEditor(); 27 | 28 | EraserBrush brush = new EraserBrush(); 29 | brush.makeRectangleBrush(new Rectangle(0, 0, 1, 1)); 30 | brush.setTile(new Tile()); 31 | MainWindow.getInstance().setCurrentBrush(brush); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/listeners/ShowVectorsItemListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.listeners; 9 | 10 | import java.awt.event.ItemEvent; 11 | import java.awt.event.ItemListener; 12 | import javax.swing.JCheckBoxMenuItem; 13 | import net.rpgtoolkit.editor.MainWindow; 14 | import net.rpgtoolkit.editor.editors.BoardEditor; 15 | 16 | /** 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public class ShowVectorsItemListener implements ItemListener { 21 | 22 | @Override 23 | public void itemStateChanged(ItemEvent e) { 24 | JCheckBoxMenuItem showVectorsMenuItem = (JCheckBoxMenuItem) e.getItem(); 25 | BoardEditor editor = MainWindow.getInstance().getCurrentBoardEditor(); 26 | if (editor != null) { 27 | MainWindow.getInstance().setShowVectors(showVectorsMenuItem.isSelected()); 28 | editor.getBoardView().repaint(); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/listeners/ShowCoordinatesItemListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.listeners; 9 | 10 | import java.awt.event.ItemEvent; 11 | import java.awt.event.ItemListener; 12 | import javax.swing.JCheckBoxMenuItem; 13 | import net.rpgtoolkit.editor.MainWindow; 14 | import net.rpgtoolkit.editor.editors.BoardEditor; 15 | 16 | /** 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public class ShowCoordinatesItemListener implements ItemListener { 21 | 22 | @Override 23 | public void itemStateChanged(ItemEvent e) { 24 | JCheckBoxMenuItem showCoordinatesMenuItem = (JCheckBoxMenuItem) e.getItem(); 25 | BoardEditor editor = MainWindow.getInstance().getCurrentBoardEditor(); 26 | if (editor != null) { 27 | MainWindow.getInstance().setShowCoordinates(showCoordinatesMenuItem.isSelected()); 28 | editor.getBoardView().repaint(); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/listeners/ShowGridItemListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.listeners; 9 | 10 | import java.awt.event.ItemEvent; 11 | import java.awt.event.ItemListener; 12 | import javax.swing.JCheckBoxMenuItem; 13 | import net.rpgtoolkit.editor.MainWindow; 14 | import net.rpgtoolkit.editor.editors.BoardEditor; 15 | 16 | /** 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public class ShowGridItemListener implements ItemListener { 21 | 22 | /** 23 | * 24 | * @param e 25 | */ 26 | @Override 27 | public void itemStateChanged(ItemEvent e) { 28 | JCheckBoxMenuItem showGridMenuItem = (JCheckBoxMenuItem) e.getItem(); 29 | BoardEditor editor = MainWindow.getInstance().getCurrentBoardEditor(); 30 | if (editor != null) { 31 | MainWindow.getInstance().setShowGrid(showGridMenuItem.isSelected()); 32 | editor.getBoardView().repaint(); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/VectorAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | import net.rpgtoolkit.editor.editors.BoardEditor; 13 | import net.rpgtoolkit.editor.editors.board.BoardVectorBrush; 14 | import net.rpgtoolkit.editor.MainWindow; 15 | 16 | /** 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public class VectorAction extends AbstractAction { 21 | 22 | @Override 23 | public void actionPerformed(ActionEvent e) { 24 | BoardEditor.toggleSelectedOnBoardEditor(); 25 | 26 | BoardVectorBrush brush = new BoardVectorBrush(); 27 | MainWindow.getInstance().setCurrentBrush(brush); 28 | 29 | if (MainWindow.getInstance().getMainMenuBar().getViewMenu() 30 | .getShowVectorsMenuItem().isSelected() == false) { 31 | MainWindow.getInstance().getMainMenuBar().getViewMenu() 32 | .getShowVectorsMenuItem().setSelected(true); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/properties/EditorProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.properties; 9 | 10 | import java.io.IOException; 11 | import java.io.InputStream; 12 | import java.util.Properties; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | /** 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public class EditorProperties { 21 | 22 | private static final Logger LOGGER = LoggerFactory.getLogger(EditorProperties.class); 23 | 24 | private static final EditorProperties INSTANCE = new EditorProperties(); 25 | private final Properties properties = new Properties(); 26 | 27 | private EditorProperties() { 28 | try (InputStream in = EditorProperties.class. 29 | getResourceAsStream("/editor/properties/editor.properties")) { 30 | properties.load(in); 31 | } catch (IOException ex) { 32 | LOGGER.error("Failed to load editor properties file.", ex); 33 | } 34 | } 35 | 36 | public static String getProperty(EditorProperty property) { 37 | return INSTANCE.properties.getProperty(property.toString()); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/ToolkitDesktopManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import javax.swing.DefaultDesktopManager; 11 | import javax.swing.JInternalFrame; 12 | 13 | /** 14 | * 15 | * 16 | * @author Geoff Wilson 17 | * @author Joshua Michael Daly 18 | */ 19 | public class ToolkitDesktopManager extends DefaultDesktopManager { 20 | 21 | public ToolkitDesktopManager() { 22 | super(); 23 | } 24 | 25 | @Override 26 | public void openFrame(JInternalFrame f) { 27 | super.openFrame(f); 28 | } 29 | 30 | @Override 31 | public void closeFrame(JInternalFrame f) { 32 | super.closeFrame(f); 33 | } 34 | 35 | @Override 36 | public void activateFrame(JInternalFrame f) { 37 | super.activateFrame(f); 38 | } 39 | 40 | @Override 41 | public void deactivateFrame(JInternalFrame f) { 42 | super.deactivateFrame(f); 43 | } 44 | 45 | @Override 46 | public void maximizeFrame(JInternalFrame f) { 47 | super.maximizeFrame(f); 48 | } 49 | 50 | @Override 51 | public void minimizeFrame(JInternalFrame f) { 52 | super.minimizeFrame(f); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/sprite/AnimationsTablePanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.sprite; 9 | 10 | import java.awt.BorderLayout; 11 | import java.awt.Dimension; 12 | import javax.swing.JPanel; 13 | import net.rpgtoolkit.editor.ui.AnimatedPanel; 14 | 15 | /** 16 | * 17 | * @author Joshua Michael Daly 18 | */ 19 | public class AnimationsTablePanel extends JPanel { 20 | 21 | private final ProfilePanel profilePanel; 22 | 23 | public AnimationsTablePanel(ProfilePanel profilePanel) { 24 | super(new BorderLayout()); 25 | this.profilePanel = profilePanel; 26 | } 27 | 28 | @Override 29 | public Dimension getPreferredSize() { 30 | super.getPreferredSize(); 31 | return calculateDimensions(super.getPreferredSize().width); 32 | } 33 | 34 | @Override 35 | public Dimension getMaximumSize() { 36 | return calculateDimensions(super.getMaximumSize().width); 37 | } 38 | 39 | @Override 40 | public Dimension getMinimumSize() { 41 | return calculateDimensions(super.getMinimumSize().width); 42 | } 43 | 44 | private Dimension calculateDimensions(int width) { 45 | int height = profilePanel.getHeight() - AnimatedPanel.DEFAULT_HEIGHT; 46 | 47 | return new Dimension(width, height); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/menu/HelpMenu.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.menu; 9 | 10 | import java.awt.event.KeyEvent; 11 | import javax.swing.JMenu; 12 | import javax.swing.JMenuItem; 13 | import net.rpgtoolkit.editor.ui.resources.Icons; 14 | 15 | /** 16 | * 17 | * @author Joshua Michael Daly 18 | */ 19 | public final class HelpMenu extends JMenu { 20 | 21 | private JMenuItem indexMenuItem; 22 | private JMenuItem aboutMenuItem; 23 | 24 | public HelpMenu() { 25 | super("Help"); 26 | 27 | this.setMnemonic(KeyEvent.VK_H); 28 | 29 | this.configureIndexMenuItem(); 30 | this.configureAboutMenuItem(); 31 | 32 | this.add(indexMenuItem); 33 | this.add(aboutMenuItem); 34 | } 35 | 36 | public void configureIndexMenuItem() { 37 | indexMenuItem = new JMenuItem("Index"); // Help Index Menu (browser based?) 38 | indexMenuItem.setIcon(Icons.getSmallIcon("help")); 39 | indexMenuItem.setEnabled(false); 40 | } 41 | 42 | public void configureAboutMenuItem() { 43 | aboutMenuItem = new JMenuItem("About"); // About Menu 44 | aboutMenuItem.setIcon(Icons.getSmallIcon("information")); 45 | aboutMenuItem.setMnemonic(KeyEvent.VK_A); 46 | aboutMenuItem.setEnabled(false); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/sprite/listener/AddAnimationActionListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.sprite.listener; 9 | 10 | import java.awt.event.ActionEvent; 11 | import java.awt.event.ActionListener; 12 | import javax.swing.JOptionPane; 13 | import javax.swing.JPanel; 14 | import javax.swing.JTable; 15 | import net.rpgtoolkit.common.assets.AbstractSprite; 16 | import net.rpgtoolkit.editor.editors.sprite.AbstractSpriteEditor; 17 | 18 | /** 19 | * 20 | * @author Joshua Michael Daly 21 | */ 22 | public class AddAnimationActionListener implements ActionListener { 23 | 24 | private final AbstractSprite sprite; 25 | 26 | private final JPanel animationsPanel; 27 | 28 | public AddAnimationActionListener(AbstractSpriteEditor editor) { 29 | sprite = editor.getSprite(); 30 | animationsPanel = editor.getAnimationsPanel(); 31 | } 32 | 33 | @Override 34 | public void actionPerformed(ActionEvent e) { 35 | String key = (String) JOptionPane.showInputDialog( 36 | animationsPanel, 37 | "Enter the handle for the new animation:", 38 | "Add Animation", 39 | JOptionPane.PLAIN_MESSAGE); 40 | 41 | if (key == null || key.isEmpty()) { 42 | return; 43 | } 44 | 45 | sprite.addAnimation(key, ""); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/SaveAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import javax.swing.AbstractAction; 12 | import javax.swing.JInternalFrame; 13 | import javax.swing.JOptionPane; 14 | import net.rpgtoolkit.editor.MainWindow; 15 | import net.rpgtoolkit.editor.ui.AssetEditorWindow; 16 | import org.slf4j.Logger; 17 | import org.slf4j.LoggerFactory; 18 | 19 | /** 20 | * 21 | * 22 | * @author Joshua Michael Daly 23 | */ 24 | public class SaveAction extends AbstractAction { 25 | 26 | private static final Logger LOGGER = LoggerFactory.getLogger(SaveAction.class); 27 | 28 | @Override 29 | public void actionPerformed(ActionEvent e) { 30 | MainWindow w = MainWindow.getInstance(); 31 | JInternalFrame frame = w.getDesktopPane().getSelectedFrame(); 32 | 33 | if (frame != null) { 34 | if (frame instanceof AssetEditorWindow) { 35 | try { 36 | AssetEditorWindow window = (AssetEditorWindow) frame; 37 | window.save(); 38 | } catch (Exception ex) { 39 | LOGGER.error("Failed to invoke save for asset frame=[{}]", frame, ex); 40 | 41 | JOptionPane.showMessageDialog(MainWindow.getInstance(), 42 | "Error saving file!", 43 | "Error on Save", 44 | JOptionPane.ERROR_MESSAGE); 45 | } 46 | } 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/DoubleField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import java.text.DecimalFormat; 11 | import javax.swing.JFormattedTextField; 12 | import javax.swing.text.NumberFormatter; 13 | 14 | /** 15 | * A field that consists of a JFormattedTextField with a default formatter that ensures it contains 16 | * doubles. (0.0, 1.0, 2.0, etc.) Use any time you want a text field in which the user should enter 17 | * only integers. 18 | * 19 | * @author Joshua Michael Daly 20 | */ 21 | public class DoubleField extends JFormattedTextField { 22 | 23 | /** 24 | * Creates a IntegerField with the specified value. This will create and use a Formatter that 25 | * requires values that are (long) integers. 26 | * 27 | * @param value Initial value for the IntegerField 28 | */ 29 | public DoubleField(Object value) { 30 | super(getDoubleFormatter()); 31 | setColumns(4); 32 | setValue(value); 33 | } 34 | 35 | public static NumberFormatter getDoubleFormatter() { 36 | NumberFormatter doubleFormatter = new NumberFormatter(new DecimalFormat("#0.00")); 37 | doubleFormatter.setValueClass(Double.class); 38 | doubleFormatter.setCommitsOnValidEdit(true); 39 | 40 | return doubleFormatter; 41 | } 42 | 43 | @Override 44 | public Double getValue() { 45 | Object val = super.getValue(); 46 | if (val instanceof Double) { 47 | return (Double) val; 48 | } else { 49 | return (Double) super.getValue(); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/SingleRootFileSystemView.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import java.io.File; 11 | import javax.swing.filechooser.FileSystemView; 12 | 13 | /** 14 | * A FileSystemView class that limits the file selections to a single root. 15 | * 16 | * When used with the JFileChooser component the user will only be able to traverse the directories 17 | * contained within the specified root fill. 18 | * 19 | * The "Look In" combo box will only display the specified root. 20 | * 21 | * The "Up One Level" button will be disable when at the root. 22 | * 23 | * Taken from: http://www.camick.com/java/source/SingleRootFileSystemView.java 24 | */ 25 | public class SingleRootFileSystemView extends FileSystemView { 26 | 27 | private final File root; 28 | private final File[] roots; 29 | 30 | public SingleRootFileSystemView(File root) { 31 | super(); 32 | 33 | this.root = root; 34 | roots = new File[] {root}; 35 | } 36 | 37 | @Override 38 | public File createNewFolder(File containingDir) { 39 | File folder = new File(containingDir, "New Folder"); 40 | folder.mkdir(); 41 | 42 | return folder; 43 | } 44 | 45 | @Override 46 | public File getDefaultDirectory() { 47 | return root; 48 | } 49 | 50 | @Override 51 | public File getHomeDirectory() { 52 | return root; 53 | } 54 | 55 | @Override 56 | public File[] getRoots() { 57 | return roots; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/IntegerField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import java.text.NumberFormat; 11 | import javax.swing.JFormattedTextField; 12 | import javax.swing.text.NumberFormatter; 13 | 14 | /** 15 | * A field that consists of a JFormattedTextField with a default formatter that ensures it contains 16 | * integers. (-2, -1, 0, 1, 2, etc.) Use any time you want a text field in which the user 17 | * should enter only integers. 18 | * 19 | * @author Joel Moore 20 | */ 21 | public class IntegerField extends JFormattedTextField { 22 | 23 | /** 24 | * Creates a IntegerField with the specified value. This will create and use a Formatter that 25 | * requires values that are integers. 26 | * 27 | * @param value Initial value for the IntegerField 28 | */ 29 | public IntegerField(Object value) { 30 | super(getIntegerFormatter()); 31 | setValue(value); 32 | setColumns(4); 33 | } 34 | 35 | public static NumberFormatter getIntegerFormatter() { 36 | NumberFormatter intFormatter = new NumberFormatter(NumberFormat.getIntegerInstance()); 37 | intFormatter.setValueClass(Integer.class); 38 | intFormatter.setCommitsOnValidEdit(true); 39 | 40 | return intFormatter; 41 | } 42 | 43 | @Override 44 | public Integer getValue() { 45 | Object val = super.getValue(); 46 | if (val instanceof Integer) { 47 | return (Integer) val; 48 | } else { 49 | return (Integer) super.getValue(); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /pluginsystem/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 4.0.0 13 | 14 | 15 | net.rpgtoolkit 16 | editor-parent 17 | 4.0.0-SNAPSHOT 18 | 19 | 20 | pluginsystem 21 | jar 22 | 2017 23 | RPG Toolkit 4.x Editor Plugin System 24 | 25 | 26 | 9.4.2.v20170220 27 | 28 | 29 | 30 | 31 | org.eclipse.jetty 32 | jetty-server 33 | ${jetty.version} 34 | 35 | 36 | 37 | 38 | 39 | 40 | src/main/resources 41 | 42 | 43 | 44 | 45 | org.apache.maven.plugins 46 | maven-jar-plugin 47 | ${maven.jar.version} 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/resources/Icons.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.resources; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | import javax.swing.ImageIcon; 14 | 15 | /** 16 | * Lazy-loading and caching resource provider. 17 | * 18 | * @author Chris Hutchinson 19 | */ 20 | public final class Icons { 21 | 22 | public enum Size { 23 | SMALL, 24 | LARGE 25 | }; 26 | 27 | private static final Map CACHE; 28 | 29 | static { 30 | CACHE = new HashMap<>(); 31 | } 32 | 33 | public static final ImageIcon getIcon(String name, Size size) { 34 | int key = 0; 35 | key ^= name.hashCode(); 36 | key ^= size.hashCode() * 31; 37 | if (!CACHE.containsKey(key)) { 38 | CACHE.put(key, getImageIcon(name, size)); 39 | } 40 | return CACHE.get(key); 41 | } 42 | 43 | public static final ImageIcon getIcon(String name) { 44 | return getIcon(name, Size.SMALL); 45 | } 46 | 47 | public static final ImageIcon getSmallIcon(String name) { 48 | return getIcon(name, Size.SMALL); 49 | } 50 | 51 | public static final ImageIcon getLargeIcon(String name) { 52 | return getIcon(name, Size.LARGE); 53 | } 54 | 55 | private static ImageIcon getImageIcon(String key, Size size) { 56 | final String path = String.format("/editor/%s/%s.png", 57 | size.name().toLowerCase(), key); 58 | final ImageIcon icon = new ImageIcon(Icons.class.getResource(path)); 59 | return icon; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/Brush.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board; 9 | 10 | import java.awt.Dimension; 11 | import java.awt.Graphics2D; 12 | import java.awt.Rectangle; 13 | 14 | /** 15 | * 16 | * 17 | * @author Joshua Michael Daly 18 | */ 19 | public interface Brush { 20 | 21 | /** 22 | * 23 | * 24 | * @return 25 | */ 26 | public int getAffectedLayers(); 27 | 28 | /** 29 | * 30 | * 31 | * @return 32 | */ 33 | public Rectangle getBounds(); 34 | 35 | /** 36 | * 37 | * 38 | * @param container 39 | * @param layer 40 | */ 41 | public void startPaint(MultiLayerContainer container, int layer); 42 | 43 | /** 44 | * 45 | * 46 | * @param x 47 | * @param y 48 | * @param selection 49 | * @return 50 | * @throws Exception 51 | */ 52 | public Rectangle doPaint(int x, int y, Rectangle selection) throws Exception; 53 | 54 | /** 55 | * 56 | * 57 | */ 58 | public void endPaint(); 59 | 60 | /** 61 | * 62 | * 63 | * @param g2d 64 | * @param view 65 | */ 66 | public void drawPreview(Graphics2D g2d, AbstractBoardView view); 67 | 68 | /** 69 | * 70 | * 71 | * @param g2d 72 | * @param dimension 73 | * @param view 74 | */ 75 | public void drawPreview(Graphics2D g2d, Dimension dimension, 76 | AbstractBoardView view); 77 | 78 | /** 79 | * 80 | * 81 | * @param brush 82 | * @return 83 | */ 84 | public boolean equals(Brush brush); 85 | 86 | } 87 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/sprite/listener/BrowseAnimationActionListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.sprite.listener; 9 | 10 | import java.awt.event.ActionEvent; 11 | import java.awt.event.ActionListener; 12 | import javax.swing.JTable; 13 | import net.rpgtoolkit.common.assets.Animation; 14 | import net.rpgtoolkit.common.assets.AbstractSprite; 15 | import net.rpgtoolkit.editor.editors.sprite.AbstractSpriteEditor; 16 | import net.rpgtoolkit.editor.utilities.EditorFileManager; 17 | 18 | /** 19 | * 20 | * @author Joshua Michael Daly 21 | */ 22 | public class BrowseAnimationActionListener implements ActionListener { 23 | 24 | private final AbstractSprite sprite; 25 | 26 | private final AbstractSpriteEditor spriteEditor; 27 | 28 | private final JTable animationsTable; 29 | 30 | public BrowseAnimationActionListener(AbstractSpriteEditor editor) { 31 | spriteEditor = editor; 32 | sprite = editor.getSprite(); 33 | animationsTable = editor.getAnimationsTable(); 34 | } 35 | 36 | @Override 37 | public void actionPerformed(ActionEvent e) { 38 | int rowIndex = animationsTable.getSelectedRow(); 39 | if (rowIndex < 0) { 40 | return; 41 | } 42 | 43 | String path = EditorFileManager.browseByTypeRelative(Animation.class); 44 | if (path != null) { 45 | String key = (String) animationsTable.getValueAt(rowIndex, 0); 46 | sprite.updateAnimation(key, path); 47 | 48 | spriteEditor.openAnimation(path); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/menu/RunMenu.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.menu; 9 | 10 | import java.awt.event.KeyEvent; 11 | import javax.swing.JMenu; 12 | import javax.swing.JMenuItem; 13 | import net.rpgtoolkit.editor.ui.resources.Icons; 14 | 15 | /** 16 | * 17 | * @author Joshua Michael Daly 18 | */ 19 | public final class RunMenu extends JMenu { 20 | 21 | private JMenuItem debugProgramMenuItem; 22 | private JMenuItem runProjectMenuItem; 23 | 24 | public RunMenu() { 25 | super("Run"); 26 | 27 | setMnemonic(KeyEvent.VK_R); 28 | 29 | configureDebugProgramMenuItem(); 30 | configureRunProjectMenuItem(); 31 | 32 | add(debugProgramMenuItem); 33 | add(runProjectMenuItem); 34 | } 35 | 36 | public void configureDebugProgramMenuItem() { 37 | debugProgramMenuItem = new JMenuItem("Debug Program"); 38 | debugProgramMenuItem.setIcon(Icons.getSmallIcon("bug")); 39 | // debugProgramMenuItem.setAccelerator( 40 | // KeyStroke.getKeyStroke(KeyEvent.VK_F5, ActionEvent.ACTION_PERFORMED)); 41 | debugProgramMenuItem.setMnemonic(KeyEvent.VK_D); 42 | 43 | debugProgramMenuItem.setEnabled(false); 44 | } 45 | 46 | public void configureRunProjectMenuItem() { 47 | runProjectMenuItem = new JMenuItem("Run Project"); 48 | runProjectMenuItem.setIcon(Icons.getSmallIcon("run")); 49 | // runProjectMenuItem.setAccelerator( 50 | // KeyStroke.getKeyStroke(KeyEvent.VK_F11, ActionEvent.ACTION_FIRST)); 51 | runProjectMenuItem.setMnemonic(KeyEvent.VK_N); 52 | 53 | runProjectMenuItem.setEnabled(false); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /editor/src/test/java/net/rpgtoolkit/editor/UserInterfaceTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor; 9 | 10 | import javax.swing.JFrame; 11 | import org.assertj.swing.core.GenericTypeMatcher; 12 | import static org.assertj.swing.finder.WindowFinder.findFrame; 13 | import org.assertj.swing.fixture.FrameFixture; 14 | import org.assertj.swing.fixture.JMenuItemFixture; 15 | import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase; 16 | import org.assertj.swing.launcher.ApplicationLauncher; 17 | import org.junit.Test; 18 | 19 | /** 20 | * The purpose of this class is to enable automated testing of the SWING user 21 | * interface to ensure there is no regression of features. 22 | * 23 | * It uses AssertJ: 24 | * 25 | * http://joel-costigliola.github.io/assertj/assertj-swing-getting-started.html 26 | * 27 | * @author Joshua Michael Daly 28 | */ 29 | public class UserInterfaceTest extends AssertJSwingJUnitTestCase { 30 | 31 | private FrameFixture window; 32 | 33 | @Override 34 | protected void onSetUp() { 35 | ApplicationLauncher.application(Driver.class).start(); 36 | 37 | GenericTypeMatcher matcher = new GenericTypeMatcher(JFrame.class) { 38 | @Override 39 | protected boolean isMatching(JFrame frame) { 40 | return frame.getTitle() != null && frame.getTitle().startsWith("RPGToolkit") && frame.isShowing(); 41 | } 42 | }; 43 | window = findFrame(matcher).using(robot()); 44 | } 45 | 46 | 47 | @Test 48 | public void openProject() { 49 | JMenuItemFixture fileMenu = window.menuItem("fileMenu"); 50 | fileMenu.click(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/OpenProjectAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.event.ActionEvent; 11 | import java.io.File; 12 | import javax.swing.AbstractAction; 13 | import javax.swing.JFileChooser; 14 | import javax.swing.filechooser.FileNameExtensionFilter; 15 | import net.rpgtoolkit.common.assets.Project; 16 | import net.rpgtoolkit.common.utilities.CoreProperties; 17 | import net.rpgtoolkit.editor.MainWindow; 18 | import net.rpgtoolkit.editor.utilities.EditorFileManager; 19 | 20 | /** 21 | * 22 | * @author 23 | */ 24 | public class OpenProjectAction extends AbstractAction { 25 | 26 | @Override 27 | public void actionPerformed(ActionEvent e) { 28 | EditorFileManager.getFileChooser().resetChoosableFileFilters(); 29 | FileNameExtensionFilter filter = new FileNameExtensionFilter( 30 | "Toolkit Project", 31 | CoreProperties.getDefaultExtension(Project.class).replace(".", "")); 32 | EditorFileManager.getFileChooser().setFileFilter(filter); 33 | 34 | File mainFolder = new File(CoreProperties.getProjectsDirectory()); 35 | 36 | if (mainFolder.exists()) { 37 | EditorFileManager.getFileChooser().setCurrentDirectory(mainFolder); 38 | } 39 | 40 | if (EditorFileManager.getFileChooser().showOpenDialog(MainWindow.getInstance()) == JFileChooser.APPROVE_OPTION) { 41 | File file = EditorFileManager.getFileChooser().getSelectedFile(); 42 | MainWindow mainWindow = MainWindow.getInstance(); 43 | 44 | Project project = mainWindow.openProject(file); 45 | mainWindow.setProjectPath(file.getParent()); 46 | mainWindow.setupProject(project); 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/menu/MainMenuBar.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.menu; 9 | 10 | import net.rpgtoolkit.editor.MainWindow; 11 | import javax.swing.JMenuBar; 12 | 13 | /** 14 | * 15 | * 16 | * @author Geoff Wilson 17 | * @author Joshua Michael Daly 18 | */ 19 | public class MainMenuBar extends JMenuBar { 20 | 21 | private final MainWindow parent; 22 | 23 | private final FileMenu fileMenu; 24 | private final EditMenu editMenu; 25 | private final ViewMenu viewMenu; 26 | private final RunMenu runMenu; 27 | private final ToolsMenu toolsMenu; 28 | private final HelpMenu helpMenu; 29 | 30 | public MainMenuBar(MainWindow menuBarParent) { 31 | parent = menuBarParent; 32 | 33 | fileMenu = new FileMenu(); 34 | fileMenu.setName("fileMenu"); 35 | 36 | editMenu = new EditMenu(); 37 | viewMenu = new ViewMenu(); 38 | runMenu = new RunMenu(); 39 | toolsMenu = new ToolsMenu(); 40 | helpMenu = new HelpMenu(); 41 | 42 | add(fileMenu); 43 | add(editMenu); 44 | add(viewMenu); 45 | add(runMenu); 46 | add(toolsMenu); 47 | add(helpMenu); 48 | } 49 | 50 | public MainWindow getParentWindow() { 51 | return parent; 52 | } 53 | 54 | public FileMenu getFileMenu() { 55 | return fileMenu; 56 | } 57 | 58 | public EditMenu getEditMenu() { 59 | return editMenu; 60 | } 61 | 62 | public ViewMenu getViewMenu() { 63 | return viewMenu; 64 | } 65 | 66 | public RunMenu getRunMenu() { 67 | return runMenu; 68 | } 69 | 70 | public ToolsMenu getToolsMenu() { 71 | return toolsMenu; 72 | } 73 | 74 | @Override 75 | public HelpMenu getHelpMenu() { 76 | return helpMenu; 77 | } 78 | 79 | public void enableMenus(boolean enable) { 80 | fileMenu.doEnableItems(); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/ModelPanelFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import net.rpgtoolkit.common.assets.Animation; 11 | import net.rpgtoolkit.editor.editors.board.panels.BoardPanel; 12 | import net.rpgtoolkit.editor.editors.board.panels.BoardVectorPanel; 13 | import net.rpgtoolkit.editor.editors.board.panels.BoardSpritePanel; 14 | import net.rpgtoolkit.common.assets.Board; 15 | import net.rpgtoolkit.common.assets.BoardLight; 16 | import net.rpgtoolkit.common.assets.BoardSprite; 17 | import net.rpgtoolkit.common.assets.BoardVector; 18 | import net.rpgtoolkit.common.assets.Item; 19 | import net.rpgtoolkit.common.assets.Player; 20 | import net.rpgtoolkit.editor.editors.ItemModelPanel; 21 | import net.rpgtoolkit.editor.editors.animation.AnimationModelPanel; 22 | import net.rpgtoolkit.editor.editors.character.CharacterModelPanel; 23 | 24 | /** 25 | * 26 | * 27 | * @author Joshua Michael Daly 28 | */ 29 | public final class ModelPanelFactory { 30 | 31 | private ModelPanelFactory() { 32 | 33 | } 34 | 35 | public static AbstractModelPanel getModelPanel(Object model) { 36 | if (model instanceof Board) { 37 | return new BoardPanel((Board) model); 38 | } else if (model instanceof BoardVector) { 39 | return new BoardVectorPanel((BoardVector) model); 40 | } else if (model instanceof BoardSprite) { 41 | return new BoardSpritePanel((BoardSprite) model); 42 | } else if (model instanceof BoardLight) { 43 | 44 | } else if (model instanceof Animation) { 45 | return new AnimationModelPanel((Animation) model); 46 | } else if (model instanceof Player) { 47 | return new CharacterModelPanel((Player) model); 48 | } else if (model instanceof Item) { 49 | return new ItemModelPanel((Item) model); 50 | } 51 | 52 | return null; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/WholeNumberField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import java.text.NumberFormat; 11 | import javax.swing.JFormattedTextField; 12 | import javax.swing.text.NumberFormatter; 13 | 14 | /** 15 | * A field that consists of a JFormattedTextField with a default formatter that 16 | * ensures it contains whole numbers. (Non-negative integers. 0, 1, 2, etc.) Use 17 | * any time you want a text field in which the user should enter only integers 0 18 | * and above. May or may not enforce a maximum value, but enforces a minimum 19 | * value of 0. 20 | * 21 | * @author Joel Moore 22 | */ 23 | public class WholeNumberField extends JFormattedTextField { 24 | 25 | /** 26 | * Creates a WholeNumberField with the specified value. This will create and 27 | * use a Formatter that requires values that are whole numbers: non-negative 28 | * (long) integers. 29 | * 30 | * @param value Initial value for the WholeNumberField 31 | */ 32 | public WholeNumberField(Object value) { 33 | super(getWholeNumFormatter()); 34 | this.setValue(value); 35 | } 36 | 37 | public static NumberFormatter getWholeNumFormatter() { 38 | NumberFormatter wholeNumberFormatter = new NumberFormatter( 39 | NumberFormat.getIntegerInstance()); 40 | wholeNumberFormatter.setValueClass(Long.class); 41 | wholeNumberFormatter.setMinimum(0L); 42 | wholeNumberFormatter.setCommitsOnValidEdit(true); 43 | return wholeNumberFormatter; 44 | } 45 | 46 | @Override 47 | public Long getValue() { 48 | Object val = super.getValue(); 49 | if(val instanceof Integer) { 50 | return Long.valueOf((Integer)val); 51 | } else { 52 | return (Long)super.getValue(); 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /pluginsystem/src/main/java/net/rpgtoolkit/pluginsystem/Engine.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.pluginsystem; 9 | 10 | import java.io.File; 11 | import javax.swing.ProgressMonitor; 12 | import ro.fortsoft.pf4j.ExtensionPoint; 13 | 14 | /** 15 | * A common interface for pluggable engines to implement. 16 | * 17 | * @author Joshua Michael Daly 18 | */ 19 | public interface Engine extends ExtensionPoint { 20 | 21 | /** 22 | * Runs the project located at the specified path. An engine implementation 23 | * should take a copy of the project rather than running directly against 24 | * what the editor is using. As the engine progresses it should update the 25 | * progress of the monitor which will provide UI feedback when needed. 26 | * 27 | * @param projectName name of the current project 28 | * @param projectCopy path to the project copy for engine use 29 | * @param progressMonitor for tracking engine startup progress 30 | * @throws java.lang.Exception 31 | */ 32 | public void run(String projectName, File projectCopy, ProgressMonitor progressMonitor) throws Exception; 33 | 34 | /** 35 | * Requests that the engine instance stop as soon as possible. In this case 36 | * there is no need for UI feedback as the caller is also stopping 37 | * execution. 38 | * 39 | * @throws Exception 40 | */ 41 | public void stop() throws Exception; 42 | 43 | /** 44 | * Requests that the running engine instance stop. It is the responsibility 45 | * of the engine to remove the temporary folder created at the run step. As 46 | * the engine progresses it should update the progress of the monitor which 47 | * will provide UI feedback when needed. 48 | * 49 | * @param progressMonitor for tracking engine startup progress 50 | * @throws java.lang.Exception 51 | */ 52 | public void stop(ProgressMonitor progressMonitor) throws Exception; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/EditorFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import net.rpgtoolkit.common.assets.Animation; 11 | import net.rpgtoolkit.common.assets.Asset; 12 | import net.rpgtoolkit.common.assets.Board; 13 | import net.rpgtoolkit.common.assets.Enemy; 14 | import net.rpgtoolkit.common.assets.Item; 15 | import net.rpgtoolkit.common.assets.Player; 16 | import net.rpgtoolkit.common.assets.Project; 17 | import net.rpgtoolkit.editor.editors.AnimationEditor; 18 | import net.rpgtoolkit.editor.editors.BoardEditor; 19 | import net.rpgtoolkit.editor.editors.CharacterEditor; 20 | import net.rpgtoolkit.editor.editors.EnemyEditor; 21 | import net.rpgtoolkit.editor.editors.ItemEditor; 22 | import net.rpgtoolkit.editor.editors.ProjectEditor; 23 | 24 | /** 25 | * A factory for obtaining the corresponding file format editor based on the 26 | * asset type. 27 | * 28 | * @author Joshua Michael Daly 29 | */ 30 | public class EditorFactory { 31 | 32 | private EditorFactory() { 33 | 34 | } 35 | 36 | /** 37 | * Gets the matching editor for the asset type. 38 | * 39 | * @param asset 40 | * @return editor for asset 41 | */ 42 | public static AssetEditorWindow getEditor(Asset asset) { 43 | if (asset instanceof Animation) { 44 | return new AnimationEditor((Animation) asset); 45 | } else if (asset instanceof Board) { 46 | return new BoardEditor((Board) asset); 47 | } else if (asset instanceof Enemy) { 48 | return new EnemyEditor((Enemy) asset); 49 | } else if (asset instanceof Item) { 50 | return new ItemEditor((Item) asset); 51 | } else if (asset instanceof Player) { 52 | return new CharacterEditor((Player) asset); 53 | } else if (asset instanceof Project) { 54 | return new ProjectEditor((Project) asset); 55 | } 56 | 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/listeners/PopupListFilesListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.listeners; 9 | 10 | import java.io.File; 11 | import java.util.Collection; 12 | import javax.swing.JComboBox; 13 | import javax.swing.event.PopupMenuEvent; 14 | import javax.swing.event.PopupMenuListener; 15 | import net.rpgtoolkit.editor.utilities.EditorFileManager; 16 | import org.apache.commons.io.FileUtils; 17 | 18 | /** 19 | * 20 | * @author Joshua Michael Daly 21 | */ 22 | public class PopupListFilesListener implements PopupMenuListener { 23 | 24 | private final File rootDirectory; 25 | private final String[] extension; 26 | private final boolean recursive; 27 | private final JComboBox comboBox; 28 | 29 | public PopupListFilesListener(File directory, String[] exts, boolean isRecursive, JComboBox model) { 30 | rootDirectory = directory; 31 | extension = exts; 32 | recursive = isRecursive; 33 | comboBox = model; 34 | 35 | populate(); 36 | } 37 | 38 | @Override 39 | public void popupMenuWillBecomeVisible(PopupMenuEvent e) { 40 | Object previouslySelected = comboBox.getSelectedItem(); 41 | comboBox.removeAllItems(); 42 | comboBox.addItem(""); 43 | populate(); 44 | comboBox.setSelectedItem(previouslySelected); 45 | } 46 | 47 | @Override 48 | public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { 49 | } 50 | 51 | @Override 52 | public void popupMenuCanceled(PopupMenuEvent e) { 53 | } 54 | 55 | private void populate() { 56 | Collection files = FileUtils.listFiles(rootDirectory, extension, recursive); 57 | 58 | for (File file : files) { 59 | String path = file.getAbsolutePath(); 60 | path = path.replace(rootDirectory.getAbsolutePath() + File.separator, ""); 61 | 62 | comboBox.addItem(path); 63 | } 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/sprite/listener/AnimationListSelectionListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.sprite.listener; 9 | 10 | import javax.swing.JTable; 11 | import javax.swing.event.ListSelectionEvent; 12 | import javax.swing.event.ListSelectionListener; 13 | import net.rpgtoolkit.common.assets.AbstractSprite; 14 | import net.rpgtoolkit.common.assets.AnimationEnum; 15 | import net.rpgtoolkit.editor.editors.sprite.AbstractSpriteEditor; 16 | 17 | /** 18 | * 19 | * @author Joshua Michael Daly 20 | */ 21 | public class AnimationListSelectionListener implements ListSelectionListener { 22 | 23 | private final AbstractSprite sprite; 24 | 25 | private final AbstractSpriteEditor spriteEditor; 26 | 27 | private final JTable animationsTable; 28 | 29 | public AnimationListSelectionListener(AbstractSpriteEditor editor) { 30 | spriteEditor = editor; 31 | sprite = editor.getSprite(); 32 | animationsTable = editor.getAnimationsTable(); 33 | } 34 | 35 | @Override 36 | public void valueChanged(ListSelectionEvent e) { 37 | if (!e.getValueIsAdjusting()) { 38 | int rowIndex = animationsTable.getSelectedRow(); 39 | if (rowIndex == -1) { 40 | spriteEditor.updateAnimatedPanel(); 41 | 42 | spriteEditor.getBrowseButton().setEnabled(false); 43 | spriteEditor.getRemoveButton().setEnabled(false); 44 | } else { 45 | String path = (String) animationsTable.getValueAt(rowIndex, 1); 46 | 47 | spriteEditor.openAnimation(path); 48 | spriteEditor.getBrowseButton().setEnabled(true); 49 | 50 | try { 51 | AnimationEnum.valueOf((String) animationsTable.getValueAt(rowIndex, 0)); 52 | spriteEditor.getRemoveButton().setEnabled(false); // Cannot remove default graphics. 53 | } catch (IllegalArgumentException ex) { 54 | spriteEditor.getRemoveButton().setEnabled(true); 55 | } 56 | } 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/PropertiesPanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import java.awt.BorderLayout; 11 | import javax.swing.JPanel; 12 | import javax.swing.JScrollPane; 13 | import javax.swing.JViewport; 14 | import javax.swing.event.ListSelectionEvent; 15 | import javax.swing.event.ListSelectionListener; 16 | import net.rpgtoolkit.editor.MainWindow; 17 | 18 | /** 19 | * 20 | * @author Joshua Michael Daly 21 | */ 22 | public class PropertiesPanel extends JPanel implements ListSelectionListener { 23 | 24 | private Object model; 25 | 26 | private JScrollPane propertiesScrollPane; 27 | 28 | public PropertiesPanel() { 29 | initialize(); 30 | } 31 | 32 | public PropertiesPanel(Object model) { 33 | this.model = model; 34 | initialize(); 35 | } 36 | 37 | public Object getModel() { 38 | return model; 39 | } 40 | 41 | public void setModel(Object model) { 42 | this.model = model; 43 | 44 | AbstractModelPanel panel = ModelPanelFactory.getModelPanel(model); 45 | 46 | // To ensure that the internal controls are not streched. 47 | JPanel intermediate = new JPanel(new BorderLayout()); 48 | 49 | if (panel != null) { 50 | intermediate.add(panel, BorderLayout.NORTH); 51 | } 52 | 53 | propertiesScrollPane.setViewportView(intermediate); 54 | propertiesScrollPane.getViewport().revalidate(); 55 | } 56 | 57 | @Override 58 | public void valueChanged(ListSelectionEvent e) { 59 | 60 | } 61 | 62 | private void initialize() { 63 | if (model != null) { 64 | 65 | } else { 66 | 67 | } 68 | 69 | propertiesScrollPane = new JScrollPane(); 70 | propertiesScrollPane.getViewport().setScrollMode( 71 | JViewport.SIMPLE_SCROLL_MODE); 72 | propertiesScrollPane.setVerticalScrollBarPolicy( 73 | JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 74 | 75 | setLayout(new BorderLayout()); 76 | add(propertiesScrollPane, BorderLayout.CENTER); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/AbstractModelPanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import java.awt.Font; 11 | import javax.swing.GroupLayout; 12 | import javax.swing.GroupLayout.SequentialGroup; 13 | import javax.swing.JButton; 14 | import javax.swing.JLabel; 15 | import javax.swing.JPanel; 16 | import javax.swing.JSpinner; 17 | import javax.swing.JTextField; 18 | import javax.swing.SwingConstants; 19 | 20 | /** 21 | * 22 | * @author Joshua Michael Daly 23 | */ 24 | public abstract class AbstractModelPanel extends JPanel { 25 | 26 | protected static final int COLUMNS = 10; 27 | 28 | protected Object model; 29 | protected Font font; 30 | 31 | protected GroupLayout layout; 32 | protected SequentialGroup horizontalGroup; 33 | protected SequentialGroup verticalGroup; 34 | 35 | public AbstractModelPanel(Object model) { 36 | this.model = model; 37 | font = new JLabel().getFont(); 38 | 39 | layout = new GroupLayout(this); 40 | layout.setAutoCreateGaps(true); 41 | layout.setAutoCreateContainerGaps(true); 42 | 43 | horizontalGroup = layout.createSequentialGroup(); 44 | verticalGroup = layout.createSequentialGroup(); 45 | 46 | setLayout(layout); 47 | } 48 | 49 | public Object getModel() { 50 | return model; 51 | } 52 | 53 | public final JLabel getJLabel(String text) { 54 | JLabel label = new JLabel(text); 55 | label.setVerticalAlignment(SwingConstants.CENTER); 56 | label.setFont(font); 57 | return label; 58 | } 59 | 60 | public final JTextField getJTextField(String text) { 61 | JTextField textField = new JTextField(text); 62 | textField.setColumns(COLUMNS); 63 | textField.setFont(font); 64 | return textField; 65 | } 66 | 67 | public final JButton getJButton(String text) { 68 | JButton button = new JButton(text); 69 | button.setFont(font); 70 | return button; 71 | } 72 | 73 | public final JSpinner getJSpinner(Object value) { 74 | JSpinner spinner = new JSpinner(); 75 | spinner.setValue(value); 76 | spinner.setFont(font); 77 | return spinner; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/StartPositionBrush.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board; 9 | 10 | import java.awt.Graphics2D; 11 | import java.awt.Point; 12 | import java.awt.Rectangle; 13 | import java.awt.Shape; 14 | import net.rpgtoolkit.common.assets.Board; 15 | import net.rpgtoolkit.editor.ui.AssetEditorWindow; 16 | 17 | /** 18 | * 19 | * 20 | * @author Joshua Michael Daly 21 | */ 22 | public class StartPositionBrush extends AbstractBrush { 23 | 24 | @Override 25 | public Shape getShape() { 26 | return getBounds(); 27 | } 28 | 29 | @Override 30 | public Rectangle getBounds() { 31 | return new Rectangle(0, 0, 1, 1); 32 | } 33 | 34 | @Override 35 | public void drawPreview(Graphics2D g2d, AbstractBoardView view) { 36 | } 37 | 38 | /** 39 | * 40 | * 41 | * @param x 42 | * @param y 43 | * @param selection 44 | * @return 45 | * @throws Exception 46 | */ 47 | @Override 48 | public Rectangle doPaint(int x, int y, Rectangle selection) throws Exception { 49 | Board board = affectedContainer.getLayer(currentLayer).getLayer().getBoard(); 50 | board.setStartingPositionX(x); 51 | board.setStartingPositionY(y); 52 | board.setStartingLayer(currentLayer); 53 | board.fireBoardChanged(); 54 | 55 | return null; 56 | } 57 | 58 | @Override 59 | public boolean equals(Brush brush) { 60 | return brush instanceof StartPositionBrush; 61 | } 62 | 63 | @Override 64 | public void doMouseButton1Pressed(Point point, AssetEditorWindow editor) { 65 | 66 | } 67 | 68 | @Override 69 | public void doMouseButton2Pressed(Point point, AssetEditorWindow editor) { 70 | 71 | } 72 | 73 | @Override 74 | public void doMouseButton3Pressed(Point point, AssetEditorWindow editor) { 75 | 76 | } 77 | 78 | @Override 79 | public void doMouseButton1Dragged(Point point, Point origin, AssetEditorWindow editor) { 80 | 81 | } 82 | 83 | @Override 84 | public boolean isPixelBased() { 85 | return true; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/sprite/listener/RemoveAnimationActionListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.sprite.listener; 9 | 10 | import java.awt.event.ActionEvent; 11 | import java.awt.event.ActionListener; 12 | import javax.swing.JTable; 13 | import net.rpgtoolkit.common.assets.Animation; 14 | import net.rpgtoolkit.common.assets.AbstractSprite; 15 | import net.rpgtoolkit.common.assets.AnimationEnum; 16 | import net.rpgtoolkit.editor.editors.sprite.AbstractSpriteEditor; 17 | import net.rpgtoolkit.editor.editors.sprite.AnimationsTableModel; 18 | 19 | /** 20 | * 21 | * @author Joshua Michael Daly 22 | */ 23 | public class RemoveAnimationActionListener implements ActionListener { 24 | 25 | private final AbstractSpriteEditor spriteEditor; 26 | 27 | private final AbstractSprite sprite; 28 | 29 | private final JTable animationsTable; 30 | private final AnimationsTableModel animationsTableModel; 31 | 32 | public RemoveAnimationActionListener(AbstractSpriteEditor editor) { 33 | spriteEditor = editor; 34 | sprite = spriteEditor.getSprite(); 35 | animationsTable = spriteEditor.getAnimationsTable(); 36 | animationsTableModel = (AnimationsTableModel) animationsTable.getModel(); 37 | } 38 | 39 | @Override 40 | public void actionPerformed(ActionEvent e) { 41 | int rowIndex = animationsTable.getSelectedRow(); 42 | if (rowIndex < sprite.getAnimations().size()) { 43 | String key = (String) animationsTable.getValueAt(rowIndex, 0); 44 | 45 | try { 46 | AnimationEnum.valueOf(key); 47 | } catch (IllegalArgumentException ex) { 48 | // Not a default can be removed. 49 | sprite.removeAnimation(key); 50 | 51 | if (rowIndex > 0) { 52 | if (rowIndex == animationsTableModel.getRowCount()) { 53 | rowIndex--; 54 | } 55 | 56 | animationsTable.scrollRectToVisible(animationsTable.getCellRect(rowIndex, 0, true)); 57 | } 58 | 59 | spriteEditor.setSelectedAnim(null); 60 | spriteEditor.updateAnimatedPanel(); 61 | } 62 | } 63 | 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/properties/EditorProperty.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | /* 9 | * To change this license header, choose License Headers in Project Properties. 10 | * To change this template file, choose Tools | Templates 11 | * and open the template in the editor. 12 | */ 13 | package net.rpgtoolkit.editor.properties; 14 | 15 | /** 16 | * This Enum exits to make refactoring editor properties in the .properties file easier. 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public enum EditorProperty { 21 | 22 | EDITOR_UI_TITLE("editor.ui.title"), 23 | 24 | EDITOR_PLUGINS_DIRECOTRY("editor.plugins.directory"), 25 | 26 | // Tooltips 27 | EDITOR_UI_TOOLTIP_NEW("editor.ui.tooltip.new"), 28 | EDITOR_UI_TOOLTIP_OPEN("editor.ui.tooltip.open"), 29 | EDITOR_UI_TOOLTIP_SAVE("editor.ui.tooltip.save"), 30 | EDITOR_UI_TOOLTIP_SAVE_ALL("editor.ui.tooltip.saveall"), 31 | EDITOR_UI_TOOLTIP_CUT("editor.ui.tooltip.cut"), 32 | EDITOR_UI_TOOLTIP_COPY("editor.ui.tooltip.copy"), 33 | EDITOR_UI_TOOLTIP_PASTE("editor.ui.tooltip.paste"), 34 | EDITOR_UI_TOOLTIP_DELETE("editor.ui.tooltip.delete"), 35 | EDITOR_UI_TOOLTIP_UNDO("editor.ui.tooltip.undo"), 36 | EDITOR_UI_TOOLTIP_REDO("editor.ui.tooltip.redo"), 37 | EDITOR_UI_TOOLTIP_DRAW_TILE("editor.ui.tooltip.drawtile"), 38 | EDITOR_UI_TOOLTIP_SELECT_REGION("editor.ui.tooltip.selectregion"), 39 | EDITOR_UI_TOOLTIP_FILL_REGION("editor.ui.tooltip.fillregion"), 40 | EDITOR_UI_TOOLTIP_ERASE_REGION("editor.ui.tooltip.eraseregion"), 41 | EDITOR_UI_TOOLTIP_DRAW_VECTOR("editor.ui.tooltip.drawvector"), 42 | EDITOR_UI_TOOLTIP_DRAW_PROGRAM("editor.ui.tooltip.drawprogram"), 43 | EDITOR_UI_TOOLTIP_SET_BOARD_SPRITE("editor.ui.tooltip.setboardsprite"), 44 | EDITOR_UI_TOOLTIP_SET_BOARD_LIGHT("editor.ui.tooltip.setboardlight"), 45 | EDITOR_UI_TOOLTIP_SET_START_POSITION("editor.ui.tooltip.setstartposition"), 46 | EDITOR_UI_TOOLTIP_ZOOM_IN("editor.ui.tooltip.zoomin"), 47 | EDITOR_UI_TOOLTIP_ZOOM_OUT("editor.ui.tooltip.zoomout"), 48 | EDITOR_UI_TOOLTIP_RUN_GAME("editor.ui.tooltip.rungame"), 49 | EDITOR_UI_TOOLTIP_STOP_GAME("editor.ui.tooltip.stopgame"), 50 | EDITOR_UI_TOOLTIP_HELP("editor.ui.tooltip.help"); 51 | 52 | private final String name; 53 | 54 | private EditorProperty(String s) { 55 | name = s; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return name; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/StopAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import java.awt.Toolkit; 11 | import java.awt.event.ActionEvent; 12 | import java.util.List; 13 | import javax.swing.AbstractAction; 14 | import javax.swing.ProgressMonitor; 15 | import javax.swing.SwingWorker; 16 | import net.rpgtoolkit.editor.MainWindow; 17 | import net.rpgtoolkit.pluginsystem.Engine; 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | import ro.fortsoft.pf4j.PluginManager; 21 | 22 | /** 23 | * 24 | * @author Joshua Michael Daly 25 | */ 26 | public class StopAction extends AbstractAction { 27 | 28 | private static final Logger LOGGER = LoggerFactory.getLogger(StopAction.class); 29 | 30 | private ProgressMonitor progressMonitor; 31 | private SwingWorker worker; 32 | 33 | @Override 34 | public void actionPerformed(ActionEvent e) { 35 | try { 36 | MainWindow instance = MainWindow.getInstance(); 37 | 38 | PluginManager pluginManager = MainWindow.getInstance().getPluginManager(); 39 | List engines = pluginManager.getExtensions(Engine.class); 40 | // Just use the first available engine for now. 41 | if (engines.size() > 0) { 42 | progressMonitor = new ProgressMonitor(MainWindow.getInstance(), "Stopping Engine...", "", 0, 100); 43 | progressMonitor.setProgress(0); 44 | 45 | worker = new SwingWorker() { 46 | @Override 47 | protected Integer doInBackground() throws Exception { 48 | engines.get(0).stop(progressMonitor); 49 | 50 | return null; 51 | } 52 | 53 | @Override 54 | public void done() { 55 | Toolkit.getDefaultToolkit().beep(); 56 | instance.getMainToolBar().getRunButton().setEnabled(true); 57 | instance.getMainToolBar().getStopButton().setEnabled(false); 58 | } 59 | }; 60 | worker.execute(); 61 | } 62 | } catch (Exception ex) { 63 | LOGGER.error("Failed to stop engine.", ex); 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/AbstractImagePanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import java.awt.Dimension; 11 | import java.awt.event.MouseEvent; 12 | import java.awt.event.MouseListener; 13 | import java.awt.image.BufferedImage; 14 | import java.io.File; 15 | import java.io.IOException; 16 | import java.util.LinkedList; 17 | import javax.imageio.ImageIO; 18 | import javax.swing.JPanel; 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | 22 | /** 23 | * 24 | * @author Joshua Michael Daly 25 | */ 26 | public abstract class AbstractImagePanel extends JPanel implements MouseListener { 27 | 28 | private static final Logger LOGGER = LoggerFactory.getLogger(AbstractImagePanel.class); 29 | 30 | protected File file; 31 | protected Dimension dimension; 32 | protected LinkedList bufferedImages; 33 | 34 | public AbstractImagePanel() { 35 | bufferedImages = new LinkedList<>(); 36 | addMouseListener(this); 37 | } 38 | 39 | public AbstractImagePanel(Dimension dimension) { 40 | this(); 41 | this.dimension = dimension; 42 | } 43 | 44 | public Dimension getDimension() { 45 | return dimension; 46 | } 47 | 48 | public void setDimension(Dimension dimension) { 49 | this.dimension = dimension; 50 | } 51 | 52 | public LinkedList getBufferedImages() { 53 | return bufferedImages; 54 | } 55 | 56 | public void setBufferedImages(LinkedList images) { 57 | this.bufferedImages = images; 58 | } 59 | 60 | public File getFile() { 61 | return file; 62 | } 63 | 64 | public void addImage(File file) { 65 | if (file != null) { 66 | try { 67 | this.file = file; 68 | bufferedImages.add(ImageIO.read(file)); 69 | } catch (IOException ex) { 70 | LOGGER.error("Failed to add image file=[{}]", file, ex); 71 | } 72 | } 73 | } 74 | 75 | @Override 76 | public void mouseClicked(MouseEvent e) { 77 | } 78 | 79 | @Override 80 | public void mousePressed(MouseEvent e) { 81 | } 82 | 83 | @Override 84 | public void mouseReleased(MouseEvent e) { 85 | } 86 | 87 | @Override 88 | public void mouseEntered(MouseEvent e) { 89 | } 90 | 91 | @Override 92 | public void mouseExited(MouseEvent e) { 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /editor/src/test/java/net/rpgtoolkit/editor/utilities/FileToolsTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.utilities; 9 | 10 | import java.io.File; 11 | import org.junit.After; 12 | import org.junit.AfterClass; 13 | import static org.junit.Assert.assertEquals; 14 | import static org.junit.Assert.fail; 15 | import org.junit.Before; 16 | import org.junit.BeforeClass; 17 | import org.junit.Test; 18 | import org.junit.Ignore; 19 | 20 | /** 21 | * 22 | * @author Joshua Michael Daly 23 | */ 24 | public class FileToolsTest { 25 | 26 | public FileToolsTest() { 27 | } 28 | 29 | @BeforeClass 30 | public static void setUpClass() { 31 | } 32 | 33 | @AfterClass 34 | public static void tearDownClass() { 35 | } 36 | 37 | @Before 38 | public void setUp() { 39 | } 40 | 41 | @After 42 | public void tearDown() { 43 | } 44 | 45 | /** 46 | * Test of createDirectoryStructure method, of class FileTools. 47 | */ 48 | @Test 49 | public void testCreateDirectoryStructure() { 50 | System.out.println("createDirectoryStructure"); 51 | String path = System.getProperty("user.home"); 52 | String project = "Test"; 53 | 54 | boolean expResult = true; 55 | boolean result = FileTools.createDirectoryStructure(path, project); 56 | 57 | assertEquals(expResult, result); 58 | } 59 | 60 | /** 61 | * Test of doChoosePath method, of class FileTools. 62 | */ 63 | @Test 64 | @Ignore 65 | public void testDoChoosePath() { 66 | System.out.println("doChoosePath"); 67 | File expResult = null; 68 | File result = FileTools.doChoosePath(); 69 | assertEquals(expResult, result); 70 | // TODO review the generated test code and remove the default call to fail. 71 | fail("The test case is a prototype."); 72 | } 73 | 74 | /** 75 | * Test of doChooseFile method, of class FileTools. 76 | */ 77 | @Test 78 | @Ignore 79 | public void testDoChooseFile() { 80 | System.out.println("doChooseFile"); 81 | String extension = ""; 82 | String directory = ""; 83 | String type = ""; 84 | File expResult = null; 85 | File result = FileTools.doChooseFile(extension, directory, type); 86 | assertEquals(expResult, result); 87 | // TODO review the generated test code and remove the default call to fail. 88 | fail("The test case is a prototype."); 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/tileset/TileSetUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.tileset; 9 | 10 | import java.awt.Graphics2D; 11 | import java.awt.image.BufferedImage; 12 | import java.io.File; 13 | import java.io.FileInputStream; 14 | import java.io.IOException; 15 | import java.util.List; 16 | import javax.imageio.ImageIO; 17 | import net.rpgtoolkit.common.assets.Tile; 18 | import net.rpgtoolkit.common.assets.TileSet; 19 | import net.rpgtoolkit.editor.utilities.EditorFileManager; 20 | 21 | /** 22 | * 23 | * @author Joshua Michael Daly 24 | */ 25 | public class TileSetUtil { 26 | 27 | public static TileSet load(TileSet tileSet) throws IOException { 28 | int tileWidth = tileSet.getTileWidth(); 29 | int tileHeight = tileSet.getTileHeight(); 30 | List images = tileSet.getImages(); 31 | for (String image : images) { 32 | String subdir = EditorFileManager.getGraphicsSubdirectory(); 33 | File file = EditorFileManager.getPath(subdir + File.separator + image); 34 | 35 | try (FileInputStream fis = new FileInputStream(file)) { 36 | BufferedImage source = ImageIO.read(fis); 37 | tileSet = loadImageIntoTileSet(tileSet, source, tileWidth, tileHeight); 38 | } 39 | } 40 | 41 | return tileSet; 42 | } 43 | 44 | public static TileSet loadImageIntoTileSet(TileSet tileSet, BufferedImage source, int tileWidth, int tileHeight) { 45 | int sourceWidth = source.getWidth(); 46 | int sourceHeight = source.getHeight(); 47 | 48 | int rows = sourceHeight / tileHeight; 49 | int columns = sourceWidth / tileWidth; 50 | 51 | Tile tile; 52 | BufferedImage subImage; 53 | for (int x = 0; x < rows; x++) { 54 | for (int y = 0; y < columns; y++) { 55 | subImage = new BufferedImage(tileWidth, tileHeight, BufferedImage.TYPE_INT_ARGB); 56 | 57 | Graphics2D g2d = subImage.createGraphics(); 58 | g2d.drawImage(source, 0, 0, tileWidth, tileHeight, tileWidth * y, tileHeight * x, 59 | tileWidth * y + tileWidth, tileHeight * x + tileHeight, null); 60 | g2d.dispose(); 61 | 62 | tile = new Tile(); 63 | tileSet.addTile(tile); 64 | 65 | tile.setRect(0, 0, subImage.getRaster()); 66 | tile.setTileSet(tileSet); 67 | tile.setIndex(tileSet.getTiles().size() - 1); 68 | } 69 | } 70 | 71 | return tileSet; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/listeners/TileSetSelectionListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | /* 9 | * To change this license header, choose License Headers in Project Properties. 10 | * To change this template file, choose Tools | Templates 11 | * and open the template in the editor. 12 | */ 13 | package net.rpgtoolkit.editor.ui.listeners; 14 | 15 | import java.awt.Rectangle; 16 | import net.rpgtoolkit.common.assets.Tile; 17 | import net.rpgtoolkit.editor.MainWindow; 18 | import net.rpgtoolkit.editor.editors.TileRegionSelectionEvent; 19 | import net.rpgtoolkit.editor.editors.TileSelectionEvent; 20 | import net.rpgtoolkit.editor.editors.board.Brush; 21 | import net.rpgtoolkit.editor.editors.board.BucketBrush; 22 | import net.rpgtoolkit.editor.editors.board.CustomBrush; 23 | import net.rpgtoolkit.editor.editors.board.ShapeBrush; 24 | 25 | /** 26 | * 27 | * @author Joshua Michael Daly 28 | */ 29 | public class TileSetSelectionListener implements TileSelectionListener { 30 | 31 | @Override 32 | public void tileSelected(TileSelectionEvent e) { 33 | MainWindow mainWindow = MainWindow.getInstance(); 34 | 35 | Brush currentBrush = mainWindow.getCurrentBrush(); 36 | Tile lastSelectedTile = mainWindow.getLastSelectedTile(); 37 | 38 | if (currentBrush instanceof ShapeBrush) { 39 | ((ShapeBrush) currentBrush).setTile(e.getTile()); 40 | mainWindow.getMainToolBar().getPencilButton().setSelected(true); 41 | } else if (currentBrush instanceof BucketBrush) { 42 | ((BucketBrush) currentBrush).setPourTile(e.getTile()); 43 | } else { 44 | ShapeBrush shapeBrush = new ShapeBrush(); 45 | shapeBrush.setTile(e.getTile()); 46 | shapeBrush.makeRectangleBrush( 47 | new Rectangle(0, 0, 1, 1) 48 | ); 49 | mainWindow.setCurrentBrush(shapeBrush); 50 | mainWindow.getMainToolBar().getPencilButton().setSelected(true); 51 | } 52 | 53 | if (lastSelectedTile != e.getTile()) { 54 | mainWindow.setLastSelectedTile(e.getTile()); 55 | } 56 | } 57 | 58 | @Override 59 | public void tileRegionSelected(TileRegionSelectionEvent e) { 60 | MainWindow mainWindow = MainWindow.getInstance(); 61 | 62 | Brush currentBrush = MainWindow.getInstance().getCurrentBrush(); 63 | 64 | if (!(currentBrush instanceof CustomBrush)) { 65 | mainWindow.setCurrentBrush(new CustomBrush(e.getTiles())); 66 | } else { 67 | ((CustomBrush) currentBrush).setTiles(e.getTiles()); 68 | } 69 | 70 | mainWindow.getMainToolBar().getPencilButton().setSelected(true); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/SelectionBrush.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board; 9 | 10 | import java.awt.Point; 11 | import java.awt.Rectangle; 12 | import net.rpgtoolkit.common.assets.Tile; 13 | import net.rpgtoolkit.editor.editors.BoardEditor; 14 | import net.rpgtoolkit.editor.ui.AssetEditorWindow; 15 | 16 | /** 17 | * 18 | * 19 | * @author Joshua Michael Daly 20 | */ 21 | public class SelectionBrush extends CustomBrush { 22 | 23 | /** 24 | * 25 | * 26 | * @param tiles 27 | */ 28 | public SelectionBrush(Tile[][] tiles) { 29 | super(tiles); 30 | } 31 | 32 | /** 33 | * 34 | * 35 | * @param x 36 | * @param y 37 | * @param selection 38 | * @return 39 | * @throws Exception 40 | */ 41 | @Override 42 | public Rectangle doPaint(int x, int y, Rectangle selection) throws Exception { 43 | // Do nothing on paint. Perhaps collect the selected tiles here? 44 | return null; 45 | } 46 | 47 | @Override 48 | public void doMouseButton1Pressed(Point point, AssetEditorWindow editor) { 49 | if (editor instanceof BoardEditor) { 50 | BoardEditor boardEditor = (BoardEditor) editor; 51 | 52 | boardEditor.setSelection(new Rectangle(point.x, point.y, 0, 0)); 53 | boardEditor.setSelectedTiles( 54 | boardEditor.createTileLayerFromRegion( 55 | boardEditor.getSelection() 56 | ) 57 | ); 58 | } 59 | } 60 | 61 | @Override 62 | public void doMouseButton2Pressed(Point point, AssetEditorWindow editor) { 63 | // No implementation. 64 | } 65 | 66 | @Override 67 | public void doMouseButton3Pressed(Point point, AssetEditorWindow editor) { 68 | // No implementation. 69 | } 70 | 71 | @Override 72 | public void doMouseButton1Dragged(Point point, Point origin, AssetEditorWindow editor) { 73 | if (editor instanceof BoardEditor) { 74 | BoardEditor boardEditor = (BoardEditor) editor; 75 | 76 | Rectangle select = new Rectangle(origin.x, origin.y, 0, 0); 77 | select.add(point); 78 | 79 | if (!select.equals(boardEditor.getSelection())) { 80 | boardEditor.setSelection(select); 81 | } 82 | boardEditor.setSelectedTiles( 83 | boardEditor.createTileLayerFromRegion( 84 | boardEditor.getSelection() 85 | ) 86 | ); 87 | } 88 | } 89 | 90 | @Override 91 | public boolean isPixelBased() { 92 | return false; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/utilities/FileTools.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.utilities; 9 | 10 | import java.io.File; 11 | import java.net.URISyntaxException; 12 | import javax.swing.JFileChooser; 13 | import javax.swing.filechooser.FileNameExtensionFilter; 14 | import net.rpgtoolkit.common.utilities.CoreProperties; 15 | import net.rpgtoolkit.editor.MainWindow; 16 | import net.rpgtoolkit.editor.ui.SingleRootFileSystemView; 17 | 18 | /** 19 | * 20 | * @author Joshua Michael Daly 21 | */ 22 | public final class FileTools { 23 | 24 | public static String getExecutionPath(Class clazz) throws URISyntaxException { 25 | return new File(clazz.getProtectionDomain() 26 | .getCodeSource().getLocation().toURI().getPath()) 27 | .getAbsolutePath(); 28 | } 29 | 30 | public static boolean createDirectoryStructure(String path, String projectName) { 31 | boolean result = true; 32 | 33 | result &= createDirectory(path + File.separator + projectName); 34 | 35 | for (String directory : CoreProperties.getDirectories()) { 36 | result &= createDirectory(path + File.separator + projectName + File.separator + directory); 37 | } 38 | 39 | return result; 40 | } 41 | 42 | private static boolean createDirectory(String path) { 43 | File directory = new File(path); 44 | 45 | if (!directory.exists()) { 46 | return directory.mkdirs(); 47 | } else { 48 | return true; 49 | } 50 | } 51 | 52 | public static File doChoosePath() { 53 | JFileChooser fileChooser = new JFileChooser(System.getProperty("user.home")); 54 | fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 55 | 56 | if (fileChooser.showOpenDialog(MainWindow.getInstance()) == JFileChooser.APPROVE_OPTION) { 57 | return fileChooser.getCurrentDirectory(); 58 | } 59 | 60 | return null; 61 | } 62 | 63 | public static File doChooseFile(String extension, String directory, String type) { 64 | if (MainWindow.getInstance().getActiveProject() != null) { 65 | File projectPath = new File( 66 | System.getProperty("project.path") 67 | + File.separator 68 | + directory); 69 | 70 | if (projectPath.exists()) { 71 | JFileChooser fileChooser = new JFileChooser(new SingleRootFileSystemView(projectPath)); 72 | fileChooser.setAcceptAllFileFilterUsed(false); 73 | 74 | FileNameExtensionFilter filter = new FileNameExtensionFilter(type, extension); 75 | fileChooser.setFileFilter(filter); 76 | 77 | if (fileChooser.showOpenDialog(MainWindow.getInstance()) == JFileChooser.APPROVE_OPTION) { 78 | return fileChooser.getSelectedFile(); 79 | } 80 | } 81 | } 82 | 83 | return null; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/actions/RunAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.actions; 9 | 10 | import com.google.common.io.Files; 11 | import java.awt.Toolkit; 12 | import java.awt.event.ActionEvent; 13 | import java.io.File; 14 | import java.io.IOException; 15 | import java.util.List; 16 | import javax.swing.AbstractAction; 17 | import javax.swing.ProgressMonitor; 18 | import javax.swing.SwingWorker; 19 | import net.rpgtoolkit.editor.MainWindow; 20 | import net.rpgtoolkit.pluginsystem.Engine; 21 | import org.apache.commons.io.FileUtils; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | import ro.fortsoft.pf4j.PluginManager; 25 | 26 | /** 27 | * 28 | * @author Joshua Michael Daly 29 | */ 30 | public class RunAction extends AbstractAction { 31 | 32 | private static final Logger LOGGER = LoggerFactory.getLogger(RunAction.class); 33 | 34 | private ProgressMonitor progressMonitor; 35 | private SwingWorker worker; 36 | 37 | @Override 38 | public void actionPerformed(ActionEvent e) { 39 | try { 40 | MainWindow instance = MainWindow.getInstance(); 41 | 42 | String projectName = instance.getTitle(); 43 | 44 | // Make a temporary copy of the user's project for the engine to use. 45 | File projectOriginal = new File(System.getProperty("project.path")); 46 | File projectCopy = Files.createTempDir(); 47 | FileUtils.copyDirectory(projectOriginal, projectCopy); 48 | 49 | PluginManager pluginManager = MainWindow.getInstance().getPluginManager(); 50 | List engines = pluginManager.getExtensions(Engine.class); 51 | 52 | // Just use the first available engine for now. 53 | if (engines.size() > 0) { 54 | progressMonitor = new ProgressMonitor(MainWindow.getInstance(), "Starting Engine...", "", 0, 100); 55 | progressMonitor.setProgress(0); 56 | 57 | worker = new SwingWorker() { 58 | @Override 59 | protected Integer doInBackground() throws Exception { 60 | engines.get(0).run(projectName, projectCopy, progressMonitor); 61 | 62 | return null; 63 | } 64 | 65 | @Override 66 | public void done() { 67 | Toolkit.getDefaultToolkit().beep(); 68 | instance.getMainToolBar().getRunButton().setEnabled(false); 69 | instance.getMainToolBar().getStopButton().setEnabled(true); 70 | } 71 | }; 72 | worker.execute(); 73 | } 74 | 75 | } catch (IOException ex) { 76 | LOGGER.error("Failed to run engine.", ex); 77 | } 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/AbstractBrush.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board; 9 | 10 | import java.awt.Dimension; 11 | import java.awt.Graphics2D; 12 | import java.awt.Point; 13 | import java.awt.Rectangle; 14 | import java.awt.Shape; 15 | import net.rpgtoolkit.editor.ui.AssetEditorWindow; 16 | 17 | /** 18 | * 19 | * 20 | * @author Joshua Michael Daly 21 | */ 22 | public abstract class AbstractBrush implements Brush { 23 | 24 | /** 25 | * 26 | */ 27 | protected int affectedLayers = 1; 28 | 29 | /** 30 | * 31 | */ 32 | protected MultiLayerContainer affectedContainer; 33 | 34 | /** 35 | * 36 | */ 37 | protected boolean isPainting = false; 38 | 39 | /** 40 | * 41 | */ 42 | protected int currentLayer; 43 | 44 | /** 45 | * 46 | */ 47 | public AbstractBrush() { 48 | 49 | } 50 | 51 | /** 52 | * 53 | * @param abstractBrush 54 | */ 55 | public AbstractBrush(AbstractBrush abstractBrush) { 56 | affectedLayers = abstractBrush.affectedLayers; 57 | } 58 | 59 | @Override 60 | public int getAffectedLayers() { 61 | return affectedLayers; 62 | } 63 | 64 | /** 65 | * 66 | * @param layers 67 | */ 68 | public void setAffectedLayers(int layers) { 69 | affectedLayers = layers; 70 | } 71 | 72 | /** 73 | * 74 | * @return 75 | */ 76 | public int getInitialLayer() { 77 | return currentLayer; 78 | } 79 | 80 | /** 81 | * 82 | * @return 83 | */ 84 | public abstract Shape getShape(); 85 | 86 | @Override 87 | public void startPaint(MultiLayerContainer container, int layer) { 88 | affectedContainer = container; 89 | currentLayer = layer; 90 | isPainting = true; 91 | } 92 | 93 | @Override 94 | public Rectangle doPaint(int x, int y, Rectangle selection) throws Exception { 95 | if (!isPainting) { 96 | throw new Exception("Attempted to call doPaint() without calling" 97 | + "startPaint() beforehand."); 98 | } 99 | 100 | return null; 101 | } 102 | 103 | @Override 104 | public void endPaint() { 105 | isPainting = false; 106 | } 107 | 108 | @Override 109 | public void drawPreview(Graphics2D g2d, Dimension dimension, 110 | AbstractBoardView view) { 111 | // TODO: draw an off-board preview here. 112 | } 113 | 114 | public abstract void doMouseButton1Pressed(Point point, AssetEditorWindow editor); 115 | 116 | public abstract void doMouseButton2Pressed(Point point, AssetEditorWindow editor); 117 | 118 | public abstract void doMouseButton3Pressed(Point point, AssetEditorWindow editor); 119 | 120 | public abstract void doMouseButton1Dragged(Point point, Point origin, AssetEditorWindow editor); 121 | 122 | public abstract boolean isPixelBased(); 123 | 124 | } 125 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/animation/AddSpriteSheetButton.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.animation; 9 | 10 | import java.awt.Dimension; 11 | import java.awt.Graphics; 12 | import java.awt.Image; 13 | import java.awt.event.MouseEvent; 14 | import java.awt.image.BufferedImage; 15 | import java.io.File; 16 | import java.io.IOException; 17 | import java.util.logging.Level; 18 | import java.util.logging.Logger; 19 | import javax.imageio.ImageIO; 20 | import net.rpgtoolkit.common.assets.Animation; 21 | import net.rpgtoolkit.common.assets.SpriteSheet; 22 | import net.rpgtoolkit.editor.utilities.EditorFileManager; 23 | import net.rpgtoolkit.editor.ui.resources.Icons; 24 | import net.rpgtoolkit.editor.utilities.TransparentDrawer; 25 | 26 | /** 27 | * 28 | * @author Joshua Michael Daly 29 | */ 30 | public class AddSpriteSheetButton extends SpriteSheetImage { 31 | 32 | public AddSpriteSheetButton(Animation animation) { 33 | this.animation = animation; 34 | dimension = new Dimension(50, 50); 35 | } 36 | 37 | @Override 38 | public void paint(Graphics g) { 39 | TransparentDrawer.drawTransparentBackground(g, dimension.width, dimension.height); 40 | 41 | Image image = Icons.getIcon("plus", Icons.Size.LARGE).getImage(); 42 | 43 | int x = getWidth() / 2 - (image.getWidth(null) / 2); 44 | int y = getHeight() / 2 - (image.getHeight(null) / 2); 45 | g.drawImage(Icons.getIcon("plus", Icons.Size.LARGE).getImage(), x, y, this); 46 | } 47 | 48 | @Override 49 | public void mouseClicked(MouseEvent e) { 50 | File imageFile = EditorFileManager.browseLocationBySubdir( 51 | EditorFileManager.getGraphicsSubdirectory(), 52 | EditorFileManager.getImageFilterDescription(), 53 | EditorFileManager.getImageExtensions() 54 | ); 55 | 56 | if (imageFile != null) { 57 | try { 58 | BufferedImage image = ImageIO.read(imageFile); 59 | 60 | // TODO: Work around until user can specifiy region. 61 | int x = 0; 62 | int y = 0; 63 | int width = image.getWidth(); 64 | int height = image.getHeight(); 65 | 66 | String remove = EditorFileManager.getGraphicsPath(); 67 | String path = imageFile.getAbsolutePath().replace(remove, ""); 68 | animation.setSpriteSheet(new SpriteSheet(path, x, y, width, height)); 69 | animation.setAnimationHeight(height); // Save the user an extra step. 70 | } catch (IOException ex) { 71 | Logger.getLogger(AddSpriteSheetButton.class.getName()).log(Level.SEVERE, null, ex); 72 | } 73 | } 74 | } 75 | 76 | @Override 77 | public void mouseEntered(MouseEvent e) { 78 | } 79 | 80 | @Override 81 | public void mouseExited(MouseEvent e) { 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/TileSetTabbedPane.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import net.rpgtoolkit.editor.MainWindow; 11 | import java.awt.Font; 12 | import java.awt.event.MouseAdapter; 13 | import java.awt.event.MouseEvent; 14 | import java.util.Collection; 15 | import javax.swing.JScrollPane; 16 | import javax.swing.JTabbedPane; 17 | import javax.swing.JViewport; 18 | import javax.swing.event.ChangeEvent; 19 | import net.rpgtoolkit.common.assets.TileSet; 20 | import net.rpgtoolkit.common.utilities.CoreProperties; 21 | import net.rpgtoolkit.editor.editors.TileSetCanvas; 22 | 23 | /** 24 | * 25 | * @author Joshua Michael Daly 26 | */ 27 | public class TileSetTabbedPane extends JTabbedPane { 28 | 29 | public TileSetTabbedPane() { 30 | setFont(new Font(getFont().getFontName(), Font.PLAIN, 10)); 31 | setTabPlacement(JTabbedPane.BOTTOM); 32 | 33 | addMouseListener(); 34 | addTabChangeListener(); 35 | } 36 | 37 | public void addTileSet(TileSet tileSet) { 38 | String tabName = tileSet.getName().replace( 39 | CoreProperties.getDefaultExtension(TileSet.class), ""); 40 | 41 | if (indexOfTab(tabName) < 0) { 42 | JScrollPane scrollPane = new JScrollPane(); 43 | scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); 44 | 45 | TileSetCanvas canvas = new TileSetCanvas(tileSet); 46 | canvas.addTileSelectionListener( 47 | MainWindow.getInstance().getTileSetSelectionListener() 48 | ); 49 | 50 | scrollPane.setViewportView(canvas); 51 | scrollPane.getViewport().revalidate(); 52 | 53 | addTab(tabName, scrollPane); 54 | setSelectedIndex(indexOfTab(tabName)); 55 | } 56 | } 57 | 58 | public void addTileSets(Collection tileSets) { 59 | for (TileSet tileSet : tileSets) { 60 | addTileSet(tileSet); 61 | } 62 | } 63 | 64 | public void removeTileSets() { 65 | removeAll(); 66 | } 67 | 68 | private void addMouseListener() { 69 | addMouseListener(new MouseAdapter() { 70 | 71 | @Override 72 | public void mouseClicked(MouseEvent e) { 73 | JTabbedPane tabs = (JTabbedPane) e.getSource(); 74 | 75 | int index = tabs.indexAtLocation(e.getX(), e.getY()); 76 | 77 | if (index > -1 && e.getButton() == MouseEvent.BUTTON2) { 78 | tabs.remove(index); 79 | } 80 | } 81 | 82 | }); 83 | } 84 | 85 | private void addTabChangeListener() { 86 | addChangeListener((ChangeEvent e) -> { 87 | JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource(); 88 | int index = sourceTabbedPane.getSelectedIndex(); 89 | 90 | if (index > -1) { 91 | 92 | } 93 | }); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/tileset/NewTilesetDialog.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | /* 9 | * To change this license header, choose License Headers in Project Properties. 10 | * To change this template file, choose Tools | Templates 11 | * and open the template in the editor. 12 | */ 13 | package net.rpgtoolkit.editor.editors.tileset; 14 | 15 | import java.awt.GridLayout; 16 | import java.awt.event.ActionEvent; 17 | import java.awt.event.ActionListener; 18 | import javax.swing.JButton; 19 | import javax.swing.JDialog; 20 | import javax.swing.JLabel; 21 | import javax.swing.JPanel; 22 | import javax.swing.JSpinner; 23 | import javax.swing.SpinnerNumberModel; 24 | import javax.swing.SwingConstants; 25 | import net.rpgtoolkit.editor.MainWindow; 26 | 27 | /** 28 | * 29 | * @author Joshua Michael Daly 30 | */ 31 | public class NewTilesetDialog extends JDialog { 32 | 33 | private final JSpinner widthSpinner; 34 | private final JSpinner heightSpinner; 35 | 36 | private final JButton okButton; 37 | private final JButton cancelButton; 38 | 39 | private int[] value = null; 40 | 41 | /** 42 | * 43 | */ 44 | public NewTilesetDialog() { 45 | super(MainWindow.getInstance(), 46 | "New Tileset", 47 | JDialog.ModalityType.APPLICATION_MODAL); 48 | 49 | widthSpinner = new JSpinner(new SpinnerNumberModel(32, 16, 128, 1)); 50 | ((JSpinner.DefaultEditor) widthSpinner.getEditor()). 51 | getTextField().setColumns(7); 52 | 53 | heightSpinner = new JSpinner(new SpinnerNumberModel(32, 16, 128, 1)); 54 | ((JSpinner.DefaultEditor) heightSpinner.getEditor()). 55 | getTextField().setColumns(7); 56 | 57 | okButton = new JButton("OK"); 58 | okButton.addActionListener(new ActionListener() { 59 | 60 | @Override 61 | public void actionPerformed(ActionEvent e) { 62 | value = new int[] { 63 | (int) widthSpinner.getValue(), 64 | (int) heightSpinner.getValue() 65 | }; 66 | dispose(); 67 | } 68 | 69 | }); 70 | 71 | cancelButton = new JButton("Cancel"); 72 | cancelButton.addActionListener(new ActionListener() { 73 | 74 | @Override 75 | public void actionPerformed(ActionEvent e) { 76 | dispose(); 77 | } 78 | 79 | }); 80 | 81 | JPanel gridPanel = new JPanel(new GridLayout(0, 2)); 82 | gridPanel.add(new JLabel("Tile Width", SwingConstants.CENTER)); 83 | gridPanel.add(widthSpinner); 84 | gridPanel.add(new JLabel("Tile Height", SwingConstants.CENTER)); 85 | gridPanel.add(heightSpinner); 86 | gridPanel.add(okButton); 87 | gridPanel.add(cancelButton); 88 | 89 | add(gridPanel); 90 | 91 | setResizable(false); 92 | pack(); 93 | } 94 | 95 | /** 96 | * 97 | * @return 98 | */ 99 | public int[] getValue() { 100 | return value; 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /editor/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 15 | 16 | 4.0.0 17 | 18 | 19 | net.rpgtoolkit 20 | editor-parent 21 | 4.0.0-SNAPSHOT 22 | 23 | 24 | editor 25 | jar 26 | 2015 27 | RPG Toolkit 4.x Editor (UI) 28 | 29 | 30 | 31 | ${project.groupId} 32 | core 33 | ${project.version} 34 | 35 | 36 | ${project.groupId} 37 | pluginsystem 38 | ${project.version} 39 | 40 | 41 | 42 | 43 | 44 | 45 | src/main/resources 46 | 47 | 48 | 49 | 50 | 51 | org.apache.maven.plugins 52 | maven-jar-plugin 53 | ${maven.jar.version} 54 | 55 | 56 | 57 | true 58 | lib/ 59 | net.rpgtoolkit.editor.Driver 60 | 61 | 62 | 63 | 64 | 65 | maven-assembly-plugin 66 | 67 | 68 | package 69 | 70 | single 71 | 72 | 73 | 74 | 75 | 76 | 77 | net.rpgtoolkit.editor.Driver 78 | 79 | 80 | 81 | jar-with-dependencies 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/sprite/AnimationsTableModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.sprite; 9 | 10 | import javax.swing.table.AbstractTableModel; 11 | import net.rpgtoolkit.common.assets.AbstractSprite; 12 | import net.rpgtoolkit.common.assets.events.SpriteChangedEvent; 13 | import net.rpgtoolkit.common.assets.listeners.SpriteChangeListener; 14 | 15 | /** 16 | * 17 | * @author Joshua Michael Daly 18 | */ 19 | public class AnimationsTableModel extends AbstractTableModel implements SpriteChangeListener { 20 | 21 | private final AbstractSprite sprite; 22 | 23 | private static final String[] COLUMNS = { 24 | "Name", "Animation" 25 | }; 26 | 27 | public AnimationsTableModel(AbstractSprite sprite) { 28 | this.sprite = sprite; 29 | } 30 | 31 | /** 32 | * 33 | * 34 | * @param column 35 | * @return 36 | */ 37 | @Override 38 | public Class getColumnClass(int column) { 39 | switch (column) { 40 | case 0: 41 | return String.class; 42 | case 1: 43 | return String.class; 44 | } 45 | 46 | return null; 47 | } 48 | 49 | /** 50 | * 51 | * 52 | * @param column 53 | * @return 54 | */ 55 | @Override 56 | public String getColumnName(int column) { 57 | return COLUMNS[column]; 58 | } 59 | 60 | @Override 61 | public int getRowCount() { 62 | return (sprite.getAnimations().size()); 63 | } 64 | 65 | @Override 66 | public int getColumnCount() { 67 | return COLUMNS.length; 68 | } 69 | 70 | @Override 71 | public Object getValueAt(int rowIndex, int columnIndex) { 72 | switch (columnIndex) { 73 | case 0: 74 | return sprite.getAnimations().keySet().toArray()[rowIndex]; 75 | case 1: 76 | return sprite.getAnimations().values().toArray()[rowIndex]; 77 | default: 78 | return "NOT SUPPORTED"; 79 | } 80 | } 81 | 82 | /** 83 | * 84 | * 85 | * @param value 86 | * @param rowIndex 87 | * @param columnIndex 88 | */ 89 | @Override 90 | public void setValueAt(Object value, int rowIndex, int columnIndex) { 91 | fireTableCellUpdated(rowIndex, columnIndex); 92 | } 93 | 94 | /** 95 | * 96 | * 97 | * @param rowIndex 98 | * @param columnIndex 99 | * @return 100 | */ 101 | @Override 102 | public boolean isCellEditable(int rowIndex, int columnIndex) { 103 | // Don't allow direct editing of cells for simplicity. 104 | return false; 105 | } 106 | 107 | @Override 108 | public void spriteChanged(SpriteChangedEvent e) { 109 | } 110 | 111 | @Override 112 | public void spriteAnimationAdded(SpriteChangedEvent e) { 113 | fireTableDataChanged(); 114 | } 115 | 116 | @Override 117 | public void spriteAnimationUpdated(SpriteChangedEvent e) { 118 | fireTableDataChanged(); 119 | } 120 | 121 | @Override 122 | public void spriteAnimationRemoved(SpriteChangedEvent e) { 123 | fireTableDataChanged(); 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/ItemEditor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors; 9 | 10 | import java.awt.Component; 11 | import java.io.File; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import javax.swing.JLabel; 15 | import javax.swing.JTextField; 16 | import javax.swing.event.InternalFrameListener; 17 | import net.rpgtoolkit.common.assets.AbstractAsset; 18 | import net.rpgtoolkit.common.assets.AssetDescriptor; 19 | import net.rpgtoolkit.common.assets.GraphicEnum; 20 | import net.rpgtoolkit.common.assets.Item; 21 | import net.rpgtoolkit.common.assets.listeners.SpriteChangeListener; 22 | import net.rpgtoolkit.editor.editors.sprite.AbstractSpriteEditor; 23 | import net.rpgtoolkit.editor.ui.resources.Icons; 24 | 25 | /** 26 | * 27 | * @author Joshua Michael Daly 28 | */ 29 | public class ItemEditor extends AbstractSpriteEditor implements InternalFrameListener, SpriteChangeListener { 30 | 31 | private final Item item; 32 | 33 | private JTextField itemName; 34 | private JTextField itemDescription; 35 | 36 | public ItemEditor(Item item) { 37 | super("Untitled", item, Icons.getIcon("item")); 38 | 39 | this.item = item; 40 | this.item.addSpriteChangeListener(this); 41 | 42 | if (this.item.getDescriptor() == null) { 43 | setupNewItem(); 44 | } else { 45 | setTitle(new File(item.getDescriptor().getURI()).getName()); 46 | } 47 | 48 | constructWindow(); 49 | setVisible(true); 50 | pack(); 51 | } 52 | 53 | @Override 54 | public AbstractAsset getAsset() { 55 | return item; 56 | } 57 | 58 | public Item getItem() { 59 | return item; 60 | } 61 | 62 | @Override 63 | public void save() throws Exception { 64 | // Get the relative portrait path. 65 | checkProfileImagePath(); 66 | 67 | item.setName(itemName.getText()); 68 | item.setDescription(itemDescription.getText()); 69 | 70 | save(item); 71 | } 72 | 73 | @Override 74 | public void saveAs(File file) throws Exception { 75 | item.setDescriptor(new AssetDescriptor((file.toURI()))); 76 | setTitle(file.getName()); 77 | save(); 78 | } 79 | 80 | private void setupNewItem() { 81 | String undefined = "Undefined"; 82 | item.setDescription(undefined); 83 | } 84 | 85 | private void constructWindow() { 86 | addInternalFrameListener(this); 87 | 88 | createStatsPanel(); 89 | createAnimationsPanel(); 90 | 91 | build(); 92 | } 93 | 94 | private void createStatsPanel() { 95 | List labels = new ArrayList<>(); 96 | labels.add(new JLabel("Name")); 97 | labels.add(new JLabel("Description")); 98 | 99 | itemName = new JTextField(item.getName()); 100 | itemName.setColumns(DEFAULT_INPUT_COLUMNS); 101 | 102 | itemDescription = new JTextField(item.getDescription()); 103 | itemDescription.setColumns(DEFAULT_INPUT_COLUMNS); 104 | 105 | List inputs = new ArrayList<>(); 106 | inputs.add(itemName); 107 | inputs.add(itemDescription); 108 | 109 | profileImagePath = item.getGraphics().get(GraphicEnum.PROFILE.toString()); 110 | 111 | buildStatsPanel(labels, inputs); 112 | } 113 | 114 | private void createAnimationsPanel() { 115 | buildAnimationsPanel(); 116 | } 117 | 118 | } -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/AssetEditorWindow.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui; 9 | 10 | import java.io.File; 11 | import javax.swing.ImageIcon; 12 | import javax.swing.JInternalFrame; 13 | import net.rpgtoolkit.common.assets.AbstractAsset; 14 | import net.rpgtoolkit.common.assets.AssetDescriptor; 15 | import net.rpgtoolkit.common.assets.AssetManager; 16 | import net.rpgtoolkit.editor.utilities.EditorFileManager; 17 | import org.apache.commons.io.FileUtils; 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | 21 | public abstract class AssetEditorWindow extends JInternalFrame { 22 | 23 | private static final Logger LOGGER = LoggerFactory.getLogger(AssetEditorWindow.class); 24 | 25 | protected boolean needSave; 26 | 27 | public AssetEditorWindow() { 28 | 29 | } 30 | 31 | public boolean doesNeedSave() { 32 | return needSave; 33 | } 34 | 35 | protected void setNeedSave(boolean needSave) { 36 | if (this.needSave == needSave) { 37 | return; 38 | } 39 | 40 | this.needSave = needSave; 41 | setTitle(getTitle() + "*"); 42 | } 43 | 44 | public abstract AbstractAsset getAsset(); 45 | 46 | public AssetEditorWindow(String title, boolean resizeable, boolean closeable, 47 | boolean maximizable, boolean iconifiable, ImageIcon icon) { 48 | super(title, resizeable, closeable, maximizable, iconifiable); 49 | setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); 50 | setFrameIcon(icon); 51 | } 52 | 53 | public abstract void save() throws Exception; 54 | 55 | protected void save(AbstractAsset asset) throws Exception { 56 | File original; 57 | File backup = null; 58 | if (asset.getDescriptor() == null) { 59 | if (!selectDescriptor(asset)) { 60 | return; // Save was aborted by the user. 61 | } 62 | } else { 63 | // This will throw an exception if it can't make a backup. 64 | backup = EditorFileManager.backupFile(new File(asset.getDescriptor().getURI())); 65 | } 66 | 67 | original = new File(asset.getDescriptor().getURI()); 68 | try { 69 | AssetManager.getInstance().serialize( 70 | AssetManager.getInstance().getHandle(asset)); 71 | setTitle(original.getName()); 72 | needSave = false; 73 | setTitle(getTitle().replace("*", "")); 74 | } catch (Exception ex) { 75 | LOGGER.error("Failed to save asset=[{}].", asset, ex); 76 | 77 | if (backup != null) { 78 | // Existing file that failed during save. 79 | FileUtils.copyFile(backup, original); 80 | FileUtils.deleteQuietly(backup); 81 | } else { 82 | // New file that failed during save. 83 | asset.setDescriptor(null); 84 | FileUtils.deleteQuietly(original); 85 | } 86 | 87 | throw new Exception("Failed to save asset."); 88 | } 89 | 90 | if (backup != null) { 91 | FileUtils.deleteQuietly(backup); 92 | } 93 | } 94 | 95 | public abstract void saveAs(File file) throws Exception; 96 | 97 | private boolean selectDescriptor(AbstractAsset asset) { 98 | File file = EditorFileManager.saveByType(asset.getClass()); 99 | 100 | if (file == null) { 101 | return false; 102 | } 103 | 104 | asset.setDescriptor(new AssetDescriptor(file.toURI())); 105 | return true; 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/NewBoardDialog.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board; 9 | 10 | import java.awt.GridLayout; 11 | import java.awt.event.ActionEvent; 12 | import java.awt.event.ActionListener; 13 | import javax.swing.JButton; 14 | import javax.swing.JDialog; 15 | import javax.swing.JLabel; 16 | import javax.swing.JPanel; 17 | import javax.swing.JSpinner; 18 | import javax.swing.SpinnerNumberModel; 19 | import javax.swing.SwingConstants; 20 | import net.rpgtoolkit.editor.MainWindow; 21 | 22 | /** 23 | * 24 | * @author Joshua Michael Daly 25 | */ 26 | public class NewBoardDialog extends JDialog { 27 | 28 | private final JSpinner widthSpinner; 29 | private final JSpinner heightSpinner; 30 | private final JSpinner tileWidthSpinner; 31 | private final JSpinner tileHeightSpinner; 32 | 33 | private final JButton okButton; 34 | private final JButton cancelButton; 35 | 36 | private int[] value = null; 37 | 38 | /** 39 | * 40 | */ 41 | public NewBoardDialog() { 42 | super(MainWindow.getInstance(), 43 | "New Board", 44 | JDialog.ModalityType.APPLICATION_MODAL); 45 | 46 | widthSpinner = new JSpinner(new SpinnerNumberModel(10, 3, 50, 1)); 47 | ((JSpinner.DefaultEditor) widthSpinner.getEditor()). 48 | getTextField().setColumns(7); 49 | 50 | heightSpinner = new JSpinner(new SpinnerNumberModel(10, 3, 50, 1)); 51 | ((JSpinner.DefaultEditor) heightSpinner.getEditor()). 52 | getTextField().setColumns(7); 53 | 54 | tileWidthSpinner = new JSpinner(new SpinnerNumberModel(32, 3, 50, 1)); 55 | ((JSpinner.DefaultEditor) tileWidthSpinner.getEditor()). 56 | getTextField().setColumns(7); 57 | 58 | tileHeightSpinner = new JSpinner(new SpinnerNumberModel(32, 3, 50, 1)); 59 | ((JSpinner.DefaultEditor) tileHeightSpinner.getEditor()). 60 | getTextField().setColumns(7); 61 | 62 | okButton = new JButton("OK"); 63 | okButton.addActionListener(new ActionListener() { 64 | 65 | @Override 66 | public void actionPerformed(ActionEvent e) { 67 | value = new int[]{ 68 | (int) widthSpinner.getValue(), 69 | (int) heightSpinner.getValue(), 70 | (int) tileWidthSpinner.getValue(), 71 | (int) tileHeightSpinner.getValue() 72 | }; 73 | dispose(); 74 | } 75 | 76 | }); 77 | 78 | cancelButton = new JButton("Cancel"); 79 | cancelButton.addActionListener(new ActionListener() { 80 | 81 | @Override 82 | public void actionPerformed(ActionEvent e) { 83 | dispose(); 84 | } 85 | 86 | }); 87 | 88 | JPanel gridPanel = new JPanel(new GridLayout(0, 2)); 89 | gridPanel.add(new JLabel("Width", SwingConstants.CENTER)); 90 | gridPanel.add(widthSpinner); 91 | gridPanel.add(new JLabel("Height", SwingConstants.CENTER)); 92 | gridPanel.add(heightSpinner); 93 | gridPanel.add(new JLabel("Tile Width", SwingConstants.CENTER)); 94 | gridPanel.add(tileWidthSpinner); 95 | gridPanel.add(new JLabel("Tile Height", SwingConstants.CENTER)); 96 | gridPanel.add(tileHeightSpinner); 97 | gridPanel.add(okButton); 98 | gridPanel.add(cancelButton); 99 | 100 | add(gridPanel); 101 | 102 | setResizable(false); 103 | pack(); 104 | } 105 | 106 | /** 107 | * 108 | * @return 109 | */ 110 | public int[] getValue() { 111 | return value; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/sprite/ProfilePanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.sprite; 9 | 10 | import net.rpgtoolkit.editor.ui.AbstractImagePanel; 11 | import java.awt.Color; 12 | import java.awt.Dimension; 13 | import java.awt.Graphics; 14 | import java.awt.Image; 15 | import java.awt.event.MouseEvent; 16 | import java.io.File; 17 | import net.rpgtoolkit.editor.MainWindow; 18 | import net.rpgtoolkit.editor.utilities.EditorFileManager; 19 | import net.rpgtoolkit.editor.ui.resources.Icons; 20 | import net.rpgtoolkit.editor.utilities.TransparentDrawer; 21 | 22 | /** 23 | * 24 | * @author Joshua Michael Daly 25 | */ 26 | public class ProfilePanel extends AbstractImagePanel { 27 | 28 | private final Image defaultImage; 29 | 30 | private Dimension scaledDimension; 31 | 32 | public ProfilePanel() { 33 | super(new Dimension(250, 500)); 34 | setToolTipText("Double click to select an image."); 35 | 36 | defaultImage = Icons.getIcon("image", Icons.Size.LARGE).getImage(); 37 | scaledDimension = null; 38 | } 39 | 40 | @Override 41 | public Dimension getPreferredSize() { 42 | return dimension; 43 | } 44 | 45 | @Override 46 | public Dimension getMaximumSize() { 47 | return dimension; 48 | } 49 | 50 | @Override 51 | public Dimension getMinimumSize() { 52 | return dimension; 53 | } 54 | 55 | @Override 56 | public void paint(Graphics g) { 57 | if (scaledDimension == null) { 58 | // First call to paint. 59 | calculateScaledDimension(); 60 | } 61 | 62 | TransparentDrawer.drawTransparentBackground(g, getWidth(), getHeight()); 63 | 64 | Image image; 65 | if (bufferedImages.size() > 0) { 66 | image = bufferedImages.getFirst(); 67 | } else { 68 | image = defaultImage; 69 | } 70 | 71 | int x = (getWidth() - scaledDimension.width) / 2; 72 | int y = (getHeight() - scaledDimension.height) / 2; 73 | g.drawImage(image, x, y, scaledDimension.width, scaledDimension.height, this); 74 | 75 | g.setColor(Color.LIGHT_GRAY); 76 | g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); 77 | } 78 | 79 | @Override 80 | public void mouseClicked(MouseEvent e) { 81 | if (e.getClickCount() == 2) { 82 | MainWindow mainWindow = MainWindow.getInstance(); 83 | File imageFile = EditorFileManager.browseLocationBySubdir( 84 | EditorFileManager.getGraphicsSubdirectory(), 85 | EditorFileManager.getImageFilterDescription(), 86 | EditorFileManager.getImageExtensions() 87 | ); 88 | 89 | if (imageFile != null) { 90 | if (bufferedImages.size() > 0) { 91 | bufferedImages.remove(); 92 | } 93 | 94 | addImage(imageFile); 95 | calculateScaledDimension(); 96 | repaint(); 97 | } 98 | } 99 | } 100 | 101 | private void calculateScaledDimension() { 102 | Image image; 103 | if (bufferedImages.isEmpty()) { 104 | image = defaultImage; 105 | } else { 106 | image = bufferedImages.getFirst(); 107 | } 108 | 109 | int originalWidth = image.getWidth(this); 110 | int originalHeight = image.getHeight(this); 111 | int boundWidth = getWidth(); 112 | int boundHeight = getHeight(); 113 | int newWidth = originalWidth; 114 | int newHeight = originalHeight; 115 | 116 | if (originalWidth > boundWidth) { 117 | newWidth = boundWidth; 118 | newHeight = (newWidth * originalHeight) / originalWidth; 119 | } 120 | 121 | if (newHeight > boundHeight) { 122 | newHeight = boundHeight; 123 | newWidth = (newHeight * originalWidth) / originalHeight; 124 | } 125 | 126 | scaledDimension = new Dimension(newWidth, newHeight); 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/animation/SpriteSheetImage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.animation; 9 | 10 | import java.awt.Color; 11 | import java.awt.Dimension; 12 | import java.awt.Graphics; 13 | import java.awt.Graphics2D; 14 | import java.awt.Rectangle; 15 | import java.awt.event.MouseEvent; 16 | import java.awt.event.MouseListener; 17 | import java.awt.image.BufferedImage; 18 | import java.io.File; 19 | import java.io.IOException; 20 | import javax.swing.JPanel; 21 | import net.rpgtoolkit.common.assets.Animation; 22 | import net.rpgtoolkit.common.assets.SpriteSheet; 23 | import net.rpgtoolkit.editor.utilities.EditorFileManager; 24 | import net.rpgtoolkit.editor.utilities.GuiHelper; 25 | import net.rpgtoolkit.editor.utilities.TransparentDrawer; 26 | 27 | /** 28 | * 29 | * @author Joshua Michael Daly 30 | */ 31 | public class SpriteSheetImage extends JPanel implements MouseListener { 32 | 33 | protected Animation animation; 34 | private SpriteSheet spriteSheet; 35 | 36 | protected Dimension dimension; 37 | 38 | private boolean entered; 39 | 40 | public SpriteSheetImage() { 41 | animation = null; 42 | spriteSheet = null; 43 | entered = false; 44 | dimension = new Dimension(150, 150); 45 | 46 | addMouseListener(this); 47 | } 48 | 49 | public SpriteSheetImage(Animation animation, SpriteSheet sheet) { 50 | this.animation = animation; 51 | spriteSheet = sheet; 52 | entered = false; 53 | dimension = new Dimension(150, 150); 54 | 55 | addMouseListener(this); 56 | } 57 | 58 | @Override 59 | public Dimension getPreferredSize() { 60 | return dimension; 61 | } 62 | 63 | @Override 64 | public Dimension getMaximumSize() { 65 | return dimension; 66 | } 67 | 68 | @Override 69 | public Dimension getMinimumSize() { 70 | return dimension; 71 | } 72 | 73 | @Override 74 | public void paint(Graphics g) { 75 | TransparentDrawer.drawTransparentBackground( 76 | g, dimension.width, dimension.height 77 | ); 78 | 79 | BufferedImage image = spriteSheet.getImage(); 80 | if (image != null) { 81 | g.drawImage(image, 0, 0, null); 82 | GuiHelper.drawGrid( 83 | (Graphics2D) g, 84 | animation.getAnimationWidth(), 85 | animation.getAnimationHeight(), 86 | new Rectangle(image.getWidth(), image.getHeight()) 87 | ); 88 | } 89 | 90 | if (entered) { 91 | g.setColor(new Color(0, 0, 255, 64)); 92 | g.fillRect(0, 0, getWidth() - 1, getHeight() - 1); 93 | } 94 | } 95 | 96 | @Override 97 | public void mouseClicked(MouseEvent e) { 98 | if (e.getButton() == MouseEvent.BUTTON1) { 99 | File imageFile = EditorFileManager.browseLocationBySubdir( 100 | EditorFileManager.getGraphicsSubdirectory(), 101 | EditorFileManager.getImageFilterDescription(), 102 | EditorFileManager.getImageExtensions() 103 | ); 104 | 105 | if (imageFile != null) { 106 | String remove = EditorFileManager.getGraphicsPath(); 107 | String path = imageFile.getAbsolutePath().replace(remove, ""); 108 | 109 | spriteSheet = new SpriteSheet( 110 | path, 111 | 0, 0, 112 | dimension.width, dimension.height 113 | ); 114 | animation.setSpriteSheet(spriteSheet); 115 | repaint(); 116 | } 117 | } else if (e.getButton() == MouseEvent.BUTTON2) { 118 | animation.removeSpriteSheet(); 119 | } 120 | } 121 | 122 | @Override 123 | public void mousePressed(MouseEvent e) { 124 | } 125 | 126 | @Override 127 | public void mouseReleased(MouseEvent e) { 128 | } 129 | 130 | @Override 131 | public void mouseEntered(MouseEvent e) { 132 | entered = !entered; 133 | repaint(); 134 | } 135 | 136 | @Override 137 | public void mouseExited(MouseEvent e) { 138 | entered = !entered; 139 | repaint(); 140 | } 141 | 142 | public BufferedImage loadImage() throws IOException { 143 | BufferedImage image = spriteSheet.loadImage(); 144 | dimension = new Dimension(image.getWidth(), image.getHeight()); 145 | return image; 146 | } 147 | 148 | } 149 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/MultiLayerContainer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board; 9 | 10 | import java.awt.Rectangle; 11 | import java.util.ArrayList; 12 | import java.util.Collection; 13 | import java.util.Iterator; 14 | import java.util.ListIterator; 15 | 16 | /** 17 | * 18 | * @author Joshua Michael Daly 19 | */ 20 | public interface MultiLayerContainer { 21 | 22 | /** 23 | * Returns the total number of layers. 24 | * 25 | * @return the size of the layer vector 26 | */ 27 | int getTotalLayers(); 28 | 29 | /** 30 | * Changes the bounds of this plane to include all layers completely. 31 | */ 32 | public void fitBoundsToLayers(); 33 | 34 | /** 35 | * Returns a Rectangle representing the maximum bounds in 36 | * tiles. 37 | * 38 | * @return a new rectangle containing the maximum bounds of this plane 39 | */ 40 | public Rectangle getBounds(); 41 | 42 | /** 43 | * Returns a Rectangle representing the maximum bounds in 44 | * pixels. 45 | * 46 | * @return a new rectangle containing the maximum bounds of this plane 47 | */ 48 | public Rectangle getPixelBounds(); 49 | 50 | /** 51 | * Adds a layer to the map. 52 | * 53 | * @param layer The {@link MapLayer} to add 54 | * @return the layer passed to the function 55 | */ 56 | public BoardLayerView addLayerView(BoardLayerView layer); 57 | 58 | /** 59 | * Adds the MapLayer l after the MapLayer after. 60 | * 61 | * @param l the layer to add 62 | * @param after specifies the layer to add l after 63 | */ 64 | public void addLayerAfter(BoardLayerView l, BoardLayerView after); 65 | 66 | /** 67 | * Add a layer at the specified index, which should be within the valid 68 | * range. 69 | * 70 | * @param index the position at which to add the layer 71 | * @param layer the layer to add 72 | */ 73 | public void addLayer(int index, BoardLayerView layer); 74 | 75 | /** 76 | * 77 | * @param index 78 | * @param layer 79 | */ 80 | public void setLayer(int index, BoardLayerView layer); 81 | 82 | /** 83 | * Adds all the layers in a given java.util.Collection. 84 | * 85 | * @param layers a collection of layers to add 86 | */ 87 | public void addAllLayers(Collection layers); 88 | 89 | /** 90 | * Removes the layer at the specified index. Layers above this layer will 91 | * move down to fill the gap. 92 | * 93 | * @param index the index of the layer to be removed 94 | * @return the layer that was removed from the list 95 | */ 96 | public BoardLayerView removeLayer(int index); 97 | 98 | /** 99 | * Returns the layer vector. 100 | * 101 | * @return Vector the layer vector 102 | */ 103 | public ArrayList getLayerArrayList(); 104 | 105 | /** 106 | * Sets the layer vector to the given java.util.Vector. 107 | * 108 | * @param layers the new set of layers 109 | */ 110 | public void setLayerArrayList(ArrayList layers); 111 | 112 | /** 113 | * Moves the layer at index up one in the vector. 114 | * 115 | * @param index the index of the layer to swap up 116 | */ 117 | public void swapLayerUp(int index); 118 | 119 | /** 120 | * Moves the layer at index down one in the vector. 121 | * 122 | * @param index the index of the layer to swap down 123 | */ 124 | public void swapLayerDown(int index); 125 | 126 | /** 127 | * Returns the layer at the specified vector index. 128 | * 129 | * @param i the index of the layer to return 130 | * @return the layer at the specified index, or null if the index is out of 131 | * bounds 132 | */ 133 | public BoardLayerView getLayer(int i); 134 | 135 | /** 136 | * Gets a listIterator of all layers. 137 | * 138 | * @return a listIterator 139 | */ 140 | public ListIterator getLayers(); 141 | 142 | /** 143 | * Determines whether the point (x,y) falls within the plane. 144 | * 145 | * @param x 146 | * @param y 147 | * @return true if the point is within the plane, 148 | * false otherwise 149 | */ 150 | public boolean inBounds(int x, int y); 151 | 152 | /** 153 | * 154 | * 155 | * @return 156 | */ 157 | public Iterator iterator(); 158 | 159 | } 160 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/menu/ViewMenu.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.menu; 9 | 10 | import net.rpgtoolkit.editor.ui.listeners.SnapToGridItemListener; 11 | import net.rpgtoolkit.editor.ui.listeners.ShowVectorsItemListener; 12 | import net.rpgtoolkit.editor.ui.listeners.ShowGridItemListener; 13 | import net.rpgtoolkit.editor.ui.listeners.ShowCoordinatesItemListener; 14 | import java.awt.event.ActionEvent; 15 | import java.awt.event.KeyEvent; 16 | import javax.swing.JCheckBoxMenuItem; 17 | import javax.swing.JMenu; 18 | import javax.swing.JMenuItem; 19 | import javax.swing.JSeparator; 20 | import javax.swing.KeyStroke; 21 | import net.rpgtoolkit.editor.ui.actions.ZoomInAction; 22 | import net.rpgtoolkit.editor.ui.actions.ZoomOutAction; 23 | import net.rpgtoolkit.editor.ui.resources.Icons; 24 | 25 | /** 26 | * 27 | * @author Joshua Michael Daly 28 | */ 29 | public final class ViewMenu extends JMenu { 30 | 31 | private JMenuItem zoomInMenuItem; 32 | private JMenuItem zoomOutMenuItem; 33 | private JCheckBoxMenuItem showGridMenuItem; 34 | private JCheckBoxMenuItem showCoordinatesMenuItem; 35 | private JCheckBoxMenuItem showVectorsMenuItem; 36 | private JCheckBoxMenuItem snapToGridMenuItem; 37 | 38 | /** 39 | * 40 | */ 41 | public ViewMenu() { 42 | super("View"); 43 | 44 | setMnemonic(KeyEvent.VK_V); 45 | 46 | configureZoomInMenuItem(); 47 | configureZoomOutMenuItem(); 48 | configureShowGridMenuItem(); 49 | configureShowCoordinatesMenuItem(); 50 | configureShowVectorsMenuItem(); 51 | configureSnapToGridMenuItem(); 52 | 53 | add(zoomInMenuItem); 54 | add(zoomOutMenuItem); 55 | add(new JSeparator()); 56 | add(showGridMenuItem); 57 | add(showCoordinatesMenuItem); 58 | add(showVectorsMenuItem); 59 | add(new JSeparator()); 60 | add(snapToGridMenuItem); 61 | } 62 | 63 | public JMenuItem getZoomInMenuItem() { 64 | return zoomInMenuItem; 65 | } 66 | 67 | public JMenuItem getZoomOutMenuItem() { 68 | return zoomOutMenuItem; 69 | } 70 | 71 | public JCheckBoxMenuItem getShowGridMenuItem() { 72 | return showGridMenuItem; 73 | } 74 | 75 | public JCheckBoxMenuItem getShowCoordinatesMenuItem() { 76 | return showCoordinatesMenuItem; 77 | } 78 | 79 | public JCheckBoxMenuItem getShowVectorsMenuItem() { 80 | return showVectorsMenuItem; 81 | } 82 | 83 | /** 84 | * 85 | */ 86 | public void configureZoomInMenuItem() { 87 | zoomInMenuItem = new JMenuItem("Zoom In"); 88 | zoomInMenuItem.setIcon(Icons.getSmallIcon("zoom-in")); 89 | zoomInMenuItem.setAccelerator( 90 | KeyStroke.getKeyStroke(KeyEvent.VK_ADD, ActionEvent.CTRL_MASK)); 91 | zoomInMenuItem.setMnemonic(KeyEvent.VK_PLUS); 92 | zoomInMenuItem.addActionListener(new ZoomInAction()); 93 | } 94 | 95 | /** 96 | * 97 | */ 98 | public void configureZoomOutMenuItem() { 99 | zoomOutMenuItem = new JMenuItem("Zoom Out"); 100 | zoomOutMenuItem.setIcon(Icons.getSmallIcon("zoom-out")); 101 | zoomOutMenuItem.setAccelerator( 102 | KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, ActionEvent.CTRL_MASK)); 103 | zoomOutMenuItem.setMnemonic(KeyEvent.VK_MINUS); 104 | zoomOutMenuItem.addActionListener(new ZoomOutAction()); 105 | } 106 | 107 | /** 108 | * 109 | */ 110 | public void configureShowGridMenuItem() { 111 | showGridMenuItem = new JCheckBoxMenuItem("Show Grid"); 112 | showGridMenuItem.setIcon(Icons.getSmallIcon("grid")); 113 | showGridMenuItem.setAccelerator( 114 | KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.CTRL_MASK)); 115 | showGridMenuItem.setMnemonic(KeyEvent.VK_G); 116 | showGridMenuItem.addItemListener(new ShowGridItemListener()); 117 | } 118 | 119 | /** 120 | * 121 | */ 122 | public void configureShowCoordinatesMenuItem() { 123 | showCoordinatesMenuItem = new JCheckBoxMenuItem("Show Coordinates"); 124 | //showGridMenuItem.setAccelerator( 125 | // KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.CTRL_MASK)); 126 | //showGridMenuItem.setMnemonic(KeyEvent.VK_G); 127 | showCoordinatesMenuItem.addItemListener(new ShowCoordinatesItemListener()); 128 | } 129 | 130 | /** 131 | * 132 | */ 133 | public void configureShowVectorsMenuItem() { 134 | showVectorsMenuItem = new JCheckBoxMenuItem("Show Vectors"); 135 | //showGridMenuItem.setAccelerator( 136 | // KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.CTRL_MASK)); 137 | //showGridMenuItem.setMnemonic(KeyEvent.VK_G); 138 | showVectorsMenuItem.addItemListener(new ShowVectorsItemListener()); 139 | } 140 | 141 | /** 142 | * 143 | */ 144 | public void configureSnapToGridMenuItem() { 145 | snapToGridMenuItem = new JCheckBoxMenuItem("Snap to Grid"); 146 | snapToGridMenuItem.addItemListener(new SnapToGridItemListener()); 147 | } 148 | 149 | } 150 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/AnimationEditor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors; 9 | 10 | import java.awt.BorderLayout; 11 | import java.awt.Color; 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.util.logging.Level; 15 | import java.util.logging.Logger; 16 | import javax.swing.BorderFactory; 17 | import javax.swing.JPanel; 18 | import javax.swing.JScrollPane; 19 | import net.rpgtoolkit.common.assets.AbstractAsset; 20 | 21 | import net.rpgtoolkit.common.assets.Animation; 22 | import net.rpgtoolkit.common.assets.AssetDescriptor; 23 | import net.rpgtoolkit.common.assets.SpriteSheet; 24 | import net.rpgtoolkit.common.assets.events.AnimationChangedEvent; 25 | import net.rpgtoolkit.common.assets.listeners.AnimationChangeListener; 26 | import net.rpgtoolkit.editor.editors.animation.AddSpriteSheetButton; 27 | import net.rpgtoolkit.editor.editors.animation.SpriteSheetImage; 28 | import net.rpgtoolkit.editor.ui.AnimatedPanel; 29 | 30 | import net.rpgtoolkit.editor.ui.AssetEditorWindow; 31 | import net.rpgtoolkit.editor.ui.resources.Icons; 32 | 33 | /** 34 | * 35 | * @author Geoff Wilson 36 | * @author Joshua Michael Daly 37 | */ 38 | public class AnimationEditor extends AssetEditorWindow implements AnimationChangeListener { 39 | 40 | private final Animation animation; 41 | 42 | private AnimatedPanel animatedPanel; 43 | 44 | private JScrollPane timelineScrollPane; 45 | private JPanel timelinePanel; 46 | 47 | public AnimationEditor(Animation theAnimation) { 48 | super("Untitled", true, true, true, true, Icons.getIcon("animation")); 49 | 50 | animation = theAnimation; 51 | animation.addAnimationChangeListener(this); 52 | 53 | if (animation.getDescriptor() != null) { 54 | setTitle(new File(animation.getDescriptor().getURI()).getName()); 55 | } 56 | 57 | configureInterface(); 58 | setSize(400, 400); 59 | setVisible(true); 60 | } 61 | 62 | @Override 63 | public AbstractAsset getAsset() { 64 | return animation; 65 | } 66 | 67 | @Override 68 | public void save() throws Exception { 69 | save(animation); 70 | } 71 | 72 | /** 73 | * 74 | * 75 | * @param file 76 | * @throws java.lang.Exception 77 | */ 78 | @Override 79 | public void saveAs(File file) throws Exception { 80 | animation.setDescriptor(new AssetDescriptor(file.toURI())); 81 | save(); 82 | } 83 | 84 | public void gracefulClose() { 85 | animation.removeAnimationChangeListener(this); 86 | } 87 | 88 | public Animation getAnimation() { 89 | return animation; 90 | } 91 | 92 | @Override 93 | public void animationChanged(AnimationChangedEvent e) { 94 | updateInterface(); 95 | setNeedSave(true); 96 | } 97 | 98 | @Override 99 | public void animationFrameAdded(AnimationChangedEvent e) { 100 | updateInterface(); 101 | setNeedSave(true); 102 | } 103 | 104 | @Override 105 | public void animationFrameRemoved(AnimationChangedEvent e) { 106 | updateInterface(); 107 | setNeedSave(true); 108 | } 109 | 110 | private void updateInterface() { 111 | timelinePanel.removeAll(); 112 | configureTimeline(); 113 | revalidate(); 114 | repaint(); 115 | } 116 | 117 | private void configureInterface() { 118 | animatedPanel = new AnimatedPanel(); 119 | 120 | timelinePanel = new JPanel(); 121 | timelinePanel.setBackground(Color.LIGHT_GRAY); 122 | timelinePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); 123 | configureTimeline(); 124 | 125 | timelineScrollPane = new JScrollPane(timelinePanel); 126 | timelineScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); 127 | 128 | JPanel container = new JPanel(new BorderLayout()); 129 | container.add(animatedPanel, BorderLayout.CENTER); 130 | container.add(timelineScrollPane, BorderLayout.SOUTH); 131 | 132 | setContentPane(container); 133 | } 134 | 135 | private void configureTimeline() { 136 | try { 137 | SpriteSheet spriteSheet = animation.getSpriteSheet(); 138 | if (!spriteSheet.getFileName().isEmpty()) { 139 | SpriteSheetImage spriteSheetImage = new SpriteSheetImage( 140 | animation, 141 | spriteSheet 142 | ); 143 | 144 | spriteSheetImage.loadImage(); 145 | animatedPanel.setAnimation(animation); 146 | timelinePanel.add(spriteSheetImage); 147 | 148 | } else { 149 | timelinePanel.add(new AddSpriteSheetButton(animation)); 150 | } 151 | } catch (IOException ex) { 152 | Logger.getLogger(AnimationEditor.class.getName()).log(Level.SEVERE, null, ex); 153 | } 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/ui/menu/EditMenu.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.ui.menu; 9 | 10 | import java.awt.event.ActionEvent; 11 | import java.awt.event.KeyEvent; 12 | import javax.swing.JMenu; 13 | import javax.swing.JMenuItem; 14 | import javax.swing.JSeparator; 15 | import javax.swing.KeyStroke; 16 | import net.rpgtoolkit.editor.ui.resources.Icons; 17 | 18 | /** 19 | * 20 | * @author Joshua Michael Daly 21 | */ 22 | public final class EditMenu extends JMenu { 23 | 24 | private JMenuItem undoMenuItem; 25 | private JMenuItem redoMenuItem; 26 | private JMenuItem cutMenuItem; 27 | private JMenuItem copyMenuItem; 28 | private JMenuItem pasteMenuItem; 29 | private JMenuItem selectAllMenuItem; 30 | private JMenuItem commentMenuItem; 31 | private JMenuItem findMenuItem; 32 | private JMenuItem quickReplaceMenuItem; 33 | 34 | public EditMenu() { 35 | super("Edit"); 36 | 37 | setMnemonic(KeyEvent.VK_E); 38 | 39 | configureUndoMenuItem(); 40 | configureRedoMenuItem(); 41 | configureCutMenuItem(); 42 | configureCopyMenuItem(); 43 | configurePasteMenuItem(); 44 | configureSelectAllMenuItem(); 45 | configureCommentMenuItem(); 46 | configureFindMenuItem(); 47 | configureQuickReplaceMenuItem(); 48 | 49 | add(undoMenuItem); 50 | add(redoMenuItem); 51 | add(new JSeparator()); 52 | add(cutMenuItem); 53 | add(copyMenuItem); 54 | add(pasteMenuItem); 55 | add(new JSeparator()); 56 | add(selectAllMenuItem); 57 | add(commentMenuItem); 58 | add(new JSeparator()); 59 | add(findMenuItem); 60 | add(quickReplaceMenuItem); 61 | } 62 | 63 | public void configureUndoMenuItem() { 64 | undoMenuItem = new JMenuItem("Undo"); 65 | undoMenuItem.setIcon(Icons.getSmallIcon("undo")); 66 | undoMenuItem.setAccelerator( 67 | KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK)); 68 | undoMenuItem.setMnemonic(KeyEvent.VK_U); 69 | 70 | undoMenuItem.setEnabled(false); 71 | } 72 | 73 | public void configureRedoMenuItem() { 74 | redoMenuItem = new JMenuItem("Redo"); 75 | redoMenuItem.setIcon(Icons.getSmallIcon("redo")); 76 | redoMenuItem.setAccelerator( 77 | KeyStroke.getKeyStroke(KeyEvent.VK_Y, ActionEvent.CTRL_MASK)); 78 | redoMenuItem.setMnemonic(KeyEvent.VK_R); 79 | 80 | redoMenuItem.setEnabled(false); 81 | } 82 | 83 | public void configureCutMenuItem() { 84 | cutMenuItem = new JMenuItem("Cut"); 85 | cutMenuItem.setIcon(Icons.getSmallIcon("cut")); 86 | cutMenuItem.setAccelerator( 87 | KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); 88 | cutMenuItem.setMnemonic(KeyEvent.VK_T); 89 | 90 | cutMenuItem.setEnabled(false); 91 | } 92 | 93 | public void configureCopyMenuItem() { 94 | copyMenuItem = new JMenuItem("Copy"); 95 | copyMenuItem.setIcon(Icons.getSmallIcon("copy")); 96 | copyMenuItem.setAccelerator( 97 | KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); 98 | copyMenuItem.setMnemonic(KeyEvent.VK_C); 99 | 100 | copyMenuItem.setEnabled(false); 101 | } 102 | 103 | public void configurePasteMenuItem() { 104 | pasteMenuItem = new JMenuItem("Paste"); 105 | pasteMenuItem.setIcon(Icons.getSmallIcon("paste")); 106 | pasteMenuItem.setAccelerator( 107 | KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); 108 | pasteMenuItem.setMnemonic(KeyEvent.VK_P); 109 | 110 | pasteMenuItem.setEnabled(false); 111 | } 112 | 113 | public void configureSelectAllMenuItem() { 114 | selectAllMenuItem = new JMenuItem("Select All"); 115 | selectAllMenuItem.setAccelerator( 116 | KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); 117 | selectAllMenuItem.setMnemonic(KeyEvent.VK_A); 118 | 119 | selectAllMenuItem.setEnabled(false); 120 | } 121 | 122 | public void configureCommentMenuItem() { 123 | commentMenuItem = new JMenuItem("Un/Comment Selected"); 124 | commentMenuItem.setAccelerator( 125 | KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK 126 | + ActionEvent.SHIFT_MASK)); 127 | commentMenuItem.setMnemonic(KeyEvent.VK_M); 128 | 129 | commentMenuItem.setEnabled(false); 130 | } 131 | 132 | public void configureFindMenuItem() { 133 | findMenuItem = new JMenuItem("Quick Find"); 134 | findMenuItem.setIcon(Icons.getSmallIcon("find")); 135 | findMenuItem.setAccelerator( 136 | KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK)); 137 | findMenuItem.setMnemonic(KeyEvent.VK_F); 138 | 139 | findMenuItem.setEnabled(false); 140 | } 141 | 142 | public void configureQuickReplaceMenuItem() { 143 | quickReplaceMenuItem = new JMenuItem("Quick Replace"); 144 | quickReplaceMenuItem.setIcon(Icons.getSmallIcon("replace")); 145 | quickReplaceMenuItem.setAccelerator( 146 | KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.CTRL_MASK)); 147 | quickReplaceMenuItem.setMnemonic(KeyEvent.VK_R); 148 | 149 | quickReplaceMenuItem.setEnabled(false); 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/panels/BoardPanel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board.panels; 9 | 10 | import net.rpgtoolkit.editor.ui.AbstractModelPanel; 11 | import java.awt.event.ActionEvent; 12 | import java.awt.event.ActionListener; 13 | import java.io.File; 14 | import javax.swing.GroupLayout; 15 | import javax.swing.GroupLayout.Alignment; 16 | import javax.swing.JComboBox; 17 | import javax.swing.JLabel; 18 | import javax.swing.JSpinner; 19 | import javax.swing.event.ChangeEvent; 20 | import javax.swing.event.ChangeListener; 21 | import net.rpgtoolkit.common.assets.Board; 22 | import net.rpgtoolkit.common.utilities.CoreProperties; 23 | import net.rpgtoolkit.editor.utilities.GuiHelper; 24 | 25 | /** 26 | * 27 | * 28 | * @author Joshua Micahel Daly 29 | */ 30 | public class BoardPanel extends AbstractModelPanel { 31 | 32 | private final JSpinner widthSpinner; 33 | private final JLabel widthLabel; 34 | 35 | private final JSpinner heightSpinner; 36 | private final JLabel heightLabel; 37 | 38 | private final JComboBox musicFileComboBox; 39 | private final JLabel musicLabel; 40 | 41 | private final JComboBox entryProgramComboBox; 42 | private final JLabel entryProgramLabel; 43 | 44 | public BoardPanel(final Board board) { 45 | /// 46 | /// super 47 | /// 48 | super(board); 49 | /// 50 | /// widthSpinner 51 | /// 52 | widthSpinner = getJSpinner(board.getWidth()); 53 | widthSpinner.setEnabled(false); 54 | widthSpinner.addChangeListener(new ChangeListener() { 55 | 56 | @Override 57 | public void stateChanged(ChangeEvent e) { 58 | 59 | } 60 | 61 | }); 62 | /// 63 | /// heightSpinner 64 | /// 65 | heightSpinner = getJSpinner(board.getHeight()); 66 | heightSpinner.setEnabled(false); 67 | heightSpinner.addChangeListener(new ChangeListener() { 68 | 69 | @Override 70 | public void stateChanged(ChangeEvent e) { 71 | 72 | } 73 | 74 | }); 75 | /// 76 | /// musicTextField 77 | /// 78 | File directory = new File( 79 | System.getProperty("project.path") 80 | + File.separator 81 | + CoreProperties.getProperty("toolkit.directory.media") 82 | + File.separator); 83 | String[] exts = new String[] {"wav", "mp3"}; 84 | musicFileComboBox = GuiHelper.getFileListJComboBox(directory, exts, true); 85 | musicFileComboBox.setSelectedItem(board.getBackgroundMusic()); 86 | musicFileComboBox.addActionListener(new ActionListener() { 87 | 88 | @Override 89 | public void actionPerformed(ActionEvent e) { 90 | board.setBackgroundMusic((String)musicFileComboBox.getSelectedItem()); 91 | } 92 | 93 | }); 94 | /// 95 | /// entryProgramComboBox 96 | /// 97 | directory = new File( 98 | System.getProperty("project.path") 99 | + File.separator 100 | + CoreProperties.getProperty("toolkit.directory.program") 101 | + File.separator); 102 | exts = new String[] {"program", "js"}; 103 | entryProgramComboBox = GuiHelper.getFileListJComboBox(directory, exts, true); 104 | entryProgramComboBox.setSelectedItem(board.getFirstRunProgram()); 105 | entryProgramComboBox.addActionListener(new ActionListener() { 106 | 107 | @Override 108 | public void actionPerformed(ActionEvent e) { 109 | board.setFirstRunProgram((String)entryProgramComboBox.getSelectedItem()); 110 | } 111 | 112 | }); 113 | /// 114 | /// this 115 | /// 116 | horizontalGroup.addGroup( 117 | layout.createParallelGroup(GroupLayout.Alignment.LEADING) 118 | .addComponent(widthLabel = getJLabel("Width")) 119 | .addComponent(heightLabel = getJLabel("Height")) 120 | .addComponent(musicLabel = getJLabel("Music")) 121 | .addComponent(entryProgramLabel = getJLabel("Entry Program"))); 122 | 123 | horizontalGroup.addGroup( 124 | layout.createParallelGroup(GroupLayout.Alignment.LEADING) 125 | .addComponent(widthSpinner) 126 | .addComponent(heightSpinner) 127 | .addComponent(musicFileComboBox) 128 | .addComponent(entryProgramComboBox)); 129 | 130 | layout.setHorizontalGroup(horizontalGroup); 131 | 132 | verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) 133 | .addComponent(widthLabel).addComponent(widthSpinner)); 134 | 135 | verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) 136 | .addComponent(heightLabel).addComponent(heightSpinner)); 137 | 138 | verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) 139 | .addComponent(musicLabel).addComponent(musicFileComboBox)); 140 | 141 | verticalGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE) 142 | .addComponent(entryProgramLabel).addComponent(entryProgramComboBox)); 143 | 144 | layout.setVerticalGroup(verticalGroup); 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/CustomBrush.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board; 9 | 10 | import java.awt.Graphics2D; 11 | import java.awt.Point; 12 | import java.awt.Rectangle; 13 | import java.awt.Shape; 14 | 15 | import net.rpgtoolkit.common.assets.Tile; 16 | import net.rpgtoolkit.editor.ui.AssetEditorWindow; 17 | 18 | /** 19 | * 20 | * 21 | * @author Joshua Michael Daly 22 | */ 23 | public class CustomBrush extends AbstractBrush { 24 | 25 | /** 26 | * 27 | */ 28 | protected Rectangle bounds; 29 | 30 | /** 31 | * 32 | */ 33 | protected Tile[][] tiles; 34 | 35 | /** 36 | * 37 | * 38 | * @param tiles 39 | */ 40 | public CustomBrush(Tile[][] tiles) { 41 | this.tiles = tiles; 42 | bounds = new Rectangle(tiles.length, tiles[0].length); 43 | } 44 | 45 | /** 46 | * 47 | * 48 | * @return 49 | */ 50 | @Override 51 | public Shape getShape() { 52 | return getBounds(); 53 | } 54 | 55 | /** 56 | * 57 | * 58 | * @return 59 | */ 60 | @Override 61 | public Rectangle getBounds() { 62 | return bounds; 63 | } 64 | 65 | /** 66 | * 67 | * 68 | * @param rectangle 69 | */ 70 | public void setBounds(Rectangle rectangle) { 71 | bounds = rectangle; 72 | } 73 | 74 | /** 75 | * 76 | * 77 | * @return 78 | */ 79 | public Tile[][] getTiles() { 80 | return tiles; 81 | } 82 | 83 | /** 84 | * 85 | * 86 | * @param tiles 87 | */ 88 | public void setTiles(Tile[][] tiles) { 89 | this.tiles = tiles; 90 | resize(); 91 | } 92 | 93 | /** 94 | * 95 | * @param g2d 96 | * @param view 97 | */ 98 | @Override 99 | public void drawPreview(Graphics2D g2d, AbstractBoardView view) { 100 | 101 | } 102 | 103 | /** 104 | * 105 | * 106 | * @param brush 107 | * @return 108 | */ 109 | @Override 110 | public boolean equals(Brush brush) { 111 | if (brush instanceof CustomBrush) { 112 | if (brush == this) { 113 | return true; 114 | } 115 | } 116 | 117 | return false; 118 | } 119 | 120 | /** 121 | * 122 | * 123 | * @param container 124 | * @param layer 125 | */ 126 | @Override 127 | public void startPaint(MultiLayerContainer container, int layer) { 128 | super.startPaint(container, layer); 129 | } 130 | 131 | /** 132 | * 133 | * 134 | * @param x 135 | * @param y 136 | * @param selection 137 | * @return 138 | * @throws Exception 139 | */ 140 | @Override 141 | public Rectangle doPaint(int x, int y, Rectangle selection) throws Exception { 142 | BoardLayerView layer = affectedContainer.getLayer(currentLayer); 143 | 144 | if (layer == null) { 145 | return null; 146 | } 147 | 148 | int layerWidth = layer.getLayer().getBoard().getWidth(); 149 | int layerHeight = layer.getLayer().getBoard().getHeight(); 150 | 151 | int centerX = x - bounds.width / 2; 152 | int centerY = y - bounds.height / 2; 153 | 154 | super.doPaint(x, y, selection); 155 | 156 | // TODO: Some small inefficiencies in this with regard to the ifs. 157 | for (int offsetY = centerY; offsetY < centerY + bounds.height; offsetY++) { 158 | if (offsetY < 0) { 159 | continue; 160 | } else if (offsetY == layerHeight) { 161 | break; 162 | } 163 | 164 | for (int offsetX = centerX; offsetX < centerX + bounds.width; offsetX++) { 165 | if (offsetX < 0) { 166 | continue; 167 | } else if (offsetX == layerWidth) { 168 | break; 169 | } 170 | 171 | layer.getLayer().setTileAt(offsetX, offsetY, 172 | tiles[offsetX - centerX][offsetY - centerY]); 173 | } 174 | } 175 | 176 | return new Rectangle(centerX, centerY, 177 | bounds.width, bounds.height); 178 | } 179 | 180 | /** 181 | * 182 | */ 183 | public void resize() { 184 | bounds = new Rectangle(tiles.length, tiles[0].length); 185 | } 186 | 187 | @Override 188 | public void doMouseButton1Pressed(Point point, AssetEditorWindow editor) { 189 | 190 | } 191 | 192 | @Override 193 | public void doMouseButton2Pressed(Point point, AssetEditorWindow editor) { 194 | 195 | } 196 | 197 | @Override 198 | public void doMouseButton3Pressed(Point point, AssetEditorWindow editor) { 199 | 200 | } 201 | 202 | @Override 203 | public void doMouseButton1Dragged(Point point, Point origin, AssetEditorWindow editor) { 204 | } 205 | 206 | @Override 207 | public boolean isPixelBased() { 208 | return false; 209 | } 210 | 211 | } 212 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/BucketBrush.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board; 9 | 10 | import java.awt.Graphics2D; 11 | import java.awt.Point; 12 | import java.awt.Rectangle; 13 | import java.awt.Shape; 14 | import java.util.Stack; 15 | import net.rpgtoolkit.common.assets.Tile; 16 | import net.rpgtoolkit.editor.editors.BoardEditor; 17 | import net.rpgtoolkit.editor.ui.AssetEditorWindow; 18 | 19 | /** 20 | * 21 | * 22 | * @author Joshua Michael Daly 23 | */ 24 | public class BucketBrush extends AbstractBrush { 25 | 26 | /** 27 | * 28 | */ 29 | protected Tile pourTile; 30 | 31 | /** 32 | * 33 | */ 34 | protected Tile oldTile; 35 | 36 | /** 37 | * 38 | */ 39 | public BucketBrush() { 40 | 41 | } 42 | 43 | /** 44 | * 45 | * 46 | * @return 47 | */ 48 | @Override 49 | public Shape getShape() { 50 | return getBounds(); 51 | } 52 | 53 | /** 54 | * 55 | * 56 | * @return 57 | */ 58 | @Override 59 | public Rectangle getBounds() { 60 | return new Rectangle(0, 0, 1, 1); 61 | } 62 | 63 | /** 64 | * 65 | * 66 | * @return 67 | */ 68 | public Tile getPourTile() { 69 | return pourTile; 70 | } 71 | 72 | /** 73 | * 74 | * 75 | * @param tile 76 | */ 77 | public void setPourTile(Tile tile) { 78 | pourTile = tile; 79 | } 80 | 81 | /** 82 | * 83 | * 84 | * @return 85 | */ 86 | public Tile getOldTile() { 87 | return oldTile; 88 | } 89 | 90 | /** 91 | * 92 | * 93 | * @param tile 94 | */ 95 | public void setOldTile(Tile tile) { 96 | oldTile = tile; 97 | } 98 | 99 | /** 100 | * 101 | * 102 | * @param g2d 103 | * @param view 104 | */ 105 | @Override 106 | public void drawPreview(Graphics2D g2d, AbstractBoardView view) { 107 | 108 | } 109 | 110 | /** 111 | * 112 | * 113 | * @param brush 114 | * @return 115 | */ 116 | @Override 117 | public boolean equals(Brush brush) { 118 | return brush instanceof BucketBrush; 119 | } 120 | 121 | /** 122 | * 123 | * 124 | * @param x 125 | * @param y 126 | * @param selection 127 | * @return 128 | */ 129 | @Override 130 | public Rectangle doPaint(int x, int y, Rectangle selection) { 131 | BoardLayerView layer = affectedContainer.getLayer(currentLayer); 132 | 133 | if (layer == null) { 134 | return null; 135 | } 136 | if (pourTile.getTileSet() == null) { 137 | return null; 138 | } 139 | 140 | oldTile = layer.getLayer().getTileAt(x, y); 141 | 142 | if (oldTile == pourTile) { 143 | return null; 144 | } 145 | 146 | if (selection != null && selection.contains(x, y)) { 147 | if (selection.contains(x, y)) { 148 | for (int y2 = selection.y; y2 < selection.height + selection.y; y2++) { 149 | for (int x2 = selection.x; x2 < selection.width + selection.x; x2++) { 150 | layer.getLayer().setTileAt(x2, y2, pourTile); 151 | } 152 | } 153 | } 154 | return selection; 155 | } else { 156 | Rectangle area = new Rectangle(new Point(x, y)); 157 | Stack stack = new Stack<>(); 158 | 159 | stack.push(new Point(x, y)); 160 | 161 | while (!stack.empty()) { 162 | // Remove the next tile from the stack. 163 | Point point = stack.pop(); 164 | 165 | if (layer.getLayer().contains(point.x, point.y) 166 | && layer.getLayer().getTileAt(point.x, point.y).equals(oldTile)) { 167 | layer.getLayer().setTileAt(point.x, point.y, pourTile); 168 | area.add(point); 169 | 170 | stack.push(new Point(point.x, point.y - 1)); 171 | stack.push(new Point(point.x, point.y + 1)); 172 | stack.push(new Point(point.x + 1, point.y)); 173 | stack.push(new Point(point.x - 1, point.y)); 174 | } 175 | } 176 | 177 | return new Rectangle(area.x, area.y, area.width + 1, area.height + 1); 178 | } 179 | } 180 | 181 | @Override 182 | public void doMouseButton1Pressed(Point point, AssetEditorWindow editor) { 183 | if (editor instanceof BoardEditor) { 184 | BoardEditor boardEditor = (BoardEditor) editor; 185 | } 186 | } 187 | 188 | @Override 189 | public void doMouseButton2Pressed(Point point, AssetEditorWindow editor) { 190 | 191 | } 192 | 193 | @Override 194 | public void doMouseButton3Pressed(Point point, AssetEditorWindow editor) { 195 | 196 | } 197 | 198 | @Override 199 | public void doMouseButton1Dragged(Point point, Point origin, AssetEditorWindow editor) { 200 | 201 | } 202 | 203 | @Override 204 | public boolean isPixelBased() { 205 | return false; 206 | } 207 | 208 | } 209 | -------------------------------------------------------------------------------- /editor/src/main/java/net/rpgtoolkit/editor/editors/board/ShapeBrush.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015, rpgtoolkit.net 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | package net.rpgtoolkit.editor.editors.board; 9 | 10 | import java.awt.Dimension; 11 | import java.awt.Graphics2D; 12 | import java.awt.Point; 13 | import java.awt.Rectangle; 14 | import java.awt.Shape; 15 | import java.awt.geom.Area; 16 | import java.awt.geom.Rectangle2D; 17 | import net.rpgtoolkit.common.assets.Tile; 18 | import net.rpgtoolkit.editor.editors.BoardEditor; 19 | import net.rpgtoolkit.editor.ui.AssetEditorWindow; 20 | 21 | /** 22 | * 23 | * 24 | * @author Joshua Michael Daly 25 | */ 26 | public class ShapeBrush extends AbstractBrush { 27 | 28 | /** 29 | * 30 | */ 31 | protected Area shape; 32 | 33 | /** 34 | * 35 | */ 36 | protected Tile paintTile; 37 | 38 | /** 39 | * 40 | */ 41 | public ShapeBrush() { 42 | 43 | } 44 | 45 | /** 46 | * 47 | * 48 | * @param shape 49 | */ 50 | public ShapeBrush(Area shape) { 51 | this.shape = shape; 52 | paintTile = new Tile(); 53 | } 54 | 55 | /** 56 | * 57 | * 58 | * @param abstractBrush 59 | */ 60 | public ShapeBrush(AbstractBrush abstractBrush) { 61 | super(abstractBrush); 62 | 63 | if (abstractBrush instanceof ShapeBrush) { 64 | shape = ((ShapeBrush) abstractBrush).shape; 65 | paintTile = ((ShapeBrush) abstractBrush).paintTile; 66 | } 67 | } 68 | 69 | /** 70 | * 71 | * 72 | * @return 73 | */ 74 | public Tile getTile() { 75 | return paintTile; 76 | } 77 | 78 | /** 79 | * 80 | * 81 | * @param tile 82 | */ 83 | public void setTile(Tile tile) { 84 | paintTile = tile; 85 | } 86 | 87 | /** 88 | * 89 | * 90 | * @return 91 | */ 92 | @Override 93 | public Rectangle getBounds() { 94 | return shape.getBounds(); 95 | } 96 | 97 | /** 98 | * 99 | * 100 | * @return 101 | */ 102 | @Override 103 | public Shape getShape() { 104 | return shape; 105 | } 106 | 107 | /** 108 | * 109 | * 110 | * @param rectangle 111 | */ 112 | public void makeRectangleBrush(Rectangle rectangle) { 113 | shape = new Area(new Rectangle2D.Double(rectangle.x, rectangle.y, 114 | rectangle.width, rectangle.height)); 115 | } 116 | 117 | /** 118 | * 119 | * 120 | * @param g2d 121 | * @param dimension 122 | * @param view 123 | */ 124 | @Override 125 | public void drawPreview(Graphics2D g2d, Dimension dimension, 126 | AbstractBoardView view) { 127 | g2d.fill(shape); 128 | } 129 | 130 | /** 131 | * 132 | * 133 | * @param g2d 134 | * @param view 135 | */ 136 | @Override 137 | public void drawPreview(Graphics2D g2d, AbstractBoardView view) { 138 | 139 | } 140 | 141 | /** 142 | * 143 | * 144 | * @param brush 145 | * @return 146 | */ 147 | @Override 148 | public boolean equals(Brush brush) { 149 | return brush instanceof ShapeBrush 150 | && ((ShapeBrush) brush).shape.equals(shape); 151 | } 152 | 153 | /** 154 | * 155 | * 156 | * @param x 157 | * @param y 158 | * @param selection 159 | * @return 160 | * @throws Exception 161 | */ 162 | @Override 163 | public Rectangle doPaint(int x, int y, Rectangle selection) throws Exception { 164 | Rectangle shapeBounds = shape.getBounds(); 165 | int centerX = x - shapeBounds.width / 2; 166 | int centerY = y - shapeBounds.height / 2; 167 | 168 | super.doPaint(x, y, selection); 169 | 170 | for (int layer = 0; layer < affectedLayers; layer++) { 171 | BoardLayerView boardLayer = affectedContainer.getLayer( 172 | currentLayer + layer); 173 | 174 | if (boardLayer != null) { 175 | for (int i = 0; i <= shapeBounds.height + 1; i++) { 176 | for (int j = 0; j <= shapeBounds.width + 1; j++) { 177 | if (shape.contains(i, j)) { 178 | boardLayer.getLayer().setTileAt(j + centerX, i + centerY, 179 | paintTile); 180 | } 181 | } 182 | } 183 | } 184 | } 185 | 186 | return new Rectangle( 187 | centerX, centerY, shapeBounds.width, shapeBounds.height); 188 | } 189 | 190 | @Override 191 | public void doMouseButton1Pressed(Point point, AssetEditorWindow editor) { 192 | if (editor instanceof BoardEditor) { 193 | BoardEditor boardEditor = (BoardEditor) editor; 194 | boardEditor.setSelection(null); 195 | } 196 | } 197 | 198 | @Override 199 | public void doMouseButton2Pressed(Point point, AssetEditorWindow editor) { 200 | 201 | } 202 | 203 | @Override 204 | public void doMouseButton3Pressed(Point point, AssetEditorWindow editor) { 205 | 206 | } 207 | 208 | @Override 209 | public void doMouseButton1Dragged(Point point, Point origin, AssetEditorWindow editor) { 210 | 211 | } 212 | 213 | @Override 214 | public boolean isPixelBased() { 215 | return false; 216 | } 217 | 218 | } 219 | --------------------------------------------------------------------------------