#include "../cl_shared.h"
#include "../cl_inventory.h"
#include "../ui/ui_main.h"
#include "../ui/ui_popup.h"
#include "cp_campaign.h"
#include "cp_market.h"
#include "cp_market_callbacks.h"
Go to the source code of this file.
Data Structures | |
struct | buyListEntry_s |
An entry in the buylist. More... | |
struct | buyList_s |
Defines | |
#define | MAX_BUYLIST 64 |
#define | MAX_MARKET_MENU_ENTRIES 22 |
Typedefs | |
typedef struct buyListEntry_s | buyListEntry_t |
An entry in the buylist. | |
typedef struct buyList_s | buyList_t |
Functions | |
static qboolean | BS_AircraftIsOnMarket (const aircraft_t *aircraft) |
Checks whether a given aircraft should appear on the market. | |
static int | BS_GetBuySellFactor (void) |
Set the number of item to buy or sell. | |
static const objDef_t * | BS_GetObjectDefition (const buyListEntry_t *entry) |
static void | BS_MarketAircraftDescription (const aircraft_t *aircraftTemplate) |
Prints general information about aircraft for Buy/Sell menu. | |
static int | BS_GetStorageAmountInBase (const base_t *base, const char *aircraftID) |
static qboolean | BS_GetMinMaxValueByItemID (const base_t *base, int itemNum, int *min, int *max, int *value) |
static void | BS_UpdateItem (const base_t *base, int itemNum) |
Update the GUI by calling a console function. | |
static void | BS_MarketScroll_f (void) |
static void | BS_MarketClick_f (void) |
Select one entry on the list. | |
static void | BS_MarketInfoClick_f (void) |
Opens the UFOpedia for the current selected item/aircraft/ugv. | |
static void | BS_AddToList (const char *name, int storage, int market, int price) |
Appends a new entry to the market buffers. | |
static void | BS_BuyType (const base_t *base) |
Updates the Buy/Sell menu list. | |
static void | BS_BuyType_f (void) |
Init function for Buy/Sell menu. | |
static void | BS_BuyAircraft_f (void) |
Buys aircraft or craftitem. | |
static void | BS_SellAircraft_f (void) |
Sells aircraft or craftitem. | |
static void | BS_BuyItem_f (void) |
Buy one item of a given type. | |
static void | BS_SellItem_f (void) |
Sell one item of a given type. | |
static void | BS_BuySellItem_f (void) |
static void | BS_Autosell_f (void) |
Enable or disable autosell option for given itemtype. | |
void | BS_InitCallbacks (void) |
void | BS_ShutdownCallbacks (void) |
Variables | |
static buyList_t | buyList |
static const objDef_t * | currentSelectedMenuEntry |
static int | buyCat = FILTER_S_PRIMARY |
static const int | MAX_BS_FACTORS = 500 |
Max values for Buy/Sell factors. | |
static linkedList_t * | bsMarketNames |
Market text nodes buffers. | |
static linkedList_t * | bsMarketStorage |
static linkedList_t * | bsMarketMarket |
static linkedList_t * | bsMarketPrices |
Definition in file cp_market_callbacks.c.
#define MAX_BUYLIST 64 |
Definition at line 33 of file cp_market_callbacks.c.
Referenced by BS_BuyType().
#define MAX_MARKET_MENU_ENTRIES 22 |
Definition at line 35 of file cp_market_callbacks.c.
Referenced by BS_BuyType(), and BS_MarketScroll_f().
typedef struct buyListEntry_s buyListEntry_t |
An entry in the buylist.
static void BS_AddToList | ( | const char * | name, | |
int | storage, | |||
int | market, | |||
int | price | |||
) | [static] |
Appends a new entry to the market buffers.
Definition at line 300 of file cp_market_callbacks.c.
References _, LIST_AddString(), and va().
Referenced by BS_BuyType().
static qboolean BS_AircraftIsOnMarket | ( | const aircraft_t * | aircraft | ) | [static] |
Checks whether a given aircraft should appear on the market.
aircraft | The aircraft to check |
true
if the aircraft should appear on the market Definition at line 67 of file cp_market_callbacks.c.
References AIRCRAFT_UFO, aircraft_s::price, and aircraft_s::type.
Referenced by BS_BuyType().
static void BS_Autosell_f | ( | void | ) | [static] |
Enable or disable autosell option for given itemtype.
Definition at line 898 of file cp_market_callbacks.c.
References market_s::autosell, B_GetCurrentSelectedBase(), BS_BuyType(), BS_GetObjectDefition(), ccs, Cmd_Argc(), Cmd_Argv(), Com_DPrintf(), Com_Printf(), DEBUG_CLIENT, ccs_s::eMarket, objDef_s::idx, buyList_s::l, buyList_s::length, objDef_s::name, qfalse, qtrue, RS_GetTechForItem(), RS_IsResearched_ptr(), and buyList_s::scroll.
Referenced by BS_InitCallbacks().
static void BS_BuyAircraft_f | ( | void | ) | [static] |
Buys aircraft or craftitem.
Definition at line 573 of file cp_market_callbacks.c.
References _, AIR_CalculateHangarStorage(), AIR_NewAircraft(), buyListEntry_s::aircraft, B_GetBuildingStatus(), B_GetCurrentSelectedBase(), B_HANGAR, B_POWER, B_SMALL_HANGAR, BS_GetAircraftBuyingPrice(), BS_RemoveAircraftFromMarket(), buyCat, ccs, CL_UpdateCredits(), Cmd_Argc(), Cmd_Argv(), Cmd_ExecuteString(), Com_Printf(), ccs_s::credits, FILTER_AIRCRAFT, aircraft_s::id, INV_GetFilterType(), buyList_s::l, buyList_s::length, UI_Popup(), and va().
Referenced by BS_BuyItem_f().
static void BS_BuyItem_f | ( | void | ) | [static] |
Buy one item of a given type.
Definition at line 723 of file cp_market_callbacks.c.
References _, B_GetCurrentSelectedBase(), B_UpdateStorageAndCapacity(), BS_BuyAircraft_f(), BS_BuyType(), BS_CheckAndDoBuyItem(), BS_GetBuySellFactor(), BS_GetObjectDefition(), BS_RemoveItemFromMarket(), BS_UpdateItem(), buyCat, CAP_ITEMS, base_s::capacities, ccs, CL_UpdateCredits(), Cmd_Argc(), Cmd_Argv(), Com_DPrintf(), Com_Error(), Com_Printf(), ccs_s::credits, cap_maxcur_s::cur, DEBUG_CLIENT, E_CountUnhiredRobotsByType(), E_HireRobot(), ccs_s::eMarket, ERR_DROP, FILTER_AIRCRAFT, FILTER_UGVITEM, objDef_s::id, ugv_s::id, objDef_s::idx, INV_ItemDescription(), INVSH_GetItemByID(), buyList_s::l, buyList_s::length, cap_maxcur_s::max, market_s::numItems, ugv_s::price, qfalse, qtrue, buyList_s::scroll, objDef_s::size, buyListEntry_s::ugv, UGV_SIZE, UI_ExecuteConfunc(), UI_Popup(), UP_UGVDescription(), and ugv_s::weapon.
Referenced by BS_BuySellItem_f(), and BS_InitCallbacks().
static void BS_BuySellItem_f | ( | void | ) | [static] |
Definition at line 874 of file cp_market_callbacks.c.
References BS_BuyItem_f(), BS_SellItem_f(), Cmd_Argc(), Cmd_Argv(), and Com_Printf().
Referenced by BS_InitCallbacks().
static void BS_BuyType | ( | const base_t * | base | ) | [static] |
Updates the Buy/Sell menu list.
Definition at line 312 of file cp_market_callbacks.c.
References buyListEntry_s::aircraft, ccs_s::aircraftTemplates, market_s::autosell, BS_AddToList(), BS_AircraftIsOnMarket(), BS_GetAircraftBuyingPrice(), BS_GetAircraftOnMarket(), BS_GetItemBuyingPrice(), BS_GetStorageAmountInBase(), BS_IsOnMarket(), BS_MarketAircraftDescription(), BS_UpdateItem(), buyCat, CAP_ITEMS, base_s::capacities, ccs, CL_UpdateCredits(), Com_Error(), Com_sprintf(), ccs_s::credits, csi, cap_maxcur_s::cur, Cvar_Set(), E_CountHiredRobotByType(), E_CountUnhiredRobotsByType(), ccs_s::eMarket, ERR_DROP, FILTER_AIRCRAFT, FILTER_CRAFTITEM, FILTER_DUMMY, FILTER_UGVITEM, i, ugv_s::id, aircraft_s::id, INV_ItemDescription(), INV_ItemMatchesFilter(), buyListEntry_s::item, buyList_s::l, buyList_s::length, cap_maxcur_s::max, MAX_BUYLIST, MAX_FILTERTYPES, MAX_MARKET_MENU_ENTRIES, MAX_SOLDIER_FILTERTYPES, MAX_VAR, technology_s::name, objDef_s::name, aircraft_s::name, ccs_s::numAircraftTemplates, market_s::numItems, equipDef_s::numItems, csi_s::numODs, csi_s::numUGV, csi_s::ods, ugv_s::price, RS_GetTechByProvided(), RS_IsResearched_ptr(), buyList_s::scroll, base_s::storage, aircraft_s::tech, TEXT_ITEMDESCRIPTION, TEXT_MARKET_MARKET, TEXT_MARKET_NAMES, TEXT_MARKET_PRICES, TEXT_MARKET_STORAGE, buyListEntry_s::ugv, csi_s::ugvs, UI_ExecuteConfunc(), UI_RegisterLinkedListText(), UI_ResetData(), UP_AircraftItemDescription(), and UP_UGVDescription().
Referenced by BS_Autosell_f(), BS_BuyItem_f(), BS_BuyType_f(), BS_SellAircraft_f(), and BS_SellItem_f().
static void BS_BuyType_f | ( | void | ) | [static] |
Init function for Buy/Sell menu.
Definition at line 541 of file cp_market_callbacks.c.
References B_GetCurrentSelectedBase(), BS_BuyType(), buyCat, Cmd_Argc(), Cmd_Argv(), Cvar_Set(), FILTER_DISASSEMBLY, INV_GetFilterType(), INV_GetFilterTypeID(), MAX_FILTERTYPES, buyList_s::scroll, and UI_ExecuteConfunc().
Referenced by BS_InitCallbacks().
static int BS_GetBuySellFactor | ( | void | ) | [inline, static] |
Set the number of item to buy or sell.
Definition at line 75 of file cp_market_callbacks.c.
Referenced by BS_BuyItem_f(), and BS_SellItem_f().
static qboolean BS_GetMinMaxValueByItemID | ( | const base_t * | base, | |
int | itemNum, | |||
int * | min, | |||
int * | max, | |||
int * | value | |||
) | [inline, static] |
Definition at line 138 of file cp_market_callbacks.c.
References buyListEntry_s::aircraft, BS_GetAircraftOnMarket(), BS_GetObjectDefition(), BS_GetStorageAmountInBase(), buyCat, ccs, ccs_s::eMarket, FILTER_AIRCRAFT, FILTER_UGVITEM, aircraft_s::id, objDef_s::idx, buyList_s::l, buyList_s::length, market_s::numItems, equipDef_s::numItems, qfalse, qtrue, buyList_s::scroll, base_s::storage, and buyListEntry_s::ugv.
Referenced by BS_UpdateItem().
static const objDef_t* BS_GetObjectDefition | ( | const buyListEntry_t * | entry | ) | [static] |
Definition at line 80 of file cp_market_callbacks.c.
References buyListEntry_s::aircraft, Com_Error(), ERR_DROP, buyListEntry_s::item, and buyListEntry_s::ugv.
Referenced by BS_Autosell_f(), BS_BuyItem_f(), BS_GetMinMaxValueByItemID(), BS_MarketScroll_f(), and BS_SellItem_f().
static int BS_GetStorageAmountInBase | ( | const base_t * | base, | |
const char * | aircraftID | |||
) | [static] |
Returns the storage amount of a
[in] | base | The base to count the aircraft type in |
[in] | aircraftID | Aircraft script id |
Definition at line 122 of file cp_market_callbacks.c.
References AIR_GetNextFromBase(), and aircraft_s::id.
Referenced by BS_BuyType(), and BS_GetMinMaxValueByItemID().
void BS_InitCallbacks | ( | void | ) |
Definition at line 939 of file cp_market_callbacks.c.
References BS_Autosell_f(), BS_BuyItem_f(), BS_BuySellItem_f(), BS_BuyType_f(), BS_MarketClick_f(), BS_MarketInfoClick_f(), BS_MarketScroll_f(), BS_SellItem_f(), Cmd_AddCommand(), and buyList_s::length.
Referenced by CP_AddCampaignCallbackCommands().
static void BS_MarketAircraftDescription | ( | const aircraft_t * | aircraftTemplate | ) | [static] |
Prints general information about aircraft for Buy/Sell menu.
[in] | aircraftTemplate | Aircraft type. |
Definition at line 100 of file cp_market_callbacks.c.
References _, Cvar_Set(), aircraft_s::id, aircraft_s::name, aircraft_s::tech, aircraft_s::tpl, and UP_AircraftDescription().
Referenced by BS_BuyType(), and BS_MarketClick_f().
static void BS_MarketClick_f | ( | void | ) | [static] |
Select one entry on the list.
Definition at line 232 of file cp_market_callbacks.c.
References buyListEntry_s::aircraft, BS_MarketAircraftDescription(), buyCat, Cmd_Argc(), Cmd_Argv(), Com_Printf(), Cvar_Set(), FILTER_AIRCRAFT, FILTER_CRAFTITEM, FILTER_UGVITEM, INV_ItemDescription(), buyListEntry_s::item, buyList_s::l, buyList_s::length, MAX_FILTERTYPES, aircraft_s::tpl, buyListEntry_s::ugv, UI_ExecuteConfunc(), UP_AircraftItemDescription(), and UP_UGVDescription().
Referenced by BS_InitCallbacks().
static void BS_MarketInfoClick_f | ( | void | ) | [static] |
Opens the UFOpedia for the current selected item/aircraft/ugv.
Definition at line 281 of file cp_market_callbacks.c.
References Cvar_GetString(), technology_s::id, RS_GetTechByProvided(), and UP_OpenWith().
Referenced by BS_InitCallbacks().
static void BS_MarketScroll_f | ( | void | ) | [static] |
Definition at line 186 of file cp_market_callbacks.c.
References market_s::autosell, B_GetCurrentSelectedBase(), BS_GetObjectDefition(), BS_UpdateItem(), buyCat, ccs, Cmd_Argc(), Cmd_Argv(), Com_Printf(), ccs_s::eMarket, i, objDef_s::idx, INV_ItemMatchesFilter(), buyList_s::l, buyList_s::length, MAX_FILTERTYPES, MAX_MARKET_MENU_ENTRIES, market_s::numItems, equipDef_s::numItems, buyList_s::scroll, base_s::storage, and UI_ExecuteConfunc().
Referenced by BS_InitCallbacks().
static void BS_SellAircraft_f | ( | void | ) | [static] |
Sells aircraft or craftitem.
Definition at line 635 of file cp_market_callbacks.c.
References _, AIR_DeleteAircraft(), AIR_GetNextFromBase(), AIR_GetTeamSize(), AIR_IsAircraftInBase(), buyListEntry_s::aircraft, aircraftSlot_s::ammo, B_GetCurrentSelectedBase(), BS_AddAircraftToMarket(), BS_BuyType(), BS_GetAircraftSellingPrice(), BS_ProcessCraftItemSale(), buyCat, ccs, CL_UpdateCredits(), Cmd_Argc(), Cmd_Argv(), Com_DPrintf(), Com_Printf(), ccs_s::credits, DEBUG_CLIENT, aircraft_s::electronics, FILTER_AIRCRAFT, aircraft_s::id, aircraft_s::idx, aircraftSlot_s::item, buyList_s::l, buyList_s::length, aircraft_s::maxElectronics, aircraft_s::maxWeapons, qfalse, qtrue, aircraft_s::shield, UI_Popup(), and aircraft_s::weapons.
Referenced by BS_SellItem_f().
static void BS_SellItem_f | ( | void | ) | [static] |
Sell one item of a given type.
Definition at line 803 of file cp_market_callbacks.c.
References B_GetCurrentSelectedBase(), B_UpdateStorageAndCapacity(), BS_AddItemToMarket(), BS_BuyType(), BS_GetBuySellFactor(), BS_GetItemSellingPrice(), BS_GetObjectDefition(), BS_SellAircraft_f(), BS_UpdateItem(), buyCat, ccs, CL_UpdateCredits(), Cmd_Argc(), Cmd_Argv(), Com_DPrintf(), Com_Error(), Com_Printf(), ccs_s::credits, DEBUG_CLIENT, E_GetHiredRobot(), E_UnhireEmployee(), ERR_DROP, FILTER_AIRCRAFT, FILTER_UGVITEM, ugv_s::id, objDef_s::idx, INV_ItemDescription(), INVSH_GetItemByID(), buyList_s::l, buyList_s::length, equipDef_s::numItems, ugv_s::price, qfalse, buyList_s::scroll, base_s::storage, buyListEntry_s::ugv, UI_ExecuteConfunc(), UP_UGVDescription(), and ugv_s::weapon.
Referenced by BS_BuySellItem_f(), and BS_InitCallbacks().
void BS_ShutdownCallbacks | ( | void | ) |
Definition at line 954 of file cp_market_callbacks.c.
References Cmd_RemoveCommand().
Referenced by CP_RemoveCampaignCallbackCommands().
static void BS_UpdateItem | ( | const base_t * | base, | |
int | itemNum | |||
) | [static] |
Update the GUI by calling a console function.
Definition at line 173 of file cp_market_callbacks.c.
References BS_GetMinMaxValueByItemID(), and UI_ExecuteConfunc().
Referenced by BS_BuyItem_f(), BS_BuyType(), BS_MarketScroll_f(), and BS_SellItem_f().
linkedList_t* bsMarketMarket [static] |
Definition at line 292 of file cp_market_callbacks.c.
linkedList_t* bsMarketNames [static] |
Market text nodes buffers.
Definition at line 290 of file cp_market_callbacks.c.
linkedList_t* bsMarketPrices [static] |
Definition at line 293 of file cp_market_callbacks.c.
linkedList_t* bsMarketStorage [static] |
Definition at line 291 of file cp_market_callbacks.c.
int buyCat = FILTER_S_PRIMARY [static] |
Category of items in the menu.
Definition at line 56 of file cp_market_callbacks.c.
Referenced by BS_BuyAircraft_f(), BS_BuyItem_f(), BS_BuyType(), BS_BuyType_f(), BS_GetMinMaxValueByItemID(), BS_MarketClick_f(), BS_MarketScroll_f(), BS_SellAircraft_f(), and BS_SellItem_f().
Current buylist that is shown in the menu.
Definition at line 54 of file cp_market_callbacks.c.
const objDef_t* currentSelectedMenuEntry [static] |
Current selected entry on the list.
Definition at line 55 of file cp_market_callbacks.c.
const int MAX_BS_FACTORS = 500 [static] |
Max values for Buy/Sell factors.
Definition at line 60 of file cp_market_callbacks.c.