mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-08-29 17:32:39 -04:00
Switch LUS to port-maintenance branch (#727)
* lus update compiles but not run * Game runs, fix demo bug * Switch lus to port-maintenance branch
This commit is contained in:
+1
-1
Submodule libultraship updated: f5c3843fe9...60c9bb713e
@@ -137,12 +137,15 @@ void RaceManager::SetItemTables() {
|
||||
switch (gPlayerCountSelection1) {
|
||||
case TWO_PLAYERS_SELECTED:
|
||||
humanTableName = "mk:versus_2p";
|
||||
cpuTableName = "mk:versus_2p"; // Required for demo mode to work
|
||||
break;
|
||||
case THREE_PLAYERS_SELECTED:
|
||||
humanTableName = "mk:versus_3p";
|
||||
cpuTableName = "mk:versus_3p";
|
||||
break;
|
||||
case FOUR_PLAYERS_SELECTED:
|
||||
humanTableName = "mk:versus_4p";
|
||||
cpuTableName = "mk:versus_4p";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -52,11 +52,11 @@ namespace TrackEditor {
|
||||
bIsEditorPaused = true;
|
||||
CVarSetInteger("gFreecam", true);
|
||||
CM_SetFreeCamera(true);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Tools")->Show();
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Scene Explorer")->Show();
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Content Browser")->Show();
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Track Properties")->Show();
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Properties")->Show();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Tools")->Show();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Scene Explorer")->Show();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Content Browser")->Show();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Track Properties")->Show();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Properties")->Show();
|
||||
}
|
||||
|
||||
void Editor::Disable() {
|
||||
@@ -64,11 +64,11 @@ namespace TrackEditor {
|
||||
bIsEditorPaused = false;
|
||||
CVarSetInteger("gFreecam", false);
|
||||
CM_SetFreeCamera(false);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Tools")->Hide();
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Scene Explorer")->Hide();
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Content Browser")->Hide();
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Track Properties")->Hide();
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Properties")->Hide();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Tools")->Hide();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Scene Explorer")->Hide();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Content Browser")->Hide();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Track Properties")->Hide();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Properties")->Hide();
|
||||
}
|
||||
|
||||
bool Editor::IsEnabled() {
|
||||
|
||||
@@ -188,13 +188,13 @@ bool FreecamKeyDown(int virtualKey) {
|
||||
static bool prevKeyState[256] = { false }; // Store previous key states
|
||||
bool isDownNow = false;
|
||||
|
||||
if (wnd->GetWindowBackend() == Ship::WindowBackend::FAST3D_SDL_OPENGL) {
|
||||
if (wnd->GetWindowBackend() == Fast::WindowBackend::FAST3D_SDL_OPENGL) {
|
||||
// Use SDL to check key states
|
||||
const uint8_t* keystate = SDL_GetKeyboardState(NULL);
|
||||
isDownNow = keystate[virtualKey] != 0;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else if (wnd->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
else if (wnd->GetWindowBackend() == Fast::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
// Use Windows GetKeyState for DirectX
|
||||
SHORT keyState = GetKeyState(virtualKey);
|
||||
isDownNow = (keyState & 0x8000) != 0;
|
||||
@@ -272,7 +272,7 @@ void freecam_keyboard_manager(Camera* camera, Vec3f forwardVector) {
|
||||
}
|
||||
// Keyboard and mouse DX
|
||||
#ifdef _WIN32
|
||||
else if (wnd->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
else if (wnd->GetWindowBackend() == Fast::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
if (FreecamKeyDown('F')) {
|
||||
fTargetPlayer = !fTargetPlayer;
|
||||
FrameInterpolation_DontInterpolateCamera();
|
||||
@@ -308,7 +308,7 @@ void freecam_keyboard_manager(Camera* camera, Vec3f forwardVector) {
|
||||
// Keyboard/mouse OpenGL/SDL
|
||||
}
|
||||
#endif
|
||||
else if (wnd->GetWindowBackend() == Ship::WindowBackend::FAST3D_SDL_OPENGL) {
|
||||
else if (wnd->GetWindowBackend() == Fast::WindowBackend::FAST3D_SDL_OPENGL) {
|
||||
const uint8_t* keystate = SDL_GetKeyboardState(NULL);
|
||||
if (FreecamKeyDown(SDL_SCANCODE_F)) {
|
||||
fTargetPlayer = !fTargetPlayer;
|
||||
|
||||
+19
-14
@@ -27,6 +27,8 @@
|
||||
#include <ship/window/gui/Fonts.h>
|
||||
#include "ship/window/gui/resource/Font.h"
|
||||
#include "ship/window/gui/resource/FontFactory.h"
|
||||
#include "libultraship/window/gui/InputEditorWindow.h"
|
||||
#include "libultraship/window/gui/GfxDebuggerWindow.h"
|
||||
#include "libultraship/controller/controldeck/ControlDeck.h"
|
||||
#include "SpaghettiGui.h"
|
||||
|
||||
@@ -58,7 +60,7 @@ float gInterpolationStep = 0.0f;
|
||||
}
|
||||
|
||||
Fast::Interpreter* GetInterpreter() {
|
||||
return static_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow())
|
||||
return static_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetRawInstance()->GetWindow())
|
||||
->GetInterpreterWeak()
|
||||
.lock()
|
||||
.get();
|
||||
@@ -174,21 +176,24 @@ GameEngine::GameEngine() {
|
||||
auto wnd = std::make_shared<Fast::Fast3dWindow>(gui);
|
||||
|
||||
// auto wnd = std::make_shared<Fast::Fast3dWindow>(std::vector<std::shared_ptr<Ship::GuiWindow>>({}));
|
||||
// auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow());
|
||||
// auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetRawInstance()->GetWindow());
|
||||
|
||||
gui->AddGuiWindow(std::make_shared<LUS::InputEditorWindow>(CVAR_CONTROLLER_CONFIGURATION_WINDOW_OPEN, "Input Editor"));
|
||||
gui->AddGuiWindow(std::make_shared<LUS::GfxDebuggerWindow>(CVAR_GFX_DEBUGGER_WINDOW_OPEN, "GfxDebuggerWindow", ImVec2(520, 600)));
|
||||
|
||||
this->context->Init({assets_path}, {}, 3, { 26800, 512, 1100 }, wnd, controlDeck);
|
||||
|
||||
#ifndef __SWITCH__
|
||||
Ship::Context::GetInstance()->GetLogger()->set_level(
|
||||
Ship::Context::GetRawInstance()->GetLogger()->set_level(
|
||||
(spdlog::level::level_enum) CVarGetInteger("gDeveloperTools.LogLevel", 1));
|
||||
Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v");
|
||||
Ship::Context::GetRawInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v");
|
||||
#endif
|
||||
|
||||
SPDLOG_INFO("Spaghetti Kart " SPAGHETTI_VERSION);
|
||||
SPDLOG_INFO(CVarGetInteger("gEnableDebugMode", 0) == 0 ? "Debug Mode deactivated" : "Debug Mode activated");
|
||||
|
||||
wnd->SetRendererUCode(ucode_f3dex);
|
||||
this->context->InitGfxDebugger();
|
||||
//this->context->InitGfxDebugger();
|
||||
|
||||
auto loader = context->GetResourceManager()->GetResourceLoader();
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::AudioBankFactoryV0>(), RESOURCE_FORMAT_BINARY, "AudioBank",
|
||||
@@ -290,11 +295,11 @@ bool GameEngine::GenAssetFile() {
|
||||
|
||||
uint32_t GameEngine::GetInterpolationFPS() {
|
||||
if (CVarGetInteger("gMatchRefreshRate", 0)) {
|
||||
return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
return Ship::Context::GetRawInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
|
||||
} else if (CVarGetInteger("gVsyncEnabled", 1) ||
|
||||
!Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) {
|
||||
return std::min<uint32_t>(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(),
|
||||
!Ship::Context::GetRawInstance()->GetWindow()->CanDisableVerticalSync()) {
|
||||
return std::min<uint32_t>(Ship::Context::GetRawInstance()->GetWindow()->GetCurrentRefreshRate(),
|
||||
CVarGetInteger("gInterpolationFPS", 30));
|
||||
}
|
||||
|
||||
@@ -395,7 +400,7 @@ void GameEngine::StartFrame() const {
|
||||
// }
|
||||
|
||||
void GameEngine::RunCommands(Gfx* pool, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements) {
|
||||
auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow());
|
||||
auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetRawInstance()->GetWindow());
|
||||
|
||||
if (wnd == nullptr) {
|
||||
return;
|
||||
@@ -416,7 +421,7 @@ void GameEngine::RunCommands(Gfx* pool, const std::vector<std::unordered_map<Mtx
|
||||
bool curAltAssets = CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0);
|
||||
if (prevAltAssets != curAltAssets) {
|
||||
prevAltAssets = curAltAssets;
|
||||
Ship::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets);
|
||||
Ship::Context::GetRawInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets);
|
||||
gfx_texture_cache_clear();
|
||||
}
|
||||
}
|
||||
@@ -462,7 +467,7 @@ void GameEngine::ProcessGfxCommands(Gfx* pool) {
|
||||
|
||||
time -= fps;
|
||||
|
||||
auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow());
|
||||
auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetRawInstance()->GetWindow());
|
||||
if (wnd != nullptr) {
|
||||
wnd->SetTargetFps(GetInterpolationFPS());
|
||||
wnd->SetMaximumFrameLatency(1);
|
||||
@@ -533,7 +538,7 @@ void GameEngine::EndAudioFrame() {
|
||||
}
|
||||
|
||||
void GameEngine::AudioInit() {
|
||||
const auto resourceMgr = Ship::Context::GetInstance()->GetResourceManager();
|
||||
const auto resourceMgr = Ship::Context::GetRawInstance()->GetResourceManager();
|
||||
resourceMgr->LoadResources("sound");
|
||||
const auto banksFiles = resourceMgr->GetArchiveManager()->ListFiles("sound/banks/*");
|
||||
const auto sequences_files = resourceMgr->GetArchiveManager()->ListFiles("sound/sequences/*");
|
||||
@@ -610,7 +615,7 @@ ImFont* GameEngine::CreateFontWithSize(float size, std::string fontPath) {
|
||||
initData->ResourceVersion = 0;
|
||||
initData->Path = fontPath;
|
||||
std::shared_ptr<Ship::Font> fontData = std::static_pointer_cast<Ship::Font>(
|
||||
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fontPath, false, initData));
|
||||
Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(fontPath, false, initData));
|
||||
char* fontDataPtr = (char*) malloc(fontData->DataSize);
|
||||
memcpy(fontDataPtr, fontData->Data, fontData->DataSize);
|
||||
ImFontConfig fontCfg = ImFontConfig();
|
||||
@@ -633,7 +638,7 @@ ImFont* GameEngine::CreateFontWithSize(float size, std::string fontPath) {
|
||||
// End
|
||||
|
||||
extern "C" uint32_t GameEngine_GetSampleRate() {
|
||||
auto player = Ship::Context::GetInstance()->GetAudio()->GetAudioPlayer();
|
||||
auto player = Ship::Context::GetRawInstance()->GetAudio()->GetAudioPlayer();
|
||||
if (player == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ class GameEngine {
|
||||
public:
|
||||
static GameEngine* Instance;
|
||||
|
||||
std::shared_ptr<Ship::Context> context;
|
||||
Ship::Context* context;
|
||||
std::vector<CtlEntry*> banksTable;
|
||||
std::vector<std::string> sequenceTable;
|
||||
std::vector<AudioSequenceData*> audioSequenceTable;
|
||||
|
||||
@@ -13,7 +13,7 @@ extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) {
|
||||
char* imgData = (char*) dl;
|
||||
|
||||
if (GameEngine_OTRSigCheck(imgData)) {
|
||||
auto resource = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(imgData);
|
||||
auto resource = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(imgData);
|
||||
auto res = std::static_pointer_cast<Fast::DisplayList>(resource);
|
||||
dl = &res->Instructions[0];
|
||||
}
|
||||
@@ -38,7 +38,7 @@ extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) {
|
||||
auto data = reinterpret_cast<char*>(texAddr);
|
||||
|
||||
if (texAddr != 0 && GameEngine_OTRSigCheck(data)) {
|
||||
const auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(data);
|
||||
const auto res = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResource(data);
|
||||
const auto type = static_cast<Fast::ResourceType>(res->GetInitData()->Type);
|
||||
|
||||
if (res->GetInitData()->Type == static_cast<uint32_t>(Fast::ResourceType::DisplayList)) {
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace Ship {
|
||||
#define TOGGLE_PAD_BTN ImGuiKey_GamepadBack
|
||||
|
||||
void SpaghettiGui::DrawMenu() {
|
||||
const std::shared_ptr<Window> wnd = Context::GetInstance()->GetWindow();
|
||||
const std::shared_ptr<Config> conf = Context::GetInstance()->GetConfig();
|
||||
const std::shared_ptr<Window> wnd = Context::GetRawInstance()->GetWindow();
|
||||
const std::shared_ptr<Config> conf = Context::GetRawInstance()->GetConfig();
|
||||
|
||||
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoBackground |
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove |
|
||||
@@ -112,7 +112,7 @@ void SpaghettiGui::DrawMenu() {
|
||||
Gui::GetMenuBar()->ToggleVisibility();
|
||||
}
|
||||
if (wnd->IsFullscreen()) {
|
||||
Context::GetInstance()->GetWindow()->SetMouseCapture(
|
||||
Context::GetRawInstance()->GetWindow()->SetMouseCapture(
|
||||
!(GetMenuOrMenubarVisible() || wnd->ShouldForceCursorVisibility()));
|
||||
}
|
||||
if (CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) && GetMenuOrMenubarVisible()) {
|
||||
@@ -126,14 +126,14 @@ void SpaghettiGui::DrawMenu() {
|
||||
if ((ImGui::IsKeyDown(ImGuiKey_LeftSuper) || ImGui::IsKeyDown(ImGuiKey_RightSuper)) &&
|
||||
ImGui::IsKeyPressed(ImGuiKey_R, false)) {
|
||||
std::reinterpret_pointer_cast<ConsoleWindow>(
|
||||
Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
|
||||
Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
|
||||
->Dispatch("reset");
|
||||
}
|
||||
#else
|
||||
if ((ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) &&
|
||||
ImGui::IsKeyPressed(ImGuiKey_R, false)) {
|
||||
std::reinterpret_pointer_cast<ConsoleWindow>(
|
||||
Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
|
||||
Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))
|
||||
->Dispatch("reset");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2,16 +2,17 @@
|
||||
|
||||
#include <libultraship.h>
|
||||
#include "ship/window/gui/Gui.h"
|
||||
#include "fast/Fast3dGui.h"
|
||||
#include "ship/window/Window.h"
|
||||
|
||||
class Gui; // <-- forward declare
|
||||
//class Window;
|
||||
|
||||
namespace Ship {
|
||||
class SpaghettiGui : public Gui {
|
||||
class SpaghettiGui : public Fast::Fast3dGui {
|
||||
public:
|
||||
SpaghettiGui() : Gui() {}
|
||||
SpaghettiGui(std::vector<std::shared_ptr<GuiWindow>> guiWindows) : Gui(guiWindows) {}
|
||||
SpaghettiGui() : Fast::Fast3dGui() {}
|
||||
SpaghettiGui(std::vector<std::shared_ptr<GuiWindow>> guiWindows) : Fast::Fast3dGui(guiWindows) {}
|
||||
|
||||
protected:
|
||||
virtual void DrawMenu() override;
|
||||
|
||||
@@ -33,14 +33,14 @@ SM64::AudioSequenceFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
bank->mData.id = id;
|
||||
|
||||
for (const auto& ext : extension) {
|
||||
auto custom = Ship::Context::GetInstance()->GetResourceManager()->LoadFileProcess(initData->Path + ext);
|
||||
auto custom = Ship::Context::GetRawInstance()->GetResourceManager()->LoadFileProcess(initData->Path + ext);
|
||||
|
||||
if (custom != nullptr) {
|
||||
bank->sampleData = std::vector<uint8_t>(custom->Buffer->begin(), custom->Buffer->end());
|
||||
uint8_t* data = bank->sampleData.data();
|
||||
size_t size = bank->sampleData.size();
|
||||
|
||||
auto metadata = Ship::Context::GetInstance()->GetResourceManager()->LoadFileProcess(initData->Path + ".json");
|
||||
auto metadata = Ship::Context::GetRawInstance()->GetResourceManager()->LoadFileProcess(initData->Path + ".json");
|
||||
if (metadata != nullptr) {
|
||||
auto json = nlohmann::json::parse(std::string(metadata->Buffer->begin(), metadata->Buffer->end()));
|
||||
HMAS_Info info;
|
||||
|
||||
@@ -32,7 +32,7 @@ ResourceFactoryBinaryTextureV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
}
|
||||
|
||||
for (const auto& ext : extension) {
|
||||
auto filePng = Ship::Context::GetInstance()->GetResourceManager()->LoadFileProcess(
|
||||
auto filePng = Ship::Context::GetRawInstance()->GetResourceManager()->LoadFileProcess(
|
||||
initData->Path + ext);
|
||||
|
||||
if (filePng != nullptr) {
|
||||
@@ -62,7 +62,7 @@ ResourceFactoryBinaryTextureV1::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
}
|
||||
|
||||
for (const auto& ext : extension) {
|
||||
auto filePng = Ship::Context::GetInstance()->GetResourceManager()->LoadFileProcess(
|
||||
auto filePng = Ship::Context::GetRawInstance()->GetResourceManager()->LoadFileProcess(
|
||||
initData->Path + ext);
|
||||
|
||||
if (filePng != nullptr) {
|
||||
|
||||
@@ -10,14 +10,14 @@ template <typename T> T LoadChild(uint64_t crc) {
|
||||
if (path == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
auto asset = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path);
|
||||
auto asset = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(path);
|
||||
return asset ? static_cast<T>(asset->GetRawPointer()) : nullptr;
|
||||
}
|
||||
template <typename T> T LoadChild(const char* path) {
|
||||
if (path == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
auto asset = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path);
|
||||
auto asset = Ship::Context::GetRawInstance()->GetResourceManager()->LoadResourceProcess(path);
|
||||
return asset ? static_cast<T>(asset->GetRawPointer()) : nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
+58
-55
@@ -16,6 +16,7 @@
|
||||
#include <imgui_internal.h>
|
||||
#include <libultraship/libultraship.h>
|
||||
#include <fast/Fast3dWindow.h>
|
||||
#include <fast/Fast3dGui.h>
|
||||
#include "port/Engine.h"
|
||||
#include "PortMenu.h"
|
||||
|
||||
@@ -40,7 +41,7 @@ std::shared_ptr<Ship::GuiWindow> mTrackPropertiesWindow;
|
||||
std::shared_ptr<Ship::GuiWindow> mContentBrowserWindow;
|
||||
|
||||
void SetupGuiElements() {
|
||||
auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
|
||||
auto gui = Ship::Context::GetRawInstance()->GetWindow()->GetGui();
|
||||
|
||||
// mGameMenuBar = std::make_shared<GameMenuBar>("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0));
|
||||
// gui->SetMenuBar(mGameMenuBar);
|
||||
@@ -155,23 +156,23 @@ void DrawSettingsMenu() {
|
||||
// };
|
||||
//
|
||||
// ImGui::Text("Audio API (Needs reload)");
|
||||
// auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetCurrentAudioBackend();
|
||||
// auto currentAudioBackend = Ship::Context::GetRawInstance()->GetAudio()->GetCurrentAudioBackend();
|
||||
//
|
||||
// if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
|
||||
// if (Ship::Context::GetRawInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
|
||||
// UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f);
|
||||
// }
|
||||
// if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) {
|
||||
// for (uint8_t i = 0; i <
|
||||
// Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) {
|
||||
// Ship::Context::GetRawInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) {
|
||||
// auto backend =
|
||||
// Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i]; if
|
||||
// Ship::Context::GetRawInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i]; if
|
||||
// (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) {
|
||||
// Ship::Context::GetInstance()->GetAudio()->SetCurrentAudioBackend(backend);
|
||||
// Ship::Context::GetRawInstance()->GetAudio()->SetCurrentAudioBackend(backend);
|
||||
// }
|
||||
// }
|
||||
// ImGui::EndCombo();
|
||||
// }
|
||||
// if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
|
||||
// if (Ship::Context::GetRawInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
|
||||
// UIWidgets::ReEnableComponent("");
|
||||
// }
|
||||
//
|
||||
@@ -219,7 +220,7 @@ void DrawSettingsMenu() {
|
||||
// UIWidgets::Spacer(0);
|
||||
//
|
||||
// // Previously was running every frame, and nothing was setting it? Maybe a bad copy/paste?
|
||||
// // Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution",
|
||||
// // Ship::Context::GetRawInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution",
|
||||
// 1));
|
||||
// // UIWidgets::Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but
|
||||
// // effective form of anti-aliasing");
|
||||
@@ -229,18 +230,18 @@ void DrawSettingsMenu() {
|
||||
// { .tooltip =
|
||||
// "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel"
|
||||
// })) {
|
||||
// Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1));
|
||||
// Ship::Context::GetRawInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1));
|
||||
// }
|
||||
// #endif
|
||||
//
|
||||
// { // FPS Slider
|
||||
// const int minFps = 30;
|
||||
// static int maxFps;
|
||||
// if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() ==
|
||||
// Ship::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
// if (Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend() ==
|
||||
// Fast::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
// maxFps = 360;
|
||||
// } else {
|
||||
// maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
// maxFps = Ship::Context::GetRawInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
// }
|
||||
// int currentFps = 0;
|
||||
// #ifdef __WIIU__
|
||||
@@ -302,18 +303,18 @@ void DrawSettingsMenu() {
|
||||
// currentFps = 60;
|
||||
// }
|
||||
// CVarSetInteger("gInterpolationFPS", currentFps);
|
||||
// Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
// Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
// #else
|
||||
// bool matchingRefreshRate =
|
||||
// CVarGetInteger("gMatchRefreshRate", 0) &&
|
||||
// Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() !=
|
||||
// Ship::WindowBackend::FAST3D_DXGI_DX11;
|
||||
// Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend() !=
|
||||
// Fast::WindowBackend::FAST3D_DXGI_DX11;
|
||||
// UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS",
|
||||
// minFps,
|
||||
// maxFps, 1, { .disabled = matchingRefreshRate });
|
||||
// #endif
|
||||
// if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() ==
|
||||
// Ship::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
// if (Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend() ==
|
||||
// Fast::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
// UIWidgets::Tooltip(
|
||||
// "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. "
|
||||
// "This is purely "
|
||||
@@ -327,14 +328,14 @@ void DrawSettingsMenu() {
|
||||
// }
|
||||
// } // END FPS Slider
|
||||
//
|
||||
// if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() ==
|
||||
// Ship::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
// if (Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend() ==
|
||||
// Fast::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
// UIWidgets::Spacer(0);
|
||||
// if (ImGui::Button("Match Refresh Rate")) {
|
||||
// int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
// int hz = Ship::Context::GetRawInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
// if (hz >= 30 && hz <= 360) {
|
||||
// CVarSetInteger("gInterpolationFPS", hz);
|
||||
// Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
// Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
@@ -343,8 +344,8 @@ void DrawSettingsMenu() {
|
||||
//
|
||||
// UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate");
|
||||
//
|
||||
// if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() ==
|
||||
// Ship::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
// if (Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend() ==
|
||||
// Fast::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
// UIWidgets::PaddedEnhancementSliderInt(
|
||||
// CVarGetInteger("gExtraLatencyThreshold", 0) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS",
|
||||
// "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 0, true, true, false);
|
||||
@@ -357,53 +358,53 @@ void DrawSettingsMenu() {
|
||||
//
|
||||
// UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f);
|
||||
//
|
||||
// static std::unordered_map<Ship::WindowBackend, const char*> windowBackendNames = {
|
||||
// { Ship::WindowBackend::FAST3D_DXGI_DX11, "DirectX" },
|
||||
// { Ship::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL" },
|
||||
// { Ship::WindowBackend::FAST3D_SDL_METAL, "Metal" },
|
||||
// static std::unordered_map<Fast::WindowBackend, const char*> windowBackendNames = {
|
||||
// { Fast::WindowBackend::FAST3D_DXGI_DX11, "DirectX" },
|
||||
// { Fast::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL" },
|
||||
// { Fast::WindowBackend::FAST3D_SDL_METAL, "Metal" },
|
||||
// };
|
||||
//
|
||||
// ImGui::Text("Renderer API (Needs reload)");
|
||||
// Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend();
|
||||
// Ship::WindowBackend configWindowBackend;
|
||||
// int configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1);
|
||||
// if (Ship::Context::GetInstance()->GetWindow()->IsAvailableWindowBackend(configWindowBackendId)) {
|
||||
// configWindowBackend = static_cast<Ship::WindowBackend>(configWindowBackendId);
|
||||
// Fast::WindowBackend runningWindowBackend = Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend();
|
||||
// Fast::WindowBackend configWindowBackend;
|
||||
// int configWindowBackendId = Ship::Context::GetRawInstance()->GetConfig()->GetInt("Window.Backend.Id", -1);
|
||||
// if (Ship::Context::GetRawInstance()->GetWindow()->IsAvailableWindowBackend(configWindowBackendId)) {
|
||||
// configWindowBackend = static_cast<Fast::WindowBackend>(configWindowBackendId);
|
||||
// } else {
|
||||
// configWindowBackend = runningWindowBackend;
|
||||
// }
|
||||
//
|
||||
// if (Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) {
|
||||
// if (Ship::Context::GetRawInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) {
|
||||
// UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f);
|
||||
// }
|
||||
// if (ImGui::BeginCombo("##RApi", windowBackendNames[configWindowBackend])) {
|
||||
// for (size_t i = 0; i <
|
||||
// Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size();
|
||||
// Ship::Context::GetRawInstance()->GetWindow()->GetAvailableWindowBackends()->size();
|
||||
// i++) {
|
||||
// auto backend = Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i];
|
||||
// auto backend = Ship::Context::GetRawInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i];
|
||||
// if (ImGui::Selectable(windowBackendNames[backend], backend == configWindowBackend)) {
|
||||
// Ship::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id",
|
||||
// Ship::Context::GetRawInstance()->GetConfig()->SetInt("Window.Backend.Id",
|
||||
// static_cast<int>(backend));
|
||||
// Ship::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name",
|
||||
// Ship::Context::GetRawInstance()->GetConfig()->SetString("Window.Backend.Name",
|
||||
// windowBackendNames[backend]);
|
||||
// Ship::Context::GetInstance()->GetConfig()->Save();
|
||||
// Ship::Context::GetRawInstance()->GetConfig()->Save();
|
||||
// }
|
||||
// }
|
||||
// ImGui::EndCombo();
|
||||
// }
|
||||
// if (Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) {
|
||||
// if (Ship::Context::GetRawInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) {
|
||||
// UIWidgets::ReEnableComponent("");
|
||||
// }
|
||||
//
|
||||
// if (Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) {
|
||||
// if (Ship::Context::GetRawInstance()->GetWindow()->CanDisableVerticalSync()) {
|
||||
// UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false);
|
||||
// }
|
||||
//
|
||||
// if (Ship::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) {
|
||||
// if (Ship::Context::GetRawInstance()->GetWindow()->SupportsWindowedFullscreen()) {
|
||||
// UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false);
|
||||
// }
|
||||
//
|
||||
// if (Ship::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) {
|
||||
// if (Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SupportsViewports()) {
|
||||
// UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows", "gEnableMultiViewports", true, false,
|
||||
// false, "",
|
||||
// UIWidgets::CheckboxGraphics::Cross, true);
|
||||
@@ -419,7 +420,7 @@ void DrawSettingsMenu() {
|
||||
//
|
||||
// UIWidgets::Spacer(0);
|
||||
//
|
||||
// Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings();
|
||||
// Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings();
|
||||
//
|
||||
// ImGui::EndMenu();
|
||||
// }
|
||||
@@ -428,26 +429,28 @@ void DrawSettingsMenu() {
|
||||
void DrawMenuBarIcon() {
|
||||
static bool gameIconLoaded = false;
|
||||
if (!gameIconLoaded) {
|
||||
// Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon",
|
||||
// Ship::Context::GetRawInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon",
|
||||
// "textures/icons/gIcon.png");
|
||||
gameIconLoaded = false;
|
||||
}
|
||||
|
||||
if (Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) {
|
||||
if (auto fast3dGui = std::dynamic_pointer_cast<Fast::Fast3dGui>(Ship::Context::GetRawInstance()->GetWindow()->GetGui())) {
|
||||
if (fast3dGui->GetTextureByName("Game_Icon")) {
|
||||
#ifdef __SWITCH__
|
||||
ImVec2 iconSize = ImVec2(20.0f, 20.0f);
|
||||
float posScale = 1.0f;
|
||||
ImVec2 iconSize = ImVec2(20.0f, 20.0f);
|
||||
float posScale = 1.0f;
|
||||
#elif defined(__WIIU__)
|
||||
ImVec2 iconSize = ImVec2(16.0f * 2, 16.0f * 2);
|
||||
float posScale = 2.0f;
|
||||
ImVec2 iconSize = ImVec2(16.0f * 2, 16.0f * 2);
|
||||
float posScale = 2.0f;
|
||||
#else
|
||||
ImVec2 iconSize = ImVec2(20.0f, 20.0f);
|
||||
float posScale = 1.5f;
|
||||
ImVec2 iconSize = ImVec2(20.0f, 20.0f);
|
||||
float posScale = 1.5f;
|
||||
#endif
|
||||
ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale);
|
||||
ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize);
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPos(ImVec2(25, 0) * posScale);
|
||||
ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale);
|
||||
ImGui::Image(fast3dGui->GetTextureByName("Game_Icon"), iconSize);
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPos(ImVec2(25, 0) * posScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -90,15 +90,15 @@ void Menu::RemoveSidebarSearch() {
|
||||
}
|
||||
|
||||
void Menu::UpdateWindowBackendObjects() {
|
||||
Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend();
|
||||
int32_t configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1);
|
||||
if (Ship::Context::GetInstance()->GetWindow()->IsAvailableWindowBackend(configWindowBackendId)) {
|
||||
configWindowBackend = static_cast<Ship::WindowBackend>(configWindowBackendId);
|
||||
Fast::WindowBackend runningWindowBackend = static_cast<Fast::WindowBackend>(Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend());
|
||||
Fast::WindowBackend configWindowBackendId = static_cast<Fast::WindowBackend>(Ship::Context::GetRawInstance()->GetConfig()->GetInt("Window.Backend.Id", -1));
|
||||
if (Ship::Context::GetRawInstance()->GetWindow()->IsAvailableWindowBackend(configWindowBackendId)) {
|
||||
configWindowBackend = static_cast<Fast::WindowBackend>(configWindowBackendId);
|
||||
} else {
|
||||
configWindowBackend = runningWindowBackend;
|
||||
}
|
||||
|
||||
availableWindowBackends = Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends();
|
||||
availableWindowBackends = Ship::Context::GetRawInstance()->GetWindow()->GetAvailableWindowBackends();
|
||||
for (auto& backend : *availableWindowBackends) {
|
||||
availableWindowBackendsMap[backend] = windowBackendsMap.at(backend);
|
||||
}
|
||||
@@ -269,14 +269,14 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me
|
||||
};
|
||||
} break;
|
||||
case WIDGET_AUDIO_BACKEND: {
|
||||
auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetCurrentAudioBackend();
|
||||
auto currentAudioBackend = Ship::Context::GetRawInstance()->GetAudio()->GetCurrentAudioBackend();
|
||||
UIWidgets::ComboboxOptions options = {};
|
||||
options.color = menuThemeIndex;
|
||||
options.tooltip = "Sets the audio API used by the game. Requires a relaunch to take effect.";
|
||||
options.disabled = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1;
|
||||
options.disabled = Ship::Context::GetRawInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1;
|
||||
options.disabledTooltip = "Only one audio API is available on this platform.";
|
||||
if (UIWidgets::Combobox("Audio API", ¤tAudioBackend, audioBackendsMap, options)) {
|
||||
Ship::Context::GetInstance()->GetAudio()->SetCurrentAudioBackend(currentAudioBackend);
|
||||
Ship::Context::GetRawInstance()->GetAudio()->SetCurrentAudioBackend(currentAudioBackend);
|
||||
}
|
||||
} break;
|
||||
case WIDGET_VIDEO_BACKEND: {
|
||||
@@ -287,11 +287,11 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me
|
||||
options.disabledTooltip = "Only one renderer API is available on this platform.";
|
||||
if (UIWidgets::Combobox("Renderer API (Needs reload)", &configWindowBackend, availableWindowBackendsMap,
|
||||
options)) {
|
||||
Ship::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id",
|
||||
Ship::Context::GetRawInstance()->GetConfig()->SetInt("Window.Backend.Id",
|
||||
(int32_t)(configWindowBackend));
|
||||
Ship::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name",
|
||||
Ship::Context::GetRawInstance()->GetConfig()->SetString("Window.Backend.Name",
|
||||
windowBackendsMap.at(configWindowBackend));
|
||||
Ship::Context::GetInstance()->GetConfig()->Save();
|
||||
Ship::Context::GetRawInstance()->GetConfig()->Save();
|
||||
UpdateWindowBackendObjects();
|
||||
}
|
||||
} break;
|
||||
@@ -411,7 +411,7 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me
|
||||
SPDLOG_ERROR(msg.c_str());
|
||||
break;
|
||||
}
|
||||
auto window = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow(widget.windowName);
|
||||
auto window = Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetGuiWindow(widget.windowName);
|
||||
if (!window) {
|
||||
std::string msg =
|
||||
fmt::format("Error drawing window contents: windowName {} does not exist", widget.windowName);
|
||||
@@ -589,7 +589,7 @@ void Menu::DrawElement() {
|
||||
// Update gamepad navigation after close based on if other menus are still visible
|
||||
auto mImGuiIo = &ImGui::GetIO();
|
||||
if (CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) &&
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->GetMenuOrMenubarVisible()) {
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->GetMenuOrMenubarVisible()) {
|
||||
mImGuiIo->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
|
||||
} else {
|
||||
mImGuiIo->ConfigFlags &= ~ImGuiConfigFlags_NavEnableGamepad;
|
||||
@@ -673,7 +673,7 @@ void Menu::DrawElement() {
|
||||
if (!popped) {
|
||||
ToggleVisibility();
|
||||
}
|
||||
Ship::Context::GetInstance()->GetWindow()->Close();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->Close();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
|
||||
+3
-3
@@ -48,9 +48,9 @@ class Menu : public GuiWindow {
|
||||
ImGuiTextFilter menuSearch;
|
||||
uint8_t searchSidebarIndex;
|
||||
UIWidgets::Colors defaultThemeIndex;
|
||||
std::shared_ptr<std::vector<Ship::WindowBackend>> availableWindowBackends;
|
||||
std::unordered_map<Ship::WindowBackend, const char*> availableWindowBackendsMap;
|
||||
Ship::WindowBackend configWindowBackend;
|
||||
std::shared_ptr<std::vector<int32_t>> availableWindowBackends;
|
||||
std::unordered_map<int32_t, const char*> availableWindowBackendsMap;
|
||||
int32_t configWindowBackend;
|
||||
|
||||
std::unordered_map<uint32_t, disabledInfo> disabledMap;
|
||||
std::vector<disabledInfo> disabledVector;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define MENUTYPES_H
|
||||
|
||||
#include <libultraship/libultraship.h>
|
||||
#include <fast/Fast3dWindow.h>
|
||||
#include "UIWidgets.h"
|
||||
|
||||
typedef enum {
|
||||
@@ -260,10 +261,10 @@ static const std::unordered_map<Ship::AudioBackend, const char*> audioBackendsMa
|
||||
{ Ship::AudioBackend::COREAUDIO, "CoreAudio" },
|
||||
};
|
||||
|
||||
static const std::unordered_map<Ship::WindowBackend, const char*> windowBackendsMap = {
|
||||
{ Ship::WindowBackend::FAST3D_DXGI_DX11, "DirectX" },
|
||||
{ Ship::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL" },
|
||||
{ Ship::WindowBackend::FAST3D_SDL_METAL, "Metal" },
|
||||
static const std::unordered_map<int32_t, const char*> windowBackendsMap = {
|
||||
{ Fast::WindowBackend::FAST3D_DXGI_DX11, "DirectX" },
|
||||
{ Fast::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL" },
|
||||
{ Fast::WindowBackend::FAST3D_SDL_METAL, "Metal" },
|
||||
};
|
||||
|
||||
struct MenuInit {
|
||||
|
||||
+17
-17
@@ -100,8 +100,8 @@ void PortMenu::AddSettings() {
|
||||
#ifndef __SWITCH__
|
||||
AddWidget(path, "Toggle Fullscreen", WIDGET_CHECKBOX)
|
||||
.ValuePointer(&isFullscreen)
|
||||
.PreFunc([](WidgetInfo& info) { isFullscreen = Ship::Context::GetInstance()->GetWindow()->IsFullscreen(); })
|
||||
.Callback([](WidgetInfo& info) { Ship::Context::GetInstance()->GetWindow()->ToggleFullscreen(); })
|
||||
.PreFunc([](WidgetInfo& info) { isFullscreen = Ship::Context::GetRawInstance()->GetWindow()->IsFullscreen(); })
|
||||
.Callback([](WidgetInfo& info) { Ship::Context::GetRawInstance()->GetWindow()->ToggleFullscreen(); })
|
||||
.Options(CheckboxOptions().Tooltip("Toggles Fullscreen On/Off."));
|
||||
#endif
|
||||
|
||||
@@ -148,7 +148,7 @@ void PortMenu::AddSettings() {
|
||||
AddWidget(path, "Cursor Always Visible", WIDGET_CVAR_CHECKBOX)
|
||||
.CVar("gSettings.CursorVisibility")
|
||||
.Callback([](WidgetInfo& info) {
|
||||
Ship::Context::GetInstance()->GetWindow()->SetForceCursorVisibility(
|
||||
Ship::Context::GetRawInstance()->GetWindow()->SetForceCursorVisibility(
|
||||
CVarGetInteger("gSettings.CursorVisibility", 0));
|
||||
})
|
||||
.Options(CheckboxOptions().Tooltip("Makes the cursor always visible, even in full screen."));
|
||||
@@ -175,7 +175,7 @@ void PortMenu::AddSettings() {
|
||||
#ifndef __SWITCH__
|
||||
AddWidget(path, "Open App Files Folder", WIDGET_BUTTON)
|
||||
.Callback([](WidgetInfo& info) {
|
||||
std::string filesPath = Ship::Context::GetInstance()->GetAppDirectoryPath();
|
||||
std::string filesPath = Ship::Context::GetRawInstance()->GetAppDirectoryPath();
|
||||
SDL_OpenURL(std::string("file:///" + std::filesystem::absolute(filesPath).string()).c_str());
|
||||
})
|
||||
.Options(ButtonOptions().Tooltip("Opens the folder that contains the save and mods folders, etc."));
|
||||
@@ -217,13 +217,13 @@ void PortMenu::AddSettings() {
|
||||
// Graphics Settings
|
||||
static int32_t maxFps;
|
||||
const char* tooltip = "";
|
||||
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
if (Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend() == Fast::WindowBackend::FAST3D_DXGI_DX11) {
|
||||
maxFps = MAX_FPS;
|
||||
tooltip = "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is "
|
||||
"purely visual and does not impact game logic, execution of glitches etc.\n\nA higher target "
|
||||
"FPS than your monitor's refresh rate will waste resources, and might give a worse result.";
|
||||
} else {
|
||||
maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
maxFps = Ship::Context::GetRawInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
tooltip = "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is "
|
||||
"purely visual and does not impact game logic, execution of glitches etc.";
|
||||
}
|
||||
@@ -234,7 +234,7 @@ void PortMenu::AddSettings() {
|
||||
AddWidget(path, "Internal Resolution: %.0f%%", WIDGET_CVAR_SLIDER_FLOAT)
|
||||
.CVar(CVAR_INTERNAL_RESOLUTION)
|
||||
.Callback([](WidgetInfo& info) {
|
||||
Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(
|
||||
Ship::Context::GetRawInstance()->GetWindow()->SetResolutionMultiplier(
|
||||
CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1));
|
||||
})
|
||||
.PreFunc([](WidgetInfo& info) {
|
||||
@@ -260,7 +260,7 @@ void PortMenu::AddSettings() {
|
||||
AddWidget(path, "Anti-aliasing (MSAA): %d", WIDGET_CVAR_SLIDER_INT)
|
||||
.CVar(CVAR_MSAA_VALUE)
|
||||
.Callback([](WidgetInfo& info) {
|
||||
Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1));
|
||||
Ship::Context::GetRawInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1));
|
||||
})
|
||||
.Options(
|
||||
IntSliderOptions()
|
||||
@@ -289,10 +289,10 @@ void PortMenu::AddSettings() {
|
||||
.Options(IntSliderOptions().Tooltip(tooltip).Min(30).Max(maxFps).DefaultValue(30));
|
||||
AddWidget(path, "Match Refresh Rate", WIDGET_BUTTON)
|
||||
.Callback([](WidgetInfo& info) {
|
||||
int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
int hz = Ship::Context::GetRawInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
if (hz >= 30 && hz <= MAX_FPS) {
|
||||
CVarSetInteger("gInterpolationFPS", hz);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
}
|
||||
})
|
||||
.PreFunc([](WidgetInfo& info) { info.isHidden = mPortMenu->disabledMap.at(DISABLE_FOR_NOT_DIRECTX).active; })
|
||||
@@ -651,29 +651,29 @@ void PortMenu::InitElement() {
|
||||
"Debug Mode is Disabled" } },
|
||||
{ DISABLE_FOR_NO_VSYNC,
|
||||
{ [](disabledInfo& info) -> bool {
|
||||
return !Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync();
|
||||
return !Ship::Context::GetRawInstance()->GetWindow()->CanDisableVerticalSync();
|
||||
},
|
||||
"Disabling VSync not supported" } },
|
||||
{ DISABLE_FOR_NO_WINDOWED_FULLSCREEN,
|
||||
{ [](disabledInfo& info) -> bool {
|
||||
return !Ship::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen();
|
||||
return !Ship::Context::GetRawInstance()->GetWindow()->SupportsWindowedFullscreen();
|
||||
},
|
||||
"Windowed Fullscreen not supported" } },
|
||||
{ DISABLE_FOR_NO_MULTI_VIEWPORT,
|
||||
{ [](disabledInfo& info) -> bool {
|
||||
return !Ship::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports();
|
||||
return !Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SupportsViewports();
|
||||
},
|
||||
"Multi-viewports not supported" } },
|
||||
{ DISABLE_FOR_NOT_DIRECTX,
|
||||
{ [](disabledInfo& info) -> bool {
|
||||
return Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() !=
|
||||
Ship::WindowBackend::FAST3D_DXGI_DX11;
|
||||
return Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend() !=
|
||||
Fast::WindowBackend::FAST3D_DXGI_DX11;
|
||||
},
|
||||
"Available Only on DirectX" } },
|
||||
{ DISABLE_FOR_DIRECTX,
|
||||
{ [](disabledInfo& info) -> bool {
|
||||
return Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() ==
|
||||
Ship::WindowBackend::FAST3D_DXGI_DX11;
|
||||
return Ship::Context::GetRawInstance()->GetWindow()->GetWindowBackend() ==
|
||||
Fast::WindowBackend::FAST3D_DXGI_DX11;
|
||||
},
|
||||
"Not Available on DirectX" } },
|
||||
{ DISABLE_FOR_MATCH_REFRESH_RATE_ON,
|
||||
|
||||
@@ -291,7 +291,7 @@ bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions
|
||||
bool value = (bool)CVarGetInteger(cvarName, options.defaultValue);
|
||||
if (Checkbox(label, &value, options)) {
|
||||
CVarSetInteger(cvarName, value);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
dirty = true;
|
||||
}
|
||||
return dirty;
|
||||
@@ -404,7 +404,7 @@ bool CVarSliderInt(const char* label, const char* cvarName, const IntSliderOptio
|
||||
int32_t value = CVarGetInteger(cvarName, options.defaultValue);
|
||||
if (SliderInt(label, &value, options)) {
|
||||
CVarSetInteger(cvarName, value);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
dirty = true;
|
||||
}
|
||||
return dirty;
|
||||
@@ -514,7 +514,7 @@ bool CVarSliderFloat(const char* label, const char* cvarName, const FloatSliderO
|
||||
float value = CVarGetFloat(cvarName, options.defaultValue);
|
||||
if (SliderFloat(label, &value, options)) {
|
||||
CVarSetFloat(cvarName, value);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
dirty = true;
|
||||
}
|
||||
return dirty;
|
||||
@@ -531,7 +531,7 @@ bool CVarColorPicker(const char* label, const char* cvarName, Color_RGBA8 defaul
|
||||
color.b = (uint8_t)(colorVec.z * 255.0f);
|
||||
color.a = (uint8_t)(colorVec.w * 255.0f);
|
||||
CVarSetColor(cvarName, color);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
changed = true;
|
||||
}
|
||||
PopStyleCombobox();
|
||||
|
||||
@@ -431,7 +431,7 @@ namespace UIWidgets {
|
||||
int32_t value = CVarGetInteger(cvarName, options.defaultIndex);
|
||||
if (Combobox(label, &value, comboSource, options)) {
|
||||
CVarSetInteger(cvarName, value);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
ShipInit::Init(cvarName);
|
||||
dirty = true;
|
||||
}
|
||||
@@ -670,7 +670,7 @@ namespace UIWidgets {
|
||||
int32_t value = CVarGetInteger(cvarName, options.defaultIndex);
|
||||
if (Combobox<T>(label, &value, comboMap, options)) {
|
||||
CVarSetInteger(cvarName, value);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
dirty = true;
|
||||
}
|
||||
return dirty;
|
||||
@@ -682,7 +682,7 @@ namespace UIWidgets {
|
||||
int32_t value = CVarGetInteger(cvarName, options.defaultIndex);
|
||||
if (Combobox<T>(label, &value, comboVector, options)) {
|
||||
CVarSetInteger(cvarName, value);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
dirty = true;
|
||||
}
|
||||
return dirty;
|
||||
@@ -694,7 +694,7 @@ namespace UIWidgets {
|
||||
int32_t value = CVarGetInteger(cvarName, options.defaultIndex);
|
||||
if (Combobox<T>(label, &value, comboArray, options)) {
|
||||
CVarSetInteger(cvarName, value);
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
dirty = true;
|
||||
}
|
||||
return dirty;
|
||||
|
||||
Reference in New Issue
Block a user