OpenXcom  1.0
Open-source clone of the original X-Com
Public Member Functions | List of all members
OpenXcom::DogfightState Class Reference

Shows a dogfight (interception) between a player craft and an UFO. More...

#include <DogfightState.h>

Inheritance diagram for OpenXcom::DogfightState:
OpenXcom::State

Public Member Functions

 DogfightState (GeoscapeState *state, Craft *craft, Ufo *ufo)
 Creates the Dogfight state. More...
 
 ~DogfightState ()
 Cleans up the Dogfight state. More...
 
void think ()
 Runs the timers. More...
 
void animate ()
 Animates the window. More...
 
void update ()
 Moves the craft. More...
 
void fireWeapon1 ()
 Fires a shot from the first weapon equipped on the craft.
 
void fireWeapon2 ()
 Fires a shot from the second weapon equipped on the craft.
 
void ufoFireWeapon ()
 Each time a UFO will try to fire it's cannons a calculation is made. More...
 
void minimumDistance ()
 Sets the craft to the minimum distance required to fire a weapon.
 
void maximumDistance ()
 Sets the craft to the maximum distance required to fire a weapon.
 
void setStatus (const std::string &status)
 Changes the status text. More...
 
void btnMinimizeClick (Action *action)
 Handler for clicking the Minimize button. More...
 
void btnStandoffPress (Action *action)
 Handler for pressing the Standoff button. More...
 
void btnCautiousPress (Action *action)
 Handler for pressing the Cautious Attack button. More...
 
void btnStandardPress (Action *action)
 Handler for pressing the Standard Attack button. More...
 
void btnAggressivePress (Action *action)
 Handler for pressing the Aggressive Attack button. More...
 
void btnDisengagePress (Action *action)
 Handler for pressing the Disengage button. More...
 
void btnUfoClick (Action *action)
 Handler for clicking the Ufo button. More...
 
void previewClick (Action *action)
 Handler for clicking the Preview graphic. More...
 
void drawUfo ()
 Draws UFO.
 
void drawProjectile (const CraftWeaponProjectile *p)
 Draws projectiles.
 
void animateCraftDamage ()
 Animates craft damage. More...
 
void drawCraftDamage ()
 Updates craft damage. More...
 
void weapon1Click (Action *action)
 Toggles usage of weapon 1. More...
 
void weapon2Click (Action *action)
 Toggles usage of weapon 2. More...
 
void recolor (const int weaponNo, const bool currentState)
 Changes colors of weapon icons, range indicators and ammo texts base on current weapon state. More...
 
bool isMinimized () const
 Returns true if state is minimized. More...
 
void setMinimized (const bool minimized)
 Sets state minimized or maximized. More...
 
void btnMinimizedIconClick (Action *action)
 Handler for clicking the minimized interception window icon. More...
 
int getInterceptionNumber () const
 Gets interception number. More...
 
void setInterceptionNumber (const int number)
 Sets interception number. More...
 
void setInterceptionsCount (const size_t count)
 Sets interceptions count. More...
 
void calculateWindowPosition ()
 Calculates window position according to opened interception windows. More...
 
void moveWindow ()
 Moves window to new position. More...
 
bool dogfightEnded () const
 Checks if the dogfight should be ended. More...
 
UfogetUfo () const
 Gets pointer to the UFO in this dogfight. More...
 
CraftgetCraft () const
 Gets pointer to the craft in this dogfight. More...
 
void setWaitForPoly (bool wait)
 Waits until the UFO reaches a polygon.
 
bool getWaitForPoly () const
 Waits until the UFO reaches a polygon.
 
void setWaitForAltitude (bool wait)
 Waits until the UFO reaches the right altitude.
 
bool getWaitForAltitude () const
 Waits until the UFO reaches the right altutude.
 
- Public Member Functions inherited from OpenXcom::State
 State ()
 Creates a new state linked to a game. More...
 
virtual ~State ()
 Cleans up the state. More...
 
void setInterface (const std::string &s, bool alterPal=false, SavedBattleGame *battleGame=0)
 Set interface rules. More...
 
void add (Surface *surface)
 Adds a child element to the state. More...
 
void add (Surface *surface, const std::string &id, const std::string &category, Surface *parent=0)
 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 init ()
 Initializes the state. More...
 
virtual void handle (Action *action)
 Handles any events. 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...
 
const LocalizedTexttr (const std::string &id, SoldierGender gender) 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 * getPalette ()
 Gets the state's 8bpp palette. More...
 
virtual void resize (int &dX, int &dY)
 Let the state know the window has been resized. More...
 
virtual void recenter (int dX, int dY)
 Re-orients all the surfaces in the state. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from OpenXcom::State
static void setGamePtr (Game *game)
 Sets game object pointer.
 
- Static Protected Attributes inherited from OpenXcom::State
static Game_game = 0
 Initializes static member.
 

Detailed Description

Shows a dogfight (interception) between a player craft and an UFO.

Constructor & Destructor Documentation

◆ DogfightState()

OpenXcom::DogfightState::DogfightState ( GeoscapeState state,
Craft craft,
Ufo ufo 
)

Creates the Dogfight state.

Initializes all the elements in the Dogfight window.

Parameters
gamePointer to the core game.
statePointer to the Geoscape.
craftPointer to the craft intercepting.
ufoPointer to the UFO being intercepted.

◆ ~DogfightState()

OpenXcom::DogfightState::~DogfightState ( )

Cleans up the Dogfight state.

Cleans up the dogfight state.

Member Function Documentation

◆ animate()

void OpenXcom::DogfightState::animate ( )

Animates the window.

Animates the window with a palette effect.

◆ animateCraftDamage()

void OpenXcom::DogfightState::animateCraftDamage ( )

Animates craft damage.

Animates interceptor damage by changing the color and redrawing the image.

◆ btnAggressivePress()

void OpenXcom::DogfightState::btnAggressivePress ( Action action)

Handler for pressing the Aggressive Attack button.

Switches to Aggressive mode (minimum range).

Parameters
actionPointer to an action.

◆ btnCautiousPress()

void OpenXcom::DogfightState::btnCautiousPress ( Action action)

Handler for pressing the Cautious Attack button.

Switches to Cautious mode (maximum weapon range).

Parameters
actionPointer to an action.

◆ btnDisengagePress()

void OpenXcom::DogfightState::btnDisengagePress ( Action action)

Handler for pressing the Disengage button.

Disengages from the UFO.

Parameters
actionPointer to an action.

◆ btnMinimizeClick()

void OpenXcom::DogfightState::btnMinimizeClick ( Action action)

Handler for clicking the Minimize button.

Minimizes the dogfight window.

Parameters
actionPointer to an action.

◆ btnMinimizedIconClick()

void OpenXcom::DogfightState::btnMinimizedIconClick ( Action action)

Handler for clicking the minimized interception window icon.

Maximizes the interception window.

Parameters
actionPointer to an action.

◆ btnStandardPress()

void OpenXcom::DogfightState::btnStandardPress ( Action action)

Handler for pressing the Standard Attack button.

Switches to Standard mode (minimum weapon range).

Parameters
actionPointer to an action.

◆ btnStandoffPress()

void OpenXcom::DogfightState::btnStandoffPress ( Action action)

Handler for pressing the Standoff button.

Switches to Standoff mode (maximum range).

Parameters
actionPointer to an action.

◆ btnUfoClick()

void OpenXcom::DogfightState::btnUfoClick ( Action action)

Handler for clicking the Ufo button.

Shows a front view of the UFO.

Parameters
actionPointer to an action.

◆ calculateWindowPosition()

void OpenXcom::DogfightState::calculateWindowPosition ( )

Calculates window position according to opened interception windows.

