Module ScreenManager
The ScreenManager library is a state manager at heart which allows some nifty things, like stacking multiple screens on top of each other.
Functions
performChanges () | This function is used internally by the ScreenManager library. |
init (nscreens, screen[, ...]) | Initialises the ScreenManager library. |
switch (screen[, ...]) | Switches to a screen. |
push (screen[, ...]) | Pushes a new screen to the stack. |
peek () | Returns the screen on top of the screen stack without removing it. |
pop () | Removes the topmost screen of the stack. |
publish (event, ...) | Publishes a message to all screens which have a public receive function. |
directorydropped (path) | Reroutes the directorydropped callback to the currently active screen. |
draw () | Reroutes the draw callback to all screens on the stack. |
filedropped (file) | Reroutes the filedropped callback to the currently active screen. |
focus (focus) | Reroutes the focus callback to all screens on the stack. |
keypressed (key, scancode, isrepeat) | Reroutes the keypressed callback to the currently active screen. |
keyreleased (key, scancode) | Reroutes the keyreleased callback to the currently active screen. |
lowmemory () | Reroutes the lowmemory callback to the currently active screen. |
mousefocus (focus) | Reroutes the mousefocus callback to the currently active screen. |
mousemoved (x, y, dx, dy) | Reroutes the mousemoved callback to the currently active screen. |
mousepressed (x, y, button, istouch) | Reroutes the mousepressed callback to the currently active screen. |
mousereleased (x, y, button, istouch) | Reroutes the mousereleased callback to the currently active screen. |
quit () | Reroutes the quit callback to the currently active screen. |
resize (w, h) | Reroutes the resize callback to all screens on the stack. |
textedited (text, start, length) | Reroutes the textedited callback to the currently active screen. |
textinput (input) | Reroutes the textinput callback to the currently active screen. |
threaderror (thread, errorstr) | Reroutes the threaderror callback to all screens. |
touchmoved (id, x, y, dx, dy, pressure) | Reroutes the touchmoved callback to the currently active screen. |
touchpressed (id, x, y, dx, dy, pressure) | Reroutes the touchpressed callback to the currently active screen. |
touchreleased (id, x, y, dx, dy, pressure) | Reroutes the touchreleased callback to the currently active screen. |
update (dt) | Reroutes the update callback to all screens. |
visible (visible) | Reroutes the visible callback to all screens. |
wheelmoved (x, y) | Reroutes the wheelmoved callback to the currently active screen. |
gamepadaxis (joystick, axis, value) | Reroutes the gamepadaxis callback to the currently active screen. |
gamepadpressed (joystick, button) | Reroutes the gamepadpressed callback to the currently active screen. |
gamepadreleased (joystick, button) | Reroutes the gamepadreleased callback to the currently active screen. |
joystickadded (joystick) | Reroutes the joystickadded callback to the currently active screen. |
joystickhat (joystick, hat, direction) | Reroutes the joystickhat callback to the currently active screen. |
joystickpressed (joystick, button) | Reroutes the joystickpressed callback to the currently active screen. |
joystickreleased (joystick, button) | Reroutes the joystickreleased callback to the currently active screen. |
joystickremoved (joystick) | Reroutes the joystickremoved callback to the currently active screen. |
registerCallbacks (callbacks) | Register to multiple LÖVE callbacks, defaults to all. |
Functions
- performChanges ()
-
This function is used internally by the ScreenManager library.
It performs all changes that have been added to the changes queue (FIFO) and
resets the queue afterwards.
See also:
- init (nscreens, screen[, ...])
-
Initialises the ScreenManager library.
It sets up the stack table, the list of screens to use and then proceeds with
validating and switching to the initial screen.
Parameters:
- nscreens table A table containing pointers to the different screen classes. The keys will are used to call a specific screen.
- screen string The key of the first screen to push to the stack. Use the key under which the screen in question is stored in the nscreens table.
- ... vararg Aditional arguments which will be passed to the new screen's init function. (optional)
- switch (screen[, ...])
-
Switches to a screen.
Removes all screens from the stack, creates a new screen and switches to it.
Use this if you don't want to stack onto other screens.
Parameters:
- screen string The key of the screen to switch to.
- ... vararg One or multiple arguments passed to the new screen's init function. (optional)
- push (screen[, ...])
-
Pushes a new screen to the stack.
Creates a new screen and pushes it onto the stack, where it will overlay the
other screens below it. Screens below this new screen will be set inactive.
Parameters:
- screen string The key of the screen to push to the stack.
- ... vararg One or multiple arguments passed to the new screen's init function. (optional)
- peek ()
-
Returns the screen on top of the screen stack without removing it.
Returns:
-
table
The screen on top of the stack.
- pop ()
-
Removes the topmost screen of the stack.
Raises:
Throws an error if the screen to pop is the last one on the stack. - publish (event, ...)
-
Publishes a message to all screens which have a public receive function.
Parameters:
- event string A string by which the message can be identified.
- ... varargs Multiple parameters to push to the receiver.
- directorydropped (path)
-
Reroutes the directorydropped callback to the currently active screen.
Parameters:
- path (string) The full platform-dependent path to the directory. It can be used as an argument to love.filesystem.mount, in order to gain read access to the directory with love.filesystem.
- draw ()
- Reroutes the draw callback to all screens on the stack. Screens that are higher on the stack will overlay screens that are below them.
- filedropped (file)
-
Reroutes the filedropped callback to the currently active screen.
Parameters:
- file (File) The unopened File object representing the file that was dropped.
- focus (focus)
-
Reroutes the focus callback to all screens on the stack.
Parameters:
- focus (boolean) True if the window gains focus, false if it loses focus.
- keypressed (key, scancode, isrepeat)
-
Reroutes the keypressed callback to the currently active screen.
Parameters:
- key (KeyConstant) Character of the pressed key.
- scancode (Scancode) The scancode representing the pressed key.
- isrepeat (boolean) Whether this keypress event is a repeat. The delay between key repeats depends on the user's system settings.
- keyreleased (key, scancode)
-
Reroutes the keyreleased callback to the currently active screen.
Parameters:
- key (KeyConstant) Character of the released key.
- scancode (Scancode) The scancode representing the released key.
- lowmemory ()
- Reroutes the lowmemory callback to the currently active screen. mobile devices.
- mousefocus (focus)
-
Reroutes the mousefocus callback to the currently active screen.
Parameters:
- focus (boolean) Wether the window has mouse focus or not.
- mousemoved (x, y, dx, dy)
-
Reroutes the mousemoved callback to the currently active screen.
Parameters:
- x (number) Mouse x position.
- y (number) Mouse y position.
- dx (number) The amount moved along the x-axis since the last time love.mousemoved was called.
- dy (number) The amount moved along the y-axis since the last time love.mousemoved was called.
- mousepressed (x, y, button, istouch)
-
Reroutes the mousepressed callback to the currently active screen.
Parameters:
- x (number) Mouse x position, in pixels.
- y (number) Mouse y position, in pixels.
- button (number) The button index that was pressed. 1 is the primary mouse button, 2 is the secondary mouse button and 3 is the middle button. Further buttons are mouse dependent.
- istouch (boolean) True if the mouse button press originated from a touchscreen touch-press.
- mousereleased (x, y, button, istouch)
-
Reroutes the mousereleased callback to the currently active screen.
Parameters:
- x (number) Mouse x position, in pixels.
- y (number) Mouse y position, in pixels.
- button (number) The button index that was released. 1 is the primary mouse button, 2 is the secondary mouse button and 3 is the middle button. Further buttons are mouse dependent.
- istouch (boolean) True if the mouse button release originated from a touchscreen touch-release.
- quit ()
-
Reroutes the quit callback to the currently active screen.
Returns:
-
quit (boolean) Abort quitting. If true, do not close the game.
- resize (w, h)
-
Reroutes the resize callback to all screens on the stack.
Parameters:
- w (number) The new width, in pixels.
- h (number) The new height, in pixels.
- textedited (text, start, length)
-
Reroutes the textedited callback to the currently active screen.
Parameters:
- text (string) The UTF-8 encoded unicode candidate text.
- start (number) The start cursor of the selected candidate text.
- length (number) The length of the selected candidate text. May be 0.
- textinput (input)
-
Reroutes the textinput callback to the currently active screen.
Parameters:
- input (string) The UTF-8 encoded unicode text.
- threaderror (thread, errorstr)
-
Reroutes the threaderror callback to all screens.
Parameters:
- thread (Thread) The thread which produced the error.
- errorstr (string) The error message.
- touchmoved (id, x, y, dx, dy, pressure)
-
Reroutes the touchmoved callback to the currently active screen.
Parameters:
- id (light userdata) The identifier for the touch press.
- x (number) The x-axis position of the touch press inside the window, in pixels.
- y (number) The y-axis position of the touch press inside the window, in pixels.
- dx (number) The x-axis movement of the touch inside the window, in pixels.
- dy (number) The y-axis movement of the touch inside the window, in pixels.
- pressure (number) The amount of pressure being applied. Most touch screens aren't pressure sensitive, in which case the pressure will be 1.
- touchpressed (id, x, y, dx, dy, pressure)
-
Reroutes the touchpressed callback to the currently active screen.
Parameters:
- id (light userdata) The identifier for the touch press.
- x (number) The x-axis position of the touch press inside the window, in pixels.
- y (number) The y-axis position of the touch press inside the window, in pixels.
- dx (number) The x-axis movement of the touch inside the window, in pixels.
- dy (number) The y-axis movement of the touch inside the window, in pixels.
- pressure (number) The amount of pressure being applied. Most touch screens aren't pressure sensitive, in which case the pressure will be 1.
- touchreleased (id, x, y, dx, dy, pressure)
-
Reroutes the touchreleased callback to the currently active screen.
Parameters:
- id (light userdata) The identifier for the touch press.
- x (number) The x-axis position of the touch press inside the window, in pixels.
- y (number) The y-axis position of the touch press inside the window, in pixels.
- dx (number) The x-axis movement of the touch inside the window, in pixels.
- dy (number) The y-axis movement of the touch inside the window, in pixels.
- pressure (number) The amount of pressure being applied. Most touch screens aren't pressure sensitive, in which case the pressure will be 1.
- update (dt)
-
Reroutes the update callback to all screens.
Parameters:
- dt (number) Time since the last update in seconds.
- visible (visible)
-
Reroutes the visible callback to all screens.
Parameters:
- visible (boolean) True if the window is visible, false if it isn't.
- wheelmoved (x, y)
-
Reroutes the wheelmoved callback to the currently active screen.
Parameters:
- x (number) Amount of horizontal mouse wheel movement. Positive values indicate movement to the right.
- y (number) Amount of vertical mouse wheel movement. Positive values indicate upward movement.
- gamepadaxis (joystick, axis, value)
-
Reroutes the gamepadaxis callback to the currently active screen.
Parameters:
- joystick (Joystick) The joystick object.
- axis (GamepadAxis) The joystick object.
- value (number) The new axis value.
- gamepadpressed (joystick, button)
-
Reroutes the gamepadpressed callback to the currently active screen.
Parameters:
- joystick (Joystick) The joystick object.
- button (GamepadButton) The virtual gamepad button.
- gamepadreleased (joystick, button)
-
Reroutes the gamepadreleased callback to the currently active screen.
Parameters:
- joystick (Joystick) The joystick object.
- button (GamepadButton) The virtual gamepad button.
- joystickadded (joystick)
-
Reroutes the joystickadded callback to the currently active screen.
Parameters:
- joystick (Joystick) The newly connected Joystick object.
- joystickhat (joystick, hat, direction)
-
Reroutes the joystickhat callback to the currently active screen.
Parameters:
- joystick (Joystick) The newly connected Joystick object.
- hat (number) The hat number.
- direction (JoystickHat) The new hat direction.
- joystickpressed (joystick, button)
-
Reroutes the joystickpressed callback to the currently active screen.
Parameters:
- joystick (Joystick) The newly connected Joystick object.
- button (number) The button number.
- joystickreleased (joystick, button)
-
Reroutes the joystickreleased callback to the currently active screen.
Parameters:
- joystick (Joystick) The newly connected Joystick object.
- button (number) The button number.
- joystickremoved (joystick)
-
Reroutes the joystickremoved callback to the currently active screen.
Parameters:
- joystick (Joystick) The now-disconnected Joystick object.
- registerCallbacks (callbacks)
-
Register to multiple LÖVE callbacks, defaults to all.
Parameters:
- callbacks (table) Table with the names of the callbacks to register to.