UFO: Alien Invasion
Loading...
Searching...
No Matches
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"
Include dependency graph for cp_base_callbacks.cpp:

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.

Functions

static void B_Destroy_AntimaterStorage_f (void)
 onDestroy Callback for Antimatter Storage
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_BuildBase_f (void)
 Constructs a new base.
static void B_ChangeBaseName_f (void)
 Creates console command to change the name of a base.
static void B_BaseInit_f (void)
 Initialises base.
static void B_BuildingDestroy_f (void)
 Destroy a base building.
static void B_AssembleMap_f (void)
 Builds a base map for tactical combat.
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_ListBuildings_f (void)
 Update the facilities list.
static void B_FillMap_f (void)
 Lists building tiles for the Basescape UI.
static void B_BuildingOpenAfterClick_f (void)
 Opens menu on clicking a building in Baseview.
static void B_BuildBuilding_f (void)
 Build a base building.
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

◆ CREATE_NEW_BASE_ID

#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

◆ B_AssembleMap_f()

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, GEO_IsNight(), and base_t::pos.

◆ B_BaseInit_f()

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, CP_UpdateCredits(), E_HireAllowed(), HOS_HospitalAllowed(), PR_ProductionAllowed(), and RS_ResearchAllowed().

◆ B_BuildBase_f()

◆ B_BuildBuilding_f()

void B_BuildBuilding_f ( void )
static

◆ B_BuildingDestroy_f()

◆ B_BuildingOpenAfterClick_f()

◆ B_ChangeBaseName_f()

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, Com_IsValidName(), and base_t::name.

◆ B_Destroy_AntimaterStorage_f()

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_t::baseStatus, CAP_ANTIMATTER, CAP_GetCurrent, CAP_RemoveAntimatterExceedingCapacity(), cgi, frand(), MS_AddNewMessage(), base_t::name, and va().

◆ B_FillBuildingInfo_f()

◆ B_FillMap_f()

◆ B_InitCallbacks()

void B_InitCallbacks ( void )
Todo
unify the names into mn_base_*

Definition at line 695 of file cp_base_callbacks.cpp.

References _, B_GetCount(), baseCallbacks, ccs, cgi, MAX_BASES, and mn_base_title.

Referenced by CP_AddCampaignCallbackCommands().

◆ B_ListBuildings_f()

◆ B_MakeBaseMapShot_f()

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.

◆ B_SelectBase_f()

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, CREATE_NEW_BASE_ID, and MAX_BASES.

◆ B_SetBaseTitle_f()

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, cgi, Com_sprintf(), i, lengthof, MAX_BASES, MAX_VAR, MS_AddNewMessage(), Q_streq, and Q_strncpyz().

◆ B_ShutdownCallbacks()

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

Definition at line 706 of file cp_base_callbacks.cpp.

References baseCallbacks, and cgi.

Referenced by CP_RemoveCampaignCallbackCommands().

Variable Documentation

◆ baseCallbacks

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

Init/Shutdown functions

Definition at line 676 of file cp_base_callbacks.cpp.

Referenced by B_InitCallbacks(), and B_ShutdownCallbacks().

◆ mn_base_title

cvar_t* mn_base_title
static

Definition at line 40 of file cp_base_callbacks.cpp.

Referenced by B_BuildBase_f(), and B_InitCallbacks().