OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::BattlescapeState Class Reference

Battlescape screen which shows the tactical battle. More...

#include <BattlescapeState.h>

Inheritance diagram for OpenXcom::BattlescapeState:
OpenXcom::State

Public Member Functions

void selectNextPlayerUnit (bool checkReselect=false, bool setReselect=false, bool checkInventory=false)
 Selects the next soldier. More...
 
void selectPreviousPlayerUnit (bool checkReselect=false, bool setReselect=false, bool checkInventory=false)
 Selects the previous soldier. More...
 
 BattlescapeState (Game *game)
 Creates the Battlescape state. More...
 
 ~BattlescapeState ()
 Cleans up the Battlescape state. More...
 
void init ()
 Initilizes the battlescapestate.
 
void think ()
 Runs the timers and handles popups.
 
void mapOver (Action *action)
 Handler for moving mouse over the map. More...
 
void mapPress (Action *action)
 Handler for pressing the map. More...
 
void mapClick (Action *action)
 Handler for clicking the map. More...
 
void mapIn (Action *action)
 Handler for entering with mouse to the map surface. More...
 
void btnUnitUpClick (Action *action)
 Handler for clicking the Unit Up button. More...
 
void btnUnitDownClick (Action *action)
 Handler for clicking the Unit Down button. More...
 
void btnMapUpClick (Action *action)
 Handler for clicking the Map Up button. More...
 
void btnMapDownClick (Action *action)
 Handler for clicking the Map Down button. More...
 
void btnShowMapClick (Action *action)
 Handler for clicking the Show Map button. More...
 
void btnKneelClick (Action *action)
 Handler for clicking the Kneel button. More...
 
void btnInventoryClick (Action *action)
 Handler for clicking the Soldier button. More...
 
void btnCenterClick (Action *action)
 Handler for clicking the Center button. More...
 
void btnNextSoldierClick (Action *action)
 Handler for clicking the Next Soldier button. More...
 
void btnNextStopClick (Action *action)
 Handler for clicking the Next Stop button. More...
 
void btnPrevSoldierClick (Action *action)
 Handler for clicking the Previous Soldier button. More...
 
void btnShowLayersClick (Action *action)
 Handler for clicking the Show Layers button. More...
 
void btnHelpClick (Action *action)
 Handler for clicking the Help button. More...
 
void btnEndTurnClick (Action *action)
 Handler for clicking the End Turn button. More...
 
void btnAbortClick (Action *action)
 Handler for clicking the Abort button. More...
 
void btnStatsClick (Action *action)
 Handler for clicking the stats. More...
 
void btnLeftHandItemClick (Action *action)
 Handler for clicking the left hand item button. More...
 
void btnRightHandItemClick (Action *action)
 Handler for clicking the right hand item button. More...
 
void btnVisibleUnitClick (Action *action)
 Handler for clicking a visible unit button. More...
 
void btnLaunchClick (Action *action)
 Handler for clicking the launch rocket button. More...
 
void btnPsiClick (Action *action)
 Handler for clicking the use psi button. More...
 
void btnReserveClick (Action *action)
 Handler for clicking a reserved button. More...
 
void btnReloadClick (Action *action)
 Handler for clicking the reload button. More...
 
void btnPersonalLightingClick (Action *action)
 Handler for clicking the lighting button. More...
 
bool playableUnitSelected ()
 Determines whether a playable unit is selected. More...
 
void updateSoldierInfo ()
 Updates soldier name/rank/tu/energy/health/morale. More...
 
void animate ()
 Animates map objects on the map, also smoke,fire, ...
 
void handleState ()
 Handles the battle game state.
 
void setStateInterval (Uint32 interval)
 Sets the state timer interval. More...
 
GamegetGame () const
 Gets game. More...
 
MapgetMap () const
 Gets map. More...
 
void debug (const std::wstring &message)
 Show debug message. More...
 
void warning (const std::string &message)
 Show warning message. More...
 
void handle (Action *action)
 Handles keypresses. More...
 
void popup (State *state)
 Displays a popup window. More...
 