Calculates dogfight window position according to number of active interceptions.

◆ dogfightEnded()

bool OpenXcom::DogfightState::dogfightEnded ( ) const

Checks if the dogfight should be ended.

Checks whether the dogfight should end.

Returns
Returns true if the dogfight should end, otherwise returns false.

◆ drawCraftDamage()

void OpenXcom::DogfightState::drawCraftDamage ( )

Updates craft damage.

Draws interceptor damage according to percentage of HP's left.

◆ getCraft()

Craft * OpenXcom::DogfightState::getCraft ( ) const

Gets pointer to the craft in this dogfight.

Returns the craft associated to this dogfight.

Returns
Returns pointer to craft object associated to this dogfight.

◆ getInterceptionNumber()

int OpenXcom::DogfightState::getInterceptionNumber ( ) const

Gets interception number.

Returns interception number.

Returns
interception number

◆ getUfo()

Ufo * OpenXcom::DogfightState::getUfo ( ) const

Gets pointer to the UFO in this dogfight.

Returns the UFO associated to this dogfight.

Returns
Returns pointer to UFO object associated to this dogfight.

◆ isMinimized()

bool OpenXcom::DogfightState::isMinimized ( ) const

Returns true if state is minimized.

Otherwise returns false.

Returns
Is the dogfight minimized?

◆ moveWindow()

void OpenXcom::DogfightState::moveWindow ( )

Moves window to new position.

Relocates all dogfight window elements to calculated position.

This is used when multiple interceptions are running.

◆ previewClick()

void OpenXcom::DogfightState::previewClick ( Action action)

Handler for clicking the Preview graphic.

Hides the front view of the UFO.

Parameters
actionPointer to an action.

◆ recolor()

void OpenXcom::DogfightState::recolor ( const int  weaponNo,
const bool  currentState 
)

Changes colors of weapon icons, range indicators and ammo texts base on current weapon state.

Parameters
weaponNo- number of weapon for which colors must be changed.
currentState- state of weapon (enabled = true, disabled = false).

◆ setInterceptionNumber()

void OpenXcom::DogfightState::setInterceptionNumber ( const int  number)

Sets interception number.

Used to draw proper number when window minimized.

Parameters
numberID number.

◆ setInterceptionsCount()

void OpenXcom::DogfightState::setInterceptionsCount ( const size_t  count)

Sets interceptions count.

Used to properly position the window.

Parameters
countAmount of interception windows.

◆ setMinimized()

void OpenXcom::DogfightState::setMinimized ( const bool  minimized)

Sets state minimized or maximized.

Sets the state to minimized/maximized status.

Parameters
minimizedIs the dogfight minimized?

◆ setStatus()

void OpenXcom::DogfightState::setStatus ( const std::string &  status)

Changes the status text.

Updates the status text and restarts the text timeout counter.

Parameters
statusNew status text.

◆ think()

void OpenXcom::DogfightState::think ( )
virtual

Runs the timers.

Runs the higher level dogfight functionality.

Reimplemented from OpenXcom::State.

◆ ufoFireWeapon()

void OpenXcom::DogfightState::ufoFireWeapon ( )

Each time a UFO will try to fire it's cannons a calculation is made.

There's only 10% chance that it will actually fire.

◆ update()

void OpenXcom::DogfightState::update ( )

Moves the craft.

Updates all the elements in the dogfight, including ufo movement, weapons fire, projectile movement, ufo escape conditions, craft and ufo destruction conditions, and retaliation mission generation, as applicable.

◆ weapon1Click()

void OpenXcom::DogfightState::weapon1Click ( Action action)

Toggles usage of weapon 1.

Toggles usage of weapon number 1.

Parameters
actionPointer to an action.

◆ weapon2Click()

void OpenXcom::DogfightState::weapon2Click ( Action action)

Toggles usage of weapon 2.

Toggles usage of weapon number 2.

Parameters
actionPointer to an action.

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