cp_base_callbacks.c File Reference

Menu related console command callbacks. More...

#include "../cl_shared.h"
#include "../ui/ui_main.h"
#include "../ui/ui_popup.h"
#include "cp_campaign.h"
#include "cp_base_callbacks.h"
#include "cp_base.h"
#include "cp_map.h"
#include "cp_popup.h"
#include "cp_ufo.h"
Include dependency graph for cp_base_callbacks.c:

Go to the source code of this file.

Defines

#define CREATE_NEW_BASE_ID   -1
 Used from menu scripts as parameter for mn_base_select.

Functions

static void B_Destroy_AntimaterStorage_f (void)
 onDestroy Callback for Antimatter Storage
static void B_BuildingAddToList (linkedList_t **buildingList, building_t *building)
 Handles the list of constructable buildings.
static void B_SelectBase_f (void)
 Called when a base is opened or a new base is created on geoscape. For a new base the baseID is -1.
static void B_NextBase_f (void)
 Cycles to the next base.
static void B_PrevBase_f (void)
 Cycles to the previous base.
static void B_SetBaseTitle_f (void)
 Sets the title of the base to a cvar to prepare the rename menu.
static void B_BuildBase_f (void)
 Constructs a new base.
static void B_ChangeBaseName_f (void)
 Creates console command to change the name of a base. Copies the value of the cvar mn_base_title over as the name of the current selected base.
static void B_ResetBuildingCurrent_f (void)
 Resets the currently selected building.
static void B_BaseInit_f (void)
 Initialises base.
static void B_BuildingOnDestroy_f (void)
 On destroy function for several building type.
static void B_BuildingInit (base_t *base)
 Update the building-list.
static void B_BuildingInit_f (void)
 Script command binding for B_BuildingInit.
static void B_BuildingInfoClick_f (void)
 Opens the UFOpedia for the current selected building.
static void B_BuildingClick_f (void)
 Script function for clicking the building list text field.
static void B_BuildingDestroy_f (void)
 We are doing the real destroy of a building here.
static void B_BuildingStatus_f (void)
 Console callback for B_BuildingStatus.
static void B_AssembleMap_f (void)
 Builds a base map for tactical combat.
static void B_CheckBuildingStatusForMenu_f (void)
 Checks why a button in base menu is disabled, and create a popup to inform player.
static void BaseSummary_Init (const base_t *base)
 Base Summary menu init function.
static void BaseSummary_SelectBase_f (void)
 Open menu for basesummary.
static void B_MakeBaseMapShot_f (void)
 Makes a mapshot - called by basemapshot script command.
void B_InitCallbacks (void)
void B_ShutdownCallbacks (void)

Variables

static cvar_tmn_base_title
static cvar_tcl_start_buildings
static building_tbuildingConstructionList [MAX_BUILDINGS]
static int buildingNumber = 0

Detailed Description

Menu related console command callbacks.

Definition in file cp_base_callbacks.c.


Define Documentation

#define CREATE_NEW_BASE_ID   -1

Used from menu scripts as parameter for mn_base_select.

Definition at line 37 of file cp_base_callbacks.c.

Referenced by B_SelectBase_f().


Function Documentation

static void B_AssembleMap_f ( void   )  [static]

Builds a base map for tactical combat.

See also:
SV_AssembleMap
CP_BaseAttackChooseBase

Definition at line 531 of file cp_base_callbacks.c.

References B_AssembleMap(), B_GetBaseByIDX(), B_GetCurrentSelectedBase(), Cmd_Argc(), Cmd_Argv(), Com_DPrintf(), and DEBUG_CLIENT.

Referenced by B_InitCallbacks().

static void B_BaseInit_f ( void   )  [static]

Initialises base.

Note:
This command is executed in the init node of the base menu. It is called everytime the base menu pops up and sets the cvars.
Todo:
integrate building status tooltips from B_CheckBuildingStatusForMenu_f into this one

Definition at line 273 of file cp_base_callbacks.c.

References _, AC_ContainmentAllowed(), AIR_AircraftAllowed(), AIR_BaseHasAircraft(), base_s::aircraft, B_GetCurrentSelectedBase(), BS_BuySellAllowed(), ccs, CL_UpdateCredits(), ccs_s::credits, Cvar_SetValue(), E_HireAllowed(), HOS_HospitalAllowed(), LIST_Count(), ccs_s::numBases, PR_ProductionAllowed(), RS_ResearchAllowed(), UI_ExecuteConfunc(), and va().

Referenced by B_InitCallbacks().

static void B_BuildBase_f ( void   )  [static]
static void B_BuildingAddToList ( linkedList_t **  buildingList,
building_t building 
) [static]

Handles the list of constructable buildings.

Parameters:
[in] buildingList list of buildings to upate
[in] building Add this building to the construction list
Note:
Called everytime a building was constructed and thus maybe other buildings get available. The content is updated everytime B_BuildingInit is called (i.e everytime the buildings-list is displayed/updated)

Definition at line 83 of file cp_base_callbacks.c.

References _, count, LIST_AddPointer(), LIST_Count(), building_s::name, and building_s::tpl.

Referenced by B_BuildingInit().

static void B_BuildingClick_f ( void   )  [static]

Script function for clicking the building list text field.

Definition at line 463 of file cp_base_callbacks.c.

References B_DrawBuilding(), B_GetCurrentSelectedBase(), BA_NEWBUILDING, ccs_s::baseAction, base_s::buildingCurrent, buildingNumber, ccs, Cmd_Argc(), Cmd_Argv(), Com_DPrintf(), Com_Printf(), and DEBUG_CLIENT.

Referenced by B_InitCallbacks().

static void B_BuildingDestroy_f ( void   )  [static]

We are doing the real destroy of a building here.

See also:
B_BuildingDestroy
B_NewBuilding

Definition at line 498 of file cp_base_callbacks.c.

References B_BuildingDestroy(), B_BuildingInit(), B_GetCurrentSelectedBase(), B_ResetBuildingCurrent(), and base_s::buildingCurrent.

Referenced by B_InitCallbacks().

static void B_BuildingInfoClick_f ( void   )  [static]

Opens the UFOpedia for the current selected building.

Definition at line 449 of file cp_base_callbacks.c.

References B_GetCurrentSelectedBase(), base_s::buildingCurrent, building_s::pedia, and UP_OpenWith().

Referenced by B_InitCallbacks().

static void B_BuildingInit ( base_t base  )  [static]
static void B_BuildingInit_f ( void   )  [static]

Script command binding for B_BuildingInit.

Definition at line 436 of file cp_base_callbacks.c.

References B_BuildingInit(), and B_GetCurrentSelectedBase().

Referenced by B_InitCallbacks().

static void B_BuildingOnDestroy_f ( void   )  [static]

On destroy function for several building type.

Note:
this function is only used for sanity checks, and send to related function depending on building type.
Precondition:
Functions below will be called AFTER the building is actually destroyed.
See also:
B_BuildingDestroy_f
Todo:
Why does this exist? why is this not part of B_BuildingDestroy?

Definition at line 338 of file cp_base_callbacks.c.

References AL_RemoveAliens(), AL_RESEARCH, B_ALIEN_CONTAINMENT, B_GetFoundedBaseByIDX(), B_HANGAR, B_LAB, B_QUARTERS, B_RemoveAircraftExceedingCapacity(), B_RemoveItemsExceedingCapacity(), B_SMALL_HANGAR, B_STORAGE, B_WORKSHOP, CAP_ALIENS, base_s::capacities, Cmd_Argc(), Cmd_Argv(), Com_Printf(), cap_maxcur_s::cur, E_DeleteEmployeesExceedingCapacity(), cap_maxcur_s::max, MAX_BASES, MAX_BUILDING_TYPE, PR_UpdateProductionCap(), and RS_RemoveScientistsExceedingCapacity().

Referenced by B_InitCallbacks().

static void B_BuildingStatus_f ( void   )  [static]

Console callback for B_BuildingStatus.

See also:
B_BuildingStatus

Definition at line 515 of file cp_base_callbacks.c.

References B_BuildingStatus(), B_GetCurrentSelectedBase(), and base_s::buildingCurrent.

Referenced by B_InitCallbacks().

static void B_ChangeBaseName_f ( void   )  [static]

Creates console command to change the name of a base. Copies the value of the cvar mn_base_title over as the name of the current selected base.

Definition at line 244 of file cp_base_callbacks.c.

References B_GetCurrentSelectedBase(), Cvar_GetString(), base_s::name, and Q_strncpyz().

Referenced by B_InitCallbacks().

static void B_CheckBuildingStatusForMenu_f ( void   )  [static]
static void B_Destroy_AntimaterStorage_f ( void   )  [static]

onDestroy Callback for Antimatter Storage

note: third parameter not used but we must be sure we have probability parameter

Definition at line 47 of file cp_base_callbacks.c.

References _, B_Destroy(), B_GetFoundedBaseByIDX(), B_RemoveAntimatterExceedingCapacity(), BASE_WORKING, base_s::baseStatus, CAP_ANTIMATTER, base_s::capacities, Cmd_Argc(), Cmd_Argv(), Com_Printf(), cap_maxcur_s::cur, frand(), MS_AddNewMessage(), MSG_STANDARD, base_s::name, qfalse, UI_PopWindow(), and va().

Referenced by B_InitCallbacks().

void B_InitCallbacks ( void   ) 
static void B_MakeBaseMapShot_f ( void   )  [static]

Makes a mapshot - called by basemapshot script command.

Note:
Load a basemap and execute 'basemapshot' in console

Definition at line 806 of file cp_base_callbacks.c.

References Cmd_ExecuteString(), Com_Printf(), Com_ServerState(), Cvar_SetValue(), UI_PushWindow(), and va().

Referenced by B_InitCallbacks().

static void B_NextBase_f ( void   )  [static]

Cycles to the next base.

See also:
B_PrevBase
B_SelectBase_f

Definition at line 126 of file cp_base_callbacks.c.

References B_GetCurrentSelectedBase(), B_GetFoundedBaseByIDX(), B_SelectBase(), ccs, base_s::idx, and ccs_s::numBases.

Referenced by B_InitCallbacks().

static void B_PrevBase_f ( void   )  [static]

Cycles to the previous base.

See also:
B_NextBase
B_SelectBase_f

Definition at line 145 of file cp_base_callbacks.c.

References B_GetCurrentSelectedBase(), B_GetFoundedBaseByIDX(), B_SelectBase(), ccs, base_s::idx, and ccs_s::numBases.

Referenced by B_InitCallbacks().

static void B_ResetBuildingCurrent_f ( void   )  [static]

Resets the currently selected building.

Is called e.g. when leaving the build-menu

Definition at line 260 of file cp_base_callbacks.c.

References B_GetCurrentSelectedBase(), and B_ResetBuildingCurrent().

Referenced by B_InitCallbacks().

static void B_SelectBase_f ( void   )  [static]

Called when a base is opened or a new base is created on geoscape. For a new base the baseID is -1.

Definition at line 98 of file cp_base_callbacks.c.

References B_GetFoundedBaseByIDX(), B_SelectBase(), Cmd_Argc(), Cmd_Argv(), Com_Printf(), CREATE_NEW_BASE_ID, and MAX_BASES.

Referenced by B_InitCallbacks().

static void B_SetBaseTitle_f ( void   )  [static]

Sets the title of the base to a cvar to prepare the rename menu.

Definition at line 167 of file cp_base_callbacks.c.

References _, ccs_s::bases, ccs, Com_sprintf(), Cvar_Set(), i, lengthof, MAX_BASES, MAX_VAR, MS_AddNewMessage(), MSG_STANDARD, base_s::name, ccs_s::numBases, Q_strncpyz(), qfalse, and UI_PopWindow().

Referenced by B_InitCallbacks().

void B_ShutdownCallbacks ( void   ) 
Todo:
unify the names into mn_base_*

Definition at line 856 of file cp_base_callbacks.c.

References Cmd_RemoveCommand(), and Cvar_Delete().

Referenced by CP_RemoveCampaignCallbackCommands().

static void BaseSummary_Init ( const base_t base  )  [static]

Base Summary menu init function.

BaseSummary Callbacks:

Note:
Should be called whenever the Base Summary menu gets active.

Todo:
use the same method as we do in PR_ProductionInfo

Definition at line 655 of file cp_base_callbacks.c.

References _, AIR_CountTypeInBase(), AIR_GetAircraftString(), production_s::aircraft, base_s::alienscont, production_s::amount, aliensCont_s::amountAlive, aliensCont_s::amountDead, B_GetBuildingStatus(), B_GetCapacityFromBuildingType(), B_GetNumberOfBuildingsInBaseByBuildingType(), B_STATUS_UNDER_CONSTRUCTION, technology_s::base, building_s::buildingStatus, ccs_s::buildingTemplates, building_s::buildingType, building_s::buildTime, base_s::capacities, ccs, Com_Error(), cap_maxcur_s::cur, ccs_s::date, date_s::day, E_CountHired(), E_GetEmployeeString(), ERR_DROP, i, base_s::idx, production_s::item, production_queue_s::items, cap_maxcur_s::max, MAX_CAP, MAX_EMPL, MAX_HUMAN_AIRCRAFT_TYPE, technology_s::name, aircraft_s::name, objDef_s::name, name, building_s::name, ngettext, ccs_s::numAliensTD, ccs_s::numBuildingTemplates, production_queue_s::numItems, ccs_s::numTechnologies, technology_s::overallTime, production_s::percentDone, ccs_s::productions, Q_strcat(), RS_GetTechByIDX(), RS_IsResearched_ptr(), RS_PAUSED, RS_RUNNING, technology_s::scientists, technology_s::statusResearch, building_s::tech, TEXT_STANDARD, TEXT_STATS_BASESUMMARY, technology_s::time, building_s::timeStart, aircraft_s::tpl, production_s::ufo, UFO_TypeToName(), storedUFO_s::ufoTemplate, aircraft_s::ufotype, UI_RegisterText(), and va().

Referenced by BaseSummary_SelectBase_f().

static void BaseSummary_SelectBase_f ( void   )  [static]

Variable Documentation

building_t* buildingConstructionList[MAX_BUILDINGS] [static]

Definition at line 41 of file cp_base_callbacks.c.

int buildingNumber = 0 [static]

Definition at line 42 of file cp_base_callbacks.c.

Referenced by B_BuildingClick_f(), and B_BuildingInit().

Definition at line 40 of file cp_base_callbacks.c.

cvar_t* mn_base_title [static]

Definition at line 39 of file cp_base_callbacks.c.


Generated by  doxygen 1.6.2