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_WUI_ENCYCLOPEDIA_WINDOW_H 21 #define WL_WUI_ENCYCLOPEDIA_WINDOW_H 22 23 #include <memory> 24 25 #include "scripting/lua_interface.h" 26 #include "scripting/lua_table.h" 27 #include "ui_basic/box.h" 28 #include "ui_basic/listselect.h" 29 #include "ui_basic/multilinetextarea.h" 30 #include "ui_basic/table.h" 31 #include "ui_basic/tabpanel.h" 32 #include "ui_basic/unique_window.h" 33 34 class InteractiveBase; 35 36 namespace UI { 37 38 struct EncyclopediaWindow : public UI::UniqueWindow { 39 EncyclopediaWindow(InteractiveBase&, UI::UniqueWindow::Registry&, LuaInterface* const lua); 40 41 protected: 42 void init(InteractiveBase& parent, std::unique_ptr<LuaTable> table); 43 44 LuaInterface* const lua_; 45 46 private: 47 struct EncyclopediaEntry { EncyclopediaEntryEncyclopediaWindow::EncyclopediaEntry48 EncyclopediaEntry(const std::string& init_script_path, 49 const std::vector<std::string>& init_script_parameters) 50 : script_path(init_script_path), script_parameters(init_script_parameters) { 51 } 52 const std::string script_path; 53 const std::vector<std::string> script_parameters; 54 }; 55 56 // Update contents when an entry is selected 57 void entry_selected(const std::string& tab_name); 58 59 // UI elements 60 UI::TabPanel tabs_; 61 62 // Wrapper boxes so we can add some padding 63 std::map<std::string, std::unique_ptr<UI::Box>> wrapper_boxes_; 64 // Main contents boxes for each tab 65 std::map<std::string, std::unique_ptr<UI::Box>> boxes_; 66 // A tab's table of contents 67 std::map<std::string, std::unique_ptr<UI::Listselect<EncyclopediaEntry>>> lists_; 68 // The contents shown when an entry is selected in a tab 69 std::map<std::string, std::unique_ptr<UI::MultilineTextarea>> contents_; 70 }; 71 72 } // namespace UI 73 74 #endif // end of include guard: WL_WUI_ENCYCLOPEDIA_WINDOW_H 75