25 #include "../../cl_shared.h"
26 #include "../../ui/ui_dataids.h"
103 cgi->Com_Printf(
"AII_SelectAircraftSlot: Unknown airequipID: %i\n", type);
203 currentTech = techList;
204 while (*currentTech) {
211 currentTech = techList;
212 while (*currentTech) {
217 cgi->LIST_AddString(&amountList,
va(
"%d", amount));
244 cgi->UI_ExecuteConfunc(
"airequip_display_slot %i 0",
i);
261 for (
int j = 0; j < max; j++, slot++) {
263 if (slot->
pos ==
i) {
266 cgi->UI_ExecuteConfunc(
"airequip_display_slot %i 2",
i);
268 cgi->UI_ExecuteConfunc(
"airequip_display_slot %i 1",
i);
287 cgi->UI_ExecuteConfunc(
"airequip_zone2_color \"1 0 0 1\"");
297 cgi->UI_ExecuteConfunc(
"airequip_zone2_color \"1 1 1 1\"");
302 static char smallbuffer1[256];
303 static char smallbuffer2[128];
304 const char* typeName;
349 typeName =
"unknown";
352 cgi->
Cvar_Set(
"mn_equip_itemtype",
"%s", typeName);
356 Com_sprintf(smallbuffer1,
sizeof(smallbuffer1),
"%s",
_(
"No item assigned.\n"));
357 Q_strcat(smallbuffer1,
sizeof(smallbuffer1),
_(
"This slot is for %s or smaller items."),
365 Q_strcat(smallbuffer1,
sizeof(smallbuffer1),
_(
"This item is functional.\n"));
367 Q_strcat(smallbuffer1,
sizeof(smallbuffer1),
ngettext(
"This item will be installed in %i hour.\n",
370 Q_strcat(smallbuffer1,
sizeof(smallbuffer1),
ngettext(
"%s will be removed in %i hour.\n",
"%s will be removed in %i hours.\n",
372 Q_strcat(smallbuffer1,
sizeof(smallbuffer1),
ngettext(
"%s will be installed in %i hour.\n",
376 Q_strcat(smallbuffer1,
sizeof(smallbuffer1),
ngettext(
"This item will be removed in %i hour.\n",
386 Com_sprintf(smallbuffer2,
sizeof(smallbuffer2),
"%s",
_(
"No ammo assigned to this weapon."));
394 Q_strncpyz(smallbuffer2,
_(
"No ammo needed"),
sizeof(smallbuffer2));
397 *smallbuffer2 =
'\0';
405 #define AIM_LOADING_OK 0
406 #define AIM_LOADING_NOSLOTSELECTED 1
407 #define AIM_LOADING_NOTECHNOLOGYSELECTED 2
408 #define AIM_LOADING_ALIENTECH 3
409 #define AIM_LOADING_TECHNOLOGYNOTRESEARCHED 4
410 #define AIM_LOADING_TOOHEAVY 5
411 #define AIM_LOADING_UNKNOWNPROBLEM 6
412 #define AIM_LOADING_NOWEAPON 7
413 #define AIM_LOADING_NOTUSABLEWITHWEAPON 8
444 if (weapon ==
nullptr)
448 for (k = 0; k < weapon->
numAmmos; k++) {
450 if (usable && item->
idx == usable->
idx)
478 }
else if (slot->
base) {
521 cgi->
Cvar_Set(
"mn_aircraft_item_warning",
_(
"No slot selected."));
524 cgi->
Cvar_Set(
"mn_aircraft_item_warning",
_(
"No item selected."));
527 cgi->
Cvar_Set(
"mn_aircraft_item_warning",
_(
"You can't equip an alien technology."));
530 cgi->
Cvar_Set(
"mn_aircraft_item_warning",
_(
"Technology requested is not yet completed."));
533 cgi->
Cvar_Set(
"mn_aircraft_item_warning",
_(
"This item is too heavy for the selected slot."));
536 cgi->
Cvar_Set(
"mn_aircraft_item_warning",
_(
"Equip a weapon first."));
539 cgi->
Cvar_Set(
"mn_aircraft_item_warning",
_(
"Ammo not usable with current weapon."));
542 cgi->
Cvar_Set(
"mn_aircraft_item_warning",
_(
"Unknown problem."));
550 cgi->UI_ExecuteConfunc(
"airequip_no_item");
553 cgi->UI_ExecuteConfunc(
"airequip_installed_item");
556 cgi->UI_ExecuteConfunc(
"airequip_installable_item");
558 cgi->UI_ExecuteConfunc(
"airequip_noinstallable_item");
569 if (
cgi->Cmd_Argc() != 2) {
581 cgi->UI_ExecuteConfunc(
"airequip_zone2_off");
586 cgi->UI_ExecuteConfunc(
"airequip_zone2_on");
612 if (
cgi->Cmd_Argc() < 2) {
613 cgi->Com_Printf(
"Usage: %s <arg> <zone1|zone2|item>\n",
cgi->
Cmd_Argv(0));
623 if (
cgi->Cmd_Argc() == 3) {
644 cgi->Com_Printf(
"this slot hasn't been found in aircraft electronics slots\n");
656 cgi->Com_Printf(
"this slot hasn't been found in aircraft weapon slots\n");
659 cgi->Com_Printf(
"AIM_AircraftEquipSlotSelect_f : only weapons and electronics have several slots\n");
686 if (
cgi->Cmd_Argc() < 2) {
742 if (!aimSelectedTechnology)
888 if (
cgi->Cmd_Argc() < 2) {
907 if (
cgi->Cmd_Argc() != 2) {
908 cgi->Com_Printf(
"Usage: %s <weapon|ammo|armour|item>\n",
cgi->
Cmd_Argv(0));
916 else if (
Q_streq(name,
"ammo"))
918 else if (
Q_streq(name,
"armour"))
920 else if (
Q_streq(name,
"item"))
923 cgi->Com_Printf(
"AIM_AircraftItemtypeByName_f: Invalid itemtype!\n");
928 cgi->Cmd_ExecuteString(
"airequip_updatemenu %d",
airequipID);
939 {
nullptr,
nullptr,
nullptr}
943 cgi->Cmd_TableAddList(airequipCmds);
948 cgi->Cmd_TableRemoveList(airequipCmds);
const objDef_t * nextItem
const objDef_t * INVSH_GetItemByIDSilent(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
int B_ItemInBase(const objDef_t *item, const base_t *base)
Check if the item has been collected (i.e it is in the storage) in the given base.
static void AIM_AircraftEquipSlotSelect_f(void)
Select the current slot you want to assign the item to.
#define AIM_LOADING_NOWEAPON
technology_t * RS_GetTechByIDX(int techIdx)
Returns the technology pointer for a tech index. You can use this instead of "&ccs.technologies[techIdx]" to avoid having to check valid indices.
void AIM_ShutdownCallbacks(void)
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
QGL_EXTERN GLint GLenum type
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
static void AIM_AircraftItemtypeByName_f(void)
Update the GUI with a named itemtype.
void AII_UpdateAircraftStats(aircraft_t *aircraft)
Update the value of stats array of an aircraft.
static const cmdList_t airequipCmds[]
static void AIM_AircraftEquipMenuClick_f(void)
Set AIM_selectedTechnology to the technology of current selected aircraft item.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
static void AIM_EmphazeAmmoSlotText(void)
Write in red the text in zone ammo (zone 2)
static void AIM_AircraftEquipMenuUpdate(void)
bool AII_AddAmmoToSlot(base_t *base, const technology_t *tech, aircraftSlot_t *slot)
Add an ammo to an aircraft weapon slot.
base_t * B_GetCurrentSelectedBase(void)
returns the currently selected base
static const char * AIM_AircraftItemtypeName(const int equiptype)
Returns the userfriendly name for craftitem types (shown in aircraft equip menu)
static void AIM_CheckAirequipSelectedSlot(const aircraft_t *aircraft)
Check that airequipSelectedSlot is the indice of an existing slot in the aircraft.
const struct objDef_s * ammos[MAX_AMMOS_PER_OBJDEF]
Defines all attributes of objects used in the inventory.
itemWeight_t AII_GetItemWeightBySize(const objDef_t *od)
Returns craftitem weight based on size.
A base with all it's data.
static void AIM_CheckAirequipSelectedZone(aircraftSlot_t *slot)
Check that airequipSelectedZone is available.
const char *IMPORT * Cvar_GetString(const char *varName)
#define AIM_LOADING_NOTUSABLEWITHWEAPON
static void AIM_AircraftEquipZoneSelect_f(void)
Select the current zone you want to assign the item to.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
cvar_t *IMPORT * Cvar_Set(const char *varName, const char *value,...) __attribute__((format(__printf__
aircraft_t * aircraftCurrent
#define ngettext(x, y, cnt)
Header file for menu callback functions used for base and aircraft equip menu.
static void AIM_UpdateAircraftItemList(const aircraftSlot_t *slot)
Update the list of item you can choose.
static void AIM_AircraftEquipRemoveItem_f(void)
Delete an object from a zone.
const cgame_import_t * cgi
void UP_AircraftItemDescription(const objDef_t *item)
Prints the (UFOpaedia and other) description for aircraft items.
This is the technology parsed from research.ufo.
#define AIM_LOADING_NOTECHNOLOGYSELECTED
void AIM_InitCallbacks(void)
#define AIM_LOADING_TECHNOLOGYNOTRESEARCHED
aircraftSlot_t weapons[MAX_AIRCRAFTSLOT]
Atomic structure used to define most of the UI.
#define AIM_LOADING_UNKNOWNPROBLEM
bool AII_AddItemToSlot(base_t *base, const technology_t *tech, aircraftSlot_t *slot, bool nextItem)
Add an item to an aircraft slot.
const objDef_t * nextAmmo
static int airequipSelectedSlot
static void AIM_AircraftEquipAddItem_f(void)
Add selected item to current zone.
static void AIM_CheckAirequipID(void)
Check airequipID value and set the correct values for aircraft items.
static bool AIM_CrafttypeFilter(const base_t *base, aircraftItemType_t filterType, const technology_t *tech)
#define AIM_LOADING_NOSLOTSELECTED
aircraftSlot_t * AII_SelectAircraftSlot(aircraft_t *aircraft, aircraftItemType_t type)
Returns a pointer to the selected slot.
static int AIM_CheckTechnologyIntoSlot(const aircraftSlot_t *slot, const technology_t *tech)
Header for slot management related stuff.
#define AIM_LOADING_TOOHEAVY
bool AIM_SelectableCraftItem(const aircraftSlot_t *slot, const technology_t *tech)
Check if an aircraft item should or should not be displayed in airequip menu.
aircraftItemType_t
All different types of craft items.
static void AIM_AircraftEquipMenuUpdate_f(void)
Fills the weapon and shield list of the aircraft equip menu.
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
bool B_BaseHasItem(const base_t *base, const objDef_t *item)
Check if an item is available on a base.
void AII_AutoAddAmmo(aircraftSlot_t *slot)
Auto add ammo corresponding to weapon, if there is enough in storage.
static int airequipSelectedZone
const char * AII_WeightToName(itemWeight_t weight)
Translate a weight int to a translated string.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
static aircraftItemType_t airequipID
#define AIM_LOADING_ALIENTECH
Header file for single player campaign control.
static void AIM_NoEmphazeAmmoSlotText(void)
Write in white the text in zone ammo (zone 2)
technology_t ** AII_GetCraftitemTechsByType(aircraftItemType_t type)
Returns a list of craftitem technologies for the given type.
void AII_RemoveNextItemFromSlot(base_t *base, aircraftSlot_t *slot, bool ammo)
Cancel replacing item, move nextItem (or optionally its ammo only) back to the base storage...
static technology_t * aimSelectedTechnology
An aircraft with all it's data.
static void AIM_DrawAircraftSlots(const aircraft_t *aircraft)
Draw only slots existing for this aircraft, and emphases selected one.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
const char uiNode_t *IMPORT * UI_AddOption(uiNode_t **tree, const char *name, const char *label, const char *value)
void AII_RemoveItemFromSlot(base_t *base, aircraftSlot_t *slot, bool ammo)
Remove the item from the slot (or optionally its ammo only) and put it the base storage.
itemPos_t
different positions for aircraft items
struct aircraft_s * aircraft
const char *IMPORT * Cmd_Argv(int n)
aircraftSlot_t electronics[MAX_AIRCRAFTSLOT]
const struct objDef_s * weapons[MAX_WEAPONS_PER_OBJDEF]
static void AIM_UpdateItemDescription(bool fromList, bool fromSlot)
Update the item description according to the tech and the slot selected.