Merge branch 'master' of github.com:wesnoth/wesnoth

This commit is contained in:
Elvish_Hunter 2020-12-03 21:40:17 +01:00
commit 1fd4111cb9
12 changed files with 49 additions and 51 deletions

View File

@ -16,7 +16,7 @@ scons translations build=release --debug=time nls=true jobs=2 || exit 1
cd ./projectfiles/Xcode cd ./projectfiles/Xcode
xcodebuild CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -project "The Battle for Wesnoth.xcodeproj" -target "The Battle for Wesnoth" -configuration "$CFG" xcodebuild CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO EXCLUDED_ARCHS=arm64 -project "The Battle for Wesnoth.xcodeproj" -target "The Battle for Wesnoth" -configuration "$CFG"
EXIT_VAL=$? EXIT_VAL=$?
ccache -s ccache -s

View File

@ -46,14 +46,14 @@ namespace gui2
* be tuned. This page will describe what can be tuned. * be tuned. This page will describe what can be tuned.
* *
*/ */
window* build(const builder_window::window_resolution* definition) std::unique_ptr<window> build(const builder_window::window_resolution& definition)
{ {
// We set the values from the definition since we can only determine the // We set the values from the definition since we can only determine the
// best size (if needed) after all widgets have been placed. // best size (if needed) after all widgets have been placed.
window* win = new window(definition); auto win = std::make_unique<window>(definition);
assert(win); assert(win);
for(const auto& lg : definition->linked_groups) { for(const auto& lg : definition.linked_groups) {
if(win->has_linked_size_group(lg.id)) { if(win->has_linked_size_group(lg.id)) {
t_string msg = VGETTEXT("Linked '$id' group has multiple definitions.", {{"id", lg.id}}); t_string msg = VGETTEXT("Linked '$id' group has multiple definitions.", {{"id", lg.id}});
@ -63,27 +63,27 @@ window* build(const builder_window::window_resolution* definition)
win->init_linked_size_group(lg.id, lg.fixed_width, lg.fixed_height); win->init_linked_size_group(lg.id, lg.fixed_width, lg.fixed_height);
} }
win->set_click_dismiss(definition->click_dismiss); win->set_click_dismiss(definition.click_dismiss);
const auto conf = win->cast_config_to<window_definition>(); const auto conf = win->cast_config_to<window_definition>();
assert(conf); assert(conf);
if(conf->grid) { if(conf->grid) {
win->init_grid(*conf->grid); win->init_grid(*conf->grid);
win->finalize(*definition->grid); win->finalize(*definition.grid);
} else { } else {
win->init_grid(*definition->grid); win->init_grid(*definition.grid);
} }
win->add_to_keyboard_chain(win); win->add_to_keyboard_chain(win.get());
return win; return win;
} }
window* build(const std::string& type) std::unique_ptr<window> build(const std::string& type)
{ {
const builder_window::window_resolution& definition = get_window_builder(type); const builder_window::window_resolution& definition = get_window_builder(type);
window* window = build(&definition); auto window = build(definition);
window->set_id(type); window->set_id(type);
return window; return window;
} }

View File

@ -28,14 +28,6 @@ namespace gui2
class window; class window;
/**
* Builds a window.
*
* @param type The type id string of the window, this window
* must be registered at startup.
*/
window* build(const std::string& type);
/** Contains the info needed to instantiate a widget. */ /** Contains the info needed to instantiate a widget. */
struct builder_widget struct builder_widget
{ {
@ -212,7 +204,15 @@ private:
/** /**
* Builds a window. * Builds a window.
*
* @param type The type id string of the window, this window
* must be registered at startup.
*/ */
window* build(const builder_window::window_resolution* res); std::unique_ptr<window> build(const std::string& type);
/**
* Builds a window.
*/
std::unique_ptr<window> build(const builder_window::window_resolution& res);
} // namespace gui2 } // namespace gui2

View File

@ -74,7 +74,7 @@ bool modal_dialog::show(const unsigned auto_close_time)
return false; return false;
} }
window_.reset(build_window()); window_ = build_window();
assert(window_.get()); assert(window_.get());
post_build(*window_); post_build(*window_);
@ -218,7 +218,7 @@ field_label* modal_dialog::register_label(const std::string& id,
return field; return field;
} }
window* modal_dialog::build_window() const std::unique_ptr<window> modal_dialog::build_window() const
{ {
return build(window_id()); return build(window_id());
} }

View File

