cp_market_callbacks.c File Reference

#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"
Include dependency graph for cp_market_callbacks.c:

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_tBS_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_tcurrentSelectedMenuEntry
static int buyCat = FILTER_S_PRIMARY
static const int MAX_BS_FACTORS = 500
 Max values for Buy/Sell factors.
static linkedList_tbsMarketNames
 Market text nodes buffers.
static linkedList_tbsMarketStorage
static linkedList_tbsMarketMarket
static linkedList_tbsMarketPrices

Detailed Description

Definition in file cp_market_callbacks.c.


Define Documentation

#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 Documentation

typedef struct buyList_s buyList_t

An entry in the buylist.

Note:
The pointers are used XOR - there can be only one (used).

Function Documentation

static void BS_AddToList ( const char *  name,
int  storage,
int  market,
int  price 
) [static]

Appends a new entry to the market buffers.

See also:
BS_MarketScroll_f
BS_MarketClick_f

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.

Parameters:
aircraft The aircraft to check
Returns:
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]
static void BS_BuyAircraft_f ( void   )  [static]
static void BS_BuyItem_f ( void   )  [static]
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.

See also:
BS_BuyType_f

Todo:
Add this entry to the list
Todo:
use the market to get the price
See also:
BS_MarketClick_f
Todo:
Use craftitem name here? See also BS_MarketClick_f
Todo:
select first heavy item

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]
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]
static const objDef_t* BS_GetObjectDefition ( const buyListEntry_t entry  )  [static]
static int BS_GetStorageAmountInBase ( const base_t base,
const char *  aircraftID 
) [static]

Returns the storage amount of a

Parameters:
[in] base The base to count the aircraft type in
[in] aircraftID Aircraft script id
Returns:
The storage amount for the given aircraft type in the given base

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   ) 
static void BS_MarketAircraftDescription ( const aircraft_t aircraftTemplate  )  [static]

Prints general information about aircraft for Buy/Sell menu.

Parameters:
[in] aircraftTemplate Aircraft type.
See also:
UP_AircraftDescription
UP_AircraftItemDescription

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]
static void BS_MarketInfoClick_f ( void   )  [static]

Opens the UFOpedia for the current selected item/aircraft/ugv.

Note:
called by market_openpedia

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]
static void BS_SellAircraft_f ( void   )  [static]
static void BS_SellItem_f ( void   )  [static]
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.

See also:
BS_BuyType

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


Variable Documentation

Definition at line 292 of file cp_market_callbacks.c.

Market text nodes buffers.

Definition at line 290 of file cp_market_callbacks.c.

Definition at line 293 of file cp_market_callbacks.c.

Definition at line 291 of file cp_market_callbacks.c.

int buyCat = FILTER_S_PRIMARY [static]
buyList_t buyList [static]

Current buylist that is shown in the menu.

Definition at line 54 of file cp_market_callbacks.c.

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.


Generated by  doxygen 1.6.2