Class EngineFrame

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class EngineFrame extends JFrame
Possibly. The most chaotic, most important UI. This is the main UI of the entire app where the user will spend ALL of their time and where just everything has to connect.

As a result, this class is also the orchestrator of all the important references storted within StaticRefs.

Like all other UI, it's generated with NetBeans, hence the initComponents().

Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • defer

      private static boolean defer
      Boolean flag to run FloatingPanel instances only if the engine is in a "running" state
    • mouseOwner

      private static MOwner mouseOwner
      The default MouseOwner. being selection
      See Also:
    • mousePos

      public static ScreenPoint mousePos
      The position of the mouse that is suspected by this frame. Do not trust this value. you might need to do offset magic with StaticConfig.jMenuBarOffsetY
    • selectionArea

      public static ScreenPoint[] selectionArea
      The selection area of the actual selection
      See Also:
    • commandPalette

      private CommandPalette commandPalette
      The command palette instance.
      See Also:
    • contextMenu

      private ContextMenu contextMenu
    • guideManager

      private GuideManager guideManager
    • floats

      private static final ArrayList<Runnable> floats
      The arraylist of runnables to initialise floaters when EngineFrame is ready.
    • PF_VERSION

      private final int PF_VERSION
      See Also:
    • LOADED_OLD

      private static boolean LOADED_OLD
      A flag to indicate if an old project file version was loaded during the readFileUsingVers(File, int) process. This is used to prevent redundant processing when attempting to load newer versions after a fallback to an older version has already occurred.
    • copyMenuItem

      private JMenuItem copyMenuItem
    • editJMenu

      private JMenu editJMenu
    • exportAsPNGJMenuItem

      private JMenuItem exportAsPNGJMenuItem
    • exportJMenuItemDropDown

      private JMenu exportJMenuItemDropDown
    • jMenu1

      private JMenu jMenu1
    • jMenuBar1

      public JMenuBar jMenuBar1
    • jMenuItem1

      private JMenuItem jMenuItem1
    • macroEditorMenu

      private JMenuItem macroEditorMenu
    • macroJMenu

      private JMenu macroJMenu
    • macroMainMenu

      private JMenu macroMainMenu
    • mainPanel

      public static JPanel mainPanel
    • newProjectJMenuItem

      private JMenuItem newProjectJMenuItem
    • openProjectMenuItem

      private JMenuItem openProjectMenuItem
    • pasteMenuItem

      private JMenuItem pasteMenuItem
    • redoJMenuItem

      private JMenuItem redoJMenuItem
    • redrawJMenuItem

      private JMenuItem redrawJMenuItem
    • resetCameraJMenuItem

      private JMenuItem resetCameraJMenuItem
    • resetJMenuItemDropDown

      private JMenu resetJMenuItemDropDown
    • resetOrientationJMenuItem

      private JMenuItem resetOrientationJMenuItem
    • resetPositionJMenuItem

      private JMenuItem resetPositionJMenuItem
    • saveProjectJMenuItem

      private JMenuItem saveProjectJMenuItem
    • sceneJMenu

      private JMenu sceneJMenu
    • settingsMenuItem

      private JMenuItem settingsMenuItem
    • toggleViewJMenuItem

      private JMenuItem toggleViewJMenuItem
    • undoJMenuItem

      private JMenuItem undoJMenuItem
    • viewAsNormalJMenuItem

      private JMenuItem viewAsNormalJMenuItem
    • viewAsWireframeJMenuItem

      private JMenuItem viewAsWireframeJMenuItem
    • viewJMenu

      private JMenu viewJMenu
  • Constructor Details

    • EngineFrame

      public EngineFrame()
      Default constructor. Initialises the entire engine in a clean state.
    • EngineFrame

      public EngineFrame(File file)
      Constructor to initialise the engine frame and immediately load up a project file.
      Parameters:
      file - The File instance to load up.
      See Also:
    • EngineFrame

      public EngineFrame(Artefact artifact, boolean showTutorial)
      Constructor with a boolean flag to initialise the executor.
      Parameters:
      artifact - The artefact to run
  • Method Details

    • showContextMenu

      public void showContextMenu(int x, int y)
    • getCommandPalette

      public CommandPalette getCommandPalette()
    • setMouseOwner

      public static void setMouseOwner(MOwner owner)
      Sets the mouse owner.
      Parameters:
      owner - The mouse owner's enum identifier
      See Also:
    • getMouseOwner

      public static MOwner getMouseOwner()
      Retries the mouse owner.
      Returns:
      The mouse owner's enum identifier.
      See Also:
    • addFloaterAt

      public static void addFloaterAt(FloatingPanel p, Point lastLocation)
      Adds a floating panel to the engine. Or otherwise if the engine hasn't been built will add it later via a Runnable
      Parameters:
      p - The floating panel to add
      lastLocation - The last location the mouse was at
      See Also:
    • bringForward

      public static void bringForward(FloatingPanel p)
      Brings a floating panel forward in the layer pane.
      Parameters:
      p - The floating panel
    • removeFloater

      public static void removeFloater(FloatingPanel p)
      Removes a floating panel from the EngineFrame
      Parameters:
      p - The floating panel
    • dispose

      public void dispose()
      Overrides:
      dispose in class Window
    • complete

      public void complete(Artefact artefact)
      Completes by manually initialising almost everything. I have no more words.
      Parameters:
      artefact - The artefact to run.
    • getGuideManager

      public GuideManager getGuideManager()
    • buildContextMenu

      private void buildContextMenu()
    • readProjectFile

      private void readProjectFile(File file)
      Extracts all the file stuff like its path and name, logs the read and also actually reads it by wrapping it in a LongTask so it runs off the EDT
      Parameters:
      file - The file to read.
      See Also:
    • readFileUsingVers

      public static void readFileUsingVers(File file, int vers)
      Reads a project file using a specified protocol version. This method extracts file information, sets the project output file, and initiates an asynchronous read operation using a LongTask. It includes error handling that can trigger a fallback to an older project file version if the initial read fails.
      Parameters:
      file - The File object representing the project file to read.
      vers - The version number of the ProjectFile protocol to attempt reading with. For example, `2` for PF2.
      See Also:
    • setCloseOperations

      private void setCloseOperations()
      Sets all the closing operations:

      1. The window will do nothing when it closes

      2. If the user made a change and hasn't saved since, will prompt the user with and are you sure dialogue. Similar to running the command ExitCmd

    • initMouseOwners

      private void initMouseOwners()
      Adds all the mouse owners.
      See Also:
    • repaintL

      public static void repaintL()
      Repaints the debug panel, command pallete, and main frame on the Event Dispatch Thread. This should only be called from non-EDT threads. e.g. from the SceneManager thread.
    • getDrawPanel

      public J3DPanel getDrawPanel()
    • getMacroJMenu

      public JMenu getMacroJMenu()
    • initComponents

      private void initComponents()
      This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
    • resetPositionJMenuItemActionPerformed

      private void resetPositionJMenuItemActionPerformed(ActionEvent evt)
    • undoJMenuItemActionPerformed

      private void undoJMenuItemActionPerformed(ActionEvent evt)
    • redoJMenuItemActionPerformed

      private void redoJMenuItemActionPerformed(ActionEvent evt)
    • resetOrientationJMenuItemActionPerformed

      private void resetOrientationJMenuItemActionPerformed(ActionEvent evt)
    • resetCameraJMenuItemActionPerformed

      private void resetCameraJMenuItemActionPerformed(ActionEvent evt)
    • redrawJMenuItemActionPerformed

      private void redrawJMenuItemActionPerformed(ActionEvent evt)
    • viewAsWireframeJMenuItemActionPerformed

      private void viewAsWireframeJMenuItemActionPerformed(ActionEvent evt)
    • viewAsNormalJMenuItemActionPerformed

      private void viewAsNormalJMenuItemActionPerformed(ActionEvent evt)
    • openProjectMenuItemActionPerformed

      private void openProjectMenuItemActionPerformed(ActionEvent evt)
    • saveProjectJMenuItemActionPerformed

      private void saveProjectJMenuItemActionPerformed(ActionEvent evt)
    • newProjectJMenuItemActionPerformed

      private void newProjectJMenuItemActionPerformed(ActionEvent evt)
    • exportAsPNGJMenuItemActionPerformed

      private void exportAsPNGJMenuItemActionPerformed(ActionEvent evt)
    • settingsMenuItemActionPerformed

      private void settingsMenuItemActionPerformed(ActionEvent evt)
    • jMenuItem1ActionPerformed

      private void jMenuItem1ActionPerformed(ActionEvent evt)
    • pasteMenuItemActionPerformed

      private void pasteMenuItemActionPerformed(ActionEvent evt)
    • copyMenuItemActionPerformed

      private void copyMenuItemActionPerformed(ActionEvent evt)
    • toggleViewJMenuItemActionPerformed

      private void toggleViewJMenuItemActionPerformed(ActionEvent evt)
    • macroEditorMenuActionPerformed

      private void macroEditorMenuActionPerformed(ActionEvent evt)
    • main

      public static void main(String[] args)
      Parameters:
      args - the command line arguments