@ -392,7 +392,7 @@ private:
* *
* @returns The window to show. * @returns The window to show.
*/ */
window* build_window() const; std::unique_ptr<window> build_window() const;
/** /**
* Actions to be taken directly after the window is build. * Actions to be taken directly after the window is build.

View File

@ -41,7 +41,7 @@ void modeless_dialog::show(const bool allow_interaction, const unsigned /*auto_c
hide(); hide();
window_.reset(build_window()); window_ = build_window();
post_build(*window_); post_build(*window_);
@ -67,7 +67,7 @@ void modeless_dialog::hide()
window_.reset(nullptr); } window_.reset(nullptr); }
} }
window* modeless_dialog::build_window() const std::unique_ptr<window> modeless_dialog::build_window() const
{ {
return build(window_id()); return build(window_id());
} }

View File

@ -100,7 +100,7 @@ private:
* *
* @returns The window to show. * @returns The window to show.
*/ */
window* build_window() const; std::unique_ptr<window> build_window() const;
/** /**
* Actions to be taken directly after the window is build. * Actions to be taken directly after the window is build.

View File

@ -82,14 +82,13 @@ void stacked_widget::layout_children()
} }
} }
void void stacked_widget::finalize(const std::vector<builder_grid>& widget_builders)
stacked_widget::finalize(std::vector<builder_grid_const_ptr> widget_builder)
{ {
assert(generator_); assert(generator_);
string_map empty_data; string_map empty_data;
for(const auto & builder : widget_builder) for(const auto & builder : widget_builders)
{ {
generator_->create_item(-1, *builder, empty_data, nullptr); generator_->create_item(-1, builder, empty_data, nullptr);
} }
swap_grid(nullptr, &get_grid(), generator_, "_content_grid"); swap_grid(nullptr, &get_grid(), generator_, "_content_grid");
@ -278,7 +277,7 @@ builder_stacked_widget::builder_stacked_widget(const config& real_cfg)
VALIDATE(cfg.has_child("layer"), _("No stack layers defined.")); VALIDATE(cfg.has_child("layer"), _("No stack layers defined."));
for(const auto & layer : cfg.child_range("layer")) for(const auto & layer : cfg.child_range("layer"))
{ {
stack.emplace_back(std::make_shared<builder_grid>(layer)); stack.emplace_back(layer);
} }
} }

View File

@ -123,7 +123,7 @@ private:
* @param widget_builder The builder to build the contents of the * @param widget_builder The builder to build the contents of the
* widget. * widget.
*/ */
void finalize(std::vector<builder_grid_const_ptr> widget_builder); void finalize(const std::vector<builder_grid>& widget_builders);
/** /**
* Contains a pointer to the generator. * Contains a pointer to the generator.
@ -208,7 +208,7 @@ struct builder_stacked_widget : public builder_styled_widget
widget* build() const; widget* build() const;
/** The builders for all layers of the stack .*/ /** The builders for all layers of the stack .*/
std::vector<builder_grid_const_ptr> stack; std::vector<builder_grid> stack;
}; };
} // namespace implementation } // namespace implementation

View File

@ -271,8 +271,8 @@ window* manager::get_window(const unsigned id)
} // namespace } // namespace
window::window(const builder_window::window_resolution* definition) window::window(const builder_window::window_resolution& definition)
: panel(implementation::builder_window(::config {"definition", definition->definition}), type()) : panel(implementation::builder_window(::config {"definition", definition.definition}), type())
, video_(CVideo::get_singleton()) , video_(CVideo::get_singleton())
, status_(NEW) , status_(NEW)
, show_mode_(none) , show_mode_(none)
@ -285,19 +285,19 @@ window::window(const builder_window::window_resolution* definition)
, restore_(true) , restore_(true)
, is_toplevel_(!is_in_dialog()) , is_toplevel_(!is_in_dialog())
, restorer_() , restorer_()
, automatic_placement_(definition->automatic_placement) , automatic_placement_(definition.automatic_placement)
, horizontal_placement_(definition->horizontal_placement) , horizontal_placement_(definition.horizontal_placement)
, vertical_placement_(definition->vertical_placement) , vertical_placement_(definition.vertical_placement)
, maximum_width_(definition->maximum_width) , maximum_width_(definition.maximum_width)
, maximum_height_(definition->maximum_height) , maximum_height_(definition.maximum_height)
, x_(definition->x) , x_(definition.x)
, y_(definition->y) , y_(definition.y)
, w_(definition->width) , w_(definition.width)
, h_(definition->height) , h_(definition.height)
, reevaluate_best_size_(definition->reevaluate_best_size) , reevaluate_best_size_(definition.reevaluate_best_size)
, functions_(definition->functions) , functions_(definition.functions)
, tooltip_(definition->tooltip) , tooltip_(definition.tooltip)
, helptip_(definition->helptip) , helptip_(definition.helptip)
, click_dismiss_(false) , click_dismiss_(false)
, enter_disabled_(false) , enter_disabled_(false)
, escape_disabled_(false) , escape_disabled_(false)

View File

@ -62,13 +62,13 @@ class distributor;
class window : public panel class window : public panel
{ {
friend class debug_layout_graph; friend class debug_layout_graph;
friend window* build(const builder_window::window_resolution*); friend std::unique_ptr<window> build(const builder_window::window_resolution&);
friend struct window_implementation; friend struct window_implementation;
friend class invalidate_layout_blocker; friend class invalidate_layout_blocker;
friend class pane; friend class pane;
public: public:
explicit window(const builder_window::window_resolution* definition); explicit window(const builder_window::window_resolution& definition);
~window(); ~window();

View File

@ -66,8 +66,7 @@ int intf_show_dialog(lua_State* L)
config def_cfg = luaW_checkconfig(L, 1); config def_cfg = luaW_checkconfig(L, 1);
gui2::builder_window::window_resolution def(def_cfg); gui2::builder_window::window_resolution def(def_cfg);
std::unique_ptr<gui2::window> wp; std::unique_ptr<gui2::window> wp(gui2::build(def));
wp.reset(gui2::build(&def));
if(!lua_isnoneornil(L, 2)) { if(!lua_isnoneornil(L, 2)) {
lua_pushvalue(L, 2); lua_pushvalue(L, 2);