Merge lp:~widelands-dev/widelands/fs-tile-background into lp:widelands
- fs-tile-background
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 8163 |
Proposed branch: | lp:~widelands-dev/widelands/fs-tile-background |
Merge into: | lp:widelands |
Diff against target: |
719 lines (+320/-101) 16 files modified
cmake/codecheck/rules/do_not_use__cxx11 (+30/-0) src/ui_basic/CMakeLists.txt (+3/-0) src/ui_basic/fullscreen_window.cc (+151/-0) src/ui_basic/fullscreen_window.h (+102/-0) src/ui_basic/progresswindow.cc (+13/-20) src/ui_basic/progresswindow.h (+3/-3) src/ui_fsmenu/base.cc (+2/-41) src/ui_fsmenu/base.h (+5/-20) src/ui_fsmenu/internet_lobby.cc (+1/-1) src/ui_fsmenu/intro.cc (+2/-1) src/ui_fsmenu/launch_mpg.cc (+1/-1) src/ui_fsmenu/load_map_or_game.cc (+1/-1) src/ui_fsmenu/main.cc (+3/-1) src/ui_fsmenu/main_menu.cc (+1/-5) src/ui_fsmenu/main_menu.h (+1/-6) src/ui_fsmenu/options.cc (+1/-1) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/fs-tile-background |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tino | Approve | ||
Review via email: mp+309673@code.launchpad.net |
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.
Description of the change
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.
kaputtnik (franku) wrote : | # |
> Oh, placeholder? Thats looks definitely better than just "placeholder" ;).
>
> I really like this change!
dito :-)
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 1547. State: failed. Details: https:/
Appveyor build 1388. State: success. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
@bunnybot merge
Preview Diff
1 | === added file 'cmake/codecheck/rules/do_not_use__cxx11' |
2 | --- cmake/codecheck/rules/do_not_use__cxx11 1970-01-01 00:00:00 +0000 |
3 | +++ cmake/codecheck/rules/do_not_use__cxx11 2016-11-01 07:36:03 +0000 |
4 | @@ -0,0 +1,30 @@ |
5 | +#!/usr/bin/python -tt |
6 | + |
7 | +# QT Creator likes to add __cxx11 to the namsepace when autocompleting |
8 | +# std::string, which will break clang builds. |
9 | +def does_include_cxx11(lines, fn): |
10 | + for lineno, line in enumerate(lines, 1): |
11 | + if "std::__cxx11" in line: |
12 | + return [ (fn, lineno, |
13 | + "Do not use the std::__cxx11 namespace.") ] |
14 | + return [] |
15 | + |
16 | +evaluate_matches = does_include_cxx11 |
17 | + |
18 | + |
19 | +################# |
20 | +# ALLOWED TESTS # |
21 | +################# |
22 | +allowed = [ |
23 | +"""std::string |
24 | +""", |
25 | +] |
26 | + |
27 | + |
28 | +################### |
29 | +# FORBIDDEN TESTS # |
30 | +################### |
31 | +forbidden = [ |
32 | +"""std::__cxx11::string |
33 | +""", |
34 | +] |
35 | |
36 | === modified file 'data/images/loadscreens/progress.png' |
37 | Binary files data/images/loadscreens/progress.png 2014-12-03 14:26:52 +0000 and data/images/loadscreens/progress.png 2016-11-01 07:36:03 +0000 differ |
38 | === renamed file 'data/images/ui_fsmenu/ui_fsmenu.jpg' => 'data/images/ui_fsmenu/background.png' |
39 | Binary files data/images/ui_fsmenu/ui_fsmenu.jpg 2014-12-03 13:06:42 +0000 and data/images/ui_fsmenu/background.png 2016-11-01 07:36:03 +0000 differ |
40 | === added file 'data/images/ui_fsmenu/bottom.png' |
41 | Binary files data/images/ui_fsmenu/bottom.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/bottom.png 2016-11-01 07:36:03 +0000 differ |
42 | === added file 'data/images/ui_fsmenu/bottom_left.png' |
43 | 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-11-01 07:36:03 +0000 differ |
44 | === added file 'data/images/ui_fsmenu/bottom_right.png' |
45 | 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-11-01 07:36:03 +0000 differ |
46 | === added file 'data/images/ui_fsmenu/center.png' |
47 | Binary files data/images/ui_fsmenu/center.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/center.png 2016-11-01 07:36:03 +0000 differ |
48 | === removed file 'data/images/ui_fsmenu/choosemapmenu.jpg' |
49 | 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 |
50 | === removed file 'data/images/ui_fsmenu/internetmenu.jpg' |
51 | 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 |
52 | === removed file 'data/images/ui_fsmenu/launch_mpg_menu.jpg' |
53 | 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 |
54 | === added file 'data/images/ui_fsmenu/left.png' |
55 | Binary files data/images/ui_fsmenu/left.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/left.png 2016-11-01 07:36:03 +0000 differ |
56 | === added file 'data/images/ui_fsmenu/main_title.png' |
57 | 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-11-01 07:36:03 +0000 differ |
58 | === removed file 'data/images/ui_fsmenu/mainmenu.jpg' |
59 | 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 |
60 | === added file 'data/images/ui_fsmenu/right.png' |
61 | Binary files data/images/ui_fsmenu/right.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/right.png 2016-11-01 07:36:03 +0000 differ |
62 | === added file 'data/images/ui_fsmenu/top.png' |
63 | Binary files data/images/ui_fsmenu/top.png 1970-01-01 00:00:00 +0000 and data/images/ui_fsmenu/top.png 2016-11-01 07:36:03 +0000 differ |
64 | === added file 'data/images/ui_fsmenu/top_left.png' |
65 | 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-11-01 07:36:03 +0000 differ |
66 | === added file 'data/images/ui_fsmenu/top_right.png' |
67 | 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-11-01 07:36:03 +0000 differ |
68 | === modified file 'src/ui_basic/CMakeLists.txt' |
69 | --- src/ui_basic/CMakeLists.txt 2016-09-06 18:43:55 +0000 |
70 | +++ src/ui_basic/CMakeLists.txt 2016-11-01 07:36:03 +0000 |
71 | @@ -12,6 +12,8 @@ |
72 | editbox.h |
73 | fileview_panel.cc |
74 | fileview_panel.h |
75 | + fullscreen_window.cc |
76 | + fullscreen_window.h |
77 | icon.cc |
78 | icon.h |
79 | icongrid.cc |
80 | @@ -63,6 +65,7 @@ |
81 | graphic_text |
82 | graphic_text_layout |
83 | io_filesystem |
84 | + notifications |
85 | profile |
86 | scripting_lua_interface |
87 | scripting_lua_table |
88 | |
89 | === added file 'src/ui_basic/fullscreen_window.cc' |
90 | --- src/ui_basic/fullscreen_window.cc 1970-01-01 00:00:00 +0000 |
91 | +++ src/ui_basic/fullscreen_window.cc 2016-11-01 07:36:03 +0000 |
92 | @@ -0,0 +1,151 @@ |
93 | +/* |
94 | + * Copyright (C) 2002-2016 by the Widelands Development Team |
95 | + * |
96 | + * This program is free software; you can redistribute it and/or |
97 | + * modify it under the terms of the GNU General Public License |
98 | + * as published by the Free Software Foundation; either version 2 |
99 | + * of the License, or (at your option) any later version. |
100 | + * |
101 | + * This program is distributed in the hope that it will be useful, |
102 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
103 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
104 | + * GNU General Public License for more details. |
105 | + * |
106 | + * You should have received a copy of the GNU General Public License |
107 | + * along with this program; if not, write to the Free Software |
108 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
109 | + * |
110 | + */ |
111 | + |
112 | +#include "ui_basic/fullscreen_window.h" |
113 | + |
114 | +#include <cstdio> |
115 | + |
116 | +#include "graphic/graphic.h" |
117 | +#include "graphic/image.h" |
118 | +#include "graphic/rendertarget.h" |
119 | +#include "graphic/text_constants.h" |
120 | + |
121 | +/* |
122 | +============================================================================== |
123 | + |
124 | +FullscreenWindow |
125 | + |
126 | +============================================================================== |
127 | +*/ |
128 | +namespace UI { |
129 | + |
130 | +FullscreenWindow::FullscreenWindow() |
131 | + : UI::Panel(nullptr, 0, 0, g_gr->get_xres(), g_gr->get_yres()), |
132 | + background_image_("images/ui_fsmenu/background.png") { |
133 | + graphic_resolution_changed_subscriber_ = Notifications::subscribe<GraphicResolutionChanged>( |
134 | + [this](const GraphicResolutionChanged& message) { |
135 | + set_size(message.width, message.height); |
136 | + layout(); |
137 | + }); |
138 | + set_frame_image(FullscreenWindow::Frames::kCornerTopLeft, "images/ui_fsmenu/top_left.png"); |
139 | + set_frame_image(FullscreenWindow::Frames::kCornerTopRight, "images/ui_fsmenu/top_right.png"); |
140 | + set_frame_image(FullscreenWindow::Frames::kCornerBottomLeft, "images/ui_fsmenu/bottom_left.png"); |
141 | + set_frame_image( |
142 | + FullscreenWindow::Frames::kCornerBottomRight, "images/ui_fsmenu/bottom_right.png"); |
143 | + set_frame_image(FullscreenWindow::Frames::kEdgeLeftTile, "images/ui_fsmenu/left.png"); |
144 | + set_frame_image(FullscreenWindow::Frames::kEdgeRightTile, "images/ui_fsmenu/right.png"); |
145 | + set_frame_image(FullscreenWindow::Frames::kEdgeTopTile, "images/ui_fsmenu/top.png"); |
146 | + set_frame_image(FullscreenWindow::Frames::kEdgeBottomTile, "images/ui_fsmenu/bottom.png"); |
147 | + add_overlay_image("images/ui_fsmenu/center.png", UI::Align::kCenter); |
148 | +} |
149 | + |
150 | +FullscreenWindow::~FullscreenWindow() { |
151 | + overlays_.clear(); |
152 | + frame_overlays_.clear(); |
153 | +} |
154 | + |
155 | +void FullscreenWindow::add_overlay_image(const std::string& filename, UI::Align align) { |
156 | + overlays_.push_back(std::make_pair(g_gr->images().get(filename), align)); |
157 | +} |
158 | + |
159 | +void FullscreenWindow::clear_overlays() { |
160 | + overlays_.clear(); |
161 | +} |
162 | + |
163 | +void FullscreenWindow::set_frame_image(FullscreenWindow::Frames id, const std::string& filename) { |
164 | + frame_overlays_.insert(std::make_pair(id, g_gr->images().get(filename))); |
165 | +} |
166 | + |
167 | +const Image* FullscreenWindow::get_frame_image(FullscreenWindow::Frames id) const { |
168 | + if (frame_overlays_.count(id) == 1) { |
169 | + return frame_overlays_.find(id)->second; |
170 | + } else { |
171 | + return nullptr; |
172 | + } |
173 | +} |
174 | + |
175 | +/** |
176 | + * Draw the background / splash screen |
177 | +*/ |
178 | +void FullscreenWindow::draw(RenderTarget& dst) { |
179 | + // Overall background |
180 | + dst.tile(Recti(0, 0, get_w(), get_h()), g_gr->images().get(background_image_), Vector2i(0, 0)); |
181 | + |
182 | + // Optional overlays |
183 | + for (const auto& overlay : overlays_) { |
184 | + blit_image(dst, overlay.first, overlay.second); |
185 | + } |
186 | + |
187 | + // Frame edges |
188 | + blit_image(dst, get_frame_image(FullscreenWindow::Frames::kEdgeLeftTile), UI::Align::kTopLeft, |
189 | + UI::Align::kVertical); |
190 | + blit_image(dst, get_frame_image(FullscreenWindow::Frames::kEdgeRightTile), UI::Align::kTopRight, |
191 | + UI::Align::kVertical); |
192 | + blit_image(dst, get_frame_image(FullscreenWindow::Frames::kEdgeTopTile), UI::Align::kTopLeft, |
193 | + UI::Align::kHorizontal); |
194 | + blit_image(dst, get_frame_image(FullscreenWindow::Frames::kEdgeBottomTile), |
195 | + UI::Align::kBottomLeft, UI::Align::kHorizontal); |
196 | + |
197 | + // Frame corners |
198 | + blit_image(dst, get_frame_image(FullscreenWindow::Frames::kCornerTopLeft), UI::Align::kTopLeft); |
199 | + blit_image( |
200 | + dst, get_frame_image(FullscreenWindow::Frames::kCornerTopRight), UI::Align::kTopRight); |
201 | + blit_image( |
202 | + dst, get_frame_image(FullscreenWindow::Frames::kCornerBottomLeft), UI::Align::kBottomLeft); |
203 | + blit_image( |
204 | + dst, get_frame_image(FullscreenWindow::Frames::kCornerBottomRight), UI::Align::kBottomRight); |
205 | +} |
206 | + |
207 | +void FullscreenWindow::blit_image(RenderTarget& dst, |
208 | + const Image* image, |
209 | + UI::Align align, |
210 | + UI::Align tiling) { |
211 | + if (image) { |
212 | + int x = 0; |
213 | + int y = 0; |
214 | + if (static_cast<int>(align & UI::Align::kRight)) { |
215 | + x = get_w() - image->width(); |
216 | + } else if (static_cast<int>(align & UI::Align::kHCenter)) { |
217 | + x = (get_w() - image->width()) / 2; |
218 | + } |
219 | + if (static_cast<int>(align & UI::Align::kBottom)) { |
220 | + y = get_h() - image->height(); |
221 | + } else if (static_cast<int>(align & UI::Align::kVCenter)) { |
222 | + y = (get_h() - image->height()) / 2; |
223 | + } |
224 | + if (static_cast<int>(tiling & (UI::Align::kVertical | UI::Align::kHorizontal))) { |
225 | + const int w = (static_cast<int>(tiling & UI::Align::kVertical)) ? image->width() : get_w(); |
226 | + const int h = |
227 | + (static_cast<int>(tiling & UI::Align::kHorizontal)) ? image->height() : get_h(); |
228 | + dst.tile(Recti(x, y, w, h), image, Vector2i(0, 0)); |
229 | + } else { |
230 | + dst.blit(Vector2f(x, y), image); |
231 | + } |
232 | + } |
233 | +} |
234 | + |
235 | +int FullscreenWindow::fs_small() { |
236 | + return UI_FONT_SIZE_SMALL * get_h() / 600; |
237 | +} |
238 | + |
239 | +int FullscreenWindow::fs_big() { |
240 | + return UI_FONT_SIZE_BIG * get_h() / 600; |
241 | +} |
242 | + |
243 | +} // namespace UI |
244 | |
245 | === added file 'src/ui_basic/fullscreen_window.h' |
246 | --- src/ui_basic/fullscreen_window.h 1970-01-01 00:00:00 +0000 |
247 | +++ src/ui_basic/fullscreen_window.h 2016-11-01 07:36:03 +0000 |
248 | @@ -0,0 +1,102 @@ |
249 | +/* |
250 | + * Copyright (C) 2002-2016 by the Widelands Development Team |
251 | + * |
252 | + * This program is free software; you can redistribute it and/or |
253 | + * modify it under the terms of the GNU General Public License |
254 | + * as published by the Free Software Foundation; either version 2 |
255 | + * of the License, or (at your option) any later version. |
256 | + * |
257 | + * This program is distributed in the hope that it will be useful, |
258 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
259 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
260 | + * GNU General Public License for more details. |
261 | + * |
262 | + * You should have received a copy of the GNU General Public License |
263 | + * along with this program; if not, write to the Free Software |
264 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
265 | + * |
266 | + */ |
267 | + |
268 | +#ifndef WL_UI_BASIC_FULLSCREEN_WINDOW_H |
269 | +#define WL_UI_BASIC_FULLSCREEN_WINDOW_H |
270 | + |
271 | +#include <string> |
272 | +#include <memory> |
273 | +#include <unordered_map> |
274 | +#include <vector> |
275 | + |
276 | +#include "graphic/align.h" |
277 | +#include "graphic/graphic.h" |
278 | +#include "notifications/notifications.h" |
279 | +#include "ui_basic/panel.h" |
280 | + |
281 | +namespace UI { |
282 | + |
283 | +/** |
284 | + * This class is the base class for a fullscreen window. |
285 | + * A fullscreen window takes up the full screen; it has the size |
286 | + * g_gr->get_xres(), g_gr->get_yres() |
287 | + */ |
288 | +class FullscreenWindow : public UI::Panel { |
289 | +public: |
290 | + /// Access keys for frame overlay images |
291 | + enum class Frames { |
292 | + kCornerTopLeft, |
293 | + kCornerTopRight, |
294 | + kCornerBottomLeft, |
295 | + kCornerBottomRight, |
296 | + kEdgeLeftTile, |
297 | + kEdgeRightTile, |
298 | + kEdgeTopTile, |
299 | + kEdgeBottomTile |
300 | + }; |
301 | + struct FramesHash { |
302 | + template <typename T> int operator()(T t) const { |
303 | + return static_cast<int>(t); |
304 | + } |
305 | + }; |
306 | + |
307 | + /// A full screen main menu outside of the game/editor itself. |
308 | + FullscreenWindow(); |
309 | + virtual ~FullscreenWindow(); |
310 | + |
311 | + ///\return the size for texts fitting to current resolution |
312 | + int fs_small(); |
313 | + int fs_big(); |
314 | + |
315 | +protected: |
316 | + void draw(RenderTarget&) override; |
317 | + |
318 | + /// Sets the image for the given frame position. |
319 | + void set_frame_image(FullscreenWindow::Frames id, const std::string& filename); |
320 | + /// Add an overlay images to be blitted according to 'align'. |
321 | + void add_overlay_image(const std::string& filename, UI::Align align); |
322 | + /// Remove all overlay images |
323 | + void clear_overlays(); |
324 | + |
325 | +private: |
326 | + /// Returns the image for the given frame position. |
327 | + const Image* get_frame_image(FullscreenWindow::Frames id) const; |
328 | + /** |
329 | + * Blit an image according to the given 'align'. |
330 | + * If 'tiling' is set to 'UI::Align::kVertical' or 'UI::Align::kHorizontal', the image will be |
331 | + * tiled. |
332 | + */ |
333 | + void blit_image(RenderTarget& dst, |
334 | + const Image* image, |
335 | + UI::Align align, |
336 | + UI::Align tiling = UI::Align::kLeft); |
337 | + |
338 | + const std::string background_image_; |
339 | + /// These overlay images will be blitted in the order they were added and according to the given |
340 | + /// align. |
341 | + std::vector<std::pair<const Image*, UI::Align>> overlays_; |
342 | + /// Images for the edges. They will be blitted in top of the overlays_. |
343 | + std::unordered_map<FullscreenWindow::Frames, const Image*, FullscreenWindow::FramesHash> |
344 | + frame_overlays_; |
345 | + |
346 | + std::unique_ptr<Notifications::Subscriber<GraphicResolutionChanged>> |
347 | + graphic_resolution_changed_subscriber_; |
348 | +}; |
349 | +} // namespace UI |
350 | +#endif // end of include guard: WL_UI_BASIC_FULLSCREEN_WINDOW_H |
351 | |
352 | === modified file 'src/ui_basic/progresswindow.cc' |
353 | --- src/ui_basic/progresswindow.cc 2016-10-23 17:09:57 +0000 |
354 | +++ src/ui_basic/progresswindow.cc 2016-11-01 07:36:03 +0000 |
355 | @@ -45,7 +45,7 @@ |
356 | |
357 | namespace UI { |
358 | |
359 | -ProgressWindow::ProgressWindow(const std::string& background) { |
360 | +ProgressWindow::ProgressWindow(const std::string& background) : UI::FullscreenWindow() { |
361 | set_background(background); |
362 | step(_("Loading…")); |
363 | } |
364 | @@ -56,23 +56,20 @@ |
365 | } |
366 | } |
367 | |
368 | -void ProgressWindow::draw_background(RenderTarget& rt, const uint32_t xres, const uint32_t yres) { |
369 | - label_center_.x = xres / 2; |
370 | - label_center_.y = yres * PROGRESS_LABEL_POSITION_Y / 100; |
371 | - Recti wnd_rect(Vector2i(0, 0), xres, yres); |
372 | +void ProgressWindow::draw(RenderTarget& rt) { |
373 | + FullscreenWindow::draw(rt); |
374 | + label_center_.x = get_w() / 2; |
375 | + label_center_.y = get_h() * PROGRESS_LABEL_POSITION_Y / 100; |
376 | + Recti wnd_rect(Vector2i(0, 0), get_w(), get_h()); |
377 | |
378 | const uint32_t h = |
379 | UI::g_fh1->render(as_uifont(UI::g_fh1->fontset()->representative_character()))->height(); |
380 | |
381 | - label_rectangle_.x = xres / 4.f; |
382 | - label_rectangle_.w = xres / 2.f; |
383 | + label_rectangle_.x = get_w() / 4.f; |
384 | + label_rectangle_.w = get_w() / 2.f; |
385 | label_rectangle_.y = label_center_.y - h / 2.f - PROGRESS_STATUS_RECT_PADDING; |
386 | label_rectangle_.h = h + 2.f * PROGRESS_STATUS_RECT_PADDING; |
387 | |
388 | - const Image* bg = g_gr->images().get(background_); |
389 | - rt.blitrect_scale(Rectf(0.f, 0.f, xres, yres), bg, Recti(0, 0, bg->width(), bg->height()), 1., |
390 | - BlendMode::UseAlpha); |
391 | - |
392 | Rectf border_rect = label_rectangle_; |
393 | border_rect.x -= PROGRESS_STATUS_BORDER_X; |
394 | border_rect.y -= PROGRESS_STATUS_BORDER_Y; |
395 | @@ -84,23 +81,19 @@ |
396 | |
397 | /// Set a picture to render in the background |
398 | void ProgressWindow::set_background(const std::string& file_name) { |
399 | - RenderTarget& rt = *g_gr->get_render_target(); |
400 | + clear_overlays(); |
401 | if (!file_name.empty() && g_fs->file_exists(file_name)) { |
402 | - background_ = file_name; |
403 | + add_overlay_image(file_name, UI::Align::kCenter); |
404 | } else { |
405 | - background_ = "images/loadscreens/progress.png"; |
406 | + add_overlay_image("images/loadscreens/progress.png", UI::Align::kBottomLeft); |
407 | } |
408 | - draw_background(rt, g_gr->get_xres(), g_gr->get_yres()); |
409 | + draw(*g_gr->get_render_target()); |
410 | } |
411 | |
412 | void ProgressWindow::step(const std::string& description) { |
413 | RenderTarget& rt = *g_gr->get_render_target(); |
414 | - |
415 | - const uint32_t xres = g_gr->get_xres(); |
416 | - const uint32_t yres = g_gr->get_yres(); |
417 | - |
418 | // always repaint the background first |
419 | - draw_background(rt, xres, yres); |
420 | + draw(rt); |
421 | |
422 | rt.fill_rect(label_rectangle_, PROGRESS_FONT_COLOR_BG); |
423 | rt.blit(label_center_.cast<float>(), |
424 | |
425 | === modified file 'src/ui_basic/progresswindow.h' |
426 | --- src/ui_basic/progresswindow.h 2016-10-23 17:09:57 +0000 |
427 | +++ src/ui_basic/progresswindow.h 2016-11-01 07:36:03 +0000 |
428 | @@ -25,7 +25,7 @@ |
429 | #include <vector> |
430 | |
431 | #include "base/rect.h" |
432 | -#include "base/vector.h" |
433 | +#include "ui_basic/fullscreen_window.h" |
434 | |
435 | class Image; |
436 | class RenderTarget; |
437 | @@ -46,7 +46,7 @@ |
438 | }; |
439 | |
440 | /// Manages a progress window on the screen. |
441 | -struct ProgressWindow { |
442 | +struct ProgressWindow : public UI::FullscreenWindow { |
443 | ProgressWindow(const std::string& background = std::string()); |
444 | ~ProgressWindow(); |
445 | |
446 | @@ -70,7 +70,7 @@ |
447 | VisualizationArray visualizations_; |
448 | std::string background_; |
449 | |
450 | - void draw_background(RenderTarget& rt, uint32_t xres, uint32_t yres); |
451 | + void draw(RenderTarget&) override; |
452 | void update(bool repaint); |
453 | }; |
454 | } |
455 | |
456 | === modified file 'src/ui_fsmenu/base.cc' |
457 | --- src/ui_fsmenu/base.cc 2016-10-29 06:44:03 +0000 |
458 | +++ src/ui_fsmenu/base.cc 2016-11-01 07:36:03 +0000 |
459 | @@ -1,5 +1,5 @@ |
460 | /* |
461 | - * Copyright (C) 2002, 2007-2010 by the Widelands Development Team |
462 | + * Copyright (C) 2002-2016 by the Widelands Development Team |
463 | * |
464 | * This program is free software; you can redistribute it and/or |
465 | * modify it under the terms of the GNU General Public License |
466 | @@ -19,17 +19,6 @@ |
467 | |
468 | #include "ui_fsmenu/base.h" |
469 | |
470 | -#include <cstdio> |
471 | - |
472 | -#include "base/log.h" |
473 | -#include "base/wexception.h" |
474 | -#include "graphic/graphic.h" |
475 | -#include "graphic/image.h" |
476 | -#include "graphic/rendertarget.h" |
477 | -#include "graphic/text_constants.h" |
478 | -#include "io/filesystem/filesystem.h" |
479 | -#include "wlapplication.h" |
480 | - |
481 | /* |
482 | ============================================================================== |
483 | |
484 | @@ -38,43 +27,15 @@ |
485 | ============================================================================== |
486 | */ |
487 | |
488 | -FullscreenMenuBase::FullscreenMenuBase() : FullscreenMenuBase("images/ui_fsmenu/ui_fsmenu.jpg") { |
489 | -} |
490 | - |
491 | /** |
492 | * Initialize a pre-game menu |
493 | - * |
494 | - * Args: bgpic name of the background picture |
495 | */ |
496 | -FullscreenMenuBase::FullscreenMenuBase(const std::string& bgpic) |
497 | - : UI::Panel(nullptr, 0, 0, g_gr->get_xres(), g_gr->get_yres()), background_image_(bgpic) { |
498 | - graphic_resolution_changed_subscriber_ = Notifications::subscribe<GraphicResolutionChanged>( |
499 | - [this](const GraphicResolutionChanged& message) { |
500 | - set_size(message.width, message.height); |
501 | - layout(); |
502 | - }); |
503 | +FullscreenMenuBase::FullscreenMenuBase() : UI::FullscreenWindow() { |
504 | } |
505 | |
506 | FullscreenMenuBase::~FullscreenMenuBase() { |
507 | } |
508 | |
509 | -/** |
510 | - * Draw the background / splash screen |
511 | -*/ |
512 | -void FullscreenMenuBase::draw(RenderTarget& dst) { |
513 | - const Image* bg = g_gr->images().get(background_image_); |
514 | - dst.blitrect_scale(Rectf(0, 0, get_w(), get_h()), bg, Recti(0, 0, bg->width(), bg->height()), 1., |
515 | - BlendMode::UseAlpha); |
516 | -} |
517 | - |
518 | -int FullscreenMenuBase::fs_small() { |
519 | - return UI_FONT_SIZE_SMALL * get_h() / 600; |
520 | -} |
521 | - |
522 | -int FullscreenMenuBase::fs_big() { |
523 | - return UI_FONT_SIZE_BIG * get_h() / 600; |
524 | -} |
525 | - |
526 | bool FullscreenMenuBase::handle_key(bool down, SDL_Keysym code) { |
527 | if (down) { |
528 | switch (code.sym) { |
529 | |
530 | === modified file 'src/ui_fsmenu/base.h' |
531 | --- src/ui_fsmenu/base.h 2016-10-11 15:18:29 +0000 |
532 | +++ src/ui_fsmenu/base.h 2016-11-01 07:36:03 +0000 |
533 | @@ -20,19 +20,17 @@ |
534 | #ifndef WL_UI_FSMENU_BASE_H |
535 | #define WL_UI_FSMENU_BASE_H |
536 | |
537 | -#include <memory> |
538 | #include <string> |
539 | |
540 | -#include "graphic/graphic.h" |
541 | -#include "notifications/notifications.h" |
542 | +#include "ui_basic/fullscreen_window.h" |
543 | #include "ui_basic/panel.h" |
544 | |
545 | /** |
546 | * This class is the base class for a fullscreen menu. |
547 | - * A fullscreen menu is a menu which takes the full screen; it has the size |
548 | - * MENU_XRES and MENU_YRES and is a modal UI Element |
549 | + * A fullscreen menu is a menu which takes the full screen |
550 | + * and it is a modal UI Element |
551 | */ |
552 | -class FullscreenMenuBase : public UI::Panel { |
553 | +class FullscreenMenuBase : public UI::FullscreenWindow { |
554 | public: |
555 | enum class MenuTarget { |
556 | kBack = static_cast<int>(UI::Panel::Returncodes::kBack), |
557 | @@ -68,29 +66,16 @@ |
558 | kJoingame |
559 | }; |
560 | |
561 | - /// Calls FullscreenMenuBase(const std::string& bgpic) |
562 | - /// with a default background image |
563 | + /// A full screen main menu outside of the game/editor itself. |
564 | FullscreenMenuBase(); |
565 | - FullscreenMenuBase(const std::string& bgpic); |
566 | virtual ~FullscreenMenuBase(); |
567 | |
568 | - void draw(RenderTarget&) override; |
569 | - |
570 | - ///\return the size for texts fitting to current resolution |
571 | - int fs_small(); |
572 | - int fs_big(); |
573 | - |
574 | /// Handle keypresses |
575 | bool handle_key(bool down, SDL_Keysym code) override; |
576 | |
577 | protected: |
578 | virtual void clicked_back(); |
579 | virtual void clicked_ok(); |
580 | - |
581 | -private: |
582 | - std::string background_image_; |
583 | - std::unique_ptr<Notifications::Subscriber<GraphicResolutionChanged>> |
584 | - graphic_resolution_changed_subscriber_; |
585 | }; |
586 | |
587 | #endif // end of include guard: WL_UI_FSMENU_BASE_H |
588 | |
589 | === modified file 'src/ui_fsmenu/internet_lobby.cc' |
590 | --- src/ui_fsmenu/internet_lobby.cc 2016-09-25 12:24:46 +0000 |
591 | +++ src/ui_fsmenu/internet_lobby.cc 2016-11-01 07:36:03 +0000 |
592 | @@ -37,7 +37,7 @@ |
593 | FullscreenMenuInternetLobby::FullscreenMenuInternetLobby(char const* const nick, |
594 | char const* const pwd, |
595 | bool registered) |
596 | - : FullscreenMenuBase("images/ui_fsmenu/internetmenu.jpg"), |
597 | + : FullscreenMenuBase(), |
598 | |
599 | // Values for alignment and size |
600 | butx_(get_w() * 13 / 40), |
601 | |
602 | === modified file 'src/ui_fsmenu/intro.cc' |
603 | --- src/ui_fsmenu/intro.cc 2016-08-04 15:49:05 +0000 |
604 | +++ src/ui_fsmenu/intro.cc 2016-11-01 07:36:03 +0000 |
605 | @@ -22,7 +22,7 @@ |
606 | #include "base/i18n.h" |
607 | |
608 | FullscreenMenuIntro::FullscreenMenuIntro() |
609 | - : FullscreenMenuBase("images/loadscreens/splash.jpg"), |
610 | + : FullscreenMenuBase(), |
611 | |
612 | // Text area |
613 | message_(this, |
614 | @@ -32,6 +32,7 @@ |
615 | UI::Align::kHCenter) { |
616 | message_.set_fontsize(fs_small() * 6 / 5); |
617 | message_.set_color(RGBColor(192, 192, 128)); |
618 | + add_overlay_image("images/loadscreens/splash.jpg", UI::Align::kCenter); |
619 | } |
620 | |
621 | bool FullscreenMenuIntro::handle_mousepress(uint8_t, int32_t, int32_t) { |
622 | |
623 | === modified file 'src/ui_fsmenu/launch_mpg.cc' |
624 | --- src/ui_fsmenu/launch_mpg.cc 2016-10-28 18:04:11 +0000 |
625 | +++ src/ui_fsmenu/launch_mpg.cc 2016-11-01 07:36:03 +0000 |
626 | @@ -96,7 +96,7 @@ |
627 | |
628 | FullscreenMenuLaunchMPG::FullscreenMenuLaunchMPG(GameSettingsProvider* const settings, |
629 | GameController* const ctrl) |
630 | - : FullscreenMenuBase("images/ui_fsmenu/launch_mpg_menu.jpg"), |
631 | + : FullscreenMenuBase(), |
632 | |
633 | // Values for alignment and size |
634 | butw_(get_w() / 4), |
635 | |
636 | === modified file 'src/ui_fsmenu/load_map_or_game.cc' |
637 | --- src/ui_fsmenu/load_map_or_game.cc 2016-09-25 12:24:46 +0000 |
638 | +++ src/ui_fsmenu/load_map_or_game.cc 2016-11-01 07:36:03 +0000 |
639 | @@ -32,7 +32,7 @@ |
640 | /// This class defines common coordinates for these UI screens. |
641 | /// It also defines common buttons. |
642 | FullscreenMenuLoadMapOrGame::FullscreenMenuLoadMapOrGame() |
643 | - : FullscreenMenuBase("images/ui_fsmenu/choosemapmenu.jpg"), |
644 | + : FullscreenMenuBase(), |
645 | |
646 | // Values for alignment and size |
647 | padding_(4), |
648 | |
649 | === modified file 'src/ui_fsmenu/main.cc' |
650 | --- src/ui_fsmenu/main.cc 2016-10-31 08:07:59 +0000 |
651 | +++ src/ui_fsmenu/main.cc 2016-11-01 07:36:03 +0000 |
652 | @@ -26,7 +26,7 @@ |
653 | #include "graphic/graphic.h" |
654 | |
655 | FullscreenMenuMain::FullscreenMenuMain() |
656 | - : FullscreenMenuMainMenu("images/ui_fsmenu/mainmenu.jpg"), |
657 | + : FullscreenMenuMainMenu(), |
658 | |
659 | // Buttons |
660 | playtutorial(&vbox_, |
661 | @@ -142,6 +142,8 @@ |
662 | vbox_.add_inf_space(); |
663 | vbox_.add(&exit, UI::Align::kHCenter, true); |
664 | |
665 | + add_overlay_image("images/ui_fsmenu/main_title.png", UI::Align::kTopCenter); |
666 | + |
667 | layout(); |
668 | } |
669 | |
670 | |
671 | === modified file 'src/ui_fsmenu/main_menu.cc' |
672 | --- src/ui_fsmenu/main_menu.cc 2016-10-31 08:07:59 +0000 |
673 | +++ src/ui_fsmenu/main_menu.cc 2016-11-01 07:36:03 +0000 |
674 | @@ -20,11 +20,7 @@ |
675 | #include "ui_fsmenu/main_menu.h" |
676 | |
677 | FullscreenMenuMainMenu::FullscreenMenuMainMenu() |
678 | - : FullscreenMenuMainMenu("images/ui_fsmenu/ui_fsmenu.jpg") { |
679 | -} |
680 | - |
681 | -FullscreenMenuMainMenu::FullscreenMenuMainMenu(const std::string& background_image) |
682 | - : FullscreenMenuBase(background_image), |
683 | + : FullscreenMenuBase(), |
684 | |
685 | // Values for alignment and size |
686 | box_x_(get_w() * 13 / 40), |
687 | |
688 | === modified file 'src/ui_fsmenu/main_menu.h' |
689 | --- src/ui_fsmenu/main_menu.h 2016-10-31 08:07:59 +0000 |
690 | +++ src/ui_fsmenu/main_menu.h 2016-11-01 07:36:03 +0000 |
691 | @@ -29,14 +29,9 @@ |
692 | */ |
693 | class FullscreenMenuMainMenu : public FullscreenMenuBase { |
694 | public: |
695 | - /// Calls FullscreenMenuMainMenu(const std::string& background_image) |
696 | - /// with a default background image |
697 | + /// Assigns values for alignment and size, depending on screen size |
698 | FullscreenMenuMainMenu(); |
699 | |
700 | - /// Sets the background image and assigns values |
701 | - /// for alignment and size, depending on screen size |
702 | - FullscreenMenuMainMenu(const std::string& background_image); |
703 | - |
704 | protected: |
705 | void layout() override; |
706 | |
707 | |
708 | === modified file 'src/ui_fsmenu/options.cc' |
709 | --- src/ui_fsmenu/options.cc 2016-10-28 18:04:11 +0000 |
710 | +++ src/ui_fsmenu/options.cc 2016-11-01 07:36:03 +0000 |
711 | @@ -90,7 +90,7 @@ |
712 | |
713 | // TODO(GunChleoc): Arabic: This doesn't fit the window in Arabic. |
714 | FullscreenMenuOptions::FullscreenMenuOptions(OptionsCtrl::OptionsStruct opt) |
715 | - : FullscreenMenuBase("images/ui_fsmenu/ui_fsmenu.jpg"), |
716 | + : FullscreenMenuBase(), |
717 | |
718 | // Values for alignment and size |
719 | butw_(get_w() / 5), |
Oh, placeholder? Thats looks definitely better than just "placeholder" ;).
I really like this change!