Adds "animated" logo to the new title screen.
This commit is contained in:
parent
afe89e4070
commit
b680fbc95f
5 changed files with 143 additions and 7 deletions
|
@ -14,6 +14,7 @@ Version 1.9.0-svn:
|
|||
* Avoid resizing when next or previous button is pressed in the
|
||||
--new-widgets title screen
|
||||
* Added gui2 progress bar widget
|
||||
* Added "animated" logo to the --new-widgets title screen
|
||||
* WML Engine:
|
||||
* Deprecated [set_variable]'s random key, use rand instead
|
||||
* Renamed [unit][status] healable to unhealable so it can default to 'no'
|
||||
|
|
41
data/gui/default/widget/progress_bar_title_screen.cfg
Normal file
41
data/gui/default/widget/progress_bar_title_screen.cfg
Normal file
|
@ -0,0 +1,41 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### Definition of an progress bar, used to fade in the logo in the title screen.
|
||||
###
|
||||
|
||||
[progress_bar_definition]
|
||||
id = "title_screen"
|
||||
description = "A progress bar used in the title screen to fade in the logo."
|
||||
|
||||
[resolution]
|
||||
|
||||
min_width = 440
|
||||
min_height = 201
|
||||
|
||||
default_width = 440
|
||||
default_height = 201
|
||||
|
||||
max_width = 440
|
||||
max_height = 201
|
||||
|
||||
[state_enabled]
|
||||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
# w = 0 means fit
|
||||
# using percentage = 0 seems to fail for some reason...
|
||||
w = "(if(percentage <= 0, 1, (width * percentage) / 100))"
|
||||
h = "(height)"
|
||||
name = "misc/logo.png"
|
||||
resize_mode = "tile"
|
||||
[/image]
|
||||
|
||||
[/draw]
|
||||
|
||||
[/state_enabled]
|
||||
|
||||
[/resolution]
|
||||
|
||||
[/progress_bar_definition]
|
||||
|
|
@ -230,17 +230,58 @@
|
|||
height = "(screen_height)"
|
||||
|
||||
[grid]
|
||||
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
vertical_alignment = "bottom"
|
||||
{_GUI_TIP_SECTION}
|
||||
[/column]
|
||||
horizontal_grow = "true"
|
||||
vertical_grow = "true"
|
||||
|
||||
[stacked_widget]
|
||||
|
||||
[stack]
|
||||
|
||||
[layer]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
vertical_alignment = "bottom"
|
||||
{_GUI_TIP_SECTION}
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
horizontal_alignment = "right"
|
||||
vertical_alignment = "bottom"
|
||||
{_GUI_MENU_SECTION}
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/layer]
|
||||
|
||||
[layer]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
vertical_alignment = "top"
|
||||
|
||||
[progress_bar]
|
||||
id = "logo"
|
||||
definition = "title_screen"
|
||||
[/progress_bar]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/layer]
|
||||
|
||||
[/stack]
|
||||
|
||||
[/stacked_widget]
|
||||
|
||||
[column]
|
||||
horizontal_alignment = "right"
|
||||
{_GUI_MENU_SECTION}
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
|
|
@ -17,13 +17,16 @@
|
|||
#include "gui/dialogs/title_screen.hpp"
|
||||
|
||||
#include "game_config.hpp"
|
||||
#include "game_preferences.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "log.hpp"
|
||||
#include "gui/auxiliary/timer.hpp"
|
||||
#include "gui/dialogs/addon_connect.hpp"
|
||||
#include "gui/dialogs/language_selection.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#include "gui/widgets/multi_page.hpp"
|
||||
#include "gui/widgets/progress_bar.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "titlescreen.hpp"
|
||||
|
@ -67,6 +70,7 @@ void show_dialog(CVideo& video)
|
|||
* (source) (label) () The source for the tip of the day.
|
||||
* (next_tip) (button) () The button show the next tip of day.
|
||||
* (previous_tip) (button) () The button show the previous tip of day.
|
||||
* (logo) (progress_bar) () A progress bar to "animate" the image
|
||||
* @end_table
|
||||
*/
|
||||
|
||||
|
@ -75,10 +79,33 @@ REGISTER_WINDOW(title_screen)
|
|||
ttitle_screen::ttitle_screen()
|
||||
: video_(NULL)
|
||||
, tips_()
|
||||
, logo_timer_id_(0)
|
||||
{
|
||||
read_tips_of_day(tips_);
|
||||
}
|
||||
|
||||
ttitle_screen::~ttitle_screen()
|
||||
{
|
||||
if(logo_timer_id_) {
|
||||
remove_timer(logo_timer_id_);
|
||||
}
|
||||
}
|
||||
static void animate_logo(
|
||||
unsigned long& timer_id
|
||||
, unsigned& percentage
|
||||
, tprogress_bar& progress_bar)
|
||||
{
|
||||
assert(percentage <= 100);
|
||||
++percentage;
|
||||
progress_bar.set_percentage(percentage);
|
||||
|
||||
if(percentage == 100) {
|
||||
remove_timer(timer_id);
|
||||
timer_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ttitle_screen::pre_show(CVideo& video, twindow& window)
|
||||
{
|
||||
assert(!video_);
|
||||
|
@ -158,6 +185,27 @@ void ttitle_screen::pre_show(CVideo& video, twindow& window)
|
|||
window.canvas()[0].set_variable("background_image",
|
||||
variant(game_title_list[rand()%game_title_list.size()]));
|
||||
}
|
||||
|
||||
/***** Set the logo *****/
|
||||
tprogress_bar* logo =
|
||||
find_widget<tprogress_bar>(&window, "logo", false, false);
|
||||
if(logo) {
|
||||
static unsigned percentage = preferences::startup_effect() ? 0 : 100;
|
||||
logo->set_percentage(percentage);
|
||||
|
||||
if(percentage < 100) {
|
||||
/*
|
||||
* The interval is empirically determined so that the speed "felt"
|
||||
* good.
|
||||
*/
|
||||
logo_timer_id_ = add_timer(30
|
||||
, boost::bind(animate_logo
|
||||
, boost::ref(logo_timer_id_)
|
||||
, boost::ref(percentage)
|
||||
, boost::ref(*logo))
|
||||
, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ttitle_screen::post_show(twindow& /*window*/)
|
||||
|
|
|
@ -26,6 +26,8 @@ class ttitle_screen : public tdialog
|
|||
public:
|
||||
ttitle_screen();
|
||||
|
||||
~ttitle_screen();
|
||||
|
||||
CVideo* video() { return video_; }
|
||||
|
||||
private:
|
||||
|
@ -44,6 +46,9 @@ private:
|
|||
/** Hold the tips of the day. */
|
||||
config tips_;
|
||||
|
||||
/** The progress bar time for the logo. */
|
||||
unsigned long logo_timer_id_;
|
||||
|
||||
/**
|
||||
* Updates the tip of day widget.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue