Add support for an optional image to transient_message objects
(Part of a forthcoming fix for bug #16859.)
This commit is contained in:
parent
399b22b894
commit
b63bdf39a9
6 changed files with 71 additions and 28 deletions
|
@ -17,34 +17,59 @@
|
|||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
vertical_alignment = "top"
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
id = "title"
|
||||
definition = "title"
|
||||
[/label]
|
||||
[image]
|
||||
id = "image"
|
||||
definition = "default"
|
||||
[/image]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
grow_factor = 1
|
||||
vertical_alignment = "top"
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
id = "message"
|
||||
definition = "wml_message"
|
||||
[/label]
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
vertical_alignment = "top"
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
id = "title"
|
||||
definition = "title"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
vertical_alignment = "top"
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
id = "message"
|
||||
definition = "wml_message"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ void show_objectives(const config &level, const std::string &objectives)
|
|||
{
|
||||
static const std::string no_objectives(_("No objectives available"));
|
||||
gui2::show_transient_message(resources::screen->video(), level["name"],
|
||||
(objectives.empty() ? no_objectives : objectives), true);
|
||||
(objectives.empty() ? no_objectives : objectives), "", true);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "gui/dialogs/transient_message.hpp"
|
||||
|
||||
#include "gettext.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
@ -37,22 +38,30 @@ void ttransient_message::pre_show(CVideo& /*video*/, twindow& window)
|
|||
message.set_label(message_);
|
||||
message.set_use_markup(message_use_markup_);
|
||||
message.set_can_wrap(true);
|
||||
|
||||
timage& image = find_widget<timage>(&window, "image", false);
|
||||
|
||||
if(!image_.empty()) {
|
||||
image.set_image(image_);;
|
||||
}
|
||||
}
|
||||
|
||||
void show_transient_message(CVideo& video, const std::string& title,
|
||||
const std::string& message, bool message_use_markup, bool title_use_markup)
|
||||
const std::string& message, const std::string& image,
|
||||
bool message_use_markup, bool title_use_markup)
|
||||
{
|
||||
ttransient_message dlg(title, title_use_markup,
|
||||
message, message_use_markup);
|
||||
message, message_use_markup, image);
|
||||
dlg.show(video);
|
||||
}
|
||||
|
||||
void show_transient_error_message(CVideo& video
|
||||
, const std::string& message
|
||||
, const std::string& image
|
||||
, bool message_use_markup)
|
||||
{
|
||||
LOG_STREAM(err, lg::general) << message << '\n';
|
||||
show_transient_message(video, _("Error"), message, message_use_markup);
|
||||
show_transient_message(video, _("Error"), message, image, message_use_markup);
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
|
|
@ -29,11 +29,13 @@ public:
|
|||
ttransient_message(const std::string& title,
|
||||
bool title_use_markup,
|
||||
const std::string& message,
|
||||
bool message_use_markup)
|
||||
bool message_use_markup,
|
||||
const std::string& image)
|
||||
: title_(title)
|
||||
, title_use_markup_(title_use_markup)
|
||||
, message_(message)
|
||||
, message_use_markup_(message_use_markup)
|
||||
, image_(image)
|
||||
{}
|
||||
|
||||
protected:
|
||||
|
@ -44,15 +46,18 @@ private:
|
|||
/** The title for the dialog. */
|
||||
std::string title_;
|
||||
|
||||
/** Use markup for the title. */
|
||||
/** Use markup for the title. */
|
||||
bool title_use_markup_;
|
||||
|
||||
/** The message to show to the user. */
|
||||
std::string message_;
|
||||
|
||||
/** Use markup for the message. */
|
||||
/** Use markup for the message. */
|
||||
bool message_use_markup_;
|
||||
|
||||
/** An optional image to show at the left of the text. */
|
||||
std::string image_;
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
|
||||
virtual const std::string& window_id() const;
|
||||
};
|
||||
|
@ -70,11 +75,13 @@ private:
|
|||
* upon.
|
||||
* @param title The title of the dialog.
|
||||
* @param message The message to show in the dialog.
|
||||
* @param image An image to show in the dialog.
|
||||
* @param message_use_markup Use markup for the message?
|
||||
* @param title_use_markup Use markup for the title?
|
||||
*/
|
||||
void show_transient_message(CVideo& video, const std::string& title,
|
||||
const std::string& message,
|
||||
const std::string& image = std::string(),
|
||||
bool message_use_markup = false,
|
||||
bool title_use_markup = false);
|
||||
|
||||
|
@ -87,10 +94,12 @@ void show_transient_message(CVideo& video, const std::string& title,
|
|||
* @param video The video which contains the surface to draw
|
||||
* upon.
|
||||
* @param message The message to show in the dialog.
|
||||
* @param image An image to show in the dialog.
|
||||
* @param message_use_markup Use markup for the message?
|
||||
*/
|
||||
void show_transient_error_message(CVideo& video
|
||||
, const std::string& message
|
||||
, const std::string& image = std::string()
|
||||
, bool message_use_markup = false);
|
||||
|
||||
} // namespace gui2
|
||||
|
|
|
@ -964,7 +964,7 @@ void playsingle_controller::store_gold(bool obs)
|
|||
}
|
||||
|
||||
if (end_level.carryover_report) {
|
||||
gui2::show_transient_message(gui_->video(), title, report.str(), true);
|
||||
gui2::show_transient_message(gui_->video(), title, report.str(), "", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -355,7 +355,7 @@ struct twrapper<gui2::ttransient_message>
|
|||
{
|
||||
static gui2::ttransient_message* create()
|
||||
{
|
||||
return new gui2::ttransient_message("Title", false, "Message", false);
|
||||
return new gui2::ttransient_message("Title", false, "Message", false, "");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue