Module CorsixTH.CorsixTH.Lua.game_ui

Variant of UI for running games

Functions

GameUI:GameUI (app, local_hospital, map_editor) Game UI constructor.
GameUI:applyTransparency () Applies the current setting for wall transparency to the map
GameUI:beginShakeScreen (intensity) Start shaking the screen, e.g.
GameUI:calculateMinimumZoom () Calculate the minimum valid zoom value

Zooming out too much would cause negative width/height to be returned from makeVisibleDiamond.

GameUI:endShakeScreen () Stop the screen from shaking after beginShakeScreen is called.
GameUI:onMultiGesture (numfingers, dTheta, dDist, x, y) Process SDL_MULTIGESTURE events for zoom and map move functionality
GameUI:onWindowActive (gain) Called when the mouse enters or leaves the game window.
GameUI:playRandomAnnouncement (msgs, priority, chance_to_play, played_callback, played_callback_delay) Announcements to the player.
GameUI:quit () Offers a confirmation window to quit the game and return to main menu NB: overrides UI.quit, do NOT call it from here
GameUI:recallMapPosition (index) Retrieves stored recall position and attempts to scroll to that position - will be limited to the bounds of the camera when zoomed out param index (integer) Position in recallpositions table
GameUI:resync (ui) Update UI state after the UI has been depersisted When an UI object is depersisted, its state will reflect how the UI was at the moment of persistence, which may be different to the keyboard / mouse state at the moment of depersistence.
GameUI:setMapRecallPosition (index) Converts centre of screen coordinates to world tile positions and stores the values for later recall param index (integer) Position in recallpositions table
GameUI:setWallsTransparent (mode) Sets wall transparency to the specified parameter
GameUI:setWorldHitTest (mode) Change if the World should be tested for entities under the cursor


Functions

GameUI:GameUI (app, local_hospital, map_editor)
Game UI constructor.

Parameters:

  • app (Application) Application object.
  • local_hospital Hospital to display
  • map_editor (bool) Whether the map is editable.
GameUI:applyTransparency ()
Applies the current setting for wall transparency to the map
GameUI:beginShakeScreen (intensity)
Start shaking the screen, e.g. an earthquake effect

Parameters:

  • intensity (number) The magnitude of the effect, between 0 for no movement to 1 for significant shaking.
GameUI:calculateMinimumZoom ()
Calculate the minimum valid zoom value

Zooming out too much would cause negative width/height to be returned from makeVisibleDiamond. This function calculates the minimum zoom_factor that would be allowed.

GameUI:endShakeScreen ()
Stop the screen from shaking after beginShakeScreen is called.
GameUI:onMultiGesture (numfingers, dTheta, dDist, x, y)
Process SDL_MULTIGESTURE events for zoom and map move functionality

Parameters:

  • numfingers (integer) number of touch points, received from the SDL event This is still more info about param x.
  • dTheta (float) rotation in radians of the gesture from the SDL event
  • dDist (float) magnitude of pinch from the SDL event
  • x (float) normalised x value of the gesture
  • y (float) normalised y value of the gesture

Returns:

    (boolean) event processed indicator
GameUI:onWindowActive (gain)
Called when the mouse enters or leaves the game window.

Parameters:

  • gain
GameUI:playRandomAnnouncement (msgs, priority, chance_to_play, played_callback, played_callback_delay)
Announcements to the player.

Parameters:

  • msgs (array of string) Messages to select from.
  • priority (optional valid AnnouncementPriority selection) Priority of announcement
  • chance_to_play (optional float in range (0, 1]) Fraction of times that the call actually says something.
  • played_callback
  • played_callback_delay

Returns:

    (boolean) Whether a message was given to the user.
GameUI:quit ()
Offers a confirmation window to quit the game and return to main menu NB: overrides UI.quit, do NOT call it from here
GameUI:recallMapPosition (index)
Retrieves stored recall position and attempts to scroll to that position - will be limited to the bounds of the camera when zoomed out param index (integer) Position in recallpositions table

Parameters:

  • index
GameUI:resync (ui)
Update UI state after the UI has been depersisted When an UI object is depersisted, its state will reflect how the UI was at the moment of persistence, which may be different to the keyboard / mouse state at the moment of depersistence.

Parameters:

  • ui (UI) The previously existing UI object, from which values should be taken.
GameUI:setMapRecallPosition (index)
Converts centre of screen coordinates to world tile positions and stores the values for later recall param index (integer) Position in recallpositions table

Parameters:

  • index
GameUI:setWallsTransparent (mode)
Sets wall transparency to the specified parameter

Parameters:

  • mode (boolean) whether to enable or disable wall transparency
GameUI:setWorldHitTest (mode)
Change if the World should be tested for entities under the cursor

Parameters:

  • mode (boolean or room) true to enable hit test (normal), false to disable, room to enable only for non-door objects in given room
generated by LDoc TESTING Last updated 2015-01-01 12:00:00