diff --git a/data/gui/window/addon_license_prompt.cfg b/data/gui/window/addon_license_prompt.cfg new file mode 100644 index 00000000000..248cea2fcd0 --- /dev/null +++ b/data/gui/window/addon_license_prompt.cfg @@ -0,0 +1,123 @@ +#textdomain wesnoth-lib +### +### Definition of the Add-ons Manager license promnpt dialog +### + +[window] + id = "addon_license_prompt" + description = "Add-ons Manager content license prompt displayed during uploads." + + [resolution] + definition = "default" + + automatic_placement = true + vertical_placement = "center" + horizontal_placement = "center" + + maximum_width = 800 + #maximum_height = 600 + + [tooltip] + id = "tooltip" + [/tooltip] + + [helptip] + id = "tooltip" + [/helptip] + + [grid] + [row] + grow_factor = 0 + [column] + grow_factor = 1 + horizontal_alignment = "left" + border = "all" + border_size = 5 + + [label] + definition = "title" + label = _ "addons_server^Server Rules" + [/label] + [/column] + [/row] + + [row] + grow_factor = 0 + [column] + grow_factor = 1 + horizontal_alignment = "left" + border = "all" + border_size = 5 + + [label] + id = "message" + label = "Before uploading content to this server, you must accept the following distribution terms by choosing “I Agree”." + wrap = true + [/label] + [/column] + [/row] + + [row] + grow_factor = 0 + [column] + horizontal_grow = true + border = "all" + border_size = 5 + + [panel] + definition = "box_display_no_blur_no_border" + [grid] + [row] + [column] + horizontal_grow = true + border = "all" + border_size = 5 + + [scroll_label] + id = "terms" + definition = "description" + label = "server terms placeholder" + [/scroll_label] + [/column] + [/row] + [/grid] + [/panel] + [/column] + [/row] + + [row] + grow_factor = 0 + [column] + horizontal_alignment = "right" + + [grid] + [row] + grow_factor = 0 + [column] + horizontal_alignment = "right" + border = "all" + border_size = 5 + + [button] + id = "ok" + label = _ "I Agree" + [/button] + [/column] + + [column] + horizontal_alignment = "right" + border = "all" + border_size = 5 + + [button] + id = "cancel" + label = _ "Cancel" + [/button] + [/column] + [/row] + [/grid] + [/column] + [/row] + [/grid] + [/resolution] +[/window] diff --git a/projectfiles/VC16/wesnoth.vcxproj b/projectfiles/VC16/wesnoth.vcxproj index eb18cae30d2..0f9fa38d747 100644 --- a/projectfiles/VC16/wesnoth.vcxproj +++ b/projectfiles/VC16/wesnoth.vcxproj @@ -1478,6 +1478,13 @@ $(IntDir)Gui\Dialogs\Addon\ $(IntDir)Gui\Dialogs\Addon\ + + $(IntDir)Gui\Dialogs\Addon\ + $(IntDir)Gui\Dialogs\Addon\ + $(IntDir)Gui\Dialogs\Addon\ + $(IntDir)Gui\Dialogs\Addon\ + $(IntDir)Gui\Dialogs\Addon\ + $(IntDir)Gui\Dialogs\Addon\ $(IntDir)Gui\Dialogs\Addon\ @@ -3803,6 +3810,7 @@ + diff --git a/projectfiles/VC16/wesnoth.vcxproj.filters b/projectfiles/VC16/wesnoth.vcxproj.filters index ec22d05b25d..1ea7e07a1ef 100644 --- a/projectfiles/VC16/wesnoth.vcxproj.filters +++ b/projectfiles/VC16/wesnoth.vcxproj.filters @@ -704,6 +704,9 @@ Gui\Dialogs\Addon + + Gui\Dialogs\Addon + Gui\Dialogs\Addon @@ -2150,6 +2153,9 @@ Gui\Dialogs\Addon + + Gui\Dialogs\Addon + Gui\Dialogs\Addon diff --git a/source_lists/wesnoth b/source_lists/wesnoth index 60669539a94..e4c0ba5688f 100644 --- a/source_lists/wesnoth +++ b/source_lists/wesnoth @@ -164,6 +164,7 @@ gui/core/window_builder/helper.cpp gui/core/window_builder/instance.cpp gui/dialogs/addon/connect.cpp gui/dialogs/addon/install_dependencies.cpp +gui/dialogs/addon/license_prompt.cpp gui/dialogs/addon/manager.cpp gui/dialogs/addon/uninstall_list.cpp gui/dialogs/attack_predictions.cpp diff --git a/src/gui/dialogs/addon/license_prompt.cpp b/src/gui/dialogs/addon/license_prompt.cpp new file mode 100644 index 00000000000..1828a38ef8f --- /dev/null +++ b/src/gui/dialogs/addon/license_prompt.cpp @@ -0,0 +1,42 @@ +/* + Copyright (C) 2020 by Iris Morelle + Part of the Battle for Wesnoth Project https://www.wesnoth.org/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY. + + See the COPYING file for more details. +*/ + +#define GETTEXT_DOMAIN "wesnoth-lib" + +#include "gui/dialogs/addon/license_prompt.hpp" + +#include "gettext.hpp" +#include "gui/auxiliary/find_widget.hpp" +#include "gui/widgets/button.hpp" +#include "gui/widgets/settings.hpp" +#include "gui/widgets/window.hpp" + +namespace gui2 { +namespace dialogs { + +REGISTER_DIALOG(addon_license_prompt) + +addon_license_prompt::addon_license_prompt(const std::string& license_terms) + : license_terms_(license_terms) +{ +} + +void addon_license_prompt::pre_show(window& window) +{ + styled_widget& terms = find_widget(&window, "terms", false); + terms.set_use_markup(true); + terms.set_label(license_terms_); +} + +}} // end namespace gui2::dialogs diff --git a/src/gui/dialogs/addon/license_prompt.hpp b/src/gui/dialogs/addon/license_prompt.hpp new file mode 100644 index 00000000000..842392950d6 --- /dev/null +++ b/src/gui/dialogs/addon/license_prompt.hpp @@ -0,0 +1,45 @@ +/* + Copyright (C) 2020 by Iris Morelle + Part of the Battle for Wesnoth Project https://www.wesnoth.org/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY. + + See the COPYING file for more details. +*/ + +#pragma once + +#include "gui/dialogs/modal_dialog.hpp" + +namespace gui2 { +namespace dialogs { + +class addon_license_prompt : public modal_dialog +{ +public: + /** Constructor. */ + explicit addon_license_prompt(const std::string& license_terms); + + /** + * The execute function. + * + * See @ref modal_dialog for more information. + */ + DEFINE_SIMPLE_EXECUTE_WRAPPER(addon_license_prompt) + +private: + /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */ + virtual const std::string& window_id() const override; + + /** Inherited from modal_dialog. */ + virtual void pre_show(window& window) override; + + std::string license_terms_; +}; + +}} // end namespace gui2::dialogs diff --git a/src/gui/dialogs/addon/manager.cpp b/src/gui/dialogs/addon/manager.cpp index 173539039b6..2a13d387120 100644 --- a/src/gui/dialogs/addon/manager.cpp +++ b/src/gui/dialogs/addon/manager.cpp @@ -27,6 +27,7 @@ #include "gettext.hpp" #include "gui/auxiliary/filter.hpp" #include "gui/auxiliary/find_widget.hpp" +#include "gui/dialogs/addon/license_prompt.hpp" #include "gui/dialogs/message.hpp" #include "gui/dialogs/transient_message.hpp" #include "gui/widgets/button.hpp" @@ -796,7 +797,7 @@ void addon_manager::publish_addon(const addon_info& addon) } else if(!client_.request_distribution_terms(server_msg)) { gui2::show_error_message( _("The server responded with an error:") + "\n" + client_.get_last_server_error()); - } else if(gui2::show_message(_("Terms"), server_msg, gui2::dialogs::message::ok_cancel_buttons, true) == gui2::retval::OK) { + } else if(gui2::dialogs::addon_license_prompt::execute(server_msg)) { if(!client_.upload_addon(addon_id, server_msg, cfg, tracking_info_[addon_id].state == ADDON_INSTALLED_LOCAL_ONLY)) { const std::string& msg = _("The add-on was rejected by the server:") + "\n\n" + client_.get_last_server_error();