void finishBattle (bool abort, int inExitArea)
 Finishes a battle. More...
 
void showLaunchButton (bool show)
 Show the launch button. More...
 
void showPsiButton (bool show)
 Shows the PSI button. More...
 
void clearMouseScrollingState ()
 Clears mouse-scrolling state. More...
 
BattlescapeGamegetBattleGame ()
 Returns a pointer to the battlegame, in case we need its functions.
 
void saveAIMap ()
 Saves a map as used by the AI.
 
void saveVoxelMap ()
 Saves each layer of voxels on the bettlescape as a png.
 
void saveVoxelView ()
 Saves a first-person voxel view of the battlescape.
 
void mouseInIcons (Action *action)
 Handler for the mouse moving over the icons, disables the tile selection cube. More...
 
void mouseOutIcons (Action *action)
 Handler for the mouse going out of the icons, enabling the tile selection cube. More...
 
bool getMouseOverIcons () const
 Checks if the mouse is over the icons. More...
 
bool allowButtons (bool allowSaving=false) const
 Is the player allowed to press buttons? More...
 
void btnReserveKneelClick (Action *action)
 Handler for clicking the reserve TUs to kneel button. More...
 
void btnZeroTUsClick (Action *action)
 Handler for clicking the expend all TUs button. More...
 
void txtTooltipIn (Action *action)
 Handler for showing tooltip. More...
 
void txtTooltipOut (Action *action)
 Handler for hiding tooltip. More...
 
void resize (int &dX, int &dY)
 Update the resolution settings, we just resized the window. More...
 
void stopScrolling (Action *action)
 Move the mouse back to where it started after we finish drag scrolling. More...
 
- Public Member Functions inherited from OpenXcom::State
 State (Game *game)
 Creates a new state linked to a game. More...
 
virtual ~State ()
 Cleans up the state. More...
 
void add (Surface *surface)
 Adds a child element to the state. More...
 
bool isScreen () const
 Gets whether the state is a full-screen. More...
 
void toggleScreen ()
 Toggles whether the state is a full-screen. More...
 
virtual void blit ()
 Blits the state to the screen. More...
 
void hideAll ()
 Hides all the state surfaces. More...
 
void showAll ()
 Shws all the state surfaces. More...
 
void resetAll ()
 Resets all the state surfaces. More...
 
const LocalizedTexttr (const std::string &id) const
 Get the localized text. More...
 
LocalizedText tr (const std::string &id, unsigned n) const
 Get the localized text. More...
 
void redrawText ()
 redraw all the text-type surfaces.
 
void centerAllSurfaces ()
 center all surfaces relative to the screen. More...
 
void lowerAllSurfaces ()
 lower all surfaces by half the screen height. More...
 
void applyBattlescapeTheme ()
 switch the colours to use the battlescape palette. More...
 
void setModal (InteractiveSurface *surface)
 Sets a modal surface. More...
 
void setPalette (SDL_Color *colors, int firstcolor=0, int ncolors=256, bool immediately=true)
 Changes a set of colors on the state's 8bpp palette. More...
 
void setPalette (const std::string &palette, int backpals=-1)
 Changes the state's 8bpp palette with certain resources. More...
 
SDL_Color *const getPalette ()
 Gets the state's 8bpp palette. More...
 
virtual void recenter (int dX, int dY)
 Re-orients all the surfaces in the state. More...
 

Detailed Description

Battlescape screen which shows the tactical battle.

Constructor & Destructor Documentation

OpenXcom::BattlescapeState::BattlescapeState ( Game game)

Creates the Battlescape state.

Initializes all the elements in the Battlescape screen.

Parameters
gamePointer to the core game.
OpenXcom::BattlescapeState::~BattlescapeState ( )

Cleans up the Battlescape state.

Deletes the battlescapestate.

Member Function Documentation

bool OpenXcom::BattlescapeState::allowButtons ( bool  allowSaving = false) const

Is the player allowed to press buttons?

Determines whether the player is allowed to press buttons.

