1 //**************************************************************************
3 //** ## ## ## ## ## #### #### ### ###
4 //** ## ## ## ## ## ## ## ## ## ## #### ####
5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ##
6 //** ## ## ######## ## ## ## ## ## ## ## ### ##
7 //** ### ## ## ### ## ## ## ## ## ##
8 //** # ## ## # #### #### ## ##
10 //** Copyright (C) 1999-2006 Jānis Legzdiņš
11 //** Copyright (C) 2018-2023 Ketmar Dark
13 //** This program is free software: you can redistribute it and/or modify
14 //** it under the terms of the GNU General Public License as published by
15 //** the Free Software Foundation, version 3 of the License ONLY.
17 //** This program is distributed in the hope that it will be useful,
18 //** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 //** GNU General Public License for more details.
22 //** You should have received a copy of the GNU General Public License
23 //** along with this program. If not, see <http://www.gnu.org/licenses/>.
25 //**************************************************************************
29 //**************************************************************************
31 #include "host.h" /* host_frametime */
34 #include "client/client.h"
35 #include "client/cl_local.h"
37 #include "psim/p_player.h"
38 #include "render/r_public.h"
48 extern VCvarI screen_size
;
53 static VCvarS
sb_color_ammo1("sb_color_ammo1", "default", "StatusBar ammo number color.", CVAR_Archive
|CVAR_NoShadow
);
54 static VCvarS
sb_color_ammo2("sb_color_ammo2", "default", "StatusBar ammo number color.", CVAR_Archive
|CVAR_NoShadow
);
55 static VCvarS
sb_color_armor("sb_color_armor", "default", "StatusBar armor number color.", CVAR_Archive
|CVAR_NoShadow
);
56 static VCvarS
sb_color_health("sb_color_health", "default", "StatusBar health number color.", CVAR_Archive
|CVAR_NoShadow
);
57 static VCvarS
sb_color_healthaccum("sb_color_healthaccum", "default", "StatusBar health accumulator number color.", CVAR_Archive
|CVAR_NoShadow
);
58 static VCvarS
sb_color_frags("sb_color_frags", "default", "StatusBar frags number color.", CVAR_Archive
|CVAR_NoShadow
);
60 static VCvarS
sb_color_small_ammo("sb_color_small_ammo", "default", "StatusBar small ammo color.", CVAR_Archive
|CVAR_NoShadow
);
61 static VCvarS
sb_color_small_ammomax("sb_color_small_ammomax", "default", "StatusBar small max ammo color.", CVAR_Archive
|CVAR_NoShadow
);
62 static VCvarS
sb_color_itemamount("sb_color_itemamount", "default", "StatusBar item amount color.", CVAR_Archive
|CVAR_NoShadow
);
64 static VCvarS
sb_color_weaponammo_full("sb_color_weaponammo_full", "default", "StatusBar FS small ammo number color (full).", CVAR_Archive
|CVAR_NoShadow
);
65 static VCvarS
sb_color_weaponammo_normal("sb_color_weaponammo_normal", "default", "StatusBar FS small ammo number color (normal).", CVAR_Archive
|CVAR_NoShadow
);
66 static VCvarS
sb_color_weaponammo_lower("sb_color_weaponammo_lower", "default", "StatusBar FS small ammo number color (lower).", CVAR_Archive
|CVAR_NoShadow
);
67 static VCvarS
sb_color_weaponammo_low("sb_color_weaponammo_low", "default", "StatusBar FS small ammo number color (low).", CVAR_Archive
|CVAR_NoShadow
);
68 static VCvarS
sb_color_weaponammo_verylow("sb_color_weaponammo_verylow", "default", "StatusBar FS small ammo number color (very low/empty).", CVAR_Archive
|CVAR_NoShadow
);
70 static VCvarS
sb_color_weapon_name("sb_color_weapon_name", "default", "StatusBar FS weapon name color.", CVAR_Archive
|CVAR_NoShadow
);
72 static VCvarS
sb_color_automap_mapname("sb_color_automap_mapname", "default", "Automap stats: map name color.", CVAR_Archive
|CVAR_NoShadow
);
73 static VCvarS
sb_color_automap_mapcluster("sb_color_automap_mapcluster", "default", "Automap stats: map cluster info color.", CVAR_Archive
|CVAR_NoShadow
);
74 static VCvarS
sb_color_automap_kills("sb_color_automap_kills", "default", "Automap stats: number of kills color.", CVAR_Archive
|CVAR_NoShadow
);
75 static VCvarS
sb_color_automap_items("sb_color_automap_items", "default", "Automap stats: number of items color.", CVAR_Archive
|CVAR_NoShadow
);
76 static VCvarS
sb_color_automap_secrets("sb_color_automap_secrets", "default", "Automap stats: number of secrets color.", CVAR_Archive
|CVAR_NoShadow
);
77 static VCvarS
sb_color_automap_totaltime("sb_color_automap_totaltime", "default", "Automap stats: total playing time color.", CVAR_Archive
|CVAR_NoShadow
);
80 static ColorCV
sbColorAmmo1(&sb_color_ammo1
, nullptr, true); // allow "no color"
81 static ColorCV
sbColorAmmo2(&sb_color_ammo2
, nullptr, true); // allow "no color"
82 static ColorCV
sbColorArmor(&sb_color_armor
, nullptr, true); // allow "no color"
83 static ColorCV
sbColorHealth(&sb_color_health
, nullptr, true); // allow "no color"
84 static ColorCV
sbColorHealthAccum(&sb_color_healthaccum
, nullptr, true); // allow "no color"
85 static ColorCV
sbColorFrags(&sb_color_frags
, nullptr, true); // allow "no color"
87 static ColorCV
sbColorSmallAmmo(&sb_color_small_ammo
, nullptr, true); // allow "no color"
88 static ColorCV
sbColorSmallAmmoMax(&sb_color_small_ammomax
, nullptr, true); // allow "no color"
89 static ColorCV
sbColorItemAmount(&sb_color_itemamount
, nullptr, true); // allow "no color"
91 static ColorCV
sbColorWeaponAmmoFull(&sb_color_weaponammo_full
, nullptr, true); // allow "no color"
92 static ColorCV
sbColorWeaponAmmoNormal(&sb_color_weaponammo_normal
, nullptr, true); // allow "no color"
93 static ColorCV
sbColorWeaponAmmoLower(&sb_color_weaponammo_lower
, nullptr, true); // allow "no color"
94 static ColorCV
sbColorWeaponAmmoLow(&sb_color_weaponammo_low
, nullptr, true); // allow "no color"
95 static ColorCV
sbColorWeaponAmmoVeryLow(&sb_color_weaponammo_verylow
, nullptr, true); // allow "no color"
97 static ColorCV
sbColorWeaponName(&sb_color_weapon_name
, nullptr, true); // allow "no color"
99 static ColorCV
sbColorAutomapMapName(&sb_color_automap_mapname
, nullptr, true); // allow "no color"
100 static ColorCV
sbColorAutomapMapCluster(&sb_color_automap_mapcluster
, nullptr, true); // allow "no color"
101 static ColorCV
sbColorAutomapKills(&sb_color_automap_kills
, nullptr, true); // allow "no color"
102 static ColorCV
sbColorAutomapItems(&sb_color_automap_items
, nullptr, true); // allow "no color"
103 static ColorCV
sbColorAutomapSecrets(&sb_color_automap_secrets
, nullptr, true); // allow "no color"
104 static ColorCV
sbColorAutomapTotalTime(&sb_color_automap_totaltime
, nullptr, true); // allow "no color"
107 //==========================================================================
111 //==========================================================================
112 int SB_RealHeight () {
113 //return (int)(ScreenHeight/640.0f*sb_height*R_GetAspectRatio());
114 return (int)(ScreenHeight
/480.0f
*sb_height
*R_GetAspectRatio());
118 //==========================================================================
122 //==========================================================================
124 sb_height
= GClGame
->sb_height
;
128 //==========================================================================
132 //==========================================================================
134 if (cl
&& cls
.signon
&& cl
->MO
) {
135 GClGame
->eventStatusBarUpdateWidgets(host_frametime
);
136 } else if (GClGame
) {
137 GClGame
->eventStatusBarUpdateWidgetsNotInGame(host_frametime
);
142 //==========================================================================
146 //==========================================================================
147 bool SB_Responder (event_t
*ev
) {
149 if (!GClGame
) return false;
150 if (!cl
|| !cls
.signon
|| !cl
->MO
|| cls
.demoplayback
) return false;
151 return GClGame
->eventStatusBarResponder(ev
);
155 //==========================================================================
159 //==========================================================================
161 // update widget visibility
162 if (AM_IsFullscreen() && screen_size
>= 11) return;
163 if (!GClLevel
) return;
164 if (!CL_NeedAutomapUpdates()) return; // camera is not on the player
165 GClGame
->eventStatusBarDrawer(AM_IsFullscreen() && screen_size
< 11 ?
167 GClLevel
->Renderer
->refdef
.height
== ScreenHeight
? SB_VIEW_FULLSCREEN
: SB_VIEW_NORMAL
);
171 //==========================================================================
175 //==========================================================================
177 GClGame
->eventStatusBarStartMap();
181 //==========================================================================
185 //==========================================================================
186 static inline vuint32
retDefColorU (const vuint32 clr
, const vuint32 def
) noexcept
{
187 return (clr
? clr
: def
);
191 //==========================================================================
195 //==========================================================================
196 vuint32
SB_GetTextColor (int type
, vuint32 defval
) {
197 if (defval
== 0xdeadf00dU
) defval
= CR_UNTRANSLATED
;
199 case SBTC_Ammo1
: return retDefColorU(sbColorAmmo1
.getColor(), defval
);
200 case SBTC_Ammo2
: return retDefColorU(sbColorAmmo2
.getColor(), defval
);
201 case SBTC_Armor
: return retDefColorU(sbColorArmor
.getColor(), defval
);
202 case SBTC_Health
: return retDefColorU(sbColorHealth
.getColor(), defval
);
203 case SBTC_HealthAccum
: return retDefColorU(sbColorHealthAccum
.getColor(), defval
);
204 case SBTC_Frags
: return retDefColorU(sbColorFrags
.getColor(), defval
);
205 case SBTC_SmallAmmo
: return retDefColorU(sbColorSmallAmmo
.getColor(), defval
);
206 case SBTC_SmallMaxAmmo
: return retDefColorU(sbColorSmallAmmoMax
.getColor(), defval
);
207 case SBTC_ItemAmount
: return retDefColorU(sbColorItemAmount
.getColor(), defval
);
208 case SBTC_WeaponAmmoFull
: return retDefColorU(sbColorWeaponAmmoFull
.getColor(), CR_WHITE
);
209 case SBTC_WeaponAmmoNormal
: return retDefColorU(sbColorWeaponAmmoNormal
.getColor(), CR_GREEN
);
210 case SBTC_WeaponAmmoLower
: return retDefColorU(sbColorWeaponAmmoLower
.getColor(), CR_ORANGE
);
211 case SBTC_WeaponAmmoLow
: return retDefColorU(sbColorWeaponAmmoLow
.getColor(), CR_YELLOW
);
212 case SBTC_WeaponAmmoVeryLow
: return retDefColorU(sbColorWeaponAmmoVeryLow
.getColor(), CR_RED
);
213 case SBTC_WeaponName
: return retDefColorU(sbColorWeaponName
.getColor(), CR_GOLD
);
214 case SBTC_AutomapMapName
: return retDefColorU(sbColorAutomapMapName
.getColor(), defval
);
215 case SBTC_AutomapMapCluster
: return retDefColorU(sbColorAutomapMapCluster
.getColor(), defval
);
216 case SBTC_AutomapKills
: return retDefColorU(sbColorAutomapKills
.getColor(), CR_RED
);
217 case SBTC_AutomapItems
: return retDefColorU(sbColorAutomapItems
.getColor(), CR_GREEN
);
218 case SBTC_AutomapSecrets
: return retDefColorU(sbColorAutomapSecrets
.getColor(), CR_GOLD
);
219 case SBTS_AutomapGameTotalTime
: return retDefColorU(sbColorAutomapTotalTime
.getColor(), defval
);
222 return CR_UNTRANSLATED
;
227 //==========================================================================
231 //==========================================================================
234 //==========================================================================
238 //==========================================================================
239 static inline int retDefColor (const vuint32 clr
, const int def
) noexcept
{
240 return (clr
? (int)clr
: (int)def
);
244 //native static final int SB_GetTextColor (int type, optional int defval);
245 IMPLEMENT_FREE_FUNCTION(VObject
, SB_GetTextColor
) {
247 VOptParamInt
defval(CR_UNTRANSLATED
);
248 vobjGetParam(type
, defval
);
249 RET_INT((int)SB_GetTextColor(type
, (unsigned)defval
.value
));