widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #04443
[Merge] lp:~widelands-dev/widelands/multiplayer_help into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/multiplayer_help into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/multiplayer_help/+merge/274271
The Multiplayer help window now gets its contents from Lua, and its button will resize according to actual text height.
Split up the wui and ui_fsmenu components of helpwindow.cc/h into separate files and moved them away from ui_basic.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/multiplayer_help into lp:widelands.
=== added directory 'scripting/widelands'
=== added file 'scripting/widelands/multiplayer_help.lua'
--- scripting/widelands/multiplayer_help.lua 1970-01-01 00:00:00 +0000
+++ scripting/widelands/multiplayer_help.lua 2015-10-13 15:08:04 +0000
@@ -0,0 +1,32 @@
+include "scripting/formatting.lua"
+
+function picture_li(imagepath, text)
+ return "<rt image=" .. imagepath .. " image-align=left>" .. p(text) .. "</rt>"
+end
+
+return {
+ func = function()
+ set_textdomain("widelands")
+ local result = rt(h1(_"Multiplayer Game Setup"))
+ result = result .. rt(p(_"You are in the multiplayer launch game menu."))
+
+
+ result = result .. rt(h2(_"Client settings"))
+ result = result .. rt(p(_"On the left side is a list of all clients including you. You can set your role with the button following your nickname. Available roles are:"))
+ result = result .. picture_li("pics/genstats_enable_plr_08.png", _"The player with the color of the flag. If more than one client selected the same color, these share control over the player (‘shared kingdom mode’).")
+ result = result .. picture_li("pics/menu_tab_watch.png", _"Spectator mode, meaning you can see everything, but cannot control any player")
+
+ result = result .. rt(h2(_"Player settings"))
+ result = result .. rt(p(_"In the middle are the settings for the players. To start a game, each player must be one of the following:"))
+ result = result .. picture_li("pics/genstats_nrworkers.png", _"Connected to one or more clients (see ‘Client settings’).")
+ result = result .. picture_li("pics/ai_Normal.png", _"Connected to a computer player (the face in the picture as well as the mouse hover texts indicate the strength of the currently selected computer player).")
+ result = result .. picture_li("pics/shared_in.png", _"Set as shared in starting position for another player.")
+ result = result .. picture_li("pics/stop.png", _"Closed.")
+ result = result .. rt(p(_"The latter three can only be set by the hosting client by left-clicking the ‘type’ button of a player. Hosting players can also set the initialization of each player (the set of buildings, wares and workers the player starts with) and the tribe and team for computer players"))
+ result = result .. rt(p(_"Every client connected to a player (the set ‘role’ player) can set the tribe and the team for that player"))
+
+ result = result .. rt(h2(_"Map details"))
+ result = result .. rt(p(_"You can see information about the selected map or savegame on the right-hand side. A button next to the map name allows the host to change to a different map. Furthermore, the host is able to set a specific win condition, and finally can start the game as soon as all players are set up."))
+ return result
+ end
+}
=== modified file 'src/ui_basic/CMakeLists.txt'
--- src/ui_basic/CMakeLists.txt 2015-01-31 16:03:59 +0000
+++ src/ui_basic/CMakeLists.txt 2015-10-13 15:08:04 +0000
@@ -8,8 +8,6 @@
checkbox.h
editbox.cc
editbox.h
- helpwindow.cc
- helpwindow.h
icon.cc
icon.h
icongrid.cc
=== modified file 'src/ui_basic/button.cc'
--- src/ui_basic/button.cc 2015-09-26 09:07:40 +0000
+++ src/ui_basic/button.cc 2015-10-13 15:08:04 +0000
@@ -19,7 +19,6 @@
#include "ui_basic/button.h"
-#include "base/log.h"
#include "graphic/font_handler.h"
#include "graphic/image.h"
#include "graphic/rendertarget.h"
@@ -62,6 +61,7 @@
if (h < 1) {
int new_height = m_textstyle.font->height() + 4;
set_desired_size(w, new_height);
+ set_size(w, new_height);
}
set_thinks(false);
}
=== modified file 'src/ui_fsmenu/CMakeLists.txt'
--- src/ui_fsmenu/CMakeLists.txt 2015-03-04 09:17:22 +0000
+++ src/ui_fsmenu/CMakeLists.txt 2015-10-13 15:08:04 +0000
@@ -6,6 +6,8 @@
campaign_select.h
fileview.cc
fileview.h
+ helpwindow.cc
+ helpwindow.h
internet_lobby.cc
internet_lobby.h
intro.cc
=== added file 'src/ui_fsmenu/helpwindow.cc'
--- src/ui_fsmenu/helpwindow.cc 1970-01-01 00:00:00 +0000
+++ src/ui_fsmenu/helpwindow.cc 2015-10-13 15:08:04 +0000
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2002-2004, 2006-2010 by the Widelands Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "ui_fsmenu/helpwindow.h"
+
+#include <memory>
+#include <string>
+
+#include <boost/format.hpp>
+
+#include "base/i18n.h"
+#include "graphic/graphic.h"
+#include "scripting/lua_coroutine.h"
+#include "scripting/lua_table.h"
+#include "ui_basic/button.h"
+
+namespace UI {
+
+FullscreenHelpWindow::FullscreenHelpWindow
+ (Panel * const parent,
+ LuaInterface* lua,
+ const std::string& script_path,
+ const std::string & caption,
+ uint32_t width, uint32_t height)
+ :
+ Window(parent, "help_window", 0, 0, width, height, (boost::format(_("Help: %s")) % caption).str()),
+ textarea_(new MultilineTextarea(this, 5, 5, width - 10, height - 30, std::string(), Align_Left))
+{
+ int margin = 5;
+
+ // Calculate sizes
+ width = (width == 0) ? g_gr->get_xres() * 3 / 5 : width;
+ height = (height == 0) ? g_gr->get_yres() * 4 / 5 : height;
+
+ Button* btn = new Button(this, "ok", width / 3, 0, width / 3, 0,
+ g_gr->images().get("pics/but5.png"),
+ _("OK"), "", true, false);
+
+ btn->sigclicked.connect(boost::bind(&FullscreenHelpWindow::clicked_ok, boost::ref(*this)));
+ btn->set_pos(Point(btn->get_x(), height - margin - btn->get_h()));
+
+ std::string helptext;
+ try {
+ std::unique_ptr<LuaTable> t(lua->run_script(script_path));
+ std::unique_ptr<LuaCoroutine> cr(t->get_coroutine("func"));
+ cr->resume();
+ helptext = cr->pop_string();
+ } catch (LuaError& err) {
+ helptext = err.what();
+ }
+
+ textarea_->set_size(width - 2 * margin, height - btn->get_h() - 3 * margin);
+ textarea_->set_text(helptext);
+
+ set_inner_size(width, height);
+ center_to_parent();
+ focus();
+}
+
+
+/**
+ * Handle mouseclick.
+ *
+ * Clicking the right mouse button inside the window acts like pressing Ok.
+ */
+bool FullscreenHelpWindow::handle_mousepress(const uint8_t btn, int32_t, int32_t)
+{
+ if (btn == SDL_BUTTON_RIGHT) {
+ play_click();
+ clicked_ok();
+ }
+ return true;
+}
+
+bool FullscreenHelpWindow::handle_mouserelease(const uint8_t, int32_t, int32_t)
+{
+ return true;
+}
+
+bool FullscreenHelpWindow::handle_key(bool down, SDL_Keysym code)
+{
+ if (down) {
+ switch (code.sym) {
+ case SDLK_KP_ENTER:
+ case SDLK_RETURN:
+ clicked_ok();
+ return true;
+ default:
+ return true; // handled
+ }
+ }
+ return true;
+}
+
+
+void FullscreenHelpWindow::clicked_ok()
+{
+ if (is_modal())
+ end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kBack);
+ else {
+ // Do not call die() here - could lead to broken pointers.
+ // The window should get deleted with the parent anyways - best use a unique_ptr there.
+ set_visible(false);
+ }
+}
+
+} // namespace UI
=== added file 'src/ui_fsmenu/helpwindow.h'
--- src/ui_fsmenu/helpwindow.h 1970-01-01 00:00:00 +0000
+++ src/ui_fsmenu/helpwindow.h 2015-10-13 15:08:04 +0000
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2002-2004, 2006, 2008-2010 by the Widelands Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WL_UI_FSMENU_HELPWINDOW_H
+#define WL_UI_FSMENU_HELPWINDOW_H
+
+#include <memory>
+
+#include "scripting/lua_interface.h"
+#include "ui_basic/multilinetextarea.h"
+#include "ui_basic/window.h"
+
+
+namespace UI {
+
+/**
+ * Shows a help window with an OK button.
+ * See scripting/widelands/multiplayer_help.lua for an example Lua file.
+ */
+class FullscreenHelpWindow : public Window {
+public:
+ FullscreenHelpWindow
+ (Panel * parent,
+ LuaInterface* lua,
+ const std::string& script_path,
+ const std::string & caption,
+ uint32_t width = 0, uint32_t height = 0);
+
+ bool handle_mousepress (uint8_t btn, int32_t mx, int32_t my) override;
+ bool handle_mouserelease(uint8_t btn, int32_t mx, int32_t my) override;
+
+ /// Handle keypresses
+ bool handle_key(bool down, SDL_Keysym code) override;
+
+protected:
+ void clicked_ok();
+
+private:
+ std::unique_ptr<MultilineTextarea> textarea_;
+};
+
+
+} // namespace UI
+
+#endif // end of include guard: WL_UI_FSMENU_HELPWINDOW_H
=== modified file 'src/ui_fsmenu/launch_mpg.cc'
--- src/ui_fsmenu/launch_mpg.cc 2015-09-04 06:16:58 +0000
+++ src/ui_fsmenu/launch_mpg.cc 2015-10-13 15:08:04 +0000
@@ -242,8 +242,6 @@
FullscreenMenuLaunchMPG::~FullscreenMenuLaunchMPG() {
delete m_lua;
delete m_mpsg;
- if (m_help)
- delete m_help;
delete m_chat;
}
@@ -665,51 +663,11 @@
/// Show help
void FullscreenMenuLaunchMPG::help_clicked() {
- if (m_help)
- delete m_help;
- m_help = new UI::HelpWindow(this, _("Multiplayer Game Setup"), m_fs);
- m_help->add_paragraph(_("You are in the multiplayer launch game menu."));
- m_help->add_heading(_("Client settings"));
- m_help->add_paragraph
- (_
- ("On the left side is a list of all clients including you. You can set your role "
- "with the button following your nickname. Available roles are:"));
- m_help->add_picture_li
- (_
- ("The player with the color of the flag. If more than one client selected the same color, these "
- "share control over the player (‘shared kingdom mode’)."),
- "pics/genstats_enable_plr_08.png");
- m_help->add_picture_li
- (_("Spectator mode, meaning you can see everything, but cannot control any player"),
- "pics/menu_tab_watch.png");
- m_help->add_heading(_("Player settings"));
- m_help->add_paragraph
- (_
- ("In the middle are the settings for the players. To start a game, each player must be one of the "
- "following:"));
- m_help->add_picture_li
- (_("Connected to one or more clients (see ‘Client settings’)."), "pics/genstats_nrworkers.png");
- m_help->add_picture_li
- (_
- ("Connected to a computer player (the face in the picture as well as the mouse hover texts "
- "indicate the strength of the currently selected computer player)."),
- "pics/ai_Normal.png");
- m_help->add_picture_li(_("Set as shared in starting position for another player."), "pics/shared_in.png");
- m_help->add_picture_li(_("Closed."), "pics/stop.png");
- m_help->add_block
- (_
- ("The latter three can only be set by the hosting client by left-clicking the ‘type’ button of a "
- "player. Hosting players can also set the initialization of each player (the set of buildings, "
- "wares and workers the player starts with) and the tribe and team for computer players"));
- m_help->add_block
- (_
- ("Every client connected to a player (the set ‘role’ player) can set the tribe and the team "
- "for that player"));
- m_help->add_heading(_("Map details"));
- m_help->add_paragraph
- (_
- ("You can see information about the selected map or savegame on the right-hand side. "
- "A button next to the map name allows the host to change to a different map. "
- "Furthermore, the host is able to set a specific win condition, and finally "
- "can start the game as soon as all players are set up."));
+ if (m_help) {
+ m_help->set_visible(true);
+ } else {
+ m_help.reset(new UI::FullscreenHelpWindow(this, m_lua, "scripting/widelands/multiplayer_help.lua",
+ /** TRANSLATORS: This is a heading for a help window */
+ _("Multiplayer Game Setup")));
+ }
}
=== modified file 'src/ui_fsmenu/launch_mpg.h'
--- src/ui_fsmenu/launch_mpg.h 2015-10-02 07:02:00 +0000
+++ src/ui_fsmenu/launch_mpg.h 2015-10-13 15:08:04 +0000
@@ -20,11 +20,12 @@
#ifndef WL_UI_FSMENU_LAUNCH_MPG_H
#define WL_UI_FSMENU_LAUNCH_MPG_H
+#include <memory>
#include <string>
#include "ui_fsmenu/base.h"
+#include "ui_fsmenu/helpwindow.h"
#include "ui_basic/button.h"
-#include "ui_basic/helpwindow.h"
#include "ui_basic/listselect.h"
#include "ui_basic/multilinetextarea.h"
#include "ui_basic/textarea.h"
@@ -85,7 +86,7 @@
UI::Button m_help_button;
UI::Textarea m_title, m_mapname, m_clients, m_players, m_map, m_wincondition_type;
UI::MultilineTextarea m_map_info, m_client_info;
- UI::HelpWindow * m_help;
+ std::unique_ptr<UI::FullscreenHelpWindow> m_help;
GameSettingsProvider * m_settings;
GameController * m_ctrl;
GameChatPanel * m_chat;
=== modified file 'src/wui/CMakeLists.txt'
--- src/wui/CMakeLists.txt 2015-03-04 09:17:22 +0000
+++ src/wui/CMakeLists.txt 2015-10-13 15:08:04 +0000
@@ -98,6 +98,8 @@
game_tips.h
general_statistics_menu.cc
general_statistics_menu.h
+ helpwindow.cc
+ helpwindow.h
interactive_base.cc
interactive_base.h
interactive_gamebase.cc
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2015-09-26 09:07:40 +0000
+++ src/wui/buildingwindow.cc 2015-10-13 15:08:04 +0000
@@ -33,10 +33,10 @@
#include "logic/productionsite.h"
#include "logic/tribe.h"
#include "logic/warehouse.h"
-#include "ui_basic/helpwindow.h"
#include "ui_basic/tabpanel.h"
#include "wui/actionconfirm.h"
#include "wui/game_debug_ui.h"
+#include "wui/helpwindow.h"
#include "wui/interactive_player.h"
#include "wui/unique_window_handler.h"
#include "wui/waresqueuedisplay.h"
@@ -362,7 +362,7 @@
UI::UniqueWindow::Registry& registry =
igbase().unique_windows().get_registry(m_building.descr().name() + "_help");
registry.open_window = [this, ®istry] {
- new UI::LuaTextHelpWindow(
+ new UI::BuildingHelpWindow(
&igbase(), registry, m_building.descr(), &igbase().egbase().lua());
};
=== renamed file 'src/ui_basic/helpwindow.cc' => 'src/wui/helpwindow.cc'
--- src/ui_basic/helpwindow.cc 2015-10-02 07:02:00 +0000
+++ src/wui/helpwindow.cc 2015-10-13 15:08:04 +0000
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2002-2004, 2006-2010 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
@@ -17,7 +17,7 @@
*
*/
-#include "ui_basic/helpwindow.h"
+#include "wui/helpwindow.h"
#include <memory>
#include <string>
@@ -25,182 +25,14 @@
#include <boost/format.hpp>
#include "base/i18n.h"
-#include "base/log.h"
-#include "graphic/font.h"
-#include "graphic/font_handler.h"
-#include "graphic/font_handler1.h"
-#include "graphic/graphic.h"
-#include "graphic/text/font_set.h"
-#include "graphic/text_constants.h"
-#include "io/filesystem/layered_filesystem.h"
#include "logic/building.h"
#include "scripting/lua_interface.h"
#include "scripting/lua_table.h"
-#include "ui_basic/button.h"
-#include "ui_basic/window.h"
+
namespace UI {
-HelpWindow::HelpWindow
- (Panel * const parent,
- const std::string & caption,
- uint32_t fontsize,
- uint32_t width, uint32_t height)
- :
- Window(parent, "help_window", 0, 0, 20, 20, (boost::format(_("Help: %s")) % caption).str()),
- textarea(new MultilineTextarea(this, 5, 5, 30, 30, std::string(), Align_Left)),
- m_h1(std::to_string(fontsize < 12 ? 18 : fontsize * 3 / 2)),
- m_h2(std::to_string(fontsize < 12 ? 12 : fontsize)),
- m_p (std::to_string(fontsize < 12 ? 10 : fontsize * 5 / 6)),
- m_fn(ui_fn().substr(0, ui_fn().size() - 4)) // Font file - .ttf
-{
- // Begin the text with the caption
- m_text = "<rt text-align=center><p font-color=#AAFFAA font-face=";
- m_text += m_fn;
- m_text += " font-size=";
- m_text += m_h1;
- m_text += ">";
- m_text += caption;
- m_text += "</p></rt>";
- textarea->set_text(m_text);
- lastentry = HEADING;
-
- // Calculate sizes
- int32_t const out_width = (width == 0) ? g_gr->get_xres() * 3 / 5 : width;
- int32_t const out_height = (height == 0) ? g_gr->get_yres() * 4 / 5 : height;
- int32_t const but_height = g_gr->get_yres() * 9 / 200;
-
- assert(out_width >= 80);
- assert(out_height >= 60);
- int32_t in_width = out_width - 80;
- int32_t in_height = out_height - 60;
-
- set_inner_size(in_width, in_height);
- set_pos(Point((g_gr->get_xres() - out_width) / 2, (g_gr->get_yres() - out_height) / 2));
-
- Button * btn = new Button
- (this, "ok",
- in_width / 3, in_height - but_height * 3 / 2,
- in_width / 3, but_height,
- g_gr->images().get("pics/but5.png"),
- _("OK"), std::string(), true, false);
- btn->sigclicked.connect(boost::bind(&HelpWindow::clicked_ok, boost::ref(*this)));
- btn->set_font(Font::get((UI::g_fh1->fontset()).serif(),
- (fontsize < 12 ? 12 : fontsize)));
-
- textarea->set_size(in_width - 10, in_height - 10 - (2 * but_height));
- focus();
-}
-
-
-HelpWindow::~HelpWindow()
-{
-}
-
-/// Adds a new heading.
-void HelpWindow::add_heading(std::string heading) {
- m_text += "<rt text-align=left><p font-color=#AAAAFF font-face=";
- m_text += m_fn;
- m_text += " font-size=";
- m_text += m_h2;
- m_text += "><br><br>";
- m_text += heading;
- m_text += "</p></rt>";
- textarea->set_text(m_text);
- lastentry = HEADING;
-}
-
-/// Adds a new paragraph.
-void HelpWindow::add_paragraph(std::string block) {
- m_text += "<rt><p font-face=";
- m_text += m_fn;
- m_text += " font-size=";
- m_text += m_p;
- if (lastentry == HEADING)
- m_text += ">";
- else
- m_text += "><br>";
- lastentry = BLOCK;
- return add_block(block);
-}
-
-/// Behaves the same as add_paragraph, just it adds only one < br> if last
-/// written entry was already a block text.
-void HelpWindow::add_block(std::string block) {
- if (lastentry == HEADING)
- return add_paragraph(block);
- m_text += "<br>";
- m_text += block;
- m_text += "</p></rt>";
- textarea->set_text(m_text);
- lastentry = BLOCK;
-}
-
-void HelpWindow::add_picture_li(std::string block, std::string picpath) {
- m_text += "<rt image=";
- m_text += picpath;
- m_text += " image-align=left><p font-face=";
- m_text += m_fn;
- m_text += " font-size=";
- m_text += m_p;
- m_text += ">";
- lastentry = BLOCK;
- return add_block(block);
-}
-
-
-/**
- * Handle mouseclick.
- *
- * Clicking the right mouse button inside the window acts like pressing Ok.
- */
-bool HelpWindow::handle_mousepress(const uint8_t btn, int32_t, int32_t)
-{
- if (btn == SDL_BUTTON_RIGHT) {
- play_click();
- clicked_ok();
- }
- return true;
-}
-
-bool HelpWindow::handle_mouserelease(const uint8_t, int32_t, int32_t)
-{
- return true;
-}
-
-bool HelpWindow::handle_key(bool down, SDL_Keysym code)
-{
- if (down) {
- switch (code.sym) {
- case SDLK_KP_ENTER:
- case SDLK_RETURN:
- clicked_ok();
- return true;
- default:
- return true; // handled
- }
- }
- return true;
-}
-
-
-void HelpWindow::clicked_ok()
-{
- if (is_modal())
- end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kBack);
- else {
- // do not call die() here - could lead to broken pointers.
- // the window should get deleted with the parent anyways.
- set_visible(false);
- }
-}
-
-/*
-===================
-LuaTextHelpWindow
-===================
-*/
-LuaTextHelpWindow::LuaTextHelpWindow
+BuildingHelpWindow::BuildingHelpWindow
(Panel * const parent,
UI::UniqueWindow::Registry & reg,
const Widelands::BuildingDescr& building_description,
@@ -209,7 +41,7 @@
:
UI::UniqueWindow(parent, "help_window", ®, width, height,
(boost::format(_("Help: %s")) % building_description.descname()).str()),
- textarea(new MultilineTextarea(this, 5, 5, width - 10, height -10, std::string(), Align_Left))
+ textarea_(new MultilineTextarea(this, 5, 5, width - 10, height -10, std::string(), Align_Left))
{
try {
std::unique_ptr<LuaTable> t(
@@ -218,13 +50,10 @@
cr->push_arg(&building_description);
cr->resume();
const std::string help_text = cr->pop_string();
- textarea->set_text(help_text);
+ textarea_->set_text(help_text);
} catch (LuaError& err) {
- textarea->set_text(err.what());
+ textarea_->set_text(err.what());
}
}
-LuaTextHelpWindow::~LuaTextHelpWindow()
-{
-}
-}
+} // namespace UI
=== renamed file 'src/ui_basic/helpwindow.h' => 'src/wui/helpwindow.h'
--- src/ui_basic/helpwindow.h 2015-08-05 14:50:23 +0000
+++ src/wui/helpwindow.h 2015-10-13 15:08:04 +0000
@@ -17,15 +17,14 @@
*
*/
-#ifndef WL_UI_BASIC_HELPWINDOW_H
-#define WL_UI_BASIC_HELPWINDOW_H
+#ifndef WL_WUI_HELPWINDOW_H
+#define WL_WUI_HELPWINDOW_H
#include <memory>
#include "graphic/align.h"
#include "ui_basic/multilinetextarea.h"
#include "ui_basic/unique_window.h"
-#include "ui_basic/window.h"
class LuaInterface;
@@ -35,72 +34,22 @@
namespace UI {
-/**
- * Shows a help window.
- *
- * Using it is quite straightforward. To ensure, that all help windows have the
- * same formations, all richtext formating will be done via add_* functions:
- * HelpWindow help(parent, "Caption", fontsize);
- * help.add_heading("A minor heading");
- * help.add_block("Some lines of text!");
- * help.add_block("More text, just one linebreak between");
- * help.add_paragraph("Even more text, now drawn in a new paragraph");
- * help.add_block("More text, same paragraph, but a linebreak between!");
- * help.add_heading("Another minor heading");
- * ...
- * help.run();
-*/
-struct HelpWindow : public Window {
- HelpWindow
- (Panel * parent,
- const std::string & caption,
- uint32_t fontsize,
- uint32_t width = 0, uint32_t height = 0);
- ~HelpWindow();
-
- bool handle_mousepress (uint8_t btn, int32_t mx, int32_t my) override;
- bool handle_mouserelease(uint8_t btn, int32_t mx, int32_t my) override;
-
- /// Handle keypresses
- bool handle_key(bool down, SDL_Keysym code) override;
-
- void add_heading (std::string text);
- void add_paragraph (std::string text);
- void add_block (std::string text);
- void add_picture_li(std::string text, std::string picpath);
-
-protected:
- void clicked_ok();
-
-private:
- enum State {
- BLOCK = 0,
- HEADING = 1
- } lastentry;
-
- std::unique_ptr<MultilineTextarea> textarea;
- std::string const m_h1, m_h2, m_p; // font sizes
- std::string const m_fn; // font name
- std::string m_text;
-};
-
/*
- * This is a totally different beast than HelpWindow. It takes
- * a Lua script, runs it and displays it's formatted content
+ * This HelpWindow takes a Lua script, runs it and displays it's formatted content
* as a static text
*/
-struct LuaTextHelpWindow : public UI::UniqueWindow {
- LuaTextHelpWindow
+class BuildingHelpWindow : public UI::UniqueWindow {
+public:
+ BuildingHelpWindow
(Panel * parent, UI::UniqueWindow::Registry& reg,
const Widelands::BuildingDescr& building_description,
LuaInterface * const lua,
uint32_t width = 300, uint32_t height = 400);
- ~LuaTextHelpWindow();
private:
- std::unique_ptr<MultilineTextarea> textarea;
+ std::unique_ptr<MultilineTextarea> textarea_;
};
-}
+} // namespace UI
-#endif // end of include guard: WL_UI_BASIC_HELPWINDOW_H
+#endif // end of include guard: WL_WUI_HELPWINDOW_H
=== modified file 'utils/buildcat.py'
--- utils/buildcat.py 2015-05-07 19:55:30 +0000
+++ utils/buildcat.py 2015-10-13 15:08:04 +0000
@@ -39,6 +39,7 @@
"../../src/wlapplication.h",
"../../src/*/*.h",
"../../src/*/*/*.h",
+ "../../scripting/widelands/*.lua",
] ),
( "widelands_console/widelands_console", [
"../../src/wlapplication_messages.cc",
Follow ups