Buttons are disabled in the middle of a shot, during the alien turn, and while a player's units are panicking. The save button is an exception as we want to still be able to save if something goes wrong during the alien turn, and submit the save file for dissection.

Parameters
allowSavingTrue, if the help button was clicked.
Returns
True if the player can still press buttons.
void OpenXcom::BattlescapeState::btnAbortClick ( Action action)

Handler for clicking the Abort button.

Aborts the game.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnCenterClick ( Action action)

Handler for clicking the Center button.

Centers on the currently selected soldier.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnEndTurnClick ( Action action)

Handler for clicking the End Turn button.

Requests the end of turn.

This will add a 0 to the end of the state queue, so all ongoing actions, like explosions are finished first before really switching turn.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnHelpClick ( Action action)

Handler for clicking the Help button.

Shows options.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnInventoryClick ( Action action)

Handler for clicking the Soldier button.

Goes to the soldier info screen.

Additionally resets TUs for current side in debug mode.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnKneelClick ( Action action)

Handler for clicking the Kneel button.

Toggles the current unit's kneel/standup status.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnLaunchClick ( Action action)

Handler for clicking the launch rocket button.

Launches the blaster bomb.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnLeftHandItemClick ( Action action)

Handler for clicking the left hand item button.

Shows an action popup menu.

When clicked, creates the action.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnMapDownClick ( Action action)

Handler for clicking the Map Down button.

Shows the previous map layer.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnMapUpClick ( Action action)

Handler for clicking the Map Up button.

Shows the next map layer.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnNextSoldierClick ( Action action)

Handler for clicking the Next Soldier button.

Selects the next soldier.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnNextStopClick ( Action action)

Handler for clicking the Next Stop button.

Disables reselection of the current soldier and selects the next soldier.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnPersonalLightingClick ( Action action)

Handler for clicking the lighting button.

Toggles soldier's personal lighting (purely cosmetic).

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnPrevSoldierClick ( Action action)

Handler for clicking the Previous Soldier button.

Selects next soldier.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnPsiClick ( Action action)

Handler for clicking the use psi button.

Uses psionics.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnReloadClick ( Action action)

Handler for clicking the reload button.

Reloads the weapon in hand.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnReserveClick ( Action action)

Handler for clicking a reserved button.

Reserves time units.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnReserveKneelClick ( Action action)

Handler for clicking the reserve TUs to kneel button.

Reserves time units for kneeling.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnRightHandItemClick ( Action action)

Handler for clicking the right hand item button.

Shows an action popup menu.

When clicked, create the action.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnShowLayersClick ( Action action)

Handler for clicking the Show Layers button.

Shows/hides all map layers.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnShowMapClick ( Action action)

Handler for clicking the Show Map button.

Shows the minimap.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnStatsClick ( Action action)

Handler for clicking the stats.

Shows the selected soldier's info.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnUnitDownClick ( Action action)

Handler for clicking the Unit Down button.

Moves the selected unit down.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnUnitUpClick ( Action action)

Handler for clicking the Unit Up button.

Moves the selected unit up.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnVisibleUnitClick ( Action action)

Handler for clicking a visible unit button.

Centers on the unit corresponding to this button.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::btnZeroTUsClick ( Action action)

Handler for clicking the expend all TUs button.

Removes all time units.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::clearMouseScrollingState ( )

Clears mouse-scrolling state.

Clears mouse-scrolling state (isMouseScrolling).

void OpenXcom::BattlescapeState::debug ( const std::wstring &  message)

Show debug message.

Shows a debug message in the topleft corner.

Parameters
messageDebug message.
void OpenXcom::BattlescapeState::finishBattle ( bool  abort,
int  inExitArea 
)

Finishes a battle.

Finishes up the current battle, shuts down the battlescape and presents the debriefing screen for the mission.

Parameters
abortWas the mission aborted?
inExitAreaNumber of soldiers in the exit area OR number of survivors when battle finished due to either all aliens or objective being destroyed.
Game * OpenXcom::BattlescapeState::getGame ( ) const

Gets game.

Gets pointer to the game.

Some states need this info.

