Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's the screen that shows 'The End' at the end of an SP campaign.
- Loading branch information
Showing
11 changed files
with
262 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#textdomain wesnoth-lib | ||
|
||
[window_definition] | ||
id = "outro" | ||
description = "The window definition for the outro screen." | ||
|
||
[resolution] | ||
|
||
# NOTE: we don't specify borders like most definitions since we want | ||
# widgets to fully reach the edge of the window. | ||
|
||
[background] | ||
|
||
[draw] | ||
|
||
[rectangle] | ||
x = 0 | ||
y = 0 | ||
w = "(width)" | ||
h = "(height)" | ||
|
||
fill_color = "0, 0, 0, 255" | ||
immutable = true | ||
[/rectangle] | ||
|
||
[text] | ||
x = {GUI__TEXT_HORIZONTALLY_CENTRED} | ||
y = {GUI__TEXT_VERTICALLY_CENTRED} | ||
w = "(width)" | ||
h = "(text_height)" | ||
maximum_width = "(width)" | ||
|
||
font_size = {GUI_FONT_SIZE_HUGE} | ||
color = "([215, 215, 215, min(fade_step * 5, 255)])" | ||
|
||
text = "(outro_text)" | ||
text_markup = true | ||
[/text] | ||
|
||
[/draw] | ||
|
||
[/background] | ||
|
||
[foreground] | ||
|
||
[draw] | ||
|
||
[/draw] | ||
|
||
[/foreground] | ||
|
||
[/resolution] | ||
|
||
[/window_definition] | ||
|
||
[window] | ||
id = "outro" | ||
description = "Outro text display" | ||
|
||
[resolution] | ||
definition = "outro" | ||
|
||
{GUI_WINDOW_FULLSCREEN} | ||
|
||
[tooltip] | ||
id = "tooltip_large" | ||
[/tooltip] | ||
|
||
[helptip] | ||
id = "tooltip_large" | ||
[/helptip] | ||
|
||
# No contents. The only text is drawn in the background by the canvas. | ||
[grid] | ||
[/grid] | ||
|
||
[/resolution] | ||
|
||
[/window] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
Copyright (C) 2017 by Charles Dang <exodia339@gmail.com> | ||
Part of 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/outro.hpp" | ||
|
||
#include "formula/variant.hpp" | ||
#include "gettext.hpp" | ||
#include "gui/auxiliary/find_widget.hpp" | ||
#include "gui/core/timer.hpp" | ||
#include "gui/widgets/settings.hpp" | ||
#include "gui/widgets/window.hpp" | ||
|
||
namespace gui2 | ||
{ | ||
namespace dialogs | ||
{ | ||
|
||
REGISTER_DIALOG(outro) | ||
|
||
outro::outro(const std::string& text, unsigned int duration) | ||
: text_(text) | ||
, duration_(duration) | ||
, fade_step_(0) | ||
, fading_in_(true) | ||
, timer_id_(0) | ||
, timer_id_secondary_(0) | ||
{ | ||
if(text_.empty()) { | ||
text_ = _("The End"); | ||
} | ||
|
||
if(!duration_) { | ||
duration_ = 3500; | ||
} | ||
} | ||
|
||
void outro::pre_show(window& window) | ||
{ | ||
window.set_enter_disabled(true); | ||
window.get_canvas(0).set_variable("outro_text", wfl::variant(text_)); | ||
|
||
timer_id_ = add_timer(50, std::bind(&outro::timer_callback, this, std::ref(window)), true); | ||
} | ||
|
||
void outro::timer_callback(window& window) | ||
{ | ||
// If we've faded fully in... | ||
if(fading_in_ && fade_step_ == 255) { | ||
// Schedule the fadeout after the provided delay. | ||
if(timer_id_secondary_ == 0) { | ||
timer_id_secondary_ = add_timer(duration_, [this](size_t) { fading_in_ = false; }); | ||
} | ||
|
||
return; | ||
} | ||
|
||
// If we've faded fully out... | ||
if(!fading_in_ && fade_step_ < 0) { | ||
window.close(); | ||
return; | ||
} | ||
|
||
canvas& window_canvas = window.get_canvas(0); | ||
|
||
window_canvas.set_variable("fade_step", wfl::variant(fade_step_)); | ||
window_canvas.set_is_dirty(true); | ||
|
||
window.set_is_dirty(true); | ||
|
||
if(fading_in_) { | ||
fade_step_ += 5; | ||
} else { | ||
fade_step_ -= 5; | ||
} | ||
} | ||
|
||
void outro::post_show(window& /*window*/) | ||
{ | ||
remove_timer(timer_id_); | ||
remove_timer(timer_id_secondary_); | ||
|
||
timer_id_ = 0; | ||
timer_id_secondary_ = 0; | ||
} | ||
|
||
} // namespace dialogs | ||
} // namespace gui2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
Copyright (C) 2017 by Charles Dang <exodia339@gmail.com> | ||
Part of 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_OUTRO_HPP_INCLUDED | ||
#define GUI_DIALOGS_OUTRO_HPP_INCLUDED | ||
|
||
#include "gui/dialogs/modal_dialog.hpp" | ||
|
||
class CVideo; | ||
|
||
namespace gui2 | ||
{ | ||
namespace dialogs | ||
{ | ||
|
||
/** Dialog to display 'The End' at the end of a campaign. */ | ||
class outro : public modal_dialog | ||
{ | ||
public: | ||
outro(const std::string& text, unsigned int duration); | ||
|
||
/** | ||
* Displays a simple fading screen with any user-provided text. | ||
* Used after the end of single-player campaigns. | ||
* | ||
* @param text Text to display, centered on the screen. | ||
* | ||
* @param duration In milliseconds, for how much time the text will | ||
* be displayed on screen. | ||
*/ | ||
static void display(const std::string& text, unsigned int duration, CVideo& video) | ||
{ | ||
outro(text, duration).show(video); | ||
} | ||
|
||
private: | ||
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */ | ||
virtual const std::string& window_id() const; | ||
|
||
/** Inherited from modal_dialog. */ | ||
void pre_show(window& window); | ||
|
||
/** Inherited from modal_dialog. */ | ||
void post_show(window& window); | ||
|
||
void timer_callback(window& window); | ||
|
||
std::string text_; | ||
|
||
unsigned int duration_; | ||
int fade_step_; | ||
|
||
bool fading_in_; | ||
|
||
size_t timer_id_; | ||
size_t timer_id_secondary_; | ||
}; | ||
|
||
} // namespace dialogs | ||
} // namespace gui2 | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.