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

Menu related callback functions used for production. More...

#include "../../cl_shared.h"
#include "../../cl_inventory.h"
#include "../../ui/ui_dataids.h"
#include "cp_campaign.h"
#include "cp_market.h"
#include "cp_ufo.h"
#include "cp_popup.h"
#include "cp_produce.h"
#include "cp_produce_callbacks.h"
#include "cp_base.h"

Go to the source code of this file.

Functions

static void PR_ClearSelectedItems (void)
 Resets the selected item data structure. Does not reset the selected production. More...
 
static void PR_ClearSelected (void)
 Resets all "selected" pointers to nullptr. More...
 
static void PR_UpdateProductionList (const base_t *base)
 update the list of queued and available items More...
 
static void PR_RequirementsInfo (const base_t *base, const requirements_t *reqs)
 
static void PR_ItemProductionInfo (const base_t *base, const objDef_t *od, int remainingHours)
 Prints information about the selected item (no aircraft) in production. More...
 
static void PR_DisassemblyInfo (const storedUFO_t *ufo, int remainingHours)
 Prints information about the selected disassembly task. More...
 
static void PR_AircraftInfo (const base_t *base, const aircraft_t *aircraftTemplate, int remainingHours)
 Prints information about the selected aircraft in production. More...
 
static void PR_ProductionInfo (const base_t *base)
 Prints information about the selected item in production. More...
 
static void PR_ProductionListRightClick_f (void)
 Click function for production list. More...
 
static void PR_ProductionListClick_f (void)
 Click function for production list. More...
 
static void PR_ProductionType_f (void)
 Will select a new tab on the production list. More...
 
static void PR_ProductionList_f (void)
 Will fill the list of producible items. More...
 
static void PR_ProductionIncrease_f (void)
 Increases the production amount by given parameter. More...
 
static void PR_ProductionStop_f (void)
 Stops the current running production. More...
 
static void PR_ProductionDecrease_f (void)
 Decrease the production amount by given parameter. More...
 
static void PR_ProductionChange_f (void)
 Change the production amount by given diff. More...
 
static void PR_ProductionUp_f (void)
 shift the current production up the list More...
 
static void PR_ProductionDown_f (void)
 shift the current production down the list More...
 
static void PR_ShowActiveProduction_f (void)
 Show active production item in Base sections. More...
 
void PR_InitCallbacks (void)
 
void PR_ShutdownCallbacks (void)
 

Variables

static itemFilterTypes_t produceCategory = FILTER_S_PRIMARY
 
static production_tselectedProduction = nullptr
 
static linkedList_tproductionItemList
 
static productionData_t selectedData
 
static const int QUEUE_SPACERS = 2
 Number of blank lines between queued items and tech list. More...
 
static const cmdList_t productionCallbacks []
 

Detailed Description

Menu related callback functions used for production.

Definition in file cp_produce_callbacks.cpp.

Function Documentation

static void PR_AircraftInfo ( const base_t base,
const aircraft_t aircraftTemplate,
int  remainingHours 
)
static

Prints information about the selected aircraft in production.

Parameters
[in]basePointer to the base where information should be printed.
[in]aircraftTemplateThe aircraft to print the information for
[in]remainingHoursThe remaining hours until this production is finished
See also
PR_ProductionInfo

Definition at line 320 of file cp_produce_callbacks.cpp.

References _, cgi, Com_sprintf(), cgame_import_s::Cvar_Set(), aircraft_s::id, aircraft_s::name, requirements_s::numLinks, PR_GetPrice(), PR_RequirementsInfo(), aircraft_s::productionCost, Q_strcat(), technology_s::requireForProduction, aircraft_s::tech, and TEXT_PRODUCTION_INFO.

Referenced by PR_ProductionInfo().

static void PR_ClearSelected ( void  )
static

Resets all "selected" pointers to nullptr.

See also
PR_ClearSelectedItems

Definition at line 68 of file cp_produce_callbacks.cpp.

References PR_ClearSelectedItems().

Referenced by PR_ProductionList_f(), PR_ProductionListClick_f(), and PR_ProductionListRightClick_f().

static void PR_ClearSelectedItems ( void  )
static

Resets the selected item data structure. Does not reset the selected production.

See also
PR_ClearSelected

Definition at line 58 of file cp_produce_callbacks.cpp.

References OBJZERO, PRODUCTION_TYPE_MAX, and productionData_t::type.

Referenced by PR_ClearSelected(), and PR_ProductionType_f().

static void PR_DisassemblyInfo ( const storedUFO_t ufo,
int  remainingHours 
)
static

Prints information about the selected disassembly task.

Parameters
[in]ufoThe UFO being disassembled.
[in]remainingHoursThe remaining hours until this production is finished
See also
PR_ProductionInfo

Definition at line 286 of file cp_produce_callbacks.cpp.

References _, cgi, Com_sprintf(), storedUFO_s::comp, COMP_ITEMCOUNT_SCALED, storedUFO_s::condition, cgame_import_s::Cvar_Set(), aircraft_s::getUfoType(), i, storedUFO_s::id, storedUFO_s::installation, components_s::itemAmount, components_s::itemAmount2, components_s::items, installation_s::name, objDef_s::name, components_s::numItemtypes, Q_strcat(), TEXT_PRODUCTION_INFO, UFO_TypeToName(), and storedUFO_s::ufoTemplate.

Referenced by PR_ProductionInfo().

void PR_InitCallbacks ( void  )

Definition at line 873 of file cp_produce_callbacks.cpp.

References cgi.

Referenced by CP_AddCampaignCallbackCommands().

static void PR_ItemProductionInfo ( const base_t base,
const objDef_t od,
int  remainingHours 
)
static

Prints information about the selected item (no aircraft) in production.

Parameters
[in]basePointer to the base where information should be printed.
[in]odThe attributes of the item being produced.
[in]remainingHoursThe remaining hours until this production is finished
See also
PR_ProductionInfo

Definition at line 254 of file cp_produce_callbacks.cpp.

References _, cgi, Com_sprintf(), cgame_import_s::Cvar_Set(), objDef_s::id, objDef_s::name, requirements_s::numLinks, PR_GetPrice(), PR_ItemIsProduceable(), PR_RequirementsInfo(), objDef_s::productionCost, Q_strcat(), technology_s::requireForProduction, RS_GetTechForItem(), objDef_s::size, and TEXT_PRODUCTION_INFO.

Referenced by PR_ProductionInfo().

static void PR_ProductionChange_f ( void  )
static

Change the production amount by given diff.

Definition at line 766 of file cp_produce_callbacks.cpp.

References cgi, cgame_import_s::Cmd_Argv(), and PR_IsDataValid.

static void PR_ProductionDecrease_f ( void  )
static

Decrease the production amount by given parameter.

Todo:
add (confirmaton) popup in case storage cannot take all the items we add back to it

Definition at line 737 of file cp_produce_callbacks.cpp.

References production_s::amount, B_GetCurrentSelectedBase(), cgi, cgame_import_s::Cmd_Argv(), PR_DecreaseProduction(), PR_ProductionInfo(), PR_ProductionStop_f(), PR_UpdateProductionList(), and selectedProduction.

static void PR_ProductionDown_f ( void  )
static
static void PR_ProductionIncrease_f ( void  )
static

Increases the production amount by given parameter.

Todo:
-) need to popup something like: "You need the following items in order to produce more of ITEM: x of ITEM, x of ITEM, etc..." This info should also be displayed in the item-info. -) can can (if possible) change the 'amount' to a vlalue that can be produced (i.e. the maximum amount possible).
Todo:
this popup hides any previous popup, like popup created in PR_QueueNew

Definition at line 606 of file cp_produce_callbacks.cpp.

References _, AIR_GetHangarCapacityType(), productionData_t::productionItem_t::aircraft, production_s::amount, B_GetCurrentSelectedBase(), CAP_GetFreeCapacity(), cgi, cgame_import_s::Cmd_Argv(), Com_sprintf(), cp_messageBuffer, CP_Popup(), productionData_t::data, production_s::data, production_s::idx, MAX_PRODUCTION_AMOUNT, MSG_PRODUCTION, MSO_CheckAddNewMessage(), name, NT_PRODUCTION_STARTED, PR_GetName(), PR_GetTech(), PR_IncreaseProduction(), PR_IsAircraft, PR_IsAircraftData, PR_IsDataValid, PR_IsDisassembly, PR_ProductionInfo(), PR_QueueNew(), PR_RequirementsMet(), PR_UpdateProductionList(), technology_s::requireForProduction, and selectedProduction.

static void PR_ProductionList_f ( void  )
static

Will fill the list of producible items.

Note
Some of Production Menu related cvars are being set here.

Definition at line 582 of file cp_produce_callbacks.cpp.

