Rando settings streamline and auto render (#3391)

* Removes cvarSettings map.

Options now link with CVar names directly. So instead of passing the
cvarSettings map, the Option class can check a corresponding CVar
if a cvarName was provided during construction. Of note, it does not
automatically sync the Option selected index with the CVar value, as
we would not want this to happen in all cases, for example when dragging
a spoiler file, we don't want to overwrite all the CVars with the Options
from the spoiler file. Currently all Options are set to the value of the CVar
they are linked to right before generating a new seed, unless a spoiler file
has been dropped in which case those settings are used instead.

* Early version of ImGui Render function

Currently only the slider variant. Will allow for auto rendering of options
in ImGui, with tooltips and automatic display of the values in each Option's
options array while keeping the CVars at the selected index, preventing
Off By One Errors.

* Implementation of Checkbox and Combobox rendering.

Currently only in use for a couple of items, future commit will implement for all
options.

* Auto-render entire first tab of Randomizer Settings

* Switch remaining tabs to auto-render

* Implements disabling options

* Cleanup/Documentation

* Auto-render entire table columns

* Implement OptionGroup rendering for "Sections"

* Automates the rendering of tables in the Settings window.

With the exception of the Locations and Tricks tabs, those are special
and will need a lot more work.

* Adds ability for option groups to have descriptions,

These descriptions will automatically display as tooltips in ImGui,
if the widget container type accounts for it.

* Fix as many IDE warnings as possible in option.h/cpp

Trying out CLion Nova, and it highlighted some things I decided to fix, some from CLion itself and some from CLang-Tidy. Oddly, it didn't like a conversion from size_t to int whether I left it implicit or added a static_cast, so I guess that warning is staying.

* Fixes some simple bugs

* fix another small oopsie

* Fixes parsing some of the option changes

Specifically we went from storing the actual value in the CVar to storing an index, meaning sliders that started with 1 now have the index offset by 1. This is currently only Big Poe Count, Triforce Hunt total/required, and starting hearts. Everything else either already started at 0, or in the case of LACS/Bridge counts, we were starting the sliders at 1 but they would have always worked at 0 according to the 3drando logic.

* Fix bug with status of skip child stealth

* Renames the Settings::Setting function to GetOption

* Add `Settings` pointer as a member of `RandomizerSettingsWindow`.

* Replaces ctx->GetOption with direct access to mOptions

This is equivalent, the access through ctx in this case was completely unnecessary and a muscle-memory mistake on my part.

* Implements a few IDE/Linter suggestions
This commit is contained in:
Christopher Leggett 2023-12-10 11:20:47 -05:00 committed by GitHub
commit dad4ae0095
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 2277 additions and 2017 deletions

View file

@ -14,6 +14,7 @@
namespace Rando {
std::weak_ptr<Context> Context::mContext;
Context::Context() {
for (auto& location : StaticData::GetLocationTable()) {
mSpoilerfileCheckNameToEnum[location.GetName()] = location.GetRandomizerCheck();
@ -135,7 +136,7 @@ void Context::PlaceItemInLocation(const RandomizerCheck locKey, const Randomizer
SPDLOG_DEBUG(StaticData::GetLocation(locKey)->GetName());
SPDLOG_DEBUG("\n\n");
if (applyEffectImmediately || mSettings->Setting(RSK_LOGIC_RULES).Is(RO_LOGIC_GLITCHLESS) || mSettings->Setting(RSK_LOGIC_RULES).Is(RO_LOGIC_VANILLA)) {
if (applyEffectImmediately || mSettings->GetOption(RSK_LOGIC_RULES).Is(RO_LOGIC_GLITCHLESS) || mSettings->GetOption(RSK_LOGIC_RULES).Is(RO_LOGIC_VANILLA)) {
StaticData::RetrieveItem(item).ApplyEffect();
}
@ -175,7 +176,7 @@ void Context::AddLocations(const Container& locations, std::vector<RandomizerChe
void Context::GenerateLocationPool() {
allLocations.clear();
AddLocation(RC_LINKS_POCKET);
if (mSettings->Setting(RSK_TRIFORCE_HUNT)) {
if (mSettings->GetOption(RSK_TRIFORCE_HUNT)) {
AddLocation(RC_TRIFORCE_COMPLETED);
}
AddLocations(StaticData::overworldLocations);
@ -584,7 +585,7 @@ Sprite* Context::GetSeedTexture(const uint8_t index) {
}
Option& Context::GetOption(const RandomizerSettingKey key) const {
return mSettings->Setting(key);
return mSettings->GetOption(key);
}
Option& Context::GetTrickOption(const RandomizerTrick key) const {