@@ -871,6 +871,19 @@ const FieldParse InGameUI::s_fieldParseTable[] =
871
871
{ " ClearMinesRadiusCursor" , RadiusDecalTemplate::parseRadiusDecalTemplate, NULL , offsetof ( InGameUI, m_radiusCursors[ RADIUSCURSOR_CLEARMINES] ) },
872
872
{ " AmbulanceRadiusCursor" , RadiusDecalTemplate::parseRadiusDecalTemplate, NULL , offsetof ( InGameUI, m_radiusCursors[ RADIUSCURSOR_AMBULANCE] ) },
873
873
874
+ // TheSuperHackers @info ui enhancement configuration
875
+ { " SystemTimeFont" , INI::parseAsciiString, NULL , offsetof ( InGameUI, m_systemTimeFont ) },
876
+ { " SystemTimeBold" , INI::parseBool, NULL , offsetof ( InGameUI, m_systemTimeBold ) },
877
+ { " SystemTimePosition" , INI::parseCoord2D, NULL , offsetof ( InGameUI, m_systemTimePosition ) },
878
+ { " SystemTimeColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_systemTimeColor ) },
879
+ { " SystemTimeDropColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_systemTimeDropColor ) },
880
+
881
+ { " GameTimeFont" , INI::parseAsciiString, NULL , offsetof ( InGameUI, m_gameTimeFont ) },
882
+ { " GameTimeBold" , INI::parseBool, NULL , offsetof ( InGameUI, m_gameTimeBold ) },
883
+ { " GameTimePosition" , INI::parseCoord2D, NULL , offsetof ( InGameUI, m_gameTimePosition ) },
884
+ { " GameTimeColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_gameTimeColor ) },
885
+ { " GameTimeDropColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_gameTimeDropColor ) },
886
+
874
887
{ NULL , NULL , NULL , 0 } // keep this last
875
888
};
876
889
@@ -996,6 +1009,26 @@ InGameUI::InGameUI()
996
1009
m_replayWindow = NULL ;
997
1010
m_messagesOn = TRUE ;
998
1011
1012
+ // TheSuperHackers @info the default font, size and positions of the system and game times were chosen based on GenTools implementation
1013
+ m_systemTimeString = NULL ;
1014
+ m_systemTimeFont = " Tahoma" ;
1015
+ m_systemTimePointSize = TheGlobalData->m_systemTimeFontSize ;
1016
+ m_systemTimeBold = TRUE ;
1017
+ m_systemTimePosition.x = 3 ; // TheSuperHackers @info relative to the left of the screen
1018
+ m_systemTimePosition.y = -1 ;
1019
+ m_systemTimeColor = GameMakeColor ( 255 , 255 , 255 , 255 );
1020
+ m_systemTimeDropColor = GameMakeColor ( 0 , 0 , 0 , 255 );
1021
+
1022
+ m_gameTimeString = NULL ;
1023
+ m_gameTimeFrameString = NULL ;
1024
+ m_gameTimeFont = " Tahoma" ;
1025
+ m_gameTimePointSize = TheGlobalData->m_gameTimeFontSize ;
1026
+ m_gameTimeBold = TRUE ;
1027
+ m_gameTimePosition.x = 3 ; // TheSuperHackers @info relative to the right of the screen
1028
+ m_gameTimePosition.y = -1 ;
1029
+ m_gameTimeColor = GameMakeColor ( 255 , 255 , 255 , 255 );
1030
+ m_gameTimeDropColor = GameMakeColor ( 0 , 0 , 0 , 255 );
1031
+
999
1032
m_superweaponPosition.x = 0 .7f ;
1000
1033
m_superweaponPosition.y = 0 .7f ;
1001
1034
m_superweaponFlashDuration = 1 .0f ;
@@ -1077,6 +1110,9 @@ InGameUI::~InGameUI()
1077
1110
// delete the message resources
1078
1111
freeMessageResources ();
1079
1112
1113
+ // free custom ui strings
1114
+ freeCustomUiResources ();
1115
+
1080
1116
// delete the array for the drawbles
1081
1117
delete [] m_placeIcon;
1082
1118
m_placeIcon = NULL ;
@@ -1919,6 +1955,9 @@ void InGameUI::reset( void )
1919
1955
// free any message resources allocated
1920
1956
freeMessageResources ();
1921
1957
1958
+ // refresh custom ui strings - this will create the strings if required and update the fonts
1959
+ refreshCustomUiResources ();
1960
+
1922
1961
Int i;
1923
1962
for (i=0 ; i<MAX_PLAYER_COUNT; ++i)
1924
1963
{
@@ -2004,6 +2043,16 @@ void InGameUI::freeMessageResources( void )
2004
2043
2005
2044
} // end freeMessageResources
2006
2045
2046
+ void InGameUI::freeCustomUiResources ( void )
2047
+ {
2048
+ TheDisplayStringManager->freeDisplayString (m_systemTimeString);
2049
+ m_systemTimeString = NULL ;
2050
+ TheDisplayStringManager->freeDisplayString (m_gameTimeString);
2051
+ m_gameTimeString = NULL ;
2052
+ TheDisplayStringManager->freeDisplayString (m_gameTimeFrameString);
2053
+ m_gameTimeFrameString = NULL ;
2054
+ }
2055
+
2007
2056
// -------------------------------------------------------------------------------------------------
2008
2057
/* * Same as the unicode message method, but this takes an ascii string which is assumed
2009
2058
* to me a string manager label */
@@ -3454,6 +3503,22 @@ void InGameUI::disregardDrawable( Drawable *draw )
3454
3503
3455
3504
}
3456
3505
3506
+ // -------------------------------------------------------------------------------------------------
3507
+ /* * This is called after the WindowManager has drawn the menus. */
3508
+ // -------------------------------------------------------------------------------------------------
3509
+ void InGameUI::postWindowDraw ( void )
3510
+ {
3511
+ if (m_systemTimePointSize > 0 )
3512
+ {
3513
+ drawSystemTime ();
3514
+ }
3515
+
3516
+ if ( (m_gameTimePointSize > 0 ) && !TheGameLogic->isInShellGame () && TheGameLogic->isInGame () )
3517
+ {
3518
+ drawGameTime ();
3519
+ }
3520
+ }
3521
+
3457
3522
// -------------------------------------------------------------------------------------------------
3458
3523
/* * This is called after the UI has been drawn. */
3459
3524
// -------------------------------------------------------------------------------------------------
@@ -5659,6 +5724,44 @@ void InGameUI::recreateControlBar( void )
5659
5724
5660
5725
}
5661
5726
5727
+ void InGameUI::refreshCustomUiResources (void )
5728
+ {
5729
+ refreshSystemTimeResources ();
5730
+ refreshGameTimeResources ();
5731
+ }
5732
+
5733
+ void InGameUI::refreshSystemTimeResources (void )
5734
+ {
5735
+ if (!m_systemTimeString)
5736
+ {
5737
+ m_systemTimeString = TheDisplayStringManager->newDisplayString ();
5738
+ }
5739
+
5740
+ m_systemTimePointSize = TheGlobalData->m_systemTimeFontSize ;
5741
+ Int adjustedSystemTimeFontSize = TheGlobalLanguageData->adjustFontSize (m_systemTimePointSize);
5742
+ GameFont* systemTimeFont = TheWindowManager->winFindFont (m_systemTimeFont, adjustedSystemTimeFontSize, m_systemTimeBold);
5743
+ m_systemTimeString->setFont (systemTimeFont);
5744
+ }
5745
+
5746
+ void InGameUI::refreshGameTimeResources (void )
5747
+ {
5748
+ if (!m_gameTimeString)
5749
+ {
5750
+ m_gameTimeString = TheDisplayStringManager->newDisplayString ();
5751
+ }
5752
+
5753
+ if (!m_gameTimeFrameString)
5754
+ {
5755
+ m_gameTimeFrameString = TheDisplayStringManager->newDisplayString ();
5756
+ }
5757
+
5758
+ m_gameTimePointSize = TheGlobalData->m_gameTimeFontSize ;
5759
+ Int adjustedGameTimeFontSize = TheGlobalLanguageData->adjustFontSize (m_gameTimePointSize);
5760
+ GameFont* gameTimeFont = TheWindowManager->winFindFont (m_gameTimeFont, adjustedGameTimeFontSize, m_gameTimeBold);
5761
+ m_gameTimeString->setFont (gameTimeFont);
5762
+ m_gameTimeFrameString->setFont (gameTimeFont);
5763
+ }
5764
+
5662
5765
void InGameUI::disableTooltipsUntil (UnsignedInt frameNum)
5663
5766
{
5664
5767
if (frameNum > m_tooltipsDisabledUntil)
@@ -5713,4 +5816,40 @@ WindowMsgHandledType IdleWorkerSystem( GameWindow *window, UnsignedInt msg,
5713
5816
5714
5817
}
5715
5818
5819
+ void InGameUI::drawSystemTime ()
5820
+ {
5821
+ // current system time
5822
+ SYSTEMTIME systemTime;
5823
+ GetLocalTime ( &systemTime );
5824
+
5825
+ UnicodeString TimeString;
5826
+ TimeString.format (L" %2.2d:%2.2d:%2.2d" , systemTime.wHour , systemTime.wMinute , systemTime.wSecond );
5827
+ m_systemTimeString->setText (TimeString);
5716
5828
5829
+ m_systemTimeString->draw (m_systemTimePosition.x , m_systemTimePosition.y , m_systemTimeColor, m_systemTimeDropColor);
5830
+ }
5831
+
5832
+ void InGameUI::drawGameTime ()
5833
+ {
5834
+ Int currentFrame = TheGameLogic->getFrame ();
5835
+ Int gameSeconds = (Int) (SECONDS_PER_LOGICFRAME_REAL * currentFrame );
5836
+ Int hours = gameSeconds / 60 / 60 ;
5837
+ Int minutes = (gameSeconds / 60 ) % 60 ;
5838
+ Int seconds = gameSeconds % 60 ;
5839
+ Int frame = currentFrame % 30 ;
5840
+
5841
+ UnicodeString gameTimeString;
5842
+ gameTimeString.format (L" %2.2d:%2.2d:%2.2d" , hours, minutes, seconds);
5843
+ m_gameTimeString->setText (gameTimeString);
5844
+
5845
+ UnicodeString gameTimeFrameString;
5846
+ gameTimeFrameString.format (L" .%2.2d" , frame);
5847
+ m_gameTimeFrameString->setText (gameTimeFrameString);
5848
+
5849
+ // TheSuperHackers @info this implicitly offsets the game timer from the right instead of left of the screen
5850
+ int horizontalTimerOffset = TheDisplay->getWidth () - (Int)m_gameTimePosition.x - m_gameTimeString->getWidth () - m_gameTimeFrameString->getWidth ();
5851
+ int horizontalFrameOffset = TheDisplay->getWidth () - (Int)m_gameTimePosition.x - m_gameTimeFrameString->getWidth ();
5852
+
5853
+ m_gameTimeString->draw (horizontalTimerOffset, m_gameTimePosition.y , m_gameTimeColor, m_gameTimeDropColor);
5854
+ m_gameTimeFrameString->draw (horizontalFrameOffset, m_gameTimePosition.y , GameMakeColor (180 ,180 ,180 ,255 ), m_gameTimeDropColor);
5855
+ }
0 commit comments