1 /* 2 * Copyright (C) 2002-2020 by the Widelands Development Team 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program 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, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 */ 19 20 #ifndef WL_EDITOR_UI_MENUS_MAIN_MENU_LOAD_OR_SAVE_MAP_H 21 #define WL_EDITOR_UI_MENUS_MAIN_MENU_LOAD_OR_SAVE_MAP_H 22 23 #include "editor/editorinteractive.h" 24 #include "logic/filesystem_constants.h" 25 #include "ui_basic/button.h" 26 #include "ui_basic/checkbox.h" 27 #include "ui_basic/textarea.h" 28 #include "ui_basic/unique_window.h" 29 #include "wui/mapdetails.h" 30 #include "wui/maptable.h" 31 32 /** 33 * Choose a filename and save your brand new created map 34 */ 35 struct MainMenuLoadOrSaveMap : public UI::UniqueWindow { 36 MainMenuLoadOrSaveMap(EditorInteractive& parent, 37 UI::UniqueWindow::Registry& registry, 38 const std::string& name, 39 const std::string& title, 40 const std::string& basedir = kMapsDir); 41 42 protected: 43 virtual void clicked_ok() = 0; 44 void toggle_mapnames(); 45 // Sets the current dir and updates labels. 46 virtual void set_current_directory(const std::string& filename) = 0; 47 void layout() override; 48 void fill_table(); 49 50 bool compare_players(uint32_t, uint32_t); 51 bool compare_mapnames(uint32_t, uint32_t); 52 bool compare_size(uint32_t, uint32_t); 53 54 // Private variables first, because compiler would complain about initialization order otherwise 55 private: 56 // Common padding between panels 57 int32_t const padding_; 58 59 // Main vertical container for the UI elements 60 UI::Box main_box_; 61 62 // Top row with button for toggling map names/filenames 63 UI::Box show_mapnames_box_; 64 UI::Button show_mapnames_; 65 66 // Big flexible panel in the middle for the table and map details 67 UI::Box table_and_details_box_; 68 69 protected: 70 // Table of maps and its data 71 MapTable table_; 72 std::vector<MapData> maps_data_; 73 74 // Side panel with details about the currently selected map 75 UI::Box map_details_box_; 76 MapDetails map_details_; 77 78 // UI row below the table that can be filled by subclasses 79 UI::Box table_footer_box_; 80 81 // Shows name of current directory 82 UI::Textarea directory_info_; 83 84 // Bottom row with OK/Cancel buttons 85 UI::Box button_box_; 86 UI::Button ok_, cancel_; 87 88 // Settings data 89 const std::string basedir_; 90 std::string curdir_; 91 92 bool has_translated_mapname_; 93 UI::Checkbox* cb_dont_localize_mapnames_; 94 bool showing_mapnames_; 95 }; 96 97 #endif // end of include guard: WL_EDITOR_UI_MENUS_MAIN_MENU_LOAD_OR_SAVE_MAP_H 98