References B_GetCurrentSelectedBase(), CAP_GetCurrent, CAP_GetMax, CAP_ITEMS, CAP_WORKSPACE, cgi, cgame_import_s::Cvar_Set(), E_CountHired(), EMPL_WORKER, PR_ClearSelected(), and PR_UpdateProductionCap().

static void PR_ProductionListClick_f ( void  )
static

Click function for production list.

Note
"num" is the entry in the visible production list (includes queued entries and spaces).
Todo:
left click on spacer should either delete current selection or do nothing, not update visible selection but show old info

Definition at line 458 of file cp_produce_callbacks.cpp.

References B_GetCurrentSelectedBase(), cgi, cgame_import_s::Cmd_Argv(), DEBUG_CLIENT, FILTER_AIRCRAFT, FILTER_DISASSEMBLY, base_s::idx, production_queue_s::items, cgame_import_s::LIST_GetByIdx(), production_queue_s::numItems, PR_ClearSelected(), PR_GetProductionForBase, PR_ItemIsProduceable(), PR_ProductionInfo(), PR_SetData, produceCategory, technology_s::produceTime, PRODUCTION_TYPE_AIRCRAFT, PRODUCTION_TYPE_DISASSEMBLY, PRODUCTION_TYPE_ITEM, QUEUE_SPACERS, RS_GetTechForItem(), RS_IsResearched_ptr(), and aircraft_s::tech.

static void PR_ProductionUp_f ( void  )
static
void PR_ShutdownCallbacks ( void  )

Definition at line 878 of file cp_produce_callbacks.cpp.

References cgi.

Referenced by CP_RemoveCampaignCallbackCommands().

Variable Documentation

itemFilterTypes_t produceCategory = FILTER_S_PRIMARY
static

Holds the current active production category/filter type.

See also
itemFilterTypes_t

Definition at line 40 of file cp_produce_callbacks.cpp.

Referenced by PR_ProductionInfo(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionType_f(), and PR_UpdateProductionList().

const cmdList_t productionCallbacks[]
static
Initial value:
= {
{"prod_init", PR_ProductionList_f, nullptr},
{"prod_type", PR_ProductionType_f, nullptr},
{"prod_up", PR_ProductionUp_f, "Move production item up in the queue"},
{"prod_down", PR_ProductionDown_f, "Move production item down in the queue"},
{"prod_change", PR_ProductionChange_f, "Change production amount"},
{"prod_inc", PR_ProductionIncrease_f, "Increase production amount"},
{"prod_dec", PR_ProductionDecrease_f, "Decrease production amount"},
{"prod_stop", PR_ProductionStop_f, "Stop production"},
{"prodlist_rclick", PR_ProductionListRightClick_f, nullptr},
{"prodlist_click", PR_ProductionListClick_f, nullptr},
{"prod_show_active", PR_ShowActiveProduction_f, "Show the active production item and it's status"},
{nullptr, nullptr, nullptr}
}
static void PR_ProductionUp_f(void)
shift the current production up the list
static void PR_ProductionDecrease_f(void)
Decrease the production amount by given parameter.
static void PR_ProductionType_f(void)
Will select a new tab on the production list.
static void PR_ProductionIncrease_f(void)
Increases the production amount by given parameter.
static void PR_ProductionDown_f(void)
shift the current production down the list
static void PR_ShowActiveProduction_f(void)
Show active production item in Base sections.
static void PR_ProductionChange_f(void)
Change the production amount by given diff.
static void PR_ProductionStop_f(void)
Stops the current running production.
static void PR_ProductionListClick_f(void)
Click function for production list.
static void PR_ProductionList_f(void)
Will fill the list of producible items.
static void PR_ProductionListRightClick_f(void)
Click function for production list.

Definition at line 859 of file cp_produce_callbacks.cpp.

linkedList_t* productionItemList
static

A list if all producable items.

Definition at line 46 of file cp_produce_callbacks.cpp.

const int QUEUE_SPACERS = 2
static

Number of blank lines between queued items and tech list.

Definition at line 52 of file cp_produce_callbacks.cpp.

Referenced by PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionType_f(), and PR_UpdateProductionList().

productionData_t selectedData
static

Currently selected entry in the productionItemList (depends on content)

Definition at line 49 of file cp_produce_callbacks.cpp.

production_t* selectedProduction = nullptr
static

Holds the current active selected queue entry.

Definition at line 43 of file cp_produce_callbacks.cpp.

Referenced by PR_ProductionDecrease_f(), PR_ProductionIncrease_f(), and PR_ProductionInfo().