GUI2: removed unused Campaign Settings dialog

This was a dialog used early in 1.13 during the SP/MP codepath unification to configure certain options.
The modification selection is now built into the Selection dialog, and we decided not to enable other options
like Era selection in SP. The only option we might look to restoring in the future is the "show_connect"
option, but that requires some additional code elsewhere and probably won't be used anyway.
This commit is contained in:
Charles Dang 2017-04-30 21:15:39 +11:00
parent 804c7d6045
commit b0f91e7d2e
8 changed files with 0 additions and 623 deletions

View file

@ -1,333 +0,0 @@
#textdomain wesnoth-lib
[window]
id = "campaign_settings"
description = "Singleplayer advanced settings dialog."
[resolution]
definition = "default"
maximum_width = 800
automatic_placement = true
vertical_placement = "center"
horizontal_placement = "center"
[linked_group]
id = "era"
fixed_width = true
[/linked_group]
[linked_group]
id = "mod"
fixed_width = true
[/linked_group]
[tooltip]
id = "tooltip"
[/tooltip]
[helptip]
id = "tooltip"
[/helptip]
[grid]
[row]
grow_factor = 0
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "title"
label = _ "Advanced Settings"
[/label]
[/column]
[column]
horizontal_grow = true
vertical_grow = true
[spacer]
[/spacer]
[/column]
[/row]
[row]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "default"
label = _ "Additional dialogs:"
[/label]
[/column]
[column]
[spacer]
[/spacer]
[/column]
[/row]
[row]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[spacer]
[/spacer]
[/column]
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[toggle_button]
definition = "default"
id = "mp_connect"
label = _ "Configure sides"
[/toggle_button]
[/column]
[/row]
[row]
[column]
[spacer]
height = 5
[/spacer]
[/column]
[column]
[spacer]
height = 5
[/spacer]
[/column]
[/row]
[row]
[column]
horizontal_grow = true
vertical_grow = true
[grid]
[row]
grow_factor = 0
[column]
border = "all"
border_size = 5
horizontal_grow = true
[label]
definition = "default"
id = "era_label"
label = _ "Era:"
[/label]
[/column]
[/row]
[row]
grow_factor = 1
[column]
border = "all"
border_size = 5
horizontal_grow = true
vertical_grow = true
[listbox]
id = "era_list"
definition = "default"
[list_definition]
[row]
[column]
horizontal_grow = true
vertical_grow = true
[toggle_panel]
definition = "default"
[grid]
[row]
[column]
horizontal_grow = true
vertical_grow = true
border = "all"
border_size = 5
[label]
id = "era"
linked_group = "era"
definition = "default"
[/label]
[/column]
[/row]
[/grid]
[/toggle_panel]
[/column]
[/row]
[/list_definition]
[/listbox]
[/column]
[/row]
[/grid]
[/column]
[column]
horizontal_grow = true
vertical_grow = true
[grid]
[row]
[column]
border = "all"
border_size = 5
horizontal_grow = true
[label]
definition = "default"
id = "mod_label"
label = _ "Modifications:"
[/label]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_grow = true
vertical_grow = true
[listbox]
id = "modification_list"
definition = "default"
has_minimum = false
has_maximum = false
[list_definition]
[row]
[column]
horizontal_grow = true
vertical_grow = true
border = "all"
border_size = 5
[toggle_button]
id = "mod"
linked_group = "mod"
definition = "default"
[/toggle_button]
[/column]
[/row]
[/list_definition]
[/listbox]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
grow_factor = 0
[column]
[spacer]
[/spacer]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "ok"
definition = "default"
label = _ "OK"
[/button]
[/column]
[/row]
[/grid]
[/resolution]
[/window]

View file

@ -532,8 +532,6 @@
<Unit filename="../../src/gui/dialogs/campaign_difficulty.hpp" />
<Unit filename="../../src/gui/dialogs/campaign_selection.cpp" />
<Unit filename="../../src/gui/dialogs/campaign_selection.hpp" />
<Unit filename="../../src/gui/dialogs/campaign_settings.cpp" />
<Unit filename="../../src/gui/dialogs/campaign_settings.hpp" />
<Unit filename="../../src/gui/dialogs/chat_log.cpp" />
<Unit filename="../../src/gui/dialogs/chat_log.hpp" />
<Unit filename="../../src/gui/dialogs/core_selection.cpp" />

View file

@ -170,7 +170,6 @@ gui/dialogs/advanced_graphics_options.cpp
gui/dialogs/attack_predictions.cpp
gui/dialogs/campaign_difficulty.cpp
gui/dialogs/campaign_selection.cpp
gui/dialogs/campaign_settings.cpp
gui/dialogs/chat_log.cpp
gui/dialogs/core_selection.cpp
gui/dialogs/debug_clock.cpp

View file

@ -20,7 +20,6 @@
#include "game_preferences.hpp"
#include "gui/auxiliary/find_widget.hpp"
#include "gui/dialogs/helper.hpp"
#include "gui/dialogs/campaign_settings.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/image.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
@ -106,11 +105,6 @@ void campaign_selection::campaign_selected(window& window)
}
void campaign_selection::show_settings(CVideo& video) {
campaign_settings settings_dlg(engine_);
settings_dlg.show(video);
}
void campaign_selection::pre_show(window& window)
{
/***** Setup campaign tree. *****/
@ -189,14 +183,6 @@ void campaign_selection::pre_show(window& window)
}
campaign_selected(window);
/***** Setup advanced settings button *****/
button* advanced_settings_button =
find_widget<button>(&window, "advanced_settings", false, false);
if(advanced_settings_button) {
advanced_settings_button->connect_click_handler(
std::bind(&campaign_selection::show_settings, this, std::ref(window.video())));
}
}
void campaign_selection::post_show(window& window)

View file

@ -57,8 +57,6 @@ private:
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const override;
void show_settings(CVideo& video);
/** Inherited from modal_dialog. */
virtual void pre_show(window& window) override;

View file

@ -1,187 +0,0 @@
/*
Copyright (C) 2014 - 2017 by Nathan Walker <nathan.b.walker@vanderbilt.edu>
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.
*/
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "saved_game.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/find_widget.hpp"
#include "gui/dialogs/campaign_settings.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/label.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
#include "gui/widgets/list.hpp"
#else
#include "gui/widgets/listbox.hpp"
#endif
#include "gui/widgets/settings.hpp"
#include "gui/widgets/toggle_button.hpp"
#include "gui/widgets/window.hpp"
#include "utils/functional.hpp"
namespace gui2
{
namespace dialogs
{
/*WIKI
* @page = GUIWindowDefinitionWML
* @order = 2_campaign_settings
*
* == Campaign settings ==
*
* This shows the dialog which allows the user to select an era
* and modifications for the selected campaign, and to show
* dialogs for additional level configuration.
*
* @begin{table}{dialog_widgets}
*
* title & & label & m &
* Dialog title label. $
*
* mp_configure & & toggle_button & m &
* Option to show the multiplayer configure dialog. $
*
* mp_connect & & toggle_button & m &
* Option to show the multiplayer connect dialog. $
*
* era_label & & label & m &
* The label for the era list. $
*
* era_list & & listbox & m &
* List of available eras. $
*
* -era & & label & o &
* The name of the era. One can be selected at a time. $
*
* mod_label & & label & m &
* The label for the modification list. $
*
* modification_list & & listbox & m &
* List of available modifications. $
*
* -mod & & toggle_button & o &
* The name of the modification. Each can be enabled or disabled. $
*
* @end{table}
*/
REGISTER_DIALOG(campaign_settings)
campaign_settings::campaign_settings(ng::create_engine& eng)
: engine_(eng)
{ }
void campaign_settings::change_era(window& window)
{
listbox& list = find_widget<listbox>(&window, "era_list", false);
engine_.set_current_era_index(list.get_selected_row());
}
void campaign_settings::change_mod(size_t index, window&)
{
engine_.set_current_mod_index(index);
// force toggle mod.
engine_.toggle_current_mod(true);
}
void campaign_settings::update_lists(window& window)
{
listbox& era_list = find_widget<listbox>(&window, "era_list", false);
listbox& mod_list = find_widget<listbox>(&window, "modification_list", false);
label& era_label = find_widget<label>(&window, "era_label", false);
label& mod_label = find_widget<label>(&window, "mod_label", false);
era_list.clear();
if (engine_.current_level().allow_era_choice()) {
for (std::string era : engine_.extras_menu_item_names(ng::create_engine::ERA)) {
std::map<std::string, string_map> row;
string_map column;
column["label"] = era;
row.emplace("era", column);
era_list.add_row(row);
}
era_list.select_row(engine_.current_era_index());
}
else {
era_label.set_label(_("Era:\n\nNot allowed."));
era_list.set_active(false);
}
mod_list.clear();
{
int i = 0;
for (const ng::create_engine::extras_metadata_ptr mod : engine_.get_const_extras_by_type(ng::create_engine::MOD)) {
std::map<std::string, string_map> row;
string_map column;
column["label"] = mod->name;
row.emplace("mod", column);
mod_list.add_row(row);
std::vector<std::string> enabled = engine_.active_mods();
mod_list.select_row(i,
std::find(enabled.begin(), enabled.end(), mod->id)
!= enabled.end());
++i;
}
if (i == 0) {
mod_label.set_label(_("Modifications:\n\nNone found."));
mod_list.set_active(false);
}
}
}
void campaign_settings::pre_show(window& window)
{
find_widget<toggle_button>(&window, "mp_connect", false).set_value(
engine_.get_state().mp_settings().show_connect);
update_lists(window);
listbox& era_list = find_widget<listbox>(&window, "era_list", false);
listbox& mod_list = find_widget<listbox>(&window, "modification_list", false);
toggle_button& connect_toggle = find_widget<toggle_button>(&window, "mp_connect", false);
const config::attribute_value& show_connect = engine_.current_level().data()["show_connect"];
if (show_connect.blank() || show_connect.str() == "user") {
connect_toggle.set_active(true);
} else {
connect_toggle.set_value(show_connect.to_bool());
connect_toggle.set_active(false);
}
era_list.set_callback_item_change(
std::bind(&campaign_settings::change_era, this, std::ref(window)));
mod_list.set_callback_item_change(
std::bind(&campaign_settings::change_mod, this, _1, std::ref(window)));
}
void campaign_settings::post_show(window& window)
{
engine_.get_state().mp_settings().show_connect =
find_widget<toggle_button>(&window, "mp_connect", false).get_value_bool();
}
} // namespace dialogs
} // namespace gui2

