widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #08634
[Merge] lp:~widelands-dev/widelands/fs-tile-background into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/fs-tile-background into lp:widelands.
Commit message:
Fullscreen background images are now tiled rather than stretched.
- New class FullscreenWindow in ui_basic handles the overlays.
- There is a tiled background, plus a centered overlay
- Subclasses can add overlays and align them with UI::Align
- On top of the subclasses' overlays, the 4 edges blit a tiled image, and there is 1 image in each corner of the screen.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/fs-tile-background/+merge/309673
When showing the fullscreen menu at any resolution bigger than 800x600, the background images get fuzzy. This branch fixes that and uses some placeholder images for adornments - we will need some graphics contributions to make this look really good.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fs-tile-background into lp:widelands.
=== modified file 'data/images/loadscreens/progress.png'
Binary files data/images/loadscreens/progress.png 2014-12-03 14:26:52 +0000 and data/images/loadscreens/progress.png 2016-10-31 12:10:16 +0000 differ
=== renamed file 'data/images/ui_fsmenu/ui_fsmenu.jpg' => 'data/images/ui_fsmenu/background.png'
Binary files data/images/ui_fsmenu/ui_fsmenu.jpg 2014-12-03 13:06:42 +0000 and data/images/ui_fsmenu/background.png 2016-10-31 12:10:16 +0000 differ
=== added file 'data/images/ui_fsmenu/bottom.png'
Binary files data/images/ui_fsmenu/bottom.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/bottom.png 2016-10-31 12:10:16 +0000 differ
=== added file 'data/images/ui_fsmenu/bottom_left.png'
Binary files data/images/ui_fsmenu/bottom_left.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/bottom_left.png 2016-10-31 12:10:16 +0000 differ
=== added file 'data/images/ui_fsmenu/bottom_right.png'
Binary files data/images/ui_fsmenu/bottom_right.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/bottom_right.png 2016-10-31 12:10:16 +0000 differ
=== added file 'data/images/ui_fsmenu/center.png'
Binary files data/images/ui_fsmenu/center.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/center.png 2016-10-31 12:10:16 +0000 differ
=== removed file 'data/images/ui_fsmenu/choosemapmenu.jpg'
Binary files data/images/ui_fsmenu/choosemapmenu.jpg 2014-12-03 13:06:42 +0000 and data/images/ui_fsmenu/choosemapmenu.jpg 1970-01-01 00:00:00 +0000 differ
=== removed file 'data/images/ui_fsmenu/internetmenu.jpg'
Binary files data/images/ui_fsmenu/internetmenu.jpg 2014-12-03 13:06:42 +0000 and data/images/ui_fsmenu/internetmenu.jpg 1970-01-01 00:00:00 +0000 differ
=== removed file 'data/images/ui_fsmenu/launch_mpg_menu.jpg'
Binary files data/images/ui_fsmenu/launch_mpg_menu.jpg 2014-12-03 13:06:42 +0000 and data/images/ui_fsmenu/launch_mpg_menu.jpg 1970-01-01 00:00:00 +0000 differ
=== added file 'data/images/ui_fsmenu/left.png'
Binary files data/images/ui_fsmenu/left.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/left.png 2016-10-31 12:10:16 +0000 differ
=== added file 'data/images/ui_fsmenu/main_title.png'
Binary files data/images/ui_fsmenu/main_title.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/main_title.png 2016-10-31 12:10:16 +0000 differ
=== removed file 'data/images/ui_fsmenu/mainmenu.jpg'
Binary files data/images/ui_fsmenu/mainmenu.jpg 2014-12-03 13:06:42 +0000 and data/images/ui_fsmenu/mainmenu.jpg 1970-01-01 00:00:00 +0000 differ
=== added file 'data/images/ui_fsmenu/right.png'
Binary files data/images/ui_fsmenu/right.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/right.png 2016-10-31 12:10:16 +0000 differ
=== added file 'data/images/ui_fsmenu/top.png'
Binary files data/images/ui_fsmenu/top.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/top.png 2016-10-31 12:10:16 +0000 differ
=== added file 'data/images/ui_fsmenu/top_left.png'
Binary files data/images/ui_fsmenu/top_left.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/top_left.png 2016-10-31 12:10:16 +0000 differ
=== added file 'data/images/ui_fsmenu/top_right.png'
Binary files data/images/ui_fsmenu/top_right.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/top_right.png 2016-10-31 12:10:16 +0000 differ
=== modified file 'src/ui_basic/CMakeLists.txt'
--- src/ui_basic/CMakeLists.txt 2016-09-06 18:43:55 +0000
+++ src/ui_basic/CMakeLists.txt 2016-10-31 12:10:16 +0000
@@ -12,6 +12,8 @@
editbox.h
fileview_panel.cc
fileview_panel.h
+ fullscreen_window.cc
+ fullscreen_window.h
icon.cc
icon.h
icongrid.cc
=== added file 'src/ui_basic/fullscreen_window.cc'
--- src/ui_basic/fullscreen_window.cc 1970-01-01 00:00:00 +0000
+++ src/ui_basic/fullscreen_window.cc 2016-10-31 12:10:16 +0000
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2002, 2007-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_basic/fullscreen_window.h"
+
+#include <cstdio>
+
+#include "graphic/graphic.h"
+#include "graphic/image.h"
+#include "graphic/rendertarget.h"
+#include "graphic/text_constants.h"
+
+/*
+==============================================================================
+
+FullscreenWindow
+
+==============================================================================
+*/
+namespace UI {
+
+FullscreenWindow::FullscreenWindow()
+ : UI::Panel(nullptr, 0, 0, g_gr->get_xres(), g_gr->get_yres()),
+ background_image_("images/ui_fsmenu/background.png") {
+ graphic_resolution_changed_subscriber_ = Notifications::subscribe<GraphicResolutionChanged>(
+ [this](const GraphicResolutionChanged& message) {
+ set_size(message.width, message.height);
+ layout();
+ });
+ set_frame_image(FullscreenWindow::Frames::kCornerTopLeft, "images/ui_fsmenu/top_left.png");
+ set_frame_image(FullscreenWindow::Frames::kCornerTopRight, "images/ui_fsmenu/top_right.png");
+ set_frame_image(FullscreenWindow::Frames::kCornerBottomLeft, "images/ui_fsmenu/bottom_left.png");
+ set_frame_image(
+ FullscreenWindow::Frames::kCornerBottomRight, "images/ui_fsmenu/bottom_right.png");
+ set_frame_image(FullscreenWindow::Frames::kEdgeLeftTile, "images/ui_fsmenu/left.png");
+ set_frame_image(FullscreenWindow::Frames::kEdgeRightTile, "images/ui_fsmenu/right.png");
+ set_frame_image(FullscreenWindow::Frames::kEdgeTopTile, "images/ui_fsmenu/top.png");
+ set_frame_image(FullscreenWindow::Frames::kEdgeBottomTile, "images/ui_fsmenu/bottom.png");
+ add_overlay_image("images/ui_fsmenu/center.png", UI::Align::kCenter);
+}
+
+FullscreenWindow::~FullscreenWindow() {
+ overlays_.clear();
+ frame_overlays_.clear();
+}
+
+void FullscreenWindow::add_overlay_image(const std::string& filename, UI::Align align) {
+ overlays_.push_back(std::make_pair(g_gr->images().get(filename), align));
+}
+
+void FullscreenWindow::clear_overlays() {
+ overlays_.clear();
+}
+
+void FullscreenWindow::set_frame_image(FullscreenWindow::Frames id,
+ const std::__cxx11::string& filename) {
+ frame_overlays_.insert(std::make_pair(id, g_gr->images().get(filename)));
+}
+
+const Image* FullscreenWindow::get_frame_image(FullscreenWindow::Frames id) const {
+ if (frame_overlays_.count(id) == 1) {
+ return frame_overlays_.find(id)->second;
+ } else {
+ return nullptr;
+ }
+}
+
+/**
+ * Draw the background / splash screen
+*/
+void FullscreenWindow::draw(RenderTarget& dst) {
+ // Overall background
+ dst.tile(
+ Recti(0, 0, get_w(), get_h()), g_gr->images().get(background_image_), Vector2i(0, 0));
+
+ // Optional overlays
+ for (const auto& overlay : overlays_) {
+ blit_image(dst, overlay.first, overlay.second);
+ }
+
+ // Frame edges
+ blit_image(dst, get_frame_image(FullscreenWindow::Frames::kEdgeLeftTile), UI::Align::kTopLeft,
+ UI::Align::kVertical);
+ blit_image(dst, get_frame_image(FullscreenWindow::Frames::kEdgeRightTile), UI::Align::kTopRight,
+ UI::Align::kVertical);
+ blit_image(dst, get_frame_image(FullscreenWindow::Frames::kEdgeTopTile), UI::Align::kTopLeft,
+ UI::Align::kHorizontal);
+ blit_image(dst, get_frame_image(FullscreenWindow::Frames::kEdgeBottomTile),
+ UI::Align::kBottomLeft, UI::Align::kHorizontal);
+
+ // Frame corners
+ blit_image(dst, get_frame_image(FullscreenWindow::Frames::kCornerTopLeft), UI::Align::kTopLeft);
+ blit_image(
+ dst, get_frame_image(FullscreenWindow::Frames::kCornerTopRight), UI::Align::kTopRight);
+ blit_image(
+ dst, get_frame_image(FullscreenWindow::Frames::kCornerBottomLeft), UI::Align::kBottomLeft);
+ blit_image(
+ dst, get_frame_image(FullscreenWindow::Frames::kCornerBottomRight), UI::Align::kBottomRight);
+}
+
+void FullscreenWindow::blit_image(RenderTarget& dst,
+ const Image* image,
+ UI::Align align,
+ UI::Align tiling) {
+ if (image) {
+ int x = 0;
+ int y = 0;
+ if (static_cast<int>(align & UI::Align::kRight)) {
+ x = get_w() - image->width();
+ } else if (static_cast<int>(align & UI::Align::kHCenter)) {
+ x = (get_w() - image->width()) / 2;
+ }
+ if (static_cast<int>(align & UI::Align::kBottom)) {
+ y = get_h() - image->height();
+ } else if (static_cast<int>(align & UI::Align::kVCenter)) {
+ y = (get_h() - image->height()) / 2;
+ }
+ if (static_cast<int>(tiling & (UI::Align::kVertical | UI::Align::kHorizontal))) {
+ const int w = (static_cast<int>(tiling & UI::Align::kVertical)) ? image->width() : get_w();
+ const int h =
+ (static_cast<int>(tiling & UI::Align::kHorizontal)) ? image->height() : get_h();
+ dst.tile(Recti(x, y, w, h), image, Vector2i(0, 0));
+ } else {
+ dst.blit(Vector2f(x, y), image);
+ }
+ }
+}
+
+int FullscreenWindow::fs_small() {
+ return UI_FONT_SIZE_SMALL * get_h() / 600;
+}
+
+int FullscreenWindow::fs_big() {
+ return UI_FONT_SIZE_BIG * get_h() / 600;
+}
+
+} // namespace UI
=== added file 'src/ui_basic/fullscreen_window.h'
--- src/ui_basic/fullscreen_window.h 1970-01-01 00:00:00 +0000
+++ src/ui_basic/fullscreen_window.h 2016-10-31 12:10:16 +0000
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2002-2016 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_BASIC_FULLSCREEN_WINDOW_H
+#define WL_UI_BASIC_FULLSCREEN_WINDOW_H
+
+#include <string>
+#include <memory>
+#include <unordered_map>
+#include <vector>
+
+#include "graphic/align.h"
+#include "graphic/graphic.h"
+#include "notifications/notifications.h"
+#include "ui_basic/panel.h"
+
+namespace UI {
+
+/**
+ * This class is the base class for a fullscreen window.
+ * A fullscreen window takes up the full screen; it has the size
+ * g_gr->get_xres(), g_gr->get_yres()
+ */
+class FullscreenWindow : public UI::Panel {
+public:
+ /// Access keys for frame overlay images
+ enum class Frames {
+ kCornerTopLeft,
+ kCornerTopRight,
+ kCornerBottomLeft,
+ kCornerBottomRight,
+ kEdgeLeftTile,
+ kEdgeRightTile,
+ kEdgeTopTile,
+ kEdgeBottomTile
+ };
+ struct FramesHash {
+ template <typename T> int operator()(T t) const {
+ return static_cast<int>(t);
+ }
+ };
+
+ /// A full screen main menu outside of the game/editor itself.
+ FullscreenWindow();
+ virtual ~FullscreenWindow();
+
+ void draw(RenderTarget&) override;
+
+ ///\return the size for texts fitting to current resolution
+ int fs_small();
+ int fs_big();
+
+protected:
+ /// Sets the image for the given frame position.
+ void set_frame_image(FullscreenWindow::Frames id, const std::string& filename);
+ /// Add an overlay images to be blitted according to 'align'.
+ void add_overlay_image(const std::string& filename, UI::Align align);
+ /// Remove all overlay images
+ void clear_overlays();
+
+private:
+ /// Returns the image for the given frame position.
+ const Image* get_frame_image(FullscreenWindow::Frames id) const;
+ /**
+ * Blit an image according to the given 'align'.
+ * If 'tiling' is set to 'UI::Align::kVertical' or 'UI::Align::kHorizontal', the image will be
+ * tiled.
+ */
+ void blit_image(RenderTarget& dst,
+ const Image* image,
+ UI::Align align,
+ UI::Align tiling = UI::Align::kLeft);
+
+ const std::string background_image_;
+ /// These overlay images will be blitted in the order they were added and according to the given
+ /// align.
+ std::vector<std::pair<const Image*, UI::Align>> overlays_;
+ /// Images for the edges. They will be blitted in top of the overlays_.
+ std::unordered_map<FullscreenWindow::Frames, const Image*, FullscreenWindow::FramesHash>
+ frame_overlays_;
+
+ std::unique_ptr<Notifications::Subscriber<GraphicResolutionChanged>>
+ graphic_resolution_changed_subscriber_;
+};
+} // namespace UI
+#endif // end of include guard: WL_UI_BASIC_FULLSCREEN_WINDOW_H
=== modified file 'src/ui_basic/progresswindow.cc'
--- src/ui_basic/progresswindow.cc 2016-10-23 17:09:57 +0000
+++ src/ui_basic/progresswindow.cc 2016-10-31 12:10:16 +0000
@@ -45,7 +45,7 @@
namespace UI {
-ProgressWindow::ProgressWindow(const std::string& background) {
+ProgressWindow::ProgressWindow(const std::string& background) : UI::FullscreenWindow() {
set_background(background);
step(_("Loading…"));
}
@@ -56,23 +56,20 @@
}
}
-void ProgressWindow::draw_background(RenderTarget& rt, const uint32_t xres, const uint32_t yres) {
- label_center_.x = xres / 2;
- label_center_.y = yres * PROGRESS_LABEL_POSITION_Y / 100;
- Recti wnd_rect(Vector2i(0, 0), xres, yres);
+void ProgressWindow::draw(RenderTarget& rt) {
+ FullscreenWindow::draw(rt);
+ label_center_.x = get_w() / 2;
+ label_center_.y = get_h() * PROGRESS_LABEL_POSITION_Y / 100;
+ Recti wnd_rect(Vector2i(0, 0), get_w(), get_h());
const uint32_t h =
UI::g_fh1->render(as_uifont(UI::g_fh1->fontset()->representative_character()))->height();
- label_rectangle_.x = xres / 4.f;
- label_rectangle_.w = xres / 2.f;
+ label_rectangle_.x = get_w() / 4.f;
+ label_rectangle_.w = get_w() / 2.f;
label_rectangle_.y = label_center_.y - h / 2.f - PROGRESS_STATUS_RECT_PADDING;
label_rectangle_.h = h + 2.f * PROGRESS_STATUS_RECT_PADDING;
- const Image* bg = g_gr->images().get(background_);
- rt.blitrect_scale(Rectf(0.f, 0.f, xres, yres), bg, Recti(0, 0, bg->width(), bg->height()), 1.,
- BlendMode::UseAlpha);
-
Rectf border_rect = label_rectangle_;
border_rect.x -= PROGRESS_STATUS_BORDER_X;
border_rect.y -= PROGRESS_STATUS_BORDER_Y;
@@ -84,23 +81,19 @@
/// Set a picture to render in the background
void ProgressWindow::set_background(const std::string& file_name) {
- RenderTarget& rt = *g_gr->get_render_target();
+ clear_overlays();
if (!file_name.empty() && g_fs->file_exists(file_name)) {
- background_ = file_name;
+ add_overlay_image(file_name, UI::Align::kCenter);
} else {
- background_ = "images/loadscreens/progress.png";
+ add_overlay_image("images/loadscreens/progress.png", UI::Align::kBottomLeft);
}
- draw_background(rt, g_gr->get_xres(), g_gr->get_yres());
+ draw(*g_gr->get_render_target());
}
void ProgressWindow::step(const std::string& description) {
RenderTarget& rt = *g_gr->get_render_target();
-
- const uint32_t xres = g_gr->get_xres();
- const uint32_t yres = g_gr->get_yres();
-
// always repaint the background first
- draw_background(rt, xres, yres);
+ draw(rt);
rt.fill_rect(label_rectangle_, PROGRESS_FONT_COLOR_BG);
rt.blit(label_center_.cast<float>(),
=== modified file 'src/ui_basic/progresswindow.h'
--- src/ui_basic/progresswindow.h 2016-10-23 17:09:57 +0000
+++ src/ui_basic/progresswindow.h 2016-10-31 12:10:16 +0000
@@ -25,7 +25,7 @@
#include <vector>
#include "base/rect.h"
-#include "base/vector.h"
+#include "ui_basic/fullscreen_window.h"
class Image;
class RenderTarget;
@@ -46,7 +46,7 @@
};
/// Manages a progress window on the screen.
-struct ProgressWindow {
+struct ProgressWindow : public UI::FullscreenWindow {
ProgressWindow(const std::string& background = std::string());
~ProgressWindow();
@@ -70,7 +70,7 @@
VisualizationArray visualizations_;
std::string background_;
- void draw_background(RenderTarget& rt, uint32_t xres, uint32_t yres);
+ void draw(RenderTarget&) override;
void update(bool repaint);
};
}
=== modified file 'src/ui_fsmenu/base.cc'
--- src/ui_fsmenu/base.cc 2016-10-29 06:44:03 +0000
+++ src/ui_fsmenu/base.cc 2016-10-31 12:10:16 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002, 2007-2010 by the Widelands Development Team
+ * Copyright (C) 2002-2016 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
@@ -19,17 +19,6 @@
#include "ui_fsmenu/base.h"
-#include <cstdio>
-
-#include "base/log.h"
-#include "base/wexception.h"
-#include "graphic/graphic.h"
-#include "graphic/image.h"
-#include "graphic/rendertarget.h"
-#include "graphic/text_constants.h"
-#include "io/filesystem/filesystem.h"
-#include "wlapplication.h"
-
/*
==============================================================================
@@ -38,43 +27,15 @@
==============================================================================
*/
-FullscreenMenuBase::FullscreenMenuBase() : FullscreenMenuBase("images/ui_fsmenu/ui_fsmenu.jpg") {
-}
-
/**
* Initialize a pre-game menu
- *
- * Args: bgpic name of the background picture
*/
-FullscreenMenuBase::FullscreenMenuBase(const std::string& bgpic)
- : UI::Panel(nullptr, 0, 0, g_gr->get_xres(), g_gr->get_yres()), background_image_(bgpic) {
- graphic_resolution_changed_subscriber_ = Notifications::subscribe<GraphicResolutionChanged>(
- [this](const GraphicResolutionChanged& message) {
- set_size(message.width, message.height);
- layout();
- });
+FullscreenMenuBase::FullscreenMenuBase() : UI::FullscreenWindow() {
}
FullscreenMenuBase::~FullscreenMenuBase() {
}
-/**
- * Draw the background / splash screen
-*/
-void FullscreenMenuBase::draw(RenderTarget& dst) {
- const Image* bg = g_gr->images().get(background_image_);
- dst.blitrect_scale(Rectf(0, 0, get_w(), get_h()), bg, Recti(0, 0, bg->width(), bg->height()), 1.,
- BlendMode::UseAlpha);
-}
-
-int FullscreenMenuBase::fs_small() {
- return UI_FONT_SIZE_SMALL * get_h() / 600;
-}
-
-int FullscreenMenuBase::fs_big() {
- return UI_FONT_SIZE_BIG * get_h() / 600;
-}
-
bool FullscreenMenuBase::handle_key(bool down, SDL_Keysym code) {
if (down) {
switch (code.sym) {
=== modified file 'src/ui_fsmenu/base.h'
--- src/ui_fsmenu/base.h 2016-10-11 15:18:29 +0000
+++ src/ui_fsmenu/base.h 2016-10-31 12:10:16 +0000
@@ -20,19 +20,17 @@
#ifndef WL_UI_FSMENU_BASE_H
#define WL_UI_FSMENU_BASE_H
-#include <memory>
#include <string>
-#include "graphic/graphic.h"
-#include "notifications/notifications.h"
+#include "ui_basic/fullscreen_window.h"
#include "ui_basic/panel.h"
/**
* This class is the base class for a fullscreen menu.
- * A fullscreen menu is a menu which takes the full screen; it has the size
- * MENU_XRES and MENU_YRES and is a modal UI Element
+ * A fullscreen menu is a menu which takes the full screen
+ * and it is a modal UI Element
*/
-class FullscreenMenuBase : public UI::Panel {
+class FullscreenMenuBase : public UI::FullscreenWindow {
public:
enum class MenuTarget {
kBack = static_cast<int>(UI::Panel::Returncodes::kBack),
@@ -68,29 +66,16 @@
kJoingame
};
- /// Calls FullscreenMenuBase(const std::string& bgpic)
- /// with a default background image
+ /// A full screen main menu outside of the game/editor itself.
FullscreenMenuBase();
- FullscreenMenuBase(const std::string& bgpic);
virtual ~FullscreenMenuBase();
- void draw(RenderTarget&) override;
-
- ///\return the size for texts fitting to current resolution
- int fs_small();
- int fs_big();
-
/// Handle keypresses
bool handle_key(bool down, SDL_Keysym code) override;
protected:
virtual void clicked_back();
virtual void clicked_ok();
-
-private:
- std::string background_image_;
- std::unique_ptr<Notifications::Subscriber<GraphicResolutionChanged>>
- graphic_resolution_changed_subscriber_;
};
#endif // end of include guard: WL_UI_FSMENU_BASE_H
=== modified file 'src/ui_fsmenu/internet_lobby.cc'
--- src/ui_fsmenu/internet_lobby.cc 2016-09-25 12:24:46 +0000
+++ src/ui_fsmenu/internet_lobby.cc 2016-10-31 12:10:16 +0000
@@ -37,7 +37,7 @@
FullscreenMenuInternetLobby::FullscreenMenuInternetLobby(char const* const nick,
char const* const pwd,
bool registered)
- : FullscreenMenuBase("images/ui_fsmenu/internetmenu.jpg"),
+ : FullscreenMenuBase(),
// Values for alignment and size
butx_(get_w() * 13 / 40),
=== modified file 'src/ui_fsmenu/intro.cc'
--- src/ui_fsmenu/intro.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/intro.cc 2016-10-31 12:10:16 +0000
@@ -22,7 +22,7 @@
#include "base/i18n.h"
FullscreenMenuIntro::FullscreenMenuIntro()
- : FullscreenMenuBase("images/loadscreens/splash.jpg"),
+ : FullscreenMenuBase(),
// Text area
message_(this,
@@ -32,6 +32,7 @@
UI::Align::kHCenter) {
message_.set_fontsize(fs_small() * 6 / 5);
message_.set_color(RGBColor(192, 192, 128));
+ add_overlay_image("images/loadscreens/splash.jpg", UI::Align::kCenter);
}
bool FullscreenMenuIntro::handle_mousepress(uint8_t, int32_t, int32_t) {
=== modified file 'src/ui_fsmenu/launch_mpg.cc'
--- src/ui_fsmenu/launch_mpg.cc 2016-10-28 18:04:11 +0000
+++ src/ui_fsmenu/launch_mpg.cc 2016-10-31 12:10:16 +0000
@@ -96,7 +96,7 @@
FullscreenMenuLaunchMPG::FullscreenMenuLaunchMPG(GameSettingsProvider* const settings,
GameController* const ctrl)
- : FullscreenMenuBase("images/ui_fsmenu/launch_mpg_menu.jpg"),
+ : FullscreenMenuBase(),
// Values for alignment and size
butw_(get_w() / 4),
=== modified file 'src/ui_fsmenu/load_map_or_game.cc'
--- src/ui_fsmenu/load_map_or_game.cc 2016-09-25 12:24:46 +0000
+++ src/ui_fsmenu/load_map_or_game.cc 2016-10-31 12:10:16 +0000
@@ -32,7 +32,7 @@
/// This class defines common coordinates for these UI screens.
/// It also defines common buttons.
FullscreenMenuLoadMapOrGame::FullscreenMenuLoadMapOrGame()
- : FullscreenMenuBase("images/ui_fsmenu/choosemapmenu.jpg"),
+ : FullscreenMenuBase(),
// Values for alignment and size
padding_(4),
=== modified file 'src/ui_fsmenu/main.cc'
--- src/ui_fsmenu/main.cc 2016-10-31 08:07:59 +0000
+++ src/ui_fsmenu/main.cc 2016-10-31 12:10:16 +0000
@@ -26,7 +26,7 @@
#include "graphic/graphic.h"
FullscreenMenuMain::FullscreenMenuMain()
- : FullscreenMenuMainMenu("images/ui_fsmenu/mainmenu.jpg"),
+ : FullscreenMenuMainMenu(),
// Buttons
playtutorial(&vbox_,
@@ -142,6 +142,8 @@
vbox_.add_inf_space();
vbox_.add(&exit, UI::Align::kHCenter, true);
+ add_overlay_image("images/ui_fsmenu/main_title.png", UI::Align::kTopCenter);
+
layout();
}
=== modified file 'src/ui_fsmenu/main_menu.cc'
--- src/ui_fsmenu/main_menu.cc 2016-10-31 08:07:59 +0000
+++ src/ui_fsmenu/main_menu.cc 2016-10-31 12:10:16 +0000
@@ -20,11 +20,7 @@
#include "ui_fsmenu/main_menu.h"
FullscreenMenuMainMenu::FullscreenMenuMainMenu()
- : FullscreenMenuMainMenu("images/ui_fsmenu/ui_fsmenu.jpg") {
-}
-
-FullscreenMenuMainMenu::FullscreenMenuMainMenu(const std::string& background_image)
- : FullscreenMenuBase(background_image),
+ : FullscreenMenuBase(),
// Values for alignment and size
box_x_(get_w() * 13 / 40),
=== modified file 'src/ui_fsmenu/main_menu.h'
--- src/ui_fsmenu/main_menu.h 2016-10-31 08:07:59 +0000
+++ src/ui_fsmenu/main_menu.h 2016-10-31 12:10:16 +0000
@@ -29,14 +29,9 @@
*/
class FullscreenMenuMainMenu : public FullscreenMenuBase {
public:
- /// Calls FullscreenMenuMainMenu(const std::string& background_image)
- /// with a default background image
+ /// Assigns values for alignment and size, depending on screen size
FullscreenMenuMainMenu();
- /// Sets the background image and assigns values
- /// for alignment and size, depending on screen size
- FullscreenMenuMainMenu(const std::string& background_image);
-
protected:
void layout() override;
=== modified file 'src/ui_fsmenu/options.cc'
--- src/ui_fsmenu/options.cc 2016-10-28 18:04:11 +0000
+++ src/ui_fsmenu/options.cc 2016-10-31 12:10:16 +0000
@@ -90,7 +90,7 @@
// TODO(GunChleoc): Arabic: This doesn't fit the window in Arabic.
FullscreenMenuOptions::FullscreenMenuOptions(OptionsCtrl::OptionsStruct opt)
- : FullscreenMenuBase("images/ui_fsmenu/ui_fsmenu.jpg"),
+ : FullscreenMenuBase(),
// Values for alignment and size
butw_(get_w() / 5),
Follow ups