multiple fixes to friendlist, including tab completion

This commit is contained in:
Jérémy Rosen 2007-01-01 19:04:58 +00:00
parent 1283a41a1f
commit 145c33d11b
4 changed files with 43 additions and 20 deletions

View File

@ -1387,6 +1387,7 @@ void connect::update_playerlist_state(bool silent)
playerlist.push_back(itor->name);
}
set_user_list(playerlist, silent);
set_user_menu_items(playerlist);
}
}

View File

@ -23,6 +23,7 @@
#include "sound.hpp"
#include "video.hpp"
#include "replay.hpp"
#include "wml_separators.hpp"
#define LOG_NW LOG_STREAM(info, network)
#define ERR_NW LOG_STREAM(err, network)
@ -473,6 +474,7 @@ void ui::layout_children(const SDL_Rect& /*rect*/)
void ui::gamelist_updated(bool silent)
{
std::vector<std::string> user_strings;
std::vector<std::string> user_strings_;
config::child_list users = gamelist_.get_children("user");
config::child_iterator user;
@ -484,7 +486,6 @@ void ui::gamelist_updated(bool silent)
config* cignore;
cignore = preferences::get_prefs()->child("relationship");
char const COLUMN_SEPARATOR = '=', IMAGE_PREFIX = '&';
std::string const imgpre = IMAGE_PREFIX + std::string("misc/status-");
char const sep1 = COLUMN_SEPARATOR;
@ -499,9 +500,11 @@ void ui::gamelist_updated(bool silent)
suffix = std::string(" (") + (**user)["location"] + std::string(")");
}
if(preferences::iconize_list()) {
user_strings.push_back(imgpre + "friend.png" + sep1 + prefix + (**user)["name"].str() + suffix);
user_strings.push_back(prefix + (**user)["name"].str() + suffix);
user_strings_.push_back(imgpre + "friend.png" + sep1 + prefix + (**user)["name"].str() + suffix);
} else {
user_strings.push_back(prefix + (**user)["name"].str() + suffix);
user_strings_.push_back(prefix + (**user)["name"].str() + suffix);
}
}
}
@ -515,9 +518,11 @@ void ui::gamelist_updated(bool silent)
suffix = std::string(" (") + (**user)["location"] + std::string(")");
}
if(preferences::iconize_list()) {
user_strings.push_back(imgpre + "neutral.png" + sep1 + prefix + (**user)["name"].str() + suffix);
user_strings.push_back(prefix + (**user)["name"].str() + suffix);
user_strings_.push_back(imgpre + "neutral.png" + sep1 + prefix + (**user)["name"].str() + suffix);
} else {
user_strings.push_back(prefix + (**user)["name"].str() + suffix);
user_strings_.push_back(prefix + (**user)["name"].str() + suffix);
}
}
}
@ -531,9 +536,11 @@ void ui::gamelist_updated(bool silent)
suffix = std::string(" (") + (**user)["location"] + std::string(")");
}
if(preferences::iconize_list()) {
user_strings.push_back(imgpre + "ignore.png" + sep1 + prefix + (**user)["name"].str() + suffix);
user_strings.push_back(prefix + (**user)["name"].str() + suffix);
user_strings_.push_back(imgpre + "ignore.png" + sep1 + prefix + (**user)["name"].str() + suffix);
} else {
user_strings.push_back(prefix + (**user)["name"].str() + suffix);
user_strings_.push_back(prefix + (**user)["name"].str() + suffix);
}
}
}
@ -548,19 +555,29 @@ void ui::gamelist_updated(bool silent)
if(preferences::iconize_list()) {
std::string ig = std::string((**user)["name"]);
if((*cignore)[ig] == "ignored") {
user_strings.push_back(imgpre + "ignore.png" + sep1 + prefix + (**user)["name"].str() + suffix);
user_strings.push_back(prefix + (**user)["name"].str() + suffix);
user_strings_.push_back(imgpre + "ignore.png" + sep1 + prefix + (**user)["name"].str() + suffix);
} else if ((*cignore)[ig] == "friend") {
user_strings.push_back(imgpre + "friend.png" + sep1 + prefix + (**user)["name"].str() + suffix);
user_strings.push_back(prefix + (**user)["name"].str() + suffix);
user_strings_.push_back(imgpre + "friend.png" + sep1 + prefix + (**user)["name"].str() + suffix);
} else {
user_strings.push_back(imgpre + "neutral.png" + sep1 + prefix + (**user)["name"].str() + suffix);
user_strings.push_back(prefix + (**user)["name"].str() + suffix);
user_strings_.push_back(imgpre + "neutral.png" + sep1 + prefix + (**user)["name"].str() + suffix);
}
} else {
user_strings.push_back(prefix + (**user)["name"].str() + suffix);
user_strings_.push_back(prefix + (**user)["name"].str() + suffix);
}
}
}
set_user_list(user_strings, silent);
set_user_menu_items(user_strings_);
}
void ui::set_user_menu_items(const std::vector<std::string>& list)
{
users_menu_.set_items(list,true,true);
}
void ui::set_user_list(const std::vector<std::string>& list, bool silent)
@ -574,8 +591,6 @@ void ui::set_user_list(const std::vector<std::string>& list, bool silent)
}
user_list_ = list;
users_menu_.set_items(user_list_,true,true);
}
const gui::widget& ui::title() const

View File

@ -151,6 +151,7 @@ protected:
// Sets the user list
void set_user_list(const std::vector<std::string>&, bool silent);
void set_user_menu_items(const std::vector<std::string>& list);
// Returns the current gamelist
config& gamelist() { return gamelist_; };

View File

@ -710,18 +710,24 @@ bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
if(preferences::message_bell()) {
sound::play_sound(game_config::sounds::receive_message);
}
std::string str = (*child)["message"];
std::string buf;
std::stringstream ss(str);
ss >> buf;
if (!preferences::get_prefs()->child("relationship")){
preferences::get_prefs()->add_child("relationship");
}
config* cignore;
cignore = preferences::get_prefs()->child("relationship");
if (is_lobby_join) {
std::string str = (*child)["message"];
std::string buf;
std::stringstream ss(str);
ss >> buf;
if (!preferences::get_prefs()->child("relationship")){
preferences::get_prefs()->add_child("relationship");
}
config* cignore;
cignore = preferences::get_prefs()->child("relationship");
if ((*cignore)[buf] == "friend") {
if ((*cignore)[buf] == "friend") {
const int side = lexical_cast_default<int>((*child)["side"].c_str(),0);
disp.add_chat_message(speaker_name,side,(*child)["message"],
team_name == "" ? display::MESSAGE_PUBLIC : display::MESSAGE_PRIVATE);
}
} else {
const int side = lexical_cast_default<int>((*child)["side"].c_str(),0);
disp.add_chat_message(speaker_name,side,(*child)["message"],
team_name == "" ? display::MESSAGE_PUBLIC : display::MESSAGE_PRIVATE);