@@ -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,25 @@ InGameUI::InGameUI()
996
1009
m_replayWindow = NULL ;
997
1010
m_messagesOn = TRUE ;
998
1011
1012
+ m_systemTimeString = NULL ;
1013
+ m_systemTimeFont = " Tahoma" ;
1014
+ m_systemTimePointSize = TheGlobalData->m_systemTimeFontSize ;
1015
+ m_systemTimeBold = TRUE ;
1016
+ m_systemTimePosition.x = 3 ; // TheSuperHackers @info relative to the left of the screen
1017
+ m_systemTimePosition.y = -1 ;
1018
+ m_systemTimeColor = GameMakeColor ( 255 , 255 , 255 , 255 );
1019
+ m_systemTimeDropColor = GameMakeColor ( 0 , 0 , 0 , 255 );
1020
+
1021
+ m_gameTimeString = NULL ;
1022
+ m_gameTimeFrameString = NULL ;
1023
+ m_gameTimeFont = " Tahoma" ;
1024
+ m_gameTimePointSize = TheGlobalData->m_gameTimeFontSize ;
1025
+ m_gameTimeBold = TRUE ;
1026
+ m_gameTimePosition.x = 3 ; // TheSuperHackers @info relative to the right of the screen
1027
+ m_gameTimePosition.y = -1 ;
1028
+ m_gameTimeColor = GameMakeColor ( 255 , 255 , 255 , 255 );
1029
+ m_gameTimeDropColor = GameMakeColor ( 0 , 0 , 0 , 255 );
1030
+
999
1031
m_superweaponPosition.x = 0 .7f ;
1000
1032
m_superweaponPosition.y = 0 .7f ;
1001
1033
m_superweaponFlashDuration = 1 .0f ;
@@ -1077,6 +1109,9 @@ InGameUI::~InGameUI()
1077
1109
// delete the message resources
1078
1110
freeMessageResources ();
1079
1111
1112
+ // free custom ui strings
1113
+ freeCustomUiResources ();
1114
+
1080
1115
// delete the array for the drawbles
1081
1116
delete [] m_placeIcon;
1082
1117
m_placeIcon = NULL ;
@@ -1919,6 +1954,9 @@ void InGameUI::reset( void )
1919
1954
// free any message resources allocated
1920
1955
freeMessageResources ();
1921
1956
1957
+ // free custom ui strings
1958
+ freeCustomUiResources ();
1959
+
1922
1960
Int i;
1923
1961
for (i=0 ; i<MAX_PLAYER_COUNT; ++i)
1924
1962
{
@@ -2004,6 +2042,16 @@ void InGameUI::freeMessageResources( void )
2004
2042
2005
2043
} // end freeMessageResources
2006
2044
2045
+ void InGameUI::freeCustomUiResources ( void )
2046
+ {
2047
+ TheDisplayStringManager->freeDisplayString (m_systemTimeString);
2048
+ m_systemTimeString = NULL ;
2049
+ TheDisplayStringManager->freeDisplayString (m_gameTimeString);
2050
+ m_gameTimeString = NULL ;
2051
+ TheDisplayStringManager->freeDisplayString (m_gameTimeFrameString);
2052
+ m_gameTimeFrameString = NULL ;
2053
+ }
2054
+
2007
2055
// -------------------------------------------------------------------------------------------------
2008
2056
/* * Same as the unicode message method, but this takes an ascii string which is assumed
2009
2057
* to me a string manager label */
@@ -3454,6 +3502,22 @@ void InGameUI::disregardDrawable( Drawable *draw )
3454
3502
3455
3503
}
3456
3504
3505
+ // -------------------------------------------------------------------------------------------------
3506
+ /* * This is called after the WindowManager has drawn the menus. */
3507
+ // -------------------------------------------------------------------------------------------------
3508
+ void InGameUI::postWindowDraw ( void )
3509
+ {
3510
+ if (m_systemTimePointSize > 0 )
3511
+ {
3512
+ drawSystemTime ();
3513
+ }
3514
+
3515
+ if ( (m_gameTimePointSize > 0 ) && !TheGameLogic->isInShellGame () && TheGameLogic->isInGame () )
3516
+ {
3517
+ drawGameTime ();
3518
+ }
3519
+ }
3520
+
3457
3521
// -------------------------------------------------------------------------------------------------
3458
3522
/* * This is called after the UI has been drawn. */
3459
3523
// -------------------------------------------------------------------------------------------------
@@ -5659,6 +5723,33 @@ void InGameUI::recreateControlBar( void )
5659
5723
5660
5724
}
5661
5725
5726
+ void InGameUI::refreshCustomUiResources (void )
5727
+ {
5728
+ if (!m_systemTimeString) {
5729
+ m_systemTimeString = TheDisplayStringManager->newDisplayString ();
5730
+ }
5731
+
5732
+ m_systemTimePointSize = TheGlobalData->m_systemTimeFontSize ;
5733
+ Int adjustedSystemTimeFontSize = TheGlobalLanguageData->adjustFontSize (m_systemTimePointSize);
5734
+ GameFont* systemTimeFont = TheWindowManager->winFindFont (m_systemTimeFont, adjustedSystemTimeFontSize, m_systemTimeBold);
5735
+ m_systemTimeString->setFont (systemTimeFont);
5736
+
5737
+
5738
+ if (!m_gameTimeString) {
5739
+ m_gameTimeString = TheDisplayStringManager->newDisplayString ();
5740
+ }
5741
+
5742
+ if (!m_gameTimeFrameString) {
5743
+ m_gameTimeFrameString = TheDisplayStringManager->newDisplayString ();
5744
+ }
5745
+
5746
+ m_gameTimePointSize = TheGlobalData->m_gameTimeFontSize ;
5747
+ Int adjustedGameTimeFontSize = TheGlobalLanguageData->adjustFontSize (m_gameTimePointSize);
5748
+ GameFont* gameTimeFont = TheWindowManager->winFindFont (m_gameTimeFont, adjustedGameTimeFontSize, m_gameTimeBold);
5749
+ m_gameTimeString->setFont (gameTimeFont);
5750
+ m_gameTimeFrameString->setFont (gameTimeFont);
5751
+ }
5752
+
5662
5753
void InGameUI::disableTooltipsUntil (UnsignedInt frameNum)
5663
5754
{
5664
5755
if (frameNum > m_tooltipsDisabledUntil)
@@ -5713,4 +5804,40 @@ WindowMsgHandledType IdleWorkerSystem( GameWindow *window, UnsignedInt msg,
5713
5804
5714
5805
}
5715
5806
5807
+ void InGameUI::drawSystemTime ()
5808
+ {
5809
+ // current system time
5810
+ SYSTEMTIME systemTime;
5811
+ GetLocalTime ( &systemTime );
5716
5812
5813
+ UnicodeString TimeString;
5814
+ TimeString.format (L" %2.2d:%2.2d:%2.2d" , systemTime.wHour , systemTime.wMinute , systemTime.wSecond );
5815
+ m_systemTimeString->setText (TimeString);
5816
+
5817
+ m_systemTimeString->draw (m_systemTimePosition.x , m_systemTimePosition.y , m_systemTimeColor, m_systemTimeDropColor);
5818
+ }
5819
+
5820
+ void InGameUI::drawGameTime ()
5821
+ {
5822
+ Int currentFrame = TheGameLogic->getFrame ();
5823
+ Int gameSeconds = (Int) (SECONDS_PER_LOGICFRAME_REAL * currentFrame );
5824
+ Int hours = gameSeconds / 60 / 60 ;
5825
+ Int minutes = (gameSeconds / 60 ) % 60 ;
5826
+ Int seconds = gameSeconds % 60 ;
5827
+ Int frame = currentFrame % 30 ;
5828
+
5829
+ UnicodeString gameTimeString;
5830
+ gameTimeString.format (L" %2.2d:%2.2d:%2.2d" , hours, minutes, seconds);
5831
+ m_gameTimeString->setText (gameTimeString);
5832
+
5833
+ UnicodeString gameTimeFrameString;
5834
+ gameTimeFrameString.format (L" .%2.2d" , frame);
5835
+ m_gameTimeFrameString->setText (gameTimeFrameString);
5836
+
5837
+ // TheSuperHackers @info this implicitly offsets the game timer from the right instead of left of the screen
5838
+ int horizontalTimerOffset = TheDisplay->getWidth () - (Int)m_gameTimePosition.x - m_gameTimeString->getWidth () - m_gameTimeFrameString->getWidth ();
5839
+ int horizontalFrameOffset = TheDisplay->getWidth () - (Int)m_gameTimePosition.x - m_gameTimeFrameString->getWidth ();
5840
+
5841
+ m_gameTimeString->draw (horizontalTimerOffset, m_gameTimePosition.y , m_gameTimeColor, m_gameTimeDropColor);
5842
+ m_gameTimeFrameString->draw (horizontalFrameOffset, m_gameTimePosition.y , GameMakeColor (180 ,180 ,180 ,255 ), m_gameTimeDropColor);
5843
+ }
0 commit comments