cp_transfer_callbacks.c File Reference

#include "../cl_shared.h"
#include "cp_campaign.h"
#include "cp_transfer_callbacks.h"
#include "cp_transfer.h"
#include "../ui/ui_main.h"
#include "../ui/ui_popup.h"
#include "../ui/ui_data.h"
Include dependency graph for cp_transfer_callbacks.c:

Go to the source code of this file.

Functions

 CASSERT (lengthof(transferTypeIDs)==TRANS_TYPE_MAX)
static int TR_CountStunnedAliensInCargo (const aircraft_t *transferAircraft)
 Counts the stunned aliens in the cargo of the aircraft.
static void TR_TransferBaseListClick_f (void)
 Action to realize when clicking on Transfer Menu.
static void TR_TransferAliensFromMission_f (void)
 Shows available bases to collect aliens after a mission is finished.
static void TR_TransferStart_f (void)
 Starts the transfer.
static transferType_t TR_GetTransferType (const char *id)
 Returns the transfer type.
static int TR_CheckItem (const objDef_t *od, const base_t *destbase, int amount)
 Checks condition for item transfer.
static qboolean TR_CheckEmployee (const employee_t *employee, const base_t *destbase)
 Checks condition for employee transfer.
static qboolean TR_CheckAlien (base_t *destbase)
 Checks condition for live alien transfer.
static qboolean TR_CheckAircraft (const aircraft_t *aircraft, const base_t *destbase)
 Checks condition for aircraft transfer.
static void TR_CargoList (void)
 Display cargo list.
static qboolean TR_AircraftListSelect (int i)
 Check if an aircraft should be displayed for transfer.
static void TR_TransferSelect (base_t *srcbase, base_t *destbase, transferType_t transferType)
 Fills the items-in-base list with stuff available for transfer.
static void TR_TransferSelect_f (void)
 Function displays the transferable item/employee/aircraft/alien list.
static void TR_TransferListClear_f (void)
 Unload everything from transfer cargo back to base.
static int TR_GetTransferFactor (void)
 Set the number of item to transfer.
static qboolean TR_GetTransferEmployee (employeeType_t emplType, int *cnt, const base_t *base, int num)
static void TR_TransferListSelect_f (void)
 Adds a thing to transfercargo by left mouseclick.
static void TR_TransferBaseSelect (base_t *srcbase, base_t *destbase)
 Callback for base list click.
static void TR_InitBaseList (void)
 Fills the optionlist with available bases to transfer to.
static void TR_SelectBase_f (void)
 Callback to select destination base.
static void TR_CargoListSelect_f (void)
 Removes items from cargolist by click.
static void TR_Init_f (void)
 Transfer menu init function.
static void TR_TransferClose_f (void)
 Closes Transfer Menu and resets temp arrays.
static void TR_TransferList_Scroll_f (void)
 Callback for adjusting spinner controls of item transferlist on scrolling.
void TR_InitCallbacks (void)
void TR_ShutdownCallbacks (void)

Variables

static const char * transferTypeIDs []
 transfer typeID strings
static transferData_t td
static const int MAX_TR_FACTORS = 500
 Max values for transfer factors.
static const int MAX_TRANSLIST_MENU_ENTRIES = 21
 number of entries on menu

Detailed Description

Definition in file cp_transfer_callbacks.c.


Function Documentation

CASSERT ( lengthof(transferTypeIDs = =TRANS_TYPE_MAX  ) 
static qboolean TR_AircraftListSelect ( int  i  )  [static]

Check if an aircraft should be displayed for transfer.

Parameters:
[in] i global idx of the aircraft
Returns:
qtrue if the aircraft should be displayed, qfalse else.

Definition at line 520 of file cp_transfer_callbacks.c.

References AIR_AircraftGetFromIDX(), AIR_IsAircraftInBase(), qfalse, qtrue, transferData_s::trAircraftsTmp, and TRANS_LIST_EMPTY_SLOT.

Referenced by TR_TransferListSelect_f(), and TR_TransferSelect().

static void TR_CargoList ( void   )  [static]
static void TR_CargoListSelect_f ( void   )  [static]
static qboolean TR_CheckAircraft ( const aircraft_t aircraft,
const base_t destbase 
) [static]

Checks condition for aircraft transfer.

Parameters:
[in] aircraft Pointer to aircraft which is going to be added to transferlist.
[in] destbase Pointer to destination base.
Returns:
qtrue if transfer of this aircraft is possible.

Definition at line 352 of file cp_transfer_callbacks.c.

References _, AIR_AircraftGetFromIDX(), AIR_CalculateHangarStorage(), B_COMMAND, B_GetBuildingStatus(), B_HANGAR, B_POWER, B_SMALL_HANGAR, ccs, i, ccs_s::numAircraft, qfalse, qtrue, aircraft_s::size, aircraft_s::tpl, transferData_s::trAircraftsTmp, TRANS_LIST_EMPTY_SLOT, and UI_Popup().

Referenced by TR_TransferListSelect_f().

static qboolean TR_CheckAlien ( base_t destbase  )  [static]

Checks condition for live alien transfer.

Parameters:
[in] alienidx Index of an alien type.
[in] destbase Pointer to destination base.
Returns:
qtrue if transfer of this type of alien is possible.

Definition at line 322 of file cp_transfer_callbacks.c.

References _, AL_CheckAliveFreeSpace(), ccs, i, ccs_s::numAliensTD, qfalse, qtrue, transferData_s::trAliensTmp, TRANS_ALIEN_ALIVE, and UI_Popup().

Referenced by TR_TransferListSelect_f().

static qboolean TR_CheckEmployee ( const employee_t employee,
const base_t destbase 
) [static]

Checks condition for employee transfer.

Parameters:
[in] employee Pointer to employee for transfer.
[in] destbase Pointer to destination base.
Returns:
qtrue if transfer of this type of employee is possible.

Definition at line 268 of file cp_transfer_callbacks.c.

References _, AIR_IsEmployeeInAircraft(), CAP_EMPLOYEES, base_s::capacities, ccs, employee_s::chr, CL_GetRankByIdx(), Com_sprintf(), cap_maxcur_s::cur, EMPL_PILOT, EMPL_SOLDIER, i, cap_maxcur_s::max, MAX_EMPL, character_s::name, ccs_s::numEmployees, popupText, qfalse, qtrue, chrScoreGlobal_s::rank, character_s::score, rank_s::shortname, transferData_s::trEmployeesTmp, employee_s::type, and UI_Popup().

Referenced by TR_GetTransferEmployee(), and TR_TransferListSelect_f().

static int TR_CheckItem ( const objDef_t od,
const base_t destbase,
int  amount 
) [static]

Checks condition for item transfer.

Parameters:
[in] od Pointer to object definition.
[in] destbase Pointer to destination base.
[in] amount Number of items to transfer.
Returns:
Number of items that can be transfered.

Definition at line 215 of file cp_transfer_callbacks.c.

References _, ANTIMATTER_TECH_ID, B_ANTIMATTER, B_FreeCapacity(), B_GetBuildingStatus(), B_STORAGE, CAP_ANTIMATTER, CAP_ITEMS, base_s::capacities, csi, cap_maxcur_s::cur, i, objDef_s::id, INVSH_GetItemByIDX(), cap_maxcur_s::max, csi_s::numODs, objDef_s::size, transferData_s::trItemsTmp, and UI_Popup().

Referenced by TR_TransferListSelect_f().

static int TR_CountStunnedAliensInCargo ( const aircraft_t transferAircraft  )  [static]

Counts the stunned aliens in the cargo of the aircraft.

Parameters:
[in] transferAircraft with the stunned aliens.

Definition at line 56 of file cp_transfer_callbacks.c.

References AL_GetAircraftAlienCargo, i, and MAX_CARGO.

Referenced by TR_TransferAliensFromMission_f().

static qboolean TR_GetTransferEmployee ( employeeType_t  emplType,
int *  cnt,
const base_t base,
int  num 
) [static]

Todo:
we have to decide what to do if the check fails - there are hard failures, and soft ones - soft ones should continue to add the next employee type

Definition at line 816 of file cp_transfer_callbacks.c.

References E_GetNextFromBase(), employee_s::idx, qfalse, qtrue, TR_CheckEmployee(), transferData_s::transferBase, transferData_s::trEmployeesTmp, and employee_s::type.

Referenced by TR_TransferListSelect_f().

static int TR_GetTransferFactor ( void   )  [static]

Set the number of item to transfer.

Definition at line 811 of file cp_transfer_callbacks.c.

Referenced by TR_CargoListSelect_f(), and TR_TransferListSelect_f().

static transferType_t TR_GetTransferType ( const char *  id  )  [static]

Returns the transfer type.

Parameters:
[in] id Transfer type Id
See also:
transferType_t

Definition at line 198 of file cp_transfer_callbacks.c.

References i, TRANS_TYPE_INVALID, TRANS_TYPE_MAX, and transferTypeIDs.

Referenced by TR_TransferList_Scroll_f(), and TR_TransferSelect_f().

static void TR_Init_f ( void   )  [static]
static void TR_InitBaseList ( void   )  [static]

Fills the optionlist with available bases to transfer to.

Definition at line 1099 of file cp_transfer_callbacks.c.

References B_GetCurrentSelectedBase(), B_GetFoundedBaseByIDX(), ccs, base_s::name, ccs_s::numBases, OPTION_BASELIST, UI_AddOption(), UI_RegisterOption(), and va().

Referenced by TR_Init_f().

void TR_InitCallbacks ( void   ) 
static void TR_SelectBase_f ( void   )  [static]

Callback to select destination base.

Definition at line 1121 of file cp_transfer_callbacks.c.

References B_GetCurrentSelectedBase(), B_GetFoundedBaseByIDX(), Cmd_Argc(), Cmd_Argv(), Com_Printf(), and TR_TransferBaseSelect().

Referenced by TR_InitCallbacks().

void TR_ShutdownCallbacks ( void   ) 

Definition at line 1455 of file cp_transfer_callbacks.c.

References Cmd_RemoveCommand().

Referenced by CP_RemoveCampaignCallbackCommands().

static void TR_TransferAliensFromMission_f ( void   )  [static]

Shows available bases to collect aliens after a mission is finished.

See also:
TR_TransferBaseListClick_f

Todo:
tooltip assigining wrong here, also ui doesn't yet support tooltip on options
Todo:
send a message (?)

Definition at line 100 of file cp_transfer_callbacks.c.

References AC_ContainmentAllowed(), AIR_AircraftGetFromIDX(), B_FreeCapacity(), B_GetFoundedBaseByIDX(), CAP_ALIENS, ccs, Cmd_Argc(), Cmd_Argv(), uiNode_s::color, Com_Printf(), green, i, base_s::idx, base_s::name, ngettext, ccs_s::numBases, OPTION_BASELIST, red, string, TR_CountStunnedAliensInCargo(), transferData_s::transferStartAircraft, UI_AddOption(), UI_PushWindow(), UI_RegisterOption(), va(), Vector4Copy, and yellow.

Referenced by TR_InitCallbacks().

static void TR_TransferBaseListClick_f ( void   )  [static]

Action to realize when clicking on Transfer Menu.

Note:
This menu is used when a dropship ending a mission collected alien bodies, but there's no alien cont. in home base
See also:
TR_TransferAliensFromMission_f

Definition at line 74 of file cp_transfer_callbacks.c.

References B_GetFoundedBaseByIDX(), Cmd_Argc(), Cmd_Argv(), Com_Printf(), TR_TransferAlienAfterMissionStart(), and transferData_s::transferStartAircraft.

Referenced by TR_InitCallbacks().

static void TR_TransferBaseSelect ( base_t srcbase,
base_t destbase 
) [static]

Callback for base list click.

Note:
transferBase is being set here.
Parameters:
[in] srcbase 
[in] destbase Pointer to base which will be transferBase.

Definition at line 1037 of file cp_transfer_callbacks.c.

References _, B_ALIEN_CONTAINMENT, B_ANTIMATTER, B_COMMAND, B_GetBuildingStatus(), B_HANGAR, B_POWER, B_QUARTERS, B_SMALL_HANGAR, B_STORAGE, transferData_s::currentTransferType, Cvar_Set(), Cvar_SetValue(), base_s::idx, base_s::name, Q_strcat(), qfalse, TEXT_BASE_INFO, TR_TransferSelect(), transferData_s::transferBase, and UI_RegisterText().

Referenced by TR_Init_f(), and TR_SelectBase_f().

static void TR_TransferClose_f ( void   )  [static]
static void TR_TransferList_Scroll_f ( void   )  [static]
static void TR_TransferListClear_f ( void   )  [static]
static void TR_TransferListSelect_f ( void   )  [static]
static void TR_TransferSelect ( base_t srcbase,
base_t destbase,
transferType_t  transferType 
) [static]

Fills the items-in-base list with stuff available for transfer.

Note:
Filling the transfer list with proper stuff (items/employees/aliens/aircraft) is being done here.
Parameters:
[in] srcbase Pointer to the base the transfer starts from
[in] destbase Pointer to the base to transfer
[in] transferType Transfer category
See also:
transferType_t

Definition at line 542 of file cp_transfer_callbacks.c.

References _, AIR_AircraftGetFromIDX(), AL_AlienTypeToName(), AL_GetAlienGlobalIDX(), base_s::alienscont, aliensCont_s::amountAlive, aliensCont_s::amountDead, ANTIMATTER_TECH_ID, B_ALIEN_CONTAINMENT, B_ANTIMATTER, B_AntimatterInBase(), B_GetBuildingStatus(), B_HANGAR, B_ItemInBase(), B_ItemIsStoredInBaseStorage(), B_POWER, B_QUARTERS, B_SMALL_HANGAR, B_STORAGE, ccs, employee_s::chr, CL_GetRankByIdx(), Com_Printf(), Com_sprintf(), csi, transferData_s::currentTransferType, E_GetEmployeeString(), E_GetNextFromBase(), EMPL_PILOT, EMPL_SOLDIER, aircraft_s::homebase, i, employee_s::idx, objDef_s::idx, INVSH_GetItemByID(), INVSH_GetItemByIDX(), objDef_s::isVirtual, LIST_AddString(), MAX_AIRCRAFT, MAX_EMPL, MAX_EMPLOYEES, aircraft_s::name, character_s::name, objDef_s::name, ccs_s::numAliensTD, equipDef_s::numItems, csi_s::numODs, chrScoreGlobal_s::rank, character_s::score, rank_s::shortname, base_s::storage, aliensCont_s::teamDef, TEXT_TRANSFER_LIST, TEXT_TRANSFER_LIST_AMOUNT, TEXT_TRANSFER_LIST_TRANSFERED, TR_AircraftListSelect(), TR_CargoList(), transferData_s::trAliensTmp, TRANS_ALIEN_ALIVE, TRANS_ALIEN_DEAD, TRANS_TYPE_AIRCRAFT, TRANS_TYPE_ALIEN, TRANS_TYPE_EMPLOYEE, TRANS_TYPE_ITEM, transferData_s::trEmployeesTmp, transferData_s::trItemsTmp, UI_ExecuteConfunc(), UI_RegisterLinkedListText(), UI_ResetData(), and va().

Referenced by TR_CargoListSelect_f(), TR_TransferBaseSelect(), TR_TransferListClear_f(), TR_TransferListSelect_f(), and TR_TransferSelect_f().

static void TR_TransferSelect_f ( void   )  [static]

Function displays the transferable item/employee/aircraft/alien list.

See also:
TR_TransferStart_f
TR_TransferInit_f

Definition at line 750 of file cp_transfer_callbacks.c.

References B_GetCurrentSelectedBase(), Cmd_Argc(), Cmd_Argv(), transferData_s::currentTransferType, TR_GetTransferType(), TR_TransferSelect(), TRANS_TYPE_MAX, transferData_s::transferBase, and type.

Referenced by TR_InitCallbacks().

static void TR_TransferStart_f ( void   )  [static]

Variable Documentation

const int MAX_TR_FACTORS = 500 [static]

Max values for transfer factors.

Definition at line 48 of file cp_transfer_callbacks.c.

const int MAX_TRANSLIST_MENU_ENTRIES = 21 [static]

number of entries on menu

Definition at line 50 of file cp_transfer_callbacks.c.

transferData_t td [static]
const char* transferTypeIDs[] [static]
Initial value:
 {
    "item",
    "employee",
    "alien",
    "aircraft"
}

transfer typeID strings

Definition at line 36 of file cp_transfer_callbacks.c.

Referenced by TR_GetTransferType(), and TR_Init_f().


Generated by  doxygen 1.6.2