25 #include "../../cl_shared.h"
33 #include "../../ui/ui_dataids.h"
38 #define POPUP_INTERCEPT_MAX_AIRCRAFT 64
69 int numAvailableBases = 0;
75 cgi->LIST_Delete(&popupListData);
81 while ((base =
B_GetNext(base)) !=
nullptr) {
86 msg =
_(
"current homebase of aircraft");
92 msg =
_(
"base can hold aircraft");
101 cgi->LIST_AddString(&popupListText, text);
105 if (alwaysDisplay || numAvailableBases > 0) {
107 popupListNode =
cgi->
UI_PopupList(
_(
"Change homebase of aircraft"),
_(
"Base\tStatus"), popupListText,
"change_homebase <lineselected>;");
110 cgi->UI_TextNodeSelectLine(popupListNode, homebase);
128 cgi->Com_Printf(
"CL_PopupChangeHomebase_f: An aircraft must be selected\n");
132 if (
cgi->Cmd_Argc() < 2) {
133 cgi->Com_Printf(
"Usage: %s <popupIndex>\tpopupIndex=num in base list\n",
cgi->
Cmd_Argv(0));
139 cgi->Com_DPrintf(
DEBUG_CLIENT,
"CL_PopupHomebaseClick_f (popupNum %i, selectedPopupIndex %i)\n",
popupNum, selectedPopupIndex);
140 if (selectedPopupIndex < 0 || selectedPopupIndex >=
popupNum)
146 for (
int i = 0;
data; data = data->
next,
i++) {
147 if (
i == selectedPopupIndex) {
148 baseIdx = *(
int*)data->
data;
160 cgi->UI_PopWindow(
false);
178 #define AIR_ForeachSorted(var, sorter, userdata, sortedlist) LIST_ForeachSorted(ccs.aircraft, aircraft_t, var, sorter, userdata, sortedlist)
192 popupIntercept.
mission = mission;
193 popupIntercept.
ufo =
nullptr;
205 char aircraftListText[256] =
"";
209 Com_sprintf(aircraftListText,
sizeof(aircraftListText),
_(
"%s (%i/%i)\t%s\t%s\t%s"), aircraft->name,
210 teamSize, aircraft->maxTeamSize, statusName, aircraft->homebase->name, time);
211 cgi->LIST_AddString(&aircraftList, aircraftListText);
218 cgi->LIST_Delete(&aircraftListSorted);
223 cgi->UI_RegisterText(
TEXT_AIRCRAFT_LIST,
_(
"No craft available, no pilot assigned, or no tactical teams assigned to available craft."));
229 cgi->UI_PushWindow(
"popup_mission");
247 popupIntercept.
mission =
nullptr;
248 popupIntercept.
ufo = ufo;
255 char aircraftListText[256] =
"";
258 const char* enoughFuelMarker =
"^B";
262 cgi->Com_DPrintf(
DEBUG_CLIENT,
"CL_DisplayPopupIntercept: No useable weapon found in craft '%s' (%i)\n", aircraft->id, aircraft->maxWeapons);
267 cgi->Com_DPrintf(
DEBUG_CLIENT,
"CL_DisplayPopupIntercept: Target out of reach for craft '%s'\n", aircraft->id);
268 enoughFuelMarker =
"";
271 Com_sprintf(aircraftListText,
sizeof(aircraftListText),
_(
"%s%s (%i/%i)\t%s\t%s"), enoughFuelMarker, aircraft->name,
273 cgi->LIST_AddString(&aircraftList, aircraftListText);
280 cgi->LIST_Delete(&aircraftListSorted);
283 while ((base =
B_GetNext(base)) !=
nullptr) {
287 cgi->LIST_AddString(&baseList,
va(
"^B%s", base->
name));
293 cgi->UI_RegisterText(
TEXT_AIRCRAFT_LIST,
_(
"No craft available, no pilot assigned, or no weapon or ammo equipped."));
299 cgi->LIST_AddString(&baseList,
va(
"^B%s", installation->name));
305 cgi->UI_RegisterText(
TEXT_BASE_LIST,
_(
"No defence system operational or no weapon or ammo equipped."));
311 cgi->UI_PushWindow(
"popup_intercept");
322 if (
cgi->Cmd_Argc() < 2)
330 cgi->UI_PopWindow(
false);
333 return popupIntercept.
aircraft[num];
347 if (aircraft ==
nullptr)
354 CP_Popup(
_(
"Notice"),
_(
"No Command Centre operational in homebase\nof this aircraft.\n\nAircraft cannot start.\n"));
361 else if (popupIntercept.
ufo)
375 if (aircraft ==
nullptr)
382 cgi->UI_PushWindow(
"aircraft");
391 if (
cgi->Cmd_Argc() < 2) {
392 cgi->Com_Printf(
"Usage: %s <num>\tnum=num in base list\n",
cgi->
Cmd_Argv(0));
403 bool atLeastOneBase =
false;
404 while ((base =
B_GetNext(base)) !=
nullptr) {
408 atLeastOneBase =
true;
420 atLeastOneBase =
true;
429 if (!atLeastOneBase && !num) {
434 }
else if (num >= 0) {
435 cgi->Com_Printf(
"CL_PopupInterceptBaseClick_f: Number given in argument (%i) is bigger than number of base in list.\n", num);
439 assert(base || installation);
445 for (i = 0; i < base->numBatteries; i++)
447 for (i = 0; i < base->numLasers; i++)
451 cgi->UI_PopWindow(
false);
473 void CP_Popup (
const char* title,
const char* text, ...)
475 static char msg[1024];
478 va_start(argptr, text);
482 cgi->UI_Popup(title, msg);
uiNode_t *IMPORT * UI_PopupList(const char *title, const char *headline, linkedList_t *entries, const char *clickAction)
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
Safe (null terminating) vsnprintf implementation.
#define AIRFIGHT_WEAPON_CAN_NEVER_SHOOT
#define VectorSet(v, x, y, z)
A installation with all it's data.
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
bool AIR_SendAircraftPursuingUFO(aircraft_t *aircraft, aircraft_t *ufo)
Make the specified aircraft purchasing a UFO.
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...
const char * AIR_AircraftStatusToName(const aircraft_t *aircraft)
Translates the aircraft status id to a translatable string.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
bool AII_InstallationCanShoot(const installation_t *installation)
Check if the installation has a weapon and ammo.
void AIR_MoveAircraftIntoNewHomebase(aircraft_t *aircraft, base_t *base)
Moves a given aircraft to a new base (also the employees and inventory)
#define GEO_GetSelectedAircraft()
void CP_GameTimeStop(void)
Stop game time speed.
A base with all it's data.
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
void GEO_ResetAction(void)
No more special action on the geoscape.
Header file for menu related console command callbacks.
int AIRFIGHT_ChooseWeapon(const aircraftSlot_t *slot, int maxSlot, const vec2_t pos, const vec2_t targetPos)
Choose the weapon an attacking aircraft will use to fire on a target.
bool AIR_AircraftHasEnoughFuel(const aircraft_t *aircraft, const vec2_t destination)
check if aircraft has enough fuel to go to destination, and then come back home
Campaign missions headers.
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
const cgame_import_t * cgi
Campaign geoscape time header.
Header for Geoscape management.
Atomic structure used to define most of the UI.
const installationTemplate_t * installationTemplate
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
bool AIR_CanIntercept(const aircraft_t *aircraft)
int AIR_GetTeamSize(const aircraft_t *aircraft)
Counts the number of soldiers in given aircraft.
Header for slot management related stuff.
bool AIR_SendAircraftToMission(aircraft_t *aircraft, mission_t *mission)
Sends the specified aircraft to specified mission.
Header file for single player campaign control.
#define GEO_GetSelectedUFO()
int AII_BaseCanShoot(const base_t *base)
Check if the base has weapon and ammo.
GLsizei const GLvoid * data
const char * AIR_CheckMoveIntoNewHomebase(const aircraft_t *aircraft, const base_t *base)
Checks if destination base can store an aircraft and its team.
An aircraft with all it's data.
void B_SelectBase(const base_t *base)
Select and opens a base.
void AIR_AircraftSelect(aircraft_t *aircraft)
Sets aircraftCurrent and updates related cvars and menutexts.
const char *IMPORT * Cmd_Argv(int n)
const char * CP_SecondConvert(int second)
Converts a number of second into a char to display.
baseWeapon_t batteries[MAX_INSTALLATION_BATTERIES]
void GEO_SelectAircraft(aircraft_t *aircraft)
Select the specified aircraft on the geoscape.
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.