Package dev.prozilla.pine.core
Class Application
java.lang.Object
dev.prozilla.pine.core.Application
- All Implemented Interfaces:
- Destructible,- Initializable,- InputHandler,- Renderable,- Updatable,- ApplicationContext,- StateProvider<Application,- ApplicationState> 
public class Application
extends Object
implements Initializable, InputHandler, Updatable, Renderable, Destructible, ApplicationContext, StateProvider<Application,ApplicationState> 
2D application using the LWJGL library.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected ApplicationManagerprotected final AudioDeviceprotected final Configprotected Scenestatic final intstatic final Stringstatic booleanTrue if OpenGL has been initializedprotected Inputprotected booleanprotected final AppLoggerprotected final ModManagerprotected final Rendererprotected booleanprotected final StateMachine<Application, ApplicationState> protected final Timerprotected final Trackerprotected final Window
- 
Constructor SummaryConstructorsConstructorDescriptionApplication(int width, int height) Creates an application titled "Untitled".Application(String title, int width, int height) Creates an application.Application(String title, int width, int height, Scene scene) Creates an application.Application(String title, int width, int height, Scene scene, int targetFps) Creates an application.
- 
Method SummaryModifier and TypeMethodDescriptionintAdds a scene and returns its ID.voiddestroy()Stops the application and cleans up resources.getInput()getState()getTimer()voidinit()Initializes the application.voidinitPreview(Input input, int width, int height) voidinput(float deltaTime) Handles input for the application.booleanisAnyState(ApplicationState[] states) Checks whether this application is in any of the given states.static booleanChecks if the application is running in developer mode.booleanbooleanisPaused()booleanbooleanChecks whether this application hasn't been stopped yet.booleanbooleanisState(ApplicationState state) Checks whether this application is in a given state.voidLoads the window icons.voidloadScene(int id) Loads a scene by ID.voidLoads a scene by reference.voidLoads the next scene.voidpause()Pauses the application.voidLoads the previous scene.voidPrints system information and library versions.static booleanChecks if the application is currently running in developer mode.voidReloads the current scene.voidRenders the application.voidstatic voidThrows an exception if OpenGL has not been initialized yet.voidresize()Resizes the application window.voidresume()Resumes the application panel.voidrun()Initializes and starts the application and handles exceptions.voidsetApplicationManager(ApplicationManager applicationManager) voidsetDefaultFont(String fontPath) Sets the default font path for text elements.voidSets the icons of the application's window.voidstart()Starts the application loop.voidstop()Tells the application to stop after the current frame.voidPauses or resumes the application panel based on the current state.voidUnloads the current scene.voidupdate(float deltaTime) Updates the application.voidupdatePreview(float deltaTime) 
- 
Field Details- 
initializedOpenGLpublic static boolean initializedOpenGLTrue if OpenGL has been initialized
- 
shouldStopprotected boolean shouldStop
- 
isPreviewprotected boolean isPreview
- 
currentScene
- 
config
- 
logger
- 
timer
- 
renderer
- 
audioDevice
- 
window
- 
input
- 
tracker
- 
modManager
- 
stateMachine
- 
applicationManager
- 
DEFAULT_TITLE- See Also:
 
- 
DEFAULT_TARGET_FPSpublic static final int DEFAULT_TARGET_FPS- See Also:
 
 
- 
- 
Constructor Details- 
Applicationpublic Application(int width, int height) Creates an application titled "Untitled".- Parameters:
- width- Width of the window
- height- height of the window
 
- 
ApplicationCreates an application.- Parameters:
- title- Title of the application
- width- Width of the window
- height- height of the window
 
- 
ApplicationCreates an application.- Parameters:
- title- Title of the application
- width- Width of the window
- height- height of the window
- scene- Starting scene
 
- 
ApplicationCreates an application.- Parameters:
- title- Title of the application
- width- Width of the window
- height- height of the window
- scene- Starting scene
- targetFps- Amount of frames per second to target
 
 
- 
- 
Method Details- 
runpublic void run()Initializes and starts the application and handles exceptions.
- 
initInitializes the application.- Specified by:
- initin interface- Initializable
- Throws:
- RuntimeException
 
- 
initPreview
- 
startpublic void start()Starts the application loop. Destroys the application after the application loop has been stopped.
- 
inputpublic void input(float deltaTime) Handles input for the application.- Specified by:
- inputin interface- InputHandler
- Parameters:
- deltaTime- Delta time in seconds
 
- 
updatepublic void update(float deltaTime) Updates the application.
- 
updatePreviewpublic void updatePreview(float deltaTime) 
- 
renderRenders the application.- Specified by:
- renderin interface- Renderable
 
- 
renderPreviewpublic void renderPreview()
- 
pausepublic void pause()Pauses the application.
- 
resumepublic void resume()Resumes the application panel.
- 
togglePausepublic void togglePause()Pauses or resumes the application panel based on the current state.
- 
stoppublic void stop()Tells the application to stop after the current frame.
- 
destroypublic void destroy()Stops the application and cleans up resources. This should not be called before the application loop ends.- Specified by:
- destroyin interface- Destructible
 
- 
printInfopublic void printInfo()Prints system information and library versions.
- 
addSceneAdds a scene and returns its ID.- Parameters:
- scene- Scene
- Returns:
- Scene ID
 
- 
reloadScenepublic void reloadScene()Reloads the current scene.
- 
loadSceneLoads a scene by reference.- Parameters:
- scene- Reference to the scene
 
- 
nextScenepublic void nextScene()Loads the next scene.
- 
previousScenepublic void previousScene()Loads the previous scene.
- 
loadScenepublic void loadScene(int id) Loads a scene by ID.- Parameters:
- id- Scene ID
 
- 
unloadScenepublic void unloadScene()Unloads the current scene.
- 
getCurrentScene
- 
setApplicationManager
- 
isRunningpublic boolean isRunning()Checks whether this application hasn't been stopped yet.
- 
isLoadingpublic boolean isLoading()
- 
isPausedpublic boolean isPaused()
- 
getState- Specified by:
- getStatein interface- StateProvider<Application,- ApplicationState> 
- Returns:
- The state of this application
 
- 
isStateChecks whether this application is in a given state.- Specified by:
- isStatein interface- StateProvider<Application,- ApplicationState> 
 
- 
isAnyStateChecks whether this application is in any of the given states.- Specified by:
- isAnyStatein interface- StateProvider<Application,- ApplicationState> 
 
- 
setIconsSets the icons of the application's window.- Parameters:
- icons- Paths of icons
 
- 
loadIconspublic void loadIcons()Loads the window icons.
- 
setDefaultFontSets the default font path for text elements.- Parameters:
- fontPath- Path to the font file
 
- 
getDefaultFont- Returns:
- The default font of this application.
 
- 
resizepublic void resize()Resizes the application window.
- 
isPreviewpublic boolean isPreview()
- 
isStandalonepublic boolean isStandalone()
- 
getInput- Specified by:
- getInputin interface- ApplicationContext
 
- 
getWindow- Specified by:
- getWindowin interface- ApplicationContext
 
- 
getRenderer- Specified by:
- getRendererin interface- ApplicationContext
 
- 
getTimer- Specified by:
- getTimerin interface- ApplicationContext
 
- 
getTracker- Specified by:
- getTrackerin interface- ApplicationContext
 
- 
getConfig- Specified by:
- getConfigin interface- ApplicationContext
 
- 
getModManager- Specified by:
- getModManagerin interface- ApplicationContext
 
- 
getLogger- Specified by:
- getLoggerin interface- ApplicationContext
 
- 
getAudioDevice- Specified by:
- getAudioDevicein interface- ApplicationContext
 
- 
requireOpenGLThrows an exception if OpenGL has not been initialized yet.- Throws:
- IllegalStateException- If OpenGL has not been initialized yet.
 
- 
isDevModepublic static boolean isDevMode()Checks if the application is running in developer mode.This method is optimized and will only read the system property once. - See Also:
 
- 
readDevModepublic static boolean readDevMode()Checks if the application is currently running in developer mode.- Returns:
- trueif system property- dev-modeis currently set to- true.
 
 
-