diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/settings_dialog.cpp | 29 | ||||
-rw-r--r-- | src/settings_dialog.h | 24 | ||||
-rw-r--r-- | src/tracker_config.cpp | 2 | ||||
-rw-r--r-- | src/tracker_config.h | 1 | ||||
-rw-r--r-- | src/tracker_frame.cpp | 22 | ||||
-rw-r--r-- | src/tracker_frame.h | 1 | ||||
-rw-r--r-- | src/tracker_panel.cpp | 58 |
8 files changed, 119 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ac5467d..7750364 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -40,6 +40,7 @@ add_executable(lingo_ap_tracker | |||
40 | "src/tracker_config.cpp" | 40 | "src/tracker_config.cpp" |
41 | "src/logger.cpp" | 41 | "src/logger.cpp" |
42 | "src/achievements_pane.cpp" | 42 | "src/achievements_pane.cpp" |
43 | "src/settings_dialog.cpp" | ||
43 | ) | 44 | ) |
44 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 20) | 45 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 20) |
45 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON) | 46 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON) |
diff --git a/src/settings_dialog.cpp b/src/settings_dialog.cpp new file mode 100644 index 0000000..58e5988 --- /dev/null +++ b/src/settings_dialog.cpp | |||
@@ -0,0 +1,29 @@ | |||
1 | #include "settings_dialog.h" | ||
2 | |||
3 | #include "tracker_config.h" | ||
4 | |||
5 | SettingsDialog::SettingsDialog() : wxDialog(nullptr, wxID_ANY, "Settings") { | ||
6 | should_check_for_updates_box_ = new wxCheckBox( | ||
7 | this, wxID_ANY, "Check for updates when the tracker opens"); | ||
8 | hybrid_areas_box_ = new wxCheckBox( | ||
9 | this, wxID_ANY, | ||
10 | "Use two colors to show that an area has partial availability"); | ||
11 | |||
12 | should_check_for_updates_box_->SetValue( | ||
13 | GetTrackerConfig().should_check_for_updates); | ||
14 | hybrid_areas_box_->SetValue(GetTrackerConfig().hybrid_areas); | ||
15 | |||
16 | wxBoxSizer* form_sizer = new wxBoxSizer(wxVERTICAL); | ||
17 | |||
18 | form_sizer->Add(should_check_for_updates_box_, wxSizerFlags().HorzBorder()); | ||
19 | form_sizer->AddSpacer(2); | ||
20 | |||
21 | form_sizer->Add(hybrid_areas_box_, wxSizerFlags().HorzBorder()); | ||
22 | form_sizer->AddSpacer(2); | ||
23 | |||
24 | form_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Center()); | ||
25 | |||
26 | SetSizerAndFit(form_sizer); | ||
27 | |||
28 | Center(); | ||
29 | } | ||
diff --git a/src/settings_dialog.h b/src/settings_dialog.h new file mode 100644 index 0000000..150a7a8 --- /dev/null +++ b/src/settings_dialog.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef SETTINGS_DIALOG_H_D8635719 | ||
2 | #define SETTINGS_DIALOG_H_D8635719 | ||
3 | |||
4 | #include <wx/wxprec.h> | ||
5 | |||
6 | #ifndef WX_PRECOMP | ||
7 | #include <wx/wx.h> | ||
8 | #endif | ||
9 | |||
10 | class SettingsDialog : public wxDialog { | ||
11 | public: | ||
12 | SettingsDialog(); | ||
13 | |||
14 | bool GetShouldCheckForUpdates() const { | ||
15 | return should_check_for_updates_box_->GetValue(); | ||
16 | } | ||
17 | bool GetHybridAreas() const { return hybrid_areas_box_->GetValue(); } | ||
18 | |||
19 | private: | ||
20 | wxCheckBox* should_check_for_updates_box_; | ||
21 | wxCheckBox* hybrid_areas_box_; | ||
22 | }; | ||
23 | |||
24 | #endif /* end of include guard: SETTINGS_DIALOG_H_D8635719 */ | ||
diff --git a/src/tracker_config.cpp b/src/tracker_config.cpp index c09d241..9318091 100644 --- a/src/tracker_config.cpp +++ b/src/tracker_config.cpp | |||
@@ -14,6 +14,7 @@ void TrackerConfig::Load() { | |||
14 | ap_password = file["ap_password"].as<std::string>(); | 14 | ap_password = file["ap_password"].as<std::string>(); |
15 | asked_to_check_for_updates = file["asked_to_check_for_updates"].as<bool>(); | 15 | asked_to_check_for_updates = file["asked_to_check_for_updates"].as<bool>(); |
16 | should_check_for_updates = file["should_check_for_updates"].as<bool>(); | 16 | should_check_for_updates = file["should_check_for_updates"].as<bool>(); |
17 | hybrid_areas = file["hybrid_areas"].as<bool>(); | ||
17 | } catch (const std::exception&) { | 18 | } catch (const std::exception&) { |
18 | // It's fine if the file can't be loaded. | 19 | // It's fine if the file can't be loaded. |
19 | } | 20 | } |
@@ -26,6 +27,7 @@ void TrackerConfig::Save() { | |||
26 | output["ap_password"] = ap_password; | 27 | output["ap_password"] = ap_password; |
27 | output["asked_to_check_for_updates"] = asked_to_check_for_updates; | 28 | output["asked_to_check_for_updates"] = asked_to_check_for_updates; |
28 | output["should_check_for_updates"] = should_check_for_updates; | 29 | output["should_check_for_updates"] = should_check_for_updates; |
30 | output["hybrid_areas"] = hybrid_areas; | ||
29 | 31 | ||
30 | std::ofstream filewriter(CONFIG_FILE_NAME); | 32 | std::ofstream filewriter(CONFIG_FILE_NAME); |
31 | filewriter << output; | 33 | filewriter << output; |
diff --git a/src/tracker_config.h b/src/tracker_config.h index b9460d2..6c94e1b 100644 --- a/src/tracker_config.h +++ b/src/tracker_config.h | |||
@@ -14,6 +14,7 @@ class TrackerConfig { | |||
14 | std::string ap_password; | 14 | std::string ap_password; |
15 | bool asked_to_check_for_updates = false; | 15 | bool asked_to_check_for_updates = false; |
16 | bool should_check_for_updates = false; | 16 | bool should_check_for_updates = false; |
17 | bool hybrid_areas = false; | ||
17 | }; | 18 | }; |
18 | 19 | ||
19 | TrackerConfig& GetTrackerConfig(); | 20 | TrackerConfig& GetTrackerConfig(); |
diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index a74e81e..5341fa6 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp | |||
@@ -9,11 +9,16 @@ | |||
9 | #include "achievements_pane.h" | 9 | #include "achievements_pane.h" |
10 | #include "ap_state.h" | 10 | #include "ap_state.h" |
11 | #include "connection_dialog.h" | 11 | #include "connection_dialog.h" |
12 | #include "settings_dialog.h" | ||
12 | #include "tracker_config.h" | 13 | #include "tracker_config.h" |
13 | #include "tracker_panel.h" | 14 | #include "tracker_panel.h" |
14 | #include "version.h" | 15 | #include "version.h" |
15 | 16 | ||
16 | enum TrackerFrameIds { ID_CONNECT = 1, ID_CHECK_FOR_UPDATES = 2 }; | 17 | enum TrackerFrameIds { |
18 | ID_CONNECT = 1, | ||
19 | ID_CHECK_FOR_UPDATES = 2, | ||
20 | ID_SETTINGS = 3 | ||
21 | }; | ||
17 | 22 | ||
18 | wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent); | 23 | wxDEFINE_EVENT(STATE_CHANGED, wxCommandEvent); |
19 | wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent); | 24 | wxDEFINE_EVENT(STATUS_CHANGED, wxCommandEvent); |
@@ -29,6 +34,7 @@ TrackerFrame::TrackerFrame() | |||
29 | 34 | ||
30 | wxMenu *menuFile = new wxMenu(); | 35 | wxMenu *menuFile = new wxMenu(); |
31 | menuFile->Append(ID_CONNECT, "&Connect"); | 36 | menuFile->Append(ID_CONNECT, "&Connect"); |
37 | menuFile->Append(ID_SETTINGS, "&Settings"); | ||
32 | menuFile->Append(wxID_EXIT); | 38 | menuFile->Append(wxID_EXIT); |
33 | 39 | ||
34 | wxMenu *menuHelp = new wxMenu(); | 40 | wxMenu *menuHelp = new wxMenu(); |
@@ -47,6 +53,7 @@ TrackerFrame::TrackerFrame() | |||
47 | Bind(wxEVT_MENU, &TrackerFrame::OnAbout, this, wxID_ABOUT); | 53 | Bind(wxEVT_MENU, &TrackerFrame::OnAbout, this, wxID_ABOUT); |
48 | Bind(wxEVT_MENU, &TrackerFrame::OnExit, this, wxID_EXIT); | 54 | Bind(wxEVT_MENU, &TrackerFrame::OnExit, this, wxID_EXIT); |
49 | Bind(wxEVT_MENU, &TrackerFrame::OnConnect, this, ID_CONNECT); | 55 | Bind(wxEVT_MENU, &TrackerFrame::OnConnect, this, ID_CONNECT); |
56 | Bind(wxEVT_MENU, &TrackerFrame::OnSettings, this, ID_SETTINGS); | ||
50 | Bind(wxEVT_MENU, &TrackerFrame::OnCheckForUpdates, this, | 57 | Bind(wxEVT_MENU, &TrackerFrame::OnCheckForUpdates, this, |
51 | ID_CHECK_FOR_UPDATES); | 58 | ID_CHECK_FOR_UPDATES); |
52 | Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this); | 59 | Bind(STATE_CHANGED, &TrackerFrame::OnStateChanged, this); |
@@ -119,6 +126,19 @@ void TrackerFrame::OnConnect(wxCommandEvent &event) { | |||
119 | } | 126 | } |
120 | } | 127 | } |
121 | 128 | ||
129 | void TrackerFrame::OnSettings(wxCommandEvent &event) { | ||
130 | SettingsDialog dlg; | ||
131 | |||
132 | if (dlg.ShowModal() == wxID_OK) { | ||
133 | GetTrackerConfig().should_check_for_updates = | ||
134 | dlg.GetShouldCheckForUpdates(); | ||
135 | GetTrackerConfig().hybrid_areas = dlg.GetHybridAreas(); | ||
136 | GetTrackerConfig().Save(); | ||
137 | |||
138 | UpdateIndicators(); | ||
139 | } | ||
140 | } | ||
141 | |||
122 | void TrackerFrame::OnCheckForUpdates(wxCommandEvent &event) { | 142 | void TrackerFrame::OnCheckForUpdates(wxCommandEvent &event) { |
123 | CheckForUpdates(/*manual=*/true); | 143 | CheckForUpdates(/*manual=*/true); |
124 | } | 144 | } |
diff --git a/src/tracker_frame.h b/src/tracker_frame.h index 85cc7c3..e5bf97e 100644 --- a/src/tracker_frame.h +++ b/src/tracker_frame.h | |||
@@ -25,6 +25,7 @@ class TrackerFrame : public wxFrame { | |||
25 | void OnExit(wxCommandEvent &event); | 25 | void OnExit(wxCommandEvent &event); |
26 | void OnAbout(wxCommandEvent &event); | 26 | void OnAbout(wxCommandEvent &event); |
27 | void OnConnect(wxCommandEvent &event); | 27 | void OnConnect(wxCommandEvent &event); |
28 | void OnSettings(wxCommandEvent &event); | ||
28 | void OnCheckForUpdates(wxCommandEvent &event); | 29 | void OnCheckForUpdates(wxCommandEvent &event); |
29 | 30 | ||
30 | void OnStateChanged(wxCommandEvent &event); | 31 | void OnStateChanged(wxCommandEvent &event); |
diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index 5580068..466440f 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "ap_state.h" | 3 | #include "ap_state.h" |
4 | #include "area_popup.h" | 4 | #include "area_popup.h" |
5 | #include "game_data.h" | 5 | #include "game_data.h" |
6 | #include "tracker_config.h" | ||
6 | #include "tracker_state.h" | 7 | #include "tracker_state.h" |
7 | 8 | ||
8 | constexpr int AREA_ACTUAL_SIZE = 64; | 9 | constexpr int AREA_ACTUAL_SIZE = 64; |
@@ -91,9 +92,17 @@ void TrackerPanel::Redraw() { | |||
91 | wxMemoryDC dc; | 92 | wxMemoryDC dc; |
92 | dc.SelectObject(rendered_); | 93 | dc.SelectObject(rendered_); |
93 | 94 | ||
94 | for (AreaIndicator &area : areas_) { | 95 | int real_area_size = |
95 | const wxBrush *brush_color = wxGREY_BRUSH; | 96 | final_width * AREA_EFFECTIVE_SIZE / image_size.GetWidth(); |
97 | int actual_border_size = | ||
98 | real_area_size * AREA_BORDER_SIZE / AREA_EFFECTIVE_SIZE; | ||
99 | const wxPoint upper_left_triangle[] = { | ||
100 | {0, 0}, {0, real_area_size}, {real_area_size, 0}}; | ||
101 | const wxPoint lower_right_triangle[] = {{0, real_area_size - 1}, | ||
102 | {real_area_size - 1, 0}, | ||
103 | {real_area_size, real_area_size}}; | ||
96 | 104 | ||
105 | for (AreaIndicator &area : areas_) { | ||
97 | const MapArea &map_area = GD_GetMapArea(area.area_id); | 106 | const MapArea &map_area = GD_GetMapArea(area.area_id); |
98 | if (!AP_IsLocationVisible(map_area.classification)) { | 107 | if (!AP_IsLocationVisible(map_area.classification)) { |
99 | area.active = false; | 108 | area.active = false; |
@@ -115,27 +124,40 @@ void TrackerPanel::Redraw() { | |||
115 | } | 124 | } |
116 | } | 125 | } |
117 | 126 | ||
118 | if (has_reachable_unchecked && has_unreachable_unchecked) { | ||
119 | brush_color = wxYELLOW_BRUSH; | ||
120 | } else if (has_reachable_unchecked) { | ||
121 | brush_color = wxGREEN_BRUSH; | ||
122 | } else if (has_unreachable_unchecked) { | ||
123 | brush_color = wxRED_BRUSH; | ||
124 | } | ||
125 | |||
126 | int real_area_size = | ||
127 | final_width * AREA_EFFECTIVE_SIZE / image_size.GetWidth(); | ||
128 | int actual_border_size = | ||
129 | real_area_size * AREA_BORDER_SIZE / AREA_EFFECTIVE_SIZE; | ||
130 | int real_area_x = final_x + (map_area.map_x - (AREA_EFFECTIVE_SIZE / 2)) * | 127 | int real_area_x = final_x + (map_area.map_x - (AREA_EFFECTIVE_SIZE / 2)) * |
131 | final_width / image_size.GetWidth(); | 128 | final_width / image_size.GetWidth(); |
132 | int real_area_y = final_y + (map_area.map_y - (AREA_EFFECTIVE_SIZE / 2)) * | 129 | int real_area_y = final_y + (map_area.map_y - (AREA_EFFECTIVE_SIZE / 2)) * |
133 | final_width / image_size.GetWidth(); | 130 | final_width / image_size.GetWidth(); |
134 | 131 | ||
135 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, actual_border_size)); | 132 | if (has_reachable_unchecked && has_unreachable_unchecked && |
136 | dc.SetBrush(*brush_color); | 133 | GetTrackerConfig().hybrid_areas) { |
137 | dc.DrawRectangle({real_area_x, real_area_y}, | 134 | dc.SetPen(*wxTRANSPARENT_PEN); |
138 | {real_area_size, real_area_size}); | 135 | dc.SetBrush(*wxGREEN_BRUSH); |
136 | dc.DrawPolygon(3, upper_left_triangle, real_area_x, real_area_y); | ||
137 | |||
138 | dc.SetBrush(*wxRED_BRUSH); | ||
139 | dc.DrawPolygon(3, lower_right_triangle, real_area_x, real_area_y); | ||
140 | |||
141 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, actual_border_size)); | ||
142 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | ||
143 | dc.DrawRectangle({real_area_x, real_area_y}, | ||
144 | {real_area_size, real_area_size}); | ||
145 | |||
146 | } else { | ||
147 | const wxBrush *brush_color = wxGREY_BRUSH; | ||
148 | if (has_reachable_unchecked && has_unreachable_unchecked) { | ||
149 | brush_color = wxYELLOW_BRUSH; | ||
150 | } else if (has_reachable_unchecked) { | ||
151 | brush_color = wxGREEN_BRUSH; | ||
152 | } else if (has_unreachable_unchecked) { | ||
153 | brush_color = wxRED_BRUSH; | ||
154 | } | ||
155 | |||
156 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, actual_border_size)); | ||
157 | dc.SetBrush(*brush_color); | ||
158 | dc.DrawRectangle({real_area_x, real_area_y}, | ||
159 | {real_area_size, real_area_size}); | ||
160 | } | ||
139 | 161 | ||
140 | area.real_x1 = real_area_x; | 162 | area.real_x1 = real_area_x; |
141 | area.real_x2 = real_area_x + real_area_size; | 163 | area.real_x2 = real_area_x + real_area_size; |