| | | @@ -0,0 +1,1139 @@ |
| 1 | + | ////////////////////////////////////////////////////////////////////// |
| 2 | + | // This file is part of Remere's Map Editor |
| 3 | + | ////////////////////////////////////////////////////////////////////// |
| 4 | + | // Remere's Map Editor is free software: you can redistribute it and/or modify |
| 5 | + | // it under the terms of the GNU General Public License as published by |
| 6 | + | // the Free Software Foundation, either version 3 of the License, or |
| 7 | + | // (at your option) any later version. |
| 8 | + | // |
| 9 | + | // Remere's Map Editor is distributed in the hope that it will be useful, |
| 10 | + | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + | // GNU General Public License for more details. |
| 13 | + | // |
| 14 | + | // You should have received a copy of the GNU General Public License |
| 15 | + | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + | ////////////////////////////////////////////////////////////////////// |
| 17 | + | |
| 18 | + | #include "main.h" |
| 19 | + | |
| 20 | + | #include <wx/collpane.h> |
| 21 | + | |
| 22 | + | #include "settings.h" |
| 23 | + | #include "gui_ids.h" |
| 24 | + | #include "client_version.h" |
| 25 | + | |
| 26 | + | #include <wx/confbase.h> |
| 27 | + | #include <wx/config.h> |
| 28 | + | #include <wx/fileconf.h> |
| 29 | + | #include <wx/sstream.h> |
| 30 | + | #include <wx/wfstream.h> |
| 31 | + | #include <wx/statline.h> |
| 32 | + | |
| 33 | + | #include <iostream> |
| 34 | + | #include <string> |
| 35 | + | |
| 36 | + | #include "editor.h" |
| 37 | + | |
| 38 | + | #include "gui.h" |
| 39 | + | |
| 40 | + | #include "preferences.h" |
| 41 | + | #include "main_menubar.h" |
| 42 | + | #include "main_toolbar.h" |
| 43 | + | #include "dark_mode_manager.h" |
| 44 | + | |
| 45 | + | BEGIN_EVENT_TABLE(PreferencesWindow, wxDialog) |
| 46 | + | EVT_BUTTON(wxID_OK, PreferencesWindow::OnClickOK) |
| 47 | + | EVT_BUTTON(wxID_CANCEL, PreferencesWindow::OnClickCancel) |
| 48 | + | EVT_BUTTON(wxID_APPLY, PreferencesWindow::OnClickApply) |
| 49 | + | EVT_COLLAPSIBLEPANE_CHANGED(wxID_ANY, PreferencesWindow::OnCollapsiblePane) |
| 50 | + | END_EVENT_TABLE() |
| 51 | + | |
| 52 | + | PreferencesWindow::PreferencesWindow(wxWindow* parent, bool clientVersionSelected = false) : |
| 53 | + | wxDialog(parent, wxID_ANY, "Preferences", wxDefaultPosition, wxSize(400, 400), wxCAPTION | wxCLOSE_BOX) { |
| 54 | + | wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); |
| 55 | + | |
| 56 | + | book = newd wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_TOP); |
| 57 | + | // book->SetPadding(4); |
| 58 | + | |
| 59 | + | book->AddPage(CreateGeneralPage(), "General", true); |
| 60 | + | book->AddPage(CreateEditorPage(), "Editor"); |
| 61 | + | book->AddPage(CreateGraphicsPage(), "Graphics"); |
| 62 | + | book->AddPage(CreateUIPage(), "Interface"); |
| 63 | + | book->AddPage(CreateClientPage(), "Client Version", clientVersionSelected); |
| 64 | + | book->AddPage(CreateLODPage(), "LOD"); |
| 65 | + | book->AddPage(CreateAutomagicPage(), "Automagic"); |
| 66 | + | |
| 67 | + | sizer->Add(book, 1, wxEXPAND | wxALL, 10); |
| 68 | + | |
| 69 | + | wxSizer* subsizer = newd wxBoxSizer(wxHORIZONTAL); |
| 70 | + | subsizer->Add(newd wxButton(this, wxID_OK, "OK"), wxSizerFlags(1).Center()); |
| 71 | + | subsizer->Add(newd wxButton(this, wxID_CANCEL, "Cancel"), wxSizerFlags(1).Border(wxALL, 5).Left().Center()); |
| 72 | + | subsizer->Add(newd wxButton(this, wxID_APPLY, "Apply"), wxSizerFlags(1).Center()); |
| 73 | + | sizer->Add(subsizer, 0, wxCENTER | wxLEFT | wxBOTTOM | wxRIGHT, 10); |
| 74 | + | |
| 75 | + | SetSizerAndFit(sizer); |
| 76 | + | Centre(wxBOTH); |
| 77 | + | // FindWindowById(PANE_ADVANCED_GRAPHICS, this)->GetParent()->Fit(); |
| 78 | + | } |
| 79 | + | |
| 80 | + | PreferencesWindow::~PreferencesWindow() { |
| 81 | + | //// |
| 82 | + | } |
| 83 | + | |
| 84 | + | wxNotebookPage* PreferencesWindow::CreateGeneralPage() { |
| 85 | + | wxNotebookPage* general_page = newd wxPanel(book, wxID_ANY); |
| 86 | + | |
| 87 | + | wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); |
| 88 | + | wxStaticText* tmptext; |
| 89 | + | |
| 90 | + | show_welcome_dialog_chkbox = newd wxCheckBox(general_page, wxID_ANY, "Show welcome dialog on startup"); |
| 91 | + | show_welcome_dialog_chkbox->SetValue(g_settings.getInteger(Config::WELCOME_DIALOG) == 1); |
| 92 | + | show_welcome_dialog_chkbox->SetToolTip("Show welcome dialog when starting the editor."); |
| 93 | + | sizer->Add(show_welcome_dialog_chkbox, 0, wxLEFT | wxTOP, 5); |
| 94 | + | |
| 95 | + | always_make_backup_chkbox = newd wxCheckBox(general_page, wxID_ANY, "Always make map backup"); |
| 96 | + | always_make_backup_chkbox->SetValue(g_settings.getInteger(Config::ALWAYS_MAKE_BACKUP) == 1); |
| 97 | + | sizer->Add(always_make_backup_chkbox, 0, wxLEFT | wxTOP, 5); |
| 98 | + | |
| 99 | + | update_check_on_startup_chkbox = newd wxCheckBox(general_page, wxID_ANY, "Check for updates on startup"); |
| 100 | + | update_check_on_startup_chkbox->SetValue(g_settings.getInteger(Config::USE_UPDATER) == 1); |
| 101 | + | sizer->Add(update_check_on_startup_chkbox, 0, wxLEFT | wxTOP, 5); |
| 102 | + | |
| 103 | + | only_one_instance_chkbox = newd wxCheckBox(general_page, wxID_ANY, "Open all maps in the same instance"); |
| 104 | + | only_one_instance_chkbox->SetValue(g_settings.getInteger(Config::ONLY_ONE_INSTANCE) == 1); |
| 105 | + | only_one_instance_chkbox->SetToolTip("When checked, maps opened using the shell will all be opened in the same instance.\nTo run multiple instances regardless of this setting, use the RunMultipleInstances.bat file or -force-multi-instance parameter."); |
| 106 | + | sizer->Add(only_one_instance_chkbox, 0, wxLEFT | wxTOP, 5); |
| 107 | + | |
| 108 | + | enable_tileset_editing_chkbox = newd wxCheckBox(general_page, wxID_ANY, "Enable tileset editing"); |
| 109 | + | enable_tileset_editing_chkbox->SetValue(g_settings.getInteger(Config::SHOW_TILESET_EDITOR) == 1); |
| 110 | + | enable_tileset_editing_chkbox->SetToolTip("Show tileset editing options."); |
| 111 | + | sizer->Add(enable_tileset_editing_chkbox, 0, wxLEFT | wxTOP, 5); |
| 112 | + | |
| 113 | + | auto_select_raw_chkbox = newd wxCheckBox(general_page, wxID_ANY, "Auto-select RAW on right-click"); |
| 114 | + | auto_select_raw_chkbox->SetValue(g_settings.getBoolean(Config::AUTO_SELECT_RAW_ON_RIGHTCLICK)); |
| 115 | + | auto_select_raw_chkbox->SetToolTip("Automatically selects RAW brush when right-clicking items while showing the context menu."); |
| 116 | + | sizer->Add(auto_select_raw_chkbox, 0, wxLEFT | wxTOP, 5); |
| 117 | + | |
| 118 | + | sizer->AddSpacer(10); |
| 119 | + | |
| 120 | + | // Add autosave options |
| 121 | + | wxBoxSizer* autosave_sizer = newd wxBoxSizer(wxHORIZONTAL); |
| 122 | + | autosave_chkbox = newd wxCheckBox(general_page, wxID_ANY, "Enable autosave"); |
| 123 | + | autosave_chkbox->SetValue(g_settings.getBoolean(Config::AUTO_SAVE_ENABLED)); |
| 124 | + | autosave_chkbox->SetToolTip("Automatically save a backup of your map periodically"); |
| 125 | + | autosave_sizer->Add(autosave_chkbox, 0, wxALL, 5); |
| 126 | + | |
| 127 | + | autosave_interval_spin = newd wxSpinCtrl(general_page, wxID_ANY, i2ws(g_settings.getInteger(Config::AUTO_SAVE_INTERVAL)), |
| 128 | + | wxDefaultPosition, wxSize(120, -1), wxSP_ARROW_KEYS, 1, 7200, 60); |
| 129 | + | autosave_interval_spin->SetToolTip("How often (in seconds) should autosave occur"); |
| 130 | + | autosave_sizer->Add(autosave_interval_spin, 0, wxALL, 5); |
| 131 | + | autosave_sizer->Add(newd wxStaticText(general_page, wxID_ANY, "seconds"), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); |
| 132 | + | |
| 133 | + | sizer->Add(autosave_sizer); |
| 134 | + | |
| 135 | + | auto* grid_sizer = newd wxFlexGridSizer(2, 10, 10); |
| 136 | + | grid_sizer->AddGrowableCol(1); |
| 137 | + | |
| 138 | + | grid_sizer->Add(tmptext = newd wxStaticText(general_page, wxID_ANY, "Undo queue size: "), 0); |
| 139 | + | undo_size_spin = newd wxSpinCtrl(general_page, wxID_ANY, i2ws(g_settings.getInteger(Config::UNDO_SIZE)), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 0x10000000); |
| 140 | + | grid_sizer->Add(undo_size_spin, 0); |
| 141 | + | SetWindowToolTip(tmptext, undo_size_spin, "How many action you can undo, be aware that a high value will increase memory usage."); |
| 142 | + | |
| 143 | + | grid_sizer->Add(tmptext = newd wxStaticText(general_page, wxID_ANY, "Undo maximum memory size (MB): "), 0); |
| 144 | + | undo_mem_size_spin = newd wxSpinCtrl(general_page, wxID_ANY, i2ws(g_settings.getInteger(Config::UNDO_MEM_SIZE)), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 4096); |
| 145 | + | grid_sizer->Add(undo_mem_size_spin, 0); |
| 146 | + | SetWindowToolTip(tmptext, undo_mem_size_spin, "The approximite limit for the memory usage of the undo queue."); |
| 147 | + | |
| 148 | + | grid_sizer->Add(tmptext = newd wxStaticText(general_page, wxID_ANY, "Worker Threads: "), 0); |
| 149 | + | worker_threads_spin = newd wxSpinCtrl(general_page, wxID_ANY, i2ws(g_settings.getInteger(Config::WORKER_THREADS)), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 64); |
| 150 | + | grid_sizer->Add(worker_threads_spin, 0); |
| 151 | + | SetWindowToolTip(tmptext, worker_threads_spin, "How many threads the editor will use for intensive operations. This should be equivalent to the amount of logical processors in your system."); |
| 152 | + | |
| 153 | + | grid_sizer->Add(tmptext = newd wxStaticText(general_page, wxID_ANY, "Replace count: "), 0); |
| 154 | + | replace_size_spin = newd wxSpinCtrl(general_page, wxID_ANY, i2ws(g_settings.getInteger(Config::REPLACE_SIZE)), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100000); |
| 155 | + | grid_sizer->Add(replace_size_spin, 0); |
| 156 | + | SetWindowToolTip(tmptext, replace_size_spin, "How many items you can replace on the map using the Replace Item tool."); |
| 157 | + | |
| 158 | + | sizer->Add(grid_sizer, 0, wxALL, 5); |
| 159 | + | sizer->AddSpacer(10); |
| 160 | + | |
| 161 | + | wxString position_choices[] = { " {x = 0, y = 0, z = 0}", |
| 162 | + | R"( {"x":0,"y":0,"z":0})", |
| 163 | + | " x, y, z", |
| 164 | + | " (x, y, z)", |
| 165 | + | " Position(x, y, z)" }; |
| 166 | + | int radio_choices = sizeof(position_choices) / sizeof(wxString); |
| 167 | + | position_format = newd wxRadioBox(general_page, wxID_ANY, "Copy Position Format", wxDefaultPosition, wxDefaultSize, radio_choices, position_choices, 1, wxRA_SPECIFY_COLS); |
| 168 | + | position_format->SetSelection(g_settings.getInteger(Config::COPY_POSITION_FORMAT)); |
| 169 | + | sizer->Add(position_format, 0, wxALL | wxEXPAND, 5); |
| 170 | + | SetWindowToolTip(tmptext, position_format, "The position format when copying from the map."); |
| 171 | + | |
| 172 | + | general_page->SetSizerAndFit(sizer); |
| 173 | + | |
| 174 | + | return general_page; |
| 175 | + | } |
| 176 | + | |
| 177 | + | wxNotebookPage* PreferencesWindow::CreateEditorPage() { |
| 178 | + | wxNotebookPage* editor_page = newd wxPanel(book, wxID_ANY); |
| 179 | + | |
| 180 | + | wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); |
| 181 | + | |
| 182 | + | group_actions_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "Group same-type actions"); |
| 183 | + | group_actions_chkbox->SetValue(g_settings.getBoolean(Config::GROUP_ACTIONS)); |
| 184 | + | group_actions_chkbox->SetToolTip("This will group actions of the same type (drawing, selection..) when several take place in consecutive order."); |
| 185 | + | sizer->Add(group_actions_chkbox, 0, wxLEFT | wxTOP, 5); |
| 186 | + | |
| 187 | + | duplicate_id_warn_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "Warn for duplicate IDs"); |
| 188 | + | duplicate_id_warn_chkbox->SetValue(g_settings.getBoolean(Config::WARN_FOR_DUPLICATE_ID)); |
| 189 | + | duplicate_id_warn_chkbox->SetToolTip("Warns for most kinds of duplicate IDs."); |
| 190 | + | sizer->Add(duplicate_id_warn_chkbox, 0, wxLEFT | wxTOP, 5); |
| 191 | + | |
| 192 | + | house_remove_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "House brush removes items"); |
| 193 | + | house_remove_chkbox->SetValue(g_settings.getBoolean(Config::HOUSE_BRUSH_REMOVE_ITEMS)); |
| 194 | + | house_remove_chkbox->SetToolTip("When this option is checked, the house brush will automaticly remove items that will respawn every time the map is loaded."); |
| 195 | + | sizer->Add(house_remove_chkbox, 0, wxLEFT | wxTOP, 5); |
| 196 | + | |
| 197 | + | auto_assign_doors_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "Auto-assign door ids"); |
| 198 | + | auto_assign_doors_chkbox->SetValue(g_settings.getBoolean(Config::AUTO_ASSIGN_DOORID)); |
| 199 | + | auto_assign_doors_chkbox->SetToolTip("This will auto-assign unique door ids to all doors placed with the door brush (or doors painted over with the house brush).\nDoes NOT affect doors placed using the RAW palette."); |
| 200 | + | sizer->Add(auto_assign_doors_chkbox, 0, wxLEFT | wxTOP, 5); |
| 201 | + | |
| 202 | + | doodad_erase_same_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "Doodad brush only erases same"); |
| 203 | + | doodad_erase_same_chkbox->SetValue(g_settings.getBoolean(Config::DOODAD_BRUSH_ERASE_LIKE)); |
| 204 | + | doodad_erase_same_chkbox->SetToolTip("The doodad brush will only erase items that belongs to the current brush."); |
| 205 | + | sizer->Add(doodad_erase_same_chkbox, 0, wxLEFT | wxTOP, 5); |
| 206 | + | |
| 207 | + | eraser_leave_unique_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "Eraser leaves unique items"); |
| 208 | + | eraser_leave_unique_chkbox->SetValue(g_settings.getBoolean(Config::ERASER_LEAVE_UNIQUE)); |
| 209 | + | eraser_leave_unique_chkbox->SetToolTip("The eraser will leave containers with items in them, items with unique or action id and items."); |
| 210 | + | sizer->Add(eraser_leave_unique_chkbox, 0, wxLEFT | wxTOP, 5); |
| 211 | + | |
| 212 | + | auto_create_spawn_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "Auto create spawn when placing creature"); |
| 213 | + | auto_create_spawn_chkbox->SetValue(g_settings.getBoolean(Config::AUTO_CREATE_SPAWN)); |
| 214 | + | auto_create_spawn_chkbox->SetToolTip("When this option is checked, you can place creatures without placing a spawn manually, the spawn will be place automatically."); |
| 215 | + | sizer->Add(auto_create_spawn_chkbox, 0, wxLEFT | wxTOP, 5); |
| 216 | + | |
| 217 | + | allow_multiple_orderitems_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "Prevent toporder conflict"); |
| 218 | + | allow_multiple_orderitems_chkbox->SetValue(g_settings.getBoolean(Config::RAW_LIKE_SIMONE)); |
| 219 | + | allow_multiple_orderitems_chkbox->SetToolTip("When this option is checked, you can not place several items with the same toporder on one tile using a RAW Brush."); |
| 220 | + | sizer->Add(allow_multiple_orderitems_chkbox, 0, wxLEFT | wxTOP, 5); |
| 221 | + | |
| 222 | + | sizer->AddSpacer(10); |
| 223 | + | |
| 224 | + | merge_move_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "Use merge move"); |
| 225 | + | merge_move_chkbox->SetValue(g_settings.getBoolean(Config::MERGE_MOVE)); |
| 226 | + | merge_move_chkbox->SetToolTip("Moved tiles won't replace already placed tiles."); |
| 227 | + | sizer->Add(merge_move_chkbox, 0, wxLEFT | wxTOP, 5); |
| 228 | + | |
| 229 | + | merge_paste_chkbox = newd wxCheckBox(editor_page, wxID_ANY, "Use merge paste"); |
| 230 | + | merge_paste_chkbox->SetValue(g_settings.getBoolean(Config::MERGE_PASTE)); |
| 231 | + | merge_paste_chkbox->SetToolTip("Pasted tiles won't replace already placed tiles."); |
| 232 | + | sizer->Add(merge_paste_chkbox, 0, wxLEFT | wxTOP, 5); |
| 233 | + | |
| 234 | + | editor_page->SetSizerAndFit(sizer); |
| 235 | + | |
| 236 | + | return editor_page; |
| 237 | + | } |
| 238 | + | |
| 239 | + | wxNotebookPage* PreferencesWindow::CreateGraphicsPage() { |
| 240 | + | wxWindow* tmp; |
| 241 | + | wxNotebookPage* graphics_page = newd wxPanel(book, wxID_ANY); |
| 242 | + | |
| 243 | + | wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); |
| 244 | + | |
| 245 | + | hide_items_when_zoomed_chkbox = newd wxCheckBox(graphics_page, wxID_ANY, "Hide items when zoomed out"); |
| 246 | + | hide_items_when_zoomed_chkbox->SetValue(g_settings.getBoolean(Config::HIDE_ITEMS_WHEN_ZOOMED)); |
| 247 | + | hide_items_when_zoomed_chkbox->SetToolTip("Hides items when zooming out too far."); |
| 248 | + | sizer->Add(hide_items_when_zoomed_chkbox, 0, wxLEFT | wxTOP, 5); |
| 249 | + | |
| 250 | + | icon_selection_shadow_chkbox = newd wxCheckBox(graphics_page, wxID_ANY, "Use icon selection shadow"); |
| 251 | + | icon_selection_shadow_chkbox->SetValue(g_settings.getBoolean(Config::USE_GUI_SELECTION_SHADOW)); |
| 252 | + | icon_selection_shadow_chkbox->SetToolTip("When this option is enabled, a darker shadow will be used for selection highlights (for icon-based palettes)."); |
| 253 | + | sizer->Add(icon_selection_shadow_chkbox, 0, wxLEFT | wxTOP, 5); |
| 254 | + | |
| 255 | + | use_memcached_chkbox = newd wxCheckBox(graphics_page, wxID_ANY, "Cache sprites in memory"); |
| 256 | + | use_memcached_chkbox->SetValue(g_settings.getBoolean(Config::USE_MEMCACHED_SPRITES_TO_SAVE)); |
| 257 | + | use_memcached_chkbox->SetToolTip("Uncheck this to conserve memory."); |
| 258 | + | sizer->Add(use_memcached_chkbox, 0, wxLEFT | wxTOP, 5); |
| 259 | + | |
| 260 | + | dark_mode_chkbox = newd wxCheckBox(graphics_page, wxID_ANY, "Use dark mode"); |
| 261 | + | dark_mode_chkbox->SetValue(g_settings.getBoolean(Config::DARK_MODE)); |
| 262 | + | dark_mode_chkbox->SetToolTip("Enable dark mode for the application interface."); |
| 263 | + | sizer->Add(dark_mode_chkbox, 0, wxLEFT | wxTOP, 5); |
| 264 | + | |
| 265 | + | // Add dark mode color picker |
| 266 | + | wxBoxSizer* dark_mode_color_sizer = newd wxBoxSizer(wxHORIZONTAL); |
| 267 | + | dark_mode_color_sizer->Add(newd wxStaticText(graphics_page, wxID_ANY, "Custom dark mode color: "), 0, wxALIGN_CENTER_VERTICAL); |
| 268 | + | dark_mode_color_enabled_chkbox = newd wxCheckBox(graphics_page, wxID_ANY, "Enable"); |
| 269 | + | dark_mode_color_enabled_chkbox->SetValue(g_settings.getBoolean(Config::DARK_MODE_CUSTOM_COLOR)); |
| 270 | + | dark_mode_color_enabled_chkbox->SetToolTip("Use a custom color for dark mode instead of the default dark color."); |
| 271 | + | dark_mode_color_sizer->Add(dark_mode_color_enabled_chkbox, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 5); |
| 272 | + | |
| 273 | + | wxColor current_dark_color = wxColor( |
| 274 | + | g_settings.getInteger(Config::DARK_MODE_RED), |
| 275 | + | g_settings.getInteger(Config::DARK_MODE_GREEN), |
| 276 | + | g_settings.getInteger(Config::DARK_MODE_BLUE) |
| 277 | + | ); |
| 278 | + | dark_mode_color_pick = newd wxColourPickerCtrl(graphics_page, wxID_ANY, current_dark_color); |
| 279 | + | dark_mode_color_pick->SetToolTip("Select custom color for dark mode. This will be used when both dark mode and custom color are enabled."); |
| 280 | + | dark_mode_color_sizer->Add(dark_mode_color_pick, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 5); |
| 281 | + | sizer->Add(dark_mode_color_sizer, 0, wxLEFT | wxTOP, 5); |
| 282 | + | |
| 283 | + | // Connect events to update UI state |
| 284 | + | dark_mode_chkbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { |
| 285 | + | UpdateDarkModeUI(); |
| 286 | + | }); |
| 287 | + | |
| 288 | + | dark_mode_color_enabled_chkbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { |
| 289 | + | UpdateDarkModeUI(); |
| 290 | + | }); |
| 291 | + | |
| 292 | + | // Initial update of UI state |
| 293 | + | UpdateDarkModeUI(); |
| 294 | + | |
| 295 | + | sizer->AddSpacer(10); |
| 296 | + | |
| 297 | + | auto* subsizer = newd wxFlexGridSizer(2, 10, 10); |
| 298 | + | subsizer->AddGrowableCol(1); |
| 299 | + | |
| 300 | + | // Icon background color |
| 301 | + | icon_background_choice = newd wxChoice(graphics_page, wxID_ANY); |
| 302 | + | icon_background_choice->Append("Black background"); |
| 303 | + | icon_background_choice->Append("Gray background"); |
| 304 | + | icon_background_choice->Append("White background"); |
| 305 | + | if (g_settings.getInteger(Config::ICON_BACKGROUND) == 255) { |
| 306 | + | icon_background_choice->SetSelection(2); |
| 307 | + | } else if (g_settings.getInteger(Config::ICON_BACKGROUND) == 88) { |
| 308 | + | icon_background_choice->SetSelection(1); |
| 309 | + | } else { |
| 310 | + | icon_background_choice->SetSelection(0); |
| 311 | + | } |
| 312 | + | |
| 313 | + | subsizer->Add(tmp = newd wxStaticText(graphics_page, wxID_ANY, "Icon background color: "), 0); |
| 314 | + | subsizer->Add(icon_background_choice, 0); |
| 315 | + | SetWindowToolTip(icon_background_choice, tmp, "This will change the background color on icons in all windows."); |
| 316 | + | |
| 317 | + | // Cursor colors |
| 318 | + | subsizer->Add(tmp = newd wxStaticText(graphics_page, wxID_ANY, "Cursor color: "), 0); |
| 319 | + | subsizer->Add(cursor_color_pick = newd wxColourPickerCtrl(graphics_page, wxID_ANY, wxColor(g_settings.getInteger(Config::CURSOR_RED), g_settings.getInteger(Config::CURSOR_GREEN), g_settings.getInteger(Config::CURSOR_BLUE), g_settings.getInteger(Config::CURSOR_ALPHA))), 0); |
| 320 | + | SetWindowToolTip(icon_background_choice, tmp, "The color of the main cursor on the map (while in drawing mode)."); |
| 321 | + | |
| 322 | + | // Alternate cursor color |
| 323 | + | subsizer->Add(tmp = newd wxStaticText(graphics_page, wxID_ANY, "Secondary cursor color: "), 0); |
| 324 | + | subsizer->Add(cursor_alt_color_pick = newd wxColourPickerCtrl(graphics_page, wxID_ANY, wxColor(g_settings.getInteger(Config::CURSOR_ALT_RED), g_settings.getInteger(Config::CURSOR_ALT_GREEN), g_settings.getInteger(Config::CURSOR_ALT_BLUE), g_settings.getInteger(Config::CURSOR_ALT_ALPHA))), 0); |
| 325 | + | SetWindowToolTip(icon_background_choice, tmp, "The color of the secondary cursor on the map (for houses and flags)."); |
| 326 | + | |
| 327 | + | // Screenshot dir |
| 328 | + | subsizer->Add(tmp = newd wxStaticText(graphics_page, wxID_ANY, "Screenshot directory: "), 0); |
| 329 | + | screenshot_directory_picker = newd wxDirPickerCtrl(graphics_page, wxID_ANY); |
| 330 | + | subsizer->Add(screenshot_directory_picker, 1, wxEXPAND); |
| 331 | + | wxString ss = wxstr(g_settings.getString(Config::SCREENSHOT_DIRECTORY)); |
| 332 | + | screenshot_directory_picker->SetPath(ss); |
| 333 | + | SetWindowToolTip(screenshot_directory_picker, "Screenshot taken in the editor will be saved to this directory."); |
| 334 | + | |
| 335 | + | // Screenshot format |
| 336 | + | screenshot_format_choice = newd wxChoice(graphics_page, wxID_ANY); |
| 337 | + | screenshot_format_choice->Append("PNG"); |
| 338 | + | screenshot_format_choice->Append("JPG"); |
| 339 | + | screenshot_format_choice->Append("TGA"); |
| 340 | + | screenshot_format_choice->Append("BMP"); |
| 341 | + | if (g_settings.getString(Config::SCREENSHOT_FORMAT) == "png") { |
| 342 | + | screenshot_format_choice->SetSelection(0); |
| 343 | + | } else if (g_settings.getString(Config::SCREENSHOT_FORMAT) == "jpg") { |
| 344 | + | screenshot_format_choice->SetSelection(1); |
| 345 | + | } else if (g_settings.getString(Config::SCREENSHOT_FORMAT) == "tga") { |
| 346 | + | screenshot_format_choice->SetSelection(2); |
| 347 | + | } else if (g_settings.getString(Config::SCREENSHOT_FORMAT) == "bmp") { |
| 348 | + | screenshot_format_choice->SetSelection(3); |
| 349 | + | } else { |
| 350 | + | screenshot_format_choice->SetSelection(0); |
| 351 | + | } |
| 352 | + | subsizer->Add(tmp = newd wxStaticText(graphics_page, wxID_ANY, "Screenshot format: "), 0); |
| 353 | + | subsizer->Add(screenshot_format_choice, 0); |
| 354 | + | SetWindowToolTip(screenshot_format_choice, tmp, "This will affect the screenshot format used by the editor.\nTo take a screenshot, press F11."); |
| 355 | + | |
| 356 | + | sizer->Add(subsizer, 1, wxEXPAND | wxALL, 5); |
| 357 | + | |
| 358 | + | // Advanced g_settings |
| 359 | + | /* |
| 360 | + | wxCollapsiblePane* pane = newd wxCollapsiblePane(graphics_page, PANE_ADVANCED_GRAPHICS, "Advanced g_settings"); |
| 361 | + | { |
| 362 | + | wxSizer* pane_sizer = newd wxBoxSizer(wxVERTICAL); |
| 363 | + | |
| 364 | + | pane_sizer->Add(texture_managment_chkbox = newd wxCheckBox(pane->GetPane(), wxID_ANY, "Use texture managment")); |
| 365 | + | if(g_settings.getInteger(Config::TEXTURE_MANAGEMENT)) { |
| 366 | + | texture_managment_chkbox->SetValue(true); |
| 367 | + | } |
| 368 | + | pane_sizer->AddSpacer(8); |
| 369 | + | |
| 370 | + | wxFlexGridSizer* pane_grid_sizer = newd wxFlexGridSizer(2, 10, 10); |
| 371 | + | pane_grid_sizer->AddGrowableCol(1); |
| 372 | + | |
| 373 | + | pane_grid_sizer->Add(tmp = newd wxStaticText(pane->GetPane(), wxID_ANY, "Texture clean interval: "), 0); |
| 374 | + | clean_interval_spin = newd wxSpinCtrl(pane->GetPane(), wxID_ANY, i2ws(g_settings.getInteger(Config::TEXTURE_CLEAN_PULSE)), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 0x1000000); |
| 375 | + | pane_grid_sizer->Add(clean_interval_spin, 0); |
| 376 | + | SetWindowToolTip(clean_interval_spin, tmp, "This controls how often the editor tries to free hardware texture resources."); |
| 377 | + | |
| 378 | + | pane_grid_sizer->Add(tmp = newd wxStaticText(pane->GetPane(), wxID_ANY, "Texture longevity: "), 0); |
| 379 | + | texture_longevity_spin = newd wxSpinCtrl(pane->GetPane(), wxID_ANY, i2ws(g_settings.getInteger(Config::TEXTURE_LONGEVITY)), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 0x1000000); |
| 380 | + | pane_grid_sizer->Add(texture_longevity_spin, 0); |
| 381 | + | SetWindowToolTip(texture_longevity_spin, tmp, "This controls for how long (in seconds) that the editor will keep textures in memory before it cleans them up."); |
| 382 | + | |
| 383 | + | pane_grid_sizer->Add(tmp = newd wxStaticText(pane->GetPane(), wxID_ANY, "Texture clean threshold: "), 0); |
| 384 | + | texture_threshold_spin = newd wxSpinCtrl(pane->GetPane(), wxID_ANY, i2ws(g_settings.getInteger(Config::TEXTURE_CLEAN_THRESHOLD)), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 100, 0x1000000); |
| 385 | + | pane_grid_sizer->Add(texture_threshold_spin, 0); |
| 386 | + | SetWindowToolTip(texture_threshold_spin, tmp, "This controls how many textures the editor will hold in memory before it attempts to clean up old textures. However, an infinite amount MIGHT be loaded."); |
| 387 | + | |
| 388 | + | pane_grid_sizer->Add(tmp = newd wxStaticText(pane->GetPane(), wxID_ANY, "Software clean threshold: "), 0); |
| 389 | + | software_threshold_spin = newd wxSpinCtrl(pane->GetPane(), wxID_ANY, i2ws(g_settings.getInteger(Config::SOFTWARE_CLEAN_THRESHOLD)), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 100, 0x1000000); |
| 390 | + | pane_grid_sizer->Add(software_threshold_spin, 0); |
| 391 | + | SetWindowToolTip(software_threshold_spin, tmp, "This controls how many GUI sprites (icons) the editor will hold in memory at the same time."); |
| 392 | + | |
| 393 | + | pane_grid_sizer->Add(tmp = newd wxStaticText(pane->GetPane(), wxID_ANY, "Software clean amount: "), 0); |
| 394 | + | software_clean_amount_spin = newd wxSpinCtrl(pane->GetPane(), wxID_ANY, i2ws(g_settings.getInteger(Config::SOFTWARE_CLEAN_SIZE)), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 0x1000000); |
| 395 | + | pane_grid_sizer->Add(software_clean_amount_spin, 0); |
| 396 | + | SetWindowToolTip(software_clean_amount_spin, tmp, "How many sprites the editor will free at once when the limit is exceeded."); |
| 397 | + | |
| 398 | + | pane_sizer->Add(pane_grid_sizer, 0, wxEXPAND); |
| 399 | + | |
| 400 | + | pane->GetPane()->SetSizerAndFit(pane_sizer); |
| 401 | + | |
| 402 | + | pane->Collapse(); |
| 403 | + | } |
| 404 | + | |
| 405 | + | sizer->Add(pane, 0); |
| 406 | + | */ |
| 407 | + | |
| 408 | + | graphics_page->SetSizerAndFit(sizer); |
| 409 | + | |
| 410 | + | return graphics_page; |
| 411 | + | } |
| 412 | + | |
| 413 | + | wxChoice* PreferencesWindow::AddPaletteStyleChoice(wxWindow* parent, wxSizer* sizer, const wxString& short_description, const wxString& description, const std::string& setting) { |
| 414 | + | wxStaticText* text; |
| 415 | + | sizer->Add(text = newd wxStaticText(parent, wxID_ANY, short_description), 0); |
| 416 | + | |
| 417 | + | wxChoice* choice = newd wxChoice(parent, wxID_ANY); |
| 418 | + | sizer->Add(choice, 0); |
| 419 | + | |
| 420 | + | choice->Append("Large Icons"); |
| 421 | + | choice->Append("Small Icons"); |
| 422 | + | choice->Append("Listbox with Icons"); |
| 423 | + | |
| 424 | + | // Add Direct Draw option for RAW palette only |
| 425 | + | if (short_description.Contains("RAW")) { |
| 426 | + | choice->Append("Direct Draw"); |
| 427 | + | } |
| 428 | + | |
| 429 | + | text->SetToolTip(description); |
| 430 | + | choice->SetToolTip(description); |
| 431 | + | |
| 432 | + | if (setting == "large icons") { |
| 433 | + | choice->SetSelection(0); |
| 434 | + | } else if (setting == "small icons") { |
| 435 | + | choice->SetSelection(1); |
| 436 | + | } else if (setting == "listbox") { |
| 437 | + | choice->SetSelection(2); |
| 438 | + | } else if (setting == "direct draw") { |
| 439 | + | choice->SetSelection(3); |
| 440 | + | } |
| 441 | + | |
| 442 | + | return choice; |
| 443 | + | } |
| 444 | + | |
| 445 | + | void PreferencesWindow::SetPaletteStyleChoice(wxChoice* ctrl, int key) { |
| 446 | + | if (ctrl->GetSelection() == 0) { |
| 447 | + | g_settings.setString(key, "large icons"); |
| 448 | + | } else if (ctrl->GetSelection() == 1) { |
| 449 | + | g_settings.setString(key, "small icons"); |
| 450 | + | } else if (ctrl->GetSelection() == 2) { |
| 451 | + | g_settings.setString(key, "listbox"); |
| 452 | + | } else if (ctrl->GetSelection() == 3 && ctrl->GetString(3) == "Direct Draw") { |
| 453 | + | g_settings.setString(key, "direct draw"); |
| 454 | + | } |
| 455 | + | } |
| 456 | + | |
| 457 | + | wxNotebookPage* PreferencesWindow::CreateUIPage() { |
| 458 | + | wxNotebookPage* ui_page = newd wxPanel(book, wxID_ANY); |
| 459 | + | |
| 460 | + | wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); |
| 461 | + | |
| 462 | + | auto* subsizer = newd wxFlexGridSizer(2, 10, 10); |
| 463 | + | subsizer->AddGrowableCol(1); |
| 464 | + | terrain_palette_style_choice = AddPaletteStyleChoice( |
| 465 | + | ui_page, subsizer, |
| 466 | + | "Terrain Palette Style:", |
| 467 | + | "Configures the look of the terrain palette.", |
| 468 | + | g_settings.getString(Config::PALETTE_TERRAIN_STYLE) |
| 469 | + | ); |
| 470 | + | collection_palette_style_choice = AddPaletteStyleChoice( |
| 471 | + | ui_page, subsizer, |
| 472 | + | "Collections Palette Style:", |
| 473 | + | "Configures the look of the collections palette.", |
| 474 | + | g_settings.getString(Config::PALETTE_COLLECTION_STYLE) |
| 475 | + | ); |
| 476 | + | doodad_palette_style_choice = AddPaletteStyleChoice( |
| 477 | + | ui_page, subsizer, |
| 478 | + | "Doodad Palette Style:", |
| 479 | + | "Configures the look of the doodad palette.", |
| 480 | + | g_settings.getString(Config::PALETTE_DOODAD_STYLE) |
| 481 | + | ); |
| 482 | + | item_palette_style_choice = AddPaletteStyleChoice( |
| 483 | + | ui_page, subsizer, |
| 484 | + | "Item Palette Style:", |
| 485 | + | "Configures the look of the item palette.", |
| 486 | + | g_settings.getString(Config::PALETTE_ITEM_STYLE) |
| 487 | + | ); |
| 488 | + | raw_palette_style_choice = AddPaletteStyleChoice( |
| 489 | + | ui_page, subsizer, |
| 490 | + | "RAW Palette Style:", |
| 491 | + | "Configures the look of the raw palette.", |
| 492 | + | g_settings.getString(Config::PALETTE_RAW_STYLE) |
| 493 | + | ); |
| 494 | + | |
| 495 | + | sizer->Add(subsizer, 0, wxALL, 6); |
| 496 | + | |
| 497 | + | sizer->AddSpacer(10); |
| 498 | + | |
| 499 | + | large_terrain_tools_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Use large terrain palette tool && size icons"); |
| 500 | + | large_terrain_tools_chkbox->SetValue(g_settings.getBoolean(Config::USE_LARGE_TERRAIN_TOOLBAR)); |
| 501 | + | sizer->Add(large_terrain_tools_chkbox, 0, wxLEFT | wxTOP, 5); |
| 502 | + | |
| 503 | + | large_collection_tools_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Use large collections palette tool && size icons"); |
| 504 | + | large_collection_tools_chkbox->SetValue(g_settings.getBoolean(Config::USE_LARGE_COLLECTION_TOOLBAR)); |
| 505 | + | sizer->Add(large_collection_tools_chkbox, 0, wxLEFT | wxTOP, 5); |
| 506 | + | |
| 507 | + | large_doodad_sizebar_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Use large doodad size palette icons"); |
| 508 | + | large_doodad_sizebar_chkbox->SetValue(g_settings.getBoolean(Config::USE_LARGE_DOODAD_SIZEBAR)); |
| 509 | + | sizer->Add(large_doodad_sizebar_chkbox, 0, wxLEFT | wxTOP, 5); |
| 510 | + | |
| 511 | + | large_item_sizebar_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Use large item size palette icons"); |
| 512 | + | large_item_sizebar_chkbox->SetValue(g_settings.getBoolean(Config::USE_LARGE_ITEM_SIZEBAR)); |
| 513 | + | sizer->Add(large_item_sizebar_chkbox, 0, wxLEFT | wxTOP, 5); |
| 514 | + | |
| 515 | + | large_house_sizebar_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Use large house palette size icons"); |
| 516 | + | large_house_sizebar_chkbox->SetValue(g_settings.getBoolean(Config::USE_LARGE_HOUSE_SIZEBAR)); |
| 517 | + | sizer->Add(large_house_sizebar_chkbox, 0, wxLEFT | wxTOP, 5); |
| 518 | + | |
| 519 | + | large_raw_sizebar_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Use large raw palette size icons"); |
| 520 | + | large_raw_sizebar_chkbox->SetValue(g_settings.getBoolean(Config::USE_LARGE_RAW_SIZEBAR)); |
| 521 | + | sizer->Add(large_raw_sizebar_chkbox, 0, wxLEFT | wxTOP, 5); |
| 522 | + | |
| 523 | + | large_container_icons_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Use large container view icons"); |
| 524 | + | large_container_icons_chkbox->SetValue(g_settings.getBoolean(Config::USE_LARGE_CONTAINER_ICONS)); |
| 525 | + | sizer->Add(large_container_icons_chkbox, 0, wxLEFT | wxTOP, 5); |
| 526 | + | |
| 527 | + | large_pick_item_icons_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Use large item picker icons"); |
| 528 | + | large_pick_item_icons_chkbox->SetValue(g_settings.getBoolean(Config::USE_LARGE_CHOOSE_ITEM_ICONS)); |
| 529 | + | sizer->Add(large_pick_item_icons_chkbox, 0, wxLEFT | wxTOP, 5); |
| 530 | + | |
| 531 | + | sizer->AddSpacer(10); |
| 532 | + | |
| 533 | + | switch_mousebtn_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Switch mousebuttons"); |
| 534 | + | switch_mousebtn_chkbox->SetValue(g_settings.getBoolean(Config::SWITCH_MOUSEBUTTONS)); |
| 535 | + | switch_mousebtn_chkbox->SetToolTip("Switches the right and center mouse button."); |
| 536 | + | sizer->Add(switch_mousebtn_chkbox, 0, wxLEFT | wxTOP, 5); |
| 537 | + | |
| 538 | + | doubleclick_properties_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Double click for properties"); |
| 539 | + | doubleclick_properties_chkbox->SetValue(g_settings.getBoolean(Config::DOUBLECLICK_PROPERTIES)); |
| 540 | + | doubleclick_properties_chkbox->SetToolTip("Double clicking on a tile will bring up the properties menu for the top item."); |
| 541 | + | sizer->Add(doubleclick_properties_chkbox, 0, wxLEFT | wxTOP, 5); |
| 542 | + | |
| 543 | + | inversed_scroll_chkbox = newd wxCheckBox(ui_page, wxID_ANY, "Use inversed scroll"); |
| 544 | + | inversed_scroll_chkbox->SetValue(g_settings.getFloat(Config::SCROLL_SPEED) < 0); |
| 545 | + | inversed_scroll_chkbox->SetToolTip("When this checkbox is checked, dragging the map using the center mouse button will be inversed (default RTS behaviour)."); |
| 546 | + | sizer->Add(inversed_scroll_chkbox, 0, wxLEFT | wxTOP, 5); |
| 547 | + | |
| 548 | + | sizer->AddSpacer(10); |
| 549 | + | |
| 550 | + | sizer->Add(newd wxStaticText(ui_page, wxID_ANY, "Scroll speed: "), 0, wxLEFT | wxTOP, 5); |
| 551 | + | |
| 552 | + | auto true_scrollspeed = int(std::abs(g_settings.getFloat(Config::SCROLL_SPEED)) * 10); |
| 553 | + | scroll_speed_slider = newd wxSlider(ui_page, wxID_ANY, true_scrollspeed, 1, max(true_scrollspeed, 100)); |
| 554 | + | scroll_speed_slider->SetToolTip("This controls how fast the map will scroll when you hold down the center mouse button and move it around."); |
| 555 | + | sizer->Add(scroll_speed_slider, 0, wxEXPAND, 5); |
| 556 | + | |
| 557 | + | sizer->Add(newd wxStaticText(ui_page, wxID_ANY, "Zoom speed: "), 0, wxLEFT | wxTOP, 5); |
| 558 | + | |
| 559 | + | auto true_zoomspeed = int(g_settings.getFloat(Config::ZOOM_SPEED) * 10); |
| 560 | + | zoom_speed_slider = newd wxSlider(ui_page, wxID_ANY, true_zoomspeed, 1, max(true_zoomspeed, 100)); |
| 561 | + | zoom_speed_slider->SetToolTip("This controls how fast you will zoom when you scroll the center mouse button."); |
| 562 | + | sizer->Add(zoom_speed_slider, 0, wxEXPAND, 5); |
| 563 | + | |
| 564 | + | ui_page->SetSizerAndFit(sizer); |
| 565 | + | |
| 566 | + | return ui_page; |
| 567 | + | } |
| 568 | + | |
| 569 | + | wxNotebookPage* PreferencesWindow::CreateClientPage() { |
| 570 | + | wxNotebookPage* client_page = newd wxPanel(book, wxID_ANY); |
| 571 | + | |
| 572 | + | // Refresh g_settings |
| 573 | + | ClientVersion::saveVersions(); |
| 574 | + | ClientVersionList versions = ClientVersion::getAllVisible(); |
| 575 | + | |
| 576 | + | wxSizer* topsizer = newd wxBoxSizer(wxVERTICAL); |
| 577 | + | |
| 578 | + | auto* options_sizer = newd wxFlexGridSizer(2, 10, 10); |
| 579 | + | options_sizer->AddGrowableCol(1); |
| 580 | + | |
| 581 | + | // Default client version choice control |
| 582 | + | default_version_choice = newd wxChoice(client_page, wxID_ANY); |
| 583 | + | wxStaticText* default_client_tooltip = newd wxStaticText(client_page, wxID_ANY, "Default client version:"); |
| 584 | + | options_sizer->Add(default_client_tooltip, 0, wxLEFT | wxTOP, 5); |
| 585 | + | options_sizer->Add(default_version_choice, 0, wxTOP, 5); |
| 586 | + | SetWindowToolTip(default_client_tooltip, default_version_choice, "This will decide what client version will be used when new maps are created."); |
| 587 | + | |
| 588 | + | // Check file sigs checkbox |
| 589 | + | check_sigs_chkbox = newd wxCheckBox(client_page, wxID_ANY, "Check file signatures"); |
| 590 | + | check_sigs_chkbox->SetValue(g_settings.getBoolean(Config::CHECK_SIGNATURES)); |
| 591 | + | check_sigs_chkbox->SetToolTip("When this option is not checked, the editor will load any OTB/DAT/SPR combination without complaints. This may cause graphics bugs."); |
| 592 | + | options_sizer->Add(check_sigs_chkbox, 0, wxLEFT | wxRIGHT | wxTOP, 5); |
| 593 | + | |
| 594 | + | // Add the grid sizer |
| 595 | + | topsizer->Add(options_sizer, wxSizerFlags(0).Expand()); |
| 596 | + | topsizer->AddSpacer(10); |
| 597 | + | |
| 598 | + | wxScrolledWindow* client_list_window = newd wxScrolledWindow(client_page, wxID_ANY, wxDefaultPosition, wxDefaultSize); |
| 599 | + | client_list_window->SetMinSize(FROM_DIP(this, wxSize(450, 450))); |
| 600 | + | auto* client_list_sizer = newd wxFlexGridSizer(2, 10, 10); |
| 601 | + | client_list_sizer->AddGrowableCol(1); |
| 602 | + | |
| 603 | + | int version_counter = 0; |
| 604 | + | for (auto version : versions) { |
| 605 | + | if (!version->isVisible()) { |
| 606 | + | continue; |
| 607 | + | } |
| 608 | + | |
| 609 | + | default_version_choice->Append(wxstr(version->getName())); |
| 610 | + | |
| 611 | + | wxStaticText* tmp_text = newd wxStaticText(client_list_window, wxID_ANY, wxString(version->getName())); |
| 612 | + | client_list_sizer->Add(tmp_text, wxSizerFlags(0).Expand()); |
| 613 | + | |
| 614 | + | wxDirPickerCtrl* dir_picker = newd wxDirPickerCtrl(client_list_window, wxID_ANY, version->getClientPath().GetFullPath()); |
| 615 | + | version_dir_pickers.push_back(dir_picker); |
| 616 | + | client_list_sizer->Add(dir_picker, wxSizerFlags(0).Border(wxRIGHT, 10).Expand()); |
| 617 | + | |
| 618 | + | wxString tooltip; |
| 619 | + | tooltip << "The editor will look for " << wxstr(version->getName()) << " DAT & SPR here."; |
| 620 | + | tmp_text->SetToolTip(tooltip); |
| 621 | + | dir_picker->SetToolTip(tooltip); |
| 622 | + | |
| 623 | + | if (version->getID() == g_settings.getInteger(Config::DEFAULT_CLIENT_VERSION)) { |
| 624 | + | default_version_choice->SetSelection(version_counter); |
| 625 | + | } |
| 626 | + | |
| 627 | + | version_counter++; |
| 628 | + | } |
| 629 | + | |
| 630 | + | // Set the sizers |
| 631 | + | client_list_window->SetSizer(client_list_sizer); |
| 632 | + | client_list_window->FitInside(); |
| 633 | + | client_list_window->SetScrollRate(5, 5); |
| 634 | + | topsizer->Add(client_list_window, 0, wxALL, 5); |
| 635 | + | client_page->SetSizerAndFit(topsizer); |
| 636 | + | |
| 637 | + | return client_page; |
| 638 | + | } |
| 639 | + | |
| 640 | + | wxNotebookPage* PreferencesWindow::CreateLODPage() { |
| 641 | + | wxNotebookPage* lod_page = newd wxPanel(book, wxID_ANY); |
| 642 | + | wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); |
| 643 | + | wxStaticText* tmptext; |
| 644 | + | |
| 645 | + | // Add tooltip max zoom control |
| 646 | + | wxFlexGridSizer* grid_sizer = newd wxFlexGridSizer(2, 10, 10); |
| 647 | + | grid_sizer->AddGrowableCol(1); |
| 648 | + | |
| 649 | + | // Tooltip settings |
| 650 | + | grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Tooltip max zoom: "), 0); |
| 651 | + | tooltip_max_zoom_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::TOOLTIP_MAX_ZOOM)), |
| 652 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 10); |
| 653 | + | grid_sizer->Add(tooltip_max_zoom_spin, 0); |
| 654 | + | SetWindowToolTip(tmptext, tooltip_max_zoom_spin, "When zoomed out beyond this level, tooltips will not be generated to improve performance."); |
| 655 | + | |
| 656 | + | // Ground only rendering threshold |
| 657 | + | grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Ground-only zoom threshold: "), 0); |
| 658 | + | ground_only_threshold_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::GROUND_ONLY_ZOOM_THRESHOLD)), |
| 659 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 50, 8); |
| 660 | + | grid_sizer->Add(ground_only_threshold_spin, 0); |
| 661 | + | SetWindowToolTip(tmptext, ground_only_threshold_spin, "When zoomed out beyond this level, only ground tiles will be rendered for better performance."); |
| 662 | + | |
| 663 | + | // Item display threshold |
| 664 | + | grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Item display zoom threshold: "), 0); |
| 665 | + | item_display_threshold_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::ITEM_DISPLAY_ZOOM_THRESHOLD)), |
| 666 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 50, 10); |
| 667 | + | grid_sizer->Add(item_display_threshold_spin, 0); |
| 668 | + | SetWindowToolTip(tmptext, item_display_threshold_spin, "When zoomed out beyond this level, items on tiles won't be displayed (unless hide items when zoomed is disabled)."); |
| 669 | + | |
| 670 | + | // Special features threshold |
| 671 | + | grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Special features zoom threshold: "), 0); |
| 672 | + | special_features_threshold_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::SPECIAL_FEATURES_ZOOM_THRESHOLD)), |
| 673 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 50, 10); |
| 674 | + | grid_sizer->Add(special_features_threshold_spin, 0); |
| 675 | + | SetWindowToolTip(tmptext, special_features_threshold_spin, "When zoomed out beyond this level, special features like waypoints and house exits won't be shown."); |
| 676 | + | |
| 677 | + | // Animation threshold |
| 678 | + | grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Animation zoom threshold: "), 0); |
| 679 | + | animation_threshold_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::ANIMATION_ZOOM_THRESHOLD)), |
| 680 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 20, 2); |
| 681 | + | grid_sizer->Add(animation_threshold_spin, 0); |
| 682 | + | SetWindowToolTip(tmptext, animation_threshold_spin, "When zoomed out beyond this level, item animations won't be processed for better performance."); |
| 683 | + | |
| 684 | + | // Effects threshold |
| 685 | + | grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Effects zoom threshold: "), 0); |
| 686 | + | effects_threshold_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::EFFECTS_ZOOM_THRESHOLD)), |
| 687 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 20, 6); |
| 688 | + | grid_sizer->Add(effects_threshold_spin, 0); |
| 689 | + | SetWindowToolTip(tmptext, effects_threshold_spin, "When zoomed out beyond this level, visual effects like house highlighting won't be rendered."); |
| 690 | + | |
| 691 | + | // Light threshold |
| 692 | + | grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Light zoom threshold: "), 0); |
| 693 | + | light_threshold_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::LIGHT_ZOOM_THRESHOLD)), |
| 694 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 20, 4); |
| 695 | + | grid_sizer->Add(light_threshold_spin, 0); |
| 696 | + | SetWindowToolTip(tmptext, light_threshold_spin, "When zoomed out beyond this level, light effects won't be rendered."); |
| 697 | + | |
| 698 | + | // Shade threshold |
| 699 | + | grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Shade zoom threshold: "), 0); |
| 700 | + | shade_threshold_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::SHADE_ZOOM_THRESHOLD)), |
| 701 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 30, 8); |
| 702 | + | grid_sizer->Add(shade_threshold_spin, 0); |
| 703 | + | SetWindowToolTip(tmptext, shade_threshold_spin, "When zoomed out beyond this level, tile shading won't be shown."); |
| 704 | + | |
| 705 | + | // Town/Zone threshold |
| 706 | + | grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Town/Zone zoom threshold: "), 0); |
| 707 | + | town_zone_threshold_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::TOWN_ZONE_ZOOM_THRESHOLD)), |
| 708 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 20, 6); |
| 709 | + | grid_sizer->Add(town_zone_threshold_spin, 0); |
| 710 | + | SetWindowToolTip(tmptext, town_zone_threshold_spin, "When zoomed out beyond this level, towns and zone markers won't be displayed."); |
| 711 | + | |
| 712 | + | // Grid threshold |
| 713 | + | grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Grid zoom threshold: "), 0); |
| 714 | + | grid_threshold_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::GRID_ZOOM_THRESHOLD)), |
| 715 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 50, 12); |
| 716 | + | grid_sizer->Add(grid_threshold_spin, 0); |
| 717 | + | SetWindowToolTip(tmptext, grid_threshold_spin, "When zoomed out beyond this level, the grid won't be displayed."); |
| 718 | + | |
| 719 | + | sizer->Add(grid_sizer, 0, wxALL, 5); |
| 720 | + | |
| 721 | + | // Add a separator line |
| 722 | + | wxStaticLine* separator = new wxStaticLine(lod_page, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL); |
| 723 | + | sizer->Add(separator, 0, wxEXPAND | wxALL, 5); |
| 724 | + | |
| 725 | + | // Add a section title for palette grid settings |
| 726 | + | sizer->Add(newd wxStaticText(lod_page, wxID_ANY, "Palette Grid Settings"), 0, wxALL, 5); |
| 727 | + | |
| 728 | + | // Create a new grid sizer for palette grid settings |
| 729 | + | wxFlexGridSizer* palette_grid_sizer = newd wxFlexGridSizer(2, 10, 10); |
| 730 | + | palette_grid_sizer->AddGrowableCol(1); |
| 731 | + | |
| 732 | + | // Chunk size setting |
| 733 | + | palette_grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Grid chunk size: "), 0); |
| 734 | + | chunk_size_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::GRID_CHUNK_SIZE)), |
| 735 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 500, 10000, 3000); |
| 736 | + | palette_grid_sizer->Add(chunk_size_spin, 0); |
| 737 | + | SetWindowToolTip(tmptext, chunk_size_spin, "Number of items per chunk in large tilesets. Lower values improve performance but require more navigation."); |
| 738 | + | |
| 739 | + | // Visible rows margin setting |
| 740 | + | palette_grid_sizer->Add(tmptext = newd wxStaticText(lod_page, wxID_ANY, "Visible rows margin: "), 0); |
| 741 | + | visible_rows_margin_spin = newd wxSpinCtrl(lod_page, wxID_ANY, i2ws(g_settings.getInteger(Config::GRID_VISIBLE_ROWS_MARGIN)), |
| 742 | + | wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 5, 100, 30); |
| 743 | + | palette_grid_sizer->Add(visible_rows_margin_spin, 0); |
| 744 | + | SetWindowToolTip(tmptext, visible_rows_margin_spin, "Number of extra rows to load above/below the visible area. Higher values use more memory but reduce flickering."); |
| 745 | + | |
| 746 | + | sizer->Add(palette_grid_sizer, 0, wxALL, 5); |
| 747 | + | sizer->AddSpacer(10); |
| 748 | + | |
| 749 | + | sizer->Add(newd wxStaticText(lod_page, wxID_ANY, "Higher values = better performance, less detail."), 0, wxLEFT | wxBOTTOM, 5); |
| 750 | + | |
| 751 | + | lod_page->SetSizerAndFit(sizer); |
| 752 | + | return lod_page; |
| 753 | + | } |
| 754 | + | |
| 755 | + | wxNotebookPage* PreferencesWindow::CreateAutomagicPage() { |
| 756 | + | wxNotebookPage* automagic_page = newd wxPanel(book, wxID_ANY); |
| 757 | + | wxSizer* sizer = newd wxBoxSizer(wxVERTICAL); |
| 758 | + | |
| 759 | + | // Create main checkbox for enabling/disabling automagic |
| 760 | + | automagic_enabled_chkbox = newd wxCheckBox(automagic_page, wxID_ANY, "Enable Automagic"); |
| 761 | + | automagic_enabled_chkbox->SetValue(g_settings.getBoolean(Config::USE_AUTOMAGIC)); |
| 762 | + | automagic_enabled_chkbox->SetToolTip("Automatically apply borders and wall connections when editing (Toggle with 'A' key)"); |
| 763 | + | sizer->Add(automagic_enabled_chkbox, 0, wxLEFT | wxTOP, 5); |
| 764 | + | |
| 765 | + | // Create settings group for detailed options |
| 766 | + | wxStaticBoxSizer* settings_sizer = newd wxStaticBoxSizer(wxVERTICAL, automagic_page, "Border Settings"); |
| 767 | + | |
| 768 | + | same_ground_type_chkbox = newd wxCheckBox(automagic_page, wxID_ANY, "Same Ground Type Border"); |
| 769 | + | same_ground_type_chkbox->SetValue(g_settings.getBoolean(Config::SAME_GROUND_TYPE_BORDER)); |
| 770 | + | same_ground_type_chkbox->SetToolTip("Preserve existing borders and only apply borders for the current ground type"); |
| 771 | + | settings_sizer->Add(same_ground_type_chkbox, 0, wxALL, 5); |
| 772 | + | |
| 773 | + | walls_repel_borders_chkbox = newd wxCheckBox(automagic_page, wxID_ANY, "Walls Repel Borders"); |
| 774 | + | walls_repel_borders_chkbox->SetValue(g_settings.getBoolean(Config::WALLS_REPEL_BORDERS)); |
| 775 | + | walls_repel_borders_chkbox->SetToolTip("When enabled, walls will block border generation, preventing borders from crossing through walls"); |
| 776 | + | settings_sizer->Add(walls_repel_borders_chkbox, 0, wxALL, 5); |
| 777 | + | |
| 778 | + | layer_carpets_chkbox = newd wxCheckBox(automagic_page, wxID_ANY, "Layer Carpets"); |
| 779 | + | layer_carpets_chkbox->SetValue(g_settings.getBoolean(Config::LAYER_CARPETS)); |
| 780 | + | layer_carpets_chkbox->SetToolTip("When enabled, carpet brushes will be placed on top of existing carpets instead of replacing them"); |
| 781 | + | settings_sizer->Add(layer_carpets_chkbox, 0, wxALL, 5); |
| 782 | + | |
| 783 | + | borderize_delete_chkbox = newd wxCheckBox(automagic_page, wxID_ANY, "Borderize on Delete"); |
| 784 | + | borderize_delete_chkbox->SetValue(g_settings.getBoolean(Config::BORDERIZE_DELETE)); |
| 785 | + | borderize_delete_chkbox->SetToolTip("When enabled, deleting items will trigger automatic bordering of surrounding tiles"); |
| 786 | + | settings_sizer->Add(borderize_delete_chkbox, 0, wxALL, 5); |
| 787 | + | |
| 788 | + | // Paste/Drag borderize settings |
| 789 | + | borderize_paste_chkbox = newd wxCheckBox(automagic_page, wxID_ANY, "Borderize on Paste"); |
| 790 | + | borderize_paste_chkbox->SetValue(g_settings.getBoolean(Config::BORDERIZE_PASTE)); |
| 791 | + | borderize_paste_chkbox->SetToolTip("When enabled, pasting will trigger automatic bordering"); |
| 792 | + | settings_sizer->Add(borderize_paste_chkbox, 0, wxALL, 5); |
| 793 | + | |
| 794 | + | wxBoxSizer* paste_threshold_sizer = newd wxBoxSizer(wxHORIZONTAL); |
| 795 | + | paste_threshold_sizer->Add(newd wxStaticText(automagic_page, wxID_ANY, "Paste Borderize Threshold: "), 0, wxLEFT | wxTOP, 5); |
| 796 | + | borderize_paste_threshold_spin = newd wxSpinCtrl(automagic_page, wxID_ANY, i2ws(g_settings.getInteger(Config::BORDERIZE_PASTE_THRESHOLD)), wxDefaultPosition, wxDefaultSize); |
| 797 | + | paste_threshold_sizer->Add(borderize_paste_threshold_spin, 0, wxLEFT | wxTOP, 5); |
| 798 | + | settings_sizer->Add(paste_threshold_sizer, 0, wxALL, 0); |
| 799 | + | |
| 800 | + | borderize_drag_chkbox = newd wxCheckBox(automagic_page, wxID_ANY, "Borderize on Drag"); |
| 801 | + | borderize_drag_chkbox->SetValue(g_settings.getBoolean(Config::BORDERIZE_DRAG)); |
| 802 | + | borderize_drag_chkbox->SetToolTip("When enabled, dragging will trigger automatic bordering"); |
| 803 | + | settings_sizer->Add(borderize_drag_chkbox, 0, wxALL, 5); |
| 804 | + | |
| 805 | + | wxBoxSizer* drag_threshold_sizer = newd wxBoxSizer(wxHORIZONTAL); |
| 806 | + | drag_threshold_sizer->Add(newd wxStaticText(automagic_page, wxID_ANY, "Drag Borderize Threshold: "), 0, wxLEFT | wxTOP, 5); |
| 807 | + | borderize_drag_threshold_spin = newd wxSpinCtrl(automagic_page, wxID_ANY, i2ws(g_settings.getInteger(Config::BORDERIZE_DRAG_THRESHOLD)), wxDefaultPosition, wxDefaultSize); |
| 808 | + | drag_threshold_sizer->Add(borderize_drag_threshold_spin, 0, wxLEFT | wxTOP, 5); |
| 809 | + | settings_sizer->Add(drag_threshold_sizer, 0, wxALL, 0); |
| 810 | + | |
| 811 | + | custom_border_checkbox = newd wxCheckBox(automagic_page, wxID_ANY, "Use Custom Border"); |
| 812 | + | custom_border_checkbox->SetValue(g_settings.getBoolean(Config::CUSTOM_BORDER_ENABLED)); |
| 813 | + | custom_border_checkbox->SetToolTip("Override automatic border selection with a specific border ID"); |
| 814 | + | settings_sizer->Add(custom_border_checkbox, 0, wxALL, 5); |
| 815 | + | |
| 816 | + | // Create custom border ID input field in a horizontal layout |
| 817 | + | wxBoxSizer* custom_border_sizer = newd wxBoxSizer(wxHORIZONTAL); |
| 818 | + | custom_border_id_label = newd wxStaticText(automagic_page, wxID_ANY, "Custom Border ID: "); |
| 819 | + | custom_border_sizer->Add(custom_border_id_label, 0, wxALIGN_CENTER_VERTICAL); |
| 820 | + | |
| 821 | + | custom_border_id_spin = newd wxSpinCtrl(automagic_page, wxID_ANY, i2ws(g_settings.getInteger(Config::CUSTOM_BORDER_ID)), |
| 822 | + | wxDefaultPosition, wxDefaultSize); |
| 823 | + | custom_border_id_spin->SetRange(1, 65535); |
| 824 | + | custom_border_id_spin->SetToolTip("The ID of the border to apply during automagic operations"); |
| 825 | + | custom_border_sizer->Add(custom_border_id_spin, 0, wxLEFT, 5); |
| 826 | + | |
| 827 | + | settings_sizer->Add(custom_border_sizer, 0, wxALL, 5); |
| 828 | + | |
| 829 | + | sizer->Add(settings_sizer, 0, wxEXPAND | wxALL, 5); |
| 830 | + | |
| 831 | + | // Add description text |
| 832 | + | wxStaticText* description = newd wxStaticText(automagic_page, wxID_ANY, |
| 833 | + | "The Automagic system automatically applies borders and wall connections.\n\n" |
| 834 | + | "When 'Same Ground Type Border' is enabled, the editor will:\n" |
| 835 | + | "- Preserve existing borders on tiles\n" |
| 836 | + | "- Only apply borders for the current ground type\n" |
| 837 | + | "- Respect Z-axis positioning of existing borders\n\n" |
| 838 | + | "When 'Walls Repel Borders' is enabled, the editor will:\n" |
| 839 | + | "- Prevent borders from crossing through walls\n" |
| 840 | + | "- Treat walls as barriers for border generation\n" |
| 841 | + | "The threshold values control the maximum selection size for\n" |
| 842 | + | "auto-borderizing during paste and drag operations."); |
| 843 | + | sizer->Add(description, 0, wxALL, 5); |
| 844 | + | |
| 845 | + | // Make dependent controls dynamically enable/disable based on master checkbox |
| 846 | + | automagic_enabled_chkbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { |
| 847 | + | bool enabled = automagic_enabled_chkbox->GetValue(); |
| 848 | + | same_ground_type_chkbox->Enable(enabled); |
| 849 | + | walls_repel_borders_chkbox->Enable(enabled); |
| 850 | + | layer_carpets_chkbox->Enable(enabled); |
| 851 | + | borderize_delete_chkbox->Enable(enabled); |
| 852 | + | borderize_paste_chkbox->Enable(enabled); |
| 853 | + | borderize_drag_chkbox->Enable(enabled); |
| 854 | + | borderize_paste_threshold_spin->Enable(enabled && borderize_paste_chkbox->GetValue()); |
| 855 | + | borderize_drag_threshold_spin->Enable(enabled && borderize_drag_chkbox->GetValue()); |
| 856 | + | custom_border_checkbox->Enable(enabled); |
| 857 | + | custom_border_id_spin->Enable(enabled && custom_border_checkbox->GetValue()); |
| 858 | + | custom_border_id_label->Enable(enabled && custom_border_checkbox->GetValue()); |
| 859 | + | }); |
| 860 | + | |
| 861 | + | borderize_paste_chkbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { |
| 862 | + | borderize_paste_threshold_spin->Enable(automagic_enabled_chkbox->GetValue() && borderize_paste_chkbox->GetValue()); |
| 863 | + | }); |
| 864 | + | |
| 865 | + | borderize_drag_chkbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { |
| 866 | + | borderize_drag_threshold_spin->Enable(automagic_enabled_chkbox->GetValue() && borderize_drag_chkbox->GetValue()); |
| 867 | + | }); |
| 868 | + | |
| 869 | + | custom_border_checkbox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { |
| 870 | + | custom_border_id_spin->Enable(automagic_enabled_chkbox->GetValue() && custom_border_checkbox->GetValue()); |
| 871 | + | custom_border_id_label->Enable(automagic_enabled_chkbox->GetValue() && custom_border_checkbox->GetValue()); |
| 872 | + | }); |
| 873 | + | |
| 874 | + | // Initial state setup |
| 875 | + | bool enabled = automagic_enabled_chkbox->GetValue(); |
| 876 | + | same_ground_type_chkbox->Enable(enabled); |
| 877 | + | walls_repel_borders_chkbox->Enable(enabled); |
| 878 | + | layer_carpets_chkbox->Enable(enabled); |
| 879 | + | borderize_delete_chkbox->Enable(enabled); |
| 880 | + | borderize_paste_chkbox->Enable(enabled); |
| 881 | + | borderize_drag_chkbox->Enable(enabled); |
| 882 | + | borderize_paste_threshold_spin->Enable(enabled && borderize_paste_chkbox->GetValue()); |
| 883 | + | borderize_drag_threshold_spin->Enable(enabled && borderize_drag_chkbox->GetValue()); |
| 884 | + | custom_border_checkbox->Enable(enabled); |
| 885 | + | custom_border_id_spin->Enable(enabled && custom_border_checkbox->GetValue()); |
| 886 | + | custom_border_id_label->Enable(enabled && custom_border_checkbox->GetValue()); |
| 887 | + | |
| 888 | + | automagic_page->SetSizerAndFit(sizer); |
| 889 | + | return automagic_page; |
| 890 | + | } |
| 891 | + | |
| 892 | + | // Event handlers! |
| 893 | + | |
| 894 | + | void PreferencesWindow::OnClickOK(wxCommandEvent& WXUNUSED(event)) { |
| 895 | + | Apply(); |
| 896 | + | EndModal(0); |
| 897 | + | } |
| 898 | + | |
| 899 | + | void PreferencesWindow::OnClickCancel(wxCommandEvent& WXUNUSED(event)) { |
| 900 | + | EndModal(0); |
| 901 | + | } |
| 902 | + | |
| 903 | + | void PreferencesWindow::OnClickApply(wxCommandEvent& WXUNUSED(event)) { |
| 904 | + | Apply(); |
| 905 | + | } |
| 906 | + | |
| 907 | + | void PreferencesWindow::OnCollapsiblePane(wxCollapsiblePaneEvent& event) { |
| 908 | + | auto* win = (wxWindow*)event.GetEventObject(); |
| 909 | + | win->GetParent()->Fit(); |
| 910 | + | } |
| 911 | + | |
| 912 | + | // Stuff |
| 913 | + | |
| 914 | + | void PreferencesWindow::Apply() { |
| 915 | + | bool must_restart = false; |
| 916 | + | bool palette_update_needed = false; |
| 917 | + | bool dark_mode_changed = false; |
| 918 | + | |
| 919 | + | // General |
| 920 | + | g_settings.setInteger(Config::WELCOME_DIALOG, show_welcome_dialog_chkbox->GetValue()); |
| 921 | + | g_settings.setInteger(Config::ALWAYS_MAKE_BACKUP, always_make_backup_chkbox->GetValue()); |
| 922 | + | g_settings.setInteger(Config::USE_UPDATER, update_check_on_startup_chkbox->GetValue()); |
| 923 | + | g_settings.setInteger(Config::ONLY_ONE_INSTANCE, only_one_instance_chkbox->GetValue()); |
| 924 | + | |
| 925 | + | // Check if tileset editor setting changed |
| 926 | + | if (g_settings.getBoolean(Config::SHOW_TILESET_EDITOR) != enable_tileset_editing_chkbox->GetValue()) { |
| 927 | + | palette_update_needed = true; |
| 928 | + | } |
| 929 | + | g_settings.setInteger(Config::SHOW_TILESET_EDITOR, enable_tileset_editing_chkbox->GetValue()); |
| 930 | + | |
| 931 | + | g_settings.setInteger(Config::AUTO_SELECT_RAW_ON_RIGHTCLICK, auto_select_raw_chkbox->GetValue()); |
| 932 | + | g_settings.setInteger(Config::UNDO_SIZE, undo_size_spin->GetValue()); |
| 933 | + | g_settings.setInteger(Config::UNDO_MEM_SIZE, undo_mem_size_spin->GetValue()); |
| 934 | + | g_settings.setInteger(Config::WORKER_THREADS, worker_threads_spin->GetValue()); |
| 935 | + | g_settings.setInteger(Config::REPLACE_SIZE, replace_size_spin->GetValue()); |
| 936 | + | g_settings.setInteger(Config::COPY_POSITION_FORMAT, position_format->GetSelection()); |
| 937 | + | g_settings.setInteger(Config::AUTO_SAVE_ENABLED, autosave_chkbox->GetValue()); |
| 938 | + | g_settings.setInteger(Config::AUTO_SAVE_INTERVAL, autosave_interval_spin->GetValue()); |
| 939 | + | |
| 940 | + | // LOD Settings |
| 941 | + | g_settings.setInteger(Config::TOOLTIP_MAX_ZOOM, tooltip_max_zoom_spin->GetValue()); |
| 942 | + | g_settings.setInteger(Config::GROUND_ONLY_ZOOM_THRESHOLD, ground_only_threshold_spin->GetValue()); |
| 943 | + | g_settings.setInteger(Config::ITEM_DISPLAY_ZOOM_THRESHOLD, item_display_threshold_spin->GetValue()); |
| 944 | + | g_settings.setInteger(Config::SPECIAL_FEATURES_ZOOM_THRESHOLD, special_features_threshold_spin->GetValue()); |
| 945 | + | g_settings.setInteger(Config::ANIMATION_ZOOM_THRESHOLD, animation_threshold_spin->GetValue()); |
| 946 | + | g_settings.setInteger(Config::EFFECTS_ZOOM_THRESHOLD, effects_threshold_spin->GetValue()); |
| 947 | + | g_settings.setInteger(Config::LIGHT_ZOOM_THRESHOLD, light_threshold_spin->GetValue()); |
| 948 | + | g_settings.setInteger(Config::SHADE_ZOOM_THRESHOLD, shade_threshold_spin->GetValue()); |
| 949 | + | g_settings.setInteger(Config::TOWN_ZONE_ZOOM_THRESHOLD, town_zone_threshold_spin->GetValue()); |
| 950 | + | g_settings.setInteger(Config::GRID_ZOOM_THRESHOLD, grid_threshold_spin->GetValue()); |
| 951 | + | |
| 952 | + | // Palette grid settings |
| 953 | + | g_settings.setInteger(Config::GRID_CHUNK_SIZE, chunk_size_spin->GetValue()); |
| 954 | + | g_settings.setInteger(Config::GRID_VISIBLE_ROWS_MARGIN, visible_rows_margin_spin->GetValue()); |
| 955 | + | |
| 956 | + | // Editor |
| 957 | + | g_settings.setInteger(Config::GROUP_ACTIONS, group_actions_chkbox->GetValue()); |
| 958 | + | g_settings.setInteger(Config::WARN_FOR_DUPLICATE_ID, duplicate_id_warn_chkbox->GetValue()); |
| 959 | + | g_settings.setInteger(Config::HOUSE_BRUSH_REMOVE_ITEMS, house_remove_chkbox->GetValue()); |
| 960 | + | g_settings.setInteger(Config::AUTO_ASSIGN_DOORID, auto_assign_doors_chkbox->GetValue()); |
| 961 | + | g_settings.setInteger(Config::ERASER_LEAVE_UNIQUE, eraser_leave_unique_chkbox->GetValue()); |
| 962 | + | g_settings.setInteger(Config::DOODAD_BRUSH_ERASE_LIKE, doodad_erase_same_chkbox->GetValue()); |
| 963 | + | g_settings.setInteger(Config::AUTO_CREATE_SPAWN, auto_create_spawn_chkbox->GetValue()); |
| 964 | + | g_settings.setInteger(Config::RAW_LIKE_SIMONE, allow_multiple_orderitems_chkbox->GetValue()); |
| 965 | + | g_settings.setInteger(Config::MERGE_MOVE, merge_move_chkbox->GetValue()); |
| 966 | + | g_settings.setInteger(Config::MERGE_PASTE, merge_paste_chkbox->GetValue()); |
| 967 | + | |
| 968 | + | |
| 969 | + | // Graphics |
| 970 | + | g_settings.setInteger(Config::USE_GUI_SELECTION_SHADOW, icon_selection_shadow_chkbox->GetValue()); |
| 971 | + | if (g_settings.getBoolean(Config::USE_MEMCACHED_SPRITES) != use_memcached_chkbox->GetValue()) { |
| 972 | + | must_restart = true; |
| 973 | + | } |
| 974 | + | g_settings.setInteger(Config::USE_MEMCACHED_SPRITES_TO_SAVE, use_memcached_chkbox->GetValue()); |
| 975 | + | if (icon_background_choice->GetSelection() == 0) { |
| 976 | + | if (g_settings.getInteger(Config::ICON_BACKGROUND) != 0) { |
| 977 | + | g_gui.gfx.cleanSoftwareSprites(); |
| 978 | + | } |
| 979 | + | g_settings.setInteger(Config::ICON_BACKGROUND, 0); |
| 980 | + | } else if (icon_background_choice->GetSelection() == 1) { |
| 981 | + | if (g_settings.getInteger(Config::ICON_BACKGROUND) != 88) { |
| 982 | + | g_gui.gfx.cleanSoftwareSprites(); |
| 983 | + | } |
| 984 | + | g_settings.setInteger(Config::ICON_BACKGROUND, 88); |
| 985 | + | } else if (icon_background_choice->GetSelection() == 2) { |
| 986 | + | if (g_settings.getInteger(Config::ICON_BACKGROUND) != 255) { |
| 987 | + | g_gui.gfx.cleanSoftwareSprites(); |
| 988 | + | } |
| 989 | + | g_settings.setInteger(Config::ICON_BACKGROUND, 255); |
| 990 | + | } |
| 991 | + | |
| 992 | + | // Dark mode setting |
| 993 | + | bool new_dark_mode_value = dark_mode_chkbox->GetValue(); |
| 994 | + | if (g_settings.getBoolean(Config::DARK_MODE) != new_dark_mode_value) { |
| 995 | + | g_settings.setInteger(Config::DARK_MODE, new_dark_mode_value ? 1 : 0); |
| 996 | + | dark_mode_changed = true; |
| 997 | + | } |
| 998 | + | |
| 999 | + | // Dark mode custom color settings |
| 1000 | + | bool new_custom_color_value = dark_mode_color_enabled_chkbox->GetValue(); |
| 1001 | + | if (g_settings.getBoolean(Config::DARK_MODE_CUSTOM_COLOR) != new_custom_color_value) { |
| 1002 | + | g_settings.setInteger(Config::DARK_MODE_CUSTOM_COLOR, new_custom_color_value ? 1 : 0); |
| 1003 | + | dark_mode_changed = true; |
| 1004 | + | } |
| 1005 | + | |
| 1006 | + | wxColor dark_mode_clr = dark_mode_color_pick->GetColour(); |
| 1007 | + | if (g_settings.getInteger(Config::DARK_MODE_RED) != dark_mode_clr.Red() || |
| 1008 | + | g_settings.getInteger(Config::DARK_MODE_GREEN) != dark_mode_clr.Green() || |
| 1009 | + | g_settings.getInteger(Config::DARK_MODE_BLUE) != dark_mode_clr.Blue()) { |
| 1010 | + | |
| 1011 | + | g_settings.setInteger(Config::DARK_MODE_RED, dark_mode_clr.Red()); |
| 1012 | + | g_settings.setInteger(Config::DARK_MODE_GREEN, dark_mode_clr.Green()); |
| 1013 | + | g_settings.setInteger(Config::DARK_MODE_BLUE, dark_mode_clr.Blue()); |
| 1014 | + | dark_mode_changed = true; |
| 1015 | + | } |
| 1016 | + | |
| 1017 | + | // Screenshots |
| 1018 | + | g_settings.setString(Config::SCREENSHOT_DIRECTORY, nstr(screenshot_directory_picker->GetPath())); |
| 1019 | + | |
| 1020 | + | std::string new_format = nstr(screenshot_format_choice->GetStringSelection()); |
| 1021 | + | if (new_format == "PNG") { |
| 1022 | + | g_settings.setString(Config::SCREENSHOT_FORMAT, "png"); |
| 1023 | + | } else if (new_format == "TGA") { |
| 1024 | + | g_settings.setString(Config::SCREENSHOT_FORMAT, "tga"); |
| 1025 | + | } else if (new_format == "JPG") { |
| 1026 | + | g_settings.setString(Config::SCREENSHOT_FORMAT, "jpg"); |
| 1027 | + | } else if (new_format == "BMP") { |
| 1028 | + | g_settings.setString(Config::SCREENSHOT_FORMAT, "bmp"); |
| 1029 | + | } |
| 1030 | + | |
| 1031 | + | wxColor clr = cursor_color_pick->GetColour(); |
| 1032 | + | g_settings.setInteger(Config::CURSOR_RED, clr.Red()); |
| 1033 | + | g_settings.setInteger(Config::CURSOR_GREEN, clr.Green()); |
| 1034 | + | g_settings.setInteger(Config::CURSOR_BLUE, clr.Blue()); |
| 1035 | + | // g_settings.setInteger(Config::CURSOR_ALPHA, clr.Alpha()); |
| 1036 | + | |
| 1037 | + | clr = cursor_alt_color_pick->GetColour(); |
| 1038 | + | g_settings.setInteger(Config::CURSOR_ALT_RED, clr.Red()); |
| 1039 | + | g_settings.setInteger(Config::CURSOR_ALT_GREEN, clr.Green()); |
| 1040 | + | g_settings.setInteger(Config::CURSOR_ALT_BLUE, clr.Blue()); |
| 1041 | + | // g_settings.setInteger(Config::CURSOR_ALT_ALPHA, clr.Alpha()); |
| 1042 | + | |
| 1043 | + | g_settings.setInteger(Config::HIDE_ITEMS_WHEN_ZOOMED, hide_items_when_zoomed_chkbox->GetValue()); |
| 1044 | + | /* |
| 1045 | + | g_settings.setInteger(Config::TEXTURE_MANAGEMENT, texture_managment_chkbox->GetValue()); |
| 1046 | + | g_settings.setInteger(Config::TEXTURE_CLEAN_PULSE, clean_interval_spin->GetValue()); |
| 1047 | + | g_settings.setInteger(Config::TEXTURE_LONGEVITY, texture_longevity_spin->GetValue()); |
| 1048 | + | g_settings.setInteger(Config::TEXTURE_CLEAN_THRESHOLD, texture_threshold_spin->GetValue()); |
| 1049 | + | g_settings.setInteger(Config::SOFTWARE_CLEAN_THRESHOLD, software_threshold_spin->GetValue()); |
| 1050 | + | g_settings.setInteger(Config::SOFTWARE_CLEAN_SIZE, software_clean_amount_spin->GetValue()); |
| 1051 | + | */ |
| 1052 | + | |
| 1053 | + | // Interface |
| 1054 | + | SetPaletteStyleChoice(terrain_palette_style_choice, Config::PALETTE_TERRAIN_STYLE); |
| 1055 | + | SetPaletteStyleChoice(collection_palette_style_choice, Config::PALETTE_COLLECTION_STYLE); |
| 1056 | + | SetPaletteStyleChoice(doodad_palette_style_choice, Config::PALETTE_DOODAD_STYLE); |
| 1057 | + | SetPaletteStyleChoice(item_palette_style_choice, Config::PALETTE_ITEM_STYLE); |
| 1058 | + | SetPaletteStyleChoice(raw_palette_style_choice, Config::PALETTE_RAW_STYLE); |
| 1059 | + | g_settings.setInteger(Config::USE_LARGE_TERRAIN_TOOLBAR, large_terrain_tools_chkbox->GetValue()); |
| 1060 | + | g_settings.setInteger(Config::USE_LARGE_COLLECTION_TOOLBAR, large_collection_tools_chkbox->GetValue()); |
| 1061 | + | g_settings.setInteger(Config::USE_LARGE_DOODAD_SIZEBAR, large_doodad_sizebar_chkbox->GetValue()); |
| 1062 | + | g_settings.setInteger(Config::USE_LARGE_ITEM_SIZEBAR, large_item_sizebar_chkbox->GetValue()); |
| 1063 | + | g_settings.setInteger(Config::USE_LARGE_HOUSE_SIZEBAR, large_house_sizebar_chkbox->GetValue()); |
| 1064 | + | g_settings.setInteger(Config::USE_LARGE_RAW_SIZEBAR, large_raw_sizebar_chkbox->GetValue()); |
| 1065 | + | g_settings.setInteger(Config::USE_LARGE_CONTAINER_ICONS, large_container_icons_chkbox->GetValue()); |
| 1066 | + | g_settings.setInteger(Config::USE_LARGE_CHOOSE_ITEM_ICONS, large_pick_item_icons_chkbox->GetValue()); |
| 1067 | + | |
| 1068 | + | g_settings.setInteger(Config::SWITCH_MOUSEBUTTONS, switch_mousebtn_chkbox->GetValue()); |
| 1069 | + | g_settings.setInteger(Config::DOUBLECLICK_PROPERTIES, doubleclick_properties_chkbox->GetValue()); |
| 1070 | + | |
| 1071 | + | float scroll_mul = 1.0; |
| 1072 | + | if (inversed_scroll_chkbox->GetValue()) { |
| 1073 | + | scroll_mul = -1.0; |
| 1074 | + | } |
| 1075 | + | g_settings.setFloat(Config::SCROLL_SPEED, scroll_mul * scroll_speed_slider->GetValue() / 10.f); |
| 1076 | + | g_settings.setFloat(Config::ZOOM_SPEED, zoom_speed_slider->GetValue() / 10.f); |
| 1077 | + | |
| 1078 | + | // Client |
| 1079 | + | ClientVersionList versions = ClientVersion::getAllVisible(); |
| 1080 | + | int version_counter = 0; |
| 1081 | + | for (auto version : versions) { |
| 1082 | + | wxString dir = version_dir_pickers[version_counter]->GetPath(); |
| 1083 | + | if (dir.Length() > 0 && dir.Last() != '/' && dir.Last() != '\\') { |
| 1084 | + | dir.Append("/"); |
| 1085 | + | } |
| 1086 | + | version->setClientPath(FileName(dir)); |
| 1087 | + | |
| 1088 | + | if (version->getName() == default_version_choice->GetStringSelection()) { |
| 1089 | + | g_settings.setInteger(Config::DEFAULT_CLIENT_VERSION, version->getID()); |
| 1090 | + | } |
| 1091 | + | |
| 1092 | + | version_counter++; |
| 1093 | + | } |
| 1094 | + | g_settings.setInteger(Config::CHECK_SIGNATURES, check_sigs_chkbox->GetValue()); |
| 1095 | + | |
| 1096 | + | // Make sure to reload client paths |
| 1097 | + | ClientVersion::saveVersions(); |
| 1098 | + | ClientVersion::loadVersions(); |
| 1099 | + | |
| 1100 | + | g_settings.save(); |
| 1101 | + | |
| 1102 | + | if (must_restart) { |
| 1103 | + | g_gui.PopupDialog(this, "Notice", "You must restart the editor for the changes to take effect.", wxOK); |
| 1104 | + | } |
| 1105 | + | |
| 1106 | + | if (dark_mode_changed) { |
| 1107 | + | g_darkMode.ToggleDarkMode(); |
| 1108 | + | g_darkMode.ApplyTheme(g_gui.root); |
| 1109 | + | g_gui.PopupDialog(this, "Dark Mode Changed", "The application theme has been changed. Some elements may require a restart to display correctly.", wxOK); |
| 1110 | + | } |
| 1111 | + | |
| 1112 | + | if (palette_update_needed) { |
| 1113 | + | // Rebuild the palettes completely |
| 1114 | + | g_gui.RebuildPalettes(); |
| 1115 | + | } else { |
| 1116 | + | // Just refresh the palettes with updated settings |
| 1117 | + | g_gui.RefreshPalettes(); |
| 1118 | + | } |
| 1119 | + | |
| 1120 | + | g_settings.setInteger(Config::AUTO_SAVE_ENABLED, autosave_chkbox->GetValue()); |
| 1121 | + | g_settings.setInteger(Config::AUTO_SAVE_INTERVAL, autosave_interval_spin->GetValue()); |
| 1122 | + | g_settings.setInteger(Config::USE_AUTOMAGIC, automagic_enabled_chkbox->GetValue()); |
| 1123 | + | g_settings.setInteger(Config::SAME_GROUND_TYPE_BORDER, same_ground_type_chkbox->GetValue()); |
| 1124 | + | g_settings.setInteger(Config::WALLS_REPEL_BORDERS, walls_repel_borders_chkbox->GetValue()); |
| 1125 | + | g_settings.setInteger(Config::LAYER_CARPETS, layer_carpets_chkbox->GetValue()); |
| 1126 | + | g_settings.setInteger(Config::BORDERIZE_DELETE, borderize_delete_chkbox->GetValue()); |
| 1127 | + | g_settings.setInteger(Config::BORDERIZE_PASTE, borderize_paste_chkbox->GetValue()); |
| 1128 | + | g_settings.setInteger(Config::BORDERIZE_PASTE_THRESHOLD, borderize_paste_threshold_spin->GetValue()); |
| 1129 | + | g_settings.setInteger(Config::BORDERIZE_DRAG, borderize_drag_chkbox->GetValue()); |
| 1130 | + | g_settings.setInteger(Config::BORDERIZE_DRAG_THRESHOLD, borderize_drag_threshold_spin->GetValue()); |
| 1131 | + | g_settings.setInteger(Config::CUSTOM_BORDER_ENABLED, custom_border_checkbox->GetValue()); |
| 1132 | + | g_settings.setInteger(Config::CUSTOM_BORDER_ID, custom_border_id_spin->GetValue()); |
| 1133 | + | } |
| 1134 | + | |
| 1135 | + | void PreferencesWindow::UpdateDarkModeUI() { |
| 1136 | + | bool enabled = dark_mode_chkbox->GetValue(); |
| 1137 | + | dark_mode_color_enabled_chkbox->Enable(enabled); |
| 1138 | + | dark_mode_color_pick->Enable(enabled && dark_mode_color_enabled_chkbox->GetValue()); |
| 1139 | + | } |