mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
clang
This commit is contained in:
parent
ceadbe4e29
commit
0166448dc5
4 changed files with 126 additions and 87 deletions
|
@ -17,10 +17,10 @@ extern std::shared_ptr<SohMenu> mSohMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlankButton() {
|
void BlankButton() {
|
||||||
ImGui::PushStyleColor(ImGuiCol_Button, {0, 0, 0, 0});
|
ImGui::PushStyleColor(ImGuiCol_Button, { 0, 0, 0, 0 });
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, {0, 0, 0, 0});
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, { 0, 0, 0, 0 });
|
||||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, {0, 0, 0, 0});
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, { 0, 0, 0, 0 });
|
||||||
ImGui::PushStyleColor(ImGuiCol_Border, {0, 0, 0, 0});
|
ImGui::PushStyleColor(ImGuiCol_Border, { 0, 0, 0, 0 });
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8.0f, 8.0f));
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8.0f, 8.0f));
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f);
|
||||||
|
@ -114,7 +114,8 @@ enum PresetSection {
|
||||||
struct PresetInfo {
|
struct PresetInfo {
|
||||||
nlohmann::json presetValues;
|
nlohmann::json presetValues;
|
||||||
std::string fileName;
|
std::string fileName;
|
||||||
bool applySettings = true, applyEnhancements = true, applyAudio = true, applyCosmetics = true, applyRando = true, applyTrackers = true;
|
bool applySettings = true, applyEnhancements = true, applyAudio = true, applyCosmetics = true, applyRando = true,
|
||||||
|
applyTrackers = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::map<std::string, PresetInfo> presets;
|
static std::map<std::string, PresetInfo> presets;
|
||||||
|
@ -137,7 +138,8 @@ void DrawSectionCheck(const std::string& name, bool empty, bool* pointer, std::s
|
||||||
} else {
|
} else {
|
||||||
ImGui::PushFont(OTRGlobals::Instance->fontMono);
|
ImGui::PushFont(OTRGlobals::Instance->fontMono);
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (ImGui::GetStyle().FramePadding.y));
|
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (ImGui::GetStyle().FramePadding.y));
|
||||||
UIWidgets::Checkbox(("##" + name + section).c_str(), pointer, {.defaultValue = true, .padding = {6.0f, 6.0f}, .color = THEME_COLOR});
|
UIWidgets::Checkbox(("##" + name + section).c_str(), pointer,
|
||||||
|
{ .defaultValue = true, .padding = { 6.0f, 6.0f }, .color = THEME_COLOR });
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +154,8 @@ void LoadPresets() {
|
||||||
auto json = nlohmann::json::parse(ifs);
|
auto json = nlohmann::json::parse(ifs);
|
||||||
try {
|
try {
|
||||||
if (!json.contains("presetName")) {
|
if (!json.contains("presetName")) {
|
||||||
spdlog::error(fmt::format("Attempted to load file {} as a preset, but was not a preset file.", preset.path().filename().string()));
|
spdlog::error(fmt::format("Attempted to load file {} as a preset, but was not a preset file.",
|
||||||
|
preset.path().filename().string()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
presets[json["presetName"]].presetValues = json;
|
presets[json["presetName"]].presetValues = json;
|
||||||
|
@ -172,63 +175,93 @@ void SavePreset(std::string& presetName) {
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> sections = { CVAR_PREFIX_SETTING, CVAR_PREFIX_WINDOW, CVAR_PREFIX_ENHANCEMENT, CVAR_PREFIX_RANDOMIZER_ENHANCEMENT,
|
std::vector<std::string> sections = {
|
||||||
CVAR_PREFIX_AUDIO, CVAR_PREFIX_COSMETIC, CVAR_PREFIX_RANDOMIZER_SETTING, CVAR_PREFIX_TRACKER, CVAR_PREFIX_CHEAT };
|
CVAR_PREFIX_SETTING, CVAR_PREFIX_WINDOW, CVAR_PREFIX_ENHANCEMENT, CVAR_PREFIX_RANDOMIZER_ENHANCEMENT,
|
||||||
|
CVAR_PREFIX_AUDIO, CVAR_PREFIX_COSMETIC, CVAR_PREFIX_RANDOMIZER_SETTING, CVAR_PREFIX_TRACKER,
|
||||||
|
CVAR_PREFIX_CHEAT
|
||||||
|
};
|
||||||
|
|
||||||
static std::string newPresetName;
|
static std::string newPresetName;
|
||||||
static bool newPresetSettings = true, newPresetEnhancements = true, newPresetAudio = true, newPresetCosmetics = true, newPresetRando = true, newPresetTrackers = true;
|
static bool newPresetSettings = true, newPresetEnhancements = true, newPresetAudio = true, newPresetCosmetics = true,
|
||||||
|
newPresetRando = true, newPresetTrackers = true;
|
||||||
|
|
||||||
void PresetsCustomWidget(WidgetInfo& info) {
|
void PresetsCustomWidget(WidgetInfo& info) {
|
||||||
ImGui::PushFont(OTRGlobals::Instance->fontMonoLargest);
|
ImGui::PushFont(OTRGlobals::Instance->fontMonoLargest);
|
||||||
if (UIWidgets::Button("New Preset", UIWidgets::ButtonOptions().Size(UIWidgets::Sizes::Inline).Color(THEME_COLOR))) {
|
if (UIWidgets::Button("New Preset", UIWidgets::ButtonOptions().Size(UIWidgets::Sizes::Inline).Color(THEME_COLOR))) {
|
||||||
ImGui::OpenPopup("newPreset");
|
ImGui::OpenPopup("newPreset");
|
||||||
}
|
}
|
||||||
ImGui::SetNextWindowSize({400, 400});
|
ImGui::SetNextWindowSize({ 400, 400 });
|
||||||
if (ImGui::BeginPopup("newPreset", ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize |
|
if (ImGui::BeginPopup("newPreset", ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize |
|
||||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings |
|
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar |
|
||||||
ImGuiWindowFlags_NoTitleBar)) {
|
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoTitleBar)) {
|
||||||
bool nameExists = presets.contains(newPresetName);
|
bool nameExists = presets.contains(newPresetName);
|
||||||
UIWidgets::InputString("Preset Name", &newPresetName, UIWidgets::InputOptions().Color(THEME_COLOR).Size({200, 40})
|
UIWidgets::InputString("Preset Name", &newPresetName,
|
||||||
.ComponentAlignment(UIWidgets::ComponentAlignments::Right).LabelPosition(UIWidgets::LabelPositions::Near).ErrorText("Preset name already exists").HasError(nameExists));
|
UIWidgets::InputOptions()
|
||||||
|
.Color(THEME_COLOR)
|
||||||
|
.Size({ 200, 40 })
|
||||||
|
.ComponentAlignment(UIWidgets::ComponentAlignments::Right)
|
||||||
|
.LabelPosition(UIWidgets::LabelPositions::Near)
|
||||||
|
.ErrorText("Preset name already exists")
|
||||||
|
.HasError(nameExists));
|
||||||
nameExists = presets.contains(newPresetName);
|
nameExists = presets.contains(newPresetName);
|
||||||
bool noneSelected = !newPresetSettings && !newPresetEnhancements && !newPresetAudio && !newPresetCosmetics && !newPresetRando && !newPresetTrackers;
|
bool noneSelected = !newPresetSettings && !newPresetEnhancements && !newPresetAudio && !newPresetCosmetics &&
|
||||||
const char* disabledTooltip = (newPresetName.empty() ? "Preset name is empty" : (noneSelected ? "No sections selected" : "Preset name already exists"));
|
!newPresetRando && !newPresetTrackers;
|
||||||
UIWidgets::Checkbox("Save Settings", &newPresetSettings, UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({6.0f, 6.0f}));
|
const char* disabledTooltip =
|
||||||
UIWidgets::Checkbox("Save Enhancements", &newPresetEnhancements, UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({6.0f, 6.0f}));
|
(newPresetName.empty() ? "Preset name is empty"
|
||||||
UIWidgets::Checkbox("Save Audio", &newPresetAudio, UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({6.0f, 6.0f}));
|
: (noneSelected ? "No sections selected" : "Preset name already exists"));
|
||||||
UIWidgets::Checkbox("Save Cosmetics", &newPresetCosmetics, UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({6.0f, 6.0f}));
|
UIWidgets::Checkbox("Save Settings", &newPresetSettings,
|
||||||
UIWidgets::Checkbox("Save Rando Settings", &newPresetRando, UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({6.0f, 6.0f}));
|
UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({ 6.0f, 6.0f }));
|
||||||
UIWidgets::Checkbox("Save Trackers", &newPresetTrackers, UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({6.0f, 6.0f}));
|
UIWidgets::Checkbox("Save Enhancements", &newPresetEnhancements,
|
||||||
if (UIWidgets::Button("Save", UIWidgets::ButtonOptions({.disabled = nameExists || noneSelected || newPresetName.empty(), .disabledTooltip = disabledTooltip})
|
UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({ 6.0f, 6.0f }));
|
||||||
.Padding({6.0f, 6.0f}).Color(THEME_COLOR))) {
|
UIWidgets::Checkbox("Save Audio", &newPresetAudio,
|
||||||
|
UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({ 6.0f, 6.0f }));
|
||||||
|
UIWidgets::Checkbox("Save Cosmetics", &newPresetCosmetics,
|
||||||
|
UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({ 6.0f, 6.0f }));
|
||||||
|
UIWidgets::Checkbox("Save Rando Settings", &newPresetRando,
|
||||||
|
UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({ 6.0f, 6.0f }));
|
||||||
|
UIWidgets::Checkbox("Save Trackers", &newPresetTrackers,
|
||||||
|
UIWidgets::CheckboxOptions().Color(THEME_COLOR).Padding({ 6.0f, 6.0f }));
|
||||||
|
if (UIWidgets::Button(
|
||||||
|
"Save", UIWidgets::ButtonOptions({ .disabled = nameExists || noneSelected || newPresetName.empty(),
|
||||||
|
.disabledTooltip = disabledTooltip })
|
||||||
|
.Padding({ 6.0f, 6.0f })
|
||||||
|
.Color(THEME_COLOR))) {
|
||||||
presets[newPresetName] = {};
|
presets[newPresetName] = {};
|
||||||
auto config = Ship::Context::GetInstance()->GetConfig()->GetNestedJson();
|
auto config = Ship::Context::GetInstance()->GetConfig()->GetNestedJson();
|
||||||
if (newPresetSettings) {
|
if (newPresetSettings) {
|
||||||
presets[newPresetName].presetValues["blocks"]["settings"][CVAR_PREFIX_SETTING] = config["CVars"][CVAR_PREFIX_SETTING];
|
presets[newPresetName].presetValues["blocks"]["settings"][CVAR_PREFIX_SETTING] =
|
||||||
presets[newPresetName].presetValues["blocks"]["windows"][CVAR_PREFIX_WINDOW] = config["CVars"][CVAR_PREFIX_WINDOW];
|
config["CVars"][CVAR_PREFIX_SETTING];
|
||||||
|
presets[newPresetName].presetValues["blocks"]["windows"][CVAR_PREFIX_WINDOW] =
|
||||||
|
config["CVars"][CVAR_PREFIX_WINDOW];
|
||||||
}
|
}
|
||||||
if (newPresetEnhancements) {
|
if (newPresetEnhancements) {
|
||||||
presets[newPresetName].presetValues["blocks"]["enhancements"][CVAR_PREFIX_ENHANCEMENT] = config["CVars"][CVAR_PREFIX_ENHANCEMENT];
|
presets[newPresetName].presetValues["blocks"]["enhancements"][CVAR_PREFIX_ENHANCEMENT] =
|
||||||
presets[newPresetName].presetValues["blocks"]["randoEnhancements"][CVAR_PREFIX_RANDOMIZER_ENHANCEMENT] = config["CVars"][CVAR_PREFIX_RANDOMIZER_ENHANCEMENT];
|
config["CVars"][CVAR_PREFIX_ENHANCEMENT];
|
||||||
|
presets[newPresetName].presetValues["blocks"]["randoEnhancements"][CVAR_PREFIX_RANDOMIZER_ENHANCEMENT] =
|
||||||
|
config["CVars"][CVAR_PREFIX_RANDOMIZER_ENHANCEMENT];
|
||||||
}
|
}
|
||||||
if (newPresetAudio) {
|
if (newPresetAudio) {
|
||||||
presets[newPresetName].presetValues["blocks"]["audio"][CVAR_PREFIX_AUDIO] = config["CVars"][CVAR_PREFIX_AUDIO];
|
presets[newPresetName].presetValues["blocks"]["audio"][CVAR_PREFIX_AUDIO] =
|
||||||
|
config["CVars"][CVAR_PREFIX_AUDIO];
|
||||||
}
|
}
|
||||||
if (newPresetCosmetics) {
|
if (newPresetCosmetics) {
|
||||||
presets[newPresetName].presetValues["blocks"]["cosmetics"][CVAR_PREFIX_COSMETIC] = config["CVars"][CVAR_PREFIX_COSMETIC];
|
presets[newPresetName].presetValues["blocks"]["cosmetics"][CVAR_PREFIX_COSMETIC] =
|
||||||
|
config["CVars"][CVAR_PREFIX_COSMETIC];
|
||||||
}
|
}
|
||||||
if (newPresetRando) {
|
if (newPresetRando) {
|
||||||
presets[newPresetName].presetValues["blocks"]["rando"][CVAR_PREFIX_RANDOMIZER_SETTING] = config["CVars"][CVAR_PREFIX_RANDOMIZER_SETTING];
|
presets[newPresetName].presetValues["blocks"]["rando"][CVAR_PREFIX_RANDOMIZER_SETTING] =
|
||||||
|
config["CVars"][CVAR_PREFIX_RANDOMIZER_SETTING];
|
||||||
}
|
}
|
||||||
if (newPresetTrackers) {
|
if (newPresetTrackers) {
|
||||||
presets[newPresetName].presetValues["blocks"]["trackers"][CVAR_PREFIX_TRACKER] = config["CVars"][CVAR_PREFIX_TRACKER];
|
presets[newPresetName].presetValues["blocks"]["trackers"][CVAR_PREFIX_TRACKER] =
|
||||||
|
config["CVars"][CVAR_PREFIX_TRACKER];
|
||||||
}
|
}
|
||||||
presets[newPresetName].fileName = newPresetName;
|
presets[newPresetName].fileName = newPresetName;
|
||||||
SavePreset(newPresetName);
|
SavePreset(newPresetName);
|
||||||
newPresetName = "";
|
newPresetName = "";
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
if (UIWidgets::Button("Cancel", UIWidgets::ButtonOptions().Padding({6.0f, 6.0f}).Color(THEME_COLOR))) {
|
if (UIWidgets::Button("Cancel", UIWidgets::ButtonOptions().Padding({ 6.0f, 6.0f }).Color(THEME_COLOR))) {
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
@ -242,8 +275,10 @@ void PresetsCustomWidget(WidgetInfo& info) {
|
||||||
ImGui::TableSetupColumn("Cosmetics");
|
ImGui::TableSetupColumn("Cosmetics");
|
||||||
ImGui::TableSetupColumn("Randomizer");
|
ImGui::TableSetupColumn("Randomizer");
|
||||||
ImGui::TableSetupColumn("Trackers");
|
ImGui::TableSetupColumn("Trackers");
|
||||||
ImGui::TableSetupColumn("Apply", ImGuiTableColumnFlags_WidthFixed, ImGui::CalcTextSize("Apply").x + ImGui::GetStyle().FramePadding.x * 2);
|
ImGui::TableSetupColumn("Apply", ImGuiTableColumnFlags_WidthFixed,
|
||||||
ImGui::TableSetupColumn("Delete", ImGuiTableColumnFlags_WidthFixed, ImGui::CalcTextSize("Delete").x + ImGui::GetStyle().FramePadding.x * 2);
|
ImGui::CalcTextSize("Apply").x + ImGui::GetStyle().FramePadding.x * 2);
|
||||||
|
ImGui::TableSetupColumn("Delete", ImGuiTableColumnFlags_WidthFixed,
|
||||||
|
ImGui::CalcTextSize("Delete").x + ImGui::GetStyle().FramePadding.x * 2);
|
||||||
BlankButton();
|
BlankButton();
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
@ -285,24 +320,27 @@ void PresetsCustomWidget(WidgetInfo& info) {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
DrawSectionCheck(name, !info.presetValues["blocks"].contains("settings"), &info.applySettings, "settings");
|
DrawSectionCheck(name, !info.presetValues["blocks"].contains("settings"), &info.applySettings, "settings");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
DrawSectionCheck(name, !info.presetValues["blocks"].contains("enhancements"), &info.applyEnhancements, "enhancements");
|
DrawSectionCheck(name, !info.presetValues["blocks"].contains("enhancements"), &info.applyEnhancements,
|
||||||
|
"enhancements");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
DrawSectionCheck(name, !info.presetValues["blocks"].contains("audio"), &info.applyAudio, "audio");
|
DrawSectionCheck(name, !info.presetValues["blocks"].contains("audio"), &info.applyAudio, "audio");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
DrawSectionCheck(name, !info.presetValues["blocks"].contains("cosmetics"), &info.applyCosmetics, "cosmetics");
|
DrawSectionCheck(name, !info.presetValues["blocks"].contains("cosmetics"), &info.applyCosmetics,
|
||||||
|
"cosmetics");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
DrawSectionCheck(name, !info.presetValues["blocks"].contains("rando"), &info.applyRando, "rando");
|
DrawSectionCheck(name, !info.presetValues["blocks"].contains("rando"), &info.applyRando, "rando");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
DrawSectionCheck(name, !info.presetValues["blocks"].contains("trackers"), &info.applyTrackers, "trackers");
|
DrawSectionCheck(name, !info.presetValues["blocks"].contains("trackers"), &info.applyTrackers, "trackers");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
UIWidgets::PushStyleButton(THEME_COLOR);
|
UIWidgets::PushStyleButton(THEME_COLOR);
|
||||||
if (UIWidgets::Button(("Apply##" + name).c_str(), UIWidgets::ButtonOptions().Padding({6.0f, 6.0f}))) {
|
if (UIWidgets::Button(("Apply##" + name).c_str(), UIWidgets::ButtonOptions().Padding({ 6.0f, 6.0f }))) {
|
||||||
for (auto& section : info.presetValues["blocks"]) {
|
for (auto& section : info.presetValues["blocks"]) {
|
||||||
for (auto& item : section.items()) {
|
for (auto& item : section.items()) {
|
||||||
if (section[item.key()].is_null()) {
|
if (section[item.key()].is_null()) {
|
||||||
CVarClearBlock(item.key().c_str());
|
CVarClearBlock(item.key().c_str());
|
||||||
} else {
|
} else {
|
||||||
Ship::Context::GetInstance()->GetConfig()->SetBlock(fmt::format("{}.{}", "CVars", item.key()), item.value());
|
Ship::Context::GetInstance()->GetConfig()->SetBlock(
|
||||||
|
fmt::format("{}.{}", "CVars", item.key()), item.value());
|
||||||
Ship::Context::GetInstance()->GetConsoleVariables()->Load();
|
Ship::Context::GetInstance()->GetConsoleVariables()->Load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,7 +349,7 @@ void PresetsCustomWidget(WidgetInfo& info) {
|
||||||
UIWidgets::PopStyleButton();
|
UIWidgets::PopStyleButton();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
UIWidgets::PushStyleButton(THEME_COLOR);
|
UIWidgets::PushStyleButton(THEME_COLOR);
|
||||||
if (UIWidgets::Button(("Delete##" + name).c_str(), UIWidgets::ButtonOptions().Padding({6.0f, 6.0f}))) {
|
if (UIWidgets::Button(("Delete##" + name).c_str(), UIWidgets::ButtonOptions().Padding({ 6.0f, 6.0f }))) {
|
||||||
auto path = FormatPresetPath(info.fileName);
|
auto path = FormatPresetPath(info.fileName);
|
||||||
if (fs::exists(path)) {
|
if (fs::exists(path)) {
|
||||||
fs::remove(path);
|
fs::remove(path);
|
||||||
|
@ -332,11 +370,10 @@ void PresetsCustomWidget(WidgetInfo& info) {
|
||||||
void RegisterPresetsWidgets() {
|
void RegisterPresetsWidgets() {
|
||||||
SohGui::mSohMenu->AddSidebarEntry("Settings", "Presets", 1);
|
SohGui::mSohMenu->AddSidebarEntry("Settings", "Presets", 1);
|
||||||
WidgetPath path = { "Settings", "Presets", SECTION_COLUMN_1 };
|
WidgetPath path = { "Settings", "Presets", SECTION_COLUMN_1 };
|
||||||
SohGui::mSohMenu->AddWidget(path, "PresetsWidget", WIDGET_CUSTOM)
|
SohGui::mSohMenu->AddWidget(path, "PresetsWidget", WIDGET_CUSTOM).CustomFunction(PresetsCustomWidget);
|
||||||
.CustomFunction(PresetsCustomWidget);
|
|
||||||
presetFolder = Ship::Context::GetInstance()->GetPathRelativeToAppDirectory("presets");
|
presetFolder = Ship::Context::GetInstance()->GetPathRelativeToAppDirectory("presets");
|
||||||
LoadPresets();
|
LoadPresets();
|
||||||
}
|
}
|
||||||
|
|
||||||
//static RegisterMenuUpdateFunc updateFunc(UpdateResolutionVars, "Settings", "General");
|
// static RegisterMenuUpdateFunc updateFunc(UpdateResolutionVars, "Settings", "General");
|
||||||
static RegisterMenuInitFunc initFunc(RegisterPresetsWidgets);
|
static RegisterMenuInitFunc initFunc(RegisterPresetsWidgets);
|
||||||
|
|
|
@ -3651,47 +3651,48 @@ void RandomizerSettingsWindow::DrawElement() {
|
||||||
bool disableEditingRandoSettings =
|
bool disableEditingRandoSettings =
|
||||||
CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) || CVarGetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0);
|
CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) || CVarGetInteger(CVAR_GENERAL("OnFileSelectNameEntry"), 0);
|
||||||
ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0) || disableEditingRandoSettings);
|
ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0) || disableEditingRandoSettings);
|
||||||
//const PresetTypeDefinition presetTypeDef = presetTypes.at(PRESET_TYPE_RANDOMIZER);
|
// const PresetTypeDefinition presetTypeDef = presetTypes.at(PRESET_TYPE_RANDOMIZER);
|
||||||
//std::string comboboxTooltip = "";
|
// std::string comboboxTooltip = "";
|
||||||
//for (auto iter = presetTypeDef.presets.begin(); iter != presetTypeDef.presets.end(); ++iter) {
|
// for (auto iter = presetTypeDef.presets.begin(); iter != presetTypeDef.presets.end(); ++iter) {
|
||||||
// if (iter->first != 0)
|
// if (iter->first != 0)
|
||||||
// comboboxTooltip += "\n\n";
|
// comboboxTooltip += "\n\n";
|
||||||
// comboboxTooltip += std::string(iter->second.label) + " - " + std::string(iter->second.description);
|
// comboboxTooltip += std::string(iter->second.label) + " - " + std::string(iter->second.description);
|
||||||
//}
|
// }
|
||||||
//const std::string presetTypeCvar = CVAR_GENERAL("SelectedPresets.") + std::to_string(PRESET_TYPE_RANDOMIZER);
|
// const std::string presetTypeCvar = CVAR_GENERAL("SelectedPresets.") + std::to_string(PRESET_TYPE_RANDOMIZER);
|
||||||
//randomizerPresetSelected = CVarGetInteger(presetTypeCvar.c_str(), RANDOMIZER_PRESET_DEFAULT);
|
// randomizerPresetSelected = CVarGetInteger(presetTypeCvar.c_str(), RANDOMIZER_PRESET_DEFAULT);
|
||||||
|
|
||||||
//if (UIWidgets::Combobox("Randomizer Presets", &randomizerPresetSelected, randomizerPresetList,
|
// if (UIWidgets::Combobox("Randomizer Presets", &randomizerPresetSelected, randomizerPresetList,
|
||||||
// UIWidgets::ComboboxOptions()
|
// UIWidgets::ComboboxOptions()
|
||||||
// .DefaultIndex(RANDOMIZER_PRESET_DEFAULT)
|
// .DefaultIndex(RANDOMIZER_PRESET_DEFAULT)
|
||||||
// .Tooltip(comboboxTooltip.c_str())
|
// .Tooltip(comboboxTooltip.c_str())
|
||||||
// .Color(THEME_COLOR))) {
|
// .Color(THEME_COLOR))) {
|
||||||
// CVarSetInteger(presetTypeCvar.c_str(), randomizerPresetSelected);
|
// CVarSetInteger(presetTypeCvar.c_str(), randomizerPresetSelected);
|
||||||
//}
|
// }
|
||||||
//ImGui::SameLine();
|
// ImGui::SameLine();
|
||||||
//ImGui::SetCursorPosY(ImGui::GetCursorPos().y + 35.f);
|
// ImGui::SetCursorPosY(ImGui::GetCursorPos().y + 35.f);
|
||||||
//if (UIWidgets::Button(
|
// if (UIWidgets::Button(
|
||||||
// "Apply Preset##Randomizer",
|
// "Apply Preset##Randomizer",
|
||||||
// UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(UIWidgets::Sizes::Inline).Padding(ImVec2(10.f, 6.f)))) {
|
// UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(UIWidgets::Sizes::Inline).Padding(ImVec2(10.f, 6.f))))
|
||||||
// if (randomizerPresetSelected >= presetTypeDef.presets.size()) {
|
// {
|
||||||
// randomizerPresetSelected = 0;
|
// if (randomizerPresetSelected >= presetTypeDef.presets.size()) {
|
||||||
// }
|
// randomizerPresetSelected = 0;
|
||||||
// const PresetDefinition selectedPresetDef = presetTypeDef.presets.at(randomizerPresetSelected);
|
// }
|
||||||
// for (const char* block : presetTypeDef.blocksToClear) {
|
// const PresetDefinition selectedPresetDef = presetTypeDef.presets.at(randomizerPresetSelected);
|
||||||
// CVarClearBlock(block);
|
// for (const char* block : presetTypeDef.blocksToClear) {
|
||||||
// }
|
// CVarClearBlock(block);
|
||||||
// if (randomizerPresetSelected != 0) {
|
// }
|
||||||
// applyPreset(selectedPresetDef.entries);
|
// if (randomizerPresetSelected != 0) {
|
||||||
// }
|
// applyPreset(selectedPresetDef.entries);
|
||||||
// CVarSetInteger(presetTypeCvar.c_str(), randomizerPresetSelected);
|
// }
|
||||||
// Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
// CVarSetInteger(presetTypeCvar.c_str(), randomizerPresetSelected);
|
||||||
// mSettings->UpdateOptionProperties();
|
// Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||||
// // force excluded location list and trick list update if tab is open.
|
// mSettings->UpdateOptionProperties();
|
||||||
// locationsTabOpen = false;
|
// // force excluded location list and trick list update if tab is open.
|
||||||
// tricksTabOpen = false;
|
// locationsTabOpen = false;
|
||||||
//}
|
// tricksTabOpen = false;
|
||||||
|
// }
|
||||||
|
|
||||||
//UIWidgets::Spacer(0);
|
// UIWidgets::Spacer(0);
|
||||||
UIWidgets::CVarCheckbox("Manual seed entry", CVAR_RANDOMIZER_SETTING("ManualSeedEntry"),
|
UIWidgets::CVarCheckbox("Manual seed entry", CVAR_RANDOMIZER_SETTING("ManualSeedEntry"),
|
||||||
UIWidgets::CheckboxOptions().Color(THEME_COLOR));
|
UIWidgets::CheckboxOptions().Color(THEME_COLOR));
|
||||||
if (CVarGetInteger(CVAR_RANDOMIZER_SETTING("ManualSeedEntry"), 0)) {
|
if (CVarGetInteger(CVAR_RANDOMIZER_SETTING("ManualSeedEntry"), 0)) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ void SohMenu::AddMenuEnhancements() {
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
// Quality of Life
|
// Quality of Life
|
||||||
//path.sidebarName = "Quality of Life";
|
// path.sidebarName = "Quality of Life";
|
||||||
WidgetPath path = { "Enhancements", "Quality of Life", SECTION_COLUMN_1 };
|
WidgetPath path = { "Enhancements", "Quality of Life", SECTION_COLUMN_1 };
|
||||||
AddSidebarEntry("Enhancements", path.sidebarName, 3);
|
AddSidebarEntry("Enhancements", path.sidebarName, 3);
|
||||||
path.column = SECTION_COLUMN_1;
|
path.column = SECTION_COLUMN_1;
|
||||||
|
|
|
@ -809,11 +809,11 @@ bool InputString(const char* label, std::string* value, const InputOptions& opti
|
||||||
PopStyleInput();
|
PopStyleInput();
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
if (options.hasError&& ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) &&
|
if (options.hasError && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) &&
|
||||||
!Ship_IsCStringEmpty(options.errorText)) {
|
!Ship_IsCStringEmpty(options.errorText)) {
|
||||||
ImGui::SetTooltip("%s", WrappedText(options.errorText).c_str());
|
ImGui::SetTooltip("%s", WrappedText(options.errorText).c_str());
|
||||||
} else if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) &&
|
} else if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) &&
|
||||||
!Ship_IsCStringEmpty(options.disabledTooltip)) {
|
!Ship_IsCStringEmpty(options.disabledTooltip)) {
|
||||||
ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip).c_str());
|
ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip).c_str());
|
||||||
} else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && !Ship_IsCStringEmpty(options.tooltip)) {
|
} else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && !Ship_IsCStringEmpty(options.tooltip)) {
|
||||||
ImGui::SetTooltip("%s", WrappedText(options.tooltip).c_str());
|
ImGui::SetTooltip("%s", WrappedText(options.tooltip).c_str());
|
||||||
|
@ -972,7 +972,8 @@ bool CVarColorPicker(const char* label, const char* cvarName, Color_RGBA8 defaul
|
||||||
UIWidgets::CheckboxOptions({ { .tooltip = "Prevents this color from being changed" } }).Color(themeColor));
|
UIWidgets::CheckboxOptions({ { .tooltip = "Prevents this color from being changed" } }).Color(themeColor));
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
if (color.r == defaultColor.r && color.g == defaultColor.g && color.b == defaultColor.b && color.a == defaultColor.a) {
|
if (color.r == defaultColor.r && color.g == defaultColor.g && color.b == defaultColor.b &&
|
||||||
|
color.a == defaultColor.a) {
|
||||||
CVarClear(valueCVar.c_str());
|
CVarClear(valueCVar.c_str());
|
||||||
} else {
|
} else {
|
||||||
color.r = (uint8_t)(colorVec.x * 255.0f);
|
color.r = (uint8_t)(colorVec.x * 255.0f);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue