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

Header file for menu callback functions used for hire/employee menu. More...

#include "../../cl_shared.h"
#include "../../ui/ui_dataids.h"
#include "cp_campaign.h"
#include "cp_hospital.h"
#include "cp_employee_callbacks.h"
#include "cp_employee.h"

Go to the source code of this file.

Functions

static void E_UpdateGUICount_f (void)
 Update GUI with the current number of employee per category. More...
 
static void E_EmployeeSelect (Employee *employee)
 
static EmployeeE_GetEmployeeByMenuIndex (int num)
 Find an hired or free employee by the menu index. More...
 
static void E_EmployeeList_f (void)
 Will fill the list with employees. More...
 
static void E_ChangeName_f (void)
 Change the name of the selected actor. More...
 
static void E_EmployeeDelete_f (void)
 This removes an employee from the global list so that he/she is no longer hireable. More...
 
static void E_EmployeeHire_f (void)
 Callback for employee_hire command. More...
 
static void E_EmployeeSelect_f (void)
 Callback function that updates the character cvars when calling employee_select. More...
 
static const char * E_GetEmployeeTypeString (employeeType_t type)
 Convert employeeType_t to string id. More...
 
static void E_GetCounts_f (void)
 Returns the number of employees hired on a base for the UI. More...
 
void E_InitCallbacks (void)
 Register UI callbacks. More...
 
void E_ShutdownCallbacks (void)
 Unregister UI callbacks. More...
 

Variables

static EmployeeselectedEmployee = nullptr
 
static int employeeCategory = 0
 
static linkedList_temployeeList
 
static int employeesInCurrentList
 
static const cmdList_t employeeCmds []
 List of UI command callbacks. More...
 

Detailed Description

Header file for menu callback functions used for hire/employee menu.

Definition in file cp_employee_callbacks.cpp.

Function Documentation

static void E_ChangeName_f ( void  )
static

Change the name of the selected actor.

Note
called via "employee_changename"

Definition at line 175 of file cp_employee_callbacks.cpp.

References cgi, Employee::chr, Com_IsValidName(), cgame_import_s::Cvar_ForceSet(), cgame_import_s::Cvar_GetString(), E_GetEmployeeFromChrUCN(), character_s::name, and Q_strncpyz().

static void E_EmployeeDelete_f ( void  )
static

This removes an employee from the global list so that he/she is no longer hireable.

Definition at line 194 of file cp_employee_callbacks.cpp.

References _, cgi, cgame_import_s::Cmd_Argv(), DEBUG_CLIENT, E_DeleteEmployee(), E_GetEmployeeByMenuIndex(), and employeeCategory.

static void E_EmployeeHire_f ( void  )
static

Callback for employee_hire command.

Note
a + as parameter indicates, that more than maxEmployeesPerPage are possible
See also
CL_AssignSoldier_f

Definition at line 232 of file cp_employee_callbacks.cpp.

References _, B_GetCurrentSelectedBase(), cgi, cgame_import_s::Cmd_Argv(), DEBUG_CLIENT, E_EmployeeSelect(), E_GetEmployeeByMenuIndex(), E_HireEmployee(), E_UpdateGUICount_f(), Employee::isHired(), and Employee::unhire().

static void E_EmployeeList_f ( void  )
static

Will fill the list with employees.

Note
this is the init function in the employee hire menu
Note
0 == nothing is displayed 1 == only stuff wanted for soldiers is displayed 2 == only stuff wanted for pilots is displayed 3 == only stuff wanted for scientists/workers is displayed
Todo:
replace magic numbers - use confuncs

Definition at line 92 of file cp_employee_callbacks.cpp.

References AIR_IsEmployeeInAircraft(), B_GetCurrentSelectedBase(), cgi, cgame_import_s::Cmd_Argv(), cgame_import_s::Cvar_Set(), E_EmployeeSelect(), E_Foreach, E_GetEmployeeByMenuIndex(), EMPL_PILOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, employeeCategory, employeesInCurrentList, HOS_NeedsHealing(), MAX_EMPL, aircraft_s::name, and selectedEmployee.

static void E_EmployeeSelect ( Employee employee)
static
static void E_EmployeeSelect_f ( void  )
static

Callback function that updates the character cvars when calling employee_select.

Definition at line 282 of file cp_employee_callbacks.cpp.

References cgi, cgame_import_s::Cmd_Argv(), E_EmployeeSelect(), E_GetEmployeeByMenuIndex(), and employeesInCurrentList.

static void E_GetCounts_f ( void  )
static

Returns the number of employees hired on a base for the UI.

Definition at line 323 of file cp_employee_callbacks.cpp.

References B_GetFoundedBaseByIDX(), cgi, cgame_import_s::Cmd_Argv(), count, E_CountHired(), E_GetEmployeeString(), E_GetEmployeeTypeString(), EMPL_ROBOT, EMPL_SOLDIER, MAX_VAR, Q_strncpyz(), and type.

static Employee* E_GetEmployeeByMenuIndex ( int  num)
static

Find an hired or free employee by the menu index.

Parameters
[in]numThe index from the hire menu screen (index inemployeeList).

Definition at line 83 of file cp_employee_callbacks.cpp.

References cgi, and cgame_import_s::LIST_GetByIdx().

Referenced by E_EmployeeDelete_f(), E_EmployeeHire_f(), E_EmployeeList_f(), and E_EmployeeSelect_f().

static const char* E_GetEmployeeTypeString ( employeeType_t  type)
static

Convert employeeType_t to string id.

Parameters
typeemployeeType_t value
Returns
Employee type as string id

Definition at line 302 of file cp_employee_callbacks.cpp.

References cgi, EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, and ERR_DROP.

Referenced by E_GetCounts_f().

void E_InitCallbacks ( void  )

Register UI callbacks.

Definition at line 368 of file cp_employee_callbacks.cpp.

References cgi.

Referenced by E_InitStartup().

void E_ShutdownCallbacks ( void  )

Unregister UI callbacks.

Definition at line 376 of file cp_employee_callbacks.cpp.

References cgi.

Referenced by E_Shutdown().

static void E_UpdateGUICount_f ( void  )
static

Update GUI with the current number of employee per category.

See also
hire.ufo

Definition at line 46 of file cp_employee_callbacks.cpp.

References B_GetCurrentSelectedBase(), CAP_EMPLOYEES, CAP_GetMax, cgi, cgame_import_s::Cvar_Set(), E_CountAllHired(), E_CountHired(), EMPL_PILOT, EMPL_SCIENTIST, EMPL_SOLDIER, and EMPL_WORKER.

Referenced by E_EmployeeHire_f().

Variable Documentation

int employeeCategory = 0
static

Definition at line 35 of file cp_employee_callbacks.cpp.

Referenced by E_EmployeeDelete_f(), and E_EmployeeList_f().

const cmdList_t employeeCmds[]
static
Initial value:
= {
{"employee_update_count", E_UpdateGUICount_f, "Callback to update the employee count of the current GUI"},
{"employee_init", E_EmployeeList_f, "Init function for employee hire menu"},
{"employee_delete", E_EmployeeDelete_f, "Remove an employee from the global employee list"},
{"employee_hire", E_EmployeeHire_f, nullptr},
{"employee_select", E_EmployeeSelect_f, nullptr},
{"employee_changename", E_ChangeName_f, "Change the name of an employee"},
{"ui_get_employee_counts", E_GetCounts_f, "Callback return the number of each employee types hired on a base"},
{nullptr, nullptr, nullptr}
}
static void E_EmployeeHire_f(void)
Callback for employee_hire command.
static void E_EmployeeList_f(void)
Will fill the list with employees.
static void E_EmployeeSelect_f(void)
Callback function that updates the character cvars when calling employee_select.
static void E_EmployeeDelete_f(void)
This removes an employee from the global list so that he/she is no longer hireable.
static void E_GetCounts_f(void)
Returns the number of employees hired on a base for the UI.
static void E_ChangeName_f(void)
Change the name of the selected actor.
static void E_UpdateGUICount_f(void)
Update GUI with the current number of employee per category.

List of UI command callbacks.

Definition at line 353 of file cp_employee_callbacks.cpp.

linkedList_t* employeeList
static

Definition at line 38 of file cp_employee_callbacks.cpp.

int employeesInCurrentList
static
See also
E_GetEmployeeByMenuIndex

Definition at line 40 of file cp_employee_callbacks.cpp.

Referenced by E_EmployeeList_f(), and E_EmployeeSelect_f().

Employee* selectedEmployee = nullptr
static

Currently selected employee.

Definition at line 33 of file cp_employee_callbacks.cpp.

Referenced by E_EmployeeList_f().