View file

@ -1,68 +0,0 @@
/*
Copyright (C) 2014 - 2017 by Nathan Walker <nathan.b.walker@vanderbilt.edu>
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_CAMPAIGN_SETTINGS_HPP_INCLUDED
#define GUI_DIALOGS_CAMPAIGN_SETTINGS_HPP_INCLUDED
#include "gui/dialogs/modal_dialog.hpp"
#include "addon/validation.hpp"
#include "addon/state.hpp"
#include "game_initialization/create_engine.hpp"
namespace gui2
{
namespace dialogs
{
class campaign_settings : public modal_dialog
{
public:
campaign_settings(ng::create_engine& eng);
// whether configure is enabled
bool enable_configure();
// whether connect is enabled
bool enable_connect();
private:
ng::create_engine& engine_;
// called on era change
// sets era via create_engine
void change_era(window& window);
// called on mod change
// sets mod via create_engine
void change_mod(size_t index, window& window);
// populate era and mod lists
void update_lists(window& window);
/** 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;
/** Inherited from modal_dialog. */
virtual void post_show(window& window) override;
};
} // namespace dialogs
} // end namespace gui2
#endif

View file

@ -39,7 +39,6 @@
#include "gui/dialogs/attack_predictions.hpp"
#include "gui/dialogs/campaign_difficulty.hpp"
#include "gui/dialogs/campaign_selection.hpp"
#include "gui/dialogs/campaign_settings.hpp"
#include "gui/dialogs/chat_log.hpp"
#include "gui/dialogs/core_selection.hpp"
#include "gui/dialogs/debug_clock.hpp"
@ -399,7 +398,6 @@ BOOST_AUTO_TEST_CASE(test_gui2)
//test<attack_predictions>();
test<campaign_difficulty>();
test<campaign_selection>();
test<campaign_settings>();
test<chat_log>();
test<core_selection>();
test<custom_tod>();
@ -599,20 +597,6 @@ struct dialog_tester<campaign_selection>
}
};
template<>
struct dialog_tester<campaign_settings>
{
saved_game state;
ng::create_engine ng;
dialog_tester() : state(config_of("campaign_type", "scenario")), ng(test_utils::get_fake_display(-1, -1).video(), state)
{
}
campaign_settings* create()
{
return new campaign_settings(ng);
}
};
template<>
struct dialog_tester<chat_log>
{