mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-14 18:48:04 -07:00
Phase 1: Separate ImGui Drawing From LUS (#1310)
* Update LUS imported paths * Introduce GameMenuBar * Fix imports after LUS import paths change * Move Randomizer * Replace needs_save * Migrate Developer Tools * Migrate Cheats * Migrate Enhancements * Separate UIWidgets * Add missing Hooks.cpp file * Migrate Settings * Remove UI methods from LUS * Cleanup imports and exposed properties * Cleanup more methods * Fix project generation * Fix CI compilation * Remove resolved TODO
This commit is contained in:
parent
64aca78450
commit
0ce0ab1260
52 changed files with 2719 additions and 2552 deletions
|
@ -121,6 +121,7 @@ set(Source_Files__CustomImpl
|
|||
source_group("Source Files\\CustomImpl" FILES ${Source_Files__CustomImpl})
|
||||
|
||||
set(Source_Files__CustomImpl__Hooks
|
||||
"Hooks.cpp"
|
||||
"Hooks.h"
|
||||
)
|
||||
source_group("Source Files\\CustomImpl\\Hooks" FILES ${Source_Files__CustomImpl__Hooks})
|
||||
|
|
|
@ -16,28 +16,28 @@ namespace Ship {
|
|||
|
||||
if (CVar_Get(args[2].c_str()) != nullptr) {
|
||||
const char* key = args[2].c_str();
|
||||
GameOverlay* overlay = SohImGui::overlay;
|
||||
GameOverlay* overlay = SohImGui::GetGameOverlay();
|
||||
if (args[1] == "add") {
|
||||
if (!overlay->RegisteredOverlays.contains(key)) {
|
||||
overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f });
|
||||
SohImGui::console->SendInfoMessage("Added overlay: %s", key);
|
||||
SohImGui::GetConsole()->SendInfoMessage("Added overlay: %s", key);
|
||||
}
|
||||
else {
|
||||
SohImGui::console->SendErrorMessage("Overlay already exists: %s", key);
|
||||
SohImGui::GetConsole()->SendErrorMessage("Overlay already exists: %s", key);
|
||||
}
|
||||
}
|
||||
else if (args[1] == "remove") {
|
||||
if (overlay->RegisteredOverlays.contains(key)) {
|
||||
overlay->RegisteredOverlays.erase(key);
|
||||
SohImGui::console->SendInfoMessage("Removed overlay: %s", key);
|
||||
SohImGui::GetConsole()->SendInfoMessage("Removed overlay: %s", key);
|
||||
}
|
||||
else {
|
||||
SohImGui::console->SendErrorMessage("Overlay not found: %s", key);
|
||||
SohImGui::GetConsole()->SendErrorMessage("Overlay not found: %s", key);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
SohImGui::console->SendErrorMessage("CVar {} does not exist", args[2].c_str());
|
||||
SohImGui::GetConsole()->SendErrorMessage("CVar {} does not exist", args[2].c_str());
|
||||
}
|
||||
|
||||
return CMD_SUCCESS;
|
||||
|
@ -124,7 +124,7 @@ namespace Ship {
|
|||
else
|
||||
text_display_end = text_end;
|
||||
|
||||
GameOverlay* overlay = SohImGui::overlay;
|
||||
GameOverlay* overlay = SohImGui::GetGameOverlay();
|
||||
|
||||
ImFont* font = overlay->CurrentFont == "Default" ? g.Font : overlay->Fonts[overlay->CurrentFont];
|
||||
const float font_size = font->FontSize;
|
||||
|
@ -157,7 +157,7 @@ namespace Ship {
|
|||
}
|
||||
}
|
||||
|
||||
SohImGui::console->AddCommand("overlay", { OverlayCommand, "Draw an overlay using a cvar value" });
|
||||
SohImGui::GetConsole()->AddCommand("overlay", { OverlayCommand, "Draw an overlay using a cvar value" });
|
||||
}
|
||||
|
||||
void GameOverlay::DrawSettings() {
|
||||
|
@ -167,7 +167,7 @@ namespace Ship {
|
|||
if (ImGui::Selectable(name.c_str(), name == this->CurrentFont)) {
|
||||
this->CurrentFont = name;
|
||||
CVar_SetString("gOverlayFont", ImStrdup(name.c_str()));
|
||||
SohImGui::needs_save = true;
|
||||
SohImGui::RequestCvarSaveOnNextTick();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,14 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void enableBetaQuest();
|
||||
void disableBetaQuest();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "GameOverlay.h"
|
||||
#include "Lib/ImGui/imgui.h"
|
||||
|
@ -34,14 +25,6 @@ namespace SohImGui {
|
|||
dLoadSettings,
|
||||
};
|
||||
|
||||
// Enumeration for disabled checkbox graphics
|
||||
enum class ImGuiCheckboxGraphics
|
||||
{
|
||||
Cross,
|
||||
Checkmark,
|
||||
None
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
Backend backend;
|
||||
union {
|
||||
|
@ -76,8 +59,6 @@ namespace SohImGui {
|
|||
} gx2;
|
||||
} EventImpl;
|
||||
|
||||
extern WindowImpl impl;
|
||||
|
||||
using WindowDrawFunc = void(*)(bool& enabled);
|
||||
|
||||
typedef struct {
|
||||
|
@ -85,55 +66,49 @@ namespace SohImGui {
|
|||
WindowDrawFunc drawFunc;
|
||||
} CustomWindow;
|
||||
|
||||
extern std::shared_ptr<Ship::Console> console;
|
||||
extern Ship::InputEditor* controller;
|
||||
extern Ship::GameOverlay* overlay;
|
||||
extern bool needs_save;
|
||||
void Init(WindowImpl window_impl);
|
||||
void Update(EventImpl event);
|
||||
void Tooltip(const char* text);
|
||||
|
||||
void EnhancementRadioButton(const char* text, const char* cvarName, int id);
|
||||
void EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", ImGuiCheckboxGraphics disabledGraphic = ImGuiCheckboxGraphics::Cross);
|
||||
void EnhancementButton(const char* text, const char* cvarName);
|
||||
void EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false);
|
||||
void EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = false);
|
||||
void EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue);
|
||||
void EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha=false, bool TitleSameLine=false);
|
||||
void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector<std::string>& items, int defaultValue = 0);
|
||||
|
||||
void applyEnhancementPresets(void);
|
||||
void applyEnhancementPresetDefault(void);
|
||||
void applyEnhancementPresetVanillaPlus(void);
|
||||
void applyEnhancementPresetEnhanced(void);
|
||||
void applyEnhancementPresetRandomizer(void);
|
||||
|
||||
void DrawMainMenuAndCalculateGameSize(void);
|
||||
void RegisterMenuDrawMethod(std::function<void(void)> drawMethod);
|
||||
void AddSetupHooksDelegate(std::function<void(void)> setupHooksMethod);
|
||||
|
||||
void DrawFramebufferAndGameInput(void);
|
||||
void Render(void);
|
||||
void CancelFrame(void);
|
||||
void ShowCursor(bool hide, Dialogues w);
|
||||
void BindCmd(const std::string& cmd, Ship::CommandEntry entry);
|
||||
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled=false, bool isHidden=false);
|
||||
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint = ImVec4(1, 1, 1, 1));
|
||||
void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha=false);
|
||||
int ClampFloatToInt(float value, int min, int max);
|
||||
void RandomizeColor(const char* cvarName, ImVec4* colors);
|
||||
void RainbowColor(const char* cvarName, ImVec4* colors);
|
||||
void ResetColor(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha);
|
||||
void DrawSettings();
|
||||
|
||||
Backend WindowBackend();
|
||||
float WindowRefreshRate();
|
||||
std::pair<const char*, const char*>* GetAvailableRenderingBackends();
|
||||
std::pair<const char*, const char*> GetCurrentRenderingBackend();
|
||||
void SetCurrentRenderingBackend(uint8_t index, std::pair<const char*, const char*>);
|
||||
const char** GetSupportedTextureFilters();
|
||||
void SetResolutionMultiplier(float multiplier);
|
||||
void SetMSAALevel(uint32_t value);
|
||||
|
||||
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled = false, bool isHidden = false);
|
||||
void EnableWindow(const std::string& name, bool isEnabled = true);
|
||||
|
||||
Ship::GameOverlay* GetGameOverlay();
|
||||
|
||||
Ship::InputEditor* GetInputEditor();
|
||||
void ToggleInputEditorWindow(bool isOpen = true);
|
||||
void ToggleStatisticsWindow(bool isOpen = true);
|
||||
|
||||
std::shared_ptr<Ship::Console> GetConsole();
|
||||
void ToggleConsoleWindow(bool isOpen = true);
|
||||
void DispatchConsoleCommand(const std::string& line);
|
||||
|
||||
void RequestCvarSaveOnNextTick();
|
||||
|
||||
ImTextureID GetTextureByID(int id);
|
||||
ImTextureID GetTextureByName(const std::string& name);
|
||||
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint = ImVec4(1, 1, 1, 1));
|
||||
|
||||
void ShowCursor(bool hide, Dialogues w);
|
||||
void BeginGroupPanel(const char* name, const ImVec2 & size = ImVec2(0.0f, 0.0f));
|
||||
void EndGroupPanel(float minHeight = 0.0f);
|
||||
std::string BreakTooltip(const char* text, int lineLength = 60);
|
||||
std::string BreakTooltip(const std::string& text, int lineLength = 60);
|
||||
void InsertPadding(float extraVerticalPadding = 0.0f);
|
||||
void PaddedSeparator(bool padTop = true, bool padBottom = true, float extraVerticalTopPadding = 0.0f, float extraVerticalBottomPadding = 0.0f);
|
||||
void PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = false, bool padTop = true, bool padBottom = true);
|
||||
void PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", ImGuiCheckboxGraphics disabledGraphic = ImGuiCheckboxGraphics::Cross);
|
||||
void PaddedText(const char* text, bool padTop = true, bool padBottom = true);
|
||||
std::string GetWindowButtonText(const char* text, bool menuOpen);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,8 +41,8 @@ protected:
|
|||
}
|
||||
formatted.push_back('\0');
|
||||
const char* msg_output = formatted.data();
|
||||
if (CVar_GetS32("gSinkEnabled", 0) && SohImGui::console->IsOpened()) {
|
||||
SohImGui::console->Append("Logs", msg.level, "%s", msg_output);
|
||||
if (CVar_GetS32("gSinkEnabled", 0) && SohImGui::GetConsole()->IsOpened()) {
|
||||
SohImGui::GetConsole()->Append("Logs", msg.level, "%s", msg_output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,4 +57,4 @@ private:
|
|||
using soh_sink_mt = sohconsole_sink<std::mutex>;
|
||||
using soh_sink_st = sohconsole_sink<details::null_mutex>;
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
} // namespace spdlog
|
||||
|
|
|
@ -86,7 +86,7 @@ extern "C" {
|
|||
pad->gyro_x = 0;
|
||||
pad->gyro_y = 0;
|
||||
|
||||
if (SohImGui::controller->IsOpened()) return;
|
||||
if (SohImGui::GetInputEditor()->IsOpened()) return;
|
||||
|
||||
Ship::Window::GetInstance()->GetControlDeck()->WriteToPad(pad);
|
||||
Ship::ExecuteHooks<Ship::ControllerRead>(pad);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue