Skip to content

Commit d9e011c

Browse files
authored
Merge pull request #155 from SuperDude88/show-charts-preference
Show Charts Option
2 parents 016a1ee + c1b2d31 commit d9e011c

6 files changed

Lines changed: 44 additions & 16 deletions

File tree

gui/desktop/mainwindow.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class MainWindow : public QMainWindow
137137
bool isIslandMappedToChart(uint8_t island);
138138
uint8_t islandForChart(GameItem chart);
139139
GameItem chartForIsland(uint8_t islandNum);
140+
void tracker_update_chart_visibility();
140141

141142
private slots:
142143
void show_error_dialog(const std::string& s, const std::string& title = "An error has occured!");

gui/desktop/tracker/tracker.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,22 @@ void MainWindow::initialize_tracker_world(Settings& settings,
4848
// Copy settings to modify them
4949
trackerSettings = settings;
5050

51-
// Show or hide chart tracker buttons depending on settings
52-
for (auto chartButton : ui->tracker_tab->findChildren<TrackerChartButton*>())
53-
{
54-
// If charts are randomized, show all charts if either chart progression is enabled
55-
if (trackerSettings.randomize_charts)
56-
{
57-
chartButton->setVisible(trackerSettings.progression_treasure_charts || trackerSettings.progression_triforce_charts);
58-
}
59-
// If charts aren't randomized, show chart only if their rerespective chart type is progression
60-
else
61-
{
62-
chartButton->setVisible((trackerSettings.progression_treasure_charts && chartButton->isForTreasureChart()) ||
63-
(trackerSettings.progression_triforce_charts && chartButton->isForTriforceChart()));
64-
}
65-
}
66-
6751
selectedChartIsland = 0;
6852
if (settings.randomize_charts)
6953
{
7054
// With charts shuffled the required ones can be on any island
7155
// So for tracker purposes, treat all 49 charts as potentially progress
56+
// Also force all charts to be shown on the map
7257
if (trackerSettings.progression_treasure_charts || trackerSettings.progression_triforce_charts)
7358
{
7459
trackerSettings.progression_treasure_charts = true;
7560
trackerSettings.progression_triforce_charts = true;
61+
trackerPreferences.showCharts = true;
7662
}
7763
}
7864

65+
tracker_update_chart_visibility();
66+
7967
// Give 3 hearts so that all heart checks pass logic
8068
trackerSettings.starting_hcs = 3;
8169

@@ -459,6 +447,7 @@ bool MainWindow::autosave_current_tracker_preferences()
459447
pref["show_nonprogress_locations"] = trackerPreferences.showNonProgressLocations;
460448
pref["right_click_clear_all"] = trackerPreferences.rightClickClearAll;
461449
pref["clear_all_includes_dependent_locations"] = trackerPreferences.clearAllIncludesDependentLocations;
450+
pref["show_charts"] = trackerPreferences.showCharts;
462451
pref["override_items_color"] = trackerPreferences.overrideItemsColor;
463452
pref["override_locations_color"] = trackerPreferences.overrideLocationsColor;
464453
pref["override_stats_color"] = trackerPreferences.overrideStatsColor;
@@ -562,6 +551,11 @@ void MainWindow::load_tracker_autosave()
562551
trackerPreferences.clearAllIncludesDependentLocations = pref["clear_all_includes_dungeon_mail"].as<bool>();
563552
}
564553

554+
if (pref["show_charts"])
555+
{
556+
trackerPreferences.showCharts = pref["show_charts"].as<bool>();
557+
}
558+
565559
if (!std::filesystem::exists(trackerPreferences.autosaveFilePath))
566560
{
567561
// No autosave file, don't try to do anything
@@ -1980,3 +1974,15 @@ void MainWindow::tracker_set_required_boss(const QString& bossName, Qt::CheckSta
19801974

19811975
update_tracker();
19821976
}
1977+
1978+
void MainWindow::tracker_update_chart_visibility() {
1979+
// Show or hide chart buttons depending on the preference
1980+
for (auto chartButton : ui->tracker_tab->findChildren<TrackerChartButton*>())
1981+
{
1982+
// If charts are randomized and any are progression, showCharts is forced to be true
1983+
// If charts aren't randomized, show chart only if their respective chart type is progression
1984+
chartButton->setVisible(trackerPreferences.showCharts ||
1985+
(trackerSettings.progression_treasure_charts && chartButton->isForTreasureChart()) ||
1986+
(trackerSettings.progression_triforce_charts && chartButton->isForTriforceChart()));
1987+
}
1988+
}

gui/desktop/tracker/tracker_preferences.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct TrackerPreferences {
1010
bool showNonProgressLocations = false;
1111
bool rightClickClearAll = true;
1212
bool clearAllIncludesDependentLocations = true;
13+
bool showCharts = true;
1314
bool overrideItemsColor = false;
1415
bool overrideLocationsColor = false;
1516
bool overrideStatsColor = false;

gui/desktop/tracker/tracker_preferences_dialog.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ TrackerPreferencesDialog::TrackerPreferencesDialog(MainWindow* main_) : main(mai
1212
ui.show_nonprogress_locations->setChecked(main->trackerPreferences.showNonProgressLocations);
1313
ui.right_click_to_clear_all->setChecked(main->trackerPreferences.rightClickClearAll);
1414
ui.clear_all_includes_dependent_locations->setChecked(main->trackerPreferences.clearAllIncludesDependentLocations);
15+
ui.show_charts->setChecked(main->trackerPreferences.showCharts);
16+
if(main->trackerSettings.randomize_charts && (main->trackerSettings.progression_triforce_charts || main->trackerSettings.progression_treasure_charts)) {
17+
ui.show_charts->setChecked(true);
18+
ui.show_charts->setEnabled(false);
19+
}
1520
ui.override_items_background_color->setChecked(main->trackerPreferences.overrideItemsColor);
1621
ui.override_locations_background_color->setChecked(main->trackerPreferences.overrideLocationsColor);
1722
ui.override_statistics_background_color->setChecked(main->trackerPreferences.overrideStatsColor);
@@ -64,6 +69,13 @@ void TrackerPreferencesDialog::on_clear_all_includes_dependent_locations_stateCh
6469
}
6570

6671

72+
void TrackerPreferencesDialog::on_show_charts_stateChanged(int arg1)
73+
{
74+
main->trackerPreferences.showCharts = arg1;
75+
main->tracker_update_chart_visibility();
76+
}
77+
78+
6779
void TrackerPreferencesDialog::on_override_items_background_color_stateChanged(int arg1)
6880
{
6981
main->trackerPreferences.overrideItemsColor = arg1;

gui/desktop/tracker/tracker_preferences_dialog.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ private slots:
1717
void on_show_nonprogress_locations_stateChanged(int arg1);
1818
void on_right_click_to_clear_all_stateChanged(int arg1);
1919
void on_clear_all_includes_dependent_locations_stateChanged(int arg1);
20+
void on_show_charts_stateChanged(int arg1);
2021
void on_override_items_background_color_stateChanged(int arg1);
2122
void on_override_locations_background_color_stateChanged(int arg1);
2223
void on_override_statistics_background_color_stateChanged(int arg1);

gui/desktop/tracker/tracker_preferences_dialog.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@
8888
</property>
8989
</widget>
9090
</item>
91+
<item>
92+
<widget class="QCheckBox" name="show_charts">
93+
<property name="text">
94+
<string>Show Charts</string>
95+
</property>
96+
</widget>
97+
</item>
9198
<item>
9299
<layout class="QHBoxLayout" name="horizontalLayout">
93100
<property name="spacing">

0 commit comments

Comments
 (0)