diff --git a/.github/workflows/tidy-format-validation.yml b/.github/workflows/tidy-format-validation.yml index df06bc6..a89b4a0 100644 --- a/.github/workflows/tidy-format-validation.yml +++ b/.github/workflows/tidy-format-validation.yml @@ -39,7 +39,7 @@ jobs: mkdir clang-tidy-result - name: Analyze run: | - git diff -U0 HEAD^ -- 'src' 'include' ':!include/color.h' ':!include/libultra/*' ':!src/core/libultra/*' ':!src/graphic/Fast3D/*' | clang-tidy-diff -p1 -path build -export-fixes clang-tidy-result/fixes.yml + git diff -U0 HEAD^ -- 'src' 'include' ':!include/color.h' ':!include/libultra/*' ':!src/core/libultra/*' ':!src/graphic/Fast3D/*' ':!src/log/spd' | clang-tidy-diff -p1 -path build -export-fixes clang-tidy-result/fixes.yml - name: Save PR metadata run: | echo ${{ github.event.number }} > clang-tidy-result/pr-id.txt diff --git a/extern/ImGui/backends/wiiu/imgui_impl_wiiu.cpp b/extern/ImGui/backends/wiiu/imgui_impl_wiiu.cpp index 3cc757c..571626a 100644 --- a/extern/ImGui/backends/wiiu/imgui_impl_wiiu.cpp +++ b/extern/ImGui/backends/wiiu/imgui_impl_wiiu.cpp @@ -157,10 +157,6 @@ static void ImGui_ImplWiiU_UpdateControllerInput(ImGui_ImplWiiU_ControllerInput* ImGui_ImplWiiU_Data* bd = ImGui_ImplWiiU_GetBackendData(); ImGuiIO& io = ImGui::GetIO(); - // SoH removal to make opening the menu easier - // if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) - // return; - uint32_t vpad_buttons = input->vpad ? input->vpad->hold : 0; uint32_t wpad_buttons = 0; uint32_t classic_buttons = 0; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5fb6f14..34bb4da 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -142,7 +142,7 @@ set(Source_Files__Log source_group("Log" FILES ${Source_Files__Log}) set(Source_Files__Log__SPDLog - ${CMAKE_CURRENT_SOURCE_DIR}/log/spd/sohconsole_sink.h + ${CMAKE_CURRENT_SOURCE_DIR}/log/spd/ConsoleSink.h ) source_group("Log\\SPDLog" FILES ${Source_Files__Log__SPDLog}) diff --git a/src/core/Window.cpp b/src/core/Window.cpp index 7c2a9ae..ac72917 100644 --- a/src/core/Window.cpp +++ b/src/core/Window.cpp @@ -23,7 +23,7 @@ #include #include #include -#include "log/spd/sohconsole_sink.h" +#include "log/spd/ConsoleSink.h" #ifdef __APPLE__ #include "misc/OSXFolderManager.h" #elif defined(__SWITCH__) @@ -40,10 +40,11 @@ std::shared_ptr Window::GetInstance() { return mContext.lock(); } -std::shared_ptr Window::CreateInstance(const std::string name, const std::vector& otrFiles, +std::shared_ptr Window::CreateInstance(const std::string name, const std::string shortName, + const std::vector& otrFiles, const std::unordered_set& validHashes) { if (mContext.expired()) { - auto shared = std::make_shared(name); + auto shared = std::make_shared(name, shortName); mContext = shared; shared->Initialize(otrFiles, validHashes); return shared; @@ -54,9 +55,9 @@ std::shared_ptr Window::CreateInstance(const std::string name, const std return GetInstance(); } -Window::Window(std::string Name) +Window::Window(std::string name, std::string shortName) : mLogger(nullptr), mConfig(nullptr), mResourceManager(nullptr), mAudioPlayer(nullptr), mControlDeck(nullptr), - mName(std::move(Name)) { + mName(std::move(name)), mShortName(std::move(shortName)) { mWindowManagerApi = nullptr; mRenderingApi = nullptr; mIsFullscreen = false; @@ -166,7 +167,7 @@ std::string Window::GetAppDirectoryPath() { #ifdef __APPLE__ FolderManager folderManager; std::string fpath = std::string(folderManager.pathForDirectory(NSApplicationSupportDirectory, NSUserDomainMask)); - fpath.append("/com.shipofharkinian.soh"); + fpath.append("/com.libultraship." + Window::GetInstance()->GetShortName()); return fpath; #endif @@ -415,9 +416,9 @@ void Window::InitializeLogging() { spdlog::init_thread_pool(8192, 1); std::vector sinks; - auto SohConsoleSink = std::make_shared(); - // SohConsoleSink->set_level(spdlog::level::trace); - sinks.push_back(SohConsoleSink); + auto consoleSink = std::make_shared(); + // consoleSink->set_level(spdlog::level::trace); + sinks.push_back(consoleSink); #if (!defined(_WIN32) && !defined(__WIIU__)) || defined(_DEBUG) #if defined(_DEBUG) && defined(_WIN32) @@ -547,6 +548,10 @@ std::string Window::GetName() { return mName; } +std::string Window::GetShortName() { + return mShortName; +} + std::shared_ptr Window::GetControlDeck() { return mControlDeck; } diff --git a/src/core/Window.h b/src/core/Window.h index 9c547f2..0fc7d33 100644 --- a/src/core/Window.h +++ b/src/core/Window.h @@ -21,14 +21,16 @@ class ResourceManager; class Window { public: static std::shared_ptr GetInstance(); - static std::shared_ptr CreateInstance(const std::string name, const std::vector& otrFiles = {}, + static std::shared_ptr CreateInstance(const std::string name, const std::string shortName, + const std::vector& otrFiles = {}, const std::unordered_set& validHashes = {}); + static std::string GetAppBundlePath(); static std::string GetAppDirectoryPath(); static std::string GetPathRelativeToAppDirectory(const char* path); static std::string GetPathRelativeToAppBundle(const char* path); - Window(std::string Name); + Window(std::string name, std::string shortName); ~Window(); void CreateDefaultSettings(); void MainLoop(void (*MainFunction)(void)); @@ -52,6 +54,7 @@ class Window { uint32_t GetMenuBar(); void SetMenuBar(uint32_t menuBar); std::string GetName(); + std::string GetShortName(); std::shared_ptr GetControlDeck(); std::shared_ptr GetAudioPlayer(); std::shared_ptr GetResourceManager(); @@ -104,9 +107,10 @@ class Window { uint32_t mRefreshRate; uint32_t mWidth; uint32_t mHeight; - uint32_t mMenuBar; + bool mMenuBar; int32_t mLastScancode; std::string mName; + std::string mShortName; std::string mMainPath; std::string mBasePath; std::string mPatchesPath; diff --git a/src/core/bridge/audioplayerbridge.cpp b/src/core/bridge/audioplayerbridge.cpp index 1abae7f..4c89fa8 100644 --- a/src/core/bridge/audioplayerbridge.cpp +++ b/src/core/bridge/audioplayerbridge.cpp @@ -14,9 +14,9 @@ bool AudioPlayerInit(void) { } // loop over available audio apis if current fails - auto audioBackends = SohImGui::GetAvailableAudioBackends(); + auto audioBackends = Ship::GetAvailableAudioBackends(); for (uint8_t i = 0; i < audioBackends.size(); i++) { - SohImGui::SetCurrentAudioBackend(i, audioBackends[i]); + Ship::SetCurrentAudioBackend(i, audioBackends[i]); Ship::Window::GetInstance()->InitializeAudioPlayer(audioBackends[i].first); if (audio->Init()) { return true; diff --git a/src/core/libultra/os.cpp b/src/core/libultra/os.cpp index 8ac36e4..2c56430 100644 --- a/src/core/libultra/os.cpp +++ b/src/core/libultra/os.cpp @@ -43,7 +43,7 @@ int32_t osContStartReadData(OSMesgQueue* mesg) { void osContGetReadData(OSContPad* pad) { memset(pad, 0, sizeof(OSContPad) * __osMaxControllers); - if (SohImGui::GetInputEditor()->IsOpened()) { + if (Ship::GetInputEditor()->IsOpened()) { return; } diff --git a/src/debug/CrashHandler.cpp b/src/debug/CrashHandler.cpp index 0de7821..60dda27 100644 --- a/src/debug/CrashHandler.cpp +++ b/src/debug/CrashHandler.cpp @@ -184,13 +184,6 @@ static void ErrorHandler(int sig, siginfo_t* sigInfo, void* data) { if (status == 0) { nameFound = demangled; } -#if 0 - char command[256]; - char addrLine[128]; - snprintf(command, sizeof(command), "addr2line -e soh.elf %s + 0x%lX", nameFound, (uintptr_t)arr[i] - (uintptr_t)info.dli_saddr); - pipe = popen(command, "r"); - fgets(addrLine, 128, pipe); -#endif functionName = StringHelper::Sprintf("%s (+0x%X)", nameFound, (char*)arr[i] - (char*)info.dli_saddr); free(demangled); @@ -198,8 +191,11 @@ static void ErrorHandler(int sig, siginfo_t* sigInfo, void* data) { snprintf(intToCharBuffer, sizeof(intToCharBuffer), "%i ", (int)i); WRITE_VAR_LINE(crashHandler, intToCharBuffer, functionName.c_str()); } - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SoH has crashed", - "SoH Has crashed. Please upload the logs to the support channel in discord.", nullptr); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, (Ship::Window::GetInstance()->GetName() + " has crashed").c_str(), + (Ship::Window::GetInstance()->GetName() + + " has crashed. Please upload the logs to the support channel in discord.") + .c_str(), + nullptr); free(symbols); crashHandler->PrintCommon(); @@ -406,8 +402,11 @@ extern "C" LONG seh_filter(struct _EXCEPTION_POINTERS* ex) { WRITE_VAR_LINE(crashHandler, "Exception: ", exceptionString); crashHandler->PrintStack(ex->ContextRecord); - MessageBoxA(nullptr, "The game has crashed. Please upload the logs to the support channel in discord.", "Crash", - MB_OK | MB_ICONERROR); + MessageBoxA(nullptr, + (Ship::Window::GetInstance()->GetName() + + " has crashed. Please upload the logs to the support channel in discord.") + .c_str(), + "Crash", MB_OK | MB_ICONERROR); return EXCEPTION_EXECUTE_HANDLER; } diff --git a/src/graphic/Fast3D/gfx_direct3d11.cpp b/src/graphic/Fast3D/gfx_direct3d11.cpp index 6d1a437..1231031 100644 --- a/src/graphic/Fast3D/gfx_direct3d11.cpp +++ b/src/graphic/Fast3D/gfx_direct3d11.cpp @@ -385,10 +385,10 @@ void CSMain(uint3 DTid : SV_DispatchThreadID) { // Create ImGui - SohImGui::WindowImpl window_impl; - window_impl.backend = SohImGui::Backend::DX11; + Ship::WindowImpl window_impl; + window_impl.backend = Ship::Backend::DX11; window_impl.Dx11 = { gfx_dxgi_get_h_wnd(), d3d.context.Get(), d3d.device.Get() }; - SohImGui::Init(window_impl); + Ship::InitGui(window_impl); } static int gfx_d3d11_get_max_texture_size() { diff --git a/src/graphic/Fast3D/gfx_dxgi.cpp b/src/graphic/Fast3D/gfx_dxgi.cpp index 31ce9e1..2543732 100644 --- a/src/graphic/Fast3D/gfx_dxgi.cpp +++ b/src/graphic/Fast3D/gfx_dxgi.cpp @@ -233,9 +233,9 @@ static void onkeyup(WPARAM w_param, LPARAM l_param) { static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_param, LPARAM l_param) { char fileName[256]; - SohImGui::EventImpl event_impl; + Ship::EventImpl event_impl; event_impl.Win32 = { h_wnd, static_cast(message), static_cast(w_param), static_cast(l_param) }; - SohImGui::Update(event_impl); + Ship::UpdateGui(event_impl); switch (message) { case WM_SIZE: dxgi.current_width = (uint32_t)(l_param & 0xffff); diff --git a/src/graphic/Fast3D/gfx_pc.cpp b/src/graphic/Fast3D/gfx_pc.cpp index efa8131..0478469 100644 --- a/src/graphic/Fast3D/gfx_pc.cpp +++ b/src/graphic/Fast3D/gfx_pc.cpp @@ -3073,7 +3073,7 @@ struct GfxRenderingAPI* gfx_get_current_rendering_api(void) { void gfx_start_frame(void) { gfx_wapi->handle_events(); gfx_wapi->get_dimensions(&gfx_current_window_dimensions.width, &gfx_current_window_dimensions.height); - SohImGui::DrawMainMenuAndCalculateGameSize(); + Ship::DrawMainMenuAndCalculateGameSize(); has_drawn_imgui_menu = true; if (gfx_current_dimensions.height == 0) { // Avoid division by zero @@ -3130,8 +3130,8 @@ void gfx_run(Gfx* commands, const std::unordered_map& mtx_replacemen if (!gfx_wapi->start_frame()) { dropped_frame = true; if (has_drawn_imgui_menu) { - SohImGui::DrawFramebufferAndGameInput(); - SohImGui::CancelFrame(); + Ship::DrawFramebufferAndGameInput(); + Ship::CancelFrame(); has_drawn_imgui_menu = false; } return; @@ -3139,7 +3139,7 @@ void gfx_run(Gfx* commands, const std::unordered_map& mtx_replacemen dropped_frame = false; if (!has_drawn_imgui_menu) { - SohImGui::DrawMainMenuAndCalculateGameSize(); + Ship::DrawMainMenuAndCalculateGameSize(); } current_mtx_replacements = &mtx_replacements; @@ -3177,8 +3177,8 @@ void gfx_run(Gfx* commands, const std::unordered_map& mtx_replacemen gfxFramebuffer = (uintptr_t)gfx_rapi->get_framebuffer_texture_id(game_framebuffer); } } - SohImGui::DrawFramebufferAndGameInput(); - SohImGui::Render(); + Ship::DrawFramebufferAndGameInput(); + Ship::RenderImGui(); gfx_rapi->end_frame(); gfx_wapi->swap_buffers_begin(); has_drawn_imgui_menu = false; diff --git a/src/graphic/Fast3D/gfx_sdl2.cpp b/src/graphic/Fast3D/gfx_sdl2.cpp index 0d5309c..b6516b4 100644 --- a/src/graphic/Fast3D/gfx_sdl2.cpp +++ b/src/graphic/Fast3D/gfx_sdl2.cpp @@ -309,7 +309,7 @@ static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool s } wnd = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, flags); - SohImGui::WindowImpl window_impl; + Ship::WindowImpl window_impl; if (use_opengl) { #ifndef __SWITCH__ @@ -332,7 +332,7 @@ static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool s SDL_GL_SetSwapInterval(vsync_enabled ? 1 : 0); window_impl.Opengl = { wnd, ctx }; - window_impl.backend = SohImGui::Backend::SDL_OPENGL; + window_impl.backend = Ship::Backend::SDL_OPENGL; } else { uint32_t flags = SDL_RENDERER_ACCELERATED; if (vsync_enabled) { @@ -346,10 +346,10 @@ static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool s SDL_GetRendererOutputSize(renderer, &window_width, &window_height); window_impl.Metal = { wnd, renderer }; - window_impl.backend = SohImGui::Backend::SDL_METAL; + window_impl.backend = Ship::Backend::SDL_METAL; } - SohImGui::Init(window_impl); + Ship::InitGui(window_impl); for (size_t i = 0; i < sizeof(lus_to_sdl_table) / sizeof(SDL_Scancode); i++) { sdl_to_lus_table[lus_to_sdl_table[i]] = i; @@ -448,9 +448,9 @@ static void gfx_sdl_onkeyup(int scancode) { static void gfx_sdl_handle_events(void) { SDL_Event event; while (SDL_PollEvent(&event)) { - SohImGui::EventImpl event_impl; + Ship::EventImpl event_impl; event_impl.Sdl = { &event }; - SohImGui::Update(event_impl); + Ship::UpdateGui(event_impl); switch (event.type) { #ifndef TARGET_WEB // Scancodes are broken in Emscripten SDL2: https://bugzilla.libsdl.org/show_bug.cgi?id=3259 diff --git a/src/graphic/Fast3D/gfx_wiiu.cpp b/src/graphic/Fast3D/gfx_wiiu.cpp index 7c0434f..3a827b0 100644 --- a/src/graphic/Fast3D/gfx_wiiu.cpp +++ b/src/graphic/Fast3D/gfx_wiiu.cpp @@ -305,11 +305,11 @@ static void gfx_wiiu_init(const char* game_name, const char* gfx_api_name, bool gfx_current_dimensions.width = gfx_current_game_window_viewport.width = WIIU_DEFAULT_FB_WIDTH; gfx_current_dimensions.height = gfx_current_game_window_viewport.height = WIIU_DEFAULT_FB_HEIGHT; - SohImGui::WindowImpl window_impl; - window_impl.backend = SohImGui::Backend::GX2; + ImGui::WindowImpl window_impl; + window_impl.backend = ImGui::Backend::GX2; window_impl.Gx2.Width = WIIU_DEFAULT_FB_WIDTH; window_impl.Gx2.Height = WIIU_DEFAULT_FB_HEIGHT; - SohImGui::Init(window_impl); + ImGui::Init(window_impl); } static void gfx_wiiu_shutdown(void) { @@ -392,9 +392,9 @@ static void gfx_wiiu_handle_events(void) { } } - SohImGui::EventImpl event_impl; + ImGui::EventImpl event_impl; event_impl.Gx2.Input = &input; - SohImGui::Update(event_impl); + ImGui::Update(event_impl); } static bool gfx_wiiu_start_frame(void) { diff --git a/src/log/spd/sohconsole_sink.h b/src/log/spd/ConsoleSink.h similarity index 69% rename from src/log/spd/sohconsole_sink.h rename to src/log/spd/ConsoleSink.h index e5b6a23..e05da6d 100644 --- a/src/log/spd/sohconsole_sink.h +++ b/src/log/spd/ConsoleSink.h @@ -18,12 +18,9 @@ namespace spdlog { namespace sinks { -/* - * Android sink (logging using __android_log_write) - */ -template class sohconsole_sink final : public base_sink { +template class ConsoleSink final : public base_sink { public: - explicit sohconsole_sink(std::string tag = "spdlog", bool use_raw_msg = false) + explicit ConsoleSink(std::string tag = "spdlog", bool use_raw_msg = false) : tag_(std::move(tag)), use_raw_msg_(use_raw_msg) { } @@ -37,8 +34,8 @@ template class sohconsole_sink final : public base_sink } formatted.push_back('\0'); const char* msg_output = formatted.data(); - if (CVarGetInteger("gSinkEnabled", 0) && SohImGui::GetConsole()->IsOpened()) { - SohImGui::GetConsole()->Append("Logs", msg.level, "%s", msg_output); + if (CVarGetInteger("gSinkEnabled", 0) && Ship::GetConsole()->IsOpened()) { + Ship::GetConsole()->Append("Logs", msg.level, "%s", msg_output); } } @@ -50,7 +47,7 @@ template class sohconsole_sink final : public base_sink bool use_raw_msg_; }; -using soh_sink_mt = sohconsole_sink; -using soh_sink_st = sohconsole_sink; +using lus_sink_mt = ConsoleSink; +using lus_sink_st = ConsoleSink; } // namespace sinks } // namespace spdlog diff --git a/src/menu/GameOverlay.cpp b/src/menu/GameOverlay.cpp index a91e06c..7760ba0 100644 --- a/src/menu/GameOverlay.cpp +++ b/src/menu/GameOverlay.cpp @@ -16,24 +16,24 @@ bool GameOverlay::OverlayCommand(std::shared_ptr console, const std::ve if (CVarGet(args[2].c_str()) != nullptr) { const char* key = args[2].c_str(); - GameOverlay* overlay = SohImGui::GetGameOverlay(); + GameOverlay* overlay = GetGameOverlay(); if (args[1] == "add") { if (!overlay->RegisteredOverlays.contains(key)) { overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f }); - SohImGui::GetConsole()->SendInfoMessage("Added overlay: %s", key); + GetConsole()->SendInfoMessage("Added overlay: %s", key); } else { - SohImGui::GetConsole()->SendErrorMessage("Overlay already exists: %s", key); + GetConsole()->SendErrorMessage("Overlay already exists: %s", key); } } else if (args[1] == "remove") { if (overlay->RegisteredOverlays.contains(key)) { overlay->RegisteredOverlays.erase(key); - SohImGui::GetConsole()->SendInfoMessage("Removed overlay: %s", key); + GetConsole()->SendInfoMessage("Removed overlay: %s", key); } else { - SohImGui::GetConsole()->SendErrorMessage("Overlay not found: %s", key); + GetConsole()->SendErrorMessage("Overlay not found: %s", key); } } } else { - SohImGui::GetConsole()->SendErrorMessage("CVar {} does not exist", args[2].c_str()); + GetConsole()->SendErrorMessage("CVar {} does not exist", args[2].c_str()); } return CMD_SUCCESS; @@ -132,7 +132,7 @@ ImVec2 GameOverlay::CalculateTextSize(const char* text, const char* textEnd, boo textDisplayEnd = textEnd; } - GameOverlay* overlay = SohImGui::GetGameOverlay(); + GameOverlay* overlay = GetGameOverlay(); ImFont* font = overlay->CurrentFont == "Default" ? g.Font : overlay->Fonts[overlay->CurrentFont]; const float fontSize = font->FontSize; @@ -166,7 +166,7 @@ void GameOverlay::Init() { } } - SohImGui::GetConsole()->AddCommand("overlay", { OverlayCommand, "Draw an overlay using a cvar value" }); + GetConsole()->AddCommand("overlay", { OverlayCommand, "Draw an overlay using a cvar value" }); } void GameOverlay::DrawSettings() { @@ -176,7 +176,7 @@ void GameOverlay::DrawSettings() { if (ImGui::Selectable(name.c_str(), name == this->CurrentFont)) { this->CurrentFont = name; CVarSetString("gOverlayFont", ImStrdup(name.c_str())); - SohImGui::RequestCvarSaveOnNextTick(); + RequestCvarSaveOnNextTick(); } } ImGui::EndCombo(); @@ -188,7 +188,7 @@ void GameOverlay::Draw() { ImGui::SetNextWindowPos(viewport->Pos, ImGuiCond_Always); ImGui::SetNextWindowSize(viewport->Size, ImGuiCond_Always); - ImGui::Begin("SoHOverlay", nullptr, + ImGui::Begin("GameOverlay", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs); diff --git a/src/menu/ImGuiImpl.cpp b/src/menu/ImGuiImpl.cpp index 7fe51e6..55ba201 100644 --- a/src/menu/ImGuiImpl.cpp +++ b/src/menu/ImGuiImpl.cpp @@ -67,8 +67,6 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); #endif - -using namespace Ship; bool oldCursorState = true; #define BindButton(btn, status) \ @@ -85,8 +83,7 @@ OSContPad* pads; std::map DefaultAssets; std::vector emptyArgs; -namespace SohImGui { - +namespace Ship { WindowImpl impl; ImGuiIO* io; std::shared_ptr console = std::make_shared(); @@ -424,7 +421,7 @@ void LoadTexture(const std::string& name, const std::string& path) { // MARK: - Public API -void Init(WindowImpl windowImpl) { +void InitGui(WindowImpl windowImpl) { impl = windowImpl; ImGuiContext* ctx = ImGui::CreateContext(); ImGui::SetCurrentContext(ctx); @@ -474,9 +471,9 @@ void Init(WindowImpl windowImpl) { if (CVarGetInteger("gOpenMenuBar", 0) != 1) { #if defined(__SWITCH__) || defined(__WIIU__) - SohImGui::overlay->TextDrawNotification(30.0f, true, "Press - to access enhancements menu"); + ImGui::overlay->TextDrawNotification(30.0f, true, "Press - to access enhancements menu"); #else - SohImGui::overlay->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu"); + overlay->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu"); #endif } @@ -511,7 +508,7 @@ void Init(WindowImpl windowImpl) { setCursorVisibility(menuBarOpen); } - LoadTexture("Game_Icon", "textures/icons/gSohIcon.png"); + LoadTexture("Game_Icon", "textures/icons/gIcon.png"); LoadTexture("A-Btn", "textures/buttons/ABtn.png"); LoadTexture("B-Btn", "textures/buttons/BBtn.png"); LoadTexture("L-Btn", "textures/buttons/LBtn.png"); @@ -538,7 +535,7 @@ void Init(WindowImpl windowImpl) { #endif } -void Update(EventImpl event) { +void UpdateGui(EventImpl event) { if (needsSave) { CVarSave(); needsSave = false; @@ -649,8 +646,7 @@ void DrawMainMenuAndCalculateGameSize(void) { console->Dispatch("reset"); } #if !defined(__SWITCH__) && !defined(__WIIU__) - const char* keyboardShortcut = - strcmp(SohImGui::GetCurrentRenderingBackend().first, "sdl") == 0 ? "F10" : "ALT+Enter"; + const char* keyboardShortcut = strcmp(GetCurrentRenderingBackend().first, "sdl") == 0 ? "F10" : "ALT+Enter"; if (ImGui::MenuItem("Toggle Fullscreen", keyboardShortcut)) { Window::GetInstance()->ToggleFullscreen(); } @@ -853,7 +849,7 @@ void DrawFramebufferAndGameInput(void) { } } -void Render() { +void RenderImGui() { ImGui::Render(); ImGuiRenderDrawData(ImGui::GetDrawData()); if (io->ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { @@ -930,7 +926,7 @@ void SetMSAALevel(uint32_t value) { void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled, bool isHidden) { if (customWindows.contains(name)) { - SPDLOG_ERROR("SohImGui::AddWindow: Attempting to add duplicate window name %s", name.c_str()); + SPDLOG_ERROR("ImGui::AddWindow: Attempting to add duplicate window name %s", name.c_str()); return; } @@ -1036,7 +1032,7 @@ void LoadResource(const std::string& name, const std::string& path, const ImVec4 break; default: // TODO convert other image types - SPDLOG_WARN("SohImGui::LoadResource: Attempting to load unsupporting image type %s", path.c_str()); + SPDLOG_WARN("ImGui::LoadResource: Attempting to load unsupporting image type %s", path.c_str()); return; } @@ -1184,4 +1180,4 @@ void EndGroupPanel(float minHeight) { ImGui::EndGroup(); } -} // namespace SohImGui +} // namespace Ship diff --git a/src/menu/ImGuiImpl.h b/src/menu/ImGuiImpl.h index afe784a..7a1f99a 100644 --- a/src/menu/ImGuiImpl.h +++ b/src/menu/ImGuiImpl.h @@ -14,7 +14,7 @@ struct GameAsset { int height; }; -namespace SohImGui { +namespace Ship { enum class Backend { DX11, SDL_OPENGL, @@ -76,15 +76,15 @@ typedef struct { bool SupportsWindowedFullscreen(); bool SupportsViewports(); -void Init(WindowImpl windowImpl); -void Update(EventImpl event); +void InitGui(WindowImpl windowImpl); +void UpdateGui(EventImpl event); void DrawMainMenuAndCalculateGameSize(void); void RegisterMenuDrawMethod(std::function drawMethod); void AddSetupHooksDelegate(std::function setupHooksMethod); void DrawFramebufferAndGameInput(void); -void Render(void); +void RenderImGui(void); void CancelFrame(void); void DrawSettings(); @@ -123,6 +123,6 @@ void LoadResource(const std::string& name, const std::string& path, const ImVec4 void setCursorVisibility(bool visible); void BeginGroupPanel(const char* name, const ImVec2& size = ImVec2(0.0f, 0.0f)); void EndGroupPanel(float minHeight = 0.0f); -} // namespace SohImGui +} // namespace Ship #endif diff --git a/src/menu/InputEditor.cpp b/src/menu/InputEditor.cpp index 53b1ee1..e540135 100644 --- a/src/menu/InputEditor.cpp +++ b/src/menu/InputEditor.cpp @@ -119,7 +119,7 @@ void InputEditor::DrawControllerSchema() { DrawControllerSelect(mCurrentPort); - SohImGui::BeginGroupPanel("Buttons", ImVec2(150, 20)); + BeginGroupPanel("Buttons", ImVec2(150, 20)); DrawButton("A", BTN_A, mCurrentPort, &mBtnReading); DrawButton("B", BTN_B, mCurrentPort, &mBtnReading); DrawButton("L", BTN_L, mCurrentPort, &mBtnReading); @@ -128,24 +128,24 @@ void InputEditor::DrawControllerSchema() { DrawButton("START", BTN_START, mCurrentPort, &mBtnReading); SEPARATION(); #ifdef __SWITCH__ - SohImGui::EndGroupPanel(isKeyboard ? 7.0f : 56.0f); + ImGui::EndGroupPanel(isKeyboard ? 7.0f : 56.0f); #else - SohImGui::EndGroupPanel(isKeyboard ? 7.0f : 48.0f); + Ship::EndGroupPanel(isKeyboard ? 7.0f : 48.0f); #endif ImGui::SameLine(); - SohImGui::BeginGroupPanel("Digital Pad", ImVec2(150, 20)); + BeginGroupPanel("Digital Pad", ImVec2(150, 20)); DrawButton("Up", BTN_DUP, mCurrentPort, &mBtnReading); DrawButton("Down", BTN_DDOWN, mCurrentPort, &mBtnReading); DrawButton("Left", BTN_DLEFT, mCurrentPort, &mBtnReading); DrawButton("Right", BTN_DRIGHT, mCurrentPort, &mBtnReading); SEPARATION(); #ifdef __SWITCH__ - SohImGui::EndGroupPanel(isKeyboard ? 53.0f : 122.0f); + ImGui::EndGroupPanel(isKeyboard ? 53.0f : 122.0f); #else - SohImGui::EndGroupPanel(isKeyboard ? 53.0f : 94.0f); + EndGroupPanel(isKeyboard ? 53.0f : 94.0f); #endif ImGui::SameLine(); - SohImGui::BeginGroupPanel("Analog Stick", ImVec2(150, 20)); + BeginGroupPanel("Analog Stick", ImVec2(150, 20)); DrawButton("Up", BTN_STICKUP, mCurrentPort, &mBtnReading); DrawButton("Down", BTN_STICKDOWN, mCurrentPort, &mBtnReading); DrawButton("Left", BTN_STICKLEFT, mCurrentPort, &mBtnReading); @@ -182,15 +182,15 @@ void InputEditor::DrawControllerSchema() { ImGui::Dummy(ImVec2(0, 6)); } #ifdef __SWITCH__ - SohImGui::EndGroupPanel(isKeyboard ? 52.0f : 52.0f); + ImGui::EndGroupPanel(isKeyboard ? 52.0f : 52.0f); #else - SohImGui::EndGroupPanel(isKeyboard ? 52.0f : 24.0f); + EndGroupPanel(isKeyboard ? 52.0f : 24.0f); #endif ImGui::SameLine(); if (!isKeyboard) { ImGui::SameLine(); - SohImGui::BeginGroupPanel("Right Stick", ImVec2(150, 20)); + BeginGroupPanel("Right Stick", ImVec2(150, 20)); DrawButton("Up", BTN_VSTICKUP, mCurrentPort, &mBtnReading); DrawButton("Down", BTN_VSTICKDOWN, mCurrentPort, &mBtnReading); DrawButton("Left", BTN_VSTICKLEFT, mCurrentPort, &mBtnReading); @@ -224,9 +224,9 @@ void InputEditor::DrawControllerSchema() { ImGui::PopItemWidth(); ImGui::EndChild(); #ifdef __SWITCH__ - SohImGui::EndGroupPanel(43.0f); + ImGui::EndGroupPanel(43.0f); #else - SohImGui::EndGroupPanel(14.0f); + EndGroupPanel(14.0f); #endif } @@ -234,7 +234,7 @@ void InputEditor::DrawControllerSchema() { #ifndef __WIIU__ ImGui::SameLine(); #endif - SohImGui::BeginGroupPanel("Gyro Options", ImVec2(175, 20)); + BeginGroupPanel("Gyro Options", ImVec2(175, 20)); float cursorX = ImGui::GetCursorPosX() + 5; ImGui::SetCursorPosX(cursorX); ImGui::Checkbox("Enable Gyro", &profile->UseGyro); @@ -283,9 +283,9 @@ void InputEditor::DrawControllerSchema() { ImGui::PopItemWidth(); ImGui::EndChild(); #ifdef __SWITCH__ - SohImGui::EndGroupPanel(46.0f); + ImGui::EndGroupPanel(46.0f); #else - SohImGui::EndGroupPanel(14.0f); + EndGroupPanel(14.0f); #endif } @@ -293,13 +293,13 @@ void InputEditor::DrawControllerSchema() { const ImVec2 cursor = ImGui::GetCursorPos(); - SohImGui::BeginGroupPanel("C-Buttons", ImVec2(158, 20)); + BeginGroupPanel("C-Buttons", ImVec2(158, 20)); DrawButton("Up", BTN_CUP, mCurrentPort, &mBtnReading); DrawButton("Down", BTN_CDOWN, mCurrentPort, &mBtnReading); DrawButton("Left", BTN_CLEFT, mCurrentPort, &mBtnReading); DrawButton("Right", BTN_CRIGHT, mCurrentPort, &mBtnReading); ImGui::Dummy(ImVec2(0, 5)); - SohImGui::EndGroupPanel(); + EndGroupPanel(); ImGui::SetCursorPosX(cursor.x); #ifdef __SWITCH__ @@ -309,7 +309,7 @@ void InputEditor::DrawControllerSchema() { #else ImGui::SetCursorPosY(cursor.y + 120); #endif - SohImGui::BeginGroupPanel("Options", ImVec2(158, 20)); + BeginGroupPanel("Options", ImVec2(158, 20)); float cursorX = ImGui::GetCursorPosX() + 5; ImGui::SetCursorPosX(cursorX); ImGui::Checkbox("Rumble Enabled", &profile->UseRumble); @@ -346,7 +346,7 @@ void InputEditor::DrawControllerSchema() { } ImGui::Dummy(ImVec2(0, 5)); - SohImGui::EndGroupPanel(isKeyboard ? 0.0f : 2.0f); + EndGroupPanel(isKeyboard ? 0.0f : 2.0f); } void InputEditor::DrawHud() { diff --git a/src/port/wiiu/WiiUImpl.cpp b/src/port/wiiu/WiiUImpl.cpp index 03e6007..b8b2c41 100644 --- a/src/port/wiiu/WiiUImpl.cpp +++ b/src/port/wiiu/WiiUImpl.cpp @@ -59,9 +59,9 @@ void Init() { // make sure the required folders exist mkdir("/vol/external01/wiiu/", 0755); mkdir("/vol/external01/wiiu/apps/", 0755); - mkdir("/vol/external01/wiiu/apps/soh/", 0755); + mkdir(("/vol/external01/wiiu/apps/" + Window::GetInstance()->GetShortName()).c_str(), 0755); - chdir("/vol/external01/wiiu/apps/soh/"); + chdir(("/vol/external01/wiiu/apps/" + Window::GetInstance()->GetShortName()).c_str()); KPADInit(); WPADEnableURCC(true);