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) {
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";
200 multi_page* tip_pages = find_widget<multi_page>(
this,
"tips",
false,
false);
202 if(tip_pages !=
nullptr) {
205 WRN_CF <<
"There are no tips of day available.";
211 widget[
"use_markup"] =
"true";
214 page.emplace(
"tip",
widget);
217 page.emplace(
"source",
widget);
236 gui2::dialogs::help_browser::display();
256 set_retval(LAUNCH_GAME);
277 set_retval(LAUNCH_GAME);
308 update_static_labels();
310 }
catch(
const std::runtime_error&
e) {
319 gui2::dialogs::preferences_dialog::display();
326 panel* tip_panel = find_widget<panel>(
this,
"tip_panel",
false,
false);
327 if(tip_panel !=
nullptr) {
331 panel* menu_panel = find_widget<panel>(
this,
"menu_panel",
false,
false);
332 if(menu_panel !=
nullptr) {
354 find_widget<button>(
this,
"quit",
false,
true);
362 auto clock = find_widget<button>(
this,
"clock",
false,
false);
380 if(
label* version_label = find_widget<label>(
this,
"revision_number",
false,
false)) {
381 version_label->set_label(version_string);
389 if(
auto* lang_button = find_widget<button>(
this,
"language",
false,
false); lang_button) {
393 const auto& boost_name = boost::algorithm::erase_first_copy(locale.name(),
".UTF-8");
396 auto lang_def = std::find_if(langs.begin(), langs.end(), [&](
language_def const& lang) {
397 return lang.localename == boost_name;
400 if(lang_def != langs.end()) {
401 lang_button->set_label(lang_def->language.str());
402 }
else if(boost_name ==
"c" || boost_name ==
"C") {
406 lang_button->set_label(
"English (US)");
410 lang_button->set_label(boost_name);
423 if(tip_pages ==
nullptr) {
462 std::vector<std::string>
options;
464 if(!sc[
"is_unit_test"].to_bool(
false)) {
465 options.emplace_back(sc[
"id"]);
500 if(!gui2::dialogs::mp_host_game_prompt::execute()) {
506 case decltype(dlg)::choice::JOIN:
510 case decltype(dlg)::choice::CONNECT:
514 case decltype(dlg)::choice::HOST:
518 case decltype(dlg)::choice::LOCAL:
531 std::vector<config> cores;
533 cores.push_back(core);
536 current = cores.size() - 1;
541 if(core_dlg.
show()) {
A config object defines a single node in a WML file, with access to child nodes.
static game_config_manager * get()
void load_game_config_for_create(bool is_mp, bool is_test=false)
void select_mp_server(const std::string &server)
void set_test(const std::string &id)
void set_variable(const std::string &key, wfl::variant &&value)
void queue_reblur()
Clear the cached blur texture, forcing it to regenerate.
This shows a dialog displaying achievements.
This shows the dialog which allows the user to choose which core to play.
Clock to test the draw events.
static void display(lua_kernel_base *lk)
Display a new console, using given video and lua kernel.
Main class to show messages to the user.
Abstract base class for all modal dialogs.
bool show(const unsigned auto_close_time=0)
Shows the window.
int get_retval() const
Returns the cached window exit code.
window * get_window()
Returns a pointer to the dialog's window.
This shows the dialog to select the kind of MP game the user wants to play.
choice get_choice() const
A simple one-column listbox with OK and Cancel buttons.
int selected_index() const
Returns the selected item index after displaying.
This class implements the title screen.
std::unique_ptr< modeless_dialog > debug_clock_
Holds the debug clock dialog.
void button_callback_cores()
void update_tip(const bool previous)
Updates the tip of day widget.
void hotkey_callback_select_tests()
void button_callback_multiplayer()
void update_static_labels()
Updates UI labels that are not t_string after a language change.
void show_debug_clock_window()
Shows the debug clock.
void register_hotkey(const hotkey::HOTKEY_COMMAND id, const hotkey_function &function)
Registers a hotkey.
A label displays text that can be wrapped but no scrollbars are provided.
A multi page is a control that contains several 'pages' of which only one is visible.
grid & add_page(const widget_item &item)
Adds single page to the grid.
unsigned get_page_count() const
Returns the number of pages.
int get_selected_page() const
Returns the selected page.
void select_page(const unsigned page, const bool select=true)
Selects a page.
A panel is a visible container to hold multiple widgets.
virtual unsigned get_state() const override
See styled_widget::get_state.
base class of top level items, the only item which needs to store the final canvases to draw on.
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
void set_click_dismiss(const bool click_dismiss)
Declarations for File-IO.
static std::string _(const char *str)
language_list get_languages(bool all)
Return a list of available translations.
Standard logging facilities (interface).
bool manage_addons()
Shows the add-ons server connection dialog, for access to the various management front-ends.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
std::string get_screenshot_dir()
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::string game_title_background
std::string game_logo_background
Game configuration data as global variables.
const std::string revision
void show(const std::string &window_id, const t_string &message, const point &mouse, const SDL_Rect &source_rect)
Shows a tip.
void remove()
Removes a tip.
static std::unique_ptr< tooltip > tip
static void launch_lua_console()
static void register_button(window &win, const std::string &id, hotkey::HOTKEY_COMMAND hk, btn_callback callback)
static void make_screenshot()
bool show_debug_clock_button
Do we wish to show the button for the debug clock.
std::function< void()> btn_callback
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
std::vector< game_tip > tips
std::vector< game_tip > shuffle(const std::vector< game_tip > &tips)
Shuffles the tips.
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
bool new_widgets
Do we wish to use the new library or not.
void show_error_message(const std::string &msg, bool message_use_markup)
Shows an error message to the user.
@ OK
Dialog was closed with the OK button.
void show_help(const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
@ TITLE_SCREEN__MULTIPLAYER
@ TITLE_SCREEN__PREVIOUS_TIP
@ TITLE_SCREEN__RELOAD_WML
void set_core_id(const std::string &core_id)
int mp_server_warning_disabled()
const std::vector< game_config::server_info > & builtin_servers_list()
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
const boost::locale::info & get_effective_locale_info()
A facet that holds general information about the effective locale.
surface read_pixels(SDL_Rect *r)
Copy back a portion of the render target that is already drawn.
This file contains the settings handling of the widget library.
Contains the gui2 timer routines.
static lg::log_domain log_config("config")