@@ -15,6 +15,8 @@ extern PlayState* gPlayState;
1515uint64_t GetUnixTimestamp ();
1616}
1717
18+ static bool separateGameplay = false ;
19+ static float gameplayFontScale = 1 .0f ;
1820static float fontScale = 1 .0f ;
1921std::string timeDisplayTime = " " ;
2022ImTextureID textureDisplay = 0 ;
@@ -46,6 +48,7 @@ const std::vector<TimeObject> timeDisplayList = {
4648};
4749
4850static std::vector<TimeObject> activeTimers;
51+ static TimeObject gameplayTimer = timeDisplayList[DISPLAY_IN_GAME_TIMER ];
4952
5053std::string convertDayTime (uint32_t dayTime) {
5154 uint32_t totalSeconds = 24 * 60 * 60 ;
@@ -89,6 +92,7 @@ static void TimeDisplayGetTimer(uint32_t timeID) {
8992 case DISPLAY_IN_GAME_TIMER :
9093 textureDisplay = Ship::Context::GetInstance ()->GetWindow ()->GetGui ()->GetTextureByName (" GAMEPLAY_TIMER" );
9194 timeDisplayTime = formatTimeDisplay (GAMEPLAYSTAT_TOTAL_TIME ).c_str ();
95+ textColor = gSaveContext .ship .stats .gameComplete ? COLOR_LIGHT_GREEN : COLOR_WHITE ;
9296 break ;
9397 case DISPLAY_TIME_OF_DAY :
9498 if (gSaveContext .dayTime >= DAY_BEGINS && gSaveContext .dayTime < NIGHT_BEGINS ) {
@@ -140,6 +144,7 @@ static void TimeDisplayGetTimer(uint32_t timeID) {
140144 timeDisplayTime = std::to_string (FredsQuestWoodOnHand) + " /" + std::to_string (FredsQuestWoodCollected) +
141145 " /" + std::to_string (CVarGetInteger (" gHoliday.Fredomato.FredsQuest.WoodNeeded" , 300 ));
142146 textureDisplay = Ship::Context::GetInstance ()->GetWindow ()->GetGui ()->GetTextureByName (" ITEM_STICK" );
147+ break ;
143148 default :
144149 break ;
145150 }
@@ -152,19 +157,52 @@ void TimeDisplayUpdateDisplayOptions() {
152157 activeTimers.push_back (timer);
153158 }
154159 }
160+ }
155161
156- // if (pushBack) {
157- // activeTimers.push_back(timeDisplayList[timeID]);
158- // } else {
159- // uint32_t index = 0;
160- // for (auto& check : activeTimers) {
161- // if (check.timeID == timeID) {
162- // activeTimers.erase(activeTimers.begin() + index);
163- // return;
164- // }
165- // index++;
166- // }
167- // }
162+ void DrawStandaloneGameplayTimer () {
163+ ImGui::Begin (" GameplayTimer" , nullptr ,
164+ ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoFocusOnAppearing |
165+ ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar |
166+ ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoScrollbar);
167+ ImGui::SetWindowFontScale (gameplayFontScale);
168+ ImGui::BeginTable (" Gameplay Timer" , 2 , ImGuiTableFlags_NoClip);
169+ ImGui::PushID (DISPLAY_IN_GAME_TIMER );
170+ TimeDisplayGetTimer (DISPLAY_IN_GAME_TIMER );
171+ ImGui::TableNextColumn ();
172+ ImGui::Image (textureDisplay, ImVec2 (16 .0f * gameplayFontScale, 16 .0f * gameplayFontScale));
173+ ImGui::TableNextColumn ();
174+ if (timeDisplayTime != " -:--" ) {
175+ char * textToDecode = new char [timeDisplayTime.size () + 1 ];
176+ textToDecode = std::strcpy (textToDecode, timeDisplayTime.c_str ());
177+ size_t textLength = timeDisplayTime.length ();
178+ uint16_t textureIndex = 0 ;
179+
180+ for (size_t i = 0 ; i < textLength; i++) {
181+ if (textToDecode[i] == ' :' || textToDecode[i] == ' .' ) {
182+ textureIndex = 10 ;
183+ } else {
184+ textureIndex = textToDecode[i] - ' 0' ;
185+ }
186+ if (textToDecode[i] == ' .' ) {
187+ ImGui::SetCursorPosY (ImGui::GetCursorPosY () + (8 .0f * gameplayFontScale));
188+ ImGui::Image (Ship::Context::GetInstance ()->GetWindow ()->GetGui ()->GetTextureByName (
189+ digitList[textureIndex].first ),
190+ ImVec2 (8 .0f * gameplayFontScale, 8 .0f * gameplayFontScale), ImVec2 (0 , 0 .5f ), ImVec2 (1 , 1 ),
191+ textColor,
192+ ImVec4 (0 , 0 , 0 , 0 ));
193+ } else {
194+ ImGui::Image (Ship::Context::GetInstance ()->GetWindow ()->GetGui ()->GetTextureByName (
195+ digitList[textureIndex].first ),
196+ ImVec2 (8 .0f * gameplayFontScale, 16 .0f * gameplayFontScale), ImVec2 (0 , 0 ), ImVec2 (1 , 1 ),
197+ textColor,
198+ ImVec4 (0 , 0 , 0 , 0 ));
199+ }
200+ ImGui::SameLine (0 , 0 );
201+ }
202+ }
203+ ImGui::PopID ();
204+ ImGui::EndTable ();
205+ ImGui::End ();
168206}
169207
170208void TimeDisplayWindow::Draw () {
@@ -179,6 +217,10 @@ void TimeDisplayWindow::Draw() {
179217 ImGui::PushStyleColor (ImGuiCol_Border, ImVec4 (0 , 0 , 0 , 0 ));
180218 ImGui::PushStyleVar (ImGuiStyleVar_WindowRounding, 4 .0f );
181219
220+ if (separateGameplay) {
221+ DrawStandaloneGameplayTimer ();
222+ }
223+
182224 ImGui::Begin (" TimerDisplay" , nullptr ,
183225 ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoFocusOnAppearing |
184226 ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar |
@@ -189,6 +231,10 @@ void TimeDisplayWindow::Draw() {
189231 } else {
190232 ImGui::BeginTable (" Timer List" , 2 , ImGuiTableFlags_NoClip);
191233 for (auto & timers : activeTimers) {
234+ if (separateGameplay && timers.timeID == DISPLAY_IN_GAME_TIMER ) {
235+ continue ;
236+ }
237+
192238 ImGui::PushID (timers.timeID );
193239 TimeDisplayGetTimer (timers.timeID );
194240 ImGui::TableNextColumn ();
@@ -239,6 +285,8 @@ void TimeDisplayWindow::Draw() {
239285}
240286
241287void TimeDisplayInitSettings () {
288+ separateGameplay = CVarGetInteger (CVAR_TIME_DISPLAY (" SeparateGameplay" ), 0 );
289+ gameplayFontScale = CVarGetFloat (CVAR_TIME_DISPLAY (" GameplayFontScale" ), 1 .0f );
242290 fontScale = CVarGetFloat (CVAR_TIME_DISPLAY (" FontScale" ), 1 .0f );
243291 if (fontScale < 1 .0f ) {
244292 fontScale = 1 .0f ;
0 commit comments