Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,13 @@ GlobalSettings::GlobalSettings()
PA_ADD_OPTION(STATS_FILE);
PA_ADD_OPTION(TEMP_FOLDER);
PA_ADD_OPTION(THEME);
PA_ADD_OPTION(USE_PADDLE_OCR);
PA_ADD_OPTION(USE_GPU_FOR_ML_INFERENCE);

// gated behind Dev mode. see GlobalSettings::load_json
PA_ADD_OPTION(USE_PADDLE_OCR);
PA_ADD_OPTION(RESOURCE_DOWNLOAD_TABLE);
PA_ADD_OPTION(DOWNLOAD_ERROR);

@Mysticial Mysticial Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we should gate this table behind dev mode for now.


PA_ADD_OPTION(WINDOW_SIZE);
PA_ADD_OPTION(LOG_WINDOW_SIZE);
PA_ADD_OPTION(LOG_WINDOW_STARTUP);
Expand All @@ -289,6 +294,8 @@ GlobalSettings::GlobalSettings()
PA_ADD_STATIC(m_advanced_options);
PA_ADD_OPTION(LOG_EVERYTHING);
PA_ADD_OPTION(SAVE_DEBUG_IMAGES);

// gated behind Dev mode. see GlobalSettings::load_json
PA_ADD_OPTION(SAVE_DEBUG_VIDEOS_ON_SWITCH);
// PA_ADD_OPTION(NAUGHTY_MODE);
// PA_ADD_OPTION(HIDE_NOTIF_DISCORD_LINK);
Expand All @@ -298,6 +305,8 @@ GlobalSettings::GlobalSettings()
PA_ADD_OPTION(AUDIO_PIPELINE);
PA_ADD_OPTION(VIDEO_PIPELINE);
PA_ADD_OPTION(COMMAND_QUEUE_LIMIT);

// gated behind Dev mode. see GlobalSettings::load_json
PA_ADD_OPTION(DEVICE_LOGGING_FLAG);

PA_ADD_OPTION(ENABLE_LIFETIME_SANITIZER0);
Expand Down Expand Up @@ -327,6 +336,8 @@ void GlobalSettings::load_json(const JsonValue& json){
? ConfigOptionState::ENABLED
: ConfigOptionState::HIDDEN;
USE_PADDLE_OCR.set_visibility(devmode_visibility);
RESOURCE_DOWNLOAD_TABLE.set_visibility(devmode_visibility);
DOWNLOAD_ERROR.set_visibility(devmode_visibility);
SAVE_DEBUG_VIDEOS_ON_SWITCH.set_visibility(devmode_visibility);
DEVICE_LOGGING_FLAG.set_visibility(devmode_visibility);

Expand Down Expand Up @@ -451,9 +462,9 @@ void GlobalSettings::on_press(){
QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(RUNTIME_BASE_PATH())));
}




void GlobalSettings::connect_row_with_download(const std::string& resource_slug, std::shared_ptr<ResourceDownload>& download_ptr){
RESOURCE_DOWNLOAD_TABLE.connect_row_with_download(resource_slug, download_ptr);
}


GlobalSettings_Descriptor::GlobalSettings_Descriptor()
Expand Down
8 changes: 7 additions & 1 deletion SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "Common/Cpp/Options/ButtonOption.h"
#include "CommonFramework/Panels/SettingsPanel.h"
#include "CommonFramework/Panels/PanelTools.h"
#include "CommonFramework/ResourceDownload/SettingsResourceDownloadOptions.h"
#include "CommonFramework/ResourceDownload/SettingsResourceDownloadTable.h"

//#include <iostream>
//using std::cout;
Expand All @@ -37,7 +39,7 @@ class PerformanceOptions;
class AudioPipelineOptions;
class VideoPipelineOptions;
class ErrorReportOption;

class ResourceDownload;



Expand Down Expand Up @@ -111,6 +113,8 @@ class GlobalSettings : public BatchOption, private ConfigOption::Listener, priva
virtual void load_json(const JsonValue& json) override;
virtual JsonValue to_json() const override;

void connect_row_with_download(const std::string& resource_slug, std::shared_ptr<ResourceDownload>& download_ptr);

private:
virtual void on_config_value_changed(void* object) override;
virtual void on_press() override;
Expand All @@ -125,6 +129,8 @@ class GlobalSettings : public BatchOption, private ConfigOption::Listener, priva
Pimpl<ThemeSelectorOption> THEME;
BooleanCheckBoxOption USE_PADDLE_OCR;
BooleanCheckBoxOption USE_GPU_FOR_ML_INFERENCE;
SettingsResourceDownloadTable RESOURCE_DOWNLOAD_TABLE;
SettingsDownloadError DOWNLOAD_ERROR;
Pimpl<ResolutionOption> WINDOW_SIZE;
Pimpl<ResolutionOption> LOG_WINDOW_SIZE;
BooleanCheckBoxOption LOG_WINDOW_STARTUP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ std::shared_ptr<ResourceDownload> GlobalResourceDownloadManager::add_to_download
auto download_ptr = m_download_queue.emplace_back(std::make_shared<ResourceDownload>(*this, std::move(resource_metadata), m_queue_lock, m_cv));

download_ptr->add_listener(*this);
// GlobalSettings::instance().connect_row_with_download(resource_slug, download_ptr); TODO: re-enable this
GlobalSettings::instance().connect_row_with_download(resource_slug, download_ptr);
download_ptr->start_download();

return download_ptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#define PokemonAutomation_ResourceDownloadManager_H

#include <vector>
#include "Common/Cpp/Concurrency/SpinLock.h"
#include "Common/Cpp/Concurrency/Mutex.h"
#include "Common/Cpp/Concurrency/ConditionVariable.h"
#include "Common/Cpp/ListenerSet.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ JsonValue fetch_resource_download_list_json_from_remote(){
JsonValue json =
FileDownloader::download_json_file(
logger,
"https://raw.githubusercontent.com/jw098/Packages/refs/heads/download/Resources/ResourceDownloadList.json"
"https://raw.githubusercontent.com/PokemonAutomation/Packages/refs/heads/master/Resources/ResourceDownloadList.json"
);

return json;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/* Resource Download Options
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "SettingsResourceDownloadRow.h"
#include "SettingsResourceDownloadOptions.h"


// #include <iostream>
// using std::cout;
// using std::endl;

namespace PokemonAutomation{



void SettingsResourceButton::add_button_listener(Listener& listener){
m_listeners.add(listener);
}
void SettingsResourceButton::remove_button_listener(Listener& listener){
m_listeners.remove(listener);
}

void SettingsResourceButton::change_text(const std::string& text){
m_listeners.run_method(&Listener::on_change_text, text);
}


//////////////////////////////////////
// SettingsResourceDownloadButton
//////////////////////////////////////
// SettingsResourceDownloadButton::~SettingsResourceDownloadButton(){}
SettingsResourceDownloadButton::SettingsResourceDownloadButton(SettingsResourceDownloadRow& p_row)
: ConfigOptionImpl<SettingsResourceDownloadButton>(LockMode::UNLOCK_WHILE_RUNNING)
, row(p_row)
, m_enabled(true)
{}

void SettingsResourceDownloadButton::set_enabled(bool enabled){
m_enabled = enabled;
change_text(enabled ? "Download" : "Downloading...");
set_visibility(enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED);
}


//////////////////////////////////////
// SettingsResourceDeleteButton
//////////////////////////////////////
SettingsResourceDeleteButton::SettingsResourceDeleteButton(SettingsResourceDownloadRow& p_row)
: ConfigOptionImpl<SettingsResourceDeleteButton>(LockMode::UNLOCK_WHILE_RUNNING)
, row(p_row)
, m_enabled(true)
{}

void SettingsResourceDeleteButton::set_enabled(bool enabled){
m_enabled = enabled;
change_text(enabled ? "Delete" : "Deleting...");
set_visibility(enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED);
}

//////////////////////////////////////
// SettingsResourceCancelButton
//////////////////////////////////////
SettingsResourceCancelButton::SettingsResourceCancelButton(SettingsResourceDownloadRow& p_row)
: ConfigOptionImpl<SettingsResourceCancelButton>(LockMode::UNLOCK_WHILE_RUNNING)
, row(p_row)
, m_enabled(true)
{}

void SettingsResourceCancelButton::set_enabled(bool enabled){
m_enabled = enabled;
change_text(enabled ? "Cancel" : "Cancelling...");
set_visibility(enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED);
}
//////////////////////////////////////
// SettingsResourceProgressBar
//////////////////////////////////////
SettingsResourceProgressBar::SettingsResourceProgressBar(SettingsResourceDownloadRow& p_row)
: ConfigOptionImpl<SettingsResourceProgressBar>(LockMode::UNLOCK_WHILE_RUNNING)
, row(p_row)
{}

void SettingsResourceProgressBar::add_progress_listener(Listener& listener){
m_listeners.add(listener);
}
void SettingsResourceProgressBar::remove_progress_listener(Listener& listener){
m_listeners.remove(listener);
}

void SettingsResourceProgressBar::change_text(const std::string& text){
m_listeners.run_method(&Listener::on_change_text, text);
}

void SettingsResourceProgressBar::update_progress(uint64_t bytes_done, uint64_t total_bytes){
m_listeners.run_method(&Listener::on_update_progress, bytes_done, total_bytes);
}

void SettingsResourceProgressBar::reset_progress(){
m_listeners.run_method(&Listener::on_reset_progress);
}

////////////////////////////////
// ResourceDownload::Listener
////////////////////////////////
void SettingsResourceProgressBar::on_download_progress(uint64_t bytes_done, uint64_t total_bytes){
change_text("Downloading");
set_visibility(ConfigOptionState::ENABLED);
update_progress(bytes_done, total_bytes);
}
void SettingsResourceProgressBar::on_unzip_progress(uint64_t bytes_done, uint64_t total_bytes){
change_text("Unzipping");
set_visibility(ConfigOptionState::ENABLED);
update_progress(bytes_done, total_bytes);
}
void SettingsResourceProgressBar::on_hash_progress(uint64_t bytes_done, uint64_t total_bytes){
change_text("Verifying");
set_visibility(ConfigOptionState::ENABLED);
update_progress(bytes_done, total_bytes);
}

//////////////////////////////////////
// SettingsDownloadPopup
//////////////////////////////////////
SettingsDownloadPopup::SettingsDownloadPopup(SettingsResourceDownloadRow& p_row)
: ConfigOptionImpl<SettingsDownloadPopup>(LockMode::LOCK_WHILE_RUNNING)
, row(p_row)
{}

//////////////////////////////////////
// SettingsDownloadError
//////////////////////////////////////
SettingsDownloadError::SettingsDownloadError()
: ConfigOptionImpl<SettingsDownloadError>(LockMode::LOCK_WHILE_RUNNING)
{}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/* Resource Download Options
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_ResourceDownloadOptions_H
#define PokemonAutomation_ResourceDownloadOptions_H

#include "Common/Cpp/ListenerSet.h"
#include "ResourceDownload.h"

namespace PokemonAutomation{

class SettingsResourceDownloadRow;


class SettingsResourceButton {
public:
struct Listener{
virtual void on_change_text(const std::string& text){}
};

void add_button_listener(Listener& listener);
void remove_button_listener(Listener& listener);

void change_text(const std::string& text);

private:
ListenerSet<Listener> m_listeners;

};

class SettingsResourceDownloadButton : public ConfigOptionImpl<SettingsResourceDownloadButton>, public SettingsResourceButton{
public:
// ~SettingsResourceDownloadButton();
SettingsResourceDownloadButton(SettingsResourceDownloadRow& p_row);

public:
inline bool get_enabled(){ return m_enabled; }
void set_enabled(bool enabled);

public:
SettingsResourceDownloadRow& row;

private:
bool m_enabled; // button should be blocked during an active task. m_enabled is false when blocked



};

class SettingsResourceDeleteButton : public ConfigOptionImpl<SettingsResourceDeleteButton>, public SettingsResourceButton{
public:
SettingsResourceDeleteButton(SettingsResourceDownloadRow& p_row);

public:
inline bool get_enabled(){ return m_enabled; }
void set_enabled(bool enabled);

public:
SettingsResourceDownloadRow& row;

private:
bool m_enabled;
};

class SettingsResourceCancelButton : public ConfigOptionImpl<SettingsResourceCancelButton>, public SettingsResourceButton{
public:
SettingsResourceCancelButton(SettingsResourceDownloadRow& p_row);

public:
inline bool get_enabled(){ return m_enabled; }
void set_enabled(bool enabled);

public:
SettingsResourceDownloadRow& row;

private:
bool m_enabled;
};

class SettingsResourceProgressBar : public ConfigOptionImpl<SettingsResourceProgressBar>, public ResourceDownload::Listener{
public:
SettingsResourceProgressBar(SettingsResourceDownloadRow& p_row);

public:
struct Listener{
virtual void on_change_text(const std::string& text){}
virtual void on_update_progress(uint64_t bytes_done, uint64_t total_bytes){}
virtual void on_reset_progress(){}
};

void add_progress_listener(Listener& listener);
void remove_progress_listener(Listener& listener);

void change_text(const std::string& text);
void update_progress(uint64_t bytes_done, uint64_t total_bytes);
void reset_progress();

public: // ResourceDownload::Listener
virtual void on_download_progress(uint64_t bytes_done, uint64_t total_bytes) override;
virtual void on_unzip_progress(uint64_t bytes_done, uint64_t total_bytes) override;
virtual void on_hash_progress(uint64_t bytes_done, uint64_t total_bytes) override;

public:
SettingsResourceDownloadRow& row;

private:
ListenerSet<Listener> m_listeners;

};

class SettingsDownloadPopup : public ConfigOptionImpl<SettingsDownloadPopup>, public ResourceDownload::Listener{
public:
SettingsDownloadPopup(SettingsResourceDownloadRow& p_row);
public:
SettingsResourceDownloadRow& row;

};

class SettingsDownloadError : public ConfigOptionImpl<SettingsDownloadError>{
public:
SettingsDownloadError();


};


}
#endif
Loading
Loading