Package de.tum.cit.ase.editor.screens
Class EditorUi
java.lang.Object
com.badlogic.gdx.InputAdapter
com.badlogic.gdx.scenes.scene2d.Stage
de.tum.cit.ase.editor.screens.EditorUi
- All Implemented Interfaces:
com.badlogic.gdx.InputProcessor,com.badlogic.gdx.utils.Disposable
public class EditorUi
extends com.badlogic.gdx.scenes.scene2d.Stage
The EditorUi class is responsible for managing the user interface of the editor screen in the Maze Runner game.
It extends Stage.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.badlogic.gdx.scenes.scene2d.Stage
com.badlogic.gdx.scenes.scene2d.Stage.TouchFocus -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidact(float delta) voidaddCheckBoxSetting(String text, Field EditorConfigFieldToChange, com.badlogic.gdx.scenes.scene2d.ui.Window window, String... fieldsDisabledWhenFalse) voidcheckAndRun(BooleanSupplier check, Runnable runnableOnSuccess, String nameOfAction, String nameOfMiddleOption, Runnable runnableOnFailure) Checks a condition and runs different actions based on the result.protected voidCreates a tile bar with buttons representing different tile types.protected voidCreate the toolbar for the editor.voiddispose()voiddraw()protected voidexit()Exits the editor application.protected voidExport the given map to a file.voidprotected voidImports a map from a file and loads it into the editor canvas.protected voidopen()Opens a map project file and loads it into the editor canvas.voidresize(int width, int height) protected voidsave()Saves the current state.protected voidsave(boolean saveAs) Saves the current state.Methods inherited from class com.badlogic.gdx.scenes.scene2d.Stage
act, actorRemoved, addAction, addActor, addCaptureListener, addListener, addTouchFocus, calculateScissors, cancelTouchFocus, cancelTouchFocus, cancelTouchFocusExcept, clear, getActionsRequestRendering, getActors, getBatch, getCamera, getDebugColor, getHeight, getKeyboardFocus, getRoot, getScrollFocus, getViewport, getWidth, hit, isDebugAll, isInsideViewport, keyDown, keyTyped, keyUp, mouseMoved, removeCaptureListener, removeListener, removeTouchFocus, screenToStageCoordinates, scrolled, setActionsRequestRendering, setDebugAll, setDebugInvisible, setDebugParentUnderMouse, setDebugTableUnderMouse, setDebugTableUnderMouse, setDebugUnderMouse, setKeyboardFocus, setRoot, setScrollFocus, setViewport, stageToScreenCoordinates, toScreenCoordinates, touchCancelled, touchDown, touchDragged, touchUp, unfocus, unfocusAll
-
Constructor Details
-
EditorUi
Initializes the EditorUi with the given Editor.- Parameters:
editor- the Editor instance to be used
-
-
Method Details
-
addCheckBoxSetting
-
save
protected void save()Saves the current state. If saveAs is true or the loadedMapProject is null, a native file chooser dialog is shown to choose a file name and location to save the map project. If saveAs is false and loadedMapProject is not null, the map project is saved to the same location. -
checkAndRun
public void checkAndRun(BooleanSupplier check, Runnable runnableOnSuccess, String nameOfAction, String nameOfMiddleOption, Runnable runnableOnFailure) Checks a condition and runs different actions based on the result.- Parameters:
check- the condition to checkrunnableOnSuccess- the action to run if the condition is truenameOfAction- the name of the main actionnameOfMiddleOption- the name of the middle option for the dialogrunnableOnFailure- the action to run if the condition is false
-
save
protected void save(boolean saveAs) Saves the current state. If saveAs is true or the loadedMapProject is null, a native file chooser dialog is shown to choose a file name and location to save the map project. If saveAs is false and loadedMapProject is not null, the map project is saved to the same location.- Parameters:
saveAs- a boolean indicating whether to perform "Save As" or not
-
open
protected void open()Opens a map project file and loads it into the editor canvas. If there is a loaded map project, it will be saved first before opening a new one.File extension filter is set to "MapProject/mapproj".
-
importMap
protected void importMap()Imports a map from a file and loads it into the editor canvas. -
exportMap
protected void exportMap()Export the given map to a file. -
exit
protected void exit()Exits the editor application.This method checks if the editor has been saved. If it has been saved, it directly quits the editor and returns to the main menu. Otherwise, it displays a confirmation dialog asking the user whether they want to save the changes before quitting. If the user chooses to save, the editor saves the current state and then quits. If the user chooses not to save, the editor quits without saving the changes.
-
draw
public void draw()- Overrides:
drawin classcom.badlogic.gdx.scenes.scene2d.Stage
-
resize
public void resize(int width, int height) -
createToolBar
protected void createToolBar()Create the toolbar for the editor. The toolbar contains buttons representing different tools. When a tool button is clicked, the corresponding tool is activated and the current tool is updated accordingly. -
createTileBar
protected void createTileBar()Creates a tile bar with buttons representing different tile types. -
hideAllPopups
public void hideAllPopups() -
act
public void act(float delta) - Overrides:
actin classcom.badlogic.gdx.scenes.scene2d.Stage
-
dispose
public void dispose()- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable- Overrides:
disposein classcom.badlogic.gdx.scenes.scene2d.Stage
-