Support for total conversions, so called "cores".
This commit is contained in:
parent
70a5539a89
commit
b4ea561e37
17 changed files with 843 additions and 5 deletions
40
_main.cfg
Normal file
40
_main.cfg
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
[core]
|
||||||
|
id=default
|
||||||
|
name= _ "Wesnoth (default)"
|
||||||
|
rank=5
|
||||||
|
icon=icons/icon-game.png
|
||||||
|
image="wesnoth-icon.png"
|
||||||
|
description= _ "Wesnoth has many different sagas waiting to be played. Fight to regain the throne of Wesnoth, of which you are the legitimate heir... step into the boots of a young officer sent to guard a not-so-sleepy frontier outpost... lead a brutal quest to unite the orcish tribes... vanquish a horde of undead warriors unleashed by a foul necromancer, who also happens to have taken your brother hostage... guide a band of elvish survivors in an epic quest to find a new home... get revenge on the orcs by using the foul art of necromancy...
|
||||||
|
|
||||||
|
There are at least two hundred unit types, sixteen races, seven major factions, and hundreds of years of history.
|
||||||
|
|
||||||
|
" + _"(17 Single Player Campaigns with 211 Scenarios,
|
||||||
|
One Multiplayer Campaign with 14 Scenarios,
|
||||||
|
7 Factions battling on 46 Multiplayer Maps/Scenarios,
|
||||||
|
500+ Add-ons.)"
|
||||||
|
path="/"
|
||||||
|
[/core]
|
||||||
|
|
||||||
|
# test cores
|
||||||
|
[core]
|
||||||
|
id=broken
|
||||||
|
name= _ "The Broken One"
|
||||||
|
rank=10
|
||||||
|
icon=icons/icon-game.png
|
||||||
|
#image="wesnoth-icon.png"
|
||||||
|
description= _ "The Broken One
|
||||||
|
is a test core for the fallback solution.
|
||||||
|
|
||||||
|
" + _"(No gameplay, expected to fail during loading.)"
|
||||||
|
path="evil/broken/path"
|
||||||
|
[/core]
|
||||||
|
|
||||||
|
[core]
|
||||||
|
id=working
|
||||||
|
name= _ "Clone of Default"
|
||||||
|
rank=15
|
||||||
|
icon=icons/icon-game.png
|
||||||
|
#image="wesnoth-icon.png"
|
||||||
|
description= _ "Test core which should match the default one but not load any add-ons."
|
||||||
|
path="/"
|
||||||
|
[/core]
|
|
@ -27,6 +27,7 @@ Version 1.13.0-dev:
|
||||||
* Changed: Dropped support for AmigaOS, BeOS, and OS/2.
|
* Changed: Dropped support for AmigaOS, BeOS, and OS/2.
|
||||||
* Increased the sound mixer channel allocation from 16 to 32, thereby
|
* Increased the sound mixer channel allocation from 16 to 32, thereby
|
||||||
raising the limit for simultaneous sound effects from 5 to 21.
|
raising the limit for simultaneous sound effects from 5 to 21.
|
||||||
|
* Support for total conversions, so called "cores".
|
||||||
|
|
||||||
Version 1.11.11:
|
Version 1.11.11:
|
||||||
* Add-ons server:
|
* Add-ons server:
|
||||||
|
|
403
data/gui/default/window/core_dialog.cfg
Normal file
403
data/gui/default/window/core_dialog.cfg
Normal file
|
@ -0,0 +1,403 @@
|
||||||
|
#textdomain wesnoth-lib
|
||||||
|
###
|
||||||
|
### Definition of the window selecting the core to play
|
||||||
|
###
|
||||||
|
|
||||||
|
[window]
|
||||||
|
id = "core_selection"
|
||||||
|
description = "Core selection dialog."
|
||||||
|
|
||||||
|
[resolution]
|
||||||
|
definition = "default"
|
||||||
|
|
||||||
|
automatic_placement = "true"
|
||||||
|
vertical_placement = "center"
|
||||||
|
horizontal_placement = "center"
|
||||||
|
maximum_height = 600
|
||||||
|
|
||||||
|
[linked_group]
|
||||||
|
id = "icon_area"
|
||||||
|
fixed_width = "true"
|
||||||
|
[/linked_group]
|
||||||
|
|
||||||
|
[linked_group]
|
||||||
|
id = "name"
|
||||||
|
fixed_width = "true"
|
||||||
|
[/linked_group]
|
||||||
|
|
||||||
|
[linked_group]
|
||||||
|
id = "tree_name"
|
||||||
|
fixed_width = "true"
|
||||||
|
[/linked_group]
|
||||||
|
|
||||||
|
[tooltip]
|
||||||
|
id = "tooltip_large"
|
||||||
|
[/tooltip]
|
||||||
|
|
||||||
|
[helptip]
|
||||||
|
id = "tooltip_large"
|
||||||
|
[/helptip]
|
||||||
|
|
||||||
|
[grid]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
grow_factor = 0
|
||||||
|
|
||||||
|
[column]
|
||||||
|
grow_factor = 1
|
||||||
|
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
[label]
|
||||||
|
definition = "title"
|
||||||
|
|
||||||
|
label = _ "Load Core"
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
grow_factor = 1
|
||||||
|
|
||||||
|
[column]
|
||||||
|
grow_factor = 1
|
||||||
|
|
||||||
|
horizontal_grow = "true"
|
||||||
|
|
||||||
|
[grid]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
grow_factor = 1
|
||||||
|
|
||||||
|
[column]
|
||||||
|
grow_factor = 0
|
||||||
|
horizontal_grow = "true"
|
||||||
|
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
|
||||||
|
[listbox]
|
||||||
|
id = "core_list"
|
||||||
|
definition = "default"
|
||||||
|
|
||||||
|
horizontal_scrollbar_mode = "never"
|
||||||
|
[list_definition]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
grow_factor = 1
|
||||||
|
horizontal_grow = "true"
|
||||||
|
|
||||||
|
[toggle_panel]
|
||||||
|
id = "_toggle"
|
||||||
|
definition = "default"
|
||||||
|
|
||||||
|
return_value_id = "ok"
|
||||||
|
[grid]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
grow_factor = 1
|
||||||
|
horizontal_grow = "true"
|
||||||
|
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
vertical_alignment = "top"
|
||||||
|
|
||||||
|
[image]
|
||||||
|
id = "icon"
|
||||||
|
definition = "default"
|
||||||
|
label = "misc/laurel.png"
|
||||||
|
[/image]
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
grow_factor = 1
|
||||||
|
horizontal_grow = "true"
|
||||||
|
|
||||||
|
border = "right"
|
||||||
|
border_size = 8
|
||||||
|
|
||||||
|
[label]
|
||||||
|
id = "name"
|
||||||
|
definition = "default"
|
||||||
|
linked_group = "name"
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[/grid]
|
||||||
|
|
||||||
|
[/toggle_panel]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[/list_definition]
|
||||||
|
|
||||||
|
[/listbox]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
grow_factor = 0
|
||||||
|
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
|
||||||
|
[tree_view]
|
||||||
|
id = "core_tree"
|
||||||
|
definition = "default"
|
||||||
|
|
||||||
|
horizontal_scrollbar_mode = "never"
|
||||||
|
vertical_scrollbar_mode = "always"
|
||||||
|
|
||||||
|
indention_step_size = "40"
|
||||||
|
|
||||||
|
[node]
|
||||||
|
id = "core_group"
|
||||||
|
[node_definition]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
|
||||||
|
[toggle_button]
|
||||||
|
id = "tree_view_node_icon"
|
||||||
|
definition = "tree_view_node"
|
||||||
|
[/toggle_button]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
grow_factor = 1
|
||||||
|
horizontal_grow = "true"
|
||||||
|
|
||||||
|
[label]
|
||||||
|
id = "tree_view_node_label"
|
||||||
|
label = "group"
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[/node_definition]
|
||||||
|
|
||||||
|
[/node]
|
||||||
|
|
||||||
|
[node]
|
||||||
|
id = "core"
|
||||||
|
|
||||||
|
[node_definition]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
horizontal_grow = "true"
|
||||||
|
|
||||||
|
[toggle_panel]
|
||||||
|
id = "tree_view_node_label"
|
||||||
|
definition = "default"
|
||||||
|
|
||||||
|
# horizontal_grow = "true"
|
||||||
|
return_value_id = "ok"
|
||||||
|
[grid]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
vertical_alignment = "top"
|
||||||
|
|
||||||
|
[image]
|
||||||
|
id = "icon"
|
||||||
|
definition = "default"
|
||||||
|
[/image]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
grow_factor = 1
|
||||||
|
horizontal_grow = "true"
|
||||||
|
|
||||||
|
border = "right"
|
||||||
|
border_size = 8
|
||||||
|
|
||||||
|
[label]
|
||||||
|
id = "name"
|
||||||
|
definition = "default"
|
||||||
|
linked_group = "tree_name"
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[/grid]
|
||||||
|
|
||||||
|
[/toggle_panel]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[/node_definition]
|
||||||
|
|
||||||
|
[/node]
|
||||||
|
|
||||||
|
[/tree_view]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
grow_factor = 1
|
||||||
|
horizontal_grow = "true"
|
||||||
|
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
vertical_alignment = "top"
|
||||||
|
|
||||||
|
[multi_page]
|
||||||
|
id = "core_details"
|
||||||
|
definition = "default"
|
||||||
|
|
||||||
|
horizontal_scrollbar_mode = "never"
|
||||||
|
|
||||||
|
[page_definition]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
horizontal_grow = "true"
|
||||||
|
vertical_alignment = "top"
|
||||||
|
|
||||||
|
[scrollbar_panel]
|
||||||
|
|
||||||
|
[definition]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
grow_factor = 0
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
vertical_alignment = "top"
|
||||||
|
|
||||||
|
[label]
|
||||||
|
id = "description"
|
||||||
|
definition = "default"
|
||||||
|
|
||||||
|
characters_per_line = 66
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
grow_factor = 1
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
horizontal_alignment = "center"
|
||||||
|
vertical_alignment = "top"
|
||||||
|
|
||||||
|
[image]
|
||||||
|
id = "image"
|
||||||
|
definition = "default"
|
||||||
|
[/image]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[/definition]
|
||||||
|
|
||||||
|
[/scrollbar_panel]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[/page_definition]
|
||||||
|
|
||||||
|
[/multi_page]
|
||||||
|
|
||||||
|
[/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
|
||||||
|
|
||||||
|
grow_factor = 1
|
||||||
|
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]
|
|
@ -258,6 +258,7 @@
|
||||||
{_GUI_BUTTON "multiplayer" _"Multiplayer" _"Play multiplayer (hotseat, LAN, or Internet), or a single scenario against the AI"}
|
{_GUI_BUTTON "multiplayer" _"Multiplayer" _"Play multiplayer (hotseat, LAN, or Internet), or a single scenario against the AI"}
|
||||||
{_GUI_BUTTON "load" _"Load" _"Load a saved game"}
|
{_GUI_BUTTON "load" _"Load" _"Load a saved game"}
|
||||||
{_GUI_BUTTON "addons" _"Add-ons" _"Download usermade campaigns, eras, or map packs"}
|
{_GUI_BUTTON "addons" _"Add-ons" _"Download usermade campaigns, eras, or map packs"}
|
||||||
|
{_GUI_BUTTON "cores" _"Cores" _"Select the game core data"}
|
||||||
{_GUI_BUTTON "editor" _"Map Editor" _"Start the map editor"}
|
{_GUI_BUTTON "editor" _"Map Editor" _"Start the map editor"}
|
||||||
{_GUI_BUTTON "language" _"Language" _"Change the language"}
|
{_GUI_BUTTON "language" _"Language" _"Change the language"}
|
||||||
{_GUI_BUTTON "preferences" _"Preferences" _"Configure the game’s settings"}
|
{_GUI_BUTTON "preferences" _"Preferences" _"Configure the game’s settings"}
|
||||||
|
|
|
@ -13,6 +13,8 @@ Version 1.13.0-dev:
|
||||||
* User interface:
|
* User interface:
|
||||||
* Made orb and minmap colors configurable by the game preferences.
|
* Made orb and minmap colors configurable by the game preferences.
|
||||||
|
|
||||||
|
* Miscellaneous and bug fixes:
|
||||||
|
* Support for total conversions, so called "cores".
|
||||||
|
|
||||||
Version 1.11.11:
|
Version 1.11.11:
|
||||||
* Campaigns:
|
* Campaigns:
|
||||||
|
|
|
@ -351,6 +351,7 @@ wesnoth_sources = Split("""
|
||||||
gui/dialogs/addon_list.cpp
|
gui/dialogs/addon_list.cpp
|
||||||
gui/dialogs/campaign_difficulty.cpp
|
gui/dialogs/campaign_difficulty.cpp
|
||||||
gui/dialogs/campaign_selection.cpp
|
gui/dialogs/campaign_selection.cpp
|
||||||
|
gui/dialogs/core_selection.cpp
|
||||||
gui/dialogs/chat_log.cpp
|
gui/dialogs/chat_log.cpp
|
||||||
gui/dialogs/data_manage.cpp
|
gui/dialogs/data_manage.cpp
|
||||||
gui/dialogs/debug_clock.cpp
|
gui/dialogs/debug_clock.cpp
|
||||||
|
|
22
src/game.cpp
22
src/game.cpp
|
@ -20,6 +20,7 @@
|
||||||
#include "commandline_options.hpp"
|
#include "commandline_options.hpp"
|
||||||
#include "game_config_manager.hpp"
|
#include "game_config_manager.hpp"
|
||||||
#include "game_controller.hpp"
|
#include "game_controller.hpp"
|
||||||
|
#include "gui/dialogs/core_selection.hpp"
|
||||||
#include "gui/dialogs/title_screen.hpp"
|
#include "gui/dialogs/title_screen.hpp"
|
||||||
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
|
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
|
||||||
#include "gui/widgets/debug.hpp"
|
#include "gui/widgets/debug.hpp"
|
||||||
|
@ -622,6 +623,27 @@ static int do_gameloop(int argc, char** argv)
|
||||||
config_manager.reload_changed_game_config();
|
config_manager.reload_changed_game_config();
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
} else if(res == gui2::ttitle_screen::CORES) {
|
||||||
|
|
||||||
|
int current = 0;
|
||||||
|
std::vector<config> cores;
|
||||||
|
BOOST_FOREACH(const config& core,
|
||||||
|
resources::config_manager->game_config().child_range("core")) {
|
||||||
|
cores.push_back(core);
|
||||||
|
if (core["id"] == preferences::core_id())
|
||||||
|
current = cores.size() -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gui2::tcore_selection core_dlg(cores, current);
|
||||||
|
if (core_dlg.show(game->disp().video())) {
|
||||||
|
int core_index = core_dlg.get_choice();
|
||||||
|
const std::string& wml_tree_root = cores[core_index]["path"];
|
||||||
|
const std::string& core_id = cores[core_index]["id"];
|
||||||
|
preferences::set_wml_tree_root(wml_tree_root);
|
||||||
|
preferences::set_core_id(core_id);
|
||||||
|
config_manager.reload_changed_game_config();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
} else if(res == gui2::ttitle_screen::RELOAD_GAME_DATA) {
|
} else if(res == gui2::ttitle_screen::RELOAD_GAME_DATA) {
|
||||||
loadscreen::global_loadscreen_manager loadscreen(game->disp().video());
|
loadscreen::global_loadscreen_manager loadscreen(game->disp().video());
|
||||||
config_manager.reload_changed_game_config();
|
config_manager.reload_changed_game_config();
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "language.hpp"
|
#include "language.hpp"
|
||||||
#include "loadscreen.hpp"
|
#include "loadscreen.hpp"
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
#include "preferences.hpp"
|
||||||
#include "resources.hpp"
|
#include "resources.hpp"
|
||||||
#include "scripting/lua.hpp"
|
#include "scripting/lua.hpp"
|
||||||
#include "hotkey/hotkey_item.hpp"
|
#include "hotkey/hotkey_item.hpp"
|
||||||
|
@ -122,7 +123,12 @@ void game_config_manager::load_game_config(FORCE_RELOAD_CONFIG force_reload,
|
||||||
// Start transaction so macros are shared.
|
// Start transaction so macros are shared.
|
||||||
game_config::config_cache_transaction main_transaction;
|
game_config::config_cache_transaction main_transaction;
|
||||||
|
|
||||||
cache_.get_config(game_config::path +"/data", game_config_);
|
// Load the selected core
|
||||||
|
cache_.get_config(get_wml_location(preferences::wml_tree_root()), game_config_);
|
||||||
|
// Load the mainline core definitions to make sure switching back is always possible.
|
||||||
|
config default_core_cfg;
|
||||||
|
cache_.get_config(game_config::path, default_core_cfg);
|
||||||
|
game_config_.append(default_core_cfg);
|
||||||
|
|
||||||
main_transaction.lock();
|
main_transaction.lock();
|
||||||
|
|
||||||
|
@ -176,11 +182,21 @@ void game_config_manager::load_game_config(FORCE_RELOAD_CONFIG force_reload,
|
||||||
theme::set_known_themes(&game_config());
|
theme::set_known_themes(&game_config());
|
||||||
} catch(game::error& e) {
|
} catch(game::error& e) {
|
||||||
ERR_CONFIG << "Error loading game configuration files\n" << e.message << '\n';
|
ERR_CONFIG << "Error loading game configuration files\n" << e.message << '\n';
|
||||||
|
|
||||||
|
if (preferences::wml_tree_root() != "/"){
|
||||||
gui2::twml_error::display(
|
gui2::twml_error::display(
|
||||||
_("Error loading game configuration files. The game will now exit."),
|
_("Error loading custom game configuration files. The game will fallback to the default files."),
|
||||||
|
e.message, disp_.video());
|
||||||
|
preferences::set_wml_tree_root("/");
|
||||||
|
preferences::set_core_id("default");
|
||||||
|
load_game_config(force_reload, classification);
|
||||||
|
} else {
|
||||||
|
gui2::twml_error::display(
|
||||||
|
_("Error loading default game configuration files. The game will now exit."),
|
||||||
e.message, disp_.video());
|
e.message, disp_.video());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
old_defines_map_ = cache_.get_preproc_map();
|
old_defines_map_ = cache_.get_preproc_map();
|
||||||
|
|
||||||
|
@ -245,6 +261,22 @@ void game_config_manager::load_addons_cfg()
|
||||||
|
|
||||||
// Append the $user_campaign_dir/*/_main.cfg files to addons_to_load.
|
// Append the $user_campaign_dir/*/_main.cfg files to addons_to_load.
|
||||||
BOOST_FOREACH(const std::string& uc, user_dirs) {
|
BOOST_FOREACH(const std::string& uc, user_dirs) {
|
||||||
|
|
||||||
|
const std::string info_cfg = uc + "/_info.cfg";
|
||||||
|
if (file_exists(info_cfg)) {
|
||||||
|
|
||||||
|
config info;
|
||||||
|
cache_.get_config(info_cfg, info);
|
||||||
|
const config info_tag = info.child_or_empty("info");
|
||||||
|
std::string core = info_tag["core"];
|
||||||
|
if (core.empty()) core = "default";
|
||||||
|
if ( !info_tag.empty() && // Don't skip addons which have no [info], they are most likely manually installed.
|
||||||
|
info_tag["type"] != "core" && // Don't skip cores, we want them selectable at all times.
|
||||||
|
core != preferences::core_id() // Don't skip addons matching our current core.
|
||||||
|
)
|
||||||
|
continue; // Skip add-ons not matching our current core.
|
||||||
|
}
|
||||||
|
|
||||||
const std::string main_cfg = uc + "/_main.cfg";
|
const std::string main_cfg = uc + "/_main.cfg";
|
||||||
if(file_exists(main_cfg)) {
|
if(file_exists(main_cfg)) {
|
||||||
addons_to_load.push_back(main_cfg);
|
addons_to_load.push_back(main_cfg);
|
||||||
|
|
235
src/gui/dialogs/core_selection.cpp
Normal file
235
src/gui/dialogs/core_selection.cpp
Normal file
|
@ -0,0 +1,235 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2009 - 2014 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 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/core_selection.hpp"
|
||||||
|
|
||||||
|
#include "gui/auxiliary/find_widget.tpp"
|
||||||
|
#include "gui/dialogs/helper.hpp"
|
||||||
|
#include "gui/widgets/image.hpp"
|
||||||
|
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||||
|
#include "gui/widgets/list.hpp"
|
||||||
|
#else
|
||||||
|
#include "gui/widgets/listbox.hpp"
|
||||||
|
#endif
|
||||||
|
#include "gui/widgets/multi_page.hpp"
|
||||||
|
#include "gui/widgets/scroll_label.hpp"
|
||||||
|
#include "gui/widgets/settings.hpp"
|
||||||
|
#include "gui/widgets/tree_view.hpp"
|
||||||
|
#include "gui/widgets/tree_view_node.hpp"
|
||||||
|
#include "gui/widgets/window.hpp"
|
||||||
|
#include "utils/foreach.tpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
namespace gui2
|
||||||
|
{
|
||||||
|
|
||||||
|
/*WIKI
|
||||||
|
* @page = GUIWindowDefinitionWML
|
||||||
|
* @order = 2_core_selection
|
||||||
|
*
|
||||||
|
* == Core selection ==
|
||||||
|
*
|
||||||
|
* This shows the dialog which allows the user to choose which core to
|
||||||
|
* play.
|
||||||
|
*
|
||||||
|
* @begin{table}{dialog_widgets}
|
||||||
|
*
|
||||||
|
* core_list & & listbox & m &
|
||||||
|
* A listbox that contains all available cores. $
|
||||||
|
*
|
||||||
|
* -icon & & image & o &
|
||||||
|
* The icon for the core. $
|
||||||
|
*
|
||||||
|
* -name & & control & o &
|
||||||
|
* The name of the core. $
|
||||||
|
*
|
||||||
|
* core_details & & multi_page & m &
|
||||||
|
* A multi page widget that shows more details for the selected
|
||||||
|
* core. $
|
||||||
|
*
|
||||||
|
* -image & & image & o &
|
||||||
|
* The image for the core. $
|
||||||
|
*
|
||||||
|
* -description & & control & o &
|
||||||
|
* The description of the core. $
|
||||||
|
*
|
||||||
|
* @end{table}
|
||||||
|
*/
|
||||||
|
|
||||||
|
REGISTER_DIALOG(core_selection)
|
||||||
|
|
||||||
|
void tcore_selection::core_selected(twindow& window)
|
||||||
|
{
|
||||||
|
if(new_widgets && false) {
|
||||||
|
ttree_view& tree
|
||||||
|
= find_widget<ttree_view>(&window, "core_tree", false);
|
||||||
|
|
||||||
|
if(tree.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(tree.selected_item());
|
||||||
|
const unsigned choice
|
||||||
|
= lexical_cast<unsigned>(tree.selected_item()->id());
|
||||||
|
|
||||||
|
tmulti_page& multi_page
|
||||||
|
= find_widget<tmulti_page>(&window, "core_details", false);
|
||||||
|
multi_page.select_page(choice);
|
||||||
|
} else {
|
||||||
|
const int selected_row
|
||||||
|
= find_widget<tlistbox>(&window, "core_list", false)
|
||||||
|
.get_selected_row();
|
||||||
|
|
||||||
|
tmulti_page& multi_page
|
||||||
|
= find_widget<tmulti_page>(&window, "core_details", false);
|
||||||
|
|
||||||
|
multi_page.select_page(selected_row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcore_selection::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
|
{
|
||||||
|
if(new_widgets && false) {
|
||||||
|
/***** Setup core tree. *****/
|
||||||
|
ttree_view& tree
|
||||||
|
= find_widget<ttree_view>(&window, "core_tree", false);
|
||||||
|
|
||||||
|
tree.set_selection_change_callback(
|
||||||
|
boost::bind(&tcore_selection::core_selected,
|
||||||
|
this,
|
||||||
|
boost::ref(window)));
|
||||||
|
|
||||||
|
window.keyboard_capture(&tree);
|
||||||
|
|
||||||
|
string_map tree_group_field;
|
||||||
|
std::map<std::string, string_map> tree_group_item;
|
||||||
|
|
||||||
|
tree_group_item["tree_view_node_label"] = tree_group_field;
|
||||||
|
|
||||||
|
/***** Setup core details. *****/
|
||||||
|
tmulti_page& multi_page
|
||||||
|
= find_widget<tmulti_page>(&window, "core_details", false);
|
||||||
|
|
||||||
|
// unsigned id = 0;
|
||||||
|
FOREACH(const AUTO & core, cores_)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*** Add tree item ***/
|
||||||
|
tree_group_field["label"] = core["icon"];
|
||||||
|
tree_group_item["icon"] = tree_group_field;
|
||||||
|
|
||||||
|
tree_group_field["label"] = core["name"];
|
||||||
|
tree_group_item["name"] = tree_group_field;
|
||||||
|
|
||||||
|
/*** Add detail item ***/
|
||||||
|
string_map detail_item;
|
||||||
|
std::map<std::string, string_map> detail_page;
|
||||||
|
|
||||||
|
detail_item["label"] = core["description"];
|
||||||
|
detail_item["use_markup"] = "true";
|
||||||
|
detail_page.insert(std::make_pair("description", detail_item));
|
||||||
|
|
||||||
|
detail_item["label"] = core["image"];
|
||||||
|
detail_page.insert(std::make_pair("image", detail_item));
|
||||||
|
|
||||||
|
multi_page.add_page(detail_page);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/***** Hide the tree view. *****/
|
||||||
|
if(ttree_view* tree
|
||||||
|
= find_widget<ttree_view>(&window, "core_tree", false, false)) {
|
||||||
|
|
||||||
|
tree->set_visible(twidget::tvisible::invisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Setup core list. *****/
|
||||||
|
tlistbox& list = find_widget<tlistbox>(&window, "core_list", false);
|
||||||
|
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||||
|
connect_signal_notify_modified(
|
||||||
|
list,
|
||||||
|
boost::bind(&tcore_selection::core_selected,
|
||||||
|
this,
|
||||||
|
boost::ref(window)));
|
||||||
|
#else
|
||||||
|
list.set_callback_value_change(
|
||||||
|
dialog_callback<tcore_selection,
|
||||||
|
&tcore_selection::core_selected>);
|
||||||
|
#endif
|
||||||
|
window.keyboard_capture(&list);
|
||||||
|
|
||||||
|
/***** Setup core details. *****/
|
||||||
|
tmulti_page& multi_page
|
||||||
|
= find_widget<tmulti_page>(&window, "core_details", false);
|
||||||
|
|
||||||
|
FOREACH(const AUTO & core, cores_)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*** Add list item ***/
|
||||||
|
string_map list_item;
|
||||||
|
std::map<std::string, string_map> list_item_item;
|
||||||
|
|
||||||
|
list_item["label"] = core["icon"];
|
||||||
|
list_item_item.insert(std::make_pair("icon", list_item));
|
||||||
|
|
||||||
|
list_item["label"] = core["name"];
|
||||||
|
list_item_item.insert(std::make_pair("name", list_item));
|
||||||
|
|
||||||
|
list.add_row(list_item_item);
|
||||||
|
|
||||||
|
tgrid* grid = list.get_row_grid(list.get_item_count() - 1);
|
||||||
|
assert(grid);
|
||||||
|
|
||||||
|
/*** Add detail item ***/
|
||||||
|
string_map detail_item;
|
||||||
|
std::map<std::string, string_map> detail_page;
|
||||||
|
|
||||||
|
detail_item["label"] = core["description"];
|
||||||
|
detail_item["use_markup"] = "true";
|
||||||
|
detail_page.insert(std::make_pair("description", detail_item));
|
||||||
|
|
||||||
|
detail_item["label"] = core["image"];
|
||||||
|
detail_page.insert(std::make_pair("image", detail_item));
|
||||||
|
|
||||||
|
multi_page.add_page(detail_page);
|
||||||
|
}
|
||||||
|
list.select_row(choice_, true);
|
||||||
|
}
|
||||||
|
core_selected(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcore_selection::post_show(twindow& window)
|
||||||
|
{
|
||||||
|
if(new_widgets && false) {
|
||||||
|
ttree_view& tree
|
||||||
|
= find_widget<ttree_view>(&window, "core_tree", false);
|
||||||
|
|
||||||
|
if(tree.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(tree.selected_item());
|
||||||
|
choice_ = lexical_cast<unsigned>(tree.selected_item()->id());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
choice_ = find_widget<tlistbox>(&window, "core_list", false)
|
||||||
|
.get_selected_row();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace gui2
|
63
src/gui/dialogs/core_selection.hpp
Normal file
63
src/gui/dialogs/core_selection.hpp
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2009 - 2014 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 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_CORE_SELECTION_HPP_INCLUDED
|
||||||
|
#define GUI_DIALOGS_CORE_SELECTION_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include "gui/dialogs/dialog.hpp"
|
||||||
|
|
||||||
|
#include "config.hpp"
|
||||||
|
|
||||||
|
namespace gui2
|
||||||
|
{
|
||||||
|
|
||||||
|
class tcore_selection : public tdialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit tcore_selection(const std::vector<config>& cores, int choice)
|
||||||
|
: cores_(cores), choice_(choice)
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** ***** ***** setters / getters for members ***** ****** *****/
|
||||||
|
|
||||||
|
int get_choice() const
|
||||||
|
{
|
||||||
|
return choice_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** Called when another core is selected. */
|
||||||
|
void core_selected(twindow& window);
|
||||||
|
|
||||||
|
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||||
|
virtual const std::string& window_id() const;
|
||||||
|
|
||||||
|
/** Inherited from tdialog. */
|
||||||
|
void pre_show(CVideo& video, twindow& window);
|
||||||
|
|
||||||
|
/** Inherited from tdialog. */
|
||||||
|
void post_show(twindow& window);
|
||||||
|
|
||||||
|
/** Contains the config objects for all cores. */
|
||||||
|
const std::vector<config>& cores_;
|
||||||
|
|
||||||
|
/** The chosen core. */
|
||||||
|
int choice_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace gui2
|
||||||
|
|
||||||
|
#endif
|
|
@ -77,6 +77,9 @@ namespace gui2
|
||||||
* addons & & button & m &
|
* addons & & button & m &
|
||||||
* The button to start managing the addons. $
|
* The button to start managing the addons. $
|
||||||
*
|
*
|
||||||
|
* cores & & button & m &
|
||||||
|
* The button to start managing the cores. $
|
||||||
|
*
|
||||||
* language & & button & m &
|
* language & & button & m &
|
||||||
* The button to select the game language. $
|
* The button to select the game language. $
|
||||||
*
|
*
|
||||||
|
@ -242,6 +245,10 @@ void ttitle_screen::post_build(CVideo& video, twindow& window)
|
||||||
hotkey::TITLE_SCREEN__ADDONS,
|
hotkey::TITLE_SCREEN__ADDONS,
|
||||||
boost::bind(&hotkey, boost::ref(window), GET_ADDONS));
|
boost::bind(&hotkey, boost::ref(window), GET_ADDONS));
|
||||||
|
|
||||||
|
window.register_hotkey(
|
||||||
|
hotkey::TITLE_SCREEN__CORES,
|
||||||
|
boost::bind(&hotkey, boost::ref(window), CORES));
|
||||||
|
|
||||||
window.register_hotkey(
|
window.register_hotkey(
|
||||||
hotkey::TITLE_SCREEN__EDITOR,
|
hotkey::TITLE_SCREEN__EDITOR,
|
||||||
boost::bind(&hotkey, boost::ref(window), START_MAP_EDITOR));
|
boost::bind(&hotkey, boost::ref(window), START_MAP_EDITOR));
|
||||||
|
|
|
@ -57,6 +57,7 @@ public:
|
||||||
,
|
,
|
||||||
LOAD_GAME,
|
LOAD_GAME,
|
||||||
GET_ADDONS,
|
GET_ADDONS,
|
||||||
|
CORES,
|
||||||
START_MAP_EDITOR,
|
START_MAP_EDITOR,
|
||||||
CHANGE_LANGUAGE,
|
CHANGE_LANGUAGE,
|
||||||
EDIT_PREFERENCES,
|
EDIT_PREFERENCES,
|
||||||
|
|
|
@ -505,6 +505,8 @@ twindow::tretval twindow::get_retval_by_id(const std::string& id)
|
||||||
return static_cast<tretval>(ttitle_screen::LOAD_GAME);
|
return static_cast<tretval>(ttitle_screen::LOAD_GAME);
|
||||||
} else if(id == "addons") {
|
} else if(id == "addons") {
|
||||||
return static_cast<tretval>(ttitle_screen::GET_ADDONS);
|
return static_cast<tretval>(ttitle_screen::GET_ADDONS);
|
||||||
|
} else if(id == "cores") {
|
||||||
|
return static_cast<tretval>(ttitle_screen::CORES);
|
||||||
} else if(id == "language") {
|
} else if(id == "language") {
|
||||||
return static_cast<tretval>(ttitle_screen::CHANGE_LANGUAGE);
|
return static_cast<tretval>(ttitle_screen::CHANGE_LANGUAGE);
|
||||||
} else if(id == "preferences") {
|
} else if(id == "preferences") {
|
||||||
|
|
|
@ -245,6 +245,7 @@ hotkey::hotkey_command_temp hotkey_list_[] = {
|
||||||
{ hotkey::TITLE_SCREEN__CAMPAIGN, "title_screen__campaign", N_("Start Campaign"), false , hotkey::SCOPE_MAIN_MENU, "" },
|
{ hotkey::TITLE_SCREEN__CAMPAIGN, "title_screen__campaign", N_("Start Campaign"), false , hotkey::SCOPE_MAIN_MENU, "" },
|
||||||
{ hotkey::TITLE_SCREEN__MULTIPLAYER, "title_screen__multiplayer", N_("Start Multiplayer Game"), false, hotkey::SCOPE_MAIN_MENU, "" },
|
{ hotkey::TITLE_SCREEN__MULTIPLAYER, "title_screen__multiplayer", N_("Start Multiplayer Game"), false, hotkey::SCOPE_MAIN_MENU, "" },
|
||||||
{ hotkey::TITLE_SCREEN__ADDONS, "title_screen__addons", N_("Manage Add-ons"), false , hotkey::SCOPE_MAIN_MENU, "" },
|
{ hotkey::TITLE_SCREEN__ADDONS, "title_screen__addons", N_("Manage Add-ons"), false , hotkey::SCOPE_MAIN_MENU, "" },
|
||||||
|
{ hotkey::TITLE_SCREEN__CORES, "title_screen__cores", N_("Manage Cores"), false , hotkey::SCOPE_MAIN_MENU, "" },
|
||||||
{ hotkey::TITLE_SCREEN__EDITOR, "title_screen__editor", N_("Start Editor"), false, hotkey::SCOPE_MAIN_MENU, "" },
|
{ hotkey::TITLE_SCREEN__EDITOR, "title_screen__editor", N_("Start Editor"), false, hotkey::SCOPE_MAIN_MENU, "" },
|
||||||
{ hotkey::TITLE_SCREEN__CREDITS, "title_screen__credits", N_("Show Credits"), false , hotkey::SCOPE_MAIN_MENU, "" },
|
{ hotkey::TITLE_SCREEN__CREDITS, "title_screen__credits", N_("Show Credits"), false , hotkey::SCOPE_MAIN_MENU, "" },
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ enum HOTKEY_COMMAND {
|
||||||
TITLE_SCREEN__CAMPAIGN,
|
TITLE_SCREEN__CAMPAIGN,
|
||||||
TITLE_SCREEN__MULTIPLAYER,
|
TITLE_SCREEN__MULTIPLAYER,
|
||||||
TITLE_SCREEN__ADDONS,
|
TITLE_SCREEN__ADDONS,
|
||||||
|
TITLE_SCREEN__CORES,
|
||||||
TITLE_SCREEN__EDITOR,
|
TITLE_SCREEN__EDITOR,
|
||||||
TITLE_SCREEN__CREDITS,
|
TITLE_SCREEN__CREDITS,
|
||||||
GLOBAL__HELPTIP,
|
GLOBAL__HELPTIP,
|
||||||
|
|
|
@ -232,6 +232,26 @@ void set_allied_color(const std::string& color_id) {
|
||||||
prefs["ally_orb_color"] = color_id;
|
prefs["ally_orb_color"] = color_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string wml_tree_root() {
|
||||||
|
std::string wml_tree_root = get("wml_tree_root");
|
||||||
|
if (wml_tree_root.empty())
|
||||||
|
return "_main.cfg";
|
||||||
|
return wml_tree_root;
|
||||||
|
}
|
||||||
|
void set_wml_tree_root(const std::string& wml_tree_root) {
|
||||||
|
prefs["wml_tree_root"] = wml_tree_root;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string core_id() {
|
||||||
|
std::string core_id = get("core");
|
||||||
|
if (core_id.empty())
|
||||||
|
return "default";
|
||||||
|
return core_id;
|
||||||
|
}
|
||||||
|
void set_core_id(const std::string& core_id) {
|
||||||
|
prefs["core"] = core_id;
|
||||||
|
}
|
||||||
|
|
||||||
std::string enemy_color() {
|
std::string enemy_color() {
|
||||||
std::string enemy_color = get("enemy_orb_color");
|
std::string enemy_color = get("enemy_orb_color");
|
||||||
if (enemy_color.empty())
|
if (enemy_color.empty())
|
||||||
|
|
|
@ -55,6 +55,12 @@ namespace preferences {
|
||||||
|
|
||||||
config* get_prefs();
|
config* get_prefs();
|
||||||
|
|
||||||
|
std::string wml_tree_root();
|
||||||
|
void set_wml_tree_root(const std::string& root);
|
||||||
|
|
||||||
|
std::string core_id();
|
||||||
|
void set_core_id(const std::string& root);
|
||||||
|
|
||||||
bool fullscreen();
|
bool fullscreen();
|
||||||
void _set_fullscreen(bool ison);
|
void _set_fullscreen(bool ison);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue