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

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.
static void E_EmployeeSelect (Employee *employee)
static EmployeeE_GetEmployeeByMenuIndex (int num)
 Find an hired or free employee by the menu index.
static void E_EmployeeList_f (void)
 Will fill the list with employees.
static void E_ChangeName_f (void)
 Change the name of the selected actor.
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_EmployeeHire_f (void)
 Callback for employee_hire command.
static void E_EmployeeSelect_f (void)
 Callback function that updates the character cvars when calling employee_select.
static const char * E_GetEmployeeTypeString (employeeType_t type)
 Convert employeeType_t to string id.
static void E_GetCounts_f (void)
 Returns the number of employees hired on a base for the UI.
void E_InitCallbacks (void)
 Register UI callbacks.
void E_ShutdownCallbacks (void)
 Unregister UI callbacks.

Variables

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

Detailed Description

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

Definition in file cp_employee_callbacks.cpp.

Function Documentation

◆ E_ChangeName_f()

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(), E_GetEmployeeFromChrUCN(), character_t::name, and Q_strncpyz().

◆ E_EmployeeDelete_f()

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, DEBUG_CLIENT, E_DeleteEmployee(), E_GetEmployeeByMenuIndex(), employeeCategory, Employee::isHired(), and Employee::unhire().

◆ E_EmployeeHire_f()

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, DEBUG_CLIENT, E_EmployeeSelect(), E_GetEmployeeByMenuIndex(), E_HireEmployee(), E_UpdateGUICount_f(), Employee::isHired(), and Employee::unhire().

◆ E_EmployeeList_f()

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, E_EmployeeSelect(), E_Foreach, E_GetEmployeeByMenuIndex(), EMPL_PILOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, employeeCategory, employeeList, employeesInCurrentList, HOS_NeedsHealing(), MAX_EMPL, aircraft_t::name, and selectedEmployee.

◆ E_EmployeeSelect()

void E_EmployeeSelect ( Employee * employee)
static

◆ E_EmployeeSelect_f()

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, E_EmployeeSelect(), E_GetEmployeeByMenuIndex(), and employeesInCurrentList.

◆ E_GetCounts_f()

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, count, E_CountHired(), E_GetEmployeeString(), E_GetEmployeeTypeString(), EMPL_ROBOT, EMPL_SOLDIER, MAX_VAR, Q_strncpyz(), and type.

◆ E_GetEmployeeByMenuIndex()

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

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

◆ E_GetEmployeeTypeString()

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, ERR_DROP, and type.

Referenced by E_GetCounts_f().

◆ E_InitCallbacks()

void E_InitCallbacks ( void )

Register UI callbacks.

Definition at line 368 of file cp_employee_callbacks.cpp.

References cgi, and employeeCmds.

Referenced by E_InitStartup().

◆ E_ShutdownCallbacks()

void E_ShutdownCallbacks ( void )

Unregister UI callbacks.

Definition at line 376 of file cp_employee_callbacks.cpp.

References cgi, and employeeCmds.

Referenced by E_Shutdown().

◆ E_UpdateGUICount_f()

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, E_CountAllHired(), E_CountHired(), EMPL_PILOT, EMPL_SCIENTIST, EMPL_SOLDIER, and EMPL_WORKER.

Referenced by E_EmployeeHire_f().

Variable Documentation

◆ employeeCategory

int employeeCategory = 0
static

Definition at line 35 of file cp_employee_callbacks.cpp.

Referenced by E_EmployeeDelete_f(), and E_EmployeeList_f().

◆ employeeCmds

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_EmployeeDelete_f(void)
This removes an employee from the global list so that he/she is no longer hireable.
static void E_UpdateGUICount_f(void)
Update GUI with the current number of employee per category.
static void E_EmployeeHire_f(void)
Callback for employee_hire command.
static void E_ChangeName_f(void)
Change the name of the selected actor.
static void E_GetCounts_f(void)
Returns the number of employees hired on a base for the UI.
static void E_EmployeeSelect_f(void)
Callback function that updates the character cvars when calling employee_select.
static void E_EmployeeList_f(void)
Will fill the list with employees.

List of UI command callbacks.

Definition at line 353 of file cp_employee_callbacks.cpp.

Referenced by E_InitCallbacks(), and E_ShutdownCallbacks().

◆ employeeList

linkedList_t* employeeList
static

Definition at line 38 of file cp_employee_callbacks.cpp.

Referenced by E_EmployeeList_f(), and E_GetEmployeeByMenuIndex().

◆ employeesInCurrentList

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

◆ selectedEmployee

Employee* selectedEmployee = nullptr
static

Currently selected employee.

Definition at line 33 of file cp_employee_callbacks.cpp.

Referenced by E_EmployeeList_f(), and E_EmployeeSelect().