Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libultraship
Submodule libultraship updated 258 files
58 changes: 31 additions & 27 deletions soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "assets/soh_assets.h"
#include "soh/SohGui/ImGuiUtils.h"

#include <fast/Fast3dGui.h>

extern "C" {
#include "macros.h"
#include "functions.h"
Expand Down Expand Up @@ -83,18 +85,19 @@ static void TimeDisplayGetTimer(uint32_t timeID) {
Player* player = GET_PLAYER(gPlayState);
uint32_t timer1 = gSaveContext.timerSeconds;

auto gui = std::dynamic_pointer_cast<Fast::Fast3dGui>(
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetInstance()->GetWindow()->GetGui()));

switch (timeID) {
case DISPLAY_IN_GAME_TIMER:
textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("GAMEPLAY_TIMER");
textureDisplay = gui->GetTextureByName("GAMEPLAY_TIMER");
timeDisplayTime = formatTimeDisplay(GAMEPLAYSTAT_TOTAL_TIME).c_str();
break;
case DISPLAY_TIME_OF_DAY:
if (gSaveContext.dayTime >= DAY_BEGINS && gSaveContext.dayTime < NIGHT_BEGINS) {
textureDisplay =
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("DAY_TIME_TIMER");
textureDisplay = gui->GetTextureByName("DAY_TIME_TIMER");
} else {
textureDisplay =
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("NIGHT_TIME_TIMER");
textureDisplay = gui->GetTextureByName("NIGHT_TIME_TIMER");
}
timeDisplayTime = convertDayTime(gSaveContext.dayTime).c_str();
break;
Expand All @@ -107,18 +110,16 @@ static void TimeDisplayGetTimer(uint32_t timeID) {
: COLOR_LIGHT_BLUE)
: COLOR_WHITE;
if (gSaveContext.timerState <= TIMER_STATE_ENV_HAZARD_TICK) {
textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(
gPlayState->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3
? itemMapping[ITEM_TUNIC_GORON].name
: itemMapping[ITEM_TUNIC_ZORA].name);
textureDisplay =
gui->GetTextureByName(gPlayState->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3
? itemMapping[ITEM_TUNIC_GORON].name
: itemMapping[ITEM_TUNIC_ZORA].name);
}
if (gSaveContext.timerState >= TIMER_STATE_DOWN_PREVIEW) {
textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(
itemMapping[ITEM_SWORD_MASTER].name);
textureDisplay = gui->GetTextureByName(itemMapping[ITEM_SWORD_MASTER].name);
}
} else {
textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(
itemMapping[ITEM_TUNIC_KOKIRI].name);
textureDisplay = gui->GetTextureByName(itemMapping[ITEM_TUNIC_KOKIRI].name);
timeDisplayTime = "-:--";
}
break;
Expand All @@ -132,7 +133,7 @@ static void TimeDisplayGetTimer(uint32_t timeID) {
timeDisplayTime = convertNaviTime(NAVI_COOLDOWN - gSaveContext.naviTimer).c_str();
textColor = COLOR_GREY;
}
textureDisplay = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("NAVI_TIMER");
textureDisplay = gui->GetTextureByName("NAVI_TIMER");
break;
default:
break;
Expand Down Expand Up @@ -203,13 +204,15 @@ void TimeDisplayWindow::Draw() {
}
if (textToDecode[i] == '.') {
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (8.0f * fontScale));
ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(
digitList[textureIndex].first),
ImGui::Image(std::dynamic_pointer_cast<Fast::Fast3dGui>(
Ship::Context::GetInstance()->GetWindow()->GetGui())
->GetTextureByName(digitList[textureIndex].first),
ImVec2(8.0f * fontScale, 8.0f * fontScale), ImVec2(0, 0.5f), ImVec2(1, 1),
textColor, ImVec4(0, 0, 0, 0));
} else {
ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(
digitList[textureIndex].first),
ImGui::Image(std::dynamic_pointer_cast<Fast::Fast3dGui>(
Ship::Context::GetInstance()->GetWindow()->GetGui())
->GetTextureByName(digitList[textureIndex].first),
ImVec2(8.0f * fontScale, 16.0f * fontScale), ImVec2(0, 0), ImVec2(1, 1), textColor,
ImVec4(0, 0, 0, 0));
}
Expand Down Expand Up @@ -247,17 +250,18 @@ static void TimeDisplayInitTimers() {
}

void TimeDisplayWindow::InitElement() {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("GAMEPLAY_TIMER", gClockIconTex,
ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("DAY_TIME_TIMER", gSunIconTex,
ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("NIGHT_TIME_TIMER", gMoonIconTex,
ImVec4(1, 1, 1, 1));
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("NAVI_TIMER", gNaviIconTex, ImVec4(1, 1, 1, 1));
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetInstance()->GetWindow()->GetGui())
->LoadGuiTexture("GAMEPLAY_TIMER", gClockIconTex, ImVec4(1, 1, 1, 1));
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetInstance()->GetWindow()->GetGui())
->LoadGuiTexture("DAY_TIME_TIMER", gSunIconTex, ImVec4(1, 1, 1, 1));
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetInstance()->GetWindow()->GetGui())
->LoadGuiTexture("NIGHT_TIME_TIMER", gMoonIconTex, ImVec4(1, 1, 1, 1));
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetInstance()->GetWindow()->GetGui())
->LoadGuiTexture("NAVI_TIMER", gNaviIconTex, ImVec4(1, 1, 1, 1));

for (auto& load : digitList) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture(load.first.c_str(), load.second,
ImVec4(1, 1, 1, 1));
std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetInstance()->GetWindow()->GetGui())
->LoadGuiTexture(load.first.c_str(), load.second, ImVec4(1, 1, 1, 1));
}

TimeDisplayInitSettings();
Expand Down
Loading
Loading