added code to update the new lobby playerlist...

...when a user is ignored via a /command
This commit is contained in:
Tomasz Śniatowski 2009-07-23 19:39:23 +01:00
parent 271c53bd0a
commit 4fdd84b904
5 changed files with 42 additions and 12 deletions

View file

@ -43,7 +43,6 @@ protected:
virtual void send_whisper(const std::string& receiver, const std::string& message);
virtual void add_whisper_sent(const std::string& receiver, const std::string& message);
virtual void add_whisper_received(const std::string& sender, const std::string& message);
@ -55,6 +54,12 @@ protected:
virtual void add_chat_room_message_received(const std::string& room,
const std::string& speaker, const std::string& message);
/**
* Called when a processed command results in a relation (friend/ignore) change
* for a user whose name is passed as the 'name' arg
*/
virtual void user_relation_changed(const std::string& name);
void change_logging(const std::string& data);
friend class chat_command_handler;

View file

@ -124,6 +124,11 @@ void tlobby_main::send_chat_message(const std::string& message, bool /*allies_on
network::send_data(data, 0, true);
}
void tlobby_main::user_relation_changed(const std::string& /*name*/)
{
player_list_dirty_ = true;
}
void tlobby_main::add_chat_message(const time_t& /*time*/, const std::string& speaker,
int /*side*/, const std::string& message, events::chat_handler::MESSAGE_TYPE /*type*/)
{
@ -247,7 +252,7 @@ tlobby_main::tlobby_main(const config& game_config, lobby_info& info)
, chat_input_(NULL), window_(NULL)
, lobby_info_(info), preferences_callback_(NULL)
, open_windows_(), active_window_(0), selected_game_id_()
, player_list_()
, player_list_(), player_list_dirty_(false)
{
}
@ -369,7 +374,10 @@ void tlobby_main::update_gamelist()
}
}
update_selected_game();
}
void tlobby_main::update_playerlist()
{
lobby_info_.update_user_statuses(selected_game_id_, active_window_room());
lobby_info_.sort_users(player_list_.sort_by_name->get_value(), player_list_.sort_by_relation->get_value());
@ -452,6 +460,7 @@ void tlobby_main::update_gamelist()
player_list_.other_games.auto_hide();
window_->invalidate_layout();
player_list_dirty_ = false;
}
void tlobby_main::update_selected_game()
@ -468,6 +477,7 @@ void tlobby_main::update_selected_game()
}
window_->get_widget<tbutton>("observe_global", false).set_active(can_observe);
window_->get_widget<tbutton>("join_global", false).set_active(can_join);
update_playerlist();
}
void tlobby_main::pre_show(CVideo& /*video*/, twindow& window)
@ -683,7 +693,7 @@ void tlobby_main::active_window_changed()
<< header.label() << " vs " << t.name << "\n";
}
}
window_->invalidate_layout();
update_playerlist();
}
@ -924,6 +934,7 @@ void tlobby_main::send_message_button_callback(gui2::twindow &/*window*/)
// opened window, so e.g. /ignore in a whisper session ignores
// the other party without having to specify it's nick.
chat_handler::do_speak(input);
if (player_list_dirty_) update_gamelist();
} else {
config msg;
send_message_to_active_window(input);
@ -1060,6 +1071,7 @@ void tlobby_main::user_dialog_callback(user_info* info)
tlobby_chat_window* t = whisper_window_open(info->name, true);
switch_to_window(t);
}
update_gamelist();
}
} // namespace gui2

View file

@ -83,6 +83,8 @@ public:
void update_gamelist();
void update_playerlist();
enum legacy_result { QUIT, JOIN, OBSERVE, CREATE, PREFERENCES };
legacy_result get_legacy_result() const { return legacy_result_; }
@ -105,6 +107,8 @@ protected:
/** inherited form chat_handler */
virtual void send_chat_message(const std::string& message, bool /*allies_only*/);
virtual void user_relation_changed(const std::string& name);
/** inherited form chat_handler */
virtual void add_chat_message(const time_t& time, const std::string& speaker,
int side, const std::string& message,
@ -341,6 +345,8 @@ private:
int selected_game_id_;
tplayer_list player_list_;
bool player_list_dirty_;
};
} // namespace gui2

View file

@ -108,15 +108,6 @@ user_info::user_info(const config& c)
, registered(utils::string_bool(c["registered"]))
, observing(c["status"] == "observing")
{
if (name == preferences::login()) {
relation = ME;
} else if (preferences::is_ignored(name)) {
relation = IGNORED;
} else if (preferences::is_friend(name)) {
relation = FRIEND;
} else {
relation = NEUTRAL;
}
}
void user_info::update_state(int selected_game_id, const room_info* current_room /*= NULL*/)
@ -134,6 +125,15 @@ void user_info::update_state(int selected_game_id, const room_info* current_room
state = LOBBY;
}
}
if (name == preferences::login()) {
relation = ME;
} else if (preferences::is_ignored(name)) {
relation = IGNORED;
} else if (preferences::is_friend(name)) {
relation = FRIEND;
} else {
relation = NEUTRAL;
}
}

View file

@ -2439,6 +2439,10 @@ private:
cch.dispatch(cmd);
}
void chat_handler::user_relation_changed(const std::string& name)
{
}
void chat_handler::send_whisper(const std::string& receiver, const std::string& message)
{
config cwhisper, data;
@ -2546,6 +2550,7 @@ private:
for(int i = 1; !get_arg(i).empty(); i++){
if (preferences::add_ignore(get_arg(i))) {
print("ignore", _("Added to ignore list: ") + get_arg(i));
chat_handler_.user_relation_changed(get_arg(i));
} else {
command_failed(_("Invalid username: ") + get_arg(i));
}
@ -2561,6 +2566,7 @@ private:
} else {
for(int i = 1;!get_arg(i).empty();i++){
if (preferences::add_friend(get_arg(i))) {
chat_handler_.user_relation_changed(get_arg(i));
print("friend", _("Added to friends list: ") + get_arg(i));
} else {
command_failed(_("Invalid username: ") + get_arg(i));
@ -2574,6 +2580,7 @@ private:
for(int i = 1;!get_arg(i).empty();i++){
preferences::remove_friend(get_arg(i));
preferences::remove_ignore(get_arg(i));
chat_handler_.user_relation_changed(get_arg(i));
print("list", _("Removed from list: ") + get_arg(i));
}
}