Skip to content

Resource Download - Settings - #1305

Merged
jw098 merged 10 commits into
PokemonAutomation:mainfrom
jw098:download-settings
Jul 7, 2026
Merged

Resource Download - Settings#1305
jw098 merged 10 commits into
PokemonAutomation:mainfrom
jw098:download-settings

Conversation

@jw098

@jw098 jw098 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

No description provided.


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

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.

Are you trying to fade out the button to lock it? Even ConfigOption has a visibility field. ConfigOption::set_visibility() will set it and will automatically show/hide/grey-out the entire option unless the subclass explicitly overrides it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I forgot about set_visibility() when I wrote this. But to be fair, I'm not only fading the button, but also changing the button text. So, I'm not sure if refactoring to use set_visibility() is worth it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is where it gets used:

void SettingsDownloadButtonWidget::update_UI_state(){
    if (m_value.get_enabled()){
        m_button->setEnabled(true);
        m_button->setText("Download");
    }else{
        m_button->setEnabled(false);
        if (m_row.is_given_action_state(ActionState::PRE_DOWNLOAD) 
            || m_row.is_given_action_state(ActionState::DOWNLOADING))
        {
            m_button->setText("Downloading...");
        }
    }
}

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.

There's 2 ways to do this. You can either override set_visibility() and have it immediately call the parent to retain the visibility behavior, then you can add more stuff to it. Or you can call it manually along side a separate setText call.

Calling set_visibility() will go through the listener system to notify everything that's listening for this event. So you'll want to not bypass that.

@jw098

jw098 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

This PR should now be ready for review.

fs::remove_all(Filesystem::Path(resource_directory));

// update the table labels
set_is_downloaded(false);

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.

What happens if something happens after the files are deleted, but before set_is_downloaded(false) is called? Can it leave the program or resource folder in a bad state?

@jw098 jw098 Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

set_is_downloaded() is only to update the table labels. The main thing is ensuring that the buttons aren't frozen. update_action_state() is what unblocks the buttons. And it runs even when exceptions are thrown.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thinking about this more, I think I'll use ScopeExit to ensure that update_action_state() is always run, and to avoid repeating myself.

PA_ADD_OPTION(USE_PADDLE_OCR);
PA_ADD_OPTION(USE_GPU_FOR_ML_INFERENCE);
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.

@jw098
jw098 merged commit f816091 into PokemonAutomation:main Jul 7, 2026
7 checks passed
@jw098
jw098 deleted the download-settings branch July 21, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants