Replace the 'Install Dependencies' dialog with a GUI2 version
This commit is contained in:
parent
575326c74d
commit
678a21b4fe
7 changed files with 224 additions and 51 deletions
105
data/gui/window/install_dependencies.cfg
Normal file
105
data/gui/window/install_dependencies.cfg
Normal file
|
@ -0,0 +1,105 @@
|
|||
#textdomain wesnoth
|
||||
###
|
||||
### Window shown when the player installs an add-on that has dependencies.
|
||||
### Asks the player whether or not the dependencies should be installed.
|
||||
###
|
||||
|
||||
[window]
|
||||
id = "install_dependencies"
|
||||
description = "Install dependencies prompt."
|
||||
|
||||
[resolution]
|
||||
definition = "default"
|
||||
|
||||
automatic_placement = "true"
|
||||
horizontal_placement = "center"
|
||||
vertical_placement = "center"
|
||||
|
||||
[tooltip]
|
||||
id = "tooltip"
|
||||
[/tooltip]
|
||||
|
||||
[helptip]
|
||||
id = "helptip"
|
||||
[/helptip]
|
||||
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
id = "title"
|
||||
definition = "title"
|
||||
|
||||
label = _ "Install Dependencies"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
[label]
|
||||
id = "label"
|
||||
definition = "default"
|
||||
|
||||
wrap = "true"
|
||||
characters_per_line = 70
|
||||
|
||||
# This isn't localizable because the final text is set from C++ code (in order to support singular and plural forms properly)
|
||||
label = "The selected add-on has the following dependencies, which are not currently installed. Do you wish to install them before continuing?"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
grow_factor = 1
|
||||
[column]
|
||||
[addon_list]
|
||||
id = "dependencies"
|
||||
definition = "default"
|
||||
install_status_visibility = "invisible"
|
||||
install_buttons_visibility = "invisible"
|
||||
[/addon_list]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
grow_factor = 1
|
||||
[spacer]
|
||||
[/spacer]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "ok"
|
||||
definition = "default"
|
||||
|
||||
label = _ "Yes"
|
||||
[/button]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "cancel"
|
||||
definition = "default"
|
||||
|
||||
label = _ "No"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/resolution]
|
||||
[/window]
|
|
@ -1684,6 +1684,14 @@
|
|||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Debug|Win32'">$(IntDir)Gui\Dialogs\Addon\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Release|Win32'">$(IntDir)Gui\Dialogs\Addon\</ObjectFileName>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\gui\dialogs\addon\install_dependencies.cpp">
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)Gui\Dialogs\Addon\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)Gui\Dialogs\Addon\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='ReleaseDEBUG|Win32'">$(IntDir)Gui\Dialogs\Addon\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Debug|Win32'">$(IntDir)Gui\Dialogs\Addon\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug_with_VLD|Win32'">$(IntDir)Gui\Dialogs\Addon\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Test_Release|Win32'">$(IntDir)Gui\Dialogs\Addon\</ObjectFileName>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\gui\dialogs\addon\manager.cpp">
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug_with_VLD|Win32'">$(IntDir)Gui\Dialogs\Addon\</ObjectFileName>
|
||||
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)Gui\Dialogs\Addon\</ObjectFileName>
|
||||
|
@ -4137,6 +4145,7 @@
|
|||
<ClInclude Include="..\..\src\gui\dialogs\addon\connect.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\dialogs\addon\description.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\dialogs\addon\filter_options.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\dialogs\addon\install_dependencies.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\dialogs\addon\manager.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\dialogs\addon\uninstall_list.hpp" />
|
||||
<ClInclude Include="..\..\src\gui\dialogs\advanced_graphics_options.hpp" />
|
||||
|
|
|
@ -1525,6 +1525,9 @@
|
|||
<ClCompile Include="..\..\src\gui\core\linked_group_definition.cpp">
|
||||
<Filter>Gui\Core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\gui\dialogs\addon\install_dependencies.cpp">
|
||||
<Filter>Gui\Dialogs\Addon</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\addon\client.hpp">
|
||||
|
@ -2961,6 +2964,9 @@
|
|||
<ClInclude Include="..\..\src\gui\core\linked_group_definition.hpp">
|
||||
<Filter>Gui\Core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\gui\dialogs\addon\install_dependencies.hpp">
|
||||
<Filter>Gui\Dialogs\Addon</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\..\src\tests\test_sdl_utils.hpp">
|
||||
|
|
|
@ -165,6 +165,7 @@ gui/core/window_builder/instance.cpp
|
|||
gui/dialogs/addon/connect.cpp
|
||||
gui/dialogs/addon/description.cpp
|
||||
gui/dialogs/addon/filter_options.cpp
|
||||
gui/dialogs/addon/install_dependencies.cpp
|
||||
gui/dialogs/addon/manager.cpp
|
||||
gui/dialogs/addon/uninstall_list.cpp
|
||||
gui/dialogs/advanced_graphics_options.cpp
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "gui/dialogs/addon/manager.hpp"
|
||||
#include "gui/dialogs/addon/description.hpp"
|
||||
#include "gui/dialogs/addon/filter_options.hpp"
|
||||
#include "gui/dialogs/addon/install_dependencies.hpp"
|
||||
#include "gui/dialogs/addon/uninstall_list.hpp"
|
||||
#include "gui/dialogs/addon/connect.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
|
@ -201,58 +202,16 @@ addon_op_result do_resolve_addon_dependencies(CVideo& v, addons_client& client,
|
|||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare UI report on available dependencies.
|
||||
//
|
||||
{
|
||||
addons_list options;
|
||||
for(const std::string& dep : missing_deps) {
|
||||
const addon_info& missing_addon = addon_at(dep, addons);
|
||||
options[dep] = missing_addon;
|
||||
}
|
||||
|
||||
const std::string sep(1, COLUMN_SEPARATOR);
|
||||
const std::string header = formatter() << HEADING_PREFIX << sep <<
|
||||
_("Name") << sep << _("Version") << sep << _("Author") << sep <<
|
||||
_("Size") << sep << _("Type");
|
||||
|
||||
std::vector<std::string> options(1, header);
|
||||
std::vector<int> sort_sizes;
|
||||
|
||||
cursor_setter.reset(new cursor::setter(cursor::WAIT));
|
||||
|
||||
for(const std::string& dep : missing_deps) {
|
||||
const addon_info& missing_addon = addon_at(dep, addons);
|
||||
|
||||
const std::string& display_size = size_display_string(missing_addon.size);
|
||||
const std::string& display_type = missing_addon.display_type();
|
||||
const std::string& display_icon = missing_addon.display_icon();
|
||||
const std::string& display_version = missing_addon.version.str();
|
||||
|
||||
const std::string& display_title = font::word_wrap_text(missing_addon.display_title(), font::SIZE_NORMAL, 150, -1, 2);
|
||||
std::string display_author = missing_addon.author;
|
||||
utils::ellipsis_truncate(display_author, 14);
|
||||
|
||||
// Add negative sizes to reverse the sort order.
|
||||
sort_sizes.push_back(-missing_addon.size);
|
||||
|
||||
// NOTE: NULL_MARKUP used to escape abuse of formatting chars in add-on titles
|
||||
options.push_back(IMAGE_PREFIX + display_icon + sep +
|
||||
font::NULL_MARKUP + display_title + sep + display_version + sep +
|
||||
display_author + sep + display_size + sep +
|
||||
display_type);
|
||||
}
|
||||
|
||||
/* do */ {
|
||||
gui::dialog dlg(v, _("Install Dependencies"),
|
||||
_n("The selected add-on has the following dependency, which is not currently installed. Do you wish to install it before continuing?",
|
||||
"The selected add-on has the following dependencies, which are not currently installed. Do you wish to install them before continuing?",
|
||||
missing_deps.size()),
|
||||
gui::YES_NO);
|
||||
gui::menu::imgsel_style addon_style(gui::menu::bluebg_style);
|
||||
addon_style.scale_images(font::relative_size(72), font::relative_size(72));
|
||||
gui::menu* addon_menu = new gui::menu(
|
||||
v, options, false, -1,
|
||||
gui::dialog::max_menu_width, nullptr, &addon_style, false);
|
||||
dlg.set_menu(addon_menu);
|
||||
|
||||
cursor_setter.reset();
|
||||
|
||||
if(dlg.show() < 0) {
|
||||
gui2::dialogs::install_dependencies dlg(options);
|
||||
bool cont = dlg.show(v);
|
||||
if(!cont) {
|
||||
return result; // the user has chosen to continue without installing anything.
|
||||
}
|
||||
}
|
||||
|
|
46
src/gui/dialogs/addon/install_dependencies.cpp
Normal file
46
src/gui/dialogs/addon/install_dependencies.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
Copyright (C) 2017 by Jyrki Vesterinen <sandgtx@gmail.com>
|
||||
Part of the Battle for Wesnoth Project http://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.
|
||||
*/
|
||||
|
||||
#include "install_dependencies.hpp"
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth"
|
||||
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/addon_list.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "tstring.hpp"
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
namespace dialogs
|
||||
{
|
||||
|
||||
REGISTER_DIALOG(install_dependencies)
|
||||
|
||||
void install_dependencies::pre_show(window& window)
|
||||
{
|
||||
label& lbl = find_widget<label>(&window, "label", false);
|
||||
lbl.set_label(t_string("The selected add-on has the following dependency, which is not currently installed. Do you wish to install it before continuing?",
|
||||
"The selected add-on has the following dependencies, which are not currently installed. Do you wish to install them before continuing?",
|
||||
addons_.size(),
|
||||
"wesnoth"));
|
||||
|
||||
addon_list& list = find_widget<addon_list>(&window, "dependencies", false);
|
||||
list.set_addons(addons_);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
47
src/gui/dialogs/addon/install_dependencies.hpp
Normal file
47
src/gui/dialogs/addon/install_dependencies.hpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Copyright (C) 2017 by Jyrki Vesterinen <sandgtx@gmail.com>
|
||||
Part of the Battle for Wesnoth Project http://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.
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOGS_ADDON_INSTALL_DEPENDENCIES_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_ADDON_INSTALL_DEPENDENCIES_HPP_INCLUDED
|
||||
|
||||
#include "addon/info.hpp"
|
||||
#include "gui/dialogs/modal_dialog.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
namespace dialogs
|
||||
{
|
||||
|
||||
class install_dependencies : public modal_dialog
|
||||
{
|
||||
public:
|
||||
install_dependencies(const addons_list& addons)
|
||||
: addons_(addons)
|
||||
{}
|
||||
|
||||
private:
|
||||
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
|
||||
/** Inherited from modal_dialog. */
|
||||
void pre_show(window& window);
|
||||
|
||||
addons_list addons_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue