mirror of
				https://github.com/hedge-dev/UnleashedRecomp.git
				synced 2025-10-30 07:11:05 +00:00 
			
		
		
		
	Implement black bar drawing for loading and cutscenes. (#298)
This commit is contained in:
		
							parent
							
								
									47b1f20679
								
							
						
					
					
						commit
						9549ba54aa
					
				
					 5 changed files with 100 additions and 1 deletions
				
			
		|  | @ -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" | ||||
|  |  | |||
|  | @ -26,6 +26,7 @@ | |||
| #include <ui/message_window.h> | ||||
| #include <ui/options_menu.h> | ||||
| #include <ui/game_window.h> | ||||
| #include <ui/black_bar.h> | ||||
| #include <patches/aspect_ratio_patches.h> | ||||
| #include <user/config.h> | ||||
| #include <sdl_listener.h> | ||||
|  | @ -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!"); | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ | |||
| #include <api/SWA.h> | ||||
| #include <app.h> | ||||
| #include <ui/game_window.h> | ||||
| #include <ui/black_bar.h> | ||||
| #include <gpu/video.h> | ||||
| #include <xxHashMap.h> | ||||
| 
 | ||||
|  | @ -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<CsdModifier> 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) | ||||
|  |  | |||
							
								
								
									
										58
									
								
								UnleashedRecomp/ui/black_bar.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								UnleashedRecomp/ui/black_bar.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,58 @@ | |||
| #include "black_bar.h" | ||||
| #include <patches/aspect_ratio_patches.h> | ||||
| 
 | ||||
| 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; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										12
									
								
								UnleashedRecomp/ui/black_bar.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								UnleashedRecomp/ui/black_bar.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -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(); | ||||
| }; | ||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Skyth (Asilkan)
						Skyth (Asilkan)