Author: alink
Date: Thu Jul 10 02:21:31 2008
New Revision: 27882
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27882&view=rev
Log:
Team-color faction images in MP lobby, now all images are team-colored there.
This add a new key "image" allowing to kill the ugly hack which inserted image
url in the "name" key. This hack is still supported but not team-colored.
Fix a bug about replacing faction by the leader image only when using the hack.
Data changed in the next commit.
Modified:
trunk/src/multiplayer_connect.cpp
trunk/src/multiplayer_connect.hpp
trunk/src/multiplayer_wait.cpp
Modified: trunk/src/multiplayer_connect.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_connect.cpp?rev=27882&r1=27881&r2=27882&view=diff
==============================================================================
--- trunk/src/multiplayer_connect.cpp (original)
+++ trunk/src/multiplayer_connect.cpp Thu Jul 10 02:21:31 2008
@@ -29,6 +29,7 @@
#include "statistics.hpp"
#include "show_dialog.hpp"
#include "serialization/string_utils.hpp"
+#include "wml_separators.hpp"
#include <cassert>
#include <boost/bind.hpp>
@@ -72,7 +73,7 @@
combo_controller_(parent.disp(), parent.player_types_),
orig_controller_(parent.video(), current_player_, font::SIZE_SMALL),
combo_ai_algorithm_(parent.disp(), std::vector<std::string>()),
- combo_faction_(parent.disp(), parent.player_factions_),
+ combo_faction_(parent.disp(), std::vector<std::string>()),
combo_leader_(parent.disp(), std::vector<std::string>()),
combo_gender_(parent.disp(), std::vector<std::string>()),
combo_team_(parent.disp(), parent.player_teams_),
@@ -146,6 +147,8 @@
colour_ = game_config::color_info(cfg_["colour"]).index() - 1;
}
llm_.set_colour(colour_);
+
+ update_faction_combo();
config *ai = cfg_.child("ai");
if (ai)
@@ -447,6 +450,7 @@
if (combo_colour_.changed() && combo_colour_.selected() >= 0) {
colour_ = combo_colour_.selected();
llm_.set_colour(colour_);
+ update_faction_combo();
llm_.set_leader_combo(&combo_leader_);
llm_.set_gender_combo(&combo_gender_);
changed_ = true;
@@ -572,6 +576,23 @@
}
combo_ai_algorithm_.set_items(ais);
combo_ai_algorithm_.set_selected(sel);
+}
+
+void connect::side::update_faction_combo()
+{
+ std::vector<std::string> factions;
+ for(std::vector<config*>::const_iterator faction =
parent_->era_sides_.begin();
+ faction != parent_->era_sides_.end(); ++faction) {
+ const std::string& name = (**faction)["name"];
+ const std::string& icon = (**faction)["image"];
+ if (!icon.empty()) {
+ factions.push_back(IMAGE_PREFIX + icon + "~RC(magenta>"
+ lexical_cast<std::string>(colour_+1) + ")" + COLUMN_SEPARATOR + name);
+ } else {
+ factions.push_back(name);
+ }
+ }
+ combo_faction_.set_items(factions);
+ combo_faction_.set_selected(faction_);
}
void connect::side::update_ui()
Modified: trunk/src/multiplayer_connect.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_connect.hpp?rev=27882&r1=27881&r2=27882&view=diff
==============================================================================
--- trunk/src/multiplayer_connect.hpp (original)
+++ trunk/src/multiplayer_connect.hpp Thu Jul 10 02:21:31 2008
@@ -104,6 +104,8 @@
private:
void init_ai_algorithm_combo();
void update_ai_algorithm_combo()
{hide_ai_algorithm_combo(parent_->hidden());}
+ //! Fill or refresh the faction combo using the proper team
color
+ void update_faction_combo();
void update_controller_ui();
void update_ui();
Modified: trunk/src/multiplayer_wait.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_wait.cpp?rev=27882&r1=27881&r2=27882&view=diff
==============================================================================
--- trunk/src/multiplayer_wait.cpp (original)
+++ trunk/src/multiplayer_wait.cpp Thu Jul 10 02:21:31 2008
@@ -273,18 +273,26 @@
throw config::error(_("No multiplayer sides
found"));
return;
}
-
- std::vector<std::string> choices;
- for(config::child_list::const_iterator side =
- possible_sides.begin(); side !=
- possible_sides.end(); ++side) {
- choices.push_back((**side)["name"]);
- }
-
+
int color = side_choice;
const std::string color_str =
(*sides_list[side_choice])["colour"];
if (!color_str.empty())
color =
game_config::color_info(color_str).index() - 1;
+
+ std::vector<std::string> choices;
+ for(config::child_list::const_iterator side =
+ possible_sides.begin(); side !=
+ possible_sides.end(); ++side)
+ {
+ const std::string& name = (**side)["name"];
+ const std::string& icon = (**side)["image"];
+ if (!icon.empty()) {
+ choices.push_back(IMAGE_PREFIX + icon +
"~RC(magenta>" +
+
lexical_cast<std::string>(color+1) + ")" + COLUMN_SEPARATOR + name);
+ } else {
+ choices.push_back(name);
+ }
+ }
std::vector<gui::preview_pane* > preview_panes;
leader_preview_pane leader_selector(disp(),
@@ -501,6 +509,10 @@
if(p != std::string::npos && p <
side_name.size()) {
side_name = IMAGE_PREFIX + leader_image
+ COLUMN_SEPARATOR + side_name.str().substr(p+1);
}
+ } else {
+ // no image prefix, just add the leader image
+ // (assuming that there is also no
COLUMN_SEPARATOR)
+ side_name = IMAGE_PREFIX + leader_image +
COLUMN_SEPARATOR + side_name.str();
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits