-
Notifications
You must be signed in to change notification settings - Fork 89
Max lair/added save on the go #1101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Boombaastical
wants to merge
15
commits into
PokemonAutomation:main
Choose a base branch
from
Boombaastical:MaxLair/AddedSaveOnTheGo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8711f8a
Updated draft
Boombaastical f581b9c
Updated draft for adding saved paths on the go
Boombaastical 6f35536
Merge remote-tracking branch 'upstream' into MaxLair/AddedSaveOnTheGoo
Boombaastical fc7c2aa
Updated draft
Boombaastical 5054e92
Added more draft changes
Boombaastical d12f770
Updated draft, now working logic but needs UI
Boombaastical 846247e
Finalizing the save-on-the-go feature for MaxLair, missing the screen…
Boombaastical 4bbfe56
Draft: updated some other fixes
Boombaastical 401a3fe
Tweaked things a bit
Boombaastical 19b9e3a
Saved other changes
Boombaastical 10e5b1d
Fixed logic
Boombaastical 8dc8317
Merge remote-tracking branch 'upstream' into MaxLair/AddedSaveOnTheGo
Boombaastical 12aa9f5
Finalized logic, testing
Boombaastical 8f2e4fd
Finalized implementation of the save-on-the-go option
Boombaastical d49935a
Merge remote-tracking branch 'upstream' into MaxLair/AddedSaveOnTheGo
Boombaastical File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,10 @@ | |
| #include "PokemonSwSh/Resources/PokemonSwSh_PokemonSprites.h" | ||
| #include "PokemonSwSh/Resources/PokemonSwSh_MaxLairDatabase.h" | ||
| #include "PokemonSwSh_MaxLair_Options_BossAction.h" | ||
| #include "Common/Cpp/Options/BooleanCheckBoxOption.h" | ||
| #include "Common/Cpp/Options/ConfigOption.h" | ||
| #include <vector> | ||
| #include <memory> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here applies with general formatting. We generally order our includes as:
|
||
|
|
||
| //#include <iostream> | ||
| //using std::cout; | ||
|
|
@@ -49,30 +53,101 @@ BossActionRow::BossActionRow(std::string slug, const std::string& name_slug, con | |
| BossAction::CATCH_AND_STOP_IF_SHINY | ||
| ) | ||
| , ball(LockMode::UNLOCK_WHILE_RUNNING, "poke-ball") | ||
| , save_on_the_go(LockMode::UNLOCK_WHILE_RUNNING, false) | ||
| { | ||
| PA_ADD_STATIC(pokemon); | ||
| add_option(action, "Action"); | ||
| add_option(ball, "Ball"); | ||
| add_option(save_on_the_go, "Save Path"); | ||
|
|
||
| save_on_the_go.set_visibility( | ||
| action == BossAction::CATCH_AND_STOP_IF_SHINY ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED | ||
| ); | ||
|
|
||
| action.add_listener(*this); | ||
| } | ||
|
|
||
| void BossActionRow::on_config_value_changed(void* object) { | ||
| if (action != BossAction::CATCH_AND_STOP_IF_SHINY) { | ||
| save_on_the_go = false; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| BossActionTable::BossActionTable() | ||
| : StaticTableOption("<b>Boss Actions:</b>", LockMode::UNLOCK_WHILE_RUNNING) | ||
| , m_reverting(false) | ||
| { | ||
| for (const auto& item : all_bosses_by_dex()){ | ||
| // cout << item.second << endl; | ||
| const MaxLairSlugs& slugs = get_maxlair_slugs(item.second); | ||
| const std::string& sprite_slug = *slugs.sprite_slugs.begin(); | ||
| const std::string& name_slug = slugs.name_slug; | ||
| add_row(std::make_unique<BossActionRow>(item.second, name_slug, sprite_slug)); | ||
|
|
||
| auto row = std::make_unique<BossActionRow>(item.second, name_slug, sprite_slug); | ||
| m_rows.push_back(row.get()); | ||
| add_row(std::move(row)); | ||
| } | ||
| finish_construction(); | ||
|
|
||
| for (auto* row : m_rows) { | ||
| row->save_on_the_go.add_listener(*this); | ||
| row->action.add_listener(*this); | ||
| } | ||
|
|
||
| update_checkbox_states(); | ||
| } | ||
|
|
||
| BossActionTable::~BossActionTable(){ | ||
| for (auto* row : m_rows) { | ||
| row->save_on_the_go.remove_listener(*this); | ||
| row->action.remove_listener(*this); | ||
| } | ||
| } | ||
|
|
||
| void BossActionTable::update_checkbox_states() { | ||
| size_t checked = 0; | ||
| for (auto* row : m_rows) { | ||
| if (row->save_on_the_go) checked++; | ||
| } | ||
| for (auto* row : m_rows) { | ||
| bool action_ok = (row->action == BossAction::CATCH_AND_STOP_IF_SHINY); | ||
| bool disable_by_max = (checked >= 3 && !row->save_on_the_go); | ||
| ConfigOptionState state = (action_ok && !disable_by_max) ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED; | ||
| row->save_on_the_go.set_visibility(state); | ||
| } | ||
| } | ||
|
|
||
| void BossActionTable::on_config_value_changed(void* object) { | ||
| if (m_reverting) return; | ||
|
|
||
| // Counting how many checkboxes are currently checked | ||
| size_t checked = 0; | ||
| for (auto* row : m_rows) { | ||
| if (row->save_on_the_go) checked++; | ||
| } | ||
|
|
||
| // If we exceed the 3 boxes ticked, we revert the change for the last box ticked | ||
| if (checked > 3) { | ||
| for (auto* row : m_rows) { | ||
| if (object == &row->save_on_the_go && row->save_on_the_go) { | ||
| m_reverting = true; | ||
| row->save_on_the_go = false; | ||
| m_reverting = false; | ||
|
|
||
| return; | ||
| } | ||
| } | ||
| } | ||
| update_checkbox_states(); | ||
| } | ||
|
|
||
| std::vector<std::string> BossActionTable::make_header() const{ | ||
| std::vector<std::string> ret{ | ||
| STRING_POKEMON, | ||
| "Action", | ||
| STRING_POKEBALL | ||
| STRING_POKEBALL, | ||
| "Save Path (Max 3)" | ||
| }; | ||
| return ret; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try not to deviate too much from our formatting standard. While we don't document it, there is a pattern to try to adhere to.