diff --git a/Common/Cpp/Containers/Pimpl.h b/Common/Cpp/Containers/Pimpl.h index 1b2a34043..c1fe2b748 100644 --- a/Common/Cpp/Containers/Pimpl.h +++ b/Common/Cpp/Containers/Pimpl.h @@ -40,6 +40,9 @@ class Pimpl{ public: operator bool() const{ return m_ptr != nullptr; } + operator const Type&() const{ return *m_ptr; } + operator Type&() { return *m_ptr; } + const Type& operator*() const { return *m_ptr; } Type& operator*() { return *m_ptr; } diff --git a/Common/Qt/Options/GroupWidget.cpp b/Common/Qt/Options/GroupWidget.cpp index 648dcc677..dac203d07 100644 --- a/Common/Qt/Options/GroupWidget.cpp +++ b/Common/Qt/Options/GroupWidget.cpp @@ -77,9 +77,12 @@ GroupWidget::GroupWidget(QWidget& parent, GroupOption& value) } 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); + m_restore_defaults_button->setContentsMargins(5, 5, 5, 5); + QHBoxLayout* row = new QHBoxLayout(); + m_options_layout->addLayout(row); + row->addWidget(m_restore_defaults_button, 1); + row->addStretch(3); connect( m_restore_defaults_button, &QPushButton::clicked, this, [this](bool on){ diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index e090a57a8..ba3c9a52a 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -246,6 +246,7 @@ file(GLOB MAIN_SOURCES Source/CommonFramework/AudioPipeline/AudioOption.cpp Source/CommonFramework/AudioPipeline/AudioOption.h Source/CommonFramework/AudioPipeline/AudioPassthroughPair.h + Source/CommonFramework/AudioPipeline/AudioPipelineOptions.h Source/CommonFramework/AudioPipeline/AudioSession.cpp Source/CommonFramework/AudioPipeline/AudioSession.h Source/CommonFramework/AudioPipeline/AudioStream.cpp @@ -460,6 +461,7 @@ file(GLOB MAIN_SOURCES Source/CommonFramework/OCR/OCR_TextMatcher.h Source/CommonFramework/OCR/OCR_TrainingTools.cpp Source/CommonFramework/OCR/OCR_TrainingTools.h + Source/CommonFramework/Options/Environment/PerformanceOptions.h Source/CommonFramework/Options/Environment/ProcessPriorityOption.h Source/CommonFramework/Options/Environment/ProcessorLevelOption.cpp Source/CommonFramework/Options/Environment/ProcessorLevelOption.h @@ -589,6 +591,7 @@ file(GLOB MAIN_SOURCES Source/CommonFramework/VideoPipeline/VideoOverlaySession.h Source/CommonFramework/VideoPipeline/VideoOverlayTypes.cpp Source/CommonFramework/VideoPipeline/VideoOverlayTypes.h + Source/CommonFramework/VideoPipeline/VideoPipelineOptions.h Source/CommonFramework/Windows/ButtonDiagram.cpp Source/CommonFramework/Windows/ButtonDiagram.h Source/CommonFramework/Windows/DpiScaler.cpp diff --git a/SerialPrograms/SerialPrograms.pro b/SerialPrograms/SerialPrograms.pro index ed70d4820..a96ec72a9 100644 --- a/SerialPrograms/SerialPrograms.pro +++ b/SerialPrograms/SerialPrograms.pro @@ -1221,6 +1221,7 @@ HEADERS += \ Source/CommonFramework/AudioPipeline/AudioInfo.h \ Source/CommonFramework/AudioPipeline/AudioOption.h \ Source/CommonFramework/AudioPipeline/AudioPassthroughPair.h \ + Source/CommonFramework/AudioPipeline/AudioPipelineOptions.h \ Source/CommonFramework/AudioPipeline/AudioSession.h \ Source/CommonFramework/AudioPipeline/AudioStream.h \ Source/CommonFramework/AudioPipeline/AudioTemplate.h \ @@ -1341,6 +1342,7 @@ HEADERS += \ Source/CommonFramework/OCR/OCR_StringNormalization.h \ Source/CommonFramework/OCR/OCR_TextMatcher.h \ Source/CommonFramework/OCR/OCR_TrainingTools.h \ + Source/CommonFramework/Options/Environment/PerformanceOptions.h \ Source/CommonFramework/Options/Environment/ProcessPriorityOption.h \ Source/CommonFramework/Options/Environment/ProcessorLevelOption.h \ Source/CommonFramework/Options/Environment/SleepSuppressOption.h \ diff --git a/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioInfo.cpp b/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioInfo.cpp index 1d740266b..7f36c448d 100644 --- a/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioInfo.cpp +++ b/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioInfo.cpp @@ -7,14 +7,17 @@ #include #include #include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Time.h" #include "Common/Cpp/PrettyPrint.h" #include "Common/Cpp/Containers/Pimpl.tpp" #include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/Logging/Logger.h" +#include "CommonFramework/AudioPipeline/AudioPipelineOptions.h" #include "AudioInfo.h" -#include -using std::cout; -using std::endl; +//#include +//using std::cout; +//using std::endl; #if QT_VERSION_MAJOR == 5 @@ -312,7 +315,8 @@ std::vector AudioDeviceInfo::all_input_devices(){ double seconds = std::chrono::duration_cast(end - start).count() / 1000.; global_logger_tagged().log("Done querying audio inputs... " + tostr_fixed(seconds, 3) + " seconds", COLOR_CYAN); - if (GlobalSettings::instance().SHOW_ALL_AUDIO_DEVICES){ + bool show_all_devices = GlobalSettings::instance().AUDIO_PIPELINE->SHOW_ALL_DEVICES; + if (show_all_devices){ return list; } @@ -335,7 +339,7 @@ std::vector AudioDeviceInfo::all_input_devices(){ if (device.preferred_format_index() >= 0){ current_score += 100; } - if (current_score >= best_score || GlobalSettings::instance().SHOW_ALL_AUDIO_DEVICES){ + if (current_score >= best_score || show_all_devices){ ret.emplace_back(std::move(device)); } } diff --git a/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioPipelineOptions.h b/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioPipelineOptions.h new file mode 100644 index 000000000..4282f435a --- /dev/null +++ b/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioPipelineOptions.h @@ -0,0 +1,79 @@ +/* Audio Pipeline Options + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_AudioPipeline_AudioPipelineOptions_H +#define PokemonAutomation_AudioPipeline_AudioPipelineOptions_H + +#include "Common/Cpp/Options/GroupOption.h" +#include "Common/Cpp/Options/BooleanCheckBoxOption.h" +#include "Common/Cpp/Options/SimpleIntegerOption.h" +#include "Common/Cpp/Options/FloatingPointOption.h" +#include "CommonFramework/GlobalSettingsPanel.h" + +namespace PokemonAutomation{ + + +class AudioPipelineOptions : public GroupOption{ +public: + AudioPipelineOptions() + : GroupOption( + "Audio Pipeline", + LockMode::LOCK_WHILE_RUNNING, + GroupOption::EnableMode::ALWAYS_ENABLED, true + ) + , FILE_VOLUME_SCALE( + "Audio File Input Volume Scale:
" + "Multiply audio file playback by this factor. (This is linear scale. So each factor of 10 is 20dB.)", + LockMode::UNLOCK_WHILE_RUNNING, + 0.31622776601683793320, // -10dB + -10000, 10000 + ) + , DEVICE_VOLUME_SCALE( + "Audio Device Input Volume Scale:
" + "Multiply audio device input by this factor. (This is linear scale. So each factor of 10 is 20dB.)", + LockMode::UNLOCK_WHILE_RUNNING, + 1.0, -10000, 10000 + ) + , SHOW_ALL_DEVICES( + "Show all Audio Devices:
" + "Show all audio devices - including duplicates.", + LockMode::UNLOCK_WHILE_RUNNING, + false + ) + , SHOW_RECORD_FREQUENCIES( + "Show Record Frequencies:
" + "Show option to record audio frequencies.", + LockMode::UNLOCK_WHILE_RUNNING, + false + ) + , AUTO_RESET_SECONDS( + "Audio Auto-Reset:
" + "Attempt to reset the audio if this many seconds has elapsed since the last audio frame (in order to fix issues with RDP disconnection, etc).", + LockMode::UNLOCK_WHILE_RUNNING, + 5 + ) + { + PA_ADD_OPTION(FILE_VOLUME_SCALE); + PA_ADD_OPTION(DEVICE_VOLUME_SCALE); + PA_ADD_OPTION(SHOW_ALL_DEVICES); + if (PreloadSettings::instance().DEVELOPER_MODE){ + PA_ADD_OPTION(SHOW_RECORD_FREQUENCIES); + } + PA_ADD_OPTION(AUTO_RESET_SECONDS); + } + +public: + FloatingPointOption FILE_VOLUME_SCALE; + FloatingPointOption DEVICE_VOLUME_SCALE; + BooleanCheckBoxOption SHOW_ALL_DEVICES; + BooleanCheckBoxOption SHOW_RECORD_FREQUENCIES; + SimpleIntegerOption AUTO_RESET_SECONDS; +}; + + + +} +#endif diff --git a/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioSession.cpp b/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioSession.cpp index bbbcd01a1..27e5cb19e 100644 --- a/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioSession.cpp +++ b/SerialPrograms/Source/CommonFramework/AudioPipeline/AudioSession.cpp @@ -8,6 +8,7 @@ #include "CommonFramework/GlobalServices.h" #include "CommonFramework/GlobalSettingsPanel.h" #include "Backends/AudioPassthroughPairQtThread.h" +#include "AudioPipelineOptions.h" #include "AudioSession.h" //#include @@ -52,7 +53,7 @@ AudioSession::AudioSession(Logger& logger, AudioOption& option) AudioSession::reset(); m_devices->add_listener(*this); - uint8_t watchdog_timeout = GlobalSettings::instance().AUTO_RESET_AUDIO_SECONDS; + uint8_t watchdog_timeout = GlobalSettings::instance().AUDIO_PIPELINE->AUTO_RESET_SECONDS; if (watchdog_timeout != 0){ global_watchdog().add(*this, std::chrono::seconds(watchdog_timeout)); } @@ -292,7 +293,7 @@ void AudioSession::on_watchdog_timeout(){ return; } - uint8_t watchdog_timeout = GlobalSettings::instance().AUTO_RESET_AUDIO_SECONDS; + uint8_t watchdog_timeout = GlobalSettings::instance().AUDIO_PIPELINE->AUTO_RESET_SECONDS; m_logger.log("No audio detected for " + std::to_string(watchdog_timeout) + " seconds...", COLOR_RED); if (watchdog_timeout == 0){ diff --git a/SerialPrograms/Source/CommonFramework/AudioPipeline/Backends/AudioPassthroughPairQt.cpp b/SerialPrograms/Source/CommonFramework/AudioPipeline/Backends/AudioPassthroughPairQt.cpp index 5a864274e..067b5459a 100644 --- a/SerialPrograms/Source/CommonFramework/AudioPipeline/Backends/AudioPassthroughPairQt.cpp +++ b/SerialPrograms/Source/CommonFramework/AudioPipeline/Backends/AudioPassthroughPairQt.cpp @@ -5,7 +5,9 @@ */ //#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/AbstractLogger.h" #include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/AudioPipeline/AudioPipelineOptions.h" //#include "CommonFramework/AudioPipeline/AudioConstants.h" //#include "CommonFramework/AudioPipeline/Tools/AudioFormatUtils.h" #include "CommonFramework/AudioPipeline/IO/AudioSource.h" @@ -13,9 +15,9 @@ #include "CommonFramework/AudioPipeline/Spectrum/FFTStreamer.h" #include "AudioPassthroughPairQt.h" -#include -using std::cout; -using std::endl; +//#include +//using std::cout; +//using std::endl; namespace PokemonAutomation{ @@ -99,8 +101,8 @@ AudioPassthroughPairQt::~AudioPassthroughPairQt(){} AudioPassthroughPairQt::AudioPassthroughPairQt(Logger& logger) : m_logger(logger) - , m_file_input_multiplier((float)GlobalSettings::instance().AUDIO_FILE_VOLUME_SCALE) - , m_device_input_multiplier((float)GlobalSettings::instance().AUDIO_DEVICE_VOLUME_SCALE) + , m_file_input_multiplier((float)GlobalSettings::instance().AUDIO_PIPELINE->FILE_VOLUME_SCALE) + , m_device_input_multiplier((float)GlobalSettings::instance().AUDIO_PIPELINE->DEVICE_VOLUME_SCALE) {} void AudioPassthroughPairQt::reset( diff --git a/SerialPrograms/Source/CommonFramework/AudioPipeline/Backends/AudioPassthroughPairQtThread.cpp b/SerialPrograms/Source/CommonFramework/AudioPipeline/Backends/AudioPassthroughPairQtThread.cpp index 0e930c870..af8a1566a 100644 --- a/SerialPrograms/Source/CommonFramework/AudioPipeline/Backends/AudioPassthroughPairQtThread.cpp +++ b/SerialPrograms/Source/CommonFramework/AudioPipeline/Backends/AudioPassthroughPairQtThread.cpp @@ -6,6 +6,7 @@ #include "Common/Cpp/Concurrency/SpinPause.h" #include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/Options/Environment/PerformanceOptions.h" #include "AudioPassthroughPairQt.h" #include "AudioPassthroughPairQtThread.h" @@ -51,7 +52,7 @@ AudioPassthroughPairQtThread::~AudioPassthroughPairQtThread(){ wait(); } void AudioPassthroughPairQtThread::run(){ - GlobalSettings::instance().REALTIME_THREAD_PRIORITY0.set_on_this_thread(); + GlobalSettings::instance().PERFORMANCE->REALTIME_THREAD_PRIORITY.set_on_this_thread(); AudioPassthroughPairQt body(m_logger); m_body.store(&body, std::memory_order_relaxed); diff --git a/SerialPrograms/Source/CommonFramework/AudioPipeline/IO/AudioSource.cpp b/SerialPrograms/Source/CommonFramework/AudioPipeline/IO/AudioSource.cpp index 311758065..5c283e306 100644 --- a/SerialPrograms/Source/CommonFramework/AudioPipeline/IO/AudioSource.cpp +++ b/SerialPrograms/Source/CommonFramework/AudioPipeline/IO/AudioSource.cpp @@ -16,15 +16,15 @@ using NativeAudioSource = QAudioSource; #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/PrettyPrint.h" #include "Common/Cpp/Time.h" -#include "Common/Cpp/StreamConverters.h" +//#include "Common/Cpp/StreamConverters.h" #include "CommonFramework/AudioPipeline/AudioStream.h" #include "CommonFramework/AudioPipeline/Tools/AudioFormatUtils.h" #include "AudioFileLoader.h" #include "AudioSource.h" -#include -using std::cout; -using std::endl; +//#include +//using std::cout; +//using std::endl; namespace PokemonAutomation{ diff --git a/SerialPrograms/Source/CommonFramework/AudioPipeline/UI/AudioSelectorWidget.cpp b/SerialPrograms/Source/CommonFramework/AudioPipeline/UI/AudioSelectorWidget.cpp index 373367200..47ba82357 100644 --- a/SerialPrograms/Source/CommonFramework/AudioPipeline/UI/AudioSelectorWidget.cpp +++ b/SerialPrograms/Source/CommonFramework/AudioPipeline/UI/AudioSelectorWidget.cpp @@ -12,6 +12,7 @@ #include #include "Common/Qt/NoWheelComboBox.h" #include "CommonFramework/AudioPipeline/AudioSession.h" +#include "CommonFramework/AudioPipeline/AudioPipelineOptions.h" #include "AudioDisplayWidget.h" #include "AudioSelectorWidget.h" #include "CommonFramework/GlobalSettingsPanel.h" @@ -80,7 +81,7 @@ AudioSelectorWidget::AudioSelectorWidget( QHBoxLayout* output_layout = new QHBoxLayout(); row1->addLayout(output_layout, 10); - if (GlobalSettings::instance().SHOW_RECORD_FREQUENCIES){ + if (GlobalSettings::instance().AUDIO_PIPELINE->SHOW_RECORD_FREQUENCIES){ m_audio_output_box = new NoWheelComboBox(this); output_layout->addWidget(m_audio_output_box, 7); m_record_button = new QPushButton("Record Frequencies", this); @@ -186,7 +187,7 @@ AudioSelectorWidget::AudioSelectorWidget( // only in developer mode: // record audio - if (GlobalSettings::instance().SHOW_RECORD_FREQUENCIES){ + if (GlobalSettings::instance().AUDIO_PIPELINE->SHOW_RECORD_FREQUENCIES){ connect(m_record_button, &QPushButton::clicked, this, [this](bool){ m_record_is_on = !m_record_is_on; m_session.spectrums().saveAudioFrequenciesToDisk(m_record_is_on); diff --git a/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp b/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp index 7d9a0cc06..ca385339d 100644 --- a/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp +++ b/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp @@ -315,7 +315,7 @@ void send_reports(Logger& logger, const std::vector& reports){ } void send_all_unsent_reports(Logger& logger, bool allow_prompt){ #ifdef PA_OFFICIAL - ErrorReportSendMode mode = GlobalSettings::instance().ERROR_REPORTS.SEND_MODE; + ErrorReportSendMode mode = GlobalSettings::instance().ERROR_REPORTS->SEND_MODE; if (mode == ErrorReportSendMode::NEVER_SEND_ANYTHING){ return; } diff --git a/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp b/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp index 8135ba08c..77e275c1a 100644 --- a/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp +++ b/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp @@ -7,11 +7,21 @@ #include #include #include +#include "Common/Cpp/Containers/Pimpl.tpp" #include "Common/Cpp/LifetimeSanitizer.h" #include "Common/Cpp/Json/JsonValue.h" #include "Common/Cpp/Json/JsonArray.h" #include "Common/Cpp/Json/JsonObject.h" #include "CommonFramework/Globals.h" +#include "CommonFramework/Options/ResolutionOption.h" +#include "CommonFramework/Options/Environment/SleepSuppressOption.h" +#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "CommonFramework/Options/Environment/PerformanceOptions.h" +#include "CommonFramework/Recording/StreamHistoryOption.h" +#include "CommonFramework/AudioPipeline/AudioPipelineOptions.h" +#include "CommonFramework/VideoPipeline/VideoPipelineOptions.h" +#include "CommonFramework/ErrorReports/ErrorReports.h" +#include "Integrations/DiscordSettingsOption.h" //#include "CommonFramework/Environment/Environment.h" #include "GlobalSettingsPanel.h" @@ -103,12 +113,16 @@ GlobalSettings::GlobalSettings() "TempFiles/", "TempFiles/" ) + , THEME(CONSTRUCT_TOKEN) , WINDOW_SIZE( + CONSTRUCT_TOKEN, "Window Size:", "Set the size of the window. Takes effect immediately.
" "Use this to easily set the window to a specific resolution for streaming alignment.", 1280, 1000 ) + , STREAM_HISTORY(CONSTRUCT_TOKEN) + , SLEEP_SUPPRESS(CONSTRUCT_TOKEN) , m_discord_settings( "Discord Settings: Integrate with Discord. (" + make_text_url( @@ -121,6 +135,7 @@ GlobalSettings::GlobalSettings() LockMode::UNLOCK_WHILE_RUNNING, true ) + , DISCORD(CONSTRUCT_TOKEN) , m_advanced_options( "Advanced Options: You should not need to touch anything below here." ) @@ -143,82 +158,16 @@ GlobalSettings::GlobalSettings() LockMode::UNLOCK_WHILE_RUNNING, false ) - , REALTIME_THREAD_PRIORITY0( - "Realtime Thread Priority:
" - "Thread priority of real-time threads. (UI thread, audio threads)
" - "Restart the program for this to fully take effect.", - DEFAULT_PRIORITY_REALTIME - ) - , INFERENCE_PRIORITY0( - "Inference Priority:
" - "Thread priority of inference threads. (image/sound recognition)", - DEFAULT_PRIORITY_INFERENCE - ) - , COMPUTE_PRIORITY0( - "Compute Priority:
" - "Thread priority of computation threads.", - DEFAULT_PRIORITY_COMPUTE - ) - , AUDIO_FILE_VOLUME_SCALE( - "Audio File Input Volume Scale:
" - "Multiply audio file playback by this factor. (This is linear scale. So each factor of 10 is 20dB.)", - LockMode::UNLOCK_WHILE_RUNNING, - 0.31622776601683793320, // -10dB - -10000, 10000 - ) - , AUDIO_DEVICE_VOLUME_SCALE( - "Audio Device Input Volume Scale:
" - "Multiply audio device input by this factor. (This is linear scale. So each factor of 10 is 20dB.)", - LockMode::UNLOCK_WHILE_RUNNING, - 1.0, -10000, 10000 - ) - , SHOW_ALL_AUDIO_DEVICES( - "Show all Audio Devices:
" - "Show all audio devices - including duplicates.", - LockMode::UNLOCK_WHILE_RUNNING, - false - ) - , SHOW_RECORD_FREQUENCIES( - "Show Record Frequencies:
" - "Show option to record audio frequencies.", - LockMode::UNLOCK_WHILE_RUNNING, - false - ) -#if QT_VERSION_MAJOR == 5 - , ENABLE_FRAME_SCREENSHOTS( - "Enable Frame Screenshots:
" - "Attempt to use QVideoProbe and QVideoFrame for screenshots.", - LockMode::UNLOCK_WHILE_RUNNING, - true - ) -#endif - , AUTO_RESET_AUDIO_SECONDS( - "Audio Auto-Reset:
" - "Attempt to reset the audio if this many seconds has elapsed since the last audio frame (in order to fix issues with RDP disconnection, etc).", - LockMode::UNLOCK_WHILE_RUNNING, - 5 - ) - , AUTO_RESET_VIDEO_SECONDS( - "Video Auto-Reset:
" - "Attempt to reset the video if this many seconds has elapsed since the last video frame (in order to fix issues with RDP disconnection, etc).
" - "This option is not supported by all video frameworks.", - LockMode::UNLOCK_WHILE_RUNNING, - 5 - ) + , PERFORMANCE(CONSTRUCT_TOKEN) + , AUDIO_PIPELINE(CONSTRUCT_TOKEN) + , VIDEO_PIPELINE(CONSTRUCT_TOKEN) , ENABLE_LIFETIME_SANITIZER( "Enable Lifetime Sanitizer: (for debugging)
" "Check for C++ object lifetime violations. Terminate program with stack dump if violations are found.", LockMode::UNLOCK_WHILE_RUNNING, IS_BETA_VERSION ) -#if 0 - , SEND_ERROR_REPORTS0( - "Send Error Reports:
" - "Send error reports to the " + PROGRAM_NAME + " server to help them resolve issues and improve the program.", - LockMode::LOCK_WHILE_RUNNING, - true - ) -#endif + , ERROR_REPORTS(CONSTRUCT_TOKEN) , DEVELOPER_TOKEN( true, "Developer Token:
Restart application to take full effect after changing this.", @@ -235,7 +184,7 @@ GlobalSettings::GlobalSettings() #if (QT_VERSION_MAJOR == 6) && (QT_VERSION_MINOR >= 8) PA_ADD_OPTION(STREAM_HISTORY); #else - STREAM_HISTORY.set_enabled(false); + STREAM_HISTORY->set_enabled(false); #endif #ifdef PA_ENABLE_SLEEP_SUPPRESS PA_ADD_OPTION(SLEEP_SUPPRESS); @@ -250,30 +199,14 @@ GlobalSettings::GlobalSettings() // PA_ADD_OPTION(NAUGHTY_MODE); PA_ADD_OPTION(HIDE_NOTIF_DISCORD_LINK); - PA_ADD_OPTION(REALTIME_THREAD_PRIORITY0); - PA_ADD_OPTION(INFERENCE_PRIORITY0); - PA_ADD_OPTION(COMPUTE_PRIORITY0); + PA_ADD_OPTION(PERFORMANCE); - PA_ADD_OPTION(AUDIO_FILE_VOLUME_SCALE); - PA_ADD_OPTION(AUDIO_DEVICE_VOLUME_SCALE); - PA_ADD_OPTION(SHOW_ALL_AUDIO_DEVICES); - if (PreloadSettings::instance().DEVELOPER_MODE){ - PA_ADD_OPTION(SHOW_RECORD_FREQUENCIES); - } - PA_ADD_OPTION(VIDEO_BACKEND); -#if QT_VERSION_MAJOR == 5 - PA_ADD_OPTION(ENABLE_FRAME_SCREENSHOTS); -#endif - - PA_ADD_OPTION(AUTO_RESET_AUDIO_SECONDS); - PA_ADD_OPTION(AUTO_RESET_VIDEO_SECONDS); + PA_ADD_OPTION(AUDIO_PIPELINE); + PA_ADD_OPTION(VIDEO_PIPELINE); PA_ADD_OPTION(ENABLE_LIFETIME_SANITIZER); - PA_ADD_OPTION(PROCESSOR_LEVEL0); - #ifdef PA_OFFICIAL -// PA_ADD_OPTION(SEND_ERROR_REPORTS0); PA_ADD_OPTION(ERROR_REPORTS); #endif diff --git a/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.h b/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.h index d6e50b7a6..359a70f55 100644 --- a/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.h +++ b/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.h @@ -7,23 +7,15 @@ #ifndef PokemonAutomation_GlobalSettingsPanel_H #define PokemonAutomation_GlobalSettingsPanel_H +#include +#include "Common/Cpp/Containers/Pimpl.h" #include "Common/Cpp/Options/ConfigOption.h" #include "Common/Cpp/Options/StaticTextOption.h" #include "Common/Cpp/Options/BooleanCheckBoxOption.h" -#include "Common/Cpp/Options/SimpleIntegerOption.h" -#include "Common/Cpp/Options/FloatingPointOption.h" +//#include "Common/Cpp/Options/SimpleIntegerOption.h" #include "Common/Cpp/Options/StringOption.h" -#include "CommonFramework/Options/ResolutionOption.h" -#include "CommonFramework/Options/Environment/ProcessPriorityOption.h" -#include "CommonFramework/Options/Environment/ProcessorLevelOption.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" -#include "CommonFramework/Options/Environment/SleepSuppressOption.h" -#include "CommonFramework/ErrorReports/ErrorReports.h" -#include "CommonFramework/VideoPipeline/Backends/CameraImplementations.h" -#include "CommonFramework/Recording/StreamHistoryOption.h" #include "CommonFramework/Panels/SettingsPanel.h" #include "CommonFramework/Panels/PanelTools.h" -#include "Integrations/DiscordSettingsOption.h" //#include //using std::cout; @@ -32,6 +24,18 @@ namespace PokemonAutomation{ +class ThemeSelectorOption; +class ResolutionOption; +class StreamHistoryOption; +class SleepSuppressOptions; +namespace Integration{ + class DiscordSettingsOption; +} +class PerformanceOptions; +class AudioPipelineOptions; +class VideoPipelineOptions; +class ErrorReportOption; + class FolderInputOption : public StringOption{ public: @@ -45,6 +49,8 @@ class FolderInputOption : public StringOption{ }; + + struct DebugSettings{ bool COLOR_CHECK = false; bool IMAGE_TEMPLATE_MATCHING = false; @@ -69,6 +75,7 @@ class PreloadSettings{ + class GlobalSettings : public BatchOption, private ConfigOption::Listener{ ~GlobalSettings(); GlobalSettings(); @@ -87,48 +94,30 @@ class GlobalSettings : public BatchOption, private ConfigOption::Listener{ StringOption STATS_FILE; FolderInputOption TEMP_FOLDER; - ThemeSelectorOption THEME; - ResolutionOption WINDOW_SIZE; + Pimpl THEME; + Pimpl WINDOW_SIZE; - StreamHistoryOption STREAM_HISTORY; - SleepSuppressOptions SLEEP_SUPPRESS; + Pimpl STREAM_HISTORY; + Pimpl SLEEP_SUPPRESS; SectionDividerOption m_discord_settings; BooleanCheckBoxOption ALL_STATS; - Integration::DiscordSettingsOption DISCORD; + Pimpl DISCORD; SectionDividerOption m_advanced_options; BooleanCheckBoxOption LOG_EVERYTHING; BooleanCheckBoxOption SAVE_DEBUG_IMAGES; // BooleanCheckBoxOption NAUGHTY_MODE_OPTION; - BooleanCheckBoxOption HIDE_NOTIF_DISCORD_LINK; -// ProcessPriorityOption PROCESS_PRIORITY0; - ThreadPriorityOption REALTIME_THREAD_PRIORITY0; - ThreadPriorityOption INFERENCE_PRIORITY0; - ThreadPriorityOption COMPUTE_PRIORITY0; - - FloatingPointOption AUDIO_FILE_VOLUME_SCALE; - FloatingPointOption AUDIO_DEVICE_VOLUME_SCALE; - BooleanCheckBoxOption SHOW_ALL_AUDIO_DEVICES; - BooleanCheckBoxOption SHOW_RECORD_FREQUENCIES; - - VideoBackendOption VIDEO_BACKEND; -#if QT_VERSION_MAJOR == 5 - BooleanCheckBoxOption ENABLE_FRAME_SCREENSHOTS; -#endif - - SimpleIntegerOption AUTO_RESET_AUDIO_SECONDS; - SimpleIntegerOption AUTO_RESET_VIDEO_SECONDS; + Pimpl PERFORMANCE; + Pimpl AUDIO_PIPELINE; + Pimpl VIDEO_PIPELINE; BooleanCheckBoxOption ENABLE_LIFETIME_SANITIZER; -// BooleanCheckBoxOption SEND_ERROR_REPORTS0; - ErrorReportOption ERROR_REPORTS; - - ProcessorLevelOption PROCESSOR_LEVEL0; + Pimpl ERROR_REPORTS; StringOption DEVELOPER_TOKEN; diff --git a/SerialPrograms/Source/CommonFramework/Globals.cpp b/SerialPrograms/Source/CommonFramework/Globals.cpp index 72aa798b3..9c429d5eb 100644 --- a/SerialPrograms/Source/CommonFramework/Globals.cpp +++ b/SerialPrograms/Source/CommonFramework/Globals.cpp @@ -69,7 +69,7 @@ const std::string COMPILER_VERSION = "Unknown Compiler"; -const size_t LOG_HISTORY_LINES = 2000; +const size_t LOG_HISTORY_LINES = 10000; namespace{ diff --git a/SerialPrograms/Source/CommonFramework/ImageMatch/CroppedImageDictionaryMatcher.cpp b/SerialPrograms/Source/CommonFramework/ImageMatch/CroppedImageDictionaryMatcher.cpp index 0bde59761..7024c3902 100644 --- a/SerialPrograms/Source/CommonFramework/ImageMatch/CroppedImageDictionaryMatcher.cpp +++ b/SerialPrograms/Source/CommonFramework/ImageMatch/CroppedImageDictionaryMatcher.cpp @@ -6,6 +6,7 @@ #include #include "Common/Cpp/Exceptions.h" +#include "CommonFramework/Logging/Logger.h" #include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/Tools/DebugDumper.h" diff --git a/SerialPrograms/Source/CommonFramework/ImageTools/WaterfillUtilities.cpp b/SerialPrograms/Source/CommonFramework/ImageTools/WaterfillUtilities.cpp index c3525668e..aa77e5793 100644 --- a/SerialPrograms/Source/CommonFramework/ImageTools/WaterfillUtilities.cpp +++ b/SerialPrograms/Source/CommonFramework/ImageTools/WaterfillUtilities.cpp @@ -6,9 +6,10 @@ #include #include "Common/Cpp/Color.h" -#include "CommonFramework/GlobalSettingsPanel.h" #include "Kernels/Waterfill/Kernels_Waterfill_Session.h" #include "Kernels/Waterfill/Kernels_Waterfill_Types.h" +#include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/Logging/Logger.h" #include "CommonFramework/ImageMatch/WaterfillTemplateMatcher.h" #include "CommonFramework/ImageTools/BinaryImage_FilterRgb32.h" #include "CommonFramework/ImageTypes/ImageRGB32.h" @@ -32,8 +33,8 @@ std::pair remove_center_pixels( // cout << matrix.dump() << endl; // Sort all pixels by distance from center. - size_t center_x = object.center_of_gravity_x() - object.min_x; - size_t center_y = object.center_of_gravity_y() - object.min_y; + size_t center_x = (size_t)(object.center_of_gravity_x() - object.min_x); + size_t center_y = (size_t)(object.center_of_gravity_y() - object.min_y); std::map distances; for (size_t r = 0; r < height; r++){ for (size_t c = 0; c < width; c++){ diff --git a/SerialPrograms/Source/CommonFramework/Main.cpp b/SerialPrograms/Source/CommonFramework/Main.cpp index 00a6efb55..a234f49c9 100644 --- a/SerialPrograms/Source/CommonFramework/Main.cpp +++ b/SerialPrograms/Source/CommonFramework/Main.cpp @@ -11,6 +11,7 @@ #include "PersistentSettings.h" #include "Tests/CommandLineTests.h" #include "ErrorReports/ProgramDumper.h" +#include "ErrorReports/ErrorReports.h" #include "Environment/HardwareValidation.h" #include "Logging/Logger.h" #include "Logging/OutputRedirector.h" @@ -93,7 +94,7 @@ int main(int argc, char *argv[]){ check_new_version(global_logger_tagged()); - Integration::DiscordIntegrationSettingsOption& discord_settings = GlobalSettings::instance().DISCORD.integration; + Integration::DiscordIntegrationSettingsOption& discord_settings = GlobalSettings::instance().DISCORD->integration; if (discord_settings.run_on_start){ #ifdef PA_SLEEPY if (discord_settings.library0 == Integration::DiscordIntegrationSettingsOption::Library::SleepyDiscord){ @@ -123,13 +124,12 @@ int main(int argc, char *argv[]){ // Write program settings back to the json file. PERSISTENT_SETTINGS().write(); -#ifdef PA_SLEEPY - Integration::SleepyDiscordRunner::sleepy_terminate(); -#endif - #ifdef PA_DPP Integration::DppClient::Client::instance().disconnect(); #endif +#ifdef PA_SLEEPY + Integration::SleepyDiscordRunner::sleepy_terminate(); +#endif return ret; } diff --git a/SerialPrograms/Source/CommonFramework/Notifications/ProgramNotifications.cpp b/SerialPrograms/Source/CommonFramework/Notifications/ProgramNotifications.cpp index a42715457..3ee1ff4ed 100644 --- a/SerialPrograms/Source/CommonFramework/Notifications/ProgramNotifications.cpp +++ b/SerialPrograms/Source/CommonFramework/Notifications/ProgramNotifications.cpp @@ -54,7 +54,7 @@ std::pair make_session_field( const ProgramInfo& info, const StatsTracker* current_stats, const std::string& current_stats_addendum ){ - const std::string& instance_name = GlobalSettings::instance().DISCORD.message.instance_name; + const std::string& instance_name = GlobalSettings::instance().DISCORD->message.instance_name; std::string name = instance_name.empty() ? "Current Session:" : "Current Session: (" + instance_name + ")"; @@ -122,7 +122,7 @@ void send_raw_notification( ); #ifdef PA_SLEEPY - if (GlobalSettings::instance().DISCORD.integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::SleepyDiscord){ + if (GlobalSettings::instance().DISCORD->integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::SleepyDiscord){ Integration::SleepyDiscordRunner::send_embed_sleepy( should_ping, tags, std::move(embed), hasFile ? file : nullptr @@ -131,7 +131,7 @@ void send_raw_notification( #endif #ifdef PA_DPP - if (GlobalSettings::instance().DISCORD.integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::DPP){ + if (GlobalSettings::instance().DISCORD->integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::DPP){ Integration::DppClient::Client::instance().send_embed_dpp( should_ping, color, tags, std::move(embed), hasFile ? file : nullptr @@ -175,7 +175,7 @@ void send_raw_notification( ); #ifdef PA_SLEEPY - if (GlobalSettings::instance().DISCORD.integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::SleepyDiscord){ + if (GlobalSettings::instance().DISCORD->integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::SleepyDiscord){ Integration::SleepyDiscordRunner::send_embed_sleepy( should_ping, tags, std::move(embed), hasFile ? file : nullptr @@ -184,7 +184,7 @@ void send_raw_notification( #endif #ifdef PA_DPP - if (GlobalSettings::instance().DISCORD.integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::DPP){ + if (GlobalSettings::instance().DISCORD->integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::DPP){ Integration::DppClient::Client::instance().send_embed_dpp( should_ping, color, tags, std::move(embed), hasFile ? file : nullptr diff --git a/SerialPrograms/Source/CommonFramework/OCR/OCR_TrainingTools.cpp b/SerialPrograms/Source/CommonFramework/OCR/OCR_TrainingTools.cpp index 1c58f82de..2e67f7a39 100644 --- a/SerialPrograms/Source/CommonFramework/OCR/OCR_TrainingTools.cpp +++ b/SerialPrograms/Source/CommonFramework/OCR/OCR_TrainingTools.cpp @@ -9,9 +9,8 @@ #include "Common/Cpp/Concurrency/ParallelTaskRunner.h" #include "CommonFramework/Globals.h" #include "CommonFramework/GlobalSettingsPanel.h" -#include "CommonFramework/ImageTypes/ImageViewRGB32.h" -#include "CommonFramework/OCR/OCR_RawOCR.h" -#include "CommonFramework/OCR/OCR_StringNormalization.h" +#include "CommonFramework/Options/Environment/PerformanceOptions.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" #include "OCR_SmallDictionaryMatcher.h" #include "OCR_LargeDictionaryMatcher.h" #include "OCR_TrainingTools.h" @@ -112,7 +111,7 @@ void TrainingSession::generate_small_dictionary( OCR::SmallDictionaryMatcher trained(ocr_json_file, !incremental); ParallelTaskRunner task_runner( - [](){ GlobalSettings::instance().COMPUTE_PRIORITY0.set_on_this_thread(); }, + [](){ GlobalSettings::instance().PERFORMANCE->COMPUTE_PRIORITY.set_on_this_thread(); }, 0, threads ); @@ -194,7 +193,7 @@ void TrainingSession::generate_large_dictionary( OCR::LargeDictionaryMatcher trained(ocr_json_directory + output_prefix, nullptr, !incremental); ParallelTaskRunner task_runner( - [](){ GlobalSettings::instance().COMPUTE_PRIORITY0.set_on_this_thread(); }, + [](){ GlobalSettings::instance().PERFORMANCE->COMPUTE_PRIORITY.set_on_this_thread(); }, 0, threads ); diff --git a/SerialPrograms/Source/CommonFramework/Options/Environment/PerformanceOptions.h b/SerialPrograms/Source/CommonFramework/Options/Environment/PerformanceOptions.h new file mode 100644 index 000000000..d947ce0c9 --- /dev/null +++ b/SerialPrograms/Source/CommonFramework/Options/Environment/PerformanceOptions.h @@ -0,0 +1,61 @@ +/* Performance Options + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_PerformanceOptions_H +#define PokemonAutomation_PerformanceOptions_H + +#include "Common/Cpp/Options/GroupOption.h" +#include "ProcessPriorityOption.h" +#include "ProcessorLevelOption.h" + +namespace PokemonAutomation{ + + +class PerformanceOptions : public GroupOption{ +public: + PerformanceOptions() + : GroupOption( + "Performance", + LockMode::LOCK_WHILE_RUNNING, + GroupOption::EnableMode::ALWAYS_ENABLED, true + ) + , REALTIME_THREAD_PRIORITY( + "Realtime Thread Priority:
" + "Thread priority of real-time threads. (UI thread, audio threads)
" + "Restart the program for this to fully take effect.", + DEFAULT_PRIORITY_REALTIME + ) + , INFERENCE_PRIORITY( + "Inference Priority:
" + "Thread priority of inference threads. (image/sound recognition)", + DEFAULT_PRIORITY_INFERENCE + ) + , COMPUTE_PRIORITY( + "Compute Priority:
" + "Thread priority of computation threads.", + DEFAULT_PRIORITY_COMPUTE + ) + { + PA_ADD_OPTION(REALTIME_THREAD_PRIORITY); + PA_ADD_OPTION(INFERENCE_PRIORITY); + PA_ADD_OPTION(COMPUTE_PRIORITY); + PA_ADD_OPTION(PROCESSOR_LEVEL); + } + +public: + ThreadPriorityOption REALTIME_THREAD_PRIORITY; + ThreadPriorityOption INFERENCE_PRIORITY; + ThreadPriorityOption COMPUTE_PRIORITY; + + ProcessorLevelOption PROCESSOR_LEVEL; +}; + + + + + +} +#endif diff --git a/SerialPrograms/Source/CommonFramework/Options/Environment/ProcessPriorityOption.h b/SerialPrograms/Source/CommonFramework/Options/Environment/ProcessPriorityOption.h index 5506bbb9d..cb7db0943 100644 --- a/SerialPrograms/Source/CommonFramework/Options/Environment/ProcessPriorityOption.h +++ b/SerialPrograms/Source/CommonFramework/Options/Environment/ProcessPriorityOption.h @@ -8,6 +8,7 @@ #define PokemonAutomation_ProcessPriorityOption_H #include "Common/Cpp/Options/EnumDropdownOption.h" +#include "Common/Cpp/Options/GroupOption.h" #include "CommonFramework/Environment/Environment.h" namespace PokemonAutomation{ diff --git a/SerialPrograms/Source/CommonFramework/Options/Environment/ProcessorLevelOption.cpp b/SerialPrograms/Source/CommonFramework/Options/Environment/ProcessorLevelOption.cpp index 5c25e78a8..b5b85eb95 100644 --- a/SerialPrograms/Source/CommonFramework/Options/Environment/ProcessorLevelOption.cpp +++ b/SerialPrograms/Source/CommonFramework/Options/Environment/ProcessorLevelOption.cpp @@ -6,7 +6,6 @@ #include "Common/Cpp/Json/JsonValue.h" #include "Common/Cpp/Json/JsonObject.h" -#include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/Environment/Environment.h" #include "CommonFramework/Logging/Logger.h" #include "ProcessorLevelOption.h" diff --git a/SerialPrograms/Source/CommonFramework/PersistentSettings.cpp b/SerialPrograms/Source/CommonFramework/PersistentSettings.cpp index 1da1c4a14..eda0dc35d 100644 --- a/SerialPrograms/Source/CommonFramework/PersistentSettings.cpp +++ b/SerialPrograms/Source/CommonFramework/PersistentSettings.cpp @@ -11,6 +11,7 @@ #include "Common/Cpp/Json/JsonObject.h" #include "CommonFramework/Globals.h" #include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/Options/Environment/PerformanceOptions.h" #include "NintendoSwitch/Framework/NintendoSwitch_VirtualControllerMapping.h" #include "PersistentSettings.h" @@ -64,7 +65,7 @@ void PersistentSettings::read(){ } // GlobalSettings::instance().PROCESS_PRIORITY0.update_priority_to_option(); - GlobalSettings::instance().REALTIME_THREAD_PRIORITY0.set_on_this_thread(); + GlobalSettings::instance().PERFORMANCE->REALTIME_THREAD_PRIORITY.set_on_this_thread(); { const JsonArray* array = obj->get_array("50-SwitchKeyboardMapping"); diff --git a/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.cpp b/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.cpp index c89c4b7f1..b037026d0 100644 --- a/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.cpp +++ b/SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.cpp @@ -44,7 +44,7 @@ StreamHistoryOption::StreamHistoryOption() {Resolution::FORCE_1080p, "1080p", "1920 x 1080"}, }, LockMode::UNLOCK_WHILE_RUNNING, - Resolution::MATCH_INPUT + Resolution::FORCE_720p ) , ENCODING_MODE( "Encoding Mode:", diff --git a/SerialPrograms/Source/CommonFramework/Recording/StreamHistorySession.cpp b/SerialPrograms/Source/CommonFramework/Recording/StreamHistorySession.cpp index e205d5e4d..69a40903c 100644 --- a/SerialPrograms/Source/CommonFramework/Recording/StreamHistorySession.cpp +++ b/SerialPrograms/Source/CommonFramework/Recording/StreamHistorySession.cpp @@ -4,11 +4,13 @@ * */ +#include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/Containers/Pimpl.tpp" #include "Common/Cpp/Concurrency/SpinLock.h" #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/VideoPipeline/Backends/VideoFrameQt.h" +#include "CommonFramework/Recording/StreamHistoryOption.h" #if (QT_VERSION_MAJOR == 6) && (QT_VERSION_MINOR >= 8) //#include "StreamHistoryTracker_SaveFrames.h" @@ -38,7 +40,7 @@ struct StreamHistorySession::Data{ Data(Logger& logger) : m_logger(logger) - , m_window(GlobalSettings::instance().STREAM_HISTORY.HISTORY_SECONDS) + , m_window(GlobalSettings::instance().STREAM_HISTORY->HISTORY_SECONDS) , m_audio_format(AudioChannelFormat::NONE) {} }; @@ -133,7 +135,7 @@ void StreamHistorySession::clear(){ data.m_audio_format = AudioChannelFormat::NONE; } void StreamHistorySession::initialize(){ - if (!GlobalSettings::instance().STREAM_HISTORY.enabled()){ + if (!GlobalSettings::instance().STREAM_HISTORY->enabled()){ return; } diff --git a/SerialPrograms/Source/CommonFramework/Recording/StreamRecorder.cpp b/SerialPrograms/Source/CommonFramework/Recording/StreamRecorder.cpp index 64c67e023..3c3f3d491 100644 --- a/SerialPrograms/Source/CommonFramework/Recording/StreamRecorder.cpp +++ b/SerialPrograms/Source/CommonFramework/Recording/StreamRecorder.cpp @@ -20,6 +20,7 @@ #include "Common/Cpp/Concurrency/SpinPause.h" #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/VideoPipeline/Backends/VideoFrameQt.h" +#include "CommonFramework/Recording/StreamHistoryOption.h" #include "StreamRecorder.h" @@ -159,7 +160,9 @@ void StreamRecording::internal_run(){ // recorder.setQuality(QMediaRecorder::LowQuality); // recorder.setQuality(QMediaRecorder::VeryLowQuality); - switch (GlobalSettings::instance().STREAM_HISTORY.RESOLUTION){ + const StreamHistoryOption& settings = GlobalSettings::instance().STREAM_HISTORY; + + switch (settings.RESOLUTION){ case StreamHistoryOption::Resolution::MATCH_INPUT: break; case StreamHistoryOption::Resolution::FORCE_720p: @@ -170,9 +173,9 @@ void StreamRecording::internal_run(){ break; } - switch (GlobalSettings::instance().STREAM_HISTORY.ENCODING_MODE){ + switch (settings.ENCODING_MODE){ case StreamHistoryOption::EncodingMode::FIXED_QUALITY: - switch (GlobalSettings::instance().STREAM_HISTORY.VIDEO_QUALITY){ + switch (settings.VIDEO_QUALITY){ case StreamHistoryOption::VideoQuality::VERY_LOW: recorder.setQuality(QMediaRecorder::VeryLowQuality); break; @@ -191,7 +194,7 @@ void StreamRecording::internal_run(){ } break; case StreamHistoryOption::EncodingMode::FIXED_BITRATE: - recorder.setVideoBitRate(GlobalSettings::instance().STREAM_HISTORY.VIDEO_BITRATE * 1000); + recorder.setVideoBitRate(settings.VIDEO_BITRATE * 1000); recorder.setEncodingMode(QMediaRecorder::AverageBitRateEncoding); break; } diff --git a/SerialPrograms/Source/CommonFramework/SetupSettings.cpp b/SerialPrograms/Source/CommonFramework/SetupSettings.cpp index eae41e304..13e4e4283 100644 --- a/SerialPrograms/Source/CommonFramework/SetupSettings.cpp +++ b/SerialPrograms/Source/CommonFramework/SetupSettings.cpp @@ -8,10 +8,11 @@ #include #include #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) - #if QT_CONFIG(permissions) - #include - #endif +#if QT_CONFIG(permissions) +#include +#endif #endif +#include "Common/Cpp/AbstractLogger.h" #include "Globals.h" #include "GlobalSettingsPanel.h" #include "SetupSettings.h" diff --git a/SerialPrograms/Source/CommonFramework/Tools/ProgramEnvironment.cpp b/SerialPrograms/Source/CommonFramework/Tools/ProgramEnvironment.cpp index dbf0c153f..cdf7fee2c 100644 --- a/SerialPrograms/Source/CommonFramework/Tools/ProgramEnvironment.cpp +++ b/SerialPrograms/Source/CommonFramework/Tools/ProgramEnvironment.cpp @@ -4,15 +4,12 @@ * */ -//#include -#include #include "Common/Cpp/Containers/Pimpl.tpp" -#include "Common/Cpp/Exceptions.h" #include "Common/Cpp/Concurrency/AsyncDispatcher.h" -#include "ClientSource/Connection/BotBase.h" #include "CommonFramework/GlobalSettingsPanel.h" -#include "CommonFramework/Notifications/ProgramInfo.h" #include "CommonFramework/ProgramSession.h" +#include "CommonFramework/Notifications/ProgramInfo.h" +#include "CommonFramework/Options/Environment/PerformanceOptions.h" #include "StatsTracking.h" #include "ProgramEnvironment.h" @@ -32,13 +29,13 @@ struct ProgramEnvironmentData{ : m_program_info(program_info) , m_realtime_dispatcher( [](){ - GlobalSettings::instance().REALTIME_THREAD_PRIORITY0.set_on_this_thread(); + GlobalSettings::instance().PERFORMANCE->REALTIME_THREAD_PRIORITY.set_on_this_thread(); }, 0 ) , m_inference_dispatcher( [](){ - GlobalSettings::instance().INFERENCE_PRIORITY0.set_on_this_thread(); + GlobalSettings::instance().PERFORMANCE->INFERENCE_PRIORITY.set_on_this_thread(); }, 0 ) diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraImplementations.cpp b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraImplementations.cpp index e26da55e5..b9f4e3bd6 100644 --- a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraImplementations.cpp +++ b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraImplementations.cpp @@ -7,6 +7,7 @@ #include //#include "Common/Cpp/PrettyPrint.h" #include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/VideoPipeline/VideoPipelineOptions.h" #include "CameraImplementations.h" //#include @@ -106,7 +107,7 @@ VideoBackendOption::VideoBackendOption() const CameraBackend& get_camera_backend(){ - size_t index = GlobalSettings::instance().VIDEO_BACKEND.current_value(); + size_t index = GlobalSettings::instance().VIDEO_PIPELINE->VIDEO_BACKEND.current_value(); return *CameraBackends::instance().m_backends[index].backend; } diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt5.cpp b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt5.cpp index 5d3d4f15c..d28bd7f43 100644 --- a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt5.cpp +++ b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt5.cpp @@ -13,6 +13,7 @@ #include "Common/Cpp/Exceptions.h" #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/VideoPipeline/CameraOption.h" +#include "CommonFramework/VideoPipeline/VideoPipelineOptions.h" #include "VideoToolsQt5.h" #include "CameraWidgetQt5.h" @@ -255,7 +256,7 @@ VideoSnapshot CameraSession::snapshot(){ std::unique_lock lg(m_lock); // Frame screenshots are disabled. - if (!GlobalSettings::instance().ENABLE_FRAME_SCREENSHOTS){ + if (!GlobalSettings::instance().VIDEO_PIPELINE->ENABLE_FRAME_SCREENSHOTS){ return snapshot_image(); } @@ -381,7 +382,7 @@ void CameraSession::startup(){ this, [this](const QVideoFrame& frame){ WallClock now = current_time(); SpinLockGuard lg(m_frame_lock); - if (GlobalSettings::instance().ENABLE_FRAME_SCREENSHOTS){ + if (GlobalSettings::instance().VIDEO_PIPELINE->ENABLE_FRAME_SCREENSHOTS){ m_last_frame = frame; } m_last_frame_timestamp = now; diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.5.cpp b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.5.cpp index c6032f8e4..d8843dfe2 100644 --- a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.5.cpp +++ b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.5.cpp @@ -21,6 +21,7 @@ #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/GlobalServices.h" #include "CommonFramework/VideoPipeline/CameraOption.h" +#include "CommonFramework/VideoPipeline/VideoPipelineOptions.h" #include "VideoFrameQt.h" #include "MediaServicesQt6.h" #include "CameraWidgetQt6.5.h" @@ -118,7 +119,7 @@ CameraSession::CameraSession(Logger& logger, Resolution default_resolution) , m_stats_conversion("ConvertFrame", "ms", 1000, std::chrono::seconds(10)) // , m_history(GlobalSettings::instance().HISTORY_SECONDS * 1000000) { - uint8_t watchdog_timeout = GlobalSettings::instance().AUTO_RESET_VIDEO_SECONDS; + uint8_t watchdog_timeout = GlobalSettings::instance().VIDEO_PIPELINE->AUTO_RESET_SECONDS; if (watchdog_timeout != 0){ global_watchdog().add(*this, std::chrono::seconds(watchdog_timeout)); } @@ -439,7 +440,7 @@ void CameraSession::on_watchdog_timeout(){ } } - uint8_t watchdog_timeout = GlobalSettings::instance().AUTO_RESET_VIDEO_SECONDS; + uint8_t watchdog_timeout = GlobalSettings::instance().VIDEO_PIPELINE->AUTO_RESET_SECONDS; m_logger.log("No video detected for " + std::to_string(watchdog_timeout) + " seconds...", COLOR_RED); if (watchdog_timeout == 0){ diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/VideoPipelineOptions.h b/SerialPrograms/Source/CommonFramework/VideoPipeline/VideoPipelineOptions.h new file mode 100644 index 000000000..563da2385 --- /dev/null +++ b/SerialPrograms/Source/CommonFramework/VideoPipeline/VideoPipelineOptions.h @@ -0,0 +1,62 @@ +/* Video Pipeline Options + * + * From: https://github.com/PokemonAutomation/Arduino-Source + * + */ + +#ifndef PokemonAutomation_VideoPipeline_VideoPipelineOptions_H +#define PokemonAutomation_VideoPipeline_VideoPipelineOptions_H + +#include "Common/Cpp/Options/GroupOption.h" +#include "Common/Cpp/Options/BooleanCheckBoxOption.h" +#include "Common/Cpp/Options/SimpleIntegerOption.h" +#include "Backends/CameraImplementations.h" + +namespace PokemonAutomation{ + + +class VideoPipelineOptions : public GroupOption{ +public: + VideoPipelineOptions() + : GroupOption( + "Video Pipeline", + LockMode::LOCK_WHILE_RUNNING, + GroupOption::EnableMode::ALWAYS_ENABLED, true + ) +#if QT_VERSION_MAJOR == 5 + , ENABLE_FRAME_SCREENSHOTS( + "Enable Frame Screenshots:
" + "Attempt to use QVideoProbe and QVideoFrame for screenshots.", + LockMode::UNLOCK_WHILE_RUNNING, + true + ) +#endif + , AUTO_RESET_SECONDS( + "Video Auto-Reset:
" + "Attempt to reset the video if this many seconds has elapsed since the last video frame (in order to fix issues with RDP disconnection, etc).
" + "This option is not supported by all video frameworks.", + LockMode::UNLOCK_WHILE_RUNNING, + 5 + ) + { + PA_ADD_OPTION(VIDEO_BACKEND); +#if QT_VERSION_MAJOR == 5 + PA_ADD_OPTION(ENABLE_FRAME_SCREENSHOTS); +#endif + + PA_ADD_OPTION(AUTO_RESET_SECONDS); + } + +public: + VideoBackendOption VIDEO_BACKEND; +#if QT_VERSION_MAJOR == 5 + BooleanCheckBoxOption ENABLE_FRAME_SCREENSHOTS; +#endif + + SimpleIntegerOption AUTO_RESET_SECONDS; +}; + + + +} +#endif diff --git a/SerialPrograms/Source/CommonFramework/Windows/MainWindow.cpp b/SerialPrograms/Source/CommonFramework/Windows/MainWindow.cpp index 2f3cea4f5..ac3e5920c 100644 --- a/SerialPrograms/Source/CommonFramework/Windows/MainWindow.cpp +++ b/SerialPrograms/Source/CommonFramework/Windows/MainWindow.cpp @@ -12,10 +12,13 @@ #include #include #include +#include "Common/Cpp/CpuId/CpuId.h" #include "CommonFramework/Globals.h" #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/Logging/FileWindowLogger.h" #include "CommonFramework/NewVersionCheck.h" +#include "CommonFramework/Options/ResolutionOption.h" +#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" #include "PanelLists.h" #include "WindowTracker.h" #include "ButtonDiagram.h" @@ -38,7 +41,10 @@ MainWindow::MainWindow(QWidget* parent) } this->setWindowIcon(QIcon(QString::fromStdString(RESOURCE_PATH() + "icon.png"))); // QSize window_size = PERSISTENT_SETTINGS().window_size; - resize(GlobalSettings::instance().WINDOW_SIZE.WIDTH, GlobalSettings::instance().WINDOW_SIZE.HEIGHT); + resize( + GlobalSettings::instance().WINDOW_SIZE->WIDTH, + GlobalSettings::instance().WINDOW_SIZE->HEIGHT + ); centralwidget = new QWidget(this); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); setCentralWidget(centralwidget); @@ -185,14 +191,14 @@ MainWindow::MainWindow(QWidget* parent) // Load the program panel specified in the persistent setting. m_program_list->load_persistent_panel(); - GlobalSettings::instance().WINDOW_SIZE.WIDTH.add_listener(*this); - GlobalSettings::instance().WINDOW_SIZE.HEIGHT.add_listener(*this); + GlobalSettings::instance().WINDOW_SIZE->WIDTH.add_listener(*this); + GlobalSettings::instance().WINDOW_SIZE->HEIGHT.add_listener(*this); // cout << "Done constructing" << endl; } MainWindow::~MainWindow(){ close_panel(); - GlobalSettings::instance().WINDOW_SIZE.WIDTH.remove_listener(*this); - GlobalSettings::instance().WINDOW_SIZE.HEIGHT.remove_listener(*this); + GlobalSettings::instance().WINDOW_SIZE->WIDTH.remove_listener(*this); + GlobalSettings::instance().WINDOW_SIZE->HEIGHT.remove_listener(*this); } @@ -202,8 +208,8 @@ void MainWindow::closeEvent(QCloseEvent* event){ } void MainWindow::resizeEvent(QResizeEvent* event){ m_pending_resize = true; - GlobalSettings::instance().WINDOW_SIZE.WIDTH.set(width()); - GlobalSettings::instance().WINDOW_SIZE.HEIGHT.set(height()); + GlobalSettings::instance().WINDOW_SIZE->WIDTH.set(width()); + GlobalSettings::instance().WINDOW_SIZE->HEIGHT.set(height()); m_pending_resize = false; } @@ -276,7 +282,10 @@ void MainWindow::on_idle(){ void MainWindow::value_changed(void* object){ QMetaObject::invokeMethod(this, [this]{ if (!m_pending_resize){ - resize(GlobalSettings::instance().WINDOW_SIZE.WIDTH, GlobalSettings::instance().WINDOW_SIZE.HEIGHT); + resize( + GlobalSettings::instance().WINDOW_SIZE->WIDTH, + GlobalSettings::instance().WINDOW_SIZE->HEIGHT + ); } }); } diff --git a/SerialPrograms/Source/ComputerPrograms/Framework/ComputerProgramSession.cpp b/SerialPrograms/Source/ComputerPrograms/Framework/ComputerProgramSession.cpp index a888a0d7f..c3be6621c 100644 --- a/SerialPrograms/Source/ComputerPrograms/Framework/ComputerProgramSession.cpp +++ b/SerialPrograms/Source/ComputerPrograms/Framework/ComputerProgramSession.cpp @@ -11,6 +11,7 @@ #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/Notifications/ProgramInfo.h" #include "CommonFramework/Notifications/ProgramNotifications.h" +#include "CommonFramework/Options/Environment/PerformanceOptions.h" #include "ComputerProgramOption.h" #include "ComputerProgramSession.h" @@ -80,7 +81,7 @@ void ComputerProgramSession::internal_stop_program(){ } } void ComputerProgramSession::internal_run_program(){ - GlobalSettings::instance().REALTIME_THREAD_PRIORITY0.set_on_this_thread(); + GlobalSettings::instance().PERFORMANCE->REALTIME_THREAD_PRIORITY.set_on_this_thread(); m_option.options().reset_state(); ProgramInfo program_info( diff --git a/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp b/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp index edf749729..407d4e20e 100644 --- a/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp +++ b/SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp @@ -28,7 +28,11 @@ DiscordIntegrationSettingsOption::~DiscordIntegrationSettingsOption(){ this->remove_listener(*this); } DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption() - : GroupOption("Discord Integration Settings", LockMode::LOCK_WHILE_RUNNING) + : GroupOption( + "Discord Integration Settings", + LockMode::LOCK_WHILE_RUNNING, + GroupOption::EnableMode::DEFAULT_DISABLED + ) // , 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/DiscordWebhook.cpp b/SerialPrograms/Source/Integrations/DiscordWebhook.cpp index aefe4de10..f165344b9 100644 --- a/SerialPrograms/Source/Integrations/DiscordWebhook.cpp +++ b/SerialPrograms/Source/Integrations/DiscordWebhook.cpp @@ -120,7 +120,7 @@ void DiscordWebhookSender::throttle(){ while (!m_sent.empty() && m_sent[0] + duration < now){ m_sent.pop_front(); } - if (!m_sent.empty() && m_sent.size() >= GlobalSettings::instance().DISCORD.webhooks.sends_per_second){ + if (!m_sent.empty() && m_sent.size() >= GlobalSettings::instance().DISCORD->webhooks.sends_per_second){ m_logger.log("Throttling webhook messages due to rate limit...", COLOR_RED); std::unique_lock lg(m_lock); m_cv.wait_for( diff --git a/SerialPrograms/Source/Integrations/DppIntegration/DppClient.cpp b/SerialPrograms/Source/Integrations/DppIntegration/DppClient.cpp index cf52777c7..feb3313cb 100644 --- a/SerialPrograms/Source/Integrations/DppIntegration/DppClient.cpp +++ b/SerialPrograms/Source/Integrations/DppIntegration/DppClient.cpp @@ -137,7 +137,13 @@ void Client::run(const std::string& token){ Handler::initialize(*m_bot.get(), *m_handler.get()); m_bot->set_websocket_protocol(websocket_protocol_t::ws_etf); m_bot->start(st_return); - m_bot->set_presence(presence(presence_status::ps_online, activity_type::at_game, (std::string)GlobalSettings::instance().DISCORD.integration.game_status)); + m_bot->set_presence( + presence( + presence_status::ps_online, + activity_type::at_game, + (std::string)GlobalSettings::instance().DISCORD->integration.game_status + ) + ); m_is_connected.store(true, std::memory_order_release); }catch (std::exception& e){ Handler::log_dpp("DPP thew an exception: " + (std::string)e.what(), "run()", ll_critical); diff --git a/SerialPrograms/Source/Integrations/DppIntegration/DppCommandHandler.cpp b/SerialPrograms/Source/Integrations/DppIntegration/DppCommandHandler.cpp index 73e01c18b..75b5480c4 100644 --- a/SerialPrograms/Source/Integrations/DppIntegration/DppCommandHandler.cpp +++ b/SerialPrograms/Source/Integrations/DppIntegration/DppCommandHandler.cpp @@ -28,8 +28,8 @@ void Handler::initialize(cluster& bot, commandhandler& handler){ }); owner = bot.current_application_get_sync().owner; - auto cmd_type = GlobalSettings::instance().DISCORD.integration.command_type.get(); - std::string prefix = GlobalSettings::instance().DISCORD.integration.command_prefix; + auto cmd_type = GlobalSettings::instance().DISCORD->integration.command_type.get(); + std::string prefix = GlobalSettings::instance().DISCORD->integration.command_prefix; if (cmd_type == DiscordIntegrationSettingsOption::CommandType::MessageCommands && !prefix.empty()){ handler.add_prefix(prefix); @@ -72,7 +72,7 @@ void Handler::initialize(cluster& bot, commandhandler& handler){ bot.on_message_create([&handler](const message_create_t& event){ std::string content = event.msg.content; if (!event.msg.author.is_bot() && handler.string_has_prefix(content)){ - auto channels = GlobalSettings::instance().DISCORD.integration.channels.command_channels(); + auto channels = GlobalSettings::instance().DISCORD->integration.channels.command_channels(); auto channel = std::find(channels.begin(), channels.end(), std::to_string(event.msg.channel_id)); if (channel != channels.end()){ handler.route(event); @@ -82,7 +82,7 @@ void Handler::initialize(cluster& bot, commandhandler& handler){ bot.on_slashcommand([&handler](const slashcommand_t& event){ if (!event.command.usr.is_bot() && handler.slash_commands_enabled){ - auto channels = GlobalSettings::instance().DISCORD.integration.channels.command_channels(); + auto channels = GlobalSettings::instance().DISCORD->integration.channels.command_channels(); auto channel = std::find(channels.begin(), channels.end(), std::to_string(event.command.channel_id)); if (channel != channels.end()){ handler.route(event); @@ -208,7 +208,7 @@ void Handler::create_unified_commands(commandhandler& handler){ [&handler, this](const std::string& command, const parameter_list_t&, command_source src){ log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); message message; - message.set_content((std::string)GlobalSettings::instance().DISCORD.integration.hello_message); + message.set_content((std::string)GlobalSettings::instance().DISCORD->integration.hello_message); if (src.message_event.has_value()){ message.set_reference(src.message_event.value().msg.id); } @@ -223,7 +223,7 @@ void Handler::create_unified_commands(commandhandler& handler){ }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src){ log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id){ + if (!GlobalSettings::instance().DISCORD->integration.allow_buttons_from_users && src.issuer.id != owner.id){ handler.reply(message("You do not have permission to use this command."), src); return; } @@ -254,7 +254,7 @@ void Handler::create_unified_commands(commandhandler& handler){ }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src){ log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id){ + if (!GlobalSettings::instance().DISCORD->integration.allow_buttons_from_users && src.issuer.id != owner.id){ handler.reply(message("You do not have permission to use this command."), src); return; } @@ -285,7 +285,7 @@ void Handler::create_unified_commands(commandhandler& handler){ }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src){ log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id){ + if (!GlobalSettings::instance().DISCORD->integration.allow_buttons_from_users && src.issuer.id != owner.id){ handler.reply(message("You do not have permission to use this command."), src); return; } @@ -316,7 +316,7 @@ void Handler::create_unified_commands(commandhandler& handler){ }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src){ log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id){ + if (!GlobalSettings::instance().DISCORD->integration.allow_buttons_from_users && src.issuer.id != owner.id){ handler.reply(message("You do not have permission to use this command."), src); return; } @@ -380,7 +380,7 @@ void Handler::create_unified_commands(commandhandler& handler){ }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src){ log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id){ + if (!GlobalSettings::instance().DISCORD->integration.allow_buttons_from_users && src.issuer.id != owner.id){ handler.reply(message("You do not have permission to use this command."), src); return; } @@ -443,7 +443,7 @@ void Handler::create_unified_commands(commandhandler& handler){ }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src){ log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id){ + if (!GlobalSettings::instance().DISCORD->integration.allow_buttons_from_users && src.issuer.id != owner.id){ handler.reply(message("You do not have permission to use this command."), src); return; } @@ -506,7 +506,7 @@ void Handler::create_unified_commands(commandhandler& handler){ }, [&handler, this](const std::string& command, const parameter_list_t& params, command_source src){ log_dpp("Executing " + command + "...", "Unified Command Handler", ll_info); - if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && src.issuer.id != owner.id){ + if (!GlobalSettings::instance().DISCORD->integration.allow_buttons_from_users && src.issuer.id != owner.id){ handler.reply(message("You do not have permission to use this command."), src); return; } @@ -564,7 +564,7 @@ void Handler::create_unified_commands(commandhandler& handler){ for (auto& cmd : commands){ std::string name = cmd.first; log_dpp(name, "help command", ll_info); - if (!GlobalSettings::instance().DISCORD.integration.allow_buttons_from_users && + if (!GlobalSettings::instance().DISCORD->integration.allow_buttons_from_users && src.issuer.id != owner.id && name != "hi" && name != "ping" && name != "about" && name != "status" && name != "help" ){ continue; diff --git a/SerialPrograms/Source/Integrations/DppIntegration/DppUtility.cpp b/SerialPrograms/Source/Integrations/DppIntegration/DppUtility.cpp index bb1a5d1f6..7d36fe2d6 100644 --- a/SerialPrograms/Source/Integrations/DppIntegration/DppUtility.cpp +++ b/SerialPrograms/Source/Integrations/DppIntegration/DppUtility.cpp @@ -4,6 +4,7 @@ #include #include #include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/Logging/Logger.h" using namespace dpp; namespace PokemonAutomation{ diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp b/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp index 9b15e5994..1bb94d6db 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp @@ -9,9 +9,10 @@ #include "Common/Cpp/Containers/FixedLimitVector.tpp" #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/Exceptions/ProgramFinishedException.h" -#include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/Notifications/ProgramInfo.h" #include "CommonFramework/Notifications/ProgramNotifications.h" +#include "CommonFramework/Options/Environment/SleepSuppressOption.h" +#include "CommonFramework/Options/Environment/PerformanceOptions.h" #include "CommonFramework/Tools/BlackBorderCheck.h" #include "NintendoSwitch_MultiSwitchProgramOption.h" #include "NintendoSwitch_MultiSwitchProgramSession.h" @@ -118,10 +119,10 @@ void MultiSwitchProgramSession::internal_stop_program(){ } } void MultiSwitchProgramSession::internal_run_program(){ - GlobalSettings::instance().REALTIME_THREAD_PRIORITY0.set_on_this_thread(); + GlobalSettings::instance().PERFORMANCE->REALTIME_THREAD_PRIORITY.set_on_this_thread(); m_option.options().reset_state(); - SleepSuppressScope sleep_scope(GlobalSettings::instance().SLEEP_SUPPRESS.PROGRAM_RUNNING); + SleepSuppressScope sleep_scope(GlobalSettings::instance().SLEEP_SUPPRESS->PROGRAM_RUNNING); // Lock the system to prevent the # of Switches from changing. std::lock_guard lg(m_system); diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp b/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp index e810d80e5..c8c8adb58 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp @@ -8,7 +8,8 @@ #include "Common/Cpp/Concurrency/SpinPause.h" #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/Exceptions/ProgramFinishedException.h" -#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonFramework/Options/Environment/SleepSuppressOption.h" +#include "CommonFramework/Options/Environment/PerformanceOptions.h" #include "CommonFramework/Notifications/ProgramInfo.h" #include "CommonFramework/Notifications/ProgramNotifications.h" #include "CommonFramework/Tools/BlackBorderCheck.h" @@ -91,10 +92,10 @@ void SingleSwitchProgramSession::internal_stop_program(){ m_system.serial_session().reset(); } void SingleSwitchProgramSession::internal_run_program(){ - GlobalSettings::instance().REALTIME_THREAD_PRIORITY0.set_on_this_thread(); + GlobalSettings::instance().PERFORMANCE->REALTIME_THREAD_PRIORITY.set_on_this_thread(); m_option.options().reset_state(); - SleepSuppressScope sleep_scope(GlobalSettings::instance().SLEEP_SUPPRESS.PROGRAM_RUNNING); + SleepSuppressScope sleep_scope(GlobalSettings::instance().SLEEP_SUPPRESS->PROGRAM_RUNNING); ProgramInfo program_info( identifier(), diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_VirtualController.cpp b/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_VirtualController.cpp index ebebab51c..26b777431 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_VirtualController.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_VirtualController.cpp @@ -4,12 +4,12 @@ * */ -#include #include #include "Common/Cpp/Exceptions.h" #include "Common/Cpp/PanicDump.h" #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/Exceptions/ProgramFinishedException.h" +#include "CommonFramework/Options/Environment/PerformanceOptions.h" #include "NintendoSwitch/Commands/NintendoSwitch_Messages_PushButtons.h" #include "NintendoSwitch_VirtualController.h" @@ -165,7 +165,7 @@ bool VirtualController::on_key_release(Qt::Key key){ void VirtualController::thread_loop(){ - GlobalSettings::instance().REALTIME_THREAD_PRIORITY0.set_on_this_thread(); + GlobalSettings::instance().PERFORMANCE->REALTIME_THREAD_PRIORITY.set_on_this_thread(); VirtualControllerState last; bool last_neutral = true; diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_CommandRow.cpp b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_CommandRow.cpp index 198c562fe..b0a205546 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_CommandRow.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_CommandRow.cpp @@ -8,6 +8,7 @@ #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/Options/Environment/ThemeSelectorOption.h" #include "CommonFramework/VideoPipeline/UI/VideoOverlayWidget.h" +#include "CommonFramework/Recording/StreamHistoryOption.h" #include "NintendoSwitch_CommandRow.h" namespace PokemonAutomation{ @@ -106,7 +107,7 @@ CommandRow::CommandRow( ); #if (QT_VERSION_MAJOR == 6) && (QT_VERSION_MINOR >= 8) - if (GlobalSettings::instance().STREAM_HISTORY.enabled()){ + if (GlobalSettings::instance().STREAM_HISTORY->enabled()){ m_video_button = new QPushButton("Video Capture", this); command_row->addWidget(m_video_button, 2); connect( diff --git a/SerialPrograms/Source/PokemonLA/Inference/Battles/PokemonLA_BattleSpriteWatcher.cpp b/SerialPrograms/Source/PokemonLA/Inference/Battles/PokemonLA_BattleSpriteWatcher.cpp index 74fa1d7cd..a3f6f1940 100644 --- a/SerialPrograms/Source/PokemonLA/Inference/Battles/PokemonLA_BattleSpriteWatcher.cpp +++ b/SerialPrograms/Source/PokemonLA/Inference/Battles/PokemonLA_BattleSpriteWatcher.cpp @@ -4,16 +4,16 @@ * */ +#include #include "Common/Cpp/AbstractLogger.h" #include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" #include "CommonFramework/ImageTools/ImageStats.h" #include "CommonFramework/Tools/DebugDumper.h" #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" #include "PokemonLA_BattleSpriteWatcher.h" -#include #include -#include using std::cout; using std::endl; diff --git a/SerialPrograms/Source/PokemonLA/Programs/General/PokemonLA_RamanasIslandCombee.cpp b/SerialPrograms/Source/PokemonLA/Programs/General/PokemonLA_RamanasIslandCombee.cpp index ef73735b3..889b84f97 100644 --- a/SerialPrograms/Source/PokemonLA/Programs/General/PokemonLA_RamanasIslandCombee.cpp +++ b/SerialPrograms/Source/PokemonLA/Programs/General/PokemonLA_RamanasIslandCombee.cpp @@ -114,7 +114,7 @@ void RamanasCombeeFinder::check_tree_no_stop(SingleSwitchProgramEnvironment& env context.wait_for_all_requests(); disable_shiny_sound(context); // Throw pokemon - pbf_press_button(context, BUTTON_ZR, (0.5 * TICKS_PER_SECOND), 1.5 * TICKS_PER_SECOND); + pbf_press_button(context, BUTTON_ZR, (uint16_t)(0.5 * TICKS_PER_SECOND), (uint16_t)(1.5 * TICKS_PER_SECOND)); context.wait_for_all_requests(); env.current_stats().trees++; env.update_stats(); diff --git a/SerialPrograms/Source/PokemonLA/Programs/ShinyHunting/PokemonLA_BurmyFinder.cpp b/SerialPrograms/Source/PokemonLA/Programs/ShinyHunting/PokemonLA_BurmyFinder.cpp index bbd5c5c8f..7b805392b 100644 --- a/SerialPrograms/Source/PokemonLA/Programs/ShinyHunting/PokemonLA_BurmyFinder.cpp +++ b/SerialPrograms/Source/PokemonLA/Programs/ShinyHunting/PokemonLA_BurmyFinder.cpp @@ -27,6 +27,10 @@ #include "PokemonLA/Programs/PokemonLA_LeapPokemonActions.h" #include "CommonFramework/GlobalSettingsPanel.h" +#ifdef _MSC_VER +#pragma warning(disable:4244) // double -> int precision loss +#endif + namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonLA{ diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index efdb11fbd..7b041aeaf 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -9,6 +9,7 @@ #include "CommonFramework/Notifications/ProgramNotifications.h" #include "CommonFramework/Tools/StatsTracking.h" #include "CommonFramework/Tools/VideoResolutionCheck.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" #include "Pokemon/Pokemon_Strings.h" #include "PokemonSwSh/Inference/PokemonSwSh_IvJudgeReader.h" diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h index e09dea12c..26a1ec228 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h @@ -8,12 +8,14 @@ #define PokemonAutomation_PokemonSV_AutoStory_H #include +#include "Common/Cpp/Options/StaticTextOption.h" +#include "Common/Cpp/Options/SimpleIntegerOption.h" +#include "Common/Cpp/Options/FloatingPointOption.h" #include "Common/Cpp/Options/EnumDropdownOption.h" #include "CommonFramework/Notifications/EventNotificationsTable.h" #include "CommonFramework/Options/LanguageOCROption.h" #include "CommonFramework/Options/StringSelectOption.h" #include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h" -#include "Common/NintendoSwitch/NintendoSwitch_ControllerDefs.h" #include "PokemonSV/Programs/PokemonSV_Navigation.h" #include "PokemonSV_AutoStoryTools.h" @@ -100,22 +102,22 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste BooleanCheckBoxOption ENABLE_TEST_REALIGN; EnumDropdownOption REALIGN_MODE; - SimpleIntegerOption X_REALIGN; - SimpleIntegerOption Y_REALIGN; + SimpleIntegerOption X_REALIGN; + SimpleIntegerOption Y_REALIGN; SimpleIntegerOption REALIGN_DURATION; BooleanCheckBoxOption ENABLE_MISC_TEST; SimpleIntegerOption FORWARD_TICKS; BooleanCheckBoxOption TEST_PBF_LEFT_JOYSTICK; - SimpleIntegerOption X_MOVE; - SimpleIntegerOption Y_MOVE; + SimpleIntegerOption X_MOVE; + SimpleIntegerOption Y_MOVE; SimpleIntegerOption HOLD_TICKS; SimpleIntegerOption RELEASE_TICKS; BooleanCheckBoxOption TEST_PBF_LEFT_JOYSTICK2; - SimpleIntegerOption X_MOVE2; - SimpleIntegerOption Y_MOVE2; + SimpleIntegerOption X_MOVE2; + SimpleIntegerOption Y_MOVE2; SimpleIntegerOption HOLD_TICKS2; SimpleIntegerOption RELEASE_TICKS2; diff --git a/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp b/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp index 1d34b350e..715d70ddd 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp @@ -9,6 +9,7 @@ #include "CommonFramework/Exceptions/ProgramFinishedException.h" #include "CommonFramework/Exceptions/FatalProgramException.h" #include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" #include "CommonFramework/Notifications/ProgramNotifications.h" #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Tools/StatsTracking.h" @@ -427,8 +428,8 @@ void EggAutonomous::hatch_eggs_full_routine(SingleSwitchProgramEnvironment& env, // Check each hatched baby whether they will be kept. // If yes, move them to the keep box. // Otherwise, release them or move them into box in case we will reset game later. - for(int i = 0; i < num_eggs_in_party; i++){ - process_one_baby(env, context, i, num_eggs_in_party); + for(uint8_t i = 0; i < num_eggs_in_party; i++){ + process_one_baby(env, context, i, (uint8_t)num_eggs_in_party); } // If the auto save mode is AfterStartAndKeep, which allows resetting the game in case no eggs in the box are kept, @@ -505,11 +506,11 @@ void EggAutonomous::hatch_eggs_full_routine(SingleSwitchProgramEnvironment& env, // While in box system and the current box is egg box, process one baby pokemon in party // Return true if the program finds a pokemon to keep -void EggAutonomous::process_one_baby(SingleSwitchProgramEnvironment& env, BotBaseContext& context, int egg_index, int num_eggs_in_party){ +void EggAutonomous::process_one_baby(SingleSwitchProgramEnvironment& env, BotBaseContext& context, uint8_t egg_index, uint8_t num_eggs_in_party){ auto& stats = env.current_stats(); // Check each pokemon from bottom to top. In this way we can reliably detect end of releasing the pokemon. - const int party_row = num_eggs_in_party - egg_index + (HAS_CLONE_RIDE_POKEMON ? 1 : 0); + uint8_t party_row = num_eggs_in_party - egg_index + (HAS_CLONE_RIDE_POKEMON ? 1 : 0); context.wait_for_all_requests(); move_box_cursor(env.program_info(), env.console, context, BoxCursorLocation::PARTY, party_row, 0); diff --git a/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.h b/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.h index 26b7b2f74..938afc5ed 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.h +++ b/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.h @@ -53,7 +53,7 @@ class EggAutonomous : public SingleSwitchProgramInstance{ int picnic_party_to_hatch_party(SingleSwitchProgramEnvironment& env, BotBaseContext& context); - void process_one_baby(SingleSwitchProgramEnvironment& env, BotBaseContext& context, int egg_index, int num_eggs_in_party); + void process_one_baby(SingleSwitchProgramEnvironment& env, BotBaseContext& context, uint8_t egg_index, uint8_t num_eggs_in_party); bool move_pokemon_to_keep(SingleSwitchProgramEnvironment& env, BotBaseContext& context, uint8_t pokemon_row_in_party); diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_AuctionFarmer.cpp b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_AuctionFarmer.cpp index b96f4b38c..1b92bab70 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_AuctionFarmer.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_AuctionFarmer.cpp @@ -203,10 +203,22 @@ std::vector> AuctionFarmer::check_offers( // read dialog bubble for (ImageFloatBox dialog_box : dialog_boxes){ +// std::cout << "dialog_box: [" +// << dialog_box.x << "," << dialog_box.y << "] - [" +// << dialog_box.width << "," << dialog_box.height << "]" << std::endl; + OverlayBoxScope dialog_overlay(env.console, dialog_box, COLOR_DARK_BLUE); ImageFloatBox offer_box(0.05, 0.02, 0.90, 0.49); - ImageFloatBox translated_offer_box = translate_to_parent(screen, dialog_box, floatbox_to_pixelbox(dialog_box.width, dialog_box.height, offer_box)); + ImageFloatBox translated_offer_box = translate_to_parent( + screen, + dialog_box, + // TODO: Fix these casts as they always go to zero. + floatbox_to_pixelbox((size_t)dialog_box.width, (size_t)dialog_box.height, offer_box) + ); +// std::cout << "translated_offer_box: [" +// << translated_offer_box.x << "," << translated_offer_box.y << "] - [" +// << translated_offer_box.width << "," << translated_offer_box.height << "]" << std::endl; OverlayBoxScope offer_overlay(env.console, translated_offer_box, COLOR_BLUE); ImageViewRGB32 dialog = extract_box_reference(screen, dialog_box); @@ -275,8 +287,8 @@ void AuctionFarmer::move_to_auctioneer(SingleSwitchProgramEnvironment& env, BotB // Dialog is the only piece of orientation we have, so the goal is to put it into the center of the screen so we know in which direction the character walks. // This is only used for multiple NPCs. void AuctionFarmer::move_dialog_to_center(SingleSwitchProgramEnvironment& env, BotBaseContext& context, AuctionOffer wanted){ - float center_x = 0.0f; - float center_y = 0.0f; + double center_x = 0.0f; + double center_y = 0.0f; bool offer_visible = false; while (center_x < 0.43 || center_x > 0.57){ @@ -298,8 +310,8 @@ void AuctionFarmer::move_dialog_to_center(SingleSwitchProgramEnvironment& env, B break; } - uint8_t distance_x = (uint16_t)((center_x) * 255); - uint8_t distance_y = (uint16_t)((center_y * 255)); + uint8_t distance_x = (uint8_t)(center_x * 255); + uint8_t distance_y = (uint8_t)(center_y * 255); env.console.log(std::to_string(distance_x)); env.console.log(std::to_string(distance_y)); diff --git a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.cpp index 56585fa1f..869b34301 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_MaterialFarmerTools.cpp @@ -662,7 +662,7 @@ void fly_from_paldea_to_blueberry_entrance(const ProgramInfo& info, ConsoleHandl // move cursor to Blueberry academy fast travel point (up-left) // try different magnitudes of cursor push with each failure. int push_magnitude = 81 + adjustment_table[numAttempts]; - pbf_move_left_joystick(context, 0, 0, push_magnitude, 50); + pbf_move_left_joystick(context, 0, 0, (uint16_t)push_magnitude, 50); // press A to fly to Blueberry academy isFlySuccessful = fly_to_overworld_from_map(info, console, context, true); @@ -840,7 +840,7 @@ void fly_from_blueberry_to_north_province_3(const ProgramInfo& info, ConsoleHand // move cursor up-left // try different magnitudes of cursor push with each failure. int push_magnitude = 168 + adjustment_table[numAttempts]; - pbf_move_left_joystick(context, 112, 0, push_magnitude, 50); + pbf_move_left_joystick(context, 112, 0, (uint16_t)push_magnitude, 50); // press A to fly to North province area 3 isFlySuccessful = fly_to_overworld_from_map(info, console, context, true); diff --git a/SerialPrograms/Source/PokemonSV/Programs/General/PokemonSV_SizeChecker.cpp b/SerialPrograms/Source/PokemonSV/Programs/General/PokemonSV_SizeChecker.cpp index aec075bb1..e77f77b4e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/General/PokemonSV_SizeChecker.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/General/PokemonSV_SizeChecker.cpp @@ -7,7 +7,6 @@ #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/InferenceInfra/InferenceRoutines.h" #include "CommonFramework/Notifications/ProgramNotifications.h" -#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Tools/StatsTracking.h" #include "CommonFramework/Tools/VideoResolutionCheck.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -134,7 +133,7 @@ void SizeChecker::enter_check_mode(SingleSwitchProgramEnvironment& env, BotBaseC -void SizeChecker::exit_check_mode(SingleSwitchProgramEnvironment& env, BotBaseContext& context, struct VideoSnapshot screen){ +void SizeChecker::exit_check_mode(SingleSwitchProgramEnvironment& env, BotBaseContext& context, VideoSnapshot screen){ SizeChecker_Descriptor::Stats& stats = env.current_stats(); env.console.log("Check size and exit box mode..."); WallClock start = current_time(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/General/PokemonSV_SizeChecker.h b/SerialPrograms/Source/PokemonSV/Programs/General/PokemonSV_SizeChecker.h index 2188c573e..459e10ffa 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/General/PokemonSV_SizeChecker.h +++ b/SerialPrograms/Source/PokemonSV/Programs/General/PokemonSV_SizeChecker.h @@ -9,6 +9,7 @@ #include "Common/Cpp/Options/SimpleIntegerOption.h" #include "CommonFramework/Notifications/EventNotificationsTable.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" #include "NintendoSwitch/Options/NintendoSwitch_GoHomeWhenDoneOption.h" #include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" @@ -38,7 +39,7 @@ class SizeChecker : public SingleSwitchProgramInstance{ private: void enter_check_mode(SingleSwitchProgramEnvironment& env, BotBaseContext& context); - void exit_check_mode(SingleSwitchProgramEnvironment& env, BotBaseContext& context, struct VideoSnapshot screen); + void exit_check_mode(SingleSwitchProgramEnvironment& env, BotBaseContext& context, VideoSnapshot screen); private: GoHomeWhenDoneOption GO_HOME_WHEN_DONE; diff --git a/SerialPrograms/Source/PokemonSV/Programs/ItemPrinter/PokemonSV_ItemPrinterRNG.cpp b/SerialPrograms/Source/PokemonSV/Programs/ItemPrinter/PokemonSV_ItemPrinterRNG.cpp index a25472c70..89ca26c27 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/ItemPrinter/PokemonSV_ItemPrinterRNG.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/ItemPrinter/PokemonSV_ItemPrinterRNG.cpp @@ -922,7 +922,7 @@ uint32_t ItemPrinterRNG::calc_num_jobs_using_happiny_dust( num_happiny_dust_can_use = num_happiny_dust_can_use < 0 ? 0 : num_happiny_dust_can_use; // assume 62% value for Happiny Dust to account for item printer wasteage. - uint32_t num_print_jobs = num_happiny_dust_can_use * 0.62; // truncate the float back to int + uint32_t num_print_jobs = (uint32_t)(num_happiny_dust_can_use * 0.62); // truncate the float back to int env.console.log("Number of Happiny Dust we have: " + std::to_string(num_happiny_dust)); env.console.log("Number of Happiny Dust we can use (with some safety margins): " + std::to_string(num_happiny_dust_can_use)); env.console.log("Number of print jobs we can do before material farming: " + std::to_string(num_print_jobs)); diff --git a/SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichRoutines.cpp b/SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichRoutines.cpp index e33664c03..8b684d25a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichRoutines.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Sandwiches/PokemonSV_SandwichRoutines.cpp @@ -278,8 +278,8 @@ bool move_then_recover_sandwich_hand_position( ){ console.log("center the cursor: move towards bottom right, then left slightly."); - int num_ticks_to_move_1 = TICKS_PER_SECOND*4; - int num_ticks_to_move_2 = 100; + uint16_t num_ticks_to_move_1 = TICKS_PER_SECOND*4; + uint16_t num_ticks_to_move_2 = 100; // center the cursor if(SandwichHandType::FREE == hand_type){ @@ -292,10 +292,10 @@ bool move_then_recover_sandwich_hand_position( else if(SandwichHandType::GRABBING == hand_type){ // center the cursor while holding the A button, so you don't drop the ingredient. - int num_ticks_to_move_total = num_ticks_to_move_1 + num_ticks_to_move_2; - int num_ticks_to_wait = num_ticks_to_move_total + TICKS_PER_SECOND; // add one extra second of waiting - int num_miliseconds_to_wait = (num_ticks_to_wait*1000)/TICKS_PER_SECOND; - int num_ticks_to_hold_A = num_ticks_to_wait + TICKS_PER_SECOND*10; // hold A for extra 10 seconds + uint16_t num_ticks_to_move_total = num_ticks_to_move_1 + num_ticks_to_move_2; + uint16_t num_ticks_to_wait = num_ticks_to_move_total + TICKS_PER_SECOND; // add one extra second of waiting + uint16_t num_miliseconds_to_wait = (num_ticks_to_wait*1000)/TICKS_PER_SECOND; + uint16_t num_ticks_to_hold_A = num_ticks_to_wait + TICKS_PER_SECOND*10; // hold A for extra 10 seconds // the A button hold will be overwritten on the next move_session.dispatch, in the main function move_session.dispatch([&](BotBaseContext& context){ diff --git a/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-Scatterbug.cpp b/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-Scatterbug.cpp index 9f7efed7e..b380ee8cf 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-Scatterbug.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/ShinyHunting/PokemonSV_ShinyHunt-Scatterbug.cpp @@ -222,10 +222,14 @@ void ShinyHuntScatterbug::program(SingleSwitchProgramEnvironment& env, BotBaseCo // Whenever a battle happens, we check shinies and handle battle according to user setting. After battle ends, move // back to PokeCenter to start the `action` again. // `action` must be an action starting at the PokeCenter -void ShinyHuntScatterbug::handle_battles_and_back_to_pokecenter(SingleSwitchProgramEnvironment& env, BotBaseContext& context, - std::function&& action) -{ - assert(m_encounter_tracker != nullptr); +void ShinyHuntScatterbug::handle_battles_and_back_to_pokecenter( + SingleSwitchProgramEnvironment& env, + BotBaseContext& context, + std::function&& action +){ + if (m_encounter_tracker == nullptr){ + throw InternalProgramError(&env.logger(), PA_CURRENT_FUNCTION, "m_encounter_tracker == nullptr"); + } bool action_finished = false; bool first_iteration = true; diff --git a/SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.cpp b/SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.cpp index 31d3221a2..61d04bb83 100644 --- a/SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.cpp +++ b/SerialPrograms/Source/PokemonSwSh/Inference/PokemonSwSh_SelectionArrowFinder.cpp @@ -9,6 +9,7 @@ #include "Kernels/Waterfill/Kernels_Waterfill_Session.h" #include "CommonFramework/Globals.h" #include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/Logging/Logger.h" #include "CommonFramework/Notifications/ProgramInfo.h" #include "CommonFramework/ImageTools/ImageBoxes.h" #include "CommonFramework/ImageTools/BinaryImage_FilterRgb32.h" @@ -102,7 +103,7 @@ void SelectionArrowFinder::make_overlays(VideoOverlaySet& items) const{ items.add(COLOR_YELLOW, m_box); } bool SelectionArrowFinder::detect(const ImageViewRGB32& screen){ - const float screen_scale = screen.height() / 1080.0; + const double screen_scale = screen.height() / 1080.0; // Smallest arrow takes at least 600 pixels on 1920x1080 screen. const size_t min_arrow_area = size_t(600.0 * screen_scale * screen_scale); std::vector arrows = find_selection_arrows( @@ -187,7 +188,7 @@ RotomPhoneMenuArrowFinder::RotomPhoneMenuArrowFinder(VideoOverlay& overlay) } int RotomPhoneMenuArrowFinder::detect(const ImageViewRGB32& screen){ - const float screen_scale = screen.height() / 1080.0; + const double screen_scale = screen.height() / 1080.0; const size_t min_arrow_area = size_t(1400 * screen_scale * screen_scale); for (size_t i_row = 0; i_row < 2; i_row++){ for (size_t j_col = 0; j_col < 5; j_col++){ diff --git a/SerialPrograms/Source/PokemonSwSh/Programs/Hosting/PokemonSwSh_LobbyWait.h b/SerialPrograms/Source/PokemonSwSh/Programs/Hosting/PokemonSwSh_LobbyWait.h index 19ab77159..57cc651a3 100644 --- a/SerialPrograms/Source/PokemonSwSh/Programs/Hosting/PokemonSwSh_LobbyWait.h +++ b/SerialPrograms/Source/PokemonSwSh/Programs/Hosting/PokemonSwSh_LobbyWait.h @@ -80,7 +80,7 @@ static RaidLobbyState raid_lobby_wait( } pbf_wait( context, - std::min( + (uint16_t)std::min( lobby_wait_delay - time_elapsed, (uint32_t)TICKS_PER_SECOND ) @@ -100,7 +100,7 @@ static RaidLobbyState raid_lobby_wait( } pbf_wait( context, - std::min( + (uint16_t)std::min( FULL_LOBBY_TIMER - time_elapsed, (uint32_t)TICKS_PER_SECOND )