Add the initial version of the new campaign dialog.
This version only has the list with campaigns. The cfg is in the wesnoth text domain instead of wesnoth-lib to avoid a new string.
This commit is contained in:
parent
4f07f028ae
commit
576eba454d
10 changed files with 311 additions and 1 deletions
165
data/gui/default/window/campaign_dialog.cfg
Normal file
165
data/gui/default/window/campaign_dialog.cfg
Normal file
|
@ -0,0 +1,165 @@
|
|||
#textdomain wesnoth
|
||||
# FIXME should be in wesnoth-lib, but don't want to break the stringfreeze.
|
||||
###
|
||||
### Definition of the window select the campaign to play
|
||||
###
|
||||
|
||||
[window]
|
||||
id = "campaign_selection"
|
||||
description = "Campaign 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 = _ "Play a campaign"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
vertical_grow = "true"
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[listbox]
|
||||
id = "campaign_list"
|
||||
definition = "default"
|
||||
|
||||
vertical_scrollbar_mode = "auto"
|
||||
horizontal_scrollbar_mode = "never"
|
||||
|
||||
[list_definition]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_button]
|
||||
definition = "listbox_text_with_icon"
|
||||
|
||||
return_value_id = "ok"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
|
||||
[/row]
|
||||
|
||||
[/list_definition]
|
||||
|
||||
[/listbox]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
# FIXME show the addon pane.
|
||||
[spacer]
|
||||
[/spacer]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "ok"
|
||||
definition = "default"
|
||||
|
||||
label = _ "OK"
|
||||
[/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]
|
|
@ -6,6 +6,7 @@ src/game_preferences.cpp
|
|||
src/game_preferences_display.cpp
|
||||
src/gui/dialogs/addon_connect.cpp
|
||||
src/gui/dialogs/addon_list.cpp
|
||||
src/gui/dialogs/campaign_selection.cpp
|
||||
src/gui/dialogs/dialog.cpp
|
||||
src/gui/dialogs/language_selection.cpp
|
||||
src/gui/dialogs/message.cpp
|
||||
|
|
|
@ -227,6 +227,7 @@ SET(wesnoth-main_SRC
|
|||
generic_event.cpp
|
||||
gui/dialogs/addon_connect.cpp
|
||||
gui/dialogs/addon_list.cpp
|
||||
gui/dialogs/campaign_selection.cpp
|
||||
gui/dialogs/dialog.cpp
|
||||
gui/dialogs/language_selection.cpp
|
||||
gui/dialogs/message.cpp
|
||||
|
|
|
@ -70,6 +70,7 @@ wesnoth_source = \
|
|||
generic_event.cpp \
|
||||
gui/dialogs/addon_connect.cpp \
|
||||
gui/dialogs/addon_list.cpp \
|
||||
gui/dialogs/campaign_selection.cpp \
|
||||
gui/dialogs/dialog.cpp \
|
||||
gui/dialogs/language_selection.cpp \
|
||||
gui/dialogs/message.cpp \
|
||||
|
|
|
@ -214,6 +214,7 @@ wesnoth_sources = Split("""
|
|||
widgets/scrollpane.cpp
|
||||
gui/dialogs/addon_connect.cpp
|
||||
gui/dialogs/addon_list.cpp
|
||||
gui/dialogs/campaign_selection.cpp
|
||||
gui/dialogs/dialog.cpp
|
||||
gui/dialogs/language_selection.cpp
|
||||
gui/dialogs/message.cpp
|
||||
|
|
20
src/game.cpp
20
src/game.cpp
|
@ -33,6 +33,7 @@
|
|||
#include "gamestatus.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "gui/dialogs/addon_connect.hpp"
|
||||
#include "gui/dialogs/campaign_selection.hpp"
|
||||
#include "gui/dialogs/language_selection.hpp"
|
||||
#include "gui/dialogs/mp_method_selection.hpp"
|
||||
#include "gui/dialogs/title_screen.hpp"
|
||||
|
@ -1046,6 +1047,23 @@ bool game_controller::new_campaign()
|
|||
config::child_list campaigns = game_config_.get_children("campaign");
|
||||
std::sort(campaigns.begin(),campaigns.end(),less_campaigns_rank);
|
||||
|
||||
if(campaigns.begin() == campaigns.end()) {
|
||||
gui::show_error_message(disp(),
|
||||
_("No campaigns are available.\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
gui2::tcampaign_selection dlg(campaigns.begin(),campaigns.end());
|
||||
|
||||
dlg.show(disp().video());
|
||||
|
||||
if(dlg.get_retval() != gui2::twindow::OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const config& campaign = *campaigns[dlg.get_choice()];
|
||||
|
||||
#if 0
|
||||
std::vector<std::string> campaign_names;
|
||||
std::vector<std::pair<std::string,std::string> > campaign_desc;
|
||||
|
||||
|
@ -1097,7 +1115,7 @@ bool game_controller::new_campaign()
|
|||
}
|
||||
|
||||
const config& campaign = *campaigns[cmenu.result()];
|
||||
|
||||
#endif
|
||||
state_.campaign = campaign["id"];
|
||||
state_.abbrev = campaign["abbrev"];
|
||||
state_.scenario = campaign["first_scenario"];
|
||||
|
|
56
src/gui/dialogs/campaign_selection.cpp
Normal file
56
src/gui/dialogs/campaign_selection.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 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/campaign_selection.hpp"
|
||||
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
twindow* tcampaign_selection::build_window(CVideo& video)
|
||||
{
|
||||
return build(video, get_id(CAMPAIGN_SELECTION));
|
||||
}
|
||||
|
||||
void tcampaign_selection::pre_show(CVideo& /*video*/, twindow& window)
|
||||
{
|
||||
tlistbox* list = dynamic_cast<tlistbox*>(
|
||||
window.find_widget("campaign_list", false));
|
||||
VALIDATE(list, missing_widget("campaign_list"));
|
||||
|
||||
for(config::child_list::const_iterator itor = begin_;
|
||||
itor != end_; ++itor) {
|
||||
|
||||
string_map item;
|
||||
item.insert(std::make_pair("icon", (**itor)["icon"]));
|
||||
item.insert(std::make_pair("label", (**itor)["name"]));
|
||||
list->add_row(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void tcampaign_selection::post_show(twindow& window)
|
||||
{
|
||||
tlistbox* list = dynamic_cast<tlistbox*>(
|
||||
window.find_widget("campaign_list", false));
|
||||
assert(list);
|
||||
|
||||
choice_ = list->get_selected_row();
|
||||
}
|
||||
|
||||
} // namespace gui2
|
65
src/gui/dialogs/campaign_selection.hpp
Normal file
65
src/gui/dialogs/campaign_selection.hpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 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_CAMPAIGN_SELECTION_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_CAMPAIGN_SELECTION_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
class tcampaign_selection
|
||||
: public tdialog
|
||||
{
|
||||
public:
|
||||
tcampaign_selection(
|
||||
const config::child_list::const_iterator& begin,
|
||||
const config::child_list::const_iterator& end)
|
||||
: begin_(begin)
|
||||
, end_(end)
|
||||
, choice_(-1)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
int get_choice() const { return choice_; }
|
||||
|
||||
private:
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
twindow* build_window(CVideo& video);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void post_show(twindow& window);
|
||||
|
||||
/** Config which contains the list with the campaigns. */
|
||||
|
||||
/** Iterator to the start of the campaign list. */
|
||||
const config::child_list::const_iterator& begin_;
|
||||
|
||||
/** Iterator to the end of the campaign list. */
|
||||
const config::child_list::const_iterator& end_;
|
||||
|
||||
/** The choosen campaign. */
|
||||
int choice_;
|
||||
};
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
|
@ -71,6 +71,7 @@ static void fill_window_types()
|
|||
{
|
||||
window_type_list[ADDON_CONNECT] = "addon_connect";
|
||||
window_type_list[ADDON_LIST] = "addon_list";
|
||||
window_type_list[CAMPAIGN_SELECTION] = "campaign_selection";
|
||||
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";
|
||||
|
|
|
@ -39,6 +39,7 @@ 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. */
|
||||
CAMPAIGN_SELECTION, /**< The campaign selection dialog. */
|
||||
LANGUAGE_SELECTION, /**< The language selection dialog. */
|
||||
MESSAGE, /**< A generic message dialog. */
|
||||
WML_MESSAGE_LEFT, /**<
|
||||
|
|
Loading…
Add table
Reference in a new issue