diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index 52eb492..41285d4 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -149,7 +149,8 @@ set(UNLEASHED_RECOMP_PATCHES_CXX_SOURCES set(UNLEASHED_RECOMP_UI_CXX_SOURCES "ui/achievement_menu.cpp" - "ui/achievement_overlay.cpp" + "ui/achievement_overlay.cpp" + "ui/black_bar.cpp" "ui/button_guide.cpp" "ui/fader.cpp" "ui/game_window.cpp" diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index cfa17cc..c54f6c1 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -2318,6 +2319,7 @@ static void DrawImGui() MessageWindow::Draw(); ButtonGuide::Draw(); Fader::Draw(); + BlackBar::Draw(); assert(ImGui::GetForegroundDrawList()->_ClipRectStack.Size == 1 && "Some clip rects were not removed from the stack!"); diff --git a/UnleashedRecomp/patches/aspect_ratio_patches.cpp b/UnleashedRecomp/patches/aspect_ratio_patches.cpp index 2cfe69c..ea496aa 100644 --- a/UnleashedRecomp/patches/aspect_ratio_patches.cpp +++ b/UnleashedRecomp/patches/aspect_ratio_patches.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -340,6 +341,9 @@ enum REPEAT_LEFT = 1 << 15, TORNADO_DEFENSE = 1 << 16, + + LOADING_BLACK_BAR_MIN = 1 << 17, + LOADING_BLACK_BAR_MAX = 1 << 18, }; struct CsdModifier @@ -403,6 +407,10 @@ static const xxHashMap g_modifiers = { HashStr("ui_loading/n_2_d/letterbox/letterbox_top"), { STRETCH } }, { HashStr("ui_loading/n_2_d/letterbox/black_l"), { EXTEND_LEFT | STRETCH_VERTICAL } }, { HashStr("ui_loading/n_2_d/letterbox/black_r"), { EXTEND_RIGHT | STRETCH_VERTICAL } }, + { HashStr("ui_loading/event_viewer/black/black_top"), { LOADING_BLACK_BAR_MIN } }, + { HashStr("ui_loading/event_viewer/black/black_under"), { LOADING_BLACK_BAR_MAX } }, + { HashStr("ui_loading/pda/pda_frame/L"), { LOADING_BLACK_BAR_MIN } }, + { HashStr("ui_loading/pda/pda_frame/R"), { LOADING_BLACK_BAR_MAX } }, // ui_mediaroom { HashStr("ui_mediaroom/header/bg/img_1"), { EXTEND_LEFT } }, @@ -1022,6 +1030,18 @@ static void Draw(PPCContext& ctx, uint8_t* base, PPCFunc* original, uint32_t str position[1] = round(y); } + if ((modifier.flags & LOADING_BLACK_BAR_MIN) != 0) + { + auto position = getPosition(0); + BlackBar::g_loadingBlackBarMin = ImVec2{ position[0], position[1] }; + BlackBar::g_loadingBlackBarAlpha = *(base + ctx.r1.u32 + 0xB); + } + else if ((modifier.flags & LOADING_BLACK_BAR_MAX) != 0) + { + auto position = getPosition(3); + BlackBar::g_loadingBlackBarMax = ImVec2{ position[0], position[1] }; + } + if ((modifier.flags & REPEAT_LEFT) != 0) { float width = *getPosition(2) - *getPosition(0); @@ -1363,6 +1383,12 @@ PPC_FUNC(sub_82B8AA40) // Restore the original letterbox value. PPC_STORE_U8(r3.u32, letterbox); + + if (letterbox) + { + // Would be nice to also push this as a 2D primitive but I really cannot be bothered right now... + BlackBar::g_inspirePillarbox = Config::CutsceneAspectRatio != ECutsceneAspectRatio::Unlocked && g_aspectRatio > WIDE_ASPECT_RATIO; + } } void InspireLetterboxTopMidAsmHook(PPCRegister& r3) diff --git a/UnleashedRecomp/ui/black_bar.cpp b/UnleashedRecomp/ui/black_bar.cpp new file mode 100644 index 0000000..ebe0294 --- /dev/null +++ b/UnleashedRecomp/ui/black_bar.cpp @@ -0,0 +1,58 @@ +#include "black_bar.h" +#include + +void BlackBar::Draw() +{ + if (g_inspirePillarbox) + { + auto drawList = ImGui::GetBackgroundDrawList(); + auto& res = ImGui::GetIO().DisplaySize; + + float width = (res.x - (res.y * 16.0f / 9.0f)) / 2.0f; + + drawList->AddRectFilled( + { 0.0f, 0.0f }, + { width, res.y }, + IM_COL32_BLACK); + + drawList->AddRectFilled( + { res.x - width, 0.0f }, + res, + IM_COL32_BLACK); + + g_inspirePillarbox = false; + } + + if (g_loadingBlackBarAlpha != 0) + { + auto drawList = ImGui::GetBackgroundDrawList(); + auto& res = ImGui::GetIO().DisplaySize; + + if (g_aspectRatio > WIDE_ASPECT_RATIO) + { + drawList->AddRectFilled( + { 0.0f, 0.0f }, + { g_loadingBlackBarMin.x, g_loadingBlackBarMax.y }, + IM_COL32(0, 0, 0, g_loadingBlackBarAlpha)); + + drawList->AddRectFilled( + { g_loadingBlackBarMax.x, g_loadingBlackBarMin.y }, + res, + IM_COL32(0, 0, 0, g_loadingBlackBarAlpha)); + } + else if (g_aspectRatio < NARROW_ASPECT_RATIO) + { + drawList->AddRectFilled( + { 0.0f, 0.0f }, + { g_loadingBlackBarMax.x, g_loadingBlackBarMin.y }, + IM_COL32(0, 0, 0, g_loadingBlackBarAlpha)); + + drawList->AddRectFilled( + { g_loadingBlackBarMin.x, g_loadingBlackBarMax.y }, + res, + IM_COL32(0, 0, 0, g_loadingBlackBarAlpha)); + } + + g_loadingBlackBarAlpha = 0; + } +} diff --git a/UnleashedRecomp/ui/black_bar.h b/UnleashedRecomp/ui/black_bar.h new file mode 100644 index 0000000..7cb0768 --- /dev/null +++ b/UnleashedRecomp/ui/black_bar.h @@ -0,0 +1,12 @@ +#pragma once + +struct BlackBar +{ + static inline bool g_inspirePillarbox; + + static inline ImVec2 g_loadingBlackBarMin; + static inline ImVec2 g_loadingBlackBarMax; + static inline uint8_t g_loadingBlackBarAlpha; + + static void Draw(); +};