mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-19 06:22:17 +00:00
installer_wizard: implemented button guide
This commit is contained in:
parent
c0897dd507
commit
3c7765eb27
15 changed files with 241 additions and 63 deletions
|
|
@ -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}/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/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/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/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_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")
|
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")
|
||||||
|
|
|
||||||
|
|
@ -166,9 +166,19 @@ int HID_OnSDLEvent(void*, SDL_Event* event)
|
||||||
{
|
{
|
||||||
controller->Poll();
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -178,6 +188,7 @@ void hid::detail::Init()
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1");
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1");
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "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_HIDAPI_WII, "1");
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||||
SDL_SetHint(SDL_HINT_XINPUT_ENABLED, "1");
|
SDL_SetHint(SDL_HINT_XINPUT_ENABLED, "1");
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
#include "hid.h"
|
#include "hid.h"
|
||||||
#include "hid_detail.h"
|
#include "hid_detail.h"
|
||||||
|
|
||||||
|
hid::detail::EInputDevice hid::detail::g_inputDevice;
|
||||||
|
|
||||||
void hid::Init()
|
void hid::Init()
|
||||||
{
|
{
|
||||||
detail::Init();
|
detail::Init();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
union SDL_Event;
|
union SDL_Event;
|
||||||
|
|
||||||
namespace hid
|
namespace hid
|
||||||
{
|
{
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
uint32_t GetState(uint32_t dwUserIndex, XAMINPUT_STATE* pState);
|
uint32_t GetState(uint32_t dwUserIndex, XAMINPUT_STATE* pState);
|
||||||
uint32_t SetState(uint32_t dwUserIndex, XAMINPUT_VIBRATION* pVibration);
|
uint32_t SetState(uint32_t dwUserIndex, XAMINPUT_VIBRATION* pVibration);
|
||||||
|
|
||||||
uint32_t GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps);
|
uint32_t GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace hid::detail
|
namespace hid::detail
|
||||||
{
|
{
|
||||||
|
enum class EInputDevice
|
||||||
|
{
|
||||||
|
Keyboard,
|
||||||
|
Mouse,
|
||||||
|
Controller
|
||||||
|
};
|
||||||
|
|
||||||
|
extern EInputDevice g_inputDevice;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
uint32_t GetState(uint32_t dwUserIndex, XAMINPUT_STATE* pState);
|
uint32_t GetState(uint32_t dwUserIndex, XAMINPUT_STATE* pState);
|
||||||
uint32_t SetState(uint32_t dwUserIndex, XAMINPUT_VIBRATION* pVibration);
|
uint32_t SetState(uint32_t dwUserIndex, XAMINPUT_VIBRATION* pVibration);
|
||||||
|
|
||||||
uint32_t GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps);
|
uint32_t GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -657,7 +657,7 @@ void AchievementMenu::Open()
|
||||||
return std::get<1>(a) > std::get<1>(b);
|
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();
|
ResetSelection();
|
||||||
Game_PlaySound("sys_actstg_pausewinopen");
|
Game_PlaySound("sys_actstg_pausewinopen");
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <gpu/imgui_snapshot.h>
|
#include <gpu/imgui_snapshot.h>
|
||||||
#include <gpu/video.h>
|
#include <gpu/video.h>
|
||||||
#include <decompressor.h>
|
#include <decompressor.h>
|
||||||
#include <res/images/common/left_mouse_button.dds.h>
|
#include <res/images/common/kbm.dds.h>
|
||||||
#include <res/images/common/mat_comon_x360_001.dds.h>
|
#include <res/images/common/mat_comon_x360_001.dds.h>
|
||||||
#include <res/images/common/start_back.dds.h>
|
#include <res/images/common/start_back.dds.h>
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ ImFont* g_fntNewRodin;
|
||||||
ImFont* g_fntNewRodinLQ;
|
ImFont* g_fntNewRodinLQ;
|
||||||
|
|
||||||
std::unique_ptr<GuestTexture> g_upIcons;
|
std::unique_ptr<GuestTexture> g_upIcons;
|
||||||
std::unique_ptr<GuestTexture> g_upLMBIcon;
|
std::unique_ptr<GuestTexture> g_upKBMIcons;
|
||||||
std::unique_ptr<GuestTexture> g_upStartBackIcons;
|
std::unique_ptr<GuestTexture> g_upStartBackIcons;
|
||||||
|
|
||||||
float g_sideMargins = DEFAULT_SIDE_MARGINS;
|
float g_sideMargins = DEFAULT_SIDE_MARGINS;
|
||||||
|
|
@ -34,7 +34,8 @@ std::unordered_map<EButtonIcon, float> g_iconWidths =
|
||||||
{ EButtonIcon::LTRT, 42 },
|
{ EButtonIcon::LTRT, 42 },
|
||||||
{ EButtonIcon::Start, 40 },
|
{ EButtonIcon::Start, 40 },
|
||||||
{ EButtonIcon::Back, 40 },
|
{ EButtonIcon::Back, 40 },
|
||||||
{ EButtonIcon::LMB, 40 }
|
{ EButtonIcon::LMB, 40 },
|
||||||
|
{ EButtonIcon::Enter, 40 }
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unordered_map<EButtonIcon, float> g_iconHeights =
|
std::unordered_map<EButtonIcon, float> g_iconHeights =
|
||||||
|
|
@ -51,7 +52,8 @@ std::unordered_map<EButtonIcon, float> g_iconHeights =
|
||||||
{ EButtonIcon::LTRT, 42 },
|
{ EButtonIcon::LTRT, 42 },
|
||||||
{ EButtonIcon::Start, 40 },
|
{ EButtonIcon::Start, 40 },
|
||||||
{ EButtonIcon::Back, 40 },
|
{ EButtonIcon::Back, 40 },
|
||||||
{ EButtonIcon::LMB, 40 }
|
{ EButtonIcon::LMB, 40 },
|
||||||
|
{ EButtonIcon::Enter, 40 }
|
||||||
};
|
};
|
||||||
|
|
||||||
std::tuple<std::tuple<ImVec2, ImVec2>, GuestTexture*> GetButtonIcon(EButtonIcon icon)
|
std::tuple<std::tuple<ImVec2, ImVec2>, GuestTexture*> GetButtonIcon(EButtonIcon icon)
|
||||||
|
|
@ -112,8 +114,13 @@ std::tuple<std::tuple<ImVec2, ImVec2>, GuestTexture*> GetButtonIcon(EButtonIcon
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EButtonIcon::LMB:
|
case EButtonIcon::LMB:
|
||||||
btn = PIXELS_TO_UV_COORDS(128, 128, 0, 0, 128, 128);
|
btn = PIXELS_TO_UV_COORDS(256, 128, 0, 0, 128, 128);
|
||||||
texture = g_upLMBIcon.get();
|
texture = g_upKBMIcons.get();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EButtonIcon::Enter:
|
||||||
|
btn = PIXELS_TO_UV_COORDS(256, 128, 128, 0, 128, 128);
|
||||||
|
texture = g_upKBMIcons.get();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,9 +214,9 @@ void ButtonGuide::Init()
|
||||||
decompressZstd(g_mat_comon_x360_001, g_mat_comon_x360_001_uncompressed_size).get(),
|
decompressZstd(g_mat_comon_x360_001, g_mat_comon_x360_001_uncompressed_size).get(),
|
||||||
g_mat_comon_x360_001_uncompressed_size);
|
g_mat_comon_x360_001_uncompressed_size);
|
||||||
|
|
||||||
g_upLMBIcon = LoadTexture(
|
g_upKBMIcons = LoadTexture(
|
||||||
decompressZstd(g_left_mouse_button, g_left_mouse_button_uncompressed_size).get(),
|
decompressZstd(g_kbm, g_kbm_uncompressed_size).get(),
|
||||||
g_left_mouse_button_uncompressed_size);
|
g_kbm_uncompressed_size);
|
||||||
|
|
||||||
g_upStartBackIcons = LoadTexture(
|
g_upStartBackIcons = LoadTexture(
|
||||||
decompressZstd(g_start_back, g_start_back_uncompressed_size).get(),
|
decompressZstd(g_start_back, g_start_back_uncompressed_size).get(),
|
||||||
|
|
@ -287,11 +294,20 @@ void ButtonGuide::Draw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonGuide::Open(const std::vector<Button> buttons)
|
void ButtonGuide::Open(Button button)
|
||||||
{
|
{
|
||||||
s_isVisible = true;
|
s_isVisible = true;
|
||||||
g_sideMargins = DEFAULT_SIDE_MARGINS;
|
g_sideMargins = DEFAULT_SIDE_MARGINS;
|
||||||
g_buttons = buttons;
|
|
||||||
|
g_buttons = {};
|
||||||
|
g_buttons.push_back(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ButtonGuide::Open(const std::span<Button> buttons)
|
||||||
|
{
|
||||||
|
s_isVisible = true;
|
||||||
|
g_sideMargins = DEFAULT_SIDE_MARGINS;
|
||||||
|
g_buttons = std::vector(buttons.begin(), buttons.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonGuide::SetSideMargins(float width = DEFAULT_SIDE_MARGINS)
|
void ButtonGuide::SetSideMargins(float width = DEFAULT_SIDE_MARGINS)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
enum class EButtonIcon
|
enum class EButtonIcon
|
||||||
{
|
{
|
||||||
|
// Controller
|
||||||
A,
|
A,
|
||||||
B,
|
B,
|
||||||
X,
|
X,
|
||||||
|
|
@ -16,7 +17,10 @@ enum class EButtonIcon
|
||||||
LTRT,
|
LTRT,
|
||||||
Start,
|
Start,
|
||||||
Back,
|
Back,
|
||||||
LMB
|
|
||||||
|
// Keyboard + Mouse (temporary)
|
||||||
|
LMB,
|
||||||
|
Enter
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class EButtonAlignment
|
enum class EButtonAlignment
|
||||||
|
|
@ -55,7 +59,8 @@ public:
|
||||||
|
|
||||||
static void Init();
|
static void Init();
|
||||||
static void Draw();
|
static void Draw();
|
||||||
static void Open(const std::vector<Button> buttons);
|
static void Open(Button button);
|
||||||
|
static void Open(const std::span<Button> buttons);
|
||||||
static void SetSideMargins(float width);
|
static void SetSideMargins(float width);
|
||||||
static void Close();
|
static void Close();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@
|
||||||
#include <gpu/video.h>
|
#include <gpu/video.h>
|
||||||
#include <gpu/imgui_snapshot.h>
|
#include <gpu/imgui_snapshot.h>
|
||||||
#include <hid/hid.h>
|
#include <hid/hid.h>
|
||||||
|
#include <hid/hid_detail.h>
|
||||||
#include <locale/locale.h>
|
#include <locale/locale.h>
|
||||||
#include <ui/imgui_utils.h>
|
#include <ui/imgui_utils.h>
|
||||||
|
#include <ui/button_guide.h>
|
||||||
#include <ui/message_window.h>
|
#include <ui/message_window.h>
|
||||||
#include <ui/sdl_listener.h>
|
#include <ui/sdl_listener.h>
|
||||||
#include <ui/window.h>
|
#include <ui/window.h>
|
||||||
|
|
@ -676,6 +678,21 @@ static void DrawDescriptionContainer()
|
||||||
ImVec2 sideMax = { Scale(AlignToNextGrid(CONTAINER_X + CONTAINER_WIDTH + SIDE_CONTAINER_WIDTH)), descriptionMax.y };
|
ImVec2 sideMax = { Scale(AlignToNextGrid(CONTAINER_X + CONTAINER_WIDTH + SIDE_CONTAINER_WIDTH)), descriptionMax.y };
|
||||||
DrawContainer(sideMin, sideMax, false);
|
DrawContainer(sideMin, sideMax, false);
|
||||||
drawList->PopClipRect();
|
drawList->PopClipRect();
|
||||||
|
|
||||||
|
if (g_currentPage != WizardPage::Installing && textAlpha >= 1.0)
|
||||||
|
{
|
||||||
|
auto icon = hid::detail::g_inputDevice == hid::detail::EInputDevice::Controller
|
||||||
|
? EButtonIcon::A
|
||||||
|
: hid::detail::g_inputDevice == hid::detail::EInputDevice::Keyboard
|
||||||
|
? EButtonIcon::Enter
|
||||||
|
: EButtonIcon::LMB;
|
||||||
|
|
||||||
|
ButtonGuide::Open(Button(Localise("Common_Select"), icon));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ButtonGuide::Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawButtonContainer(ImVec2 min, ImVec2 max, int baser, int baseg, float alpha)
|
static void DrawButtonContainer(ImVec2 min, ImVec2 max, int baser, int baseg, float alpha)
|
||||||
|
|
@ -1416,7 +1433,7 @@ bool InstallerWizard::Run(bool skipGame)
|
||||||
g_currentPage = g_firstPage;
|
g_currentPage = g_firstPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::SetCursorAllowed(true);
|
Window::SetFullscreenCursorVisibility(true);
|
||||||
s_isVisible = true;
|
s_isVisible = true;
|
||||||
|
|
||||||
while (s_isVisible)
|
while (s_isVisible)
|
||||||
|
|
@ -1427,7 +1444,7 @@ bool InstallerWizard::Run(bool skipGame)
|
||||||
Video::HostPresent();
|
Video::HostPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::SetCursorAllowed(false);
|
Window::SetFullscreenCursorVisibility(false);
|
||||||
NFD_Quit();
|
NFD_Quit();
|
||||||
|
|
||||||
InstallerWizard::Shutdown();
|
InstallerWizard::Shutdown();
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@
|
||||||
#include "imgui_utils.h"
|
#include "imgui_utils.h"
|
||||||
#include <api/SWA.h>
|
#include <api/SWA.h>
|
||||||
#include <gpu/video.h>
|
#include <gpu/video.h>
|
||||||
|
#include <hid/hid_detail.h>
|
||||||
#include <locale/locale.h>
|
#include <locale/locale.h>
|
||||||
#include <ui/button_guide.h>
|
#include <ui/button_guide.h>
|
||||||
|
#include <ui/sdl_listener.h>
|
||||||
#include <app.h>
|
#include <app.h>
|
||||||
#include <exports.h>
|
#include <exports.h>
|
||||||
#include <res/images/common/general_window.dds.h>
|
#include <res/images/common/general_window.dds.h>
|
||||||
|
|
@ -28,6 +30,10 @@ static int g_foregroundCount;
|
||||||
static bool g_upWasHeld;
|
static bool g_upWasHeld;
|
||||||
static bool g_downWasHeld;
|
static bool g_downWasHeld;
|
||||||
|
|
||||||
|
static ImVec2 g_joypadAxis = {};
|
||||||
|
static bool g_isAccepted;
|
||||||
|
static bool g_isDeclined;
|
||||||
|
|
||||||
static double g_appearTime;
|
static double g_appearTime;
|
||||||
static double g_controlsAppearTime;
|
static double g_controlsAppearTime;
|
||||||
|
|
||||||
|
|
@ -40,6 +46,98 @@ std::string g_text;
|
||||||
int g_result;
|
int g_result;
|
||||||
std::vector<std::string> g_buttons;
|
std::vector<std::string> g_buttons;
|
||||||
int g_defaultButtonIndex;
|
int g_defaultButtonIndex;
|
||||||
|
int g_cancelButtonIndex;
|
||||||
|
|
||||||
|
class SDLEventListenerForMessageWindow : public SDLEventListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void OnSDLEvent(SDL_Event* event) override
|
||||||
|
{
|
||||||
|
if (!MessageWindow::s_isVisible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
constexpr float axisValueRange = 32767.0f;
|
||||||
|
constexpr float axisTapRange = 0.5f;
|
||||||
|
|
||||||
|
ImVec2 tapDirection = {};
|
||||||
|
|
||||||
|
switch (event->type)
|
||||||
|
{
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
{
|
||||||
|
switch (event->key.keysym.scancode)
|
||||||
|
{
|
||||||
|
case SDL_SCANCODE_UP:
|
||||||
|
g_joypadAxis.y = -1.0f;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_DOWN:
|
||||||
|
g_joypadAxis.y = 1.0f;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_RETURN:
|
||||||
|
case SDL_SCANCODE_KP_ENTER:
|
||||||
|
g_isAccepted = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_SCANCODE_ESCAPE:
|
||||||
|
g_isDeclined = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
g_isAccepted = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLERBUTTONDOWN:
|
||||||
|
{
|
||||||
|
switch (event->cbutton.button)
|
||||||
|
{
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_UP:
|
||||||
|
g_joypadAxis = { 0.0f, -1.0f };
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
|
||||||
|
g_joypadAxis = { 0.0f, 1.0f };
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_A:
|
||||||
|
g_isAccepted = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_CONTROLLER_BUTTON_B:
|
||||||
|
g_isDeclined = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SDL_CONTROLLERAXISMOTION:
|
||||||
|
{
|
||||||
|
if (event->caxis.axis < 2)
|
||||||
|
{
|
||||||
|
float newAxisValue = event->caxis.value / axisValueRange;
|
||||||
|
bool sameDirection = (newAxisValue * g_joypadAxis[event->caxis.axis]) > 0.0f;
|
||||||
|
bool wasInRange = abs(g_joypadAxis[event->caxis.axis]) > axisTapRange;
|
||||||
|
bool isInRange = abs(newAxisValue) > axisTapRange;
|
||||||
|
|
||||||
|
if (sameDirection && !wasInRange && isInRange)
|
||||||
|
tapDirection[event->caxis.axis] = newAxisValue;
|
||||||
|
|
||||||
|
g_joypadAxis[event->caxis.axis] = newAxisValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static SDLEventListenerForMessageWindow g_eventListener;
|
||||||
|
|
||||||
bool DrawContainer(float appearTime, ImVec2 centre, ImVec2 max, bool isForeground = true)
|
bool DrawContainer(float appearTime, ImVec2 centre, ImVec2 max, bool isForeground = true)
|
||||||
{
|
{
|
||||||
|
|
@ -134,6 +232,9 @@ static void ResetSelection()
|
||||||
g_selectedRowIndex = g_defaultButtonIndex;
|
g_selectedRowIndex = g_defaultButtonIndex;
|
||||||
g_upWasHeld = false;
|
g_upWasHeld = false;
|
||||||
g_downWasHeld = false;
|
g_downWasHeld = false;
|
||||||
|
g_joypadAxis = {};
|
||||||
|
g_isAccepted = false;
|
||||||
|
g_isDeclined = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageWindow::Init()
|
void MessageWindow::Init()
|
||||||
|
|
@ -153,7 +254,6 @@ void MessageWindow::Draw()
|
||||||
if (!s_isVisible)
|
if (!s_isVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto pInputState = g_isGameLoaded ? SWA::CInputState::GetInstance() : nullptr;
|
|
||||||
auto drawList = ImGui::GetForegroundDrawList();
|
auto drawList = ImGui::GetForegroundDrawList();
|
||||||
auto& res = ImGui::GetIO().DisplaySize;
|
auto& res = ImGui::GetIO().DisplaySize;
|
||||||
|
|
||||||
|
|
@ -164,6 +264,9 @@ void MessageWindow::Draw()
|
||||||
auto textMarginX = Scale(37);
|
auto textMarginX = Scale(37);
|
||||||
auto textMarginY = Scale(45);
|
auto textMarginY = Scale(45);
|
||||||
|
|
||||||
|
bool isController = hid::detail::g_inputDevice == hid::detail::EInputDevice::Controller;
|
||||||
|
bool isKeyboard = hid::detail::g_inputDevice == hid::detail::EInputDevice::Keyboard;
|
||||||
|
|
||||||
if (DrawContainer(g_appearTime, centre, { textSize.x / 2 + textMarginX, textSize.y / 2 + textMarginY }, !g_isControlsVisible))
|
if (DrawContainer(g_appearTime, centre, { textSize.x / 2 + textMarginX, textSize.y / 2 + textMarginY }, !g_isControlsVisible))
|
||||||
{
|
{
|
||||||
DrawCentredParagraph
|
DrawCentredParagraph
|
||||||
|
|
@ -182,10 +285,6 @@ void MessageWindow::Draw()
|
||||||
|
|
||||||
drawList->PopClipRect();
|
drawList->PopClipRect();
|
||||||
|
|
||||||
bool isAccepted = pInputState
|
|
||||||
? pInputState->GetPadState().IsTapped(SWA::eKeyState_A)
|
|
||||||
: ImGui::IsMouseClicked(ImGuiMouseButton_Left);
|
|
||||||
|
|
||||||
if (g_buttons.size())
|
if (g_buttons.size())
|
||||||
{
|
{
|
||||||
auto itemWidth = std::max(Scale(162), Scale(CalcWidestTextSize(g_fntSeurat, fontSize, g_buttons)));
|
auto itemWidth = std::max(Scale(162), Scale(CalcWidestTextSize(g_fntSeurat, fontSize, g_buttons)));
|
||||||
|
|
@ -202,13 +301,10 @@ void MessageWindow::Draw()
|
||||||
for (auto& button : g_buttons)
|
for (auto& button : g_buttons)
|
||||||
DrawButton(rowCount++, windowMarginY, itemWidth, itemHeight, button);
|
DrawButton(rowCount++, windowMarginY, itemWidth, itemHeight, button);
|
||||||
|
|
||||||
if (pInputState)
|
if (isController || isKeyboard)
|
||||||
{
|
{
|
||||||
bool upIsHeld = pInputState->GetPadState().IsDown(SWA::eKeyState_DpadUp) ||
|
bool upIsHeld = g_joypadAxis.y > 0.5f;
|
||||||
pInputState->GetPadState().LeftStickVertical > 0.5f;
|
bool downIsHeld = g_joypadAxis.y < -0.5f;
|
||||||
|
|
||||||
bool downIsHeld = pInputState->GetPadState().IsDown(SWA::eKeyState_DpadDown) ||
|
|
||||||
pInputState->GetPadState().LeftStickVertical < -0.5f;
|
|
||||||
|
|
||||||
bool scrollUp = !g_upWasHeld && upIsHeld;
|
bool scrollUp = !g_upWasHeld && upIsHeld;
|
||||||
bool scrollDown = !g_downWasHeld && downIsHeld;
|
bool scrollDown = !g_downWasHeld && downIsHeld;
|
||||||
|
|
@ -232,21 +328,28 @@ void MessageWindow::Draw()
|
||||||
g_upWasHeld = upIsHeld;
|
g_upWasHeld = upIsHeld;
|
||||||
g_downWasHeld = downIsHeld;
|
g_downWasHeld = downIsHeld;
|
||||||
|
|
||||||
if (pInputState->GetPadState().IsTapped(SWA::eKeyState_B))
|
if (g_isDeclined)
|
||||||
{
|
{
|
||||||
g_result = -1;
|
g_result = g_cancelButtonIndex;
|
||||||
|
|
||||||
Game_PlaySound("sys_actstg_pausecansel");
|
Game_PlaySound("sys_actstg_pausecansel");
|
||||||
MessageWindow::Close();
|
MessageWindow::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonGuide::Open
|
if (isController)
|
||||||
(
|
{
|
||||||
|
std::array<Button, 2> buttons =
|
||||||
{
|
{
|
||||||
Button(Localise("Common_Select"), EButtonIcon::A),
|
Button(Localise("Common_Select"), EButtonIcon::A),
|
||||||
Button(Localise("Common_Back"),EButtonIcon::B),
|
Button(Localise("Common_Back"), EButtonIcon::B),
|
||||||
}
|
};
|
||||||
);
|
|
||||||
|
ButtonGuide::Open(buttons);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ButtonGuide::Open(Button(Localise("Common_Select"), EButtonIcon::Enter));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -264,10 +367,10 @@ void MessageWindow::Draw()
|
||||||
g_selectedRowIndex = i;
|
g_selectedRowIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonGuide::Open({ Button(Localise("Common_Select"), EButtonIcon::LMB) });
|
ButtonGuide::Open(Button(Localise("Common_Select"), EButtonIcon::LMB));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_selectedRowIndex != -1 && isAccepted)
|
if (g_selectedRowIndex != -1 && g_isAccepted)
|
||||||
{
|
{
|
||||||
g_result = g_selectedRowIndex;
|
g_result = g_selectedRowIndex;
|
||||||
|
|
||||||
|
|
@ -279,18 +382,27 @@ void MessageWindow::Draw()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!g_isControlsVisible && isAccepted)
|
auto icon = isController
|
||||||
|
? EButtonIcon::A
|
||||||
|
: isKeyboard
|
||||||
|
? EButtonIcon::Enter
|
||||||
|
: EButtonIcon::LMB;
|
||||||
|
|
||||||
|
ButtonGuide::Open(Button(Localise("Common_Next"), icon));
|
||||||
|
|
||||||
|
if (!g_isControlsVisible && g_isAccepted)
|
||||||
{
|
{
|
||||||
g_controlsAppearTime = ImGui::GetTime();
|
g_controlsAppearTime = ImGui::GetTime();
|
||||||
g_isControlsVisible = true;
|
g_isControlsVisible = true;
|
||||||
|
|
||||||
|
ResetSelection();
|
||||||
Game_PlaySound("sys_actstg_pausewinopen");
|
Game_PlaySound("sys_actstg_pausewinopen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isAccepted)
|
if (g_isAccepted)
|
||||||
{
|
{
|
||||||
g_result = 0;
|
g_result = 0;
|
||||||
|
|
||||||
|
|
@ -304,7 +416,7 @@ void MessageWindow::Draw()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageWindow::Open(std::string text, int* result, std::span<std::string> buttons, int defaultButtonIndex)
|
bool MessageWindow::Open(std::string text, int* result, std::span<std::string> buttons, int defaultButtonIndex, int cancelButtonIndex)
|
||||||
{
|
{
|
||||||
if (!g_isAwaitingResult && *result == -1)
|
if (!g_isAwaitingResult && *result == -1)
|
||||||
{
|
{
|
||||||
|
|
@ -317,12 +429,11 @@ bool MessageWindow::Open(std::string text, int* result, std::span<std::string> b
|
||||||
|
|
||||||
g_text = text;
|
g_text = text;
|
||||||
g_buttons = std::vector(buttons.begin(), buttons.end());
|
g_buttons = std::vector(buttons.begin(), buttons.end());
|
||||||
g_defaultButtonIndex = g_isGameLoaded ? defaultButtonIndex : -1;
|
g_defaultButtonIndex = defaultButtonIndex;
|
||||||
|
g_cancelButtonIndex = cancelButtonIndex;
|
||||||
|
|
||||||
ResetSelection();
|
ResetSelection();
|
||||||
|
|
||||||
ButtonGuide::Open({ Button(Localise("Common_Next"), g_isGameLoaded ? EButtonIcon::A : EButtonIcon::LMB) });
|
|
||||||
|
|
||||||
Game_PlaySound("sys_actstg_pausewinopen");
|
Game_PlaySound("sys_actstg_pausewinopen");
|
||||||
|
|
||||||
g_isAwaitingResult = true;
|
g_isAwaitingResult = true;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ public:
|
||||||
|
|
||||||
static void Init();
|
static void Init();
|
||||||
static void Draw();
|
static void Draw();
|
||||||
static bool Open(std::string text, int* result, std::span<std::string> buttons = {}, int defaultButtonIndex = 0);
|
static bool Open(std::string text, int* result, std::span<std::string> buttons = {}, int defaultButtonIndex = 0, int cancelButtonIndex = 1);
|
||||||
static void Close();
|
static void Close();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1030,15 +1030,15 @@ void OptionsMenu::Open(bool isPause, SWA::EMenuType pauseMenuType)
|
||||||
|
|
||||||
*(bool*)g_memory.Translate(0x8328BB26) = false;
|
*(bool*)g_memory.Translate(0x8328BB26) = false;
|
||||||
|
|
||||||
ButtonGuide::Open
|
std::array<Button, 4> buttons =
|
||||||
(
|
{
|
||||||
{
|
Button(Localise("Common_Switch"), EButtonIcon::LBRB, EButtonAlignment::Left),
|
||||||
Button(Localise("Common_Switch"), EButtonIcon::LBRB, EButtonAlignment::Left),
|
Button(Localise("Common_Reset"), EButtonIcon::X, &g_canReset),
|
||||||
Button(Localise("Common_Reset"), EButtonIcon::X, &g_canReset),
|
Button(Localise("Common_Select"), EButtonIcon::A),
|
||||||
Button(Localise("Common_Select"), EButtonIcon::A),
|
Button(Localise("Common_Back"), EButtonIcon::B)
|
||||||
Button(Localise("Common_Back"), EButtonIcon::B)
|
};
|
||||||
}
|
|
||||||
);
|
ButtonGuide::Open(buttons);
|
||||||
|
|
||||||
ButtonGuide::SetSideMargins(250);
|
ButtonGuide::SetSideMargins(250);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ int Window_OnSDLEvent(void*, SDL_Event* event)
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
Window::s_isFocused = true;
|
Window::s_isFocused = true;
|
||||||
SDL_ShowCursor(Window::IsFullscreen() && !Window::s_cursorAllowed ? SDL_DISABLE : SDL_ENABLE);
|
SDL_ShowCursor(Window::IsFullscreen() && Window::s_isFullscreenCursorVisible ? SDL_ENABLE : SDL_DISABLE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_RESTORED:
|
case SDL_WINDOWEVENT_RESTORED:
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public:
|
||||||
|
|
||||||
inline static bool s_isFocused;
|
inline static bool s_isFocused;
|
||||||
inline static bool s_isIconNight;
|
inline static bool s_isIconNight;
|
||||||
inline static bool s_cursorAllowed = false;
|
inline static bool s_isFullscreenCursorVisible;
|
||||||
|
|
||||||
static SDL_Surface* GetIconSurface(void* pIconBmp, size_t iconSize)
|
static SDL_Surface* GetIconSurface(void* pIconBmp, size_t iconSize)
|
||||||
{
|
{
|
||||||
|
|
@ -100,7 +100,7 @@ public:
|
||||||
if (isEnabled)
|
if (isEnabled)
|
||||||
{
|
{
|
||||||
SDL_SetWindowFullscreen(s_pWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
SDL_SetWindowFullscreen(s_pWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
SDL_ShowCursor(s_cursorAllowed ? SDL_ENABLE : SDL_DISABLE);
|
SDL_ShowCursor(s_isFullscreenCursorVisible ? SDL_ENABLE : SDL_DISABLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -112,12 +112,18 @@ public:
|
||||||
return isEnabled;
|
return isEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetCursorAllowed(bool isCursorAllowed)
|
static void SetFullscreenCursorVisibility(bool isVisible)
|
||||||
{
|
{
|
||||||
s_cursorAllowed = isCursorAllowed;
|
s_isFullscreenCursorVisible = isVisible;
|
||||||
|
|
||||||
// Refresh fullscreen state to enable the right cursor behavior.
|
if (IsFullscreen())
|
||||||
SetFullscreen(IsFullscreen());
|
{
|
||||||
|
SDL_ShowCursor(s_isFullscreenCursorVisible ? SDL_ENABLE : SDL_DISABLE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsMaximised()
|
static bool IsMaximised()
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit ccb516047d697f9e4009a0b4b534adcef758b64a
|
Subproject commit 0942fed82d63ebce8f6cec3a09e31c7f3fd05ecc
|
||||||
Loading…
Add table
Reference in a new issue