diff --git a/soh/soh/Enhancements/randomizer/option.cpp b/soh/soh/Enhancements/randomizer/option.cpp index aa9eec445c..5127209816 100644 --- a/soh/soh/Enhancements/randomizer/option.cpp +++ b/soh/soh/Enhancements/randomizer/option.cpp @@ -102,14 +102,6 @@ const std::string& Option::GetCVarName() const { return cvarName; } -void Option::SetDelayedOption() { - delayedSelection = contextSelection; -} - -void Option::RestoreDelayedOption() { - contextSelection = delayedSelection; -} - void Option::SetContextIndex(uint8_t idx) { // TODO: Set to Context's OptionValue array. contextSelection = idx; @@ -152,18 +144,10 @@ bool Option::IsCategory(const OptionCategory category) const { return category == this->category; } -bool Option::HasFlag(const int imFlag_) const { - return imFlag_ & imFlags; -} - void Option::AddFlag(const int imFlag_) { imFlags |= imFlag_; } -void Option::SetFlag(const int imFlag_) { - imFlags = imFlag_; -} - void Option::RemoveFlag(const int imFlag_) { imFlags &= ~imFlag_; } @@ -178,15 +162,6 @@ uint8_t Option::GetValueFromText(const std::string text) { return defaultOption; } -void Option::SetContextIndexFromText(const std::string text) { - if (optionsTextToVar.contains(text)) { - SetContextIndex(optionsTextToVar[text]); - } else { - SPDLOG_ERROR("Option {} does not have a var named {}.", name, text); - assert(false); - } -} - Option::Option(size_t key_, std::string name_, std::vector options_, OptionCategory category_, std::string cvarName_, std::string description_, WidgetType widgetType_, uint8_t defaultOption_, bool defaultHidden_, WidgetFunc callback_, int imFlags_) @@ -238,77 +213,6 @@ Option::Option(size_t key_, std::string name_, std::vector options_ PopulateTextToNum(); } -bool Option::RenderCheckbox() { - bool changed = false; - bool val = static_cast(CVarGetInteger(cvarName.c_str(), defaultOption)); - UIWidgets::CheckboxOptions widgetOptions = static_cast( - UIWidgets::CheckboxOptions().Color(THEME_COLOR).Tooltip(description.c_str())); - widgetOptions.disabled = disabled; - if (UIWidgets::Checkbox(name.c_str(), &val, widgetOptions)) { - CVarSetInteger(cvarName.c_str(), val); - changed = true; - Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); - } - return changed; -} - -bool Option::RenderCombobox() { - bool changed = false; - uint8_t selected = CVarGetInteger(cvarName.c_str(), defaultOption); - if (selected >= static_cast(options.size())) { - selected = static_cast(options.size()); - CVarSetInteger(cvarName.c_str(), selected); - changed = true; - Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); - } - UIWidgets::ComboboxOptions widgetOptions = - UIWidgets::ComboboxOptions().Color(THEME_COLOR).Tooltip(description.c_str()); - if (this->GetKey() == RSK_LOGIC_RULES) { - widgetOptions = widgetOptions.LabelPosition(UIWidgets::LabelPositions::None) - .ComponentAlignment(UIWidgets::ComponentAlignments::Right); - } - widgetOptions.disabled = disabled; - if (UIWidgets::Combobox(name.c_str(), &selected, options, widgetOptions)) { - CVarSetInteger(cvarName.c_str(), static_cast(selected)); - changed = true; - Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); - } - return changed; -} - -bool Option::RenderSlider() { - bool changed = false; - int val = CVarGetInteger(cvarName.c_str(), defaultOption); - if (val > options.size() - 1) { - val = static_cast(options.size()) - 1; - changed = true; - } - UIWidgets::IntSliderOptions widgetOptions = UIWidgets::IntSliderOptions() - .Color(THEME_COLOR) - .Min(0) - .Max(static_cast(options.size() - 1)) - .Tooltip(description.c_str()) - .Format(options[val].c_str()) - .DefaultValue(defaultOption); - widgetOptions.disabled = disabled; - if (UIWidgets::SliderInt(name.c_str(), &val, widgetOptions)) { - changed = true; - } - if (val < 0) { - val = 0; - changed = true; - } - if (val > options.size() - 1) { - val = static_cast(options.size() - 1); - changed = true; - } - if (changed) { - CVarSetInteger(cvarName.c_str(), val); - Ship::Context::GetRawInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); - } - return changed; -} - void Option::AddWidget(WidgetPath& path) { auto widget = SohGui::mSohMenu->AddWidget(path, name, widgetType) .Callback(callback) diff --git a/soh/soh/Enhancements/randomizer/option.h b/soh/soh/Enhancements/randomizer/option.h index 6f32418b24..a915821d47 100644 --- a/soh/soh/Enhancements/randomizer/option.h +++ b/soh/soh/Enhancements/randomizer/option.h @@ -225,16 +225,6 @@ class Option { */ uint8_t GetOptionIndex() const; - /** - * @brief Set the delayedOption to the currently selected index so it can be restored later. - */ - void SetDelayedOption(); - - /** - * @brief Restores the delayedOption back to the selected index. - */ - void RestoreDelayedOption(); - /** * @brief Set the rando context index for this Option. * @@ -296,13 +286,10 @@ class Option { void AddWidget(WidgetPath& path); - bool HasFlag(int imFlag_) const; void AddFlag(int imFlag_); - void SetFlag(int imFlag_); void RemoveFlag(int imFlag_); uint8_t GetValueFromText(std::string text); - void SetContextIndexFromText(std::string text); void SetCallback(WidgetFunc callback); void RunCallback(); @@ -314,14 +301,10 @@ class Option { size_t key; private: - bool RenderCheckbox(); - bool RenderCombobox(); - bool RenderSlider(); void PopulateTextToNum(); std::string name; std::vector options; uint8_t contextSelection = 0; - uint8_t delayedSelection = 0; bool hidden = false; OptionCategory category = OptionCategory::Setting; std::string cvarName;