mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 21:33:40 -07:00
Fix tricks menu (#4278)
* Fix tricks not getting disabled by button click. * Fix area trees not collapsing on enabled side of tricks list. * Fix difficulty tag button order for Linux. * Fix Collapse All, Open All, and Disable All. Prevent Disable All from disabling all despite areas being collapsed.
This commit is contained in:
parent
9ceb5579b8
commit
bfba2a180a
3 changed files with 26 additions and 36 deletions
|
@ -2169,7 +2169,7 @@ void RandomizerSettingsWindow::DrawElement() {
|
||||||
{RA_GANONS_CASTLE, true}
|
{RA_GANONS_CASTLE, true}
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unordered_map<Rando::Tricks::Tag, bool> showTag {
|
static std::map<Rando::Tricks::Tag, bool> showTag {
|
||||||
{Rando::Tricks::Tag::NOVICE,true},
|
{Rando::Tricks::Tag::NOVICE,true},
|
||||||
{Rando::Tricks::Tag::INTERMEDIATE,true},
|
{Rando::Tricks::Tag::INTERMEDIATE,true},
|
||||||
{Rando::Tricks::Tag::ADVANCED,true},
|
{Rando::Tricks::Tag::ADVANCED,true},
|
||||||
|
@ -2236,22 +2236,14 @@ void RandomizerSettingsWindow::DrawElement() {
|
||||||
window->DC.CurrLineTextBaseOffset = 0.0f;
|
window->DC.CurrLineTextBaseOffset = 0.0f;
|
||||||
|
|
||||||
if (ImGui::Button("Collapse All##disabled")) {
|
if (ImGui::Button("Collapse All##disabled")) {
|
||||||
for (int i = 0; i < RT_MAX; i++) {
|
for (int i = 0; i < RA_MAX; i++) {
|
||||||
auto option = mSettings->GetTrickOption(static_cast<RandomizerTrick>(i));
|
areaTreeDisabled[static_cast<RandomizerArea>(i)] = false;
|
||||||
if (!option.IsHidden() && !enabledTricks.count(static_cast<RandomizerTrick>(i)) &&
|
|
||||||
!option.IsGlitch()) {
|
|
||||||
areaTreeDisabled[option.GetArea()] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Open All##disabled")) {
|
if (ImGui::Button("Open All##disabled")) {
|
||||||
for (int i = 0; i < RT_MAX; i++) {
|
for (int i = 0; i < RA_MAX; i++) {
|
||||||
auto option = mSettings->GetTrickOption(static_cast<RandomizerTrick>(i));
|
areaTreeDisabled[static_cast<RandomizerArea>(i)] = true;
|
||||||
if (option.IsHidden() && !enabledTricks.count(static_cast<RandomizerTrick>(i)) &&
|
|
||||||
!option.IsGlitch()) {
|
|
||||||
areaTreeDisabled[option.GetArea()] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
@ -2288,15 +2280,15 @@ void RandomizerSettingsWindow::DrawElement() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasTricks) {
|
if (hasTricks) {
|
||||||
ImGui::TreeNodeSetOpen(ImGui::GetID(Rando::Tricks::GetRTAreaName(area).c_str()), areaTreeDisabled[area]);
|
ImGui::TreeNodeSetOpen(ImGui::GetID((Rando::Tricks::GetRTAreaName(area) + "##disabled").c_str()), areaTreeDisabled[area]);
|
||||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||||
if (ImGui::TreeNode(Rando::Tricks::GetRTAreaName(area).c_str())) {
|
if (ImGui::TreeNode((Rando::Tricks::GetRTAreaName(area) + "##disabled").c_str())) {
|
||||||
for (auto rt : trickIds) {
|
for (auto rt : trickIds) {
|
||||||
auto option = mSettings->GetTrickOption(rt);
|
auto option = mSettings->GetTrickOption(rt);
|
||||||
if (!option.IsHidden() && trickSearch.PassFilter(option.GetName().c_str()) &&
|
if (!option.IsHidden() && trickSearch.PassFilter(option.GetName().c_str()) &&
|
||||||
!enabledTricks.count(rt) && Rando::Tricks::CheckRTTags(showTag, option.GetTags()) &&
|
!enabledTricks.count(rt) && Rando::Tricks::CheckRTTags(showTag, option.GetTags()) &&
|
||||||
!option.IsGlitch()) {
|
!option.IsGlitch()) {
|
||||||
ImGui::TreeNodeSetOpen(ImGui::GetID(Rando::Tricks::GetRTAreaName(option.GetArea()).c_str()), areaTreeDisabled[option.GetArea()]);
|
ImGui::TreeNodeSetOpen(ImGui::GetID((Rando::Tricks::GetRTAreaName(option.GetArea()) + "##disabled").c_str()), areaTreeDisabled[option.GetArea()]);
|
||||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||||
if (ImGui::ArrowButton(std::to_string(rt).c_str(), ImGuiDir_Right)) {
|
if (ImGui::ArrowButton(std::to_string(rt).c_str(), ImGuiDir_Right)) {
|
||||||
enabledTricks.insert(rt);
|
enabledTricks.insert(rt);
|
||||||
|
@ -2329,23 +2321,16 @@ void RandomizerSettingsWindow::DrawElement() {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
window->DC.CurrLineTextBaseOffset = 0.0f;
|
window->DC.CurrLineTextBaseOffset = 0.0f;
|
||||||
|
|
||||||
|
|
||||||
if (ImGui::Button("Collapse All##enabled")) {
|
if (ImGui::Button("Collapse All##enabled")) {
|
||||||
for (int i = 0; i < RT_MAX; i++) {
|
for (int i = 0; i < RA_MAX; i++) {
|
||||||
auto option = mSettings->GetTrickOption(static_cast<RandomizerTrick>(i));
|
areaTreeEnabled[static_cast<RandomizerArea>(i)] = false;
|
||||||
if (!option.IsHidden() && enabledTricks.count(static_cast<RandomizerTrick>(i)) &&
|
|
||||||
!option.IsGlitch()) {
|
|
||||||
areaTreeDisabled[option.GetArea()] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Open All##enabled")) {
|
if (ImGui::Button("Open All##enabled")) {
|
||||||
for (int i = 0; i < RT_MAX; i++) {
|
for (int i = 0; i < RA_MAX; i++) {
|
||||||
auto option = mSettings->GetTrickOption(static_cast<RandomizerTrick>(i));
|
areaTreeEnabled[static_cast<RandomizerArea>(i)] = true;
|
||||||
if (option.IsHidden() && enabledTricks.count(static_cast<RandomizerTrick>(i)) &&
|
|
||||||
!option.IsGlitch()) {
|
|
||||||
areaTreeDisabled[option.GetArea()] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
@ -2356,7 +2341,7 @@ void RandomizerSettingsWindow::DrawElement() {
|
||||||
trickSearch.PassFilter(option.GetName().c_str()) &&
|
trickSearch.PassFilter(option.GetName().c_str()) &&
|
||||||
areaTreeEnabled[option.GetArea()] &&
|
areaTreeEnabled[option.GetArea()] &&
|
||||||
Rando::Tricks::CheckRTTags(showTag, option.GetTags())) {
|
Rando::Tricks::CheckRTTags(showTag, option.GetTags())) {
|
||||||
enabledTricks.insert(static_cast<RandomizerTrick>(i));
|
enabledTricks.erase(static_cast<RandomizerTrick>(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string enabledTrickString = "";
|
std::string enabledTrickString = "";
|
||||||
|
@ -2364,7 +2349,11 @@ void RandomizerSettingsWindow::DrawElement() {
|
||||||
enabledTrickString += std::to_string(enabledTrickIt);
|
enabledTrickString += std::to_string(enabledTrickIt);
|
||||||
enabledTrickString += ",";
|
enabledTrickString += ",";
|
||||||
}
|
}
|
||||||
CVarClear(CVAR_RANDOMIZER_SETTING("EnabledTricks"));
|
if (enabledTricks.size() == 0) {
|
||||||
|
CVarClear(CVAR_RANDOMIZER_SETTING("EnabledTricks"));
|
||||||
|
} else {
|
||||||
|
CVarSetString(CVAR_RANDOMIZER_SETTING("EnabledTricks"), enabledTrickString.c_str());
|
||||||
|
}
|
||||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
|
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2382,18 +2371,18 @@ void RandomizerSettingsWindow::DrawElement() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasTricks) {
|
if (hasTricks) {
|
||||||
ImGui::TreeNodeSetOpen(ImGui::GetID(Rando::Tricks::GetRTAreaName(area).c_str()), areaTreeDisabled[area]);
|
ImGui::TreeNodeSetOpen(ImGui::GetID((Rando::Tricks::GetRTAreaName(area) + "##enabled").c_str()), areaTreeEnabled[area]);
|
||||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||||
if (ImGui::TreeNode(Rando::Tricks::GetRTAreaName(area).c_str())) {
|
if (ImGui::TreeNode((Rando::Tricks::GetRTAreaName(area) + "##enabled").c_str())) {
|
||||||
for (auto rt : trickIds) {
|
for (auto rt : trickIds) {
|
||||||
auto option = mSettings->GetTrickOption(rt);
|
auto option = mSettings->GetTrickOption(rt);
|
||||||
if (!option.IsHidden() && trickSearch.PassFilter(option.GetName().c_str()) &&
|
if (!option.IsHidden() && trickSearch.PassFilter(option.GetName().c_str()) &&
|
||||||
enabledTricks.count(rt) && Rando::Tricks::CheckRTTags(showTag, option.GetTags()) &&
|
enabledTricks.count(rt) && Rando::Tricks::CheckRTTags(showTag, option.GetTags()) &&
|
||||||
!option.IsGlitch()) {
|
!option.IsGlitch()) {
|
||||||
ImGui::TreeNodeSetOpen(ImGui::GetID(Rando::Tricks::GetRTAreaName(option.GetArea()).c_str()), areaTreeDisabled[option.GetArea()]);
|
ImGui::TreeNodeSetOpen(ImGui::GetID((Rando::Tricks::GetRTAreaName(option.GetArea()) + "##enabled").c_str()), areaTreeEnabled[option.GetArea()]);
|
||||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||||
if (ImGui::ArrowButton(std::to_string(rt).c_str(), ImGuiDir_Left)) {
|
if (ImGui::ArrowButton(std::to_string(rt).c_str(), ImGuiDir_Left)) {
|
||||||
enabledTricks.insert(rt);
|
enabledTricks.erase(rt);
|
||||||
std::string enabledTrickString = "";
|
std::string enabledTrickString = "";
|
||||||
for (auto enabledTrickIt : enabledTricks) {
|
for (auto enabledTrickIt : enabledTricks) {
|
||||||
enabledTrickString += std::to_string(enabledTrickIt);
|
enabledTrickString += std::to_string(enabledTrickIt);
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace Rando {
|
||||||
return rtAreaNames.at(area);
|
return rtAreaNames.at(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tricks::CheckRTTags(const std::unordered_map<Tag, bool> &showTag, const std::set<Tag> &rtTags) {
|
bool Tricks::CheckRTTags(const std::map<Tag, bool> &showTag, const std::set<Tag> &rtTags) {
|
||||||
if (rtTags.empty()) {
|
if (rtTags.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "randomizerTypes.h"
|
#include "randomizerTypes.h"
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ namespace Rando {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::string& GetRTAreaName(RandomizerArea area);
|
static const std::string& GetRTAreaName(RandomizerArea area);
|
||||||
static bool CheckRTTags(const std::unordered_map<Tag, bool> &showTag, const std::set<Tag> &rtTags);
|
static bool CheckRTTags(const std::map<Tag, bool> &showTag, const std::set<Tag> &rtTags);
|
||||||
static std::string GetRTTagName(Tag tag);
|
static std::string GetRTTagName(Tag tag);
|
||||||
static ImVec4 GetRTTagColor(Tag tag);
|
static ImVec4 GetRTTagColor(Tag tag);
|
||||||
static void DrawTagChips(const std::set<Tag> &rtTags);
|
static void DrawTagChips(const std::set<Tag> &rtTags);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue