Added experimental new addon download dialog.

This dialog is only available when started with --new-widgets and shouldn't
add new strings. The dialog is added to ease the testing the listbox
alignment feature that still needs to be added before 1.6. This dialog won't
be finished before 1.6.
This commit is contained in:
Mark de Wever 2009-02-22 08:17:46 +00:00
parent 3fe213fd8c
commit cce9f9da1d
8 changed files with 482 additions and 17 deletions

View file

@ -32,6 +32,8 @@ Version 1.5.10+svn:
reachmap
* When moving up or down in a listbox with a horizontal scrollbar, the
listbox no longer changes the position of the horizontal scrollbar
* Added experimental new addon download dialog (Only available when
starting with --new-widgets.)
* WML Engine:
* Fixed bug #13024: Conditional [allow_undo] not always working right

View file

@ -0,0 +1,319 @@
#textdomain wesnoth-lib
###
### Definition of the window to select an addon for installation.
###
[window]
id = "addon_list"
description = "Addon selection dialog."
[resolution]
definition = "default"
automatic_placement = "true"
vertical_placement = "center"
horizontal_placement = "center"
[grid]
[row]
grow_factor = 0
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "title"
label = "Get Add-ons"
[/label]
[/column]
[/row]
[row]
grow_factor = 0
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "default"
label = "Choose the add-on to download."
[/label]
[/column]
[/row]
[row]
grow_factor = 1
[column]
grow_factor = 1
horizontal_grow = "true"
vertical_grow = "true"
[listbox]
id = "addon_list"
definition = "default"
assume_fixed_row_size = "true"
[header]
[row]
[column]
grow_factor = 1
horizontal_grow = "true"
[label]
definition = "default"
label = "Name"
[/label]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
[label]
definition = "default"
label = "Version"
[/label]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
[label]
definition = "default"
label = "Author"
[/label]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
[label]
definition = "default"
label = "Downloads"
[/label]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
[label]
definition = "default"
label = "Size"
[/label]
[/column]
[/row]
[/header]
[list_definition]
[row]
[column]
vertical_grow = "true"
horizontal_grow = "true"
[toggle_panel]
definition = "default"
return_value = -1
[grid]
[row]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
# horizontal_alignment = "left"
[label]
id = "name"
definition = "default"
[/label]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
# horizontal_alignment = "left"
[label]
id = "version"
definition = "default"
[/label]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
# horizontal_alignment = "left"
[label]
id = "author"
definition = "default"
[/label]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
# horizontal_alignment = "left"
[label]
id = "downloads"
definition = "default"
[/label]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
# horizontal_alignment = "left"
[label]
id = "size"
definition = "default"
[/label]
[/column]
[/row]
[/grid]
[/toggle_panel]
[/column]
[/row]
[/list_definition]
[/listbox]
[/column]
[/row]
[row]
grow_factor = 0
[column]
grow_factor = 1
horizontal_grow = "true"
[grid]
[row]
grow_factor = 0
[column]
[spacer]
definition = "default"
[/spacer]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "ok"
definition = "default"
label = "Install" # fixme text might change between install and update...
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "cancel"
definition = "default"
label = "Cancel"
[/button]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/grid]
[/resolution]
[/window]

View file

@ -70,6 +70,7 @@ wesnoth_source = \
generate_report.cpp \
generic_event.cpp \
gui/dialogs/addon_connect.cpp \
gui/dialogs/addon_list.cpp \
gui/dialogs/dialog.cpp \
gui/dialogs/language_selection.cpp \
gui/dialogs/message.cpp \

View file

@ -24,6 +24,7 @@
#include "game_preferences.hpp"
#include "gettext.hpp"
#include "gui/dialogs/addon_connect.hpp"
#include "gui/dialogs/addon_list.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/widgets/window.hpp"
#include "marked-up_text.hpp"
@ -1019,27 +1020,34 @@ namespace {
return;
}
gui::menu::basic_sorter sorter;
sorter.set_alpha_sort(1).set_alpha_sort(2).set_alpha_sort(3).set_alpha_sort(4).set_numeric_sort(5).set_position_sort(6,sizes);
int index = -1;
if(gui2::new_widgets) {
gui2::taddon_list dlg(*addons_tree);
dlg.show(disp.video());
} else {
gui::dialog addon_dialog(disp, _("Get add-ons"),
_("Choose the add-on to download."),
gui::OK_CANCEL);
gui::menu::imgsel_style addon_style(gui::menu::bluebg_style);
gui::menu::basic_sorter sorter;
sorter.set_alpha_sort(1).set_alpha_sort(2).set_alpha_sort(3).set_alpha_sort(4).set_numeric_sort(5).set_position_sort(6,sizes);
//make sure the icon isn't too big
addon_style.scale_images(font::relative_size(72), font::relative_size(72));
gui::menu *addon_menu = new gui::menu(disp.video(), options, false, -1,
gui::dialog::max_menu_width, &sorter,
&addon_style, false);
addon_dialog.set_menu(addon_menu);
gui::dialog addon_dialog(disp, _("Get add-ons"),
_("Choose the add-on to download."),
gui::OK_CANCEL);
gui::menu::imgsel_style addon_style(gui::menu::bluebg_style);
gui::filter_textbox* filter = new gui::filter_textbox(disp.video(),
_("Filter: "), options, options_to_filter, 1, addon_dialog, 300);
addon_dialog.set_textbox(filter);
//make sure the icon isn't too big
addon_style.scale_images(font::relative_size(72), font::relative_size(72));
gui::menu *addon_menu = new gui::menu(disp.video(), options, false, -1,
gui::dialog::max_menu_width, &sorter,
&addon_style, false);
addon_dialog.set_menu(addon_menu);
int index = addon_dialog.show();
index = filter->get_index(index);
gui::filter_textbox* filter = new gui::filter_textbox(disp.video(),
_("Filter: "), options, options_to_filter, 1, addon_dialog, 300);
addon_dialog.set_textbox(filter);
index = addon_dialog.show();
index = filter->get_index(index);
}
if(index < 0) {
return;

View file

@ -0,0 +1,87 @@
/* $Id$ */
/*
Copyright (C) 2008 - 2009 by Mark de Wever <koraq@xs4all.nl>
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 version 2
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_list.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/listbox.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/text_box.hpp"
#include "gui/widgets/widget.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/window_builder.hpp"
#include "log.hpp"
#include "serialization/string_utils.hpp"
#include "wml_exception.hpp"
namespace gui2 {
/*WIKI
* @page = GUIWindowWML
* @order = 2_addon_list
*
* == Addon list ==
*
*/
twindow* taddon_list::build_window(CVideo& video)
{
return build(video, get_id(ADDON_LIST));
}
void taddon_list::pre_show(CVideo& /*video*/, twindow& window)
{
tlistbox* list =
dynamic_cast<tlistbox*>(window.find_widget("addon_list", false));
VALIDATE(list, missing_widget("addon_list"));
const config::child_list& cmps = cfg_.get_children("campaign");
for(config::child_list::const_iterator itor = cmps.begin();
itor != cmps.end(); ++itor) {
std::map<std::string, std::map<std::string, t_string> > data;
std::map<std::string, t_string> item;
std::string tmp = (**itor)["name"];
utils::truncate_as_wstring(tmp, 20);
item["label"] = tmp;
data.insert(std::make_pair("name", item));
tmp = (**itor)["version"];
utils::truncate_as_wstring(tmp, 12);
item["label"] = tmp;
data.insert(std::make_pair("version", item));
tmp = (**itor)["author"];
utils::truncate_as_wstring(tmp, 16);
item["label"] = tmp;
data.insert(std::make_pair("author", item));
item["label"] = (**itor)["downloads"];
data.insert(std::make_pair("downloads", item));
item["label"] = (**itor)["size"];
data.insert(std::make_pair("size", item));
list->add_row(data);
}
}
} // namespace gui2

View file

@ -0,0 +1,46 @@
/* $Id$ */
/*
Copyright (C) 2008 - 2009 by Mark de Wever <koraq@xs4all.nl>
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 version 2
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_LIST_HPP_INCLUDED
#define GUI_DIALOGS_ADDON_LIST_HPP_INCLUDED
#include "gui/dialogs/dialog.hpp"
class config;
namespace gui2 {
class taddon_list
: public tdialog
{
public:
taddon_list(const config& cfg)
: cfg_(cfg)
{}
private:
/** Inherited from tdialog. */
twindow* build_window(CVideo& video);
/** Inherited from tdialog. */
void pre_show(CVideo& video, twindow& window);
/** Config which contains the list with the campaigns. */
const config& cfg_;
};
} // namespace gui2
#endif

View file

@ -70,6 +70,7 @@ namespace {
static void fill_window_types()
{
window_type_list[ADDON_CONNECT] = "addon_connect";
window_type_list[ADDON_LIST] = "addon_list";
window_type_list[LANGUAGE_SELECTION] = "language_selection";
window_type_list[WML_MESSAGE_LEFT] = "wml_message_left";
window_type_list[WML_MESSAGE_RIGHT] = "wml_message_right";

View file

@ -38,6 +38,7 @@ extern bool new_widgets;
enum twindow_type {
TITLE_SCREEN, /**< The main title screen of the game. */
ADDON_CONNECT, /**< The addon server connection dialog. */
ADDON_LIST, /**< The addon list dialog. */
LANGUAGE_SELECTION, /**< The language selection dialog. */
MESSAGE, /**< A generic message dialog. */
WML_MESSAGE_LEFT, /**<