UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_base_callbacks.cpp File Reference

Menu related console command callbacks. More...

#include "../../cl_shared.h"
#include "cp_campaign.h"
#include "cp_base_callbacks.h"
#include "cp_base.h"
#include "cp_capacity.h"
#include "cp_geoscape.h"
#include "cp_popup.h"
#include "cp_time.h"
#include "cp_ufo.h"
#include "../../ui/ui_dataids.h"
#include "aliencontainment.h"

Go to the source code of this file.

Macros

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

Functions

static void B_Destroy_AntimaterStorage_f (void)
 onDestroy Callback for Antimatter Storage More...
 
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. More...
 
static void B_SetBaseTitle_f (void)
 Sets the title of the base to a cvar to prepare the rename menu. More...
 
static void B_BuildBase_f (void)
 Constructs a new base. More...
 
static void B_ChangeBaseName_f (void)
 Creates console command to change the name of a base. More...
 
static void B_BaseInit_f (void)
 Initialises base. More...
 
static void B_BuildingDestroy_f (void)
 Destroy a base building. More...
 
static void B_AssembleMap_f (void)
 Builds a base map for tactical combat. More...
 
static void B_MakeBaseMapShot_f (void)
 Makes a mapshot - called by basemapshot script command. More...
 
static void B_FillBuildingInfo_f (void)
 Script function for clicking the building list text field. More...
 
static void B_ListBuildings_f (void)
 Update the facilities list. More...
 
static void B_FillMap_f (void)
 Lists building tiles for the Basescape UI. More...
 
static void B_BuildingOpenAfterClick_f (void)
 Opens menu on clicking a building in Baseview. More...
 
static void B_BuildBuilding_f (void)
 Build a base building. More...
 
void B_InitCallbacks (void)
 
void B_ShutdownCallbacks (void)
 

Variables

static cvar_tmn_base_title
 
static const cmdList_t baseCallbacks []
 

Detailed Description

Menu related console command callbacks.

Definition in file cp_base_callbacks.cpp.

Macro Definition Documentation

#define CREATE_NEW_BASE_ID   -1

Used from menu scripts as parameter for mn_base_select.

Definition at line 38 of file cp_base_callbacks.cpp.

Referenced by B_SelectBase_f().

Function Documentation

static void B_AssembleMap_f ( void  )
static

Builds a base map for tactical combat.

See also
CP_BaseAttackChooseBase

Definition at line 380 of file cp_base_callbacks.cpp.

References B_AssembleMap(), B_GetFoundedBaseByIDX(), cgi, cgame_import_s::Cmd_Argv(), GEO_IsNight(), and base_s::pos.

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 209 of file cp_base_callbacks.cpp.

References _, AC_ContainmentAllowed(), AIR_AircraftAllowed(), AIR_BaseHasAircraft(), B_GetCount(), B_GetCurrentSelectedBase(), B_GetFoundedBaseByIDX(), BS_BuySellAllowed(), ccs, cgi, cgame_import_s::Cmd_Argv(), CP_UpdateCredits(), ccs_s::credits, E_HireAllowed(), HOS_HospitalAllowed(), PR_ProductionAllowed(), and RS_ResearchAllowed().

static void B_ChangeBaseName_f ( void  )
static

Creates console command to change the name of a base.

Definition at line 181 of file cp_base_callbacks.cpp.

References B_GetFoundedBaseByIDX(), B_SetName(), cgi, cgame_import_s::Cmd_Argv(), Com_IsValidName(), cgame_import_s::Cvar_Set(), and base_s::name.

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 45 of file cp_base_callbacks.cpp.

References _, B_Destroy(), B_GetFoundedBaseByIDX(), BASE_WORKING, base_s::baseStatus, CAP_ANTIMATTER, CAP_GetCurrent, CAP_RemoveAntimatterExceedingCapacity(), cgi, cgame_import_s::Cmd_Argv(), frand(), MS_AddNewMessage(), base_s::name, and va().

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 404 of file cp_base_callbacks.cpp.

References cgi.

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 77 of file cp_base_callbacks.cpp.

References B_GetFoundedBaseByIDX(), B_SelectBase(), cgi, cgame_import_s::Cmd_Argv(), CREATE_NEW_BASE_ID, and MAX_BASES.

static void B_SetBaseTitle_f ( void  )
static

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

Definition at line 103 of file cp_base_callbacks.cpp.

References _, B_GetCount(), ccs_s::bases, ccs, cgi, Com_sprintf(), cgame_import_s::Cvar_Set(), i, lengthof, MAX_BASES, MAX_VAR, MS_AddNewMessage(), base_s::name, Q_streq, and Q_strncpyz().

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

Definition at line 706 of file cp_base_callbacks.cpp.

References cgi.

Referenced by CP_RemoveCampaignCallbackCommands().

Variable Documentation

const cmdList_t baseCallbacks[]
static
Initial value:
= {
{"basemapshot", B_MakeBaseMapShot_f, "Command to make a screenshot for the baseview with the correct angles"},
{"mn_base_select", B_SelectBase_f, "Select a founded base by index"},
{"mn_base_build", B_BuildBase_f, nullptr},
{"mn_set_base_title", B_SetBaseTitle_f, nullptr},
{"base_changename", B_ChangeBaseName_f, "Called after editing the cvar base name"},
{"base_init", B_BaseInit_f, nullptr},
{"base_assemble", B_AssembleMap_f, "Called to assemble the current selected base"},
{"building_destroy", B_BuildingDestroy_f, "Function to destroy a building (select via right click in baseview first)"},
{"building_amdestroy", B_Destroy_AntimaterStorage_f, "Function called if antimatter storage destroyed"},
{"base_selectbuilding", B_BuildingOpenAfterClick_f, nullptr},
{"ui_list_buildings", B_ListBuildings_f, "Lists buildings built or can be built on a base and their capacities"},
{"ui_show_buildinginfo", B_FillBuildingInfo_f, "Opens the building information window in construction mode"},
{"ui_base_fillmap", B_FillMap_f, nullptr},
{"ui_build_building", B_BuildBuilding_f, nullptr},
{nullptr, nullptr, nullptr}
}
static void B_AssembleMap_f(void)
Builds a base map for tactical combat.
static void B_BaseInit_f(void)
Initialises base.
static void B_Destroy_AntimaterStorage_f(void)
onDestroy Callback for Antimatter Storage
static void B_BuildBuilding_f(void)
Build a base building.
static void B_ListBuildings_f(void)
Update the facilities list.
static void B_BuildingOpenAfterClick_f(void)
Opens menu on clicking a building in Baseview.
static void B_BuildBase_f(void)
Constructs a new base.
static void B_BuildingDestroy_f(void)
Destroy a base building.
static void B_MakeBaseMapShot_f(void)
Makes a mapshot - called by basemapshot script command.
static void B_FillBuildingInfo_f(void)
Script function for clicking the building list text field.
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_SetBaseTitle_f(void)
Sets the title of the base to a cvar to prepare the rename menu.
static void B_ChangeBaseName_f(void)
Creates console command to change the name of a base.
static void B_FillMap_f(void)
Lists building tiles for the Basescape UI.

Init/Shutdown functions

Definition at line 676 of file cp_base_callbacks.cpp.

cvar_t* mn_base_title
static

Definition at line 40 of file cp_base_callbacks.cpp.