mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-22 09:22:18 -05:00
Add UI scaling combobox with 4 options (one smaller than default, two larger) and experimental tag. (#3037)
This commit is contained in:
parent
ecafa87195
commit
8745881815
@ -46,6 +46,7 @@
|
|||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include "z64.h"
|
#include "z64.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
#include "Fonts.h"
|
||||||
#include <Utils/StringHelper.h>
|
#include <Utils/StringHelper.h>
|
||||||
#include "Enhancements/custom-message/CustomMessageManager.h"
|
#include "Enhancements/custom-message/CustomMessageManager.h"
|
||||||
|
|
||||||
@ -129,6 +130,8 @@ Color_RGB8 kokiriColor = { 0x1E, 0x69, 0x1B };
|
|||||||
Color_RGB8 goronColor = { 0x64, 0x14, 0x00 };
|
Color_RGB8 goronColor = { 0x64, 0x14, 0x00 };
|
||||||
Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 };
|
Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 };
|
||||||
|
|
||||||
|
float previousImGuiScale;
|
||||||
|
|
||||||
// Same as NaviColor type from OoT src (z_actor.c), but modified to be sans alpha channel for Controller LED.
|
// Same as NaviColor type from OoT src (z_actor.c), but modified to be sans alpha channel for Controller LED.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Color_RGB8 inner;
|
Color_RGB8 inner;
|
||||||
@ -298,6 +301,12 @@ OTRGlobals::OTRGlobals() {
|
|||||||
|
|
||||||
hasMasterQuest = hasOriginal = false;
|
hasMasterQuest = hasOriginal = false;
|
||||||
|
|
||||||
|
previousImGuiScale = defaultImGuiScale;
|
||||||
|
defaultFontSmaller = CreateDefaultFontWithSize(10.0f);
|
||||||
|
defaultFontLarger = CreateDefaultFontWithSize(16.0f);
|
||||||
|
defaultFontLargest = CreateDefaultFontWithSize(20.0f);
|
||||||
|
ScaleImGui();
|
||||||
|
|
||||||
// Move the camera strings from read only memory onto the heap (writable memory)
|
// Move the camera strings from read only memory onto the heap (writable memory)
|
||||||
// This is in OTRGlobals right now because this is a place that will only ever be run once at the beginning of startup.
|
// This is in OTRGlobals right now because this is a place that will only ever be run once at the beginning of startup.
|
||||||
// We should probably find some code in db_camera that does initialization and only run once, and then dealloc on deinitialization.
|
// We should probably find some code in db_camera that does initialization and only run once, and then dealloc on deinitialization.
|
||||||
@ -352,6 +361,32 @@ OTRGlobals::OTRGlobals() {
|
|||||||
OTRGlobals::~OTRGlobals() {
|
OTRGlobals::~OTRGlobals() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OTRGlobals::ScaleImGui() {
|
||||||
|
float scale = imguiScaleOptionToValue[CVarGetInteger("gImGuiScale", defaultImGuiScale)];
|
||||||
|
float newScale = scale / previousImGuiScale;
|
||||||
|
ImGui::GetStyle().ScaleAllSizes(newScale);
|
||||||
|
ImGui::GetIO().FontGlobalScale = scale;
|
||||||
|
previousImGuiScale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImFont* OTRGlobals::CreateDefaultFontWithSize(float size) {
|
||||||
|
auto mImGuiIo = &ImGui::GetIO();
|
||||||
|
ImFontConfig fontCfg = ImFontConfig();
|
||||||
|
fontCfg.OversampleH = fontCfg.OversampleV = 1;
|
||||||
|
fontCfg.PixelSnapH = true;
|
||||||
|
fontCfg.SizePixels = size;
|
||||||
|
ImFont* font = mImGuiIo->Fonts->AddFontDefault(&fontCfg);
|
||||||
|
// FontAwesome fonts need to have their sizes reduced by 2.0f/3.0f in order to align correctly
|
||||||
|
float iconFontSize = size * 2.0f / 3.0f;
|
||||||
|
static const ImWchar sIconsRanges[] = { ICON_MIN_FA, ICON_MAX_16_FA, 0 };
|
||||||
|
ImFontConfig iconsConfig;
|
||||||
|
iconsConfig.MergeMode = true;
|
||||||
|
iconsConfig.PixelSnapH = true;
|
||||||
|
iconsConfig.GlyphMinAdvanceX = iconFontSize;
|
||||||
|
mImGuiIo->Fonts->AddFontFromMemoryCompressedBase85TTF(fontawesome_compressed_data_base85, iconFontSize, &iconsConfig, sIconsRanges);
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
bool OTRGlobals::HasMasterQuest() {
|
bool OTRGlobals::HasMasterQuest() {
|
||||||
return hasMasterQuest;
|
return hasMasterQuest;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,14 @@
|
|||||||
const std::string customMessageTableID = "BaseGameOverrides";
|
const std::string customMessageTableID = "BaseGameOverrides";
|
||||||
const std::string appShortName = "soh";
|
const std::string appShortName = "soh";
|
||||||
|
|
||||||
|
#ifdef __WIIU__
|
||||||
|
const uint32_t defaultImGuiScale = 3;
|
||||||
|
#else
|
||||||
|
const uint32_t defaultImGuiScale = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const float imguiScaleOptionToValue[4] = { 0.75f, 1.0f, 1.5f, 2.0f };
|
||||||
|
|
||||||
class OTRGlobals
|
class OTRGlobals
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -30,9 +38,15 @@ public:
|
|||||||
std::shared_ptr<SaveStateMgr> gSaveStateMgr;
|
std::shared_ptr<SaveStateMgr> gSaveStateMgr;
|
||||||
std::shared_ptr<Randomizer> gRandomizer;
|
std::shared_ptr<Randomizer> gRandomizer;
|
||||||
|
|
||||||
|
ImFont* defaultFontSmaller;
|
||||||
|
ImFont* defaultFontLarger;
|
||||||
|
ImFont* defaultFontLargest;
|
||||||
|
|
||||||
OTRGlobals();
|
OTRGlobals();
|
||||||
~OTRGlobals();
|
~OTRGlobals();
|
||||||
|
|
||||||
|
void ScaleImGui();
|
||||||
|
|
||||||
bool HasMasterQuest();
|
bool HasMasterQuest();
|
||||||
bool HasOriginal();
|
bool HasOriginal();
|
||||||
uint32_t GetInterpolationFPS();
|
uint32_t GetInterpolationFPS();
|
||||||
@ -42,6 +56,7 @@ private:
|
|||||||
void CheckSaveFile(size_t sramSize) const;
|
void CheckSaveFile(size_t sramSize) const;
|
||||||
bool hasMasterQuest;
|
bool hasMasterQuest;
|
||||||
bool hasOriginal;
|
bool hasOriginal;
|
||||||
|
ImFont* CreateDefaultFontWithSize(float size);
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t IsGameMasterQuest();
|
uint32_t IsGameMasterQuest();
|
||||||
|
@ -51,6 +51,8 @@ std::string GetWindowButtonText(const char* text, bool menuOpen) {
|
|||||||
return buttonText;
|
return buttonText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* imguiScaleOptions[4] = { "Small", "Normal", "Large", "X-Large" };
|
||||||
|
|
||||||
static const char* filters[3] = {
|
static const char* filters[3] = {
|
||||||
#ifdef __WIIU__
|
#ifdef __WIIU__
|
||||||
"",
|
"",
|
||||||
@ -380,7 +382,15 @@ void DrawSettingsMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f);
|
UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f);
|
||||||
|
ImGui::Text("ImGui Menu Scale");
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextColored({ 0.85f, 0.35f, 0.0f, 1.0f }, "(Experimental)");
|
||||||
|
if (UIWidgets::EnhancementCombobox("gImGuiScale", imguiScaleOptions, 1)) {
|
||||||
|
OTRGlobals::Instance->ScaleImGui();
|
||||||
|
}
|
||||||
|
UIWidgets::Tooltip("Changes the scaling of the ImGui menu elements.");
|
||||||
|
|
||||||
|
UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f);
|
||||||
|
|
||||||
static std::unordered_map<LUS::WindowBackend, const char*> windowBackendNames = {
|
static std::unordered_map<LUS::WindowBackend, const char*> windowBackendNames = {
|
||||||
{ LUS::WindowBackend::DX11, "DirectX" },
|
{ LUS::WindowBackend::DX11, "DirectX" },
|
||||||
|
Loading…
Reference in New Issue
Block a user