|
51 | 51 | #include "Common/StatsCollector.h" |
52 | 52 | #include "Common/ThingTemplate.h" |
53 | 53 | #include "Common/GameLOD.h" |
| 54 | +#include "Common/OptionPreferences.h" |
54 | 55 |
|
55 | 56 | #include "GameClient/InGameUI.h" |
56 | 57 | #include "GameClient/CommandXlat.h" |
@@ -180,6 +181,75 @@ Bool hasThingsInProduction(PlayerType playerType) |
180 | 181 |
|
181 | 182 | #endif // defined(RTS_DEBUG) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE) |
182 | 183 |
|
| 184 | +enum ObserverFontSizeChange |
| 185 | +{ |
| 186 | + ObserverFontSizeChange_Increase, |
| 187 | + ObserverFontSizeChange_Decrease, |
| 188 | +}; |
| 189 | + |
| 190 | +static const Int ObserverFontSizeMin = 0; |
| 191 | +static const Int ObserverFontSizeMax = 15; |
| 192 | + |
| 193 | +static Int applyObserverFontSizeChange(Int fontSize, ObserverFontSizeChange change) |
| 194 | +{ |
| 195 | + switch (change) |
| 196 | + { |
| 197 | + case ObserverFontSizeChange_Increase: |
| 198 | + if (fontSize < ObserverFontSizeMax) |
| 199 | + ++fontSize; |
| 200 | + break; |
| 201 | + |
| 202 | + case ObserverFontSizeChange_Decrease: |
| 203 | + if (fontSize > ObserverFontSizeMin) |
| 204 | + --fontSize; |
| 205 | + break; |
| 206 | + } |
| 207 | + |
| 208 | + return fontSize; |
| 209 | +} |
| 210 | + |
| 211 | +static void writeObserverFontSizePref(const char* prefKey, Int fontSize) |
| 212 | +{ |
| 213 | + OptionPreferences optPref; |
| 214 | + AsciiString prefString; |
| 215 | + prefString.format("%d", fontSize); |
| 216 | + optPref[prefKey] = prefString; |
| 217 | + optPref.write(); |
| 218 | +} |
| 219 | + |
| 220 | +static bool changeObserverNotificationFontSize(ObserverFontSizeChange change) |
| 221 | +{ |
| 222 | + const Int fontSize = applyObserverFontSizeChange(TheWritableGlobalData->m_observerNotificationFontSize, change); |
| 223 | + |
| 224 | + if (fontSize == TheWritableGlobalData->m_observerNotificationFontSize) |
| 225 | + return false; |
| 226 | + |
| 227 | + TheWritableGlobalData->m_observerNotificationFontSize = fontSize; |
| 228 | + |
| 229 | + if (TheInGameUI) |
| 230 | + TheInGameUI->refreshObserverNotificationResources(); |
| 231 | + |
| 232 | + writeObserverFontSizePref("ObserverNotificationFontSize", fontSize); |
| 233 | + |
| 234 | + return true; |
| 235 | +} |
| 236 | + |
| 237 | +static bool changeObserverStatsFontSize(ObserverFontSizeChange change) |
| 238 | +{ |
| 239 | + const Int fontSize = applyObserverFontSizeChange(TheWritableGlobalData->m_observerStatsFontSize, change); |
| 240 | + |
| 241 | + if (fontSize == TheWritableGlobalData->m_observerStatsFontSize) |
| 242 | + return false; |
| 243 | + |
| 244 | + TheWritableGlobalData->m_observerStatsFontSize = fontSize; |
| 245 | + |
| 246 | + if (TheInGameUI) |
| 247 | + TheInGameUI->initObserverOverlay(); |
| 248 | + |
| 249 | + writeObserverFontSizePref("ObserverStatsFontSize", fontSize); |
| 250 | + |
| 251 | + return true; |
| 252 | +} |
183 | 253 |
|
184 | 254 | bool changeMaxRenderFps(FpsValueChange change) |
185 | 255 | { |
@@ -3278,6 +3348,46 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage |
3278 | 3348 | break; |
3279 | 3349 | } |
3280 | 3350 |
|
| 3351 | + //----------------------------------------------------------------------------------------- |
| 3352 | + case GameMessage::MSG_META_INCREASE_OBSERVER_NOTIFICATION_FONT: |
| 3353 | + { |
| 3354 | + if (changeObserverNotificationFontSize(ObserverFontSizeChange_Increase)) |
| 3355 | + { |
| 3356 | + disp = DESTROY_MESSAGE; |
| 3357 | + } |
| 3358 | + break; |
| 3359 | + } |
| 3360 | + |
| 3361 | + //----------------------------------------------------------------------------------------- |
| 3362 | + case GameMessage::MSG_META_DECREASE_OBSERVER_NOTIFICATION_FONT: |
| 3363 | + { |
| 3364 | + if (changeObserverNotificationFontSize(ObserverFontSizeChange_Decrease)) |
| 3365 | + { |
| 3366 | + disp = DESTROY_MESSAGE; |
| 3367 | + } |
| 3368 | + break; |
| 3369 | + } |
| 3370 | + |
| 3371 | + //----------------------------------------------------------------------------------------- |
| 3372 | + case GameMessage::MSG_META_INCREASE_OBSERVER_STATS_FONT: |
| 3373 | + { |
| 3374 | + if (changeObserverStatsFontSize(ObserverFontSizeChange_Increase)) |
| 3375 | + { |
| 3376 | + disp = DESTROY_MESSAGE; |
| 3377 | + } |
| 3378 | + break; |
| 3379 | + } |
| 3380 | + |
| 3381 | + //----------------------------------------------------------------------------------------- |
| 3382 | + case GameMessage::MSG_META_DECREASE_OBSERVER_STATS_FONT: |
| 3383 | + { |
| 3384 | + if (changeObserverStatsFontSize(ObserverFontSizeChange_Decrease)) |
| 3385 | + { |
| 3386 | + disp = DESTROY_MESSAGE; |
| 3387 | + } |
| 3388 | + break; |
| 3389 | + } |
| 3390 | + |
3281 | 3391 | //----------------------------------------------------------------------------------------- |
3282 | 3392 | case GameMessage::MSG_META_INCREASE_LOGIC_TIME_SCALE: |
3283 | 3393 | { |
@@ -3369,6 +3479,7 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage |
3369 | 3479 | } |
3370 | 3480 |
|
3371 | 3481 | ToggleControlBar(); |
| 3482 | + TheInGameUI->toggleObserverStats(); |
3372 | 3483 | } |
3373 | 3484 | disp = DESTROY_MESSAGE; |
3374 | 3485 | break; |
|
0 commit comments