Skip to content

Commit 0101173

Browse files
authored
Merge pull request #153 from gymnast86/hide-chart-buttons
Hide chart buttons when charts aren't progression
2 parents a8a8be3 + 5dce66e commit 0101173

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

gui/desktop/tracker/tracker.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +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+
5167
selectedChartIsland = 0;
5268
if (settings.randomize_charts)
5369
{

gui/desktop/tracker/tracker_inventory_button.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void TrackerChartButton::updateIcon()
165165
std::string chartState = "treasure_chart_closed.png";
166166
if(mainWindow->trackerSettings.randomize_charts) {
167167
if(const GameItem chart = mainWindow->chartForIsland(islandNum); chart != GameItem::INVALID) {
168-
if(chart == GameItem::TriforceChart1 || chart == GameItem::TriforceChart2 || chart == GameItem::TriforceChart3) {
168+
if(this->isForTriforceChart()) {
169169
chartState = "triforce_chart_open.png";
170170
}
171171
else {
@@ -174,15 +174,15 @@ void TrackerChartButton::updateIcon()
174174
}
175175
}
176176
else if(const GameItem chart = roomNumToDefaultChart(islandNum); elementInPool(Item(chart, &mainWindow->trackerWorlds[0]), mainWindow->trackerInventory)) {
177-
if(chart == GameItem::TriforceChart1 || chart == GameItem::TriforceChart2 || chart == GameItem::TriforceChart3) {
177+
if(this->isForTriforceChart()) {
178178
chartState = "triforce_chart_open.png";
179179
}
180180
else {
181181
chartState = "treasure_chart_open.png";
182182
}
183183
}
184184
else {
185-
if(chart == GameItem::TriforceChart1 || chart == GameItem::TriforceChart2 || chart == GameItem::TriforceChart3) {
185+
if(this->isForTriforceChart()) {
186186
chartState = "triforce_chart_closed.png";
187187
}
188188
}
@@ -192,6 +192,17 @@ void TrackerChartButton::updateIcon()
192192
+ "background-position: center;");
193193
}
194194

195+
bool TrackerChartButton::isForTriforceChart() const
196+
{
197+
const GameItem chart = roomNumToDefaultChart(islandNum);
198+
return chart == GameItem::TriforceChart1 || chart == GameItem::TriforceChart2 || chart == GameItem::TriforceChart3;
199+
}
200+
201+
bool TrackerChartButton::isForTreasureChart() const
202+
{
203+
return !isForTriforceChart();
204+
}
205+
195206
void TrackerChartButton::mouseReleaseEvent(QMouseEvent* e)
196207
{
197208
if (e->button() == Qt::LeftButton)

gui/desktop/tracker/tracker_inventory_button.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class TrackerChartButton : public QLabel
6767
QPoint mouseEnterPosition = QPoint();
6868

6969
void updateIcon();
70+
bool isForTriforceChart() const;
71+
bool isForTreasureChart() const;
7072

7173
signals:
7274
void chart_map_button_pressed(uint8_t islandNum);

0 commit comments

Comments
 (0)