diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ApplicationMenuController.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ApplicationMenuController.java new file mode 100644 index 00000000..a9f59d45 --- /dev/null +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ApplicationMenuController.java @@ -0,0 +1,51 @@ +package org.badvision.outlaweditor; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; + +/** + * + * @author blurry + */ +public abstract class ApplicationMenuController { + + @FXML + abstract public void onChangePlatformAppleDHGRSolid(ActionEvent event); + + @FXML + abstract public void onChangePlatformAppleDHGRText(ActionEvent event); + + @FXML + abstract public void onChangePlatformAppleSolid(ActionEvent event); + + @FXML + abstract public void onChangePlatformAppleText(ActionEvent event); + + @FXML + abstract public void onChangePlatformC64(ActionEvent event); + + @FXML + abstract public void onEditCopy(ActionEvent event); + + @FXML + abstract public void onEditPaste(ActionEvent event); + + @FXML + abstract public void onEditSelect(ActionEvent event); + + @FXML + abstract public void onFileOpen(ActionEvent event); + + @FXML + abstract public void onFileQuit(ActionEvent event); + + @FXML + abstract public void onFileSave(ActionEvent event); + + @FXML + abstract public void onFileSaveAs(ActionEvent event); + + @FXML + abstract public void onHelpAbout(ActionEvent event); + +} diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ApplicationMenuControllerImpl.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ApplicationMenuControllerImpl.java new file mode 100644 index 00000000..e84d4f3f --- /dev/null +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ApplicationMenuControllerImpl.java @@ -0,0 +1,116 @@ +package org.badvision.outlaweditor; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javafx.event.ActionEvent; +import org.badvision.outlaweditor.apple.AppleTileRenderer; + +/** + * + * @author blurry + */ +public class ApplicationMenuControllerImpl extends ApplicationMenuController { + + @Override + public void onChangePlatformAppleSolid(ActionEvent event) { + AppleTileRenderer.useSolidPalette = true; + Application.currentPlatform = Platform.AppleII; + ApplicationUIController.getController().platformChange(); + } + + @Override + public void onChangePlatformAppleText(ActionEvent event) { + AppleTileRenderer.useSolidPalette = false; + Application.currentPlatform = Platform.AppleII; + ApplicationUIController.getController().platformChange(); + } + + @Override + public void onChangePlatformAppleDHGRSolid(ActionEvent event) { + AppleTileRenderer.useSolidPalette = true; + Application.currentPlatform = Platform.AppleII_DHGR; + ApplicationUIController.getController().platformChange(); + } + + @Override + public void onChangePlatformAppleDHGRText(ActionEvent event) { + AppleTileRenderer.useSolidPalette = false; + Application.currentPlatform = Platform.AppleII_DHGR; + ApplicationUIController.getController().platformChange(); + } + + @Override + public void onChangePlatformC64(ActionEvent event) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void onEditCopy(ActionEvent event) { + ApplicationUIController mainController = ApplicationUIController.getController(); + if (mainController.getVisibleEditor() != null) { + mainController.getVisibleEditor().copy(); + } + } + + @Override + public void onEditPaste(ActionEvent event) { + ApplicationUIController mainController = ApplicationUIController.getController(); + if (mainController.getVisibleEditor() != null) { + mainController.getVisibleEditor().paste(); + } + } + + @Override + public void onEditSelect(ActionEvent event) { + ApplicationUIController mainController = ApplicationUIController.getController(); + if (mainController.getVisibleEditor() != null) { + mainController.getVisibleEditor().select(); + } + } + + @Override + public void onFileOpen(ActionEvent event) { + ApplicationUIController mainController = ApplicationUIController.getController(); + try { + UIAction.actionPerformed(UIAction.MAIN_ACTIONS.Load); + mainController.rebuildImageSelector(); + mainController.mapController.rebuildMapSelectors(); + mainController.rebuildTileSelectors(); + } catch (IOException ex) { + Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @Override + public void onFileQuit(ActionEvent event) { + UIAction.quit(); + } + + @Override + public void onFileSave(ActionEvent event) { + ApplicationUIController mainController = ApplicationUIController.getController(); + mainController.completeInflightOperations(); + try { + UIAction.actionPerformed(UIAction.MAIN_ACTIONS.Save); + } catch (IOException ex) { + Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @Override + public void onFileSaveAs(ActionEvent event) { + try { + UIAction.actionPerformed(UIAction.MAIN_ACTIONS.Save_as); + } catch (IOException ex) { + Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @Override + public void onHelpAbout(ActionEvent event) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + +} diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ApplicationUIController.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ApplicationUIController.java index 15830daa..262ec7b3 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/ApplicationUIController.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/ApplicationUIController.java @@ -5,21 +5,33 @@ import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.event.Event; import javafx.fxml.FXML; -import javafx.scene.control.CheckBox; import javafx.scene.control.ComboBox; -import javafx.scene.control.ListView; import javafx.scene.control.Menu; import javafx.scene.control.TextField; -import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; import org.badvision.outlaweditor.data.xml.Image; -import org.badvision.outlaweditor.data.xml.Map; -import org.badvision.outlaweditor.data.xml.Script; -import org.badvision.outlaweditor.data.xml.Tile; public abstract class ApplicationUIController { + + public static ApplicationUIController getController() { + return Application.instance.controller; + } + + abstract void rebuildTileSelectors(); + + abstract void rebuildImageSelector(); + + abstract Editor getVisibleEditor(); + @FXML // ResourceBundle that was given to the FXMLLoader protected ResourceBundle resources; + @FXML + ApplicationMenuController menuController; + @FXML + TileEditorTabController tileController; + @FXML + MapEditorTabController mapController; + @FXML // URL location of the FXML file that was given to the FXMLLoader protected URL location; @FXML // fx:id="imageCategoryField" @@ -36,38 +48,8 @@ public abstract class ApplicationUIController { protected ComboBox imageSelector; // Value injected by FXMLLoader @FXML // fx:id="imageWidthField" protected TextField imageWidthField; // Value injected by FXMLLoader - @FXML // fx:id="mapEditorAnchorPane" - protected AnchorPane mapEditorAnchorPane; // Value injected by FXMLLoader - @FXML // fx:id="mapHeightField" - protected TextField mapHeightField; // Value injected by FXMLLoader - @FXML // fx:id="mapNameField" - protected TextField mapNameField; // Value injected by FXMLLoader - @FXML // fx:id="mapScriptsList" - protected ListView