diff --git a/Common/Cpp/Options/GroupOption.cpp b/Common/Cpp/Options/GroupOption.cpp index bb66e5010..e7de1b930 100644 --- a/Common/Cpp/Options/GroupOption.cpp +++ b/Common/Cpp/Options/GroupOption.cpp @@ -20,19 +20,19 @@ namespace PokemonAutomation{ struct GroupOption::Data{ const std::string m_label; - const bool m_toggleable; - const bool m_default_enabled; + const EnableMode m_enable_mode; + const bool m_show_restore_defaults_button; + std::atomic m_enabled; Data( std::string label, - bool toggleable, - bool enabled + EnableMode enable_mode, + bool show_restore_defaults_button ) : m_label(std::move(label)) - , m_toggleable(toggleable) - , m_default_enabled(enabled) - , m_enabled(enabled) + , m_enable_mode(enable_mode) + , m_show_restore_defaults_button(show_restore_defaults_button) {} }; @@ -41,18 +41,18 @@ GroupOption::~GroupOption() = default; GroupOption::GroupOption( std::string label, LockMode lock_while_program_is_running, - bool toggleable, - bool enabled + EnableMode enable_mode, + bool show_restore_defaults_button ) : BatchOption(lock_while_program_is_running) - , m_data(CONSTRUCT_TOKEN, std::move(label), toggleable, enabled) + , m_data(CONSTRUCT_TOKEN, std::move(label), enable_mode, show_restore_defaults_button) {} const std::string GroupOption::label() const{ return m_data->m_label; } bool GroupOption::toggleable() const{ - return m_data->m_toggleable; + return m_data->m_enable_mode != EnableMode::ALWAYS_ENABLED; } bool GroupOption::enabled() const{ return m_data->m_enabled.load(std::memory_order_relaxed); @@ -63,13 +63,17 @@ void GroupOption::set_enabled(bool enabled){ on_set_enabled(enabled); } } +bool GroupOption::restore_defaults_button_enabled() const{ + return m_data->m_show_restore_defaults_button; +} + void GroupOption::load_json(const JsonValue& json){ BatchOption::load_json(json); const JsonObject* obj = json.to_object(); if (obj == nullptr){ return; } - if (m_data->m_toggleable){ + if (toggleable()){ bool enabled; if (obj->read_boolean(enabled, "Enabled")){ if (enabled != m_data->m_enabled.exchange(enabled, std::memory_order_relaxed)){ @@ -81,17 +85,19 @@ void GroupOption::load_json(const JsonValue& json){ } JsonValue GroupOption::to_json() const{ JsonObject obj = std::move(*BatchOption::to_json().to_object()); - if (m_data->m_toggleable){ + if (toggleable()){ obj["Enabled"] = m_data->m_enabled.load(std::memory_order_relaxed); } return obj; } void GroupOption::restore_defaults(){ BatchOption::restore_defaults(); - bool default_value = m_data->m_default_enabled; - if (default_value != m_data->m_enabled.exchange(default_value, std::memory_order_relaxed)){ - report_value_changed(this); - on_set_enabled(default_value); + if (toggleable()){ + bool default_value = m_data->m_enable_mode == EnableMode::DEFAULT_ENABLED; + if (default_value != m_data->m_enabled.exchange(default_value, std::memory_order_relaxed)){ + report_value_changed(this); + on_set_enabled(default_value); + } } } void GroupOption::on_set_enabled(bool enabled){} diff --git a/Common/Cpp/Options/GroupOption.h b/Common/Cpp/Options/GroupOption.h index 192a9100e..03fb0defb 100644 --- a/Common/Cpp/Options/GroupOption.h +++ b/Common/Cpp/Options/GroupOption.h @@ -15,19 +15,28 @@ namespace PokemonAutomation{ class GroupOption : public BatchOption{ public: + enum class EnableMode{ + ALWAYS_ENABLED, + DEFAULT_DISABLED, + DEFAULT_ENABLED, + }; + ~GroupOption(); GroupOption( std::string label, LockMode lock_while_program_is_running, - bool toggleable = false, - bool enabled = true + EnableMode enable_mode = EnableMode::ALWAYS_ENABLED, + bool show_restore_defaults_button = false ); const std::string label() const; + bool toggleable() const; bool enabled() const; void set_enabled(bool enabled); + bool restore_defaults_button_enabled() const; + virtual void load_json(const JsonValue& json) override; virtual JsonValue to_json() const override; diff --git a/Common/Qt/Options/GroupWidget.cpp b/Common/Qt/Options/GroupWidget.cpp index f6ad7af5a..648dcc677 100644 --- a/Common/Qt/Options/GroupWidget.cpp +++ b/Common/Qt/Options/GroupWidget.cpp @@ -6,7 +6,9 @@ #include #include +#include #include +#include //#include "Common/Compiler.h" #include "GroupWidget.h" @@ -30,6 +32,7 @@ GroupWidget::GroupWidget(QWidget& parent, GroupOption& value) : QWidget(&parent) , ConfigWidget(value, *this) , m_value(value) + , m_restore_defaults_button(nullptr) { QVBoxLayout* layout = new QVBoxLayout(this); // layout->setAlignment(Qt::AlignTop); @@ -73,6 +76,26 @@ GroupWidget::GroupWidget(QWidget& parent, GroupOption& value) m_options_layout->addWidget(&m_options.back()->widget()); } + if (value.restore_defaults_button_enabled()){ + m_options.back()->widget().setContentsMargins(5, 5, 5, 5); + m_restore_defaults_button = new QPushButton("Restore Defaults", this); + m_options_layout->addWidget(m_restore_defaults_button); + connect( + m_restore_defaults_button, &QPushButton::clicked, + this, [this](bool on){ + QMessageBox::StandardButton button = QMessageBox::question( + nullptr, + "Restore Defaults", + "Are you sure you wish to restore this section back to defaults?", + QMessageBox::Ok | QMessageBox::Cancel + ); + if (button == QMessageBox::Ok){ + m_value.restore_defaults(); + } + } + ); + } + connect( m_group_box, &QGroupBox::toggled, this, [this](bool on){ diff --git a/Common/Qt/Options/GroupWidget.h b/Common/Qt/Options/GroupWidget.h index 90089db41..a088b25fe 100644 --- a/Common/Qt/Options/GroupWidget.h +++ b/Common/Qt/Options/GroupWidget.h @@ -13,6 +13,7 @@ class QVBoxLayout; class QGroupBox; +class QPushButton; namespace PokemonAutomation{ @@ -37,6 +38,7 @@ class GroupWidget : public QWidget, public ConfigWidget{ QWidget* m_expand_text; QWidget* m_options_holder; std::vector m_options; + QPushButton* m_restore_defaults_button; bool m_expanded = true; QVBoxLayout* m_options_layout; }; diff --git a/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp b/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp index fbfd0cb33..7d9a0cc06 100644 --- a/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp +++ b/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp @@ -35,7 +35,11 @@ const std::string& ERROR_PATH_SENT = "ErrorReportsSent"; ErrorReportOption::ErrorReportOption() - : GroupOption("Error Reports", LockMode::UNLOCK_WHILE_RUNNING, false) + : GroupOption( + "Error Reports", + LockMode::UNLOCK_WHILE_RUNNING, + GroupOption::EnableMode::ALWAYS_ENABLED, true + ) , DESCRIPTION( "Send error reports to the " + PROGRAM_NAME + " server to help them resolve issues and improve the program." ) diff --git a/SerialPrograms/Source/CommonFramework/Notifications/EventNotificationsTable.cpp b/SerialPrograms/Source/CommonFramework/Notifications/EventNotificationsTable.cpp index 756c2c506..11b7e7268 100644 --- a/SerialPrograms/Source/CommonFramework/Notifications/EventNotificationsTable.cpp +++ b/SerialPrograms/Source/CommonFramework/Notifications/EventNotificationsTable.cpp @@ -40,7 +40,11 @@ std::vector EventNotificationsTable::make_header() const{ EventNotificationsOption::EventNotificationsOption(std::vector options) - : GroupOption("Discord Notifications", LockMode::UNLOCK_WHILE_RUNNING, true) + : GroupOption( + "Discord Notifications", + LockMode::UNLOCK_WHILE_RUNNING, + GroupOption::EnableMode::DEFAULT_ENABLED, false + ) , m_table(std::move(options)) { PA_ADD_OPTION(m_table); diff --git a/SerialPrograms/Source/CommonFramework/Options/Environment/SleepSuppressOption.cpp b/SerialPrograms/Source/CommonFramework/Options/Environment/SleepSuppressOption.cpp index c67e9f5a8..65f6e28c4 100644 --- a/SerialPrograms/Source/CommonFramework/Options/Environment/SleepSuppressOption.cpp +++ b/SerialPrograms/Source/CommonFramework/Options/Environment/SleepSuppressOption.cpp @@ -33,7 +33,7 @@ SleepSuppressOptions::SleepSuppressOptions() : GroupOption( "Suppress Screensaver/Sleep:", LockMode::UNLOCK_WHILE_RUNNING, - false, true + GroupOption::EnableMode::ALWAYS_ENABLED, true ) , IDLE("No Program Running:", SleepSuppress::NONE) #ifdef PA_ENABLE_SLEEP_SUPPRESS_NO_SLEEP diff --git a/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.cpp b/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.cpp index 5a7bb0044..c89c4b7f1 100644 --- a/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.cpp +++ b/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.cpp @@ -9,13 +9,14 @@ namespace PokemonAutomation{ - StreamHistoryOption::StreamHistoryOption() : GroupOption( "Stream History", LockMode::LOCK_WHILE_RUNNING, - true, IS_BETA_VERSION + ? GroupOption::EnableMode::DEFAULT_ENABLED + : GroupOption::EnableMode::DEFAULT_DISABLED, + true ) , DESCRIPTION( "Keep a record of the recent video+audio streams. This will allow video capture " @@ -35,10 +36,44 @@ StreamHistoryOption::StreamHistoryOption() LockMode::UNLOCK_WHILE_RUNNING, 30 ) + , RESOLUTION( + "Resolution:", + { + {Resolution::MATCH_INPUT, "match", "Match Input Resolution"}, + {Resolution::FORCE_720p, "720p", "1280 x 720"}, + {Resolution::FORCE_1080p, "1080p", "1920 x 1080"}, + }, + LockMode::UNLOCK_WHILE_RUNNING, + Resolution::MATCH_INPUT + ) + , ENCODING_MODE( + "Encoding Mode:", + { + {EncodingMode::FIXED_QUALITY, "fixed-quality", "Fixed Quality"}, + {EncodingMode::FIXED_BITRATE, "fixed-bitrate", "Fixed Bit Rate"}, + }, + LockMode::UNLOCK_WHILE_RUNNING, + EncodingMode::FIXED_QUALITY + ) + , VIDEO_QUALITY( + "Video Quality:
" + "High quality videos will take more disk space " + "and may exceed the attachment size limit for Discord notifications." + "", + { + {VideoQuality::VERY_LOW, "very-low", "Very Low"}, + {VideoQuality::LOW, "low", "Low"}, + {VideoQuality::NORMAL, "normal", "Normal"}, + {VideoQuality::HIGH, "high", "High"}, + {VideoQuality::VERY_HIGH, "very-high", "Very High"}, + }, + LockMode::UNLOCK_WHILE_RUNNING, + VideoQuality::LOW + ) , VIDEO_BITRATE( "Video Bit-Rate (kbps):
" "Lower = lower quality, smaller file size.
" - "Higher = high quality, larger file size.

" + "Higher = high quality, larger file size.
" "Large values can exceed the attachment size limit for Discord notifications." "", LockMode::UNLOCK_WHILE_RUNNING, @@ -47,9 +82,35 @@ StreamHistoryOption::StreamHistoryOption() { PA_ADD_STATIC(DESCRIPTION); PA_ADD_OPTION(HISTORY_SECONDS); + PA_ADD_OPTION(RESOLUTION); + PA_ADD_OPTION(ENCODING_MODE); + PA_ADD_OPTION(VIDEO_QUALITY); PA_ADD_OPTION(VIDEO_BITRATE); + + value_changed(this); + + ENCODING_MODE.add_listener(*this); +} +StreamHistoryOption::~StreamHistoryOption(){ + ENCODING_MODE.remove_listener(*this); +} + +void StreamHistoryOption::value_changed(void* object){ + switch (ENCODING_MODE){ + case EncodingMode::FIXED_QUALITY: + VIDEO_QUALITY.set_visibility(ConfigOptionState::ENABLED); + VIDEO_BITRATE.set_visibility(ConfigOptionState::HIDDEN); + break; + case EncodingMode::FIXED_BITRATE: + VIDEO_QUALITY.set_visibility(ConfigOptionState::HIDDEN); + VIDEO_BITRATE.set_visibility(ConfigOptionState::ENABLED); + break; + } } + + + } diff --git a/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.h b/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.h index 9c131a55a..b513fe8d9 100644 --- a/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.h +++ b/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.h @@ -9,18 +9,45 @@ #include "Common/Cpp/Options/StaticTextOption.h" #include "Common/Cpp/Options/SimpleIntegerOption.h" +#include "Common/Cpp/Options/EnumDropdownOption.h" #include "Common/Cpp/Options/GroupOption.h" namespace PokemonAutomation{ -class StreamHistoryOption : public GroupOption{ +class StreamHistoryOption : public GroupOption, public ConfigOption::Listener{ public: StreamHistoryOption(); + ~StreamHistoryOption(); + + virtual void value_changed(void* object) override; StaticTextOption DESCRIPTION; SimpleIntegerOption HISTORY_SECONDS; + + enum class Resolution{ + MATCH_INPUT, + FORCE_720p, + FORCE_1080p, + }; + EnumDropdownOption RESOLUTION; + + enum class EncodingMode{ + FIXED_QUALITY, + FIXED_BITRATE, + }; + EnumDropdownOption ENCODING_MODE; + + + enum class VideoQuality{ + VERY_LOW, + LOW, + NORMAL, + HIGH, + VERY_HIGH, + }; + EnumDropdownOption VIDEO_QUALITY; SimpleIntegerOption VIDEO_BITRATE; }; diff --git a/SerialPrograms/Source/CommonFramework/Recording/StreamRecorder.cpp b/SerialPrograms/Source/CommonFramework/Recording/StreamRecorder.cpp index 552a1f1e0..71abd9e74 100644 --- a/SerialPrograms/Source/CommonFramework/Recording/StreamRecorder.cpp +++ b/SerialPrograms/Source/CommonFramework/Recording/StreamRecorder.cpp @@ -157,9 +157,43 @@ void StreamRecording::internal_run(){ // recorder.setQuality(QMediaRecorder::LowQuality); // recorder.setQuality(QMediaRecorder::VeryLowQuality); - recorder.setVideoResolution(1280, 720); - recorder.setVideoBitRate(GlobalSettings::instance().STREAM_HISTORY.VIDEO_BITRATE * 1000); - recorder.setEncodingMode(QMediaRecorder::AverageBitRateEncoding); + switch (GlobalSettings::instance().STREAM_HISTORY.RESOLUTION){ + case StreamHistoryOption::Resolution::MATCH_INPUT: + break; + case StreamHistoryOption::Resolution::FORCE_720p: + recorder.setVideoResolution(1280, 720); + break; + case StreamHistoryOption::Resolution::FORCE_1080p: + recorder.setVideoResolution(1920, 1080); + break; + } + + switch (GlobalSettings::instance().STREAM_HISTORY.ENCODING_MODE){ + case StreamHistoryOption::EncodingMode::FIXED_QUALITY: + switch (GlobalSettings::instance().STREAM_HISTORY.VIDEO_QUALITY){ + case StreamHistoryOption::VideoQuality::VERY_LOW: + recorder.setQuality(QMediaRecorder::VeryLowQuality); + break; + case StreamHistoryOption::VideoQuality::LOW: + recorder.setQuality(QMediaRecorder::LowQuality); + break; + case StreamHistoryOption::VideoQuality::NORMAL: + recorder.setQuality(QMediaRecorder::NormalQuality); + break; + case StreamHistoryOption::VideoQuality::HIGH: + recorder.setQuality(QMediaRecorder::HighQuality); + break; + case StreamHistoryOption::VideoQuality::VERY_HIGH: + recorder.setQuality(QMediaRecorder::VeryHighQuality); + break; + } + break; + case StreamHistoryOption::EncodingMode::FIXED_BITRATE: + recorder.setVideoBitRate(GlobalSettings::instance().STREAM_HISTORY.VIDEO_BITRATE * 1000); + recorder.setEncodingMode(QMediaRecorder::AverageBitRateEncoding); + break; + } + #ifdef PA_STREAM_HISTORY_LOCAL_BUFFER recorder.setOutputDevice(&m_write_buffer); diff --git a/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp b/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp index 09d48d27a..edf749729 100644 --- a/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp +++ b/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp @@ -28,7 +28,7 @@ DiscordIntegrationSettingsOption::~DiscordIntegrationSettingsOption(){ this->remove_listener(*this); } DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption() - : GroupOption("Discord Integration Settings", LockMode::LOCK_WHILE_RUNNING, true, false) + : GroupOption("Discord Integration Settings", LockMode::LOCK_WHILE_RUNNING) // , m_integration_enabled(integration_enabled) , run_on_start( "Run Discord Integration on Launch:
Automatically connect to Discord as soon as the program is launched.", diff --git a/SerialPrograms/Source/Integrations/DiscordWebhookSettings.cpp b/SerialPrograms/Source/Integrations/DiscordWebhookSettings.cpp index 7c5c0448c..483577a96 100644 --- a/SerialPrograms/Source/Integrations/DiscordWebhookSettings.cpp +++ b/SerialPrograms/Source/Integrations/DiscordWebhookSettings.cpp @@ -93,7 +93,11 @@ std::vector DiscordWebhookSettingsTable::make_header() const{ DiscordWebhookSettingsOption::DiscordWebhookSettingsOption() - : GroupOption("Discord Webhook Settings", LockMode::LOCK_WHILE_RUNNING, true, false) + : GroupOption( + "Discord Webhook Settings", + LockMode::LOCK_WHILE_RUNNING, + GroupOption::EnableMode::DEFAULT_ENABLED, false + ) , sends_per_second( "Rate Limit:
Maximum number of sends per second.", LockMode::LOCK_WHILE_RUNNING, 2, 1 diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_FastCodeEntry.cpp b/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_FastCodeEntry.cpp index 28b98574f..97b566101 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_FastCodeEntry.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_FastCodeEntry.cpp @@ -24,7 +24,11 @@ namespace NintendoSwitch{ FastCodeEntrySettingsOption::FastCodeEntrySettingsOption(LockMode lock_while_program_is_running) - : GroupOption("Fast Code Entry", lock_while_program_is_running) + : GroupOption( + "Fast Code Entry", + lock_while_program_is_running, + GroupOption::EnableMode::ALWAYS_ENABLED, true + ) , KEYBOARD_LAYOUT( "Keyboard Layout:", { diff --git a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.cpp b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.cpp index a3407ed18..477b85431 100644 --- a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.cpp +++ b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_BBQOption.cpp @@ -13,11 +13,7 @@ namespace NintendoSwitch{ namespace PokemonSV{ BBQOption::BBQOption(OCR::LanguageOCROption* language_option) - : GroupOption( - "Blueberry Quests", - LockMode::UNLOCK_WHILE_RUNNING, - false, true - ) + : GroupOption("Blueberry Quests", LockMode::UNLOCK_WHILE_RUNNING) , m_language_owner(language_option == nullptr ? new OCR::LanguageOCROption( "Game Language:
This is required to read quests.", diff --git a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_EggPowerSandwichOption.cpp b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_EggPowerSandwichOption.cpp index 2a34fd16c..f7e94a80a 100644 --- a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_EggPowerSandwichOption.cpp +++ b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_EggPowerSandwichOption.cpp @@ -13,11 +13,7 @@ namespace PokemonSV{ EggPowerSandwichOption::EggPowerSandwichOption() - : GroupOption( - "Egg Power Sandwich", - LockMode::UNLOCK_WHILE_RUNNING, - false, true - ) + : GroupOption("Egg Power Sandwich", LockMode::UNLOCK_WHILE_RUNNING) , MAX_NUM_SANDWICHES( "Max Sandwiches:
How many sandwiches you can make before running out of ingredients.", LockMode::UNLOCK_WHILE_RUNNING, diff --git a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_PlayerList.cpp b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_PlayerList.cpp index bc6d65621..9aa4d2032 100644 --- a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_PlayerList.cpp +++ b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_PlayerList.cpp @@ -90,7 +90,11 @@ std::vector PlayerListTable::snapshot() const{ RaidPlayerBanList::RaidPlayerBanList() - : GroupOption("Bans:", LockMode::UNLOCK_WHILE_RUNNING, true, true) + : GroupOption( + "Bans:", + LockMode::UNLOCK_WHILE_RUNNING, + GroupOption::EnableMode::DEFAULT_ENABLED + ) , text("Ban users from this raid. If a banned person tries to join, the raid will be reset.") , local_table( "Ban Table:
A table of users to ban by IGN. " diff --git a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.cpp b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.cpp index d9aed5c90..3fc8c7cc9 100644 --- a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.cpp +++ b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.cpp @@ -296,13 +296,12 @@ SandwichMakerOption::SandwichMakerOption( OCR::LanguageOCROption* language_option, BaseRecipe base_recipe, bool show_save_option, - bool toggleable, - bool enabled + GroupOption::EnableMode enable_mode ) : GroupOption( std::move(label), LockMode::UNLOCK_WHILE_RUNNING, - toggleable, enabled + enable_mode ) , m_language_owner(language_option == nullptr ? new OCR::LanguageOCROption( diff --git a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.h b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.h index 7c077bfec..a110b3212 100644 --- a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.h +++ b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SandwichMakerOption.h @@ -228,8 +228,7 @@ class SandwichMakerOption : public GroupOption, private ConfigOption::Listener{ OCR::LanguageOCROption* language_option, BaseRecipe base_recipe, bool show_save_option, - bool toggleable, - bool enabled + GroupOption::EnableMode enable_mode ); public: diff --git a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SinglesAIOption.cpp b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SinglesAIOption.cpp index 8c5efe4c5..d6dc40fdf 100644 --- a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SinglesAIOption.cpp +++ b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_SinglesAIOption.cpp @@ -18,11 +18,7 @@ using namespace Pokemon; SinglesAIOption::~SinglesAIOption() = default; SinglesAIOption::SinglesAIOption(bool trainer_battle) - : GroupOption( - "Battle AI", - LockMode::UNLOCK_WHILE_RUNNING, - false, true - ) + : GroupOption("Battle AI", LockMode::UNLOCK_WHILE_RUNNING) , description( "Move Tables: Run these sequence of moves for the corresponding " + STRING_POKEMON + " in your party. " "When the end of the table is reached, the last entry will be repeated " diff --git a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_TeraAIOption.cpp b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_TeraAIOption.cpp index 1fcbdc7e0..755ef45c4 100644 --- a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_TeraAIOption.cpp +++ b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_TeraAIOption.cpp @@ -13,11 +13,7 @@ namespace PokemonSV{ TeraAIOption::TeraAIOption() - : GroupOption( - "Battle AI", - LockMode::UNLOCK_WHILE_RUNNING, - false, true - ) + : GroupOption("Battle AI", LockMode::UNLOCK_WHILE_RUNNING) , description( "There is no battle AI yet. It will always select the 1st move unless it is blocked by taunt, disable, torment, etc..." ) diff --git a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_TeraCatchOnWinOption.cpp b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_TeraCatchOnWinOption.cpp index b400cba9d..fea141c50 100644 --- a/SerialPrograms/Source/PokemonSV/Options/PokemonSV_TeraCatchOnWinOption.cpp +++ b/SerialPrograms/Source/PokemonSV/Options/PokemonSV_TeraCatchOnWinOption.cpp @@ -13,7 +13,13 @@ namespace PokemonSV{ TeraFarmerCatchOnWin::TeraFarmerCatchOnWin(bool enabled) - : GroupOption("Catch on Win", LockMode::UNLOCK_WHILE_RUNNING, true, enabled) + : GroupOption( + "Catch on Win", + LockMode::UNLOCK_WHILE_RUNNING, + enabled + ? GroupOption::EnableMode::DEFAULT_ENABLED + : GroupOption::EnableMode::DEFAULT_DISABLED + ) , BALL_SELECT( "Ball Select:", LockMode::UNLOCK_WHILE_RUNNING, diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmer.cpp b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmer.cpp index b06f7d483..97acff65b 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmer.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmer.cpp @@ -44,7 +44,7 @@ std::unique_ptr MaterialFarmer_Descriptor::make_stats() const{ MaterialFarmer::MaterialFarmer() : GO_HOME_WHEN_DONE(true) , MATERIAL_FARMER_OPTIONS( - false, true, + GroupOption::EnableMode::ALWAYS_ENABLED, nullptr, NOTIFICATION_STATUS_UPDATE, NOTIFICATION_PROGRAM_FINISH, diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.cpp index e83566b49..56585fa1f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.cpp @@ -44,7 +44,7 @@ MaterialFarmerOptions::~MaterialFarmerOptions(){ } MaterialFarmerOptions::MaterialFarmerOptions( - bool toggleable, bool enabled, + GroupOption::EnableMode enable_mode, OCR::LanguageOCROption* language_option, EventNotificationOption& notif_status_update_option, EventNotificationOption& notif_program_finish_option, @@ -54,7 +54,7 @@ MaterialFarmerOptions::MaterialFarmerOptions( : GroupOption( "Material Farmer", LockMode::UNLOCK_WHILE_RUNNING, - toggleable, enabled + enable_mode ) , m_language_owner(language_option == nullptr ? new OCR::LanguageOCROption( @@ -78,7 +78,13 @@ MaterialFarmerOptions::MaterialFarmerOptions( // , SAVE_GAME_BEFORE_SANDWICH_STATIC_TEXT("") // , NUM_SANDWICH_ROUNDS_STATIC_TEXT("") , LANGUAGE(language_option == nullptr ? *m_language_owner : *language_option) - , SANDWICH_OPTIONS("Make a Sandwich", &LANGUAGE, BaseRecipe::non_shiny, true, true, false) + , SANDWICH_OPTIONS( + "Make a Sandwich", + &LANGUAGE, + BaseRecipe::non_shiny, + true, + GroupOption::EnableMode::DEFAULT_DISABLED + ) , AUTO_HEAL_PERCENT( "Auto-Heal %
Auto-heal if your HP drops below this percentage.", LockMode::UNLOCK_WHILE_RUNNING, diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.h b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.h index 65947179e..e2caffd05 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.h @@ -43,7 +43,7 @@ class MaterialFarmerOptions : public GroupOption, public ConfigOption::Listener{ public: ~MaterialFarmerOptions(); MaterialFarmerOptions( - bool toggleable, bool enabled, + GroupOption::EnableMode enable_mode, OCR::LanguageOCROption* language_option, EventNotificationOption& notif_status_update_option, EventNotificationOption& notif_program_finish_option, diff --git a/SerialPrograms/Source/PokemonSV/Programs/ItemPrinter/PokemonSV_ItemPrinterRNG.cpp b/SerialPrograms/Source/PokemonSV/Programs/ItemPrinter/PokemonSV_ItemPrinterRNG.cpp index 9cd5190a7..a25472c70 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/ItemPrinter/PokemonSV_ItemPrinterRNG.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/ItemPrinter/PokemonSV_ItemPrinterRNG.cpp @@ -179,7 +179,7 @@ ItemPrinterRNG::ItemPrinterRNG() 1, 999 ) , MATERIAL_FARMER_OPTIONS( - true, false, + GroupOption::EnableMode::DEFAULT_DISABLED, &LANGUAGE, NOTIFICATION_STATUS_UPDATE, NOTIFICATION_PROGRAM_FINISH, @@ -624,7 +624,7 @@ void ItemPrinterRNG::run_item_printer_rng_automode( const uint16_t min_happiny_dust = 400; MaterialFarmerOptions material_farmer_options( - true, true, + GroupOption::EnableMode::DEFAULT_ENABLED, &LANGUAGE, NOTIFICATION_STATUS_UPDATE, NOTIFICATION_PROGRAM_FINISH, diff --git a/SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichMaker.cpp b/SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichMaker.cpp index 4d743c2e8..730687dc0 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichMaker.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichMaker.cpp @@ -39,7 +39,13 @@ SandwichMaker_Descriptor::SandwichMaker_Descriptor() {} SandwichMaker::SandwichMaker() - : SANDWICH_OPTIONS("Sandwich Options", nullptr, BaseRecipe::non_shiny, false, false, true) + : SANDWICH_OPTIONS( + "Sandwich Options", + nullptr, + BaseRecipe::non_shiny, + false, + GroupOption::EnableMode::ALWAYS_ENABLED + ) , GO_HOME_WHEN_DONE(false) , NOTIFICATIONS({ &NOTIFICATION_PROGRAM_FINISH, diff --git a/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_AreaZeroPlatform.cpp b/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_AreaZeroPlatform.cpp index 82e312369..1539cceb0 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_AreaZeroPlatform.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_AreaZeroPlatform.cpp @@ -36,7 +36,11 @@ PlatformResetSettings::~PlatformResetSettings(){ WINDOW_IN_MINUTES.remove_listener(*this); } PlatformResetSettings::PlatformResetSettings() - : GroupOption("Platform Reset Conditions", LockMode::UNLOCK_WHILE_RUNNING, true, false) + : GroupOption( + "Platform Reset Conditions", + LockMode::UNLOCK_WHILE_RUNNING, + GroupOption::EnableMode::DEFAULT_ENABLED + ) , m_description( "A \"Platform Reset\" is when you fly to Zero Gate, then return to the " "platform. This is usually done to recover from falling off the " diff --git a/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-AreaZeroPlatform.cpp b/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-AreaZeroPlatform.cpp index 200cbdc23..1512c84d5 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-AreaZeroPlatform.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-AreaZeroPlatform.cpp @@ -125,7 +125,13 @@ ShinyHuntAreaZeroPlatform::ShinyHuntAreaZeroPlatform() LockMode::UNLOCK_WHILE_RUNNING, 35 ) - , SANDWICH_OPTIONS("Sandwich Options", &LANGUAGE, BaseRecipe::paradox, false, false, true) + , SANDWICH_OPTIONS( + "Sandwich Options", + &LANGUAGE, + BaseRecipe::paradox, + false, + GroupOption::EnableMode::ALWAYS_ENABLED + ) , GO_HOME_WHEN_DONE(true) , AUTO_HEAL_PERCENT( "Auto-Heal %
Auto-heal if your HP drops below this percentage.", diff --git a/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-Scatterbug.cpp b/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-Scatterbug.cpp index 6f15576b0..9f7efed7e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-Scatterbug.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-Scatterbug.cpp @@ -88,7 +88,13 @@ ShinyHuntScatterbug::ShinyHuntScatterbug() LockMode::UNLOCK_WHILE_RUNNING, true ) - , SANDWICH_OPTIONS("Sandwich Options", &LANGUAGE, BaseRecipe::shiny, false, false, true) + , SANDWICH_OPTIONS( + "Sandwich Options", + &LANGUAGE, + BaseRecipe::shiny, + false, + GroupOption::EnableMode::ALWAYS_ENABLED + ) , GO_HOME_WHEN_DONE(true) , AUTO_HEAL_PERCENT( "Auto-Heal %
Auto-heal if your HP drops below this percentage.", diff --git a/SerialPrograms/Source/PokemonSV/Programs/TeraRaids/PokemonSV_JoinTracker.cpp b/SerialPrograms/Source/PokemonSV/Programs/TeraRaids/PokemonSV_JoinTracker.cpp index 1b9d12b83..21ce123fe 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/TeraRaids/PokemonSV_JoinTracker.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/TeraRaids/PokemonSV_JoinTracker.cpp @@ -214,7 +214,11 @@ std::vector JoinReportTable::make_header() const{ RaidJoinReportOption::RaidJoinReportOption() - : GroupOption("Join Reports:", LockMode::UNLOCK_WHILE_RUNNING, true, true) + : GroupOption( + "Join Reports:", + LockMode::UNLOCK_WHILE_RUNNING, + GroupOption::EnableMode::DEFAULT_ENABLED + ) , text( "Track how many times each IGN has joined and generate a report. " "This can be used to help identify people who join too many times for " diff --git a/SerialPrograms/Source/PokemonSwSh/Options/PokemonSwSh_AutoHostNotification.cpp b/SerialPrograms/Source/PokemonSwSh/Options/PokemonSwSh_AutoHostNotification.cpp index 80ec7776d..37da49a85 100644 --- a/SerialPrograms/Source/PokemonSwSh/Options/PokemonSwSh_AutoHostNotification.cpp +++ b/SerialPrograms/Source/PokemonSwSh/Options/PokemonSwSh_AutoHostNotification.cpp @@ -12,7 +12,11 @@ namespace PokemonSwSh{ AutoHostNotificationOption::AutoHostNotificationOption(std::string label, bool max_lair) - : GroupOption(std::move(label), LockMode::LOCK_WHILE_RUNNING, true, false) + : GroupOption( + std::move(label), + LockMode::LOCK_WHILE_RUNNING, + GroupOption::EnableMode::DEFAULT_DISABLED + ) , DESCRIPTION( "Description:", LockMode::LOCK_WHILE_RUNNING, diff --git a/SerialPrograms/Source/PokemonSwSh/Programs/General/PokemonSwSh_DexRecFinder.cpp b/SerialPrograms/Source/PokemonSwSh/Programs/General/PokemonSwSh_DexRecFinder.cpp index ab5a6fa60..418a214cb 100644 --- a/SerialPrograms/Source/PokemonSwSh/Programs/General/PokemonSwSh_DexRecFinder.cpp +++ b/SerialPrograms/Source/PokemonSwSh/Programs/General/PokemonSwSh_DexRecFinder.cpp @@ -60,7 +60,11 @@ std::unique_ptr DexRecFinder_Descriptor::make_stats() const{ DexRecFilters::DexRecFilters() - : GroupOption("Stop Automatically (requires video feedback)", LockMode::LOCK_WHILE_RUNNING, true, true) + : GroupOption( + "Stop Automatically (requires video feedback)", + LockMode::LOCK_WHILE_RUNNING, + GroupOption::EnableMode::DEFAULT_ENABLED + ) , LANGUAGE( "Game Language:
This needs to be set correctly for stop filters to work correctly.", PokemonNameReader::instance().languages(),