39#define POPUP_INTERCEPT_MAX_AIRCRAFT 64
41typedef struct popup_intercept_s {
70 int numAvailableBases = 0;
82 while ((base =
B_GetNext(base)) !=
nullptr) {
87 msg =
_(
"current homebase of aircraft");
93 msg =
_(
"base can hold aircraft");
102 cgi->LIST_AddString(&popupListText, text);
106 if (alwaysDisplay || numAvailableBases > 0) {
108 popupListNode =
cgi->UI_PopupList(
_(
"Change homebase of aircraft"),
_(
"Base\tStatus"), popupListText,
"change_homebase <lineselected>;");
129 cgi->Com_Printf(
"CL_PopupChangeHomebase_f: An aircraft must be selected\n");
133 if (
cgi->Cmd_Argc() < 2) {
134 cgi->Com_Printf(
"Usage: %s <popupIndex>\tpopupIndex=num in base list\n",
cgi->Cmd_Argv(0));
139 int selectedPopupIndex = atoi(
cgi->Cmd_Argv(1));
140 cgi->Com_DPrintf(
DEBUG_CLIENT,
"CL_PopupHomebaseClick_f (popupNum %i, selectedPopupIndex %i)\n",
popupNum, selectedPopupIndex);
141 if (selectedPopupIndex < 0 || selectedPopupIndex >=
popupNum)
148 if (
i == selectedPopupIndex) {
149 baseIdx = *(
int*)
data->data;
161 cgi->UI_PopWindow(
false);
179#define AIR_ForeachSorted(var, sorter, userdata, sortedlist) LIST_ForeachSorted(ccs.aircraft, aircraft_t, var, sorter, userdata, sortedlist)
206 char aircraftListText[256] =
"";
210 Com_sprintf(aircraftListText,
sizeof(aircraftListText),
_(
"%s (%i/%i)\t%s\t%s\t%s"), aircraft->name,
211 teamSize, aircraft->maxTeamSize, statusName, aircraft->homebase->name, time);
212 cgi->LIST_AddString(&aircraftList, aircraftListText);
219 cgi->LIST_Delete(&aircraftListSorted);
224 cgi->UI_RegisterText(
TEXT_AIRCRAFT_LIST,
_(
"No craft available, no pilot assigned, or no tactical teams assigned to available craft."));
230 cgi->UI_PushWindow(
"popup_mission");
256 char aircraftListText[256] =
"";
259 const char* enoughFuelMarker =
"^B";
263 cgi->Com_DPrintf(
DEBUG_CLIENT,
"CL_DisplayPopupIntercept: No useable weapon found in craft '%s' (%i)\n", aircraft->id, aircraft->maxWeapons);
268 cgi->Com_DPrintf(
DEBUG_CLIENT,
"CL_DisplayPopupIntercept: Target out of reach for craft '%s'\n", aircraft->id);
269 enoughFuelMarker =
"";
272 Com_sprintf(aircraftListText,
sizeof(aircraftListText),
_(
"%s%s (%i/%i)\t%s\t%s"), enoughFuelMarker, aircraft->name,
274 cgi->LIST_AddString(&aircraftList, aircraftListText);
281 cgi->LIST_Delete(&aircraftListSorted);
284 while ((base =
B_GetNext(base)) !=
nullptr) {
288 cgi->LIST_AddString(&baseList,
va(
"^B%s", base->
name));
294 cgi->UI_RegisterText(
TEXT_AIRCRAFT_LIST,
_(
"No craft available, no pilot assigned, or no weapon or ammo equipped."));
300 cgi->LIST_AddString(&baseList,
va(
"^B%s", installation->name));
306 cgi->UI_RegisterText(
TEXT_BASE_LIST,
_(
"No defence system operational or no weapon or ammo equipped."));
312 cgi->UI_PushWindow(
"popup_intercept");
323 if (
cgi->Cmd_Argc() < 2)
327 num = atoi(
cgi->Cmd_Argv(1));
331 cgi->UI_PopWindow(
false);
348 if (aircraft ==
nullptr)
355 CP_Popup(
_(
"Notice"),
_(
"No Command Centre operational in homebase\nof this aircraft.\n\nAircraft cannot start.\n"));
376 if (aircraft ==
nullptr)
383 cgi->UI_PushWindow(
"aircraft");
392 if (
cgi->Cmd_Argc() < 2) {
393 cgi->Com_Printf(
"Usage: %s <num>\tnum=num in base list\n",
cgi->Cmd_Argv(0));
401 int num = atoi(
cgi->Cmd_Argv(1));
404 bool atLeastOneBase =
false;
405 while ((base =
B_GetNext(base)) !=
nullptr) {
409 atLeastOneBase =
true;
421 atLeastOneBase =
true;
430 if (!atLeastOneBase && !num) {
435 }
else if (num >= 0) {
436 cgi->Com_Printf(
"CL_PopupInterceptBaseClick_f: Number given in argument (%i) is bigger than number of base in list.\n", num);
440 assert(base || installation);
452 cgi->UI_PopWindow(
false);
474void CP_Popup (
const char* title,
const char* text, ...)
476 static char msg[1024];
479 va_start(argptr, text);
483 cgi->UI_Popup(title, msg);
DateTime class definition.
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
static linkedList_t * popupListData
static uiNode_t * popupListNode
Share stuff between the different cgame implementations.
static const short SECONDS_PER_HOUR
bool AIR_CanIntercept(const aircraft_t *aircraft)
const char * AIR_AircraftStatusToName(const aircraft_t *aircraft)
Translates the aircraft status id to a translatable string.
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
bool AIR_SendAircraftToMission(aircraft_t *aircraft, mission_t *mission)
Sends the specified aircraft to specified mission.
void AIR_MoveAircraftIntoNewHomebase(aircraft_t *aircraft, base_t *base)
Moves a given aircraft to a new base (also the employees and inventory).
bool AIR_SendAircraftPursuingUFO(aircraft_t *aircraft, aircraft_t *ufo)
Make the specified aircraft purchasing a UFO.
int AIR_GetTeamSize(const aircraft_t *aircraft)
Counts the number of soldiers in given aircraft.
const char * AIR_CheckMoveIntoNewHomebase(const aircraft_t *aircraft, const base_t *base)
Checks if destination base can store an aircraft and its team.
void AIR_AircraftSelect(aircraft_t *aircraft)
Sets aircraftCurrent and updates related cvars and menutexts.
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.
#define AIRFIGHT_WEAPON_CAN_NEVER_SHOOT
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
void B_SelectBase(const base_t *base)
Select and opens a base.
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
Header file for single player campaign control.
const cgame_import_t * cgi
void GEO_SelectAircraft(aircraft_t *aircraft)
Select the specified aircraft on the geoscape.
void GEO_ResetAction(void)
No more special action on the geoscape.
Header for Geoscape management.
#define GEO_GetSelectedUFO()
#define GEO_GetSelectedAircraft()
int AII_BaseCanShoot(const base_t *base)
Check if the base has weapon and ammo.
bool AII_InstallationCanShoot(const installation_t *installation)
Check if the installation has a weapon and ammo.
Header for slot management related stuff.
Campaign missions headers.
const char * CP_SecondConvert(int second)
Converts a number of second into a char to display.
void CP_GameTimeStop(void)
Stop game time speed.
Campaign geoscape time header.
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
QGL_EXTERN GLsizei const GLvoid * data
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
Safe (null terminating) vsnprintf implementation.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
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...
An aircraft with all it's data.
A base with all it's data.
baseWeapon_t batteries[MAX_BASE_SLOT]
baseWeapon_t lasers[MAX_BASE_SLOT]
A installation with all it's data.
const installationTemplate_t * installationTemplate
baseWeapon_t batteries[MAX_INSTALLATION_BATTERIES]
Atomic structure used to define most of the UI.
#define VectorSet(v, x, y, z)