16 #define GETTEXT_DOMAIN "wesnoth-lib" 63 #include <boost/algorithm/string/erase.hpp> 66 #define ERR_CF LOG_STREAM(err, log_config) 67 #define WRN_CF LOG_STREAM(warn, log_config) 81 set_allow_plugin_skip(
false);
97 auto b = find_widget<button>(&win,
id,
false,
false);
115 gui2::dialogs::screenshot_notification::display(filename, screenshot);
134 std::string
message =
"Hello world.";
136 for(
int i = 0;
i < 0; ++
i) {
137 message +=
" More greetings.";
154 connect_signal<event::SDL_MOUSE_MOTION>(
155 std::bind(debug_tooltip, std::ref(*
this), std::placeholders::_3, std::placeholders::_5),
183 ERR_CF <<
"No title image defined";
189 ERR_CF <<
"No title background image defined";
202 if(
label* version_label = find_widget<label>(
this,
"revision_number",
false,
false)) {
203 version_label->set_label(version_string);
211 multi_page* tip_pages = find_widget<multi_page>(
this,
"tips",
false,
false);
213 if(tip_pages !=
nullptr) {
216 WRN_CF <<
"There are no tips of day available.";
218 for(
const auto&
tip : tips) {
222 widget[
"use_markup"] =
"true";
224 widget[
"label"] =
tip.text();
225 page.emplace(
"tip", widget);
227 widget[
"label"] =
tip.source();
228 page.emplace(
"source", widget);
247 gui2::dialogs::help_browser::display();
320 }
catch(
const std::runtime_error&
e) {
325 if(
auto* lang_button = find_widget<button>(
this,
"language",
false,
false); lang_button) {
329 const auto& boost_name = boost::algorithm::erase_first_copy(locale.name(),
".UTF-8");
332 auto lang_def = std::find_if(langs.begin(), langs.end(), [&](
language_def const& lang) {
333 return lang.localename == boost_name;
336 if(lang_def != langs.end()) {
337 lang_button->set_label(lang_def->language.str());
338 }
else if(boost_name ==
"c" || boost_name ==
"C") {
342 lang_button->set_label(
"English (US)");
346 lang_button->set_label(boost_name);
354 gui2::dialogs::preferences_dialog::display();
367 find_widget<button>(
this,
"quit",
false,
true);
375 auto clock = find_widget<button>(
this,
"clock",
false,
false);
389 if(tip_pages ==
nullptr) {
428 std::vector<std::string>
options;
430 if(!sc[
"is_unit_test"].to_bool(
false)) {
431 options.emplace_back(sc[
"id"]);
435 std::sort(options.begin(), options.end());
440 int choice = dlg.selected_index();
466 if(!gui2::dialogs::mp_host_game_prompt::execute()) {
472 case decltype(dlg)::choice::JOIN:
476 case decltype(dlg)::choice::CONNECT:
480 case decltype(dlg)::choice::HOST:
484 case decltype(dlg)::choice::LOCAL:
497 std::vector<config> cores;
499 cores.push_back(core);
502 current = cores.size() - 1;
507 if(core_dlg.
show()) {
bool new_widgets
Do we wish to use the new library or not.
void remove()
Removes a tip.
void show_debug_clock_window()
Shows the debug clock.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
void show_help(const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
surface read_pixels(SDL_Rect *r)
Copy back a portion of the render target that is already drawn.
std::string get_next_filename(const std::string &name, const std::string &extension)
Get the next free filename using "name + number (3 digits) + extension" maximum 1000 files then start...
std::vector< game_tip > tips
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
void set_variable(const std::string &key, wfl::variant &&value)
Main class to show messages to the user.
void register_hotkey(const hotkey::HOTKEY_COMMAND id, const hotkey_function &function)
Registers a hotkey.
This class implements the title screen.
void set_click_dismiss(const bool click_dismiss)
void button_callback_cores()
std::string get_screenshot_dir()
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
A label displays a text, the text can be wrapped but no scrollbars are provided.
int get_selected_page() const
Returns the selected page.
static std::string _(const char *str)
bool show(const unsigned auto_close_time=0)
Shows the window.
static void launch_lua_console()
static void display(lua_kernel_base *lk)
Display a new console, using given video and lua kernel.
This shows a dialog displaying achievements.
static game_config_manager * get()
const std::vector< game_config::server_info > & builtin_servers_list()
std::map< std::string, t_string > widget_item
A simple one-column listbox with OK and Cancel buttons.
This file contains the settings handling of the widget library.
std::string game_title_background
language_list get_languages(bool all)
Return a list of available translations.
void set_test(const std::string &id)
static std::unique_ptr< tooltip > tip
void set_core_id(const std::string &core_id)
void select_mp_server(const std::string &server)
static lg::log_domain log_config("config")
void hide()
Hides the window.
std::string game_logo_background
const char * what() const noexcept
bool manage_addons()
Shows the add-ons server connection dialog, for access to the various management front-ends.
window * get_window()
Returns a pointer to the dialog's window.
choice get_choice() const
int mp_server_warning_disabled()
const std::string revision
void load_game_config_for_create(bool is_mp, bool is_test=false)
Clock to test the draw events.
Game configuration data as global variables.
void select_page(const unsigned page, const bool select=true)
Selects a page.
void button_callback_multiplayer()
grid & add_page(const widget_item &item)
Adds single page to the grid.
Contains the gui2 timer routines.
Declarations for File-IO.
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
unsigned get_page_count() const
Returns the number of pages.
int get_retval() const
Returns the cached window exit code.
This shows the dialog to select the kind of MP game the user wants to play.
A multi page is a control that contains several 'pages' of which only one is visible.
void update_tip(const bool previous)
Updates the tip of day widget.
Abstract base class for all modal dialogs.
void hotkey_callback_select_tests()
Standard logging facilities (interface).
std::unique_ptr< modeless_dialog > debug_clock_
Holds the debug clock dialog.
void show_error_message(const std::string &msg, bool message_use_markup)
Shows an error message to the user.
std::map< std::string, widget_item > widget_data
This shows the dialog which allows the user to choose which core to play.
std::vector< game_tip > shuffle(const std::vector< game_tip > &tips)
Shuffles the tips.
Dialog was closed with the OK button.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
A config object defines a single node in a WML file, with access to child nodes.
static void make_screenshot()
base class of top level items, the only item which needs to store the final canvases to draw on...
std::function< void()> btn_callback
static void register_button(window &win, const std::string &id, hotkey::HOTKEY_COMMAND hk, btn_callback callback)
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
bool show_debug_clock_button
Do we wish to show the button for the debug clock.
const boost::locale::info & get_effective_locale_info()
A facet that holds general information about the effective locale.
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.