UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cl_hud_callbacks.cpp File Reference
#include "../client.h"
#include "cl_hud_callbacks.h"
#include "cl_hud.h"
#include "cl_actor.h"

Go to the source code of this file.

Functions

ItemHUD_GetLeftHandWeapon (const le_t *actor, containerIndex_t *container)
 returns the weapon the actor's left hand is touching. In case the actor holds a two handed weapon in his right hand, this weapon is returned here. This function only returns nullptr if no two handed weapon is in the right hand and the left hand is empty. More...
 
const fireDef_tHUD_GetFireDefinitionForHand (const le_t *actor, const actorHands_t hand)
 Returns the fire definition of the item the actor has in the given hand. More...
 
static bool HUD_CheckShooting (const le_t *le, Item *weapon)
 Check if shooting is possible. i.e. The weapon has ammo and can be fired with the 'available' hands. TUs (i.e. "time") are are not checked here, this needs to be done elsewhere for the correct firemode. More...
 
static void HUD_FireWeapon_f (void)
 Starts aiming/target mode for selected left/right firemode. More...
 
static void HUD_SetMoveMode_f (void)
 
static void HUD_ToggleCrouchReservation_f (void)
 Toggles if the current actor reserves TUs for crouching. More...
 
static void HUD_ToggleReaction_f (void)
 Toggles reaction fire states for the current selected actor. More...
 
int HUD_CalcReloadTime (const le_t *le, const objDef_t *weapon, containerIndex_t toContainer)
 Calculate total reload time for selected actor. More...
 
static bool HUD_CheckReload (const le_t *le, const Item *weapon, containerIndex_t container)
 Check if reload is possible. More...
 
static void HUD_ReloadLeft_f (void)
 Reload left weapon. More...
 
static void HUD_ReloadRight_f (void)
 Reload right weapon. More...
 
static void HUD_ExecuteAction_f (void)
 
void HUD_InitCallbacks (void)
 

Function Documentation

int HUD_CalcReloadTime ( const le_t le,
const objDef_t weapon,
containerIndex_t  toContainer 
)

Calculate total reload time for selected actor.

Parameters
[in]lePointer to local entity handling the weapon.
[in]weaponItem in (currently only right) hand.
[in]toContainerThe container index to get the ammo from (used to calculate the TUs that are needed to move the item out of this container)
Returns
Time needed to reload or -1 if no suitable ammo found.
Note
This routine assumes the time to reload a weapon
in the right hand is the same as the left hand.
See also
HUD_UpdateButtons
HUD_CheckReload

Definition at line 217 of file cl_hud_callbacks.cpp.

References CL_ActorGetContainerForReload(), objDef_s::getReloadTime(), le_s::inv, INVDEF, and NONE.

Referenced by HUD_CheckReload(), HUD_DisplayActions(), HUD_UpdateActor(), and HUD_WeaponCanBeReloaded().

static bool HUD_CheckReload ( const le_t le,
const Item weapon,
containerIndex_t  container 
)
static

Check if reload is possible.

Parameters
[in]lePointer to local entity for which we handle an action on hud menu.
[in]weaponAn item in hands.
[in]containerThe container to get the ammo from
Returns
false when action is not possible, otherwise true
See also
HUD_ReloadLeft_f
HUD_ReloadRight_f

Definition at line 244 of file cl_hud_callbacks.cpp.

References _, Item::def(), HUD_CalcReloadTime(), HUD_DisplayMessage(), Item::isReloadable(), and le_s::TU.

Referenced by HUD_ReloadLeft_f(), and HUD_ReloadRight_f().

static bool HUD_CheckShooting ( const le_t le,
Item weapon 
)
static

Check if shooting is possible. i.e. The weapon has ammo and can be fired with the 'available' hands. TUs (i.e. "time") are are not checked here, this needs to be done elsewhere for the correct firemode.

See also
HUD_FireWeapon_f
Returns
false when action is not possible, otherwise true

Definition at line 77 of file cl_hud_callbacks.cpp.

References _, Item::def(), objDef_s::fireTwoHanded, le_s::getLeftHandItem(), HUD_DisplayMessage(), and Item::mustReload().

Referenced by HUD_FireWeapon_f().

static void HUD_ExecuteAction_f ( void  )
static

Ask the current selected soldier to execute an action

Todo:
extend it to open doors or things like that

Definition at line 310 of file cl_hud_callbacks.cpp.

References Cmd_Argc(), Cmd_Argv(), Cmd_ExecuteString(), Com_Printf(), HUD_ReloadLeft_f(), HUD_ReloadRight_f(), index, Q_streq, Q_strstart(), and selActor.

Referenced by HUD_InitCallbacks().

static void HUD_FireWeapon_f ( void  )
static

Starts aiming/target mode for selected left/right firemode.

Note
Previously know as a combination of CL_FireRightPrimary, CL_FireRightSecondary,
CL_FireLeftPrimary and CL_FireLeftSecondary.

Definition at line 106 of file cl_hud_callbacks.cpp.

References _, ACTOR_GET_HAND_INDEX, ACTOR_HAND_RIGHT, CL_ActorSetMode(), CL_ActorTimeForFireDef(), CL_ActorUsableTUs(), Cmd_Argc(), Cmd_Argv(), Com_Printf(), le_s::currentSelectedFiremode, objDef_s::fd, le_s::getHandItem(), HUD_CheckShooting(), HUD_DisplayMessage(), HUD_GetFireDefinitionForHand(), M_FIRE_L, M_FIRE_R, MAX_FIREDEFS_PER_WEAPON, fireDef_s::obj, selActor, and fireDef_s::weapFdsIdx.

Referenced by HUD_InitCallbacks().

const fireDef_t* HUD_GetFireDefinitionForHand ( const le_t actor,
const actorHands_t  hand 
)

Returns the fire definition of the item the actor has in the given hand.

Parameters
[in]actorThe pointer to the actor we want to get the data from.
[in]handWhich hand to use
Returns
the used fireDef_t

Definition at line 57 of file cl_hud_callbacks.cpp.

References Item::def(), Item::getFiredefs(), and le_s::getHandItem().

Referenced by HUD_CheckFiremodeReservation(), HUD_DisplayActions(), HUD_FireWeapon_f(), HUD_PopupFiremodeReservation(), and HUD_UpdateReactionFiremodes().

Item* HUD_GetLeftHandWeapon ( const le_t actor,
containerIndex_t container 
)

returns the weapon the actor's left hand is touching. In case the actor holds a two handed weapon in his right hand, this weapon is returned here. This function only returns nullptr if no two handed weapon is in the right hand and the left hand is empty.

Todo:
remove me

Definition at line 36 of file cl_hud_callbacks.cpp.

References CID_RIGHT, le_s::getLeftHandItem(), le_s::getRightHandItem(), and Item::isHeldTwoHanded().

Referenced by HUD_ReloadLeft_f(), HUD_UpdateActor(), HUD_UpdateActorCvar(), and HUD_UpdateActorFireMode().

static void HUD_ReloadLeft_f ( void  )
static
static void HUD_ReloadRight_f ( void  )
static
static void HUD_SetMoveMode_f ( void  )
static

Definition at line 147 of file cl_hud_callbacks.cpp.

References CL_ActorSetMode(), M_MOVE, and selActor.

Referenced by HUD_InitCallbacks().

static void HUD_ToggleCrouchReservation_f ( void  )
static

Toggles if the current actor reserves TUs for crouching.

Definition at line 160 of file cl_hud_callbacks.cpp.

References _, CL_ActorCheckAction(), CL_ActorReservedTUs(), CL_ActorReserveTUs(), HUD_DisplayMessage(), RES_CROUCH, selActor, TU_CROUCH, and va().

Referenced by HUD_InitCallbacks().

static void HUD_ToggleReaction_f ( void  )
static