cp_uforecovery_callbacks.c File Reference

UFO recovery and storing callback functions. More...

#include "../cl_shared.h"
#include "cp_campaign.h"
#include "cp_ufo.h"
#include "cp_uforecovery.h"
#include "cp_uforecovery_callbacks.h"
#include "../ui/ui_main.h"
Include dependency graph for cp_uforecovery_callbacks.c:

Go to the source code of this file.

Data Structures

struct  ufoRecoveryNation_s
 Entries on Sell UFO dialog. More...
struct  ufoRecovery_s

Typedefs

typedef struct ufoRecoveryNation_s ufoRecoveryNation_t
 Entries on Sell UFO dialog.
typedef int(* COMP_FUNCTION )(ufoRecoveryNation_t *a, ufoRecoveryNation_t *b)
 Pointer to compare function.
typedef struct ufoRecovery_s ufoRecovery_t

Enumerations

enum  ufoRecoveryNationOrder_t { ORDER_NATION, ORDER_PRICE, ORDER_HAPPINESS, MAX_ORDER }
 

Constants for Sell UFO menu order.

More...

Functions

static void UR_DialogRecoveryDone (void)
 Updates UFO recovery process.
static void UR_DialogInit_f (void)
 Function to trigger UFO Recovered event.
static void UR_DialogInitStore_f (void)
 Function to initialize list of storage locations for recovered UFO.
static void UR_DialogStartStore_f (void)
 Function to start UFO recovery process.
static void UR_DialogFillNations (void)
 Build the Sell UFO dialog's nationlist.
static int UR_CompareByName (ufoRecoveryNation_t *a, ufoRecoveryNation_t *b)
 Compare nations by nation name.
static int UR_CompareByPrice (ufoRecoveryNation_t *a, ufoRecoveryNation_t *b)
 Compare nations by price.
static int UR_CompareByHappiness (ufoRecoveryNation_t *a, ufoRecoveryNation_t *b)
 Compare nations by happiness.
static void UR_SortNations (COMP_FUNCTION comp, qboolean order)
 Sort nations.
static COMP_FUNCTION UR_GetSortFunctionByColumn (ufoRecoveryNationOrder_t column)
 Returns the sort function for a column.
static void UR_DialogInitSell_f (void)
 Function to initialize list to sell recovered UFO to desired nation.
static int UR_DialogGetCurrentNationIndex (void)
 Returns the index of the selected nation in SellUFO list.
static ufoRecoveryNationOrder_t UR_GetOrderTypeByID (const char *id)
 Converts script id string to ordercolumn constant.
static void UR_DialogSortByColumn_f (void)
 Sort Sell UFO dialog.
static void UR_DialogSelectSellNation_f (void)
 Finds the nation to which recovered UFO will be sold.
static void UR_DialogStartSell_f (void)
 Function to start UFO selling process.
void UR_InitCallbacks (void)
void UR_ShutdownCallbacks (void)

Variables

static ufoRecovery_t ufoRecovery

Detailed Description

UFO recovery and storing callback functions.

Note:
UFO recovery functions with UR_*
UFO storing functions with US_*

Definition in file cp_uforecovery_callbacks.c.


Typedef Documentation

Pointer to compare function.

Note:
This function is used by sorting algorithm.

Definition at line 52 of file cp_uforecovery_callbacks.c.

typedef struct ufoRecovery_s ufoRecovery_t
See also:
ufoRecoveries_t

Entries on Sell UFO dialog.


Enumeration Type Documentation

Constants for Sell UFO menu order.

Enumerator:
ORDER_NATION 
ORDER_PRICE 
ORDER_HAPPINESS 
MAX_ORDER 

Definition at line 57 of file cp_uforecovery_callbacks.c.


Function Documentation

static int UR_CompareByHappiness ( ufoRecoveryNation_t a,
ufoRecoveryNation_t b 
) [static]

Compare nations by happiness.

Parameters:
[in] a First item to compare
[in] b Second item to compare
Returns:
1 if a > b
-1 if b > a
0 if a == b
See also:
UR_SortNations

Definition at line 282 of file cp_uforecovery_callbacks.c.

References nationInfo_s::happiness, ufoRecoveryNation_s::nation, and nation_s::stats.

Referenced by UR_GetSortFunctionByColumn().

static int UR_CompareByName ( ufoRecoveryNation_t a,
ufoRecoveryNation_t b 
) [static]

Compare nations by nation name.

Parameters:
[in] a First item to compare
[in] b Second item to compare
See also:
UR_SortNations

Definition at line 250 of file cp_uforecovery_callbacks.c.

References _, nation_s::name, and ufoRecoveryNation_s::nation.

Referenced by UR_GetSortFunctionByColumn().

static int UR_CompareByPrice ( ufoRecoveryNation_t a,
ufoRecoveryNation_t b 
) [static]

Compare nations by price.

Parameters:
[in] a First item to compare
[in] b Second item to compare
Returns:
1 if a > b
-1 if b > a
0 if a == b
See also:
UR_SortNations

Definition at line 264 of file cp_uforecovery_callbacks.c.

References ufoRecoveryNation_s::price.

Referenced by UR_GetSortFunctionByColumn().

static void UR_DialogFillNations ( void   )  [static]
static int UR_DialogGetCurrentNationIndex ( void   )  [static]

Returns the index of the selected nation in SellUFO list.

Definition at line 383 of file cp_uforecovery_callbacks.c.

References ccs, i, ufoRecovery_s::nation, ufoRecoveryNation_s::nation, ccs_s::numNations, and ufoRecovery_s::UFONations.

Referenced by UR_DialogSortByColumn_f(), and UR_DialogStartSell_f().

static void UR_DialogInit_f ( void   )  [static]
static void UR_DialogInitSell_f ( void   )  [static]
static void UR_DialogInitStore_f ( void   )  [static]
static void UR_DialogRecoveryDone ( void   )  [static]

Updates UFO recovery process.

Definition at line 81 of file cp_uforecovery_callbacks.c.

References qtrue, and ufoRecovery_s::recoveryDone.

Referenced by UR_DialogStartSell_f(), and UR_DialogStartStore_f().

static void UR_DialogSelectSellNation_f ( void   )  [static]

Finds the nation to which recovered UFO will be sold.

Note:
The nation selection is being done here.
Callback command: cp_uforecovery_nationlist_click.

Definition at line 451 of file cp_uforecovery_callbacks.c.

References _, ccs, Cmd_Argc(), Cmd_Argv(), Com_DPrintf(), Com_Printf(), Cvar_Set(), DEBUG_CLIENT, nation_s::name, ufoRecovery_s::nation, ufoRecoveryNation_s::nation, ccs_s::numNations, ufoRecovery_s::UFONations, and UI_ExecuteConfunc().

Referenced by UR_InitCallbacks().

static void UR_DialogSortByColumn_f ( void   )  [static]
static void UR_DialogStartSell_f ( void   )  [static]
static void UR_DialogStartStore_f ( void   )  [static]
static ufoRecoveryNationOrder_t UR_GetOrderTypeByID ( const char *  id  )  [static]

Converts script id string to ordercolumn constant.

Parameters:
[in] id Script id for order column
See also:
ufoRecoveryNationOrder_t

Definition at line 398 of file cp_uforecovery_callbacks.c.

References MAX_ORDER, ORDER_HAPPINESS, ORDER_NATION, and ORDER_PRICE.

Referenced by UR_DialogSortByColumn_f().

static COMP_FUNCTION UR_GetSortFunctionByColumn ( ufoRecoveryNationOrder_t  column  )  [static]

Returns the sort function for a column.

Parameters:
[in] column Column ordertype.

Definition at line 334 of file cp_uforecovery_callbacks.c.

References Com_Printf(), ORDER_HAPPINESS, ORDER_NATION, ORDER_PRICE, UR_CompareByHappiness(), UR_CompareByName(), and UR_CompareByPrice().

Referenced by UR_DialogInitSell_f(), and UR_DialogSortByColumn_f().

void UR_InitCallbacks ( void   ) 
void UR_ShutdownCallbacks ( void   ) 

Definition at line 638 of file cp_uforecovery_callbacks.c.

References Cmd_RemoveCommand().

Referenced by CP_RemoveCampaignCallbackCommands().

static void UR_SortNations ( COMP_FUNCTION  comp,
qboolean  order 
) [static]

Sort nations.

Note:
uses Bubble sort algorithm
Parameters:
[in] comp Compare function
[in] order Ascending/Descending order
See also:
UR_CompareByName
UR_CompareByPrice
UR_CompareByHappiness

Definition at line 303 of file cp_uforecovery_callbacks.c.

References ccs, i, ccs_s::numNations, qfalse, qtrue, and ufoRecovery_s::UFONations.

Referenced by UR_DialogInitSell_f(), and UR_DialogSortByColumn_f().


Variable Documentation

Definition at line 76 of file cp_uforecovery_callbacks.c.


Generated by  doxygen 1.6.2