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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
act
(float delta) void
addCheckBoxSetting
(String text, Field EditorConfigFieldToChange, com.badlogic.gdx.scenes.scene2d.ui.Window window, String... fieldsDisabledWhenFalse) void
checkAndRun
(BooleanSupplier check, Runnable runnableOnSuccess, String nameOfAction, String nameOfMiddleOption, Runnable runnableOnFailure) Checks a condition and runs different actions based on the result.protected void
Creates a tile bar with buttons representing different tile types.protected void
Create the toolbar for the editor.void
dispose()
void
draw()
protected void
exit()
Exits the editor application.protected void
Export the given map to a file.void
protected void
Imports a map from a file and loads it into the editor canvas.protected void
open()
Opens a map project file and loads it into the editor canvas.void
resize
(int width, int height) protected void
save()
Saves the current state.protected void
save
(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:
draw
in 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:
act
in classcom.badlogic.gdx.scenes.scene2d.Stage
-
dispose
public void dispose()- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Overrides:
dispose
in classcom.badlogic.gdx.scenes.scene2d.Stage
-