@@ -876,6 +876,19 @@ const FieldParse InGameUI::s_fieldParseTable[] =
876
876
{ " ClearMinesRadiusCursor" , RadiusDecalTemplate::parseRadiusDecalTemplate, NULL , offsetof ( InGameUI, m_radiusCursors[ RADIUSCURSOR_CLEARMINES] ) },
877
877
{ " AmbulanceRadiusCursor" , RadiusDecalTemplate::parseRadiusDecalTemplate, NULL , offsetof ( InGameUI, m_radiusCursors[ RADIUSCURSOR_AMBULANCE] ) },
878
878
879
+ // TheSuperHackers @info ui enhancement configuration
880
+ { " SystemTimeFont" , INI::parseAsciiString, NULL , offsetof ( InGameUI, m_systemTimeFont ) },
881
+ { " SystemTimeBold" , INI::parseBool, NULL , offsetof ( InGameUI, m_systemTimeBold ) },
882
+ { " SystemTimePosition" , INI::parseCoord2D, NULL , offsetof ( InGameUI, m_systemTimePosition ) },
883
+ { " SystemTimeColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_systemTimeColor ) },
884
+ { " SystemTimeDropColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_systemTimeDropColor ) },
885
+
886
+ { " GameTimeFont" , INI::parseAsciiString, NULL , offsetof ( InGameUI, m_gameTimeFont ) },
887
+ { " GameTimeBold" , INI::parseBool, NULL , offsetof ( InGameUI, m_gameTimeBold ) },
888
+ { " GameTimePosition" , INI::parseCoord2D, NULL , offsetof ( InGameUI, m_gameTimePosition ) },
889
+ { " GameTimeColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_gameTimeColor ) },
890
+ { " GameTimeDropColor" , INI::parseColorInt, NULL , offsetof ( InGameUI, m_gameTimeDropColor ) },
891
+
879
892
{ NULL , NULL , NULL , 0 } // keep this last
880
893
};
881
894
@@ -1001,6 +1014,25 @@ InGameUI::InGameUI()
1001
1014
m_replayWindow = NULL ;
1002
1015
m_messagesOn = TRUE ;
1003
1016
1017
+ m_systemTimeString = NULL ;
1018
+ m_systemTimeFont = " Tahoma" ;
1019
+ m_systemTimePointSize = TheGlobalData->m_systemTimeFontSize ;
1020
+ m_systemTimeBold = TRUE ;
1021
+ m_systemTimePosition.x = 3 ; // TheSuperHackers @info relative to the left of the screen
1022
+ m_systemTimePosition.y = -1 ;
1023
+ m_systemTimeColor = GameMakeColor ( 255 , 255 , 255 , 255 );
1024
+ m_systemTimeDropColor = GameMakeColor ( 0 , 0 , 0 , 255 );
1025
+
1026
+ m_gameTimeString = NULL ;
1027
+ m_gameTimeFrameString = NULL ;
1028
+ m_gameTimeFont = " Tahoma" ;
1029
+ m_gameTimePointSize = TheGlobalData->m_gameTimeFontSize ;
1030
+ m_gameTimeBold = TRUE ;
1031
+ m_gameTimePosition.x = 3 ; // TheSuperHackers @info relative to the right of the screen
1032
+ m_gameTimePosition.y = -1 ;
1033
+ m_gameTimeColor = GameMakeColor ( 255 , 255 , 255 , 255 );
1034
+ m_gameTimeDropColor = GameMakeColor ( 0 , 0 , 0 , 255 );
1035
+
1004
1036
m_superweaponPosition.x = 0 .7f ;
1005
1037
m_superweaponPosition.y = 0 .7f ;
1006
1038
m_superweaponFlashDuration = 1 .0f ;
@@ -1082,6 +1114,9 @@ InGameUI::~InGameUI()
1082
1114
// delete the message resources
1083
1115
freeMessageResources ();
1084
1116
1117
+ // free custom ui strings
1118
+ freeCustomUiResources ();
1119
+
1085
1120
// delete the array for the drawbles
1086
1121
delete [] m_placeIcon;
1087
1122
m_placeIcon = NULL ;
@@ -1924,6 +1959,9 @@ void InGameUI::reset( void )
1924
1959
// free any message resources allocated
1925
1960
freeMessageResources ();
1926
1961
1962
+ // free custom ui strings
1963
+ freeCustomUiResources ();
1964
+
1927
1965
Int i;
1928
1966
for (i=0 ; i<MAX_PLAYER_COUNT; ++i)
1929
1967
{
@@ -2009,6 +2047,16 @@ void InGameUI::freeMessageResources( void )
2009
2047
2010
2048
} // end freeMessageResources
2011
2049
2050
+ void InGameUI::freeCustomUiResources ( void )
2051
+ {
2052
+ TheDisplayStringManager->freeDisplayString (m_systemTimeString);
2053
+ m_systemTimeString = NULL ;
2054
+ TheDisplayStringManager->freeDisplayString (m_gameTimeString);
2055
+ m_gameTimeString = NULL ;
2056
+ TheDisplayStringManager->freeDisplayString (m_gameTimeFrameString);
2057
+ m_gameTimeFrameString = NULL ;
2058
+ }
2059
+
2012
2060
// -------------------------------------------------------------------------------------------------
2013
2061
/* * Same as the unicode message method, but this takes an ascii string which is assumed
2014
2062
* to me a string manager label */
@@ -3459,6 +3507,22 @@ void InGameUI::disregardDrawable( Drawable *draw )
3459
3507
3460
3508
}
3461
3509
3510
+ // -------------------------------------------------------------------------------------------------
3511
+ /* * This is called after the WindowManager has drawn the menus. */
3512
+ // -------------------------------------------------------------------------------------------------
3513
+ void InGameUI::postWindowDraw ( void )
3514
+ {
3515
+ if (m_systemTimePointSize > 0 )
3516
+ {
3517
+ drawSystemTime ();
3518
+ }
3519
+
3520
+ if ( (m_gameTimePointSize > 0 ) && !TheGameLogic->isInShellGame () && TheGameLogic->isInGame () )
3521
+ {
3522
+ drawGameTime ();
3523
+ }
3524
+ }
3525
+
3462
3526
// -------------------------------------------------------------------------------------------------
3463
3527
/* * This is called after the UI has been drawn. */
3464
3528
// -------------------------------------------------------------------------------------------------
@@ -5718,4 +5782,59 @@ WindowMsgHandledType IdleWorkerSystem( GameWindow *window, UnsignedInt msg,
5718
5782
5719
5783
}
5720
5784
5785
+ void InGameUI::drawSystemTime ()
5786
+ {
5787
+ if (!m_systemTimeString) {
5788
+ m_systemTimeString = TheDisplayStringManager->newDisplayString ();
5789
+ }
5790
+
5791
+ // current system time
5792
+ SYSTEMTIME systemTime;
5793
+ GetLocalTime ( &systemTime );
5794
+
5795
+ UnicodeString TimeString;
5796
+ TimeString.format (L" %2.2d:%2.2d:%2.2d" , systemTime.wHour , systemTime.wMinute , systemTime.wSecond );
5797
+ Int adjustedSystemTimeFontSize = TheGlobalLanguageData->adjustFontSize (m_systemTimePointSize);
5798
+ GameFont* systemTimeFont = TheWindowManager->winFindFont (m_systemTimeFont, adjustedSystemTimeFontSize, m_systemTimeBold);
5799
+ m_systemTimeString->setFont (systemTimeFont);
5800
+ m_systemTimeString->setText (TimeString);
5801
+
5802
+ m_systemTimeString->draw (m_systemTimePosition.x , m_systemTimePosition.y , m_systemTimeColor, m_systemTimeDropColor);
5803
+ }
5804
+
5805
+ void InGameUI::drawGameTime ()
5806
+ {
5807
+ if (!m_gameTimeString) {
5808
+ m_gameTimeString = TheDisplayStringManager->newDisplayString ();
5809
+ }
5810
+
5811
+ if (!m_gameTimeFrameString) {
5812
+ m_gameTimeFrameString = TheDisplayStringManager->newDisplayString ();
5813
+ }
5814
+
5815
+ Int currentFrame = TheGameLogic->getFrame ();
5816
+ Int gameSeconds = (Int) (SECONDS_PER_LOGICFRAME_REAL * currentFrame );
5817
+ Int hours = gameSeconds / 60 / 60 ;
5818
+ Int minutes = (gameSeconds / 60 ) % 60 ;
5819
+ Int seconds = gameSeconds % 60 ;
5820
+ Int frame = currentFrame % 30 ;
5721
5821
5822
+ UnicodeString gameTimeString;
5823
+ gameTimeString.format (L" %2.2d:%2.2d:%2.2d" , hours, minutes, seconds);
5824
+ Int adjustedGameTimeFontSize = TheGlobalLanguageData->adjustFontSize (m_gameTimePointSize);
5825
+ GameFont* gameTimeFont = TheWindowManager->winFindFont (m_gameTimeFont, adjustedGameTimeFontSize, m_gameTimeBold);
5826
+ m_gameTimeString->setFont (gameTimeFont);
5827
+ m_gameTimeString->setText (gameTimeString);
5828
+
5829
+ UnicodeString gameTimeFrameString;
5830
+ gameTimeFrameString.format (L" .%2.2d" , frame);
5831
+ m_gameTimeFrameString->setFont (gameTimeFont);
5832
+ m_gameTimeFrameString->setText (gameTimeFrameString);
5833
+
5834
+ // TheSuperHackers @info this implicitly offsets the game timer from the right instead of left of the screen
5835
+ int horizontalTimerOffset = TheDisplay->getWidth () - (Int)m_gameTimePosition.x - m_gameTimeString->getWidth () - m_gameTimeFrameString->getWidth ();
5836
+ int horizontalFrameOffset = TheDisplay->getWidth () - (Int)m_gameTimePosition.x - m_gameTimeFrameString->getWidth ();
5837
+
5838
+ m_gameTimeString->draw (horizontalTimerOffset, m_gameTimePosition.y , m_gameTimeColor, m_gameTimeDropColor);
5839
+ m_gameTimeFrameString->draw (horizontalFrameOffset, m_gameTimePosition.y , GameMakeColor (180 ,180 ,180 ,255 ), m_gameTimeDropColor);
5840
+ }
0 commit comments