Returns
Pointer to game.
Map * OpenXcom::BattlescapeState::getMap ( ) const

Gets map.

Gets pointer to the map.

Some states need this info.

Returns
Pointer to map.
bool OpenXcom::BattlescapeState::getMouseOverIcons ( ) const

Checks if the mouse is over the icons.

Returns
True, if the mouse is over the icons.
void OpenXcom::BattlescapeState::handle ( Action action)
inlinevirtual

Handles keypresses.

Takes care of any events from the core game engine.

Parameters
actionPointer to an action.

Reimplemented from OpenXcom::State.

void OpenXcom::BattlescapeState::mapClick ( Action action)

Handler for clicking the map.

Processes any clicks on the map to command units.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::mapIn ( Action action)

Handler for entering with mouse to the map surface.

Handles mouse entering the map surface.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::mapOver ( Action action)

Handler for moving mouse over the map.

Processes any mouse moving over the map.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::mapPress ( Action action)

Handler for pressing the map.

Processes any presses on the map.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::mouseInIcons ( Action action)

Handler for the mouse moving over the icons, disables the tile selection cube.

Handler for the mouse moving over the icons, disabling the tile selection cube.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::mouseOutIcons ( Action action)

Handler for the mouse going out of the icons, enabling the tile selection cube.

Parameters
actionPointer to an action.
bool OpenXcom::BattlescapeState::playableUnitSelected ( )

Determines whether a playable unit is selected.

Normally only player side units can be selected, but in debug mode one can play with aliens too :) Is used to see if stats can be displayed and action buttons will work.

Returns
Whether a playable unit is selected.
void OpenXcom::BattlescapeState::popup ( State state)

Displays a popup window.

Adds a new popup window to the queue (this prevents popups from overlapping).

Parameters
statePointer to popup state.
void OpenXcom::BattlescapeState::resize ( int &  dX,
int &  dY 
)
virtual

Update the resolution settings, we just resized the window.

Updates the scale.

Parameters
dXdelta of X;
dYdelta of Y;

Reimplemented from OpenXcom::State.

void OpenXcom::BattlescapeState::selectNextPlayerUnit ( bool  checkReselect = false,
bool  setReselect = false,
bool  checkInventory = false 
)

Selects the next soldier.

Parameters
checkReselectWhen true, don't select a unit that has been previously flagged.
setReselectWhen true, flag the current unit first.
checkInventoryWhen true, don't select a unit that has no inventory.
void OpenXcom::BattlescapeState::selectPreviousPlayerUnit ( bool  checkReselect = false,
bool  setReselect = false,
bool  checkInventory = false 
)

Selects the previous soldier.

Parameters
checkReselectWhen true, don't select a unit that has been previously flagged.
setReselectWhen true, flag the current unit first.
checkInventoryWhen true, don't select a unit that has no inventory.
void OpenXcom::BattlescapeState::setStateInterval ( Uint32  interval)

Sets the state timer interval.

Sets the timer interval for think() calls of the state.

Parameters
intervalAn interval in ms.
void OpenXcom::BattlescapeState::showLaunchButton ( bool  show)

Show the launch button.

Shows the launch button.

Parameters
showShow launch button?
void OpenXcom::BattlescapeState::showPsiButton ( bool  show)

Shows the PSI button.

Parameters
showShow PSI button?
void OpenXcom::BattlescapeState::stopScrolling ( Action action)

Move the mouse back to where it started after we finish drag scrolling.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::txtTooltipIn ( Action action)

Handler for showing tooltip.

Shows a tooltip for the appropriate button.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::txtTooltipOut ( Action action)

Handler for hiding tooltip.

Clears the tooltip text.

Parameters
actionPointer to an action.
void OpenXcom::BattlescapeState::updateSoldierInfo ( )

Updates soldier name/rank/tu/energy/health/morale.

Updates a soldier's name/rank/tu/energy/health/morale.

void OpenXcom::BattlescapeState::warning ( const std::string &  message)

Show warning message.

Shows a warning message.

Parameters
messageWarning message.

The documentation for this class was generated from the following files: