diff --git a/data/gui/window/end_credits.cfg b/data/gui/window/end_credits.cfg new file mode 100644 index 00000000000..a3ed8bb3a43 --- /dev/null +++ b/data/gui/window/end_credits.cfg @@ -0,0 +1,134 @@ +#textdomain wesnoth-lib +### +### Definition of the credits screen +### + +[window_definition] + + id = "end_credits_window" + description = "The window definition for the credits screen." + + [resolution] + + [background] + + [draw] + + [image] + w = "(width)" + h = "(height)" + x = 0 + y = 0 + name = "(background_image)" + [/image] + + [/draw] + + [/background] + + [foreground] + + [draw] + + [/draw] + + [/foreground] + + [/resolution] + +[/window_definition] + +[window] + id = "end_credits" + description = "End credits dialog." + + [resolution] + definition = "end_credits_window" + + {GUI_WINDOW_FULLSCREEN} + + [tooltip] + id = "tooltip" + [/tooltip] + + [helptip] + id = "tooltip" + [/helptip] + + [grid] + + [row] + grow_factor = 1 + + [column] + horizontal_grow = "true" + vertical_grow = "true" + border = "all" + border_size = 30 + + [panel] + definition = "box_display" + + [grid] + + [row] + + [column] + horizontal_grow = "true" + vertical_grow = "true" + + [scroll_label] + definition = "default_small" + id = "text" + horizontal_scrollbar_mode = "never" + [/scroll_label] + + [/column] + + [/row] + + [/grid] + + [/panel] + + [/column] + + [/row] + + [row] + grow_factor = 0 + + [column] + grow_factor = 1 + horizontal_alignment = "center" + border = "all" + border_size = 5 + + [button] + id = "cancel" + definition = "default" + label = _ "Close" + [/button] + + [/column] + + [/row] + + [row] + grow_factor = 0 + + [column] + + [spacer] + height = 10 + [/spacer] + + [/column] + + [/row] + + [/grid] + + [/resolution] + +[/window] diff --git a/projectfiles/CodeBlocks/wesnoth.cbp b/projectfiles/CodeBlocks/wesnoth.cbp index 0a8bffb8d3f..88c017802c4 100644 --- a/projectfiles/CodeBlocks/wesnoth.cbp +++ b/projectfiles/CodeBlocks/wesnoth.cbp @@ -551,6 +551,8 @@ + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 74a1d07a00f..e83b649677c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -805,6 +805,7 @@ set(wesnoth-main_SRC gui/dialogs/editor/new_map.cpp gui/dialogs/editor/resize_map.cpp gui/dialogs/editor/set_starting_position.cpp + gui/dialogs/end_credits.cpp gui/dialogs/folder_create.cpp gui/dialogs/formula_debugger.cpp gui/dialogs/game_cache_options.cpp diff --git a/src/SConscript b/src/SConscript index 8146b53a2bd..52894149e49 100644 --- a/src/SConscript +++ b/src/SConscript @@ -381,6 +381,7 @@ wesnoth_sources = Split(""" gui/dialogs/editor/new_map.cpp gui/dialogs/editor/resize_map.cpp gui/dialogs/editor/set_starting_position.cpp + gui/dialogs/end_credits.cpp gui/dialogs/folder_create.cpp gui/dialogs/formula_debugger.cpp gui/dialogs/game_cache_options.cpp diff --git a/src/about.cpp b/src/about.cpp index 816e2f8693c..761705bc945 100644 --- a/src/about.cpp +++ b/src/about.cpp @@ -36,6 +36,7 @@ #include "tstring.hpp" // for operator== #include "video.hpp" // for update_rect, CVideo #include "widgets/button.hpp" // for button +#include "gui/dialogs/end_credits.hpp" #include // for max #include // for map, map<>::mapped_type @@ -229,6 +230,9 @@ void show_about(CVideo &video, const std::string &campaign) surface map_image, map_image_scaled; + // TODO: enable + //gui2::tend_credits::display(text, image_list, video); + if(!image_list.empty()) { map_image = image::get_image(image_list[0]); } else { diff --git a/src/gui/dialogs/end_credits.cpp b/src/gui/dialogs/end_credits.cpp new file mode 100644 index 00000000000..12149033cb8 --- /dev/null +++ b/src/gui/dialogs/end_credits.cpp @@ -0,0 +1,63 @@ +/* + Copyright (C) 2016 by the Battle for Wesnoth Project http://www.wesnoth.org/ + + 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. + + See the COPYING file for more details. +*/ + +#define GETTEXT_DOMAIN "wesnoth-lib" + +#include "gui/dialogs/end_credits.hpp" + +#include "game_config.hpp" +#include "gui/auxiliary/find_widget.hpp" +#include "gui/widgets/settings.hpp" +#include "gui/widgets/scroll_label.hpp" +#include "gui/widgets/window.hpp" +#include "formatter.hpp" +#include "marked-up_text.hpp" + +namespace gui2 +{ + +REGISTER_DIALOG(end_credits) + +tend_credits::tend_credits(const std::vector& text, const std::vector& backgrounds) + : text_(text) + , backgrounds_(backgrounds) +{ + if(backgrounds_.empty()) { + backgrounds_.push_back(game_config::images::game_title_background); + } +} + +void tend_credits::pre_show(twindow& window) +{ + // TODO: apparently, multiple images are supported... need to implement along with scrolling + window.canvas()[0].set_variable("background_image", variant(backgrounds_[0])); + + std::stringstream str; + + // BIG FAT TODO: get rid of this hacky string crap once we drop the GUI1 version + for(const auto& line : text_) { + if(line[0] == '-') { + str << font::escape_text(line.substr(1)) << "\n"; + } else if(line[0] == '+') { + str << "" << font::escape_text(line.substr(1)) << "" << "\n"; + } + } + + tscroll_label& text = find_widget(&window, "text", false); + + text.set_text_alignment(PangoAlignment::PANGO_ALIGN_CENTER); + text.set_use_markup(true); + text.set_label(str.str()); +} + +} diff --git a/src/gui/dialogs/end_credits.hpp b/src/gui/dialogs/end_credits.hpp new file mode 100644 index 00000000000..8bee79c6bdc --- /dev/null +++ b/src/gui/dialogs/end_credits.hpp @@ -0,0 +1,52 @@ +/* + Copyright (C) 2016 by the Battle for Wesnoth Project http://www.wesnoth.org/ + + 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. + + See the COPYING file for more details. +*/ + +#ifndef GUI_DIALOGS_END_CREDITS_HPP_INCLUDED +#define GUI_DIALOGS_END_CREDITS_HPP_INCLUDED + +#include "gui/dialogs/dialog.hpp" + +#include +#include +#include + +class display; + +namespace gui2 +{ + +class tend_credits : public tdialog +{ +public: + tend_credits(const std::vector& text, const std::vector& backgrounds); + + static void display(const std::vector& text, const std::vector& backgrounds, CVideo& video) + { + tend_credits(text, backgrounds).show(video); + } + +private: + /** Inherited from tdialog, implemented by REGISTER_DIALOG. */ + virtual const std::string& window_id() const; + + /** Inherited from tdialog. */ + void pre_show(twindow& window); + + const std::vector& text_; + + std::vector backgrounds_; +}; + +} // namespace gui2 + +#endif /* ! GUI_DIALOGS_END_CREDITS_HPP_INCLUDED */ diff --git a/src/tests/gui/test_gui2.cpp b/src/tests/gui/test_gui2.cpp index d7abb7dc07a..ce8bde23efc 100644 --- a/src/tests/gui/test_gui2.cpp +++ b/src/tests/gui/test_gui2.cpp @@ -50,6 +50,7 @@ #include "gui/dialogs/editor/new_map.hpp" #include "gui/dialogs/editor/resize_map.hpp" #include "gui/dialogs/editor/set_starting_position.hpp" +#include "gui/dialogs/end_credits.hpp" #include "gui/dialogs/folder_create.hpp" #include "gui/dialogs/formula_debugger.hpp" #include "gui/dialogs/game_cache_options.hpp" @@ -437,6 +438,7 @@ BOOST_AUTO_TEST_CASE(test_gui2) test(); test(); test(); + //test(); test(); //test(& lua_kernel_base()); @@ -479,7 +481,8 @@ BOOST_AUTO_TEST_CASE(test_gui2) "mp_host_game_prompt", "mp_create_game", // The title screen appears to be throwing a bad_alloc on Travis, so disable it for now - "title_screen" + "title_screen", + "end_credits", }; std::sort(list.begin(), list.end()); std::sort(omitted.begin(), omitted.end());