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

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.
static void PR_ClearSelected (void)
 Resets all "selected" pointers to nullptr.
static void PR_UpdateProductionList (const base_t *base)
 update the list of queued and available items
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.
static void PR_DisassemblyInfo (const storedUFO_t *ufo, int remainingHours)
 Prints information about the selected disassembly task.
static void PR_AircraftInfo (const base_t *base, const aircraft_t *aircraftTemplate, int remainingHours)
 Prints information about the selected aircraft in production.
static void PR_ProductionInfo (const base_t *base)
 Prints information about the selected item in production.
static void PR_ProductionListRightClick_f (void)
 Click function for production list.
static void PR_ProductionListClick_f (void)
 Click function for production list.
static void PR_ProductionType_f (void)
 Will select a new tab on the production list.
static void PR_ProductionList_f (void)
 Will fill the list of producible items.
static void PR_ProductionIncrease_f (void)
 Increases the production amount by given parameter.
static void PR_ProductionStop_f (void)
 Stops the current running production.
static void PR_ProductionDecrease_f (void)
 Decrease the production amount by given parameter.
static void PR_ProductionChange_f (void)
 Change the production amount by given diff.
static void PR_ProductionUp_f (void)
 shift the current production up the list
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.
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.
static const cmdList_t productionCallbacks []

Detailed Description

Menu related callback functions used for production.

Definition in file cp_produce_callbacks.cpp.

Function Documentation

◆ PR_AircraftInfo()

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(), aircraft_t::id, aircraft_t::name, PR_GetPrice(), PR_RequirementsInfo(), aircraft_t::productionCost, Q_strcat(), aircraft_t::tech, and TEXT_PRODUCTION_INFO.

Referenced by PR_ProductionInfo().

◆ PR_ClearSelected()

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(), and selectedProduction.

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

◆ PR_ClearSelectedItems()

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 selectedData.

Referenced by PR_ClearSelected(), and PR_ProductionType_f().

◆ PR_DisassemblyInfo()

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_t::comp, COMP_ITEMCOUNT_SCALED, storedUFO_t::condition, aircraft_t::getUfoType(), i, storedUFO_t::id, storedUFO_t::installation, installation_t::name, objDef_t::name, Q_strcat(), TEXT_PRODUCTION_INFO, UFO_TypeToName(), and storedUFO_t::ufoTemplate.

Referenced by PR_ProductionInfo().

◆ PR_InitCallbacks()

void PR_InitCallbacks ( void )

Definition at line 873 of file cp_produce_callbacks.cpp.

References cgi, and productionCallbacks.

Referenced by CP_AddCampaignCallbackCommands().

◆ PR_ItemProductionInfo()

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(), objDef_t::id, objDef_t::name, requirements_t::numLinks, PR_GetPrice(), PR_ItemIsProduceable(), PR_RequirementsInfo(), objDef_t::productionCost, Q_strcat(), technology_t::requireForProduction, RS_GetTechForItem(), objDef_t::size, and TEXT_PRODUCTION_INFO.

Referenced by PR_ProductionInfo().

◆ PR_ProductionChange_f()

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, PR_IsDataValid, selectedData, and selectedProduction.

◆ PR_ProductionDecrease_f()

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_t::amount, B_GetCurrentSelectedBase(), cgi, PR_DecreaseProduction(), PR_ProductionInfo(), PR_ProductionStop_f(), PR_UpdateProductionList(), and selectedProduction.

◆ PR_ProductionDown_f()

void PR_ProductionDown_f ( void )
static

◆ PR_ProductionIncrease_f()

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_t::amount, B_GetCurrentSelectedBase(), CAP_GetFreeCapacity(), cgi, Com_sprintf(), cp_messageBuffer, CP_Popup(), production_t::data, productionData_t::data, 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_t::requireForProduction, selectedData, and selectedProduction.

◆ PR_ProductionInfo()

◆ PR_ProductionList_f()

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, E_CountHired(), EMPL_WORKER, PR_ClearSelected(), and PR_UpdateProductionCap().

◆ PR_ProductionListClick_f()

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, DEBUG_CLIENT, FILTER_AIRCRAFT, FILTER_DISASSEMBLY, production_queue_t::items, production_queue_t::numItems, PR_ClearSelected(), PR_GetProductionForBase, PR_ItemIsProduceable(), PR_ProductionInfo(), PR_SetData, produceCategory, PRODUCTION_TYPE_AIRCRAFT, PRODUCTION_TYPE_DISASSEMBLY, PRODUCTION_TYPE_ITEM, productionItemList, QUEUE_SPACERS, RS_GetTechForItem(), RS_IsResearched_ptr(), selectedData, selectedProduction, and aircraft_t::tech.

◆ PR_ProductionListRightClick_f()

◆ PR_ProductionStop_f()

◆ PR_ProductionType_f()

◆ PR_ProductionUp_f()

void PR_ProductionUp_f ( void )
static

◆ PR_RequirementsInfo()

◆ PR_ShowActiveProduction_f()

void PR_ShowActiveProduction_f ( void )
static

◆ PR_ShutdownCallbacks()

void PR_ShutdownCallbacks ( void )

Definition at line 878 of file cp_produce_callbacks.cpp.

References cgi, and productionCallbacks.

Referenced by CP_RemoveCampaignCallbackCommands().

◆ PR_UpdateProductionList()

Variable Documentation

◆ produceCategory

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().

◆ productionCallbacks

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_ProductionStop_f(void)
Stops the current running production.
static void PR_ProductionDecrease_f(void)
Decrease the production amount by given parameter.
static void PR_ProductionListClick_f(void)
Click function for production list.
static void PR_ProductionDown_f(void)
shift the current production down the list
static void PR_ProductionIncrease_f(void)
Increases the production amount by given parameter.
static void PR_ProductionUp_f(void)
shift the current production up the 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.
static void PR_ProductionChange_f(void)
Change the production amount by given diff.
static void PR_ProductionType_f(void)
Will select a new tab on the production list.
static void PR_ShowActiveProduction_f(void)
Show active production item in Base sections.

Definition at line 859 of file cp_produce_callbacks.cpp.

Referenced by PR_InitCallbacks(), and PR_ShutdownCallbacks().

◆ productionItemList

linkedList_t* productionItemList
static

A list if all producable items.

Definition at line 46 of file cp_produce_callbacks.cpp.

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

◆ QUEUE_SPACERS

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().

◆ selectedData

productionData_t selectedData
static

Currently selected entry in the productionItemList (depends on content)

Definition at line 49 of file cp_produce_callbacks.cpp.

Referenced by PR_ClearSelectedItems(), PR_ProductionChange_f(), PR_ProductionIncrease_f(), PR_ProductionInfo(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), and PR_ProductionType_f().

◆ selectedProduction