UFO: Alien Invasion
Loading...
Searching...
No Matches
cl_hud.cpp
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26#include "../client.h"
27#include "cl_localentity.h"
28#include "cl_actor.h"
29#include "cl_hud.h"
30#include "cl_hud_callbacks.h"
31#include "cl_view.h"
32#include "../cgame/cl_game.h"
33#include "../ui/ui_main.h"
34#include "../ui/ui_popup.h"
35#include "../ui/ui_nodes.h"
36#include "../ui/ui_draw.h"
37#include "../ui/ui_render.h"
38#include "../ui/ui_tooltip.h"
40#include "../renderer/r_draw.h"
41#include "../../common/grid.h"
42
45static cvar_t* cl_hud;
47
48enum {
52
54};
56
69
76
78static char const* const shootTypeStrings[] = {
79 "primaryright",
80 "reaction",
81 "primaryleft",
82 "reloadright",
83 "reloadleft",
84 "stand",
85 "crouch",
86 "headgear"
87};
89
100
102static char const* const moveModeDescriptions[] = {
103 N_("Crouch walk"),
104 N_("Autostand"),
105 N_("Walk"),
106 N_("Crouch walk")
107};
109
110typedef struct reserveShot_s {
114 int TUs;
116
128
132
138void HUD_DisplayMessage (const char* text)
139{
140 assert(text);
141 UI_DisplayNotice(text, cl_hud_message_timeout->integer, cl_hud->string);
142}
143
145{
146 if (LE_IsDead(le))
147 return;
148
149 const Item* item = le->getRightHandItem();
150 if ((!item || !item->def() || !item->isHeldTwoHanded()) && le->getLeftHandItem())
151 item = le->getLeftHandItem();
152
153 const character_t* chr = CL_ActorGetChr(le);
154 assert(chr);
155 const char* tooltip = va(_("%s\nHP: %i/%i TU: %i\n%s"),
156 chr->name, le->HP, le->maxHP, le->TU, (item && item->def()) ? _(item->def()->name) : "");
157
158 const int idx = CL_ActorGetNumber(le);
159 const int reservedTUs = CL_ActorReservedTUs(le, RES_ALL_ACTIVE);
160 UI_ExecuteConfunc("updateactorvalues %i \"%s\" \"%i\" \"%i\" \"%i\" \"%i\" \"%i\" \"%i\" \"%i\" \"%i\" \"%i\" \"%s\"",
161 idx, le->model2->name, le->headSkin, le->HP, le->maxHP, le->TU, le->maxTU, le->morale, le->maxMorale, le->STUN, reservedTUs, tooltip);
162}
163
169{
170 if (buttonStates[button] == state)
171 return;
172
173 const char* prefix;
174
175 switch (state) {
177 prefix = "deselect_";
178 break;
179 case BT_STATE_DISABLE:
180 prefix = "disable_";
181 break;
182 default:
183 prefix = "";
184 break;
185 }
186
187 /* Connect confunc strings to the ones as defined in "menu hud_nohud". */
188 UI_ExecuteConfunc("%s%s", prefix, shootTypeStrings[button]);
189 buttonStates[button] = state;
190}
191
199static int HUD_UsableReactionTUs (const le_t* le)
200{
201 /* Get the amount of usable TUs depending on the state (i.e. is RF on or off?) */
202 if (le->state & STATE_REACTION)
203 /* CL_ActorUsableTUs DOES NOT return the stored value for "reaction" here. */
205
206 /* CL_ActorUsableTUs DOES return the stored value for "reaction" here. */
207 return CL_ActorUsableTUs(le);
208}
209
217{
218 if (!selActor)
219 return false;
220
221 actorHands_t hand;
222 foreachhand(hand) {
223 /* Get weapon (and its ammo) from the hand. */
224 const fireDef_t* fireDef = HUD_GetFireDefinitionForHand(selActor, hand);
225 if (!fireDef)
226 continue;
227
228 const objDef_t* ammo = fireDef->obj;
229 for (int i = 0; i < ammo->numFiredefs[fireDef->weapFdsIdx]; i++) {
230 /* Check if at least one firemode is available for reservation. */
232 return true;
233 }
234 }
235
236 /* No reservation possible */
237 return false;
238}
239
240
249static void HUD_SetShootReservation (const le_t* le, const int tus, const actorHands_t hand, const int fireModeIndex, const objDef_t* weapon)
250{
251 character_t* chr = CL_ActorGetChr(le);
252 assert(chr);
253
255 chr->reservedTus.shotSettings.set(hand, fireModeIndex, weapon);
256}
257
260
270static void HUD_PopupFiremodeReservation (const le_t* le, bool popupReload)
271{
272 /* reset the list */
274
276
277 /* Add list-entry for deactivation of the reservation. */
278 linkedList_t* popupListText = nullptr;
279 LIST_AddPointer(&popupListText, (void*)(_("[0 TU] No reservation")));
280 reserveShot_t reserveShotData = {ACTOR_HAND_NOT_SET, NONE, NONE, NONE};
281 LIST_Add(&popupListData, reserveShotData);
282 int selectedEntry = 0;
283
284 actorHands_t hand;
285 foreachhand(hand) {
286 const fireDef_t* fd = HUD_GetFireDefinitionForHand(le, hand);
287 if (!fd)
288 continue;
289 character_t* chr = CL_ActorGetChr(le);
290 assert(chr);
291
292 const objDef_t* ammo = fd->obj;
293 for (int i = 0; i < ammo->numFiredefs[fd->weapFdsIdx]; i++) {
294 const fireDef_t* ammoFD = &ammo->fd[fd->weapFdsIdx][i];
295 const int time = CL_ActorTimeForFireDef(le, ammoFD);
296 if (CL_ActorUsableTUs(le) + CL_ActorReservedTUs(le, RES_SHOT) >= time) {
297 static char text[MAX_VAR];
298 /* Get firemode name and TUs. */
299 Com_sprintf(text, lengthof(text), _("[%i TU] %s"), time, _(ammoFD->name));
300
301 /* Store text for popup */
302 LIST_AddString(&popupListText, text);
303
304 /* Store Data for popup-callback. */
305 reserveShotData.hand = hand;
306 reserveShotData.fireModeIndex = i;
307 reserveShotData.weaponIndex = ammo->weapons[fd->weapFdsIdx]->idx;
308 reserveShotData.TUs = time;
309 LIST_Add(&popupListData, reserveShotData);
310
311 /* Remember the line that is currently selected (if any). */
312 if (chr->reservedTus.shotSettings.getHand() == hand
314 && chr->reservedTus.shotSettings.getWeapon() == ammo->weapons[fd->weapFdsIdx])
315 selectedEntry = LIST_Count(popupListData) - 1;
316 }
317 }
318 }
319
320 if (LIST_Count(popupListData) > 1 || popupReload) {
321 /* We have more entries than the "0 TUs" one
322 * or we want to simply refresh/display the popup content (no matter how many TUs are left). */
323 popupListNode = UI_PopupList(_("Shot Reservation"), _("Reserve TUs for firing/using."), popupListText, "hud_shotreserve <lineselected>");
324 /* Set color for selected entry. */
325 VectorSet(popupListNode->selectedColor, 0.0, 0.78, 0.0);
326 popupListNode->selectedColor[3] = 1.0;
327 UI_TextNodeSelectLine(popupListNode, selectedEntry);
328 }
329}
330
336{
337 if (!selActor)
338 return;
339
340 /* A second parameter (the value itself will be ignored) was given.
341 * This is used to reset the shot-reservation.*/
342 if (Cmd_Argc() == 2) {
344 } else {
346 }
347}
348
353static void HUD_ShotReserve_f (void)
354{
355 if (Cmd_Argc() < 2) {
356 Com_Printf("Usage: %s <popupindex>\n", Cmd_Argv(0));
357 return;
358 }
359
360 if (!selActor)
361 return;
362
363 /* read and range check */
364 const int selectedPopupIndex = atoi(Cmd_Argv(1));
365 if (selectedPopupIndex < 0 || selectedPopupIndex >= LIST_Count(popupListData))
366 return;
367
368 const reserveShot_t* reserveShotData = (const reserveShot_t*)LIST_GetByIdx(popupListData, selectedPopupIndex);
369 if (!reserveShotData)
370 return;
371
372 if (reserveShotData->weaponIndex == NONE) {
374 return;
375 }
376
378 /* Check if we have enough TUs (again) */
379 if (CL_ActorUsableTUs(selActor) + CL_ActorReservedTUs(selActor, RES_SHOT) >= reserveShotData->TUs) {
380 const objDef_t* od = INVSH_GetItemByIDX(reserveShotData->weaponIndex);
381 if (GAME_ItemIsUseable(od)) {
382 HUD_SetShootReservation(selActor, std::max(0, reserveShotData->TUs), reserveShotData->hand, reserveShotData->fireModeIndex, od);
383 if (popupListNode)
384 UI_TextNodeSelectLine(popupListNode, selectedPopupIndex);
385 }
386 }
387}
388
398static void HUD_DisplayFiremodeEntry (const char* callback, const le_t* actor, const objDef_t* ammo, const weaponFireDefIndex_t weapFdsIdx, const actorHands_t hand, const int index)
399{
400 if (index >= ammo->numFiredefs[weapFdsIdx])
401 return;
402
403 assert(actor);
404 assert(hand == ACTOR_HAND_RIGHT || hand == ACTOR_HAND_LEFT);
405
406 /* We have a defined fd ... */
407 const fireDef_t* fd = &ammo->fd[weapFdsIdx][index];
408 const int time = CL_ActorTimeForFireDef(actor, fd);
409 const int usableTusForRF = HUD_UsableReactionTUs(actor);
410
411 char tuString[MAX_VAR];
412 const char* tooltip;
413 if (usableTusForRF > time) {
414 Com_sprintf(tuString, sizeof(tuString), _("Remaining TUs: %i"), usableTusForRF - time);
415 tooltip = tuString;
416 } else
417 tooltip = _("No remaining TUs left after shot.");
418
419 /* unique identifier of the action */
420 /* @todo use this id as action callback instead of hand and index (we can extend it with any other soldier action we need (open door, reload...)) */
421 char id[32];
422 Com_sprintf(id, sizeof(id), "fire_hand%c_i%i", ACTOR_GET_HAND_CHAR(hand), index);
423
424 const bool status = time <= CL_ActorUsableTUs(actor);
425 UI_ExecuteConfunc("%s firemode %s %c %i %i %i \"%s\" \"%i\" \"%i\" \"%s\"", callback, id, ACTOR_GET_HAND_CHAR(hand),
426 fd->fdIdx, fd->reaction, status, _(fd->name), time, fd->ammo, tooltip);
427
428 /* Display checkbox for reaction firemode */
429 if (fd->reaction) {
430 character_t* chr = CL_ActorGetChr(actor);
431 const bool active = THIS_FIREMODE(&chr->RFmode, hand, fd->fdIdx);
432 /* Change the state of the checkbox. */
433 UI_ExecuteConfunc("%s reaction %s %c %i", callback, id, ACTOR_GET_HAND_CHAR(hand), active);
434 }
435}
436
443static void HUD_DisplayActions (const char* callback, const le_t* actor, actionType_t type)
444{
445 if (!actor)
446 return;
447
448 if (!cls.isOurRound()) {
449 return;
450 }
451
452 const ScopedCommand c(callback, "begin", "end");
453
454 switch (type) {
455 case FIRE_RIGHT: {
456 const actorHands_t hand = ACTOR_HAND_RIGHT;
457 const fireDef_t* fd = HUD_GetFireDefinitionForHand(actor, hand);
458 if (fd == nullptr) {
459 UI_PopWindow();
460 return;
461 }
462
463 const objDef_t* ammo = fd->obj;
464 if (!ammo) {
465 Com_DPrintf(DEBUG_CLIENT, "HUD_DisplayFiremodes: no weapon or ammo found.\n");
466 return;
467 }
468
469 for (int i = 0; i < MAX_FIREDEFS_PER_WEAPON; i++) {
470 /* Display the firemode information (image + text). */
471 HUD_DisplayFiremodeEntry(callback, actor, ammo, fd->weapFdsIdx, hand, i);
472 }
473 }
474 break;
475
476 case RELOAD_RIGHT: {
477 Item* weapon = actor->getRightHandItem();
478
479 /* Reloeadable item in hand. */
480 if (weapon && weapon->def() && weapon->isReloadable()) {
481 containerIndex_t container = CID_RIGHT;
482 const char* actionId = "reload_handr";
483 const int tus = HUD_CalcReloadTime(actor, weapon->def(), container);
484 const bool noAmmo = tus == -1;
485 const bool noTU = actor->TU < tus;
486 UI_ExecuteConfunc("%s reload %s %c %i %i %i", callback, actionId, 'r', tus, !noAmmo, !noTU);
487 }
488 }
489 break;
490
491 case FIRE_LEFT: {
492 const actorHands_t hand = ACTOR_HAND_LEFT;
493 const fireDef_t* fd = HUD_GetFireDefinitionForHand(actor, hand);
494 if (fd == nullptr) {
495 UI_PopWindow();
496 return;
497 }
498
499 const objDef_t* ammo = fd->obj;
500 if (!ammo) {
501 Com_DPrintf(DEBUG_CLIENT, "HUD_DisplayFiremodes: no weapon or ammo found.\n");
502 return;
503 }
504
505 for (int i = 0; i < MAX_FIREDEFS_PER_WEAPON; i++) {
506 /* Display the firemode information (image + text). */
507 HUD_DisplayFiremodeEntry(callback, actor, ammo, fd->weapFdsIdx, hand, i);
508 }
509 }
510 break;
511
512 case RELOAD_LEFT: {
513 Item* weapon = actor->getLeftHandItem();
514
515 /* Reloadable item in hand. */
516 if (weapon && weapon->def() && weapon->isReloadable()) {
517 containerIndex_t container = CID_LEFT;
518 const char* actionId = "reload_handl";
519 const int tus = HUD_CalcReloadTime(actor, weapon->def(), container);
520 const bool noAmmo = tus == -1;
521 const bool noTU = actor->TU < tus;
522 UI_ExecuteConfunc("%s reload %s %c %i %i %i", callback, actionId, 'l', tus, !noAmmo, !noTU);
523 }
524 }
525 break;
526 }
527}
528
533static void HUD_DisplayActions_f (void)
534{
535 if (Cmd_Argc() < 3) {
536 Com_Printf("Usage: %s callback [l|r|L|R]\n", Cmd_Argv(0));
537 return;
538 }
539
540 if (!selActor)
541 return;
542
544 if (strchr(Cmd_Argv(2), 'r') != nullptr) {
546 } else if (strchr(Cmd_Argv(2), 'l') != nullptr) {
547 type = FIRE_LEFT;
548 } else if (strchr(Cmd_Argv(2), 'R') != nullptr) {
550 } else if (strchr(Cmd_Argv(2), 'L') != nullptr) {
552 } else {
553 return;
554 }
555
556 char callback[32];
557 Q_strncpyz(callback, Cmd_Argv(1), sizeof(callback));
558 HUD_DisplayActions(callback, selActor, type);
559}
560
564static void HUD_DisplayFiremodes_f (void)
565{
566 if (Cmd_Argc() < 3) {
567 Com_Printf("Usage: %s callback [l|r]\n", Cmd_Argv(0));
568 return;
569 }
570
571 if (!selActor)
572 return;
573
574 if (selActor->isMoving())
575 return;
576
577 const actorHands_t hand = ACTOR_GET_HAND_INDEX(Cmd_Argv(2)[0]);
579 char callback[32];
580 Q_strncpyz(callback, Cmd_Argv(1), sizeof(callback));
581 HUD_DisplayActions(callback, selActor, type);
582}
583
590static void HUD_UpdateReactionFiremodes (const le_t* actor, const actorHands_t hand, fireDefIndex_t firemodeActive)
591{
592 assert(actor);
593
594 const fireDef_t* fd = HUD_GetFireDefinitionForHand(actor, hand);
595 if (fd == nullptr)
596 return;
597
598 const objDef_t* ammo = fd->obj;
599 const objDef_t* od = ammo->weapons[fd->weapFdsIdx];
600
601 if (!GAME_ItemIsUseable(od))
602 return;
603
604 MSG_Write_PA(PA_REACT_SELECT, actor->entnum, hand, firemodeActive, od ? od->idx : NONE);
605}
606
611{
612 if (Cmd_Argc() < 3) { /* no argument given */
613 Com_Printf("Usage: %s [l|r] <num> num=firemode number\n", Cmd_Argv(0));
614 return;
615 }
616
617 if (!selActor)
618 return;
619
620 const fireDefIndex_t firemode = atoi(Cmd_Argv(2));
621 if (firemode >= MAX_FIREDEFS_PER_WEAPON || firemode < 0) {
622 Com_Printf("HUD_SelectReactionFiremode_f: Firemode out of bounds (%i).\n", firemode);
623 return;
624 }
625
626 const actorHands_t hand = ACTOR_GET_HAND_INDEX(Cmd_Argv(1)[0]);
627 HUD_UpdateReactionFiremodes(selActor, hand, firemode);
628}
629
634static void HUD_RemainingTUs_f (void)
635{
636 if (Cmd_Argc() < 3) {
637 Com_Printf("Usage: %s <type> <popupindex>\n", Cmd_Argv(0));
638 return;
639 }
640
641 const char* type = Cmd_Argv(1);
642 const bool state = Com_ParseBoolean(Cmd_Argv(2));
643
645
646 if (Q_streq(type, "reload_r")) {
648 } else if (Q_streq(type, "reload_l")) {
650 } else if (Q_streq(type, "crouch")) {
652 }
653}
654
658static int HUD_GetMinimumTUsForUsage (const Item* item)
659{
660 assert(item->def());
661
662 const fireDef_t* fd = item->getFastestFireDef();
663
664 return fd ? fd->time : 900;
665}
666
674static int HUD_WeaponCanBeReloaded (const le_t* le, containerIndex_t containerID, const char** reason)
675{
676 const Item* invList = le->inv.getContainer2(containerID);
677
678 /* No weapon in hand. */
679 if (!invList) {
680 *reason = _("No weapon.");
681 return -1;
682 }
683
684 const objDef_t* weapon = invList->def();
685 assert(weapon);
686
687 /* This weapon cannot be reloaded. */
688 if (!weapon->isReloadable()) {
689 *reason = _("Weapon cannot be reloaded.");
690 return -1;
691 }
692
693 /* Weapon is fully loaded. */
694 if (invList->ammoDef() && weapon->ammo == invList->getAmmoLeft()) {
695 *reason = _("No reload possible, already fully loaded.");
696 return -1;
697 }
698
699 /* Weapon is empty or not fully loaded, find ammo of any type loadable to this weapon. */
700 if (!invList->ammoDef() || weapon->ammo > invList->getAmmoLeft()) {
701 const int tuCosts = HUD_CalcReloadTime(le, weapon, containerID);
702 if (tuCosts >= 0) {
703 const int tu = CL_ActorUsableTUs(le);
704 if (tu >= tuCosts)
705 return tuCosts;
706 *reason = _("Not enough TUs for reloading weapon.");
707 } else {
708 /* Found no ammo which could be used for this weapon. */
709 *reason = _("No reload possible, you don't have backup ammo.");
710 }
711 }
712
713 return -1;
714}
715
724static bool HUD_DisplayImpossibleReaction (const le_t* actor)
725{
726 if (!actor)
727 return false;
728
729 /* Given actor does not equal the currently selected actor. */
730 if (!LE_IsSelected(actor))
731 return false;
732
734 return false;
735
736 /* Display 'impossible" (red) reaction buttons */
737 if (actor->state & STATE_REACTION) {
738 Com_Printf("HUD_DisplayImpossibleReaction: Warning! Reaction fire enabled but no suitable weapon found!\n");
739 UI_ExecuteConfunc("startreaction_impos");
741 return false;
742 }
743
744 return true;
745}
746
751static void HUD_DisplayPossibleReaction (const le_t* actor)
752{
753 if (!actor)
754 return;
755 /* Given actor does not equal the currently selected actor. This normally only happens on game-start. */
756 if (!LE_IsSelected(actor))
757 return;
758
760 return;
761
762 /* Display 'usable" (blue) reaction buttons */
763 if (actor->state & STATE_REACTION) {
764 UI_ExecuteConfunc("startreaction");
766 }
767}
768
774int HUD_ReactionFireGetTUs (const le_t* actor)
775{
776 if (!actor)
777 return -1;
778
779 const FiremodeSettings& fmSetting = CL_ActorGetChr(actor)->RFmode;
780 const Item* weapon = actor->getHandItem(fmSetting.getHand());
781
782 if (!weapon)
783 weapon = actor->getRightHandItem();
784 if (!weapon)
785 weapon = actor->getLeftHandItem();
786
787 if (weapon && weapon->ammoDef() && weapon->isWeapon()) {
788 const fireDef_t* fdArray = weapon->getFiredefs();
789 if (fdArray == nullptr)
790 return -1;
791
792 const fireDefIndex_t fmIdx = fmSetting.getFmIdx();
793 if (fmIdx >= 0 && fmIdx < MAX_FIREDEFS_PER_WEAPON) {
794 return CL_ActorTimeForFireDef(actor, &fdArray[fmIdx], true);
795 }
796 }
797
798 return -1;
799}
800
805static void HUD_UpdateButtons (const le_t* le)
806{
807 if (!le)
808 return;
809
810 const int time = CL_ActorUsableTUs(le);
811 /* Crouch/stand button. */
812 if (LE_IsCrouched(le)) {
814 if (time + CL_ActorReservedTUs(le, RES_CROUCH) < TU_CROUCH) {
815 Cvar_Set("mn_crouchstand_tt", _("Not enough TUs for standing up."));
817 } else {
818 Cvar_Set("mn_crouchstand_tt", _("Stand up (%i TU)"), TU_CROUCH);
820 }
821 } else {
823 if (time + CL_ActorReservedTUs(le, RES_CROUCH) < TU_CROUCH) {
824 Cvar_Set("mn_crouchstand_tt", _("Not enough TUs for crouching."));
826 } else {
827 Cvar_Set("mn_crouchstand_tt", _("Crouch (%i TU)"), TU_CROUCH);
829 }
830 }
831
832 /* Crouch/stand reservation checkbox. */
835 UI_ExecuteConfunc("crouch_checkbox_check");
836 Cvar_Set("mn_crouch_reservation_tt", _("%i TUs reserved for crouching/standing up.\nClick to clear."),
839 }
840 } else if (time >= TU_CROUCH) {
842 UI_ExecuteConfunc("crouch_checkbox_clear");
843 Cvar_Set("mn_crouch_reservation_tt", _("Reserve %i TUs for crouching/standing up."), TU_CROUCH);
845 }
846 } else {
848 UI_ExecuteConfunc("crouch_checkbox_disable");
849 Cvar_Set("mn_crouch_reservation_tt", _("Not enough TUs left to reserve for crouching/standing up."));
851 }
852 }
853
854 /* Shot reservation button. mn_shot_reservation_tt is the tooltip text */
855 if (CL_ActorReservedTUs(le, RES_SHOT)) {
857 UI_ExecuteConfunc("reserve_shot_check");
858 Cvar_Set("mn_shot_reservation_tt", _("%i TUs reserved for shooting.\nClick to change.\nRight-Click to clear."),
861 }
862 } else if (HUD_CheckFiremodeReservation()) {
864 UI_ExecuteConfunc("reserve_shot_clear");
865 Cvar_Set("mn_shot_reservation_tt", _("Reserve TUs for shooting."));
867 }
868 } else {
870 UI_ExecuteConfunc("reserve_shot_disable");
871 Cvar_Set("mn_shot_reservation_tt", _("Reserving TUs for shooting not possible."));
873 }
874 }
875
876 /* reaction-fire button */
877 if (!(le->state & STATE_REACTION)) {
878 if (le->inv.holdsReactionFireWeapon() && time >= HUD_ReactionFireGetTUs(le))
880 else
882 } else {
883 if (le->inv.holdsReactionFireWeapon()) {
885 } else {
887 }
888 }
889
890 const char* reason;
891
892 /* Reload buttons */
893 const int rightCanBeReloaded = HUD_WeaponCanBeReloaded(le, CID_RIGHT, &reason);
894 if (rightCanBeReloaded != -1) {
896 Cvar_Set("mn_reloadright_tt", _("Reload weapon (%i TU)."), rightCanBeReloaded);
897 } else {
898 Cvar_Set("mn_reloadright_tt", "%s", reason);
900 }
901
902 const int leftCanBeReloaded = HUD_WeaponCanBeReloaded(le, CID_LEFT, &reason);
903 if (leftCanBeReloaded != -1) {
905 Cvar_Set("mn_reloadleft_tt", _("Reload weapon (%i TU)."), leftCanBeReloaded);
906 } else {
907 Cvar_Set("mn_reloadleft_tt", "%s", reason);
909 }
910
911 const float shootingPenalty = CL_ActorInjuryModifier(le, MODIFIER_SHOOTING);
912 /* Headgear button */
913 const Item* headgear = le->inv.getHeadgear();
914 if (headgear) {
915 const int minheadgeartime = HUD_GetMinimumTUsForUsage(headgear) * shootingPenalty;
916 if (time < minheadgeartime)
918 else
920 } else {
922 }
923
924 /* Weapon firing buttons. */
925 const Item* weaponR = le->getRightHandItem();
926 if (weaponR) {
927 const int minweaponrtime = HUD_GetMinimumTUsForUsage(weaponR) * shootingPenalty;
928 if (time < minweaponrtime)
930 else
932 } else {
934 }
935
936 const Item* weaponL = nullptr;
937 /* check for two-handed weapon - if not, also define weaponL */
938 if (!weaponR || !weaponR->isHeldTwoHanded())
939 weaponL = le->getLeftHandItem();
940 if (weaponL) {
941 const int minweaponltime = HUD_GetMinimumTUsForUsage(weaponL) * shootingPenalty;
942 if (time < minweaponltime)
944 else
946 } else {
948 }
949
950 /* Check if the firemode reservation popup is shown and refresh its content. (i.e. close&open it) */
951 {
952 const char* menuName = UI_GetActiveWindowName();
953 if (menuName[0] != '\0' && strstr(UI_GetActiveWindowName(), POPUPLIST_NODE_NAME)) {
954 /* Update firemode reservation popup. */
956 }
957 }
958}
959
966static void HUD_DrawMouseCursorText (int xOffset, int yOffset, int textId)
967{
968 const char* string = UI_GetText(textId);
969 if (string && cl_show_cursor_tooltips->integer)
970 UI_DrawTooltip(string, mousePosX + xOffset, mousePosY - yOffset, viddef.virtualWidth - mousePosX);
971}
972
977{
978 /* Offset of the first icon on the x-axis. */
979 const int iconOffsetX = 16;
980 le_t* le = selActor;
981 if (le) {
982 /* Offset of the first icon on the y-axis. */
983 int iconOffsetY = 16;
984 /* the space between different icons. */
985 const int iconSpacing = 2;
986 image_t* image;
987 /* icon width */
988 const int iconW = 16;
989 /* icon height. */
990 const int iconH = 16;
991 int width = 0;
992 int bgX = mousePosX + iconOffsetX / 2 - 2;
993
994 /* checks if icons should be drawn */
995 if (!(LE_IsCrouched(le) || (le->state & STATE_REACTION)))
996 /* make place holder for icons */
997 bgX += iconW + 4;
998
999 /* if exists gets width of player name */
1001 R_FontTextSize("f_verysmall", UI_GetText(TEXT_MOUSECURSOR_PLAYERNAMES), viddef.virtualWidth - bgX, LONGLINES_WRAP, &width, nullptr, nullptr, nullptr);
1002
1003 /* gets width of background */
1004 if (width == 0 && UI_GetText(TEXT_MOUSECURSOR_RIGHT)) {
1005 R_FontTextSize("f_verysmall", UI_GetText(TEXT_MOUSECURSOR_RIGHT), viddef.virtualWidth - bgX, LONGLINES_WRAP, &width, nullptr, nullptr, nullptr);
1006 }
1007
1008 /* Display 'crouch' icon if actor is crouched. */
1009 if (LE_IsCrouched(le)) {
1010 image = R_FindImage("pics/cursors/ducked", it_pic);
1011 if (image)
1012 R_DrawImage(mousePosX - image->width / 2 + iconOffsetX, mousePosY - image->height / 2 + iconOffsetY, image);
1013 }
1014
1015 /* Height of 'crouched' icon. */
1016 iconOffsetY += iconH;
1017 iconOffsetY += iconSpacing;
1018
1019 /* Display 'Reaction shot' icon if actor has it activated. */
1020 if (le->state & STATE_REACTION)
1021 image = R_FindImage("pics/cursors/reactionfire", it_pic);
1022 else
1023 image = nullptr;
1024
1025 if (image)
1026 R_DrawImage(mousePosX - image->width / 2 + iconOffsetX, mousePosY - image->height / 2 + iconOffsetY, image);
1027
1028 /* Height of 'reaction fire' icon. ... in case we add further icons below.
1029 iconOffsetY += iconH;
1030 iconOffsetY += iconSpacing;
1031 */
1032
1033 /* Display weaponmode (text) heR_ */
1034 HUD_DrawMouseCursorText(iconOffsetX + iconW, -10, TEXT_MOUSECURSOR_RIGHT);
1035 }
1036
1037 /* playernames */
1040
1041 if (cl_map_debug->integer & MAPDEBUG_TEXT) {
1042 /* Display ceiling text */
1044 /* Display floor text */
1046 /* Display left text */
1048 }
1049}
1050
1055static void HUD_MapDebugCursor (const le_t* le)
1056{
1057 if (!(cl_map_debug->integer & MAPDEBUG_TEXT))
1058 return;
1059
1060 /* Display the floor and ceiling values for the current cell. */
1061 static char topText[UI_MAX_SMALLTEXTLEN];
1062 Com_sprintf(topText, lengthof(topText), "%u-(%i,%i,%i)\n",
1063 Grid_Ceiling(cl.mapData->routing, ACTOR_GET_FIELDSIZE(le), truePos), truePos[0], truePos[1], truePos[2]);
1064 /* Save the text for later display next to the cursor. */
1066
1067 /* Display the floor and ceiling values for the current cell. */
1068 static char bottomText[UI_MAX_SMALLTEXTLEN];
1069 Com_sprintf(bottomText, lengthof(bottomText), "%i-(%i,%i,%i)\n",
1070 Grid_Floor(cl.mapData->routing, ACTOR_GET_FIELDSIZE(le), truePos), mousePos[0], mousePos[1], mousePos[2]);
1071 /* Save the text for later display next to the cursor. */
1073
1074 /* Display the floor and ceiling values for the current cell. */
1075 const int dvec = Grid_MoveNext(&cl.pathMap, mousePos, 0);
1076 static char leftText[UI_MAX_SMALLTEXTLEN];
1077 Com_sprintf(leftText, lengthof(leftText), "%i-%i\n", getDVdir(dvec), getDVz(dvec));
1078 /* Save the text for later display next to the cursor. */
1080}
1081
1087{
1088 const Item* selWeapon;
1089
1090 /* get weapon */
1091 if (IS_MODE_FIRE_HEADGEAR(actor->actorMode)) {
1092 selWeapon = actor->inv.getHeadgear();
1093 } else if (IS_MODE_FIRE_LEFT(actor->actorMode)) {
1094 selWeapon = HUD_GetLeftHandWeapon(actor, nullptr);
1095 } else {
1096 selWeapon = actor->getRightHandItem();
1097 }
1098
1100
1101 if (!selWeapon) {
1102 CL_ActorSetMode(actor, M_MOVE);
1103 return 0;
1104 }
1105
1106 static char infoText[UI_MAX_SMALLTEXTLEN];
1107 int time = 0;
1108 const objDef_t* def = selWeapon->def();
1109 if (!def) {
1110 /* No valid weapon in the hand. */
1111 CL_ActorSetFireDef(actor, nullptr);
1112 } else {
1113 /* Check whether this item uses/has ammo. */
1114 if (!selWeapon->ammoDef()) {
1115 const fireDef_t* old = nullptr;
1116 /* This item does not use ammo, check for existing firedefs in this item. */
1117 /* This is supposed to be a weapon or other usable item. */
1118 if (def->numWeapons > 0) {
1119 if (selWeapon->isWeapon() || def->weapons[0] == def) {
1120 const fireDef_t* fdArray = selWeapon->getFiredefs();
1121 if (fdArray != nullptr) {
1122 /* Get firedef from the weapon (or other usable item) entry instead. */
1123 old = FIRESH_GetFiredef(def, fdArray->weapFdsIdx, actor->currentSelectedFiremode);
1124 }
1125 }
1126 }
1127 CL_ActorSetFireDef(actor, old);
1128 } else {
1129 const fireDef_t* fdArray = selWeapon->getFiredefs();
1130 if (fdArray != nullptr) {
1131 const fireDef_t* old = FIRESH_GetFiredef(selWeapon->ammoDef(), fdArray->weapFdsIdx, actor->currentSelectedFiremode);
1132 /* reset the align if we switched the firemode */
1133 CL_ActorSetFireDef(actor, old);
1134 }
1135 }
1136 }
1137
1138 if (!GAME_ItemIsUseable(def)) {
1139 HUD_DisplayMessage(_("You cannot use this unknown item.\nYou need to research it first."));
1140 CL_ActorSetMode(actor, M_MOVE);
1141 } else if (actor->fd) {
1142 const int hitProbability = CL_GetHitProbability(actor);
1143 static char mouseText[UI_MAX_SMALLTEXTLEN];
1144
1145 Com_sprintf(infoText, lengthof(infoText),
1146 "%s\n%s (%i) [%i%%] %i\n", _(def->name), _(actor->fd->name),
1147 actor->fd->ammo, hitProbability, CL_ActorTimeForFireDef(actor, actor->fd));
1148
1149 /* Save the text for later display next to the cursor. */
1150 Q_strncpyz(mouseText, infoText, lengthof(mouseText));
1152
1153 time = CL_ActorTimeForFireDef(actor, actor->fd);
1154 /* if no TUs left for this firing action
1155 * or if the weapon is reloadable and out of ammo,
1156 * then change to move mode */
1157 if (selWeapon->mustReload() || CL_ActorUsableTUs(actor) < time)
1158 CL_ActorSetMode(actor, M_MOVE);
1159 } else if (selWeapon) {
1160 Com_sprintf(infoText, lengthof(infoText), _("%s\n(empty)\n"), _(def->name));
1161 }
1162
1163 UI_RegisterText(TEXT_STANDARD, infoText);
1164 return time;
1165}
1166
1171static int HUD_UpdateActorMove (const le_t* actor)
1172{
1173 const int reservedTUs = CL_ActorReservedTUs(actor, RES_ALL_ACTIVE);
1174 static char infoText[UI_MAX_SMALLTEXTLEN];
1175 if (actor->actorMoveLength == ROUTING_NOT_REACHABLE) {
1177 if (reservedTUs > 0)
1178 Com_sprintf(infoText, lengthof(infoText), _("Morale %i | Reserved TUs: %i\n"), actor->morale, reservedTUs);
1179 else
1180 Com_sprintf(infoText, lengthof(infoText), _("Morale %i"), actor->morale);
1181 } else {
1182 static char mouseText[UI_MAX_SMALLTEXTLEN];
1183 const int moveMode = CL_ActorMoveMode(actor);
1184 if (reservedTUs > 0)
1185 Com_sprintf(infoText, lengthof(infoText), _("Morale %i | Reserved TUs: %i\n%s %i (%i|%i TUs left)\n"),
1186 actor->morale, reservedTUs, _(moveModeDescriptions[moveMode]), actor->actorMoveLength,
1187 actor->TU - actor->actorMoveLength, actor->TU - reservedTUs - actor->actorMoveLength);
1188 else
1189 Com_sprintf(infoText, lengthof(infoText), _("Morale %i\n%s %i (%i TUs left)\n"), actor->morale,
1190 _(moveModeDescriptions[moveMode]), actor->actorMoveLength, actor->TU - actor->actorMoveLength);
1191
1192 if (actor->actorMoveLength <= CL_ActorUsableTUs(actor))
1193 Com_sprintf(mouseText, lengthof(mouseText), "%i (%i)\n", actor->actorMoveLength, CL_ActorUsableTUs(actor));
1194 else
1195 Com_sprintf(mouseText, lengthof(mouseText), "- (-)\n");
1196
1198 }
1199
1200 UI_RegisterText(TEXT_STANDARD, infoText);
1201
1202 return actor->actorMoveLength;
1203}
1204
1205static void HUD_UpdateActorCvar (const le_t* actor)
1206{
1207 Cvar_SetValue("mn_hp", actor->HP);
1208 Cvar_SetValue("mn_hpmax", actor->maxHP);
1209 Cvar_SetValue("mn_tu", actor->TU);
1210 Cvar_SetValue("mn_tumax", actor->maxTU);
1211 Cvar_SetValue("mn_tureserved", CL_ActorReservedTUs(actor, RES_ALL_ACTIVE));
1212 Cvar_SetValue("mn_morale", actor->morale);
1213 Cvar_SetValue("mn_moralemax", actor->maxMorale);
1214 Cvar_SetValue("mn_stun", actor->STUN);
1215
1216 Cvar_Set("mn_tu_tooltips", _("Time Units\n- Available: %i (of %i)\n- Reserved: %i\n- Remaining: %i\n"),
1217 actor->TU, actor->maxTU, CL_ActorReservedTUs(actor, RES_ALL_ACTIVE), CL_ActorUsableTUs(actor));
1218
1219 /* animation and weapons */
1220 const char* animName = R_AnimGetName(&actor->as, actor->model1);
1221 if (animName)
1222 Cvar_Set("mn_anim", "%s", animName);
1223 if (actor->getRightHandItem()) {
1224 const Item* item = actor->getRightHandItem();
1225 Cvar_Set("mn_rweapon", "%s", item->def()->model);
1226 Cvar_Set("mn_rweapon_item", "%s", item->def()->id);
1227 } else {
1228 Cvar_Set("mn_rweapon", "%s", "");
1229 Cvar_Set("mn_rweapon_item", "%s", "");
1230 }
1231 if (actor->getLeftHandItem()) {
1232 const Item* item = actor->getLeftHandItem();
1233 Cvar_Set("mn_lweapon", "%s", item->def()->model);
1234 Cvar_Set("mn_lweapon_item", "%s", item->def()->id);
1235 } else {
1236 Cvar_Set("mn_lweapon", "%s", "");
1237 Cvar_Set("mn_lweapon_item", "%s", "");
1238 }
1239
1240 /* print ammo */
1241 const Item* itemRight = actor->getRightHandItem();
1242 if (itemRight)
1243 Cvar_SetValue("mn_ammoright", itemRight->getAmmoLeft());
1244 else
1245 Cvar_Set("mn_ammoright", "%s", "");
1246
1247 const Item* itemLeft = HUD_GetLeftHandWeapon(actor, nullptr);
1248 if (itemLeft)
1249 Cvar_SetValue("mn_ammoleft", itemLeft->getAmmoLeft());
1250 else
1251 Cvar_Set("mn_ammoleft", "%s", "");
1252}
1253
1254static const char* HUD_GetPenaltyString (const int type)
1255{
1256 switch (type) {
1257 case MODIFIER_ACCURACY:
1258 return _("- Reduced accuracy");
1259 case MODIFIER_SHOOTING:
1260 return _("- Reduced shooting speed");
1261 case MODIFIER_MOVEMENT:
1262 return _("- Reduced movement speed");
1263 case MODIFIER_SIGHT:
1264 return _("- Reduced sight range");
1265 case MODIFIER_REACTION:
1266 return _("- Reduced reaction speed");
1267 case MODIFIER_TU:
1268 return _("- Reduced TUs");
1269 default:
1270 return "";
1271 }
1272}
1273
1274static void HUD_ActorWoundData_f (void)
1275{
1276 if (!CL_BattlescapeRunning())
1277 return;
1278
1279 /* check if actor exists */
1280 if (!selActor)
1281 return;
1282
1283 woundInfo_t* wounds = &selActor->wounds;
1284 const BodyData* bodyData = selActor->teamDef->bodyTemplate;
1285
1286 for (int bodyPart = 0; bodyPart < bodyData->numBodyParts(); ++bodyPart) {
1287 const int woundThreshold = selActor->maxHP * bodyData->woundThreshold(bodyPart);
1288
1289 if (wounds->woundLevel[bodyPart] + wounds->treatmentLevel[bodyPart] * 0.5 > woundThreshold) {
1290 const int bleeding = wounds->woundLevel[bodyPart] * (wounds->woundLevel[bodyPart] > woundThreshold
1291 ? bodyData->bleedingFactor(bodyPart) : 0);
1292 char text[256];
1293 const char* label;
1294
1295 const bool isRobot = CHRSH_IsTeamDefRobot(selActor->teamDef);
1296 if (bleeding)
1297 label = va(isRobot ? _("%s: deteriorating (%i)\n") : _("%s: bleeding (%i)\n"), _(bodyData->name(bodyPart)), bleeding);
1298 else
1299 label = va(bleeding ? _("%s: damaged\n") : _("%s: wounded\n"), _(bodyData->name(bodyPart)));
1300
1301 Q_strncpyz(text, label, sizeof(text));
1302 if (bleeding)
1303 Q_strcat(text, lengthof(text), _("- HP loss per turn: %i\n"), bleeding);
1304 for (int penalty = MODIFIER_ACCURACY; penalty < MODIFIER_MAX; penalty++)
1305 if (bodyData->penalty(bodyPart, static_cast<modifier_types_t>(penalty)) != 0)
1306 Q_strcat(text, lengthof(text), "%s\n", HUD_GetPenaltyString(penalty));
1307
1308 UI_ExecuteConfunc("actor_wounds %s %i \"%s\" \"%s\"", bodyData->id(bodyPart), bleeding, label, text);
1309 }
1310 }
1311}
1312
1316static void HUD_UpdateActorLoad_f (void)
1317{
1318 if (!CL_BattlescapeRunning())
1319 return;
1320
1321 /* check if actor exists */
1322 if (!selActor)
1323 return;
1324
1325 const character_t* chr = CL_ActorGetChr(selActor);
1326 const int invWeight = selActor->inv.getWeight();
1327 const int maxWeight = GAME_GetChrMaxLoad(chr);
1328 const float penalty = GET_ENCUMBRANCE_PENALTY(invWeight, maxWeight);
1329 const int normalTU = GET_TU(chr->score.skills[ABILITY_SPEED], 1.0f - WEIGHT_NORMAL_PENALTY);
1330 const int tus = GET_TU(chr->score.skills[ABILITY_SPEED], penalty);
1331 const int tuPenalty = tus - normalTU;
1332 int count = 0;
1333
1334 const Container* cont = nullptr;
1335 while ((cont = chr->inv.getNextCont(cont))) {
1336 Item* item = nullptr;
1337 while ((item = cont->getNextItem(item))) {
1338 const fireDef_t* fireDef = item->getFiredefs();
1339 if (fireDef == nullptr)
1340 continue;
1341 for (int i = 0; i < MAX_FIREDEFS_PER_WEAPON; i++) {
1342 const fireDef_t& fd = fireDef[i];
1343 if (fd.time > 0 && fd.time > tus) {
1344 if (count <= 0)
1345 Com_sprintf(popupText, sizeof(popupText), _("This soldier no longer has enough TUs to use the following items:\n\n"));
1346 Q_strcat(popupText, sizeof(popupText), "%s: %s (%i)\n", _(item->def()->name), _(fd.name), fd.time);
1347 ++count;
1348 }
1349 }
1350 }
1351 }
1352
1353 if (count > 0)
1354 UI_Popup(_("Warning"), popupText);
1355
1356 char label[MAX_VAR];
1357 char tooltip[MAX_VAR];
1358 Com_sprintf(label, sizeof(label), "%g/%i %s", invWeight / WEIGHT_FACTOR, maxWeight, _("Kg"));
1359 Com_sprintf(tooltip, sizeof(tooltip), "%s %i (%+i)", _("TU:"), tus, tuPenalty);
1360 UI_ExecuteConfunc("inv_actorload \"%s\" \"%s\" %f %i", label, tooltip, WEIGHT_NORMAL_PENALTY - (1.0f - penalty), count);
1361}
1362
1367static void HUD_UpdateActor (le_t* actor)
1368{
1369 HUD_UpdateActorCvar(actor);
1370 /* write info */
1371 int time = 0;
1372
1373 /* handle actor in a panic */
1374 if (LE_IsPanicked(actor)) {
1375 UI_RegisterText(TEXT_STANDARD, _("Currently panics!\n"));
1377 if (CL_ActorUsableTUs(actor) >= TU_CROUCH)
1378 time = TU_CROUCH;
1381 const Item* item;
1382 containerIndex_t container;
1383
1385 container = CID_RIGHT;
1386 item = actor->getRightHandItem();
1388 container = NONE;
1389 item = HUD_GetLeftHandWeapon(actor, &container);
1390 } else {
1391 container = NONE;
1392 item = nullptr;
1393 }
1394
1395 if (item && item->def() && item->ammoDef() && item->isReloadable()) {
1396 const int reloadtime = HUD_CalcReloadTime(actor, item->def(), container);
1397 if (reloadtime != -1 && reloadtime <= CL_ActorUsableTUs(actor))
1398 time = reloadtime;
1399 }
1400 } else if (CL_ActorFireModeActivated(actor->actorMode)) {
1401 time = HUD_UpdateActorFireMode(actor);
1402 } else {
1403 /* If the mouse is outside the world, and we haven't placed the cursor in pend
1404 * mode already */
1405 if (IN_GetMouseSpace() != MS_WORLD && actor->actorMode < M_PEND_MOVE)
1407 time = HUD_UpdateActorMove(actor);
1408 }
1409
1410 /* Calculate remaining TUs. */
1411 /* We use the full count of TUs since the "reserved" bar is overlaid over this one. */
1412 time = std::max(0, actor->TU - time);
1413 Cvar_Set("mn_turemain", "%i", time);
1414
1415 HUD_MapDebugCursor(actor);
1416}
1417
1428void HUD_Update (void)
1429{
1430 if (cls.state != ca_active)
1431 return;
1432
1433 /* worldlevel */
1434 if (cl_worldlevel->modified) {
1435 for (int i = 0; i < PATHFINDING_HEIGHT; i++) {
1436 int status = 0;
1437 if (i == cl_worldlevel->integer)
1438 status = 2;
1439 else if (i < cl.mapMaxLevel)
1440 status = 1;
1441 UI_ExecuteConfunc("updateLevelStatus %i %i", i, status);
1442 }
1443 cl_worldlevel->modified = false;
1444 }
1445
1446 /* force them empty first */
1447 Cvar_Set("mn_anim", "stand0");
1448 Cvar_Set("mn_rweapon", "%s", "");
1449 Cvar_Set("mn_lweapon", "%s", "");
1450
1451 if (selActor) {
1453 } else if (!cl.numTeamList) {
1454 /* This will stop the drawing of the bars over the whole screen when we test maps. */
1455 Cvar_SetValue("mn_hp", 0);
1456 Cvar_SetValue("mn_hpmax", 100);
1457 Cvar_SetValue("mn_tu", 0);
1458 Cvar_SetValue("mn_tumax", 100);
1459 Cvar_SetValue("mn_tureserved", 0);
1460 Cvar_SetValue("mn_morale", 0);
1461 Cvar_SetValue("mn_moralemax", 100);
1462 Cvar_SetValue("mn_stun", 0);
1463 }
1464}
1465
1473static void HUD_ActorSelectionChangeListener (const char* cvarName, const char* oldValue, const char* newValue, void* data)
1474{
1475 if (!CL_OnBattlescape())
1476 return;
1477
1478 if (newValue[0] != '\0') {
1479 const int actorIdx = atoi(newValue);
1480 const size_t size = lengthof(cl.teamList);
1481 if (actorIdx >= 0 && actorIdx < size)
1482 UI_ExecuteConfunc("hudselect %s", newValue);
1483 }
1484}
1485
1493static void HUD_RightHandChangeListener (const char* cvarName, const char* oldValue, const char* newValue, void* data)
1494{
1495 if (!CL_OnBattlescape())
1496 return;
1497
1498 if (Q_streq(oldValue, newValue))
1499 return;
1500
1502}
1503
1511static void HUD_LeftHandChangeListener (const char* cvarName, const char* oldValue, const char* newValue, void* data)
1512{
1513 if (!CL_OnBattlescape())
1514 return;
1515
1516 if (Q_streq(oldValue, newValue))
1517 return;
1518
1520}
1521
1529static void HUD_TUChangeListener (const char* cvarName, const char* oldValue, const char* newValue, void* data)
1530{
1531 if (!CL_OnBattlescape())
1532 return;
1533
1534 if (Q_streq(oldValue, newValue))
1535 return;
1536
1538}
1539
1540static bool CL_CvarWorldLevel (cvar_t* cvar)
1541{
1542 const int maxLevel = cl.mapMaxLevel ? cl.mapMaxLevel - 1 : PATHFINDING_HEIGHT - 1;
1543 return Cvar_AssertValue(cvar, 0, maxLevel, true);
1544}
1545
1551static bool HUD_CheckCLHud (cvar_t* cvar)
1552{
1553 const uiNode_t* window = UI_GetWindow(cvar->string);
1554 if (window == nullptr) {
1555 return false;
1556 }
1557
1558 if (window->super == nullptr) {
1559 return false;
1560 }
1561
1565 return Q_streq(window->super->name, "hud");
1566}
1567
1572void HUD_InitUI (const char* optionWindowName)
1573{
1575 if (!HUD_CheckCLHud(cl_hud)) {
1576 Cvar_Set("cl_hud", "hud_default");
1577 }
1578 UI_InitStack(cl_hud->string, optionWindowName);
1579
1580 UI_ExecuteConfunc("hudinit");
1581}
1582
1588static bool HUD_CvarCheckMNHud (cvar_t* cvar)
1589{
1590 if (!HUD_CheckCLHud(cl_hud)) {
1591 Cvar_Reset(cvar);
1592 return true;
1593 }
1594 return false;
1595}
1596
1598{
1600
1601 Cmd_AddCommand("hud_remainingtus", HUD_RemainingTUs_f, "Define if remaining TUs should be displayed in the TU-bar for some hovered-over button.");
1602 Cmd_AddCommand("hud_shotreserve", HUD_ShotReserve_f, "Reserve TUs for the selected entry in the popup.");
1603 Cmd_AddCommand("hud_shotreservationpopup", HUD_PopupFiremodeReservation_f, "Pop up a list of possible firemodes for reservation in the current turn.");
1604 Cmd_AddCommand("hud_selectreactionfiremode", HUD_SelectReactionFiremode_f, "Change/Select firemode used for reaction fire.");
1605 Cmd_AddCommand("hud_listfiremodes", HUD_DisplayFiremodes_f, "Display a list of firemodes for a weapon+ammo.");
1606 Cmd_AddCommand("hud_listactions", HUD_DisplayActions_f, "Display a list of action from the selected soldier.");
1607 Cmd_AddCommand("hud_updateactorwounds", HUD_ActorWoundData_f, "Update info on actor wounds.");
1608 Cmd_AddCommand("hud_updateactorload", HUD_UpdateActorLoad_f, "Update the HUD with the selected actor inventory load.");
1609
1611 cl_hud = Cvar_Get("cl_hud", "hud_default", CVAR_ARCHIVE | CVAR_LATCH, "Current selected HUD.");
1613
1614 cl_worldlevel = Cvar_Get("cl_worldlevel", "0", 0, "Current worldlevel in tactical mode.");
1615 Cvar_SetCheckFunction("cl_worldlevel", CL_CvarWorldLevel);
1616 cl_worldlevel->modified = false;
1617
1618 Cvar_Get("mn_ammoleft", "", 0, "The remaining amount of ammunition in the left hand weapon.");
1619 Cvar_Get("mn_lweapon", "", 0, "The left hand weapon model of the current selected actor - empty if no weapon.");
1622
1623 Cvar_Get("mn_ammoright", "", 0, "The remaining amount of ammunition in the right hand weapon.");
1624 Cvar_Get("mn_rweapon", "", 0, "The right hand weapon model of the current selected actor - empty if no weapon.");
1627
1628 Cvar_Get("mn_turemain", "", 0, "Remaining TUs for the current selected actor.");
1630
1632
1633 cl_hud_message_timeout = Cvar_Get("cl_hud_message_timeout", "2000", CVAR_ARCHIVE, "Timeout for HUD messages (milliseconds).");
1634 cl_show_cursor_tooltips = Cvar_Get("cl_show_cursor_tooltips", "1", CVAR_ARCHIVE, "Show cursor tooltips in tactical game mode.");
1635}
bool CHRSH_IsTeamDefRobot(const teamDef_t *const td)
Check if a team definition is a robot.
@ ABILITY_SPEED
Definition chr_shared.h:38
@ RES_REACTION
Definition chr_shared.h:209
@ RES_ALL_ACTIVE
Definition chr_shared.h:213
@ RES_CROUCH
Definition chr_shared.h:210
@ RES_SHOT
Definition chr_shared.h:211
modifier_types_t
Definition chr_shared.h:255
@ MODIFIER_REACTION
Definition chr_shared.h:260
@ MODIFIER_ACCURACY
Definition chr_shared.h:256
@ MODIFIER_SIGHT
Definition chr_shared.h:259
@ MODIFIER_MOVEMENT
Definition chr_shared.h:258
@ MODIFIER_TU
Definition chr_shared.h:261
@ MODIFIER_SHOOTING
Definition chr_shared.h:257
@ MODIFIER_MAX
Definition chr_shared.h:263
void CL_ActorReserveTUs(const le_t *le, const reservation_types_t type, const int tus)
Replace the reserved TUs for a certain type.
Definition cl_actor.cpp:273
pos3_t mousePos
Definition cl_actor.cpp:51
int CL_ActorGetNumber(const le_t *le)
Returns the number of the actor in the teamlist.
Definition cl_actor.cpp:125
int CL_ActorUsableTUs(const le_t *le)
Returns the amount of usable (overall-reserved) TUs for an actor.
Definition cl_actor.cpp:259
void CL_ActorSetMode(le_t *actor, actorModes_t actorMode)
Definition cl_actor.cpp:835
int CL_ActorReservedTUs(const le_t *le, const reservation_types_t type)
Returns the amount of reserved TUs for a certain type.
Definition cl_actor.cpp:214
void CL_ActorSetFireDef(le_t *actor, const fireDef_t *fd)
Definition cl_actor.cpp:91
void MSG_Write_PA(player_action_t playerAction, int entnum,...)
Writes player action with its data.
Definition cl_actor.cpp:73
pos3_t truePos
Definition cl_actor.cpp:50
int CL_ActorMoveMode(const le_t *le)
Decide how the actor will walk, taking into account autostanding.
Definition cl_actor.cpp:102
bool CL_ActorFireModeActivated(const actorModes_t mode)
Checks whether we are in fire mode or node.
le_t * selActor
Definition cl_actor.cpp:49
int CL_ActorTimeForFireDef(const le_t *le, const fireDef_t *fd, bool reaction)
Find the TUs needed for the given fireDef taking into account the actor wound penalties.
Definition cl_actor.cpp:342
character_t * CL_ActorGetChr(const le_t *le)
Returns the character information for an actor in the teamlist.
Definition cl_actor.cpp:155
float CL_ActorInjuryModifier(const le_t *le, const modifier_types_t type)
Returns the actor injury modifier of the specified type.
Definition cl_actor.cpp:299
#define ACTOR_GET_FIELDSIZE(actor)
Definition cl_actor.h:48
@ WALKTYPE_MAX
Definition cl_actor.h:41
int CL_GetHitProbability(const le_t *actor)
Calculates chance to hit if the actor has a fire mode activated.
clientBattleScape_t cl
bool CL_OnBattlescape(void)
Check whether we are in a tactical mission as server or as client. But this only means that we are ab...
bool CL_BattlescapeRunning(void)
Check whether we already have actors spawned on the battlefield.
bool GAME_ItemIsUseable(const objDef_t *od)
Definition cl_game.cpp:1104
int GAME_GetChrMaxLoad(const character_t *chr)
Returns the max weight the given character can carry.
Definition cl_game.cpp:1577
Shared game type headers.
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
static int HUD_UsableReactionTUs(const le_t *le)
Returns the amount of usable "reaction fire" TUs for this actor (depends on active/inactive RF).
Definition cl_hud.cpp:199
static void HUD_UpdateReactionFiremodes(const le_t *actor, const actorHands_t hand, fireDefIndex_t firemodeActive)
Updates the information in RFmode for the selected actor with the given data from the parameters.
Definition cl_hud.cpp:590
static void HUD_UpdateActorLoad_f(void)
Update the equipment weight for the selected actor.
Definition cl_hud.cpp:1316
static void HUD_DisplayFiremodeEntry(const char *callback, const le_t *actor, const objDef_t *ammo, const weaponFireDefIndex_t weapFdsIdx, const actorHands_t hand, const int index)
Sets the display for a single weapon/reload HUD button.
Definition cl_hud.cpp:398
static weaponButtonState_t buttonStates[BT_NUM_TYPES]
Definition cl_hud.cpp:129
static int HUD_UpdateActorFireMode(le_t *actor)
Definition cl_hud.cpp:1086
static reserveButtonState_t crouchReserveButtonState
Definition cl_hud.cpp:131
static void HUD_SetShootReservation(const le_t *le, const int tus, const actorHands_t hand, const int fireModeIndex, const objDef_t *weapon)
Sets TU-reservation and firemode.
Definition cl_hud.cpp:249
void HUD_InitStartup(void)
Definition cl_hud.cpp:1597
static bool HUD_DisplayImpossibleReaction(const le_t *actor)
Display 'impossible' (red) reaction buttons.
Definition cl_hud.cpp:724
static void HUD_PopupFiremodeReservation_f(void)
Creates a (text) list of all firemodes of the currently selected actor.
Definition cl_hud.cpp:335
static reserveButtonState_t shotReserveButtonState
Definition cl_hud.cpp:130
static int HUD_GetMinimumTUsForUsage(const Item *item)
Definition cl_hud.cpp:658
static bool CL_CvarWorldLevel(cvar_t *cvar)
Definition cl_hud.cpp:1540
static void HUD_RightHandChangeListener(const char *cvarName, const char *oldValue, const char *newValue, void *data)
Callback that is called when the right hand weapon of the current selected actor changed.
Definition cl_hud.cpp:1493
static char const *const moveModeDescriptions[]
Definition cl_hud.cpp:102
static const char * HUD_GetPenaltyString(const int type)
Definition cl_hud.cpp:1254
static void HUD_DisplayPossibleReaction(const le_t *actor)
Display 'usable' (blue) reaction buttons.
Definition cl_hud.cpp:751
static void HUD_UpdateButtons(const le_t *le)
Refreshes the weapon/reload buttons on the HUD.
Definition cl_hud.cpp:805
static bool HUD_CheckCLHud(cvar_t *cvar)
Checks that the given cvar is a valid hud cvar.
Definition cl_hud.cpp:1551
weaponButtonState_t
Defines the various states of a button.
Definition cl_hud.cpp:94
@ BT_STATE_SELECT
Definition cl_hud.cpp:98
@ BT_STATE_DESELECT
Definition cl_hud.cpp:97
@ BT_STATE_DISABLE
Definition cl_hud.cpp:96
@ BT_STATE_UNINITIALZED
Definition cl_hud.cpp:95
static bool HUD_CvarCheckMNHud(cvar_t *cvar)
Checks that the given cvar is a valid hud cvar.
Definition cl_hud.cpp:1588
reserveButtonState_t
Definition cl_hud.cpp:117
@ BUTTON_TURESERVE_CROUCH_CLEAR
Definition cl_hud.cpp:126
@ BUTTON_TURESERVE_SHOT_CLEAR
Definition cl_hud.cpp:122
@ BUTTON_TURESERVE_SHOT_DISABLED
Definition cl_hud.cpp:121
@ BUTTON_TURESERVE_CROUCH_RESERVED
Definition cl_hud.cpp:124
@ BUTTON_TURESERVE_CROUCH_DISABLED
Definition cl_hud.cpp:125
@ BUTTON_TURESERVE_SHOT_RESERVED
Definition cl_hud.cpp:120
@ BUTTON_TURESERVE_UNINITIALIZED
Definition cl_hud.cpp:118
void HUD_UpdateCursor(void)
Updates the cursor texts when in battlescape.
Definition cl_hud.cpp:976
static char const *const shootTypeStrings[]
a cbuf string for each button_types_t
Definition cl_hud.cpp:78
@ REMAINING_TU_RELOAD_RIGHT
Definition cl_hud.cpp:49
@ REMAINING_TU_RELOAD_LEFT
Definition cl_hud.cpp:50
@ REMAINING_TU_MAX
Definition cl_hud.cpp:53
@ REMAINING_TU_CROUCH
Definition cl_hud.cpp:51
static void HUD_DisplayActions(const char *callback, const le_t *actor, actionType_t type)
List actions from a soldier to a callback confunc.
Definition cl_hud.cpp:443
static cvar_t * cl_show_cursor_tooltips
Definition cl_hud.cpp:44
void HUD_InitUI(const char *optionWindowName)
Display the user interface.
Definition cl_hud.cpp:1572
actionType_t
Definition cl_hud.cpp:70
@ FIRE_RIGHT
Definition cl_hud.cpp:71
@ FIRE_LEFT
Definition cl_hud.cpp:72
@ RELOAD_RIGHT
Definition cl_hud.cpp:73
@ RELOAD_LEFT
Definition cl_hud.cpp:74
static void HUD_MapDebugCursor(const le_t *le)
Shows map pathfinding debugging parameters (if activated).
Definition cl_hud.cpp:1055
static void HUD_SelectReactionFiremode_f(void)
Checks if the selected firemode checkbox is ok as a reaction firemode and updates data+display.
Definition cl_hud.cpp:610
static void HUD_UpdateActorCvar(const le_t *actor)
Definition cl_hud.cpp:1205
buttonTypes_t
Definition cl_hud.cpp:57
@ BT_RIGHT_FIRE
Definition cl_hud.cpp:58
@ BT_HEADGEAR
Definition cl_hud.cpp:65
@ BT_RIGHT_RELOAD
Definition cl_hud.cpp:61
@ BT_CROUCH
Definition cl_hud.cpp:64
@ BT_LEFT_FIRE
Definition cl_hud.cpp:60
@ BT_STAND
Definition cl_hud.cpp:63
@ BT_LEFT_RELOAD
Definition cl_hud.cpp:62
@ BT_REACTION
Definition cl_hud.cpp:59
@ BT_NUM_TYPES
Definition cl_hud.cpp:67
void HUD_DisplayMessage(const char *text)
Displays a message on the hud.
Definition cl_hud.cpp:138
cvar_t * cl_worldlevel
Definition cl_hud.cpp:46
static cvar_t * cl_hud_message_timeout
Definition cl_hud.cpp:43
static void HUD_TUChangeListener(const char *cvarName, const char *oldValue, const char *newValue, void *data)
Callback that is called when the remaining TUs for the current selected actor changed.
Definition cl_hud.cpp:1529
static void HUD_UpdateActor(le_t *actor)
Updates the hud for one actor.
Definition cl_hud.cpp:1367
static void HUD_LeftHandChangeListener(const char *cvarName, const char *oldValue, const char *newValue, void *data)
Callback that is called when the left hand weapon of the current selected actor changed.
Definition cl_hud.cpp:1511
static linkedList_t * popupListData
Definition cl_hud.cpp:258
static int HUD_WeaponCanBeReloaded(const le_t *le, containerIndex_t containerID, const char **reason)
Checks every case for reload buttons on the HUD.
Definition cl_hud.cpp:674
static void HUD_RemainingTUs_f(void)
Remember if we hover over a button that would cost some TUs when pressed.
Definition cl_hud.cpp:634
static uiNode_t * popupListNode
Definition cl_hud.cpp:259
static void HUD_ActorSelectionChangeListener(const char *cvarName, const char *oldValue, const char *newValue, void *data)
Callback that is called when the cl_selected cvar was changed.
Definition cl_hud.cpp:1473
static void HUD_PopupFiremodeReservation(const le_t *le, bool popupReload)
Creates a (text) list of all firemodes of the currently selected actor.
Definition cl_hud.cpp:270
static int HUD_UpdateActorMove(const le_t *actor)
Definition cl_hud.cpp:1171
static void HUD_DisplayActions_f(void)
Displays the firemodes for the given hand.
Definition cl_hud.cpp:533
void HUD_Update(void)
Updates console vars for an actor.
Definition cl_hud.cpp:1428
static bool displayRemainingTus[REMAINING_TU_MAX]
Definition cl_hud.cpp:55
int HUD_ReactionFireGetTUs(const le_t *actor)
Get the weapon firing TUs for reaction fire.
Definition cl_hud.cpp:774
static void HUD_ActorWoundData_f(void)
Definition cl_hud.cpp:1274
static void HUD_DrawMouseCursorText(int xOffset, int yOffset, int textId)
Draw the mouse cursor tooltips in battlescape.
Definition cl_hud.cpp:966
static cvar_t * cl_hud
Definition cl_hud.cpp:45
static void HUD_ShotReserve_f(void)
Get selected firemode in the list of the currently selected actor.
Definition cl_hud.cpp:353
void HUD_UpdateActorStats(const le_t *le)
Definition cl_hud.cpp:144
static void HUD_DisplayFiremodes_f(void)
Displays the firemodes for the given hand.
Definition cl_hud.cpp:564
static bool HUD_CheckFiremodeReservation(void)
Check if at least one firemode is available for reservation.
Definition cl_hud.cpp:216
static void HUD_SetWeaponButton(buttonTypes_t button, weaponButtonState_t state)
Sets the display for a single weapon/reload HUD button.
Definition cl_hud.cpp:168
HUD related routines.
#define ACTOR_GET_HAND_INDEX(hand)
Definition cl_hud.h:34
#define ACTOR_GET_HAND_CHAR(hand)
Definition cl_hud.h:32
Item * HUD_GetLeftHandWeapon(const le_t *actor, containerIndex_t *container)
returns the weapon the actor's left hand is touching. In case the actor holds a two handed weapon in ...
int HUD_CalcReloadTime(const le_t *le, const objDef_t *weapon, containerIndex_t toContainer)
Calculate total reload time for selected actor.
void HUD_InitCallbacks(void)
const fireDef_t * HUD_GetFireDefinitionForHand(const le_t *actor, const actorHands_t hand)
Returns the fire definition of the item the actor has in the given hand.
int mousePosY
Definition cl_input.cpp:76
int mousePosX
Definition cl_input.cpp:76
#define IN_GetMouseSpace()
Definition cl_input.h:48
@ MS_WORLD
Definition cl_input.h:34
static int fireModeIndex
#define LE_IsDead(le)
#define LE_IsPanicked(le)
#define IS_MODE_FIRE_HEADGEAR(x)
#define IS_MODE_FIRE_LEFT(x)
#define LE_IsCrouched(le)
#define LE_IsSelected(le)
@ M_MOVE
@ M_PEND_MOVE
client_static_t cls
Definition cl_main.cpp:83
void R_FontTextSize(const char *fontId, const char *text, int maxWidth, longlines_t method, int *width, int *height, int *lines, bool *isTruncated)
Supply information about the size of the text when it is linewrapped and rendered,...
Definition r_font.cpp:522
@ LONGLINES_WRAP
#define _(String)
Definition cl_shared.h:44
#define N_(String)
Definition cl_shared.h:46
@ ca_active
Definition cl_shared.h:80
viddef_t viddef
Definition cl_video.cpp:34
cvar_t * cl_map_debug
Definition cl_view.cpp:41
#define MAPDEBUG_TEXT
cvar debug_map options: debug_map is a bit mask, like the developer cvar. There is no ALL bit....
Definition cl_view.h:63
float woundThreshold(const short bodyPart) const
const char * name(const short bodyPart) const
short numBodyParts(void) const
float penalty(const short bodyPart, const modifier_types_t type) const
const char * id(void) const
float bleedingFactor(const short bodyPart) const
Item * getNextItem(const Item *prev) const
void set(const actorHands_t hand, const fireDefIndex_t fmIdx, const objDef_t *weapon)
Definition chr_shared.h:173
actorHands_t getHand() const
Definition chr_shared.h:165
const objDef_t * getWeapon() const
Definition chr_shared.h:161
int getFmIdx() const
Definition chr_shared.h:157
bool holdsReactionFireWeapon() const
Checks if there is a weapon in the hands that can be used for reaction fire.
Item * getHeadgear() const
Item * getContainer2(const containerIndex_t idx) const
Definition inv_shared.h:546
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
item instance data, with linked list capability
Definition inv_shared.h:402
const objDef_t * ammoDef(void) const
Definition inv_shared.h:460
int getAmmoLeft() const
Definition inv_shared.h:466
bool mustReload() const
Definition inv_shared.h:483
const fireDef_t * getFastestFireDef() const
const objDef_t * def(void) const
Definition inv_shared.h:469
bool isWeapon() const
Definition inv_shared.h:486
const fireDef_t * getFiredefs() const
Returns the firedefinitions for a given weapon/ammo.
bool isReloadable() const
Definition inv_shared.h:479
bool isHeldTwoHanded() const
Definition inv_shared.h:476
Primary header for client.
const char * Cmd_Argv(int arg)
Returns a given argument.
Definition cmd.cpp:516
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
Definition cmd.cpp:505
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
Definition cmd.cpp:744
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
Definition common.cpp:440
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
cvarChangeListener_t * Cvar_RegisterChangeListener(const char *varName, cvarChangeListenerFunc_t listenerFunc)
Registers a listener that is executed each time a cvar changed its value.
Definition cvar.cpp:446
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
Definition cvar.cpp:671
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
Definition cvar.cpp:615
bool Cvar_SetCheckFunction(const char *varName, bool(*check)(cvar_t *cvar))
Set a checker function for cvar values.
Definition cvar.cpp:139
bool Cvar_AssertValue(cvar_t *cvar, float minVal, float maxVal, bool shouldBeIntegral)
Checks cvar values.
Definition cvar.cpp:161
void Cvar_Reset(cvar_t *cvar)
Sets the cvar value back to the old value.
Definition cvar.cpp:241
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
Definition cvar.cpp:342
#define CVAR_ARCHIVE
Definition cvar.h:40
#define CVAR_LATCH
Definition cvar.h:44
#define ROUTING_NOT_REACHABLE
Definition defines.h:283
#define DEBUG_CLIENT
Definition defines.h:59
#define NONE
Definition defines.h:68
#define TU_CROUCH
Definition defines.h:72
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
Definition defines.h:294
int Grid_MoveNext(const pathing_t *path, const pos3_t toPos, byte crouchingState)
Get the direction to use to move to a position (used to reconstruct the path).
Definition grid.cpp:719
unsigned int Grid_Ceiling(const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos)
Returns the height of the floor in a cell.
Definition grid.cpp:741
int Grid_Floor(const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos)
Returns the height of the floor in a cell.
Definition grid.cpp:754
Battlescape grid functions.
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
const fireDef_t * FIRESH_GetFiredef(const objDef_t *obj, const weaponFireDefIndex_t weapFdsIdx, const fireDefIndex_t fdIdx)
Get the fire definitions for a given object.
int32_t weaponFireDefIndex_t
Definition inv_shared.h:77
int32_t fireDefIndex_t
Definition inv_shared.h:78
int32_t containerIndex_t
Definition inv_shared.h:46
#define MAX_FIREDEFS_PER_WEAPON
Definition inv_shared.h:42
#define foreachhand(hand)
Definition inv_shared.h:634
#define CID_LEFT
Definition inv_shared.h:48
#define CID_RIGHT
Definition inv_shared.h:47
actorHands_t
Definition inv_shared.h:626
@ ACTOR_HAND_LEFT
Definition inv_shared.h:629
@ ACTOR_HAND_NOT_SET
Definition inv_shared.h:627
@ ACTOR_HAND_RIGHT
Definition inv_shared.h:628
#define THIS_FIREMODE(fm, HAND, fdIdx)
Definition inv_shared.h:654
voidpf void uLong size
Definition ioapi.h:42
void LIST_AddString(linkedList_t **listDest, const char *data)
Adds an string to a new or to an already existing linked list. The string is copied here.
Definition list.cpp:139
void LIST_Delete(linkedList_t **list)
Definition list.cpp:195
void * LIST_GetByIdx(linkedList_t *list, int index)
Get an entry of a linked list by its index in the list.
Definition list.cpp:362
int LIST_Count(const linkedList_t *list)
Definition list.cpp:344
void LIST_AddPointer(linkedList_t **listDest, void *data)
Adds just a pointer to a new or to an already existing linked list.
Definition list.cpp:153
#define getDVz(dv)
Definition mathlib.h:251
#define getDVdir(dv)
Definition mathlib.h:249
#define WEIGHT_NORMAL_PENALTY
Definition q_shared.h:283
#define GET_TU(ab, md)
Definition q_shared.h:291
#define WEIGHT_FACTOR
Definition q_shared.h:285
#define GET_ENCUMBRANCE_PENALTY(weight, max)
Definition q_shared.h:287
#define STATE_REACTION
Definition q_shared.h:272
@ PA_REACT_SELECT
Definition q_shared.h:197
void R_DrawImage(float x, float y, const image_t *image)
Draws an image or parts of it.
Definition r_draw.cpp:341
QGL_EXTERN GLuint count
Definition r_gl.h:99
QGL_EXTERN GLsizei const GLvoid * data
Definition r_gl.h:89
QGL_EXTERN GLuint index
Definition r_gl.h:110
QGL_EXTERN GLint i
Definition r_gl.h:113
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
Definition r_image.cpp:603
@ it_pic
Definition r_image.h:45
const char * R_AnimGetName(const animState_t *as, const model_t *mod)
Get the current running animation for a model.
bool Com_ParseBoolean(const char *token)
Parses a boolean from a string.
Definition scripts.cpp:986
#define Q_streq(a, b)
Definition shared.h:136
#define OBJZERO(obj)
Definition shared.h:178
#define MAX_VAR
Definition shared.h:36
#define lengthof(x)
Definition shared.h:105
#define CASSERT(x)
Definition shared.h:107
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
Definition shared.cpp:457
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
Definition shared.cpp:475
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Definition shared.cpp:494
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...
Definition shared.cpp:410
Describes a character with all its attributes.
Definition chr_shared.h:388
chrReservations_t reservedTus
Definition chr_shared.h:415
chrScoreGlobal_t score
Definition chr_shared.h:406
FiremodeSettings RFmode
Definition chr_shared.h:416
char name[MAX_VAR]
Definition chr_shared.h:390
Inventory inv
Definition chr_shared.h:411
FiremodeSettings shotSettings
Definition chr_shared.h:196
int skills[SKILL_NUM_TYPES]
Definition chr_shared.h:122
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition cvar.h:71
char * string
Definition cvar.h:73
this is a fire definition for our weapons/ammo
Definition inv_shared.h:110
fireDefIndex_t fdIdx
Definition inv_shared.h:130
const char * name
Definition inv_shared.h:111
const struct objDef_s * obj
Definition inv_shared.h:125
bool reaction
Definition inv_shared.h:139
weaponFireDefIndex_t weapFdsIdx
Definition inv_shared.h:126
int height
Definition r_image.h:64
int width
Definition r_image.h:64
a local entity
int state
Item * getLeftHandItem() const
fireDefIndex_t currentSelectedFiremode
actorModes_t actorMode
int morale
Item * getRightHandItem() const
int maxMorale
int maxTU
animState_t as
const fireDef_t * fd
model_t * model1
byte actorMoveLength
The TUs that the current selected actor needs to walk to the current grid position marked by the mous...
unsigned int headSkin
int entnum
model_t * model2
int maxHP
Item * getHandItem(actorHands_t hand) const
Inventory inv
char name[MAX_QPATH]
Definition r_model.h:44
Defines all attributes of objects used in the inventory.
Definition inv_shared.h:264
fireDef_t fd[MAX_WEAPONS_PER_OBJDEF][MAX_FIREDEFS_PER_WEAPON]
Definition inv_shared.h:314
fireDefIndex_t numFiredefs[MAX_WEAPONS_PER_OBJDEF]
Definition inv_shared.h:315
bool isReloadable() const
Definition inv_shared.h:352
const char * model
Definition inv_shared.h:269
const char * id
Definition inv_shared.h:268
int numWeapons
Definition inv_shared.h:317
const struct objDef_s * weapons[MAX_WEAPONS_PER_OBJDEF]
Definition inv_shared.h:311
const char * name
Definition inv_shared.h:267
actorHands_t hand
Definition cl_hud.cpp:111
int fireModeIndex
Definition cl_hud.cpp:112
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80
uiNode_t const * super
Definition ui_nodes.h:84
char name[MAX_VAR]
Definition ui_nodes.h:82
Info on a wound.
Definition chr_shared.h:361
int woundLevel[BODYPART_MAXTYPE]
Definition chr_shared.h:362
int treatmentLevel[BODYPART_MAXTYPE]
Definition chr_shared.h:363
void UI_ResetData(int dataId)
Reset a shared data. Type became NONE and value became nullptr.
Definition ui_data.cpp:212
void UI_RegisterText(int dataId, const char *text)
share a text with a data id
Definition ui_data.cpp:115
const char * UI_GetText(int textId)
Definition ui_data.cpp:144
@ TEXT_MOUSECURSOR_LEFT
Definition ui_dataids.h:60
@ TEXT_MOUSECURSOR_TOP
Definition ui_dataids.h:58
@ TEXT_LIST
Definition ui_dataids.h:31
@ TEXT_STANDARD
Definition ui_dataids.h:30
@ TEXT_MOUSECURSOR_RIGHT
Definition ui_dataids.h:45
@ TEXT_MOUSECURSOR_BOTTOM
Definition ui_dataids.h:59
@ TEXT_MOUSECURSOR_PLAYERNAMES
Definition ui_dataids.h:48
void UI_DisplayNotice(const char *text, int time, const char *windowName)
Displays a message over all windows.
Definition ui_draw.cpp:411
void UI_ExecuteConfunc(const char *fmt,...)
Executes confunc - just to identify those confuncs in the code - in this frame.
Definition ui_main.cpp:110
void UI_TextNodeSelectLine(uiNode_t *node, int num)
Change the selected line.
void UI_Popup(const char *title, const char *text)
Popup on geoscape.
Definition ui_popup.cpp:47
uiNode_t * UI_PopupList(const char *title, const char *headline, linkedList_t *entries, const char *clickAction)
Generates a popup that contains a list of selectable choices.
Definition ui_popup.cpp:62
char popupText[UI_MAX_SMALLTEXTLEN]
strings to be used for popup when text is not static
Definition ui_popup.cpp:37
#define UI_MAX_SMALLTEXTLEN
Definition ui_popup.h:34
#define POPUPLIST_NODE_NAME
Definition ui_popup.h:30
int UI_DrawTooltip(const char *string, int x, int y, int maxWidth)
Generic tooltip function.
uiNode_t * UI_GetWindow(const char *name)
Searches all windows for the specified one.
void UI_PopWindow(bool all)
Pops a window from the window stack.
void UI_InitStack(const char *activeWindow, const char *mainWindow)
Init the stack to start with a window, and have an alternative window with ESC.
const char * UI_GetActiveWindowName(void)
Returns the name of the current window.
#define VectorSet(v, x, y, z)
Definition vector.h:59