From 3c7765eb27b6beeac587c1bb6bf5640ebebb28b5 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Fri, 6 Dec 2024 18:10:46 +0000 Subject: [PATCH] installer_wizard: implemented button guide --- UnleashedRecomp/CMakeLists.txt | 2 +- UnleashedRecomp/hid/driver/sdl_hid.cpp | 11 ++ UnleashedRecomp/hid/hid.cpp | 2 + UnleashedRecomp/hid/hid.h | 3 +- UnleashedRecomp/hid/hid_detail.h | 11 +- UnleashedRecomp/ui/achievement_menu.cpp | 2 +- UnleashedRecomp/ui/button_guide.cpp | 38 ++++-- UnleashedRecomp/ui/button_guide.h | 9 +- UnleashedRecomp/ui/installer_wizard.cpp | 21 ++- UnleashedRecomp/ui/message_window.cpp | 163 ++++++++++++++++++++---- UnleashedRecomp/ui/message_window.h | 2 +- UnleashedRecomp/ui/options_menu.cpp | 18 +-- UnleashedRecomp/ui/window.cpp | 2 +- UnleashedRecomp/ui/window.h | 18 ++- UnleashedRecompResources | 2 +- 15 files changed, 241 insertions(+), 63 deletions(-) diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index cb8ec0f..b405c55 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -326,7 +326,7 @@ BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/font/im_f BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/font/im_font_atlas.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/font/im_font_atlas.dds" ARRAY_NAME "g_im_font_atlas_texture" COMPRESSION_TYPE "zstd") BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/achievements_menu/trophy.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/achievements_menu/trophy.dds" ARRAY_NAME "g_trophy" COMPRESSION_TYPE "zstd") BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/common/general_window.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/common/general_window.dds" ARRAY_NAME "g_general_window" COMPRESSION_TYPE "zstd") -BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/common/left_mouse_button.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/common/left_mouse_button.dds" ARRAY_NAME "g_left_mouse_button" COMPRESSION_TYPE "zstd") +BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/common/kbm.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/common/kbm.dds" ARRAY_NAME "g_kbm" COMPRESSION_TYPE "zstd") BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/common/mat_comon_x360_001.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/common/mat_comon_x360_001.dds" ARRAY_NAME "g_mat_comon_x360_001" COMPRESSION_TYPE "zstd") BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/common/select_fade.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/common/select_fade.dds" ARRAY_NAME "g_select_fade" COMPRESSION_TYPE "zstd") BIN2C(TARGET_OBJ UnleashedRecomp SOURCE_FILE "${RESOURCES_SOURCE_PATH}/images/common/select_fill.dds" DEST_FILE "${RESOURCES_OUTPUT_PATH}/images/common/select_fill.dds" ARRAY_NAME "g_select_fill" COMPRESSION_TYPE "zstd") diff --git a/UnleashedRecomp/hid/driver/sdl_hid.cpp b/UnleashedRecomp/hid/driver/sdl_hid.cpp index ee57f9b..6a49c77 100644 --- a/UnleashedRecomp/hid/driver/sdl_hid.cpp +++ b/UnleashedRecomp/hid/driver/sdl_hid.cpp @@ -166,9 +166,19 @@ int HID_OnSDLEvent(void*, SDL_Event* event) { controller->Poll(); } + + hid::detail::g_inputDevice = hid::detail::EInputDevice::Controller; } } } + else if (event->type == SDL_KEYDOWN || event->type == SDL_KEYUP) + { + hid::detail::g_inputDevice = hid::detail::EInputDevice::Keyboard; + } + else if (event->type == SDL_MOUSEMOTION || event->type == SDL_MOUSEBUTTONDOWN || event->type == SDL_MOUSEBUTTONUP) + { + hid::detail::g_inputDevice = hid::detail::EInputDevice::Mouse; + } return 0; } @@ -178,6 +188,7 @@ void hid::detail::Init() SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_WII, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); SDL_SetHint(SDL_HINT_XINPUT_ENABLED, "1"); diff --git a/UnleashedRecomp/hid/hid.cpp b/UnleashedRecomp/hid/hid.cpp index c08961a..8f5b70d 100644 --- a/UnleashedRecomp/hid/hid.cpp +++ b/UnleashedRecomp/hid/hid.cpp @@ -2,6 +2,8 @@ #include "hid.h" #include "hid_detail.h" +hid::detail::EInputDevice hid::detail::g_inputDevice; + void hid::Init() { detail::Init(); diff --git a/UnleashedRecomp/hid/hid.h b/UnleashedRecomp/hid/hid.h index 90370d3..4f350af 100644 --- a/UnleashedRecomp/hid/hid.h +++ b/UnleashedRecomp/hid/hid.h @@ -1,11 +1,12 @@ #pragma once union SDL_Event; + namespace hid { void Init(); + uint32_t GetState(uint32_t dwUserIndex, XAMINPUT_STATE* pState); uint32_t SetState(uint32_t dwUserIndex, XAMINPUT_VIBRATION* pVibration); - uint32_t GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps); } diff --git a/UnleashedRecomp/hid/hid_detail.h b/UnleashedRecomp/hid/hid_detail.h index 1e9ca1b..7c9d1f5 100644 --- a/UnleashedRecomp/hid/hid_detail.h +++ b/UnleashedRecomp/hid/hid_detail.h @@ -1,10 +1,19 @@ #pragma once + namespace hid::detail { + enum class EInputDevice + { + Keyboard, + Mouse, + Controller + }; + + extern EInputDevice g_inputDevice; + void Init(); uint32_t GetState(uint32_t dwUserIndex, XAMINPUT_STATE* pState); uint32_t SetState(uint32_t dwUserIndex, XAMINPUT_VIBRATION* pVibration); - uint32_t GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps); } diff --git a/UnleashedRecomp/ui/achievement_menu.cpp b/UnleashedRecomp/ui/achievement_menu.cpp index 143b969..6576a31 100644 --- a/UnleashedRecomp/ui/achievement_menu.cpp +++ b/UnleashedRecomp/ui/achievement_menu.cpp @@ -657,7 +657,7 @@ void AchievementMenu::Open() return std::get<1>(a) > std::get<1>(b); }); - ButtonGuide::Open({ Button(Localise("Common_Back"), EButtonIcon::B) }); + ButtonGuide::Open(Button(Localise("Common_Back"), EButtonIcon::B)); ResetSelection(); Game_PlaySound("sys_actstg_pausewinopen"); diff --git a/UnleashedRecomp/ui/button_guide.cpp b/UnleashedRecomp/ui/button_guide.cpp index 213ea5f..40410c0 100644 --- a/UnleashedRecomp/ui/button_guide.cpp +++ b/UnleashedRecomp/ui/button_guide.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -13,7 +13,7 @@ ImFont* g_fntNewRodin; ImFont* g_fntNewRodinLQ; std::unique_ptr g_upIcons; -std::unique_ptr g_upLMBIcon; +std::unique_ptr g_upKBMIcons; std::unique_ptr g_upStartBackIcons; float g_sideMargins = DEFAULT_SIDE_MARGINS; @@ -34,7 +34,8 @@ std::unordered_map g_iconWidths = { EButtonIcon::LTRT, 42 }, { EButtonIcon::Start, 40 }, { EButtonIcon::Back, 40 }, - { EButtonIcon::LMB, 40 } + { EButtonIcon::LMB, 40 }, + { EButtonIcon::Enter, 40 } }; std::unordered_map g_iconHeights = @@ -51,7 +52,8 @@ std::unordered_map g_iconHeights = { EButtonIcon::LTRT, 42 }, { EButtonIcon::Start, 40 }, { EButtonIcon::Back, 40 }, - { EButtonIcon::LMB, 40 } + { EButtonIcon::LMB, 40 }, + { EButtonIcon::Enter, 40 } }; std::tuple, GuestTexture*> GetButtonIcon(EButtonIcon icon) @@ -112,8 +114,13 @@ std::tuple, GuestTexture*> GetButtonIcon(EButtonIcon break; case EButtonIcon::LMB: - btn = PIXELS_TO_UV_COORDS(128, 128, 0, 0, 128, 128); - texture = g_upLMBIcon.get(); + btn = PIXELS_TO_UV_COORDS(256, 128, 0, 0, 128, 128); + texture = g_upKBMIcons.get(); + break; + + case EButtonIcon::Enter: + btn = PIXELS_TO_UV_COORDS(256, 128, 128, 0, 128, 128); + texture = g_upKBMIcons.get(); break; } @@ -207,9 +214,9 @@ void ButtonGuide::Init() decompressZstd(g_mat_comon_x360_001, g_mat_comon_x360_001_uncompressed_size).get(), g_mat_comon_x360_001_uncompressed_size); - g_upLMBIcon = LoadTexture( - decompressZstd(g_left_mouse_button, g_left_mouse_button_uncompressed_size).get(), - g_left_mouse_button_uncompressed_size); + g_upKBMIcons = LoadTexture( + decompressZstd(g_kbm, g_kbm_uncompressed_size).get(), + g_kbm_uncompressed_size); g_upStartBackIcons = LoadTexture( decompressZstd(g_start_back, g_start_back_uncompressed_size).get(), @@ -287,11 +294,20 @@ void ButtonGuide::Draw() } } -void ButtonGuide::Open(const std::vector