mirror of
https://github.com/izzy2lost/libultraship.git
synced 2026-06-19 01:16:13 -07:00
Removes all lingering references to SoH from LUS (#190)
* Removes all lingering references to SoH from LUS * Adds mShortName to Window which stores a shorter version for file paths. * Runs clang-format * Fixes mac errors. * Fixes Linux build errors * Exclude custom spdlog syncs from clang-tidy.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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})
|
||||
|
||||
+14
-9
@@ -23,7 +23,7 @@
|
||||
#include <spdlog/async.h>
|
||||
#include <spdlog/sinks/rotating_file_sink.h>
|
||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||
#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> Window::GetInstance() {
|
||||
return mContext.lock();
|
||||
}
|
||||
|
||||
std::shared_ptr<Window> Window::CreateInstance(const std::string name, const std::vector<std::string>& otrFiles,
|
||||
std::shared_ptr<Window> Window::CreateInstance(const std::string name, const std::string shortName,
|
||||
const std::vector<std::string>& otrFiles,
|
||||
const std::unordered_set<uint32_t>& validHashes) {
|
||||
if (mContext.expired()) {
|
||||
auto shared = std::make_shared<Window>(name);
|
||||
auto shared = std::make_shared<Window>(name, shortName);
|
||||
mContext = shared;
|
||||
shared->Initialize(otrFiles, validHashes);
|
||||
return shared;
|
||||
@@ -54,9 +55,9 @@ std::shared_ptr<Window> 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<spdlog::sink_ptr> sinks;
|
||||
|
||||
auto SohConsoleSink = std::make_shared<spdlog::sinks::soh_sink_mt>();
|
||||
// SohConsoleSink->set_level(spdlog::level::trace);
|
||||
sinks.push_back(SohConsoleSink);
|
||||
auto consoleSink = std::make_shared<spdlog::sinks::lus_sink_mt>();
|
||||
// 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<ControlDeck> Window::GetControlDeck() {
|
||||
return mControlDeck;
|
||||
}
|
||||
|
||||
+7
-3
@@ -21,14 +21,16 @@ class ResourceManager;
|
||||
class Window {
|
||||
public:
|
||||
static std::shared_ptr<Window> GetInstance();
|
||||
static std::shared_ptr<Window> CreateInstance(const std::string name, const std::vector<std::string>& otrFiles = {},
|
||||
static std::shared_ptr<Window> CreateInstance(const std::string name, const std::string shortName,
|
||||
const std::vector<std::string>& otrFiles = {},
|
||||
const std::unordered_set<uint32_t>& 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<ControlDeck> GetControlDeck();
|
||||
std::shared_ptr<AudioPlayer> GetAudioPlayer();
|
||||
std::shared_ptr<ResourceManager> 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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<int>(message), static_cast<int>(w_param), static_cast<int>(l_param) };
|
||||
SohImGui::Update(event_impl);
|
||||
Ship::UpdateGui(event_impl);
|
||||
switch (message) {
|
||||
case WM_SIZE:
|
||||
dxgi.current_width = (uint32_t)(l_param & 0xffff);
|
||||
|
||||
@@ -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*, MtxF>& 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*, MtxF>& 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*, MtxF>& 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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -18,12 +18,9 @@
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
|
||||
/*
|
||||
* Android sink (logging using __android_log_write)
|
||||
*/
|
||||
template <typename Mutex> class sohconsole_sink final : public base_sink<Mutex> {
|
||||
template <typename Mutex> class ConsoleSink final : public base_sink<Mutex> {
|
||||
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 <typename Mutex> class sohconsole_sink final : public base_sink<Mutex>
|
||||
}
|
||||
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 <typename Mutex> class sohconsole_sink final : public base_sink<Mutex>
|
||||
bool use_raw_msg_;
|
||||
};
|
||||
|
||||
using soh_sink_mt = sohconsole_sink<std::mutex>;
|
||||
using soh_sink_st = sohconsole_sink<details::null_mutex>;
|
||||
using lus_sink_mt = ConsoleSink<std::mutex>;
|
||||
using lus_sink_st = ConsoleSink<details::null_mutex>;
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
+10
-10
@@ -16,24 +16,24 @@ bool GameOverlay::OverlayCommand(std::shared_ptr<Console> 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);
|
||||
|
||||
+11
-15
@@ -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<std::string, GameAsset*> DefaultAssets;
|
||||
std::vector<std::string> emptyArgs;
|
||||
|
||||
namespace SohImGui {
|
||||
|
||||
namespace Ship {
|
||||
WindowImpl impl;
|
||||
ImGuiIO* io;
|
||||
std::shared_ptr<Console> console = std::make_shared<Console>();
|
||||
@@ -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
|
||||
|
||||
@@ -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<void(void)> drawMethod);
|
||||
void AddSetupHooksDelegate(std::function<void(void)> 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
|
||||
|
||||
+19
-19
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user