@@ -842,6 +842,19 @@ const FieldParse InGameUI::s_fieldParseTable[] =
842
842
{ " RadarRadiusCursor" , RadiusDecalTemplate::parseRadiusDecalTemplate, NULL , offsetof ( InGameUI, m_radiusCursors[ RADIUSCURSOR_RADAR] ) },
843
843
{ " SpyDroneRadiusCursor" , RadiusDecalTemplate::parseRadiusDecalTemplate, NULL , offsetof ( InGameUI, m_radiusCursors[ RADIUSCURSOR_SPYDRONE] ) },
844
844
845
+ // TheSuperHackers @info ui enhancement configuration
846
+ { " SystemTimeFont" , INI::parseAsciiString, NULL , offsetof ( InGameUI, m_systemTimeFont ) },
847
+ { " SystemTimeBold" , INI::parseBool, NULL , offsetof ( InGameUI, m_systemTimeBold ) },
848
+ { " SystemTimePosition" , INI::parseCoord2D, NULL , offsetof ( InGameUI, m_systemTimePosition ) },
849
+ { " SystemTimeColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_systemTimeColor ) },
850
+ { " SystemTimeDropColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_systemTimeDropColor ) },
851
+
852
+ { " GameTimeFont" , INI::parseAsciiString, NULL , offsetof ( InGameUI, m_gameTimeFont ) },
853
+ { " GameTimeBold" , INI::parseBool, NULL , offsetof ( InGameUI, m_gameTimeBold ) },
854
+ { " GameTimePosition" , INI::parseCoord2D, NULL , offsetof ( InGameUI, m_gameTimePosition ) },
855
+ { " GameTimeColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_gameTimeColor ) },
856
+ { " GameTimeDropColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_gameTimeDropColor ) },
857
+
845
858
{ NULL , NULL , NULL , 0 } // keep this last
846
859
};
847
860
@@ -966,6 +979,26 @@ InGameUI::InGameUI()
966
979
m_replayWindow = NULL ;
967
980
m_messagesOn = TRUE ;
968
981
982
+ // TheSuperHackers @info the default font, size and positions of the system and game times were chosen based on GenTools implementation
983
+ m_systemTimeString = NULL ;
984
+ m_systemTimeFont = " Tahoma" ;
985
+ m_systemTimePointSize = TheGlobalData->m_systemTimeFontSize ;
986
+ m_systemTimeBold = TRUE ;
987
+ m_systemTimePosition.x = 3 ; // TheSuperHackers @info relative to the left of the screen
988
+ m_systemTimePosition.y = -1 ;
989
+ m_systemTimeColor = GameMakeColor ( 255 , 255 , 255 , 255 );
990
+ m_systemTimeDropColor = GameMakeColor ( 0 , 0 , 0 , 255 );
991
+
992
+ m_gameTimeString = NULL ;
993
+ m_gameTimeFrameString = NULL ;
994
+ m_gameTimeFont = " Tahoma" ;
995
+ m_gameTimePointSize = TheGlobalData->m_gameTimeFontSize ;
996
+ m_gameTimeBold = TRUE ;
997
+ m_gameTimePosition.x = 3 ; // TheSuperHackers @info relative to the right of the screen
998
+ m_gameTimePosition.y = -1 ;
999
+ m_gameTimeColor = GameMakeColor ( 255 , 255 , 255 , 255 );
1000
+ m_gameTimeDropColor = GameMakeColor ( 0 , 0 , 0 , 255 );
1001
+
969
1002
m_superweaponPosition.x = 0 .7f ;
970
1003
m_superweaponPosition.y = 0 .7f ;
971
1004
m_superweaponFlashDuration = 1 .0f ;
@@ -1047,6 +1080,9 @@ InGameUI::~InGameUI()
1047
1080
// delete the message resources
1048
1081
freeMessageResources ();
1049
1082
1083
+ // free custom ui strings
1084
+ freeCustomUiResources ();
1085
+
1050
1086
// delete the array for the drawbles
1051
1087
delete [] m_placeIcon;
1052
1088
m_placeIcon = NULL ;
@@ -1863,6 +1899,9 @@ void InGameUI::reset( void )
1863
1899
// free any message resources allocated
1864
1900
freeMessageResources ();
1865
1901
1902
+ // refresh custom ui strings - this will create the strings if required and update the fonts
1903
+ refreshCustomUiResources ();
1904
+
1866
1905
Int i;
1867
1906
for (i=0 ; i<MAX_PLAYER_COUNT; ++i)
1868
1907
{
@@ -1948,6 +1987,16 @@ void InGameUI::freeMessageResources( void )
1948
1987
1949
1988
} // end freeMessageResources
1950
1989
1990
+ void InGameUI::freeCustomUiResources ( void )
1991
+ {
1992
+ TheDisplayStringManager->freeDisplayString (m_systemTimeString);
1993
+ m_systemTimeString = NULL ;
1994
+ TheDisplayStringManager->freeDisplayString (m_gameTimeString);
1995
+ m_gameTimeString = NULL ;
1996
+ TheDisplayStringManager->freeDisplayString (m_gameTimeFrameString);
1997
+ m_gameTimeFrameString = NULL ;
1998
+ }
1999
+
1951
2000
// -------------------------------------------------------------------------------------------------
1952
2001
/* * Same as the unicode message method, but this takes an ascii string which is assumed
1953
2002
* to me a string manager label */
@@ -3364,6 +3413,22 @@ void InGameUI::disregardDrawable( Drawable *draw )
3364
3413
3365
3414
}
3366
3415
3416
+ // -------------------------------------------------------------------------------------------------
3417
+ /* * This is called after the WindowManager has drawn the menus. */
3418
+ // -------------------------------------------------------------------------------------------------
3419
+ void InGameUI::postWindowDraw ( void )
3420
+ {
3421
+ if (m_systemTimePointSize > 0 )
3422
+ {
3423
+ drawSystemTime ();
3424
+ }
3425
+
3426
+ if ( (m_gameTimePointSize > 0 ) && !TheGameLogic->isInShellGame () && TheGameLogic->isInGame () )
3427
+ {
3428
+ drawGameTime ();
3429
+ }
3430
+ }
3431
+
3367
3432
// -------------------------------------------------------------------------------------------------
3368
3433
/* * This is called after the UI has been drawn. */
3369
3434
// -------------------------------------------------------------------------------------------------
@@ -5487,6 +5552,44 @@ void InGameUI::recreateControlBar( void )
5487
5552
5488
5553
}
5489
5554
5555
+ void InGameUI::refreshCustomUiResources (void )
5556
+ {
5557
+ refreshSystemTimeResources ();
5558
+ refreshGameTimeResources ();
5559
+ }
5560
+
5561
+ void InGameUI::refreshSystemTimeResources (void )
5562
+ {
5563
+ if (!m_systemTimeString)
5564
+ {
5565
+ m_systemTimeString = TheDisplayStringManager->newDisplayString ();
5566
+ }
5567
+
5568
+ m_systemTimePointSize = TheGlobalData->m_systemTimeFontSize ;
5569
+ Int adjustedSystemTimeFontSize = TheGlobalLanguageData->adjustFontSize (m_systemTimePointSize);
5570
+ GameFont* systemTimeFont = TheWindowManager->winFindFont (m_systemTimeFont, adjustedSystemTimeFontSize, m_systemTimeBold);
5571
+ m_systemTimeString->setFont (systemTimeFont);
5572
+ }
5573
+
5574
+ void InGameUI::refreshGameTimeResources (void )
5575
+ {
5576
+ if (!m_gameTimeString)
5577
+ {
5578
+ m_gameTimeString = TheDisplayStringManager->newDisplayString ();
5579
+ }
5580
+
5581
+ if (!m_gameTimeFrameString)
5582
+ {
5583
+ m_gameTimeFrameString = TheDisplayStringManager->newDisplayString ();
5584
+ }
5585
+
5586
+ m_gameTimePointSize = TheGlobalData->m_gameTimeFontSize ;
5587
+ Int adjustedGameTimeFontSize = TheGlobalLanguageData->adjustFontSize (m_gameTimePointSize);
5588
+ GameFont* gameTimeFont = TheWindowManager->winFindFont (m_gameTimeFont, adjustedGameTimeFontSize, m_gameTimeBold);
5589
+ m_gameTimeString->setFont (gameTimeFont);
5590
+ m_gameTimeFrameString->setFont (gameTimeFont);
5591
+ }
5592
+
5490
5593
void InGameUI::disableTooltipsUntil (UnsignedInt frameNum)
5491
5594
{
5492
5595
if (frameNum > m_tooltipsDisabledUntil)
@@ -5541,4 +5644,40 @@ WindowMsgHandledType IdleWorkerSystem( GameWindow *window, UnsignedInt msg,
5541
5644
5542
5645
}
5543
5646
5647
+ void InGameUI::drawSystemTime ()
5648
+ {
5649
+ // current system time
5650
+ SYSTEMTIME systemTime;
5651
+ GetLocalTime ( &systemTime );
5652
+
5653
+ UnicodeString TimeString;
5654
+ TimeString.format (L" %2.2d:%2.2d:%2.2d" , systemTime.wHour , systemTime.wMinute , systemTime.wSecond );
5655
+ m_systemTimeString->setText (TimeString);
5544
5656
5657
+ m_systemTimeString->draw (m_systemTimePosition.x , m_systemTimePosition.y , m_systemTimeColor, m_systemTimeDropColor);
5658
+ }
5659
+
5660
+ void InGameUI::drawGameTime ()
5661
+ {
5662
+ Int currentFrame = TheGameLogic->getFrame ();
5663
+ Int gameSeconds = (Int) (SECONDS_PER_LOGICFRAME_REAL * currentFrame );
5664
+ Int hours = gameSeconds / 60 / 60 ;
5665
+ Int minutes = (gameSeconds / 60 ) % 60 ;
5666
+ Int seconds = gameSeconds % 60 ;
5667
+ Int frame = currentFrame % 30 ;
5668
+
5669
+ UnicodeString gameTimeString;
5670
+ gameTimeString.format (L" %2.2d:%2.2d:%2.2d" , hours, minutes, seconds);
5671
+ m_gameTimeString->setText (gameTimeString);
5672
+
5673
+ UnicodeString gameTimeFrameString;
5674
+ gameTimeFrameString.format (L" .%2.2d" , frame);
5675
+ m_gameTimeFrameString->setText (gameTimeFrameString);
5676
+
5677
+ // TheSuperHackers @info this implicitly offsets the game timer from the right instead of left of the screen
5678
+ int horizontalTimerOffset = TheDisplay->getWidth () - (Int)m_gameTimePosition.x - m_gameTimeString->getWidth () - m_gameTimeFrameString->getWidth ();
5679
+ int horizontalFrameOffset = TheDisplay->getWidth () - (Int)m_gameTimePosition.x - m_gameTimeFrameString->getWidth ();
5680
+
5681
+ m_gameTimeString->draw (horizontalTimerOffset, m_gameTimePosition.y , m_gameTimeColor, m_gameTimeDropColor);
5682
+ m_gameTimeFrameString->draw (horizontalFrameOffset, m_gameTimePosition.y , GameMakeColor (180 ,180 ,180 ,255 ), m_gameTimeDropColor);
5683
+ }
0 commit comments