LUS Bump, Mouse Capture/Cursor Visibility Improvements (#5797)
* Bump LUS to include FileDropMgr's new registration system and initial cursor visibility changes. * New LUS ref. * Remove default on for cursor always visible. Add option to camera controls next to enable mouse input for autocapture. Set autocapture on startup. * next LUS * clang again * Add "EnableMouse" CVar check to startup SetAutoCaptureMouse. * Back to LUS main. * Final LUS ref bump.
This commit is contained in:
Submodule libultraship updated: 7f737f8be9...64f16273a3
@@ -1,5 +1,6 @@
|
|||||||
#include "SohInputEditorWindow.h"
|
#include "SohInputEditorWindow.h"
|
||||||
#include <utils/StringHelper.h>
|
#include <utils/StringHelper.h>
|
||||||
|
#include "graphic/Fast3D/Fast3dWindow.h"
|
||||||
#include "soh/OTRGlobals.h"
|
#include "soh/OTRGlobals.h"
|
||||||
#include "soh/SohGui/SohMenu.h"
|
#include "soh/SohGui/SohMenu.h"
|
||||||
#include "soh/SohGui/SohGui.hpp"
|
#include "soh/SohGui/SohGui.hpp"
|
||||||
@@ -15,6 +16,7 @@ using namespace UIWidgets;
|
|||||||
|
|
||||||
static WidgetInfo freeLook;
|
static WidgetInfo freeLook;
|
||||||
static WidgetInfo mouseControl;
|
static WidgetInfo mouseControl;
|
||||||
|
static WidgetInfo mouseAutoCapture;
|
||||||
static WidgetInfo rightStickOcarina;
|
static WidgetInfo rightStickOcarina;
|
||||||
static WidgetInfo dpadOcarina;
|
static WidgetInfo dpadOcarina;
|
||||||
static WidgetInfo dpadPause;
|
static WidgetInfo dpadPause;
|
||||||
@@ -1366,6 +1368,9 @@ void SohInputEditorWindow::DrawCameraControlPanel() {
|
|||||||
ImVec2 cursor = ImGui::GetCursorPos();
|
ImVec2 cursor = ImGui::GetCursorPos();
|
||||||
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
||||||
SohGui::mSohMenu->MenuDrawItem(mouseControl, ImGui::GetContentRegionAvail().x, THEME_COLOR);
|
SohGui::mSohMenu->MenuDrawItem(mouseControl, ImGui::GetContentRegionAvail().x, THEME_COLOR);
|
||||||
|
cursor = ImGui::GetCursorPos();
|
||||||
|
ImGui::SetCursorPos(ImVec2(cursor.x + 5, cursor.y + 5));
|
||||||
|
SohGui::mSohMenu->MenuDrawItem(mouseAutoCapture, ImGui::GetContentRegionAvail().x, THEME_COLOR);
|
||||||
|
|
||||||
Ship::GuiWindow::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail());
|
Ship::GuiWindow::BeginGroupPanel("Aiming/First-Person Camera", ImGui::GetContentRegionAvail());
|
||||||
CVarCheckbox("Right Stick Aiming", CVAR_SETTING("Controls.RightStickAim"),
|
CVarCheckbox("Right Stick Aiming", CVAR_SETTING("Controls.RightStickAim"),
|
||||||
@@ -1914,13 +1919,35 @@ void RegisterInputEditorWidgets() {
|
|||||||
|
|
||||||
mouseControl = { .name = "Enable Mouse Controls", .type = WidgetType::WIDGET_CVAR_CHECKBOX };
|
mouseControl = { .name = "Enable Mouse Controls", .type = WidgetType::WIDGET_CVAR_CHECKBOX };
|
||||||
mouseControl.CVar(CVAR_SETTING("EnableMouse"))
|
mouseControl.CVar(CVAR_SETTING("EnableMouse"))
|
||||||
|
.Callback([](WidgetInfo& info) {
|
||||||
|
bool enabled =
|
||||||
|
CVarGetInteger(CVAR_SETTING("EnableMouse"), 0) && CVarGetInteger(CVAR_SETTING("AutoCaptureMouse"), 1);
|
||||||
|
auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow());
|
||||||
|
wnd->SetAutoCaptureMouse(enabled);
|
||||||
|
})
|
||||||
.Options(
|
.Options(
|
||||||
CheckboxOptions()
|
CheckboxOptions()
|
||||||
.Color(THEME_COLOR)
|
.Color(THEME_COLOR)
|
||||||
.Tooltip("Allows for using the mouse to control the camera (must enable Free Look), "
|
.Tooltip("Allows for using the mouse to control the camera (must enable Free Look), "
|
||||||
"aim with the shield, and perform quickspin attacks (quickly rotate the mouse then press B)"));
|
"aim with the shield, and perform quickspin attacks (quickly rotate the mouse then press B)\n"
|
||||||
|
"Press F2 to toggle mouse capture manually."));
|
||||||
SohGui::mSohMenu->AddSearchWidget({ mouseControl, "Settings", "Controls", "Camera Controls" });
|
SohGui::mSohMenu->AddSearchWidget({ mouseControl, "Settings", "Controls", "Camera Controls" });
|
||||||
|
|
||||||
|
mouseAutoCapture = { .name = "Auto Capture Mouse Input", .type = WidgetType::WIDGET_CVAR_CHECKBOX };
|
||||||
|
mouseAutoCapture.CVar(CVAR_SETTING("AutoCaptureMouse"))
|
||||||
|
.Callback([](WidgetInfo& info) {
|
||||||
|
bool enabled =
|
||||||
|
CVarGetInteger(CVAR_SETTING("EnableMouse"), 0) && CVarGetInteger(CVAR_SETTING("AutoCaptureMouse"), 1);
|
||||||
|
auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow());
|
||||||
|
wnd->SetAutoCaptureMouse(enabled);
|
||||||
|
})
|
||||||
|
.Options(CheckboxOptions()
|
||||||
|
.Color(THEME_COLOR)
|
||||||
|
.Tooltip("When Mouse Controls are enabled, this toggles whether the program will automatically "
|
||||||
|
"hide the cursor "
|
||||||
|
"and capture mouse input when closing the menu."));
|
||||||
|
SohGui::mSohMenu->AddSearchWidget({ mouseAutoCapture, "Settings", "Controls", "Camera Controls" });
|
||||||
|
|
||||||
rightStickOcarina = { .name = "Right Stick Ocarina Playback", .type = WidgetType::WIDGET_CVAR_CHECKBOX };
|
rightStickOcarina = { .name = "Right Stick Ocarina Playback", .type = WidgetType::WIDGET_CVAR_CHECKBOX };
|
||||||
rightStickOcarina.CVar(CVAR_SETTING("CustomOcarina.RightStick")).Options(CheckboxOptions().Color(THEME_COLOR));
|
rightStickOcarina.CVar(CVAR_SETTING("CustomOcarina.RightStick")).Options(CheckboxOptions().Color(THEME_COLOR));
|
||||||
SohGui::mSohMenu->AddSearchWidget({ rightStickOcarina, "Settings", "Controls", "Ocarina Controls" });
|
SohGui::mSohMenu->AddSearchWidget({ rightStickOcarina, "Settings", "Controls", "Ocarina Controls" });
|
||||||
|
|||||||
@@ -71,6 +71,5 @@ DEFINE_HOOK(OnFileChooseMain, (void* gameState));
|
|||||||
DEFINE_HOOK(OnGenerationCompletion, ());
|
DEFINE_HOOK(OnGenerationCompletion, ());
|
||||||
|
|
||||||
DEFINE_HOOK(OnSetGameLanguage, ());
|
DEFINE_HOOK(OnSetGameLanguage, ());
|
||||||
DEFINE_HOOK(OnFileDropped, (std::string filePath));
|
|
||||||
DEFINE_HOOK(OnAssetAltChange, ());
|
DEFINE_HOOK(OnAssetAltChange, ());
|
||||||
DEFINE_HOOK(OnKaleidoUpdate, ());
|
DEFINE_HOOK(OnKaleidoUpdate, ());
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "soh/OTRGlobals.h"
|
#include "soh/OTRGlobals.h"
|
||||||
|
#include "window/FileDropMgr.h"
|
||||||
#include "soh/SohGui/UIWidgets.hpp"
|
#include "soh/SohGui/UIWidgets.hpp"
|
||||||
#include "static_data.h"
|
#include "static_data.h"
|
||||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||||
@@ -387,6 +388,29 @@ static const char* frenchRupeeNames[39] = {
|
|||||||
"Pièces", "Plastyks", "Pokédollars", "Pokémon", "Radis", "Rubis", "Zennies",
|
"Pièces", "Plastyks", "Pokédollars", "Pokémon", "Radis", "Rubis", "Zennies",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Rando_HandleSpoilerDrop(char* filePath) {
|
||||||
|
if (SohUtils::IsStringEmpty(filePath)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
std::ifstream stream(filePath);
|
||||||
|
if (!stream) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json json;
|
||||||
|
stream >> json;
|
||||||
|
|
||||||
|
if (json.contains("version") && json.contains("finalSeed")) {
|
||||||
|
CVarSetString(CVAR_GENERAL("RandomizerDroppedFile"), filePath);
|
||||||
|
CVarSetInteger(CVAR_GENERAL("RandomizerNewFileDropped"), 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (std::exception& e) {}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Randomizer::Randomizer() {
|
Randomizer::Randomizer() {
|
||||||
Rando::StaticData::InitItemTable();
|
Rando::StaticData::InitItemTable();
|
||||||
Rando::StaticData::InitLocationTable();
|
Rando::StaticData::InitLocationTable();
|
||||||
@@ -403,6 +427,8 @@ Randomizer::Randomizer() {
|
|||||||
for (size_t c = 0; c < Rando::StaticData::hintTypeNames.size(); c++) {
|
for (size_t c = 0; c < Rando::StaticData::hintTypeNames.size(); c++) {
|
||||||
SpoilerfileHintTypeNameToEnum[Rando::StaticData::hintTypeNames[(HintType)c].GetEnglish(MF_CLEAN)] = (HintType)c;
|
SpoilerfileHintTypeNameToEnum[Rando::StaticData::hintTypeNames[(HintType)c].GetEnglish(MF_CLEAN)] = (HintType)c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ship::Context::GetInstance()->GetFileDropMgr()->RegisterDropHandler(Rando_HandleSpoilerDrop);
|
||||||
}
|
}
|
||||||
|
|
||||||
Randomizer::~Randomizer() {
|
Randomizer::~Randomizer() {
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ extern "C" {
|
|||||||
#include "src/overlays/actors/ovl_En_Dns/z_en_dns.h"
|
#include "src/overlays/actors/ovl_En_Dns/z_en_dns.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoH_ProcessDroppedFiles(std::string filePath);
|
bool SoH_HandleConfigDrop(char* filePath);
|
||||||
|
|
||||||
OTRGlobals* OTRGlobals::Instance;
|
OTRGlobals* OTRGlobals::Instance;
|
||||||
SaveManager* SaveManager::Instance;
|
SaveManager* SaveManager::Instance;
|
||||||
@@ -327,6 +327,10 @@ void OTRGlobals::Initialize() {
|
|||||||
std::make_shared<Fast::Fast3dWindow>(std::vector<std::shared_ptr<Ship::GuiWindow>>({ sohInputEditorWindow }));
|
std::make_shared<Fast::Fast3dWindow>(std::vector<std::shared_ptr<Ship::GuiWindow>>({ sohInputEditorWindow }));
|
||||||
context->InitWindow(sohFast3dWindow);
|
context->InitWindow(sohFast3dWindow);
|
||||||
|
|
||||||
|
context->GetWindow()->SetAutoCaptureMouse(CVarGetInteger(CVAR_SETTING("EnableMouse"), 0) &&
|
||||||
|
CVarGetInteger(CVAR_SETTING("AutoCaptureMouse"), 1));
|
||||||
|
context->GetWindow()->SetForceCursorVisibility(CVarGetInteger(CVAR_SETTING("CursorVisibility"), 0));
|
||||||
|
|
||||||
auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay();
|
auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay();
|
||||||
overlay->LoadFont("Press Start 2P", 12.0f, "fonts/PressStart2P-Regular.ttf");
|
overlay->LoadFont("Press Start 2P", 12.0f, "fonts/PressStart2P-Regular.ttf");
|
||||||
overlay->LoadFont("Fipps", 32.0f, "fonts/Fipps-Regular.otf");
|
overlay->LoadFont("Fipps", 32.0f, "fonts/Fipps-Regular.otf");
|
||||||
@@ -1270,7 +1274,8 @@ extern "C" void InitOTR() {
|
|||||||
CVarClear(CVAR_GENERAL("RandomizerNewFileDropped"));
|
CVarClear(CVAR_GENERAL("RandomizerNewFileDropped"));
|
||||||
CVarClear(CVAR_GENERAL("RandomizerDroppedFile"));
|
CVarClear(CVAR_GENERAL("RandomizerDroppedFile"));
|
||||||
// #endregion
|
// #endregion
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnFileDropped>(SoH_ProcessDroppedFiles);
|
|
||||||
|
Ship::Context::GetInstance()->GetFileDropMgr()->RegisterDropHandler(SoH_HandleConfigDrop);
|
||||||
|
|
||||||
RegisterImGuiItemIcons();
|
RegisterImGuiItemIcons();
|
||||||
|
|
||||||
@@ -1455,15 +1460,6 @@ extern "C" void Graph_StartFrame() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto dropMgr = Ship::Context::GetInstance()->GetFileDropMgr();
|
|
||||||
if (dropMgr->FileDropped()) {
|
|
||||||
std::string filePath = dropMgr->GetDroppedFile();
|
|
||||||
if (!filePath.empty()) {
|
|
||||||
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnFileDropped>(filePath);
|
|
||||||
}
|
|
||||||
dropMgr->ClearDroppedFile();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements) {
|
void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements) {
|
||||||
@@ -2761,26 +2757,21 @@ extern "C" void Gfx_TextureCacheDelete(const uint8_t* texAddr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoH_ProcessDroppedFiles(std::string filePath) {
|
bool SoH_HandleConfigDrop(char* filePath) {
|
||||||
|
if (SohUtils::IsStringEmpty(filePath)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
std::ifstream configStream(filePath);
|
std::ifstream configStream(filePath);
|
||||||
if (!configStream) {
|
if (!configStream) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json configJson;
|
nlohmann::json configJson;
|
||||||
configStream >> configJson;
|
configStream >> configJson;
|
||||||
|
|
||||||
// #region SOH [Randomizer] TODO: Refactor spoiler file handling for randomizer
|
|
||||||
if (configJson.contains("version") && configJson.contains("finalSeed")) {
|
|
||||||
CVarSetString(CVAR_GENERAL("RandomizerDroppedFile"), filePath.c_str());
|
|
||||||
CVarSetInteger(CVAR_GENERAL("RandomizerNewFileDropped"), 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
if (!configJson.contains("CVars")) {
|
if (!configJson.contains("CVars")) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVarClearBlock(CVAR_PREFIX_ENHANCEMENT);
|
CVarClearBlock(CVAR_PREFIX_ENHANCEMENT);
|
||||||
@@ -2826,17 +2817,19 @@ void SoH_ProcessDroppedFiles(std::string filePath) {
|
|||||||
|
|
||||||
uint32_t finalHash = SohUtils::Hash(configJson.dump());
|
uint32_t finalHash = SohUtils::Hash(configJson.dump());
|
||||||
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Configuration Loaded. Hash: %d", finalHash);
|
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Configuration Loaded. Hash: %d", finalHash);
|
||||||
|
return true;
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
SPDLOG_ERROR("Failed to load config file: {}", e.what());
|
SPDLOG_ERROR("Failed to load config file: {}", e.what());
|
||||||
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
|
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
|
||||||
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Failed to load config file");
|
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Failed to load config file");
|
||||||
return;
|
return false;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
SPDLOG_ERROR("Failed to load config file");
|
SPDLOG_ERROR("Failed to load config file");
|
||||||
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
|
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
|
||||||
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Failed to load config file");
|
gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Failed to load config file");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void CheckTracker_RecalculateAvailableChecks() {
|
extern "C" void CheckTracker_RecalculateAvailableChecks() {
|
||||||
|
|||||||
Reference in New Issue
Block a user