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);
96 button& btn = find_widget<button>(
id);
116 gui2::dialogs::screenshot_notification::display(
filename, screenshot);
135 std::string
message =
"Hello world.";
137 for(
int i = 0;
i < 0; ++
i) {
155 connect_signal<event::SDL_MOUSE_MOTION>(
156 std::bind(debug_tooltip, std::ref(*
this), std::placeholders::_3, std::placeholders::_5),
185 ERR_CF <<
"No titlescreen background defined in game config";
197 multi_page* tip_pages = find_widget<multi_page>(
"tips",
false,
false);
199 if(tip_pages !=
nullptr) {
202 WRN_CF <<
"There are no tips of day available.";
208 widget[
"use_markup"] =
"true";
218 std::string tip_text =
tip.text().str();
220 while (pos < tip_text.size() && tip_text.at(pos) ==
'<') {
221 pos = tip_text.find_first_of(
">", pos) + 1;
224 utf8::insert(tip_text, pos,
"<span font_family='" + script_font +
"' font_size='xx-large'>");
226 widget[
"label"] = tip_text;
228 page.emplace(
"tip",
widget);
231 page.emplace(
"source",
widget);
267 set_retval(LAUNCH_GAME);
288 set_retval(LAUNCH_GAME);
319 update_static_labels();
321 }
catch(
const std::runtime_error&
e) {
349 find_widget<button>(
"quit",
false,
true);
357 auto clock = find_widget<button>(
"clock",
false,
false);
368 auto test_dialog = find_widget<button>(
"test_dialog",
false,
false);
386 if(
label* version_label = find_widget<label>(
"revision_number",
false,
false)) {
387 version_label->set_label(version_string);
395 if(
auto* lang_button = find_widget<button>(
"language",
false,
false); lang_button) {
399 const auto& boost_name = boost::algorithm::erase_first_copy(locale.name(),
".UTF-8");
402 auto lang_def = std::find_if(langs.begin(), langs.end(), [&](
language_def const& lang) {
403 return lang.localename == boost_name;
406 if(lang_def != langs.end()) {
407 lang_button->set_label(lang_def->language.str());
408 }
else if(boost_name ==
"c" || boost_name ==
"C") {
412 lang_button->set_label(
"English (US)");
416 lang_button->set_label(boost_name);
428 multi_page* tip_pages = find_widget<multi_page>(
"tips",
false,
false);
429 if(tip_pages ==
nullptr) {
468 std::vector<std::string> options;
470 if(!sc[
"is_unit_test"].to_bool(
false)) {
471 options.emplace_back(sc[
"id"]);
475 std::sort(options.begin(), options.end());
502 gui2::dialogs::gui_test_dialog::execute();
518 panel* tip_panel = find_widget<panel>(
"tip_panel",
false,
false);
519 if(tip_panel !=
nullptr) {
523 panel* menu_panel = find_widget<panel>(
"menu_panel",
false,
false);
524 if(menu_panel !=
nullptr) {
542 if(res == decltype(dlg)::choice::HOST &&
prefs::get().mp_server_warning_disabled() < 2) {
543 if(!gui2::dialogs::mp_host_game_prompt::execute()) {
549 case decltype(dlg)::choice::JOIN:
553 case decltype(dlg)::choice::CONNECT:
557 case decltype(dlg)::choice::HOST:
561 case decltype(dlg)::choice::LOCAL:
574 std::vector<config> cores;
576 cores.push_back(core);
579 current = cores.size() - 1;
584 if(core_dlg.
show()) {
585 const std::string& core_id = cores[core_dlg.
get_choice()][
"id"];
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.
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.
choice get_choice() const
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 show_gui_test_dialog()
Shows the gui test window.
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 show_preferences()
Shows the preferences dialog.
void register_button(const std::string &id, hotkey::HOTKEY_COMMAND hk, const std::function< void()> &callback)
void register_hotkey(const hotkey::HOTKEY_COMMAND id, const hotkey_function &function)
Registers a hotkey.
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.
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.
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...
const t_string & get_font_families(family_class fclass)
Returns the currently defined fonts.
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 make_screenshot()
bool show_debug_clock_button
Do we wish to show the button for the debug clock.
REGISTER_DIALOG(editor_edit_unit)
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
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)
Open the help browser, show topic with id show_topic.
@ TITLE_SCREEN__MULTIPLAYER
@ TITLE_SCREEN__PREVIOUS_TIP
@ TITLE_SCREEN__RELOAD_WML
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.
std::string & insert(std::string &str, const std::size_t pos, const std::string &insert)
Insert a UTF-8 string at the specified position.
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.
std::string filename
Filename.
The help implementation caches data parsed from the game_config.
Helper class, don't construct this directly.
static lg::log_domain log_config("config")
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...