add a player info dialog that pops up on doubleclick...
...on newlobby's player list. Similar to the old lobby dialog.
This commit is contained in:
parent
638daadac6
commit
0d8e99d925
12 changed files with 520 additions and 2 deletions
|
@ -231,6 +231,7 @@
|
|||
[column]
|
||||
horizontal_grow = "true"
|
||||
[toggle_panel]
|
||||
id = "userpanel"
|
||||
definition = "default"
|
||||
[grid]
|
||||
[row]
|
||||
|
|
198
data/gui/default/window/lobby_player_info.cfg
Normal file
198
data/gui/default/window/lobby_player_info.cfg
Normal file
|
@ -0,0 +1,198 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### Definition of the lobby player info dialog
|
||||
###
|
||||
|
||||
[window]
|
||||
id = "lobby_player_info"
|
||||
description = "Lobby player info dialog."
|
||||
|
||||
[resolution]
|
||||
definition = "default"
|
||||
|
||||
automatic_placement = "true"
|
||||
vertical_placement = "center"
|
||||
horizontal_placement = "center"
|
||||
|
||||
[grid]
|
||||
[row]
|
||||
grow_factor = 0
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
[label]
|
||||
definition = "title"
|
||||
label = _ "Player Info - "
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
[label]
|
||||
definition = "title"
|
||||
id = "player_name"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[label]
|
||||
definition = "default"
|
||||
id = "location_info"
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
horizontal_alignment = "right"
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "start_whisper"
|
||||
label = _ "Send private message"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
horizontal_alignment = "center"
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[label]
|
||||
definition = "default"
|
||||
id = "relation_info"
|
||||
label = ""
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "add_to_friends"
|
||||
label = _ "Add to friends list"
|
||||
[/button]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "add_to_ignores"
|
||||
label = _ "Add to ignores list"
|
||||
[/button]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "remove_from_list"
|
||||
label = _ "Remove from list"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[grid]
|
||||
id = "admin"
|
||||
[row]
|
||||
[column]
|
||||
[label]
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
horizontal_alignment = "center"
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "Moderation"
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "check_status"
|
||||
label = _ "Check status"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
[label]
|
||||
label = _ "Kick / ban reason:"
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
[text_box]
|
||||
definition = "default"
|
||||
id = "reason"
|
||||
[/text_box]
|
||||
[/column]
|
||||
[column]
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "kick"
|
||||
label = _ "Kick"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
[label]
|
||||
label = _ "Ban time:"
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
[text_box]
|
||||
definition = "default"
|
||||
id = "time"
|
||||
[/text_box]
|
||||
[/column]
|
||||
[column]
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "kick_ban"
|
||||
label = _ "Kick/ban"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "cancel"
|
||||
label = _ "Close"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/resolution]
|
||||
[/window]
|
|
@ -1979,6 +1979,34 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\lobby_player_info.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Gui\Dialogs\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Gui\Dialogs\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug (fast)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Gui\Dialogs\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\message.cpp"
|
||||
>
|
||||
|
@ -5074,6 +5102,10 @@
|
|||
RelativePath="..\..\src\gui\dialogs\lobby_main.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\lobby_player_info.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\message.hpp"
|
||||
>
|
||||
|
|
|
@ -298,6 +298,7 @@ SET(wesnoth-main_SRC
|
|||
gui/dialogs/game_save.cpp
|
||||
gui/dialogs/language_selection.cpp
|
||||
gui/dialogs/lobby_main.cpp
|
||||
gui/dialogs/lobby_player_info.cpp
|
||||
gui/dialogs/message.cpp
|
||||
gui/dialogs/mp_connect.cpp
|
||||
gui/dialogs/mp_create_game.cpp
|
||||
|
|
|
@ -122,6 +122,7 @@ wesnoth_source = \
|
|||
gui/dialogs/game_save.cpp \
|
||||
gui/dialogs/language_selection.cpp \
|
||||
gui/dialogs/lobby_main.cpp \
|
||||
gui/dialogs/lobby_player_info.cpp \
|
||||
gui/dialogs/message.cpp \
|
||||
gui/dialogs/mp_connect.cpp \
|
||||
gui/dialogs/mp_create_game.cpp \
|
||||
|
|
|
@ -280,6 +280,7 @@ wesnoth_sources = Split("""
|
|||
gui/dialogs/game_save.cpp
|
||||
gui/dialogs/language_selection.cpp
|
||||
gui/dialogs/lobby_main.cpp
|
||||
gui/dialogs/lobby_player_info.cpp
|
||||
gui/dialogs/message.cpp
|
||||
gui/dialogs/mp_connect.cpp
|
||||
gui/dialogs/mp_create_game.cpp
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/lobby_main.hpp"
|
||||
#include "gui/dialogs/lobby_player_info.hpp"
|
||||
#include "gui/dialogs/field.hpp"
|
||||
#include "gui/dialogs/helper.hpp"
|
||||
|
||||
|
@ -382,9 +383,9 @@ void tlobby_main::update_gamelist()
|
|||
player_list_.active_room.list->clear();
|
||||
player_list_.other_rooms.list->clear();
|
||||
player_list_.other_games.list->clear();
|
||||
foreach (const user_info* userptr, lobby_info_.users_sorted())
|
||||
foreach (user_info* userptr, lobby_info_.users_sorted())
|
||||
{
|
||||
const user_info& user = *userptr;
|
||||
user_info& user = *userptr;
|
||||
tsub_player_list* target_list(NULL);
|
||||
std::map<std::string, string_map> data;
|
||||
std::stringstream icon_ss;
|
||||
|
@ -440,6 +441,10 @@ void tlobby_main::update_gamelist()
|
|||
tgrid* grid = target_list->list->get_row_grid(target_list->list->get_item_count() - 1);
|
||||
tlabel& name_label = grid->get_widget<tlabel>("player", false);
|
||||
name_label.set_markup_mode(tcontrol::PANGO_MARKUP);
|
||||
ttoggle_panel& panel = grid->get_widget<ttoggle_panel>("userpanel", false);
|
||||
panel.set_callback_mouse_left_double_click(boost::bind(
|
||||
&tlobby_main::user_dialog_callback, this, userptr));
|
||||
|
||||
}
|
||||
player_list_.active_game.auto_hide();
|
||||
player_list_.active_room.auto_hide();
|
||||
|
@ -1047,4 +1052,14 @@ void tlobby_main::player_filter_callback(gui2::twidget* /*widget*/)
|
|||
update_gamelist();
|
||||
}
|
||||
|
||||
void tlobby_main::user_dialog_callback(user_info* info)
|
||||
{
|
||||
tlobby_player_info dlg(*this, *info, lobby_info_);
|
||||
dlg.show(window_->video());
|
||||
if (dlg.result_open_whisper()) {
|
||||
tlobby_chat_window* t = whisper_window_open(info->name, true);
|
||||
switch_to_window(t);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
|
|
@ -295,6 +295,8 @@ private:
|
|||
|
||||
void player_filter_callback(twidget* widget);
|
||||
|
||||
void user_dialog_callback(user_info* info);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
twindow* build_window(CVideo& video);
|
||||
|
||||
|
|
176
src/gui/dialogs/lobby_player_info.cpp
Normal file
176
src/gui/dialogs/lobby_player_info.cpp
Normal file
|
@ -0,0 +1,176 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2009 by Tomasz Sniatowski <kailoran@gmail.com>
|
||||
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 version 2
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "gui/dialogs/helper.hpp"
|
||||
#include "gui/dialogs/lobby_player_info.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
|
||||
#include "game_preferences.hpp"
|
||||
#include "gettext.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
tlobby_player_info::tlobby_player_info(events::chat_handler& chat, user_info& info, const lobby_info& li)
|
||||
: chat_(chat), info_(info), reason_(NULL), time_(NULL), relation_(NULL),
|
||||
add_to_friends_(NULL), add_to_ignores_(NULL), remove_from_list_(NULL),
|
||||
result_open_whisper_(false), lobby_info_(li)
|
||||
{
|
||||
}
|
||||
|
||||
tlobby_player_info::~tlobby_player_info()
|
||||
{
|
||||
}
|
||||
|
||||
twindow* tlobby_player_info::build_window(CVideo& video)
|
||||
{
|
||||
return build(video, get_id(LOBBY_PLAYER_INFO));
|
||||
}
|
||||
|
||||
void tlobby_player_info::pre_show(CVideo& video, twindow& window)
|
||||
{
|
||||
relation_ = &window.get_widget<tlabel>("relation_info", false);
|
||||
GUI2_EASY_BUTTON_CALLBACK(start_whisper, tlobby_player_info);
|
||||
|
||||
GUI2_EASY_BUTTON_CALLBACK(add_to_friends, tlobby_player_info);
|
||||
GUI2_EASY_BUTTON_CALLBACK(add_to_ignores, tlobby_player_info);
|
||||
GUI2_EASY_BUTTON_CALLBACK(remove_from_list, tlobby_player_info);
|
||||
add_to_friends_ = add_to_friends_btn;
|
||||
add_to_ignores_ = add_to_ignores_btn;
|
||||
remove_from_list_ = remove_from_list_btn;
|
||||
|
||||
GUI2_EASY_BUTTON_CALLBACK(check_status, tlobby_player_info);
|
||||
GUI2_EASY_BUTTON_CALLBACK(kick, tlobby_player_info);
|
||||
GUI2_EASY_BUTTON_CALLBACK(kick_ban, tlobby_player_info);
|
||||
|
||||
window.get_widget<tlabel>("player_name", false).set_label(info_.name);
|
||||
|
||||
std::stringstream loc;
|
||||
const game_info* game = lobby_info_.get_game_by_id(info_.game_id);
|
||||
if (game != NULL) {
|
||||
loc << _("In game:") << " " << game->name << " ";
|
||||
if (info_.observing) {
|
||||
loc << _("(observing)");
|
||||
} else {
|
||||
loc << _("(playing)");
|
||||
}
|
||||
} else {
|
||||
loc << _("In lobby");
|
||||
}
|
||||
|
||||
window.get_widget<tlabel>("location_info", false).set_label(loc.str());
|
||||
update_relation(window);
|
||||
|
||||
if (!preferences::is_authenticated()) {
|
||||
twidget* aw = window.find_widget("admin", false);
|
||||
aw->set_visible(twidget::INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
void tlobby_player_info::post_show(twindow& /*window*/)
|
||||
{
|
||||
}
|
||||
|
||||
void tlobby_player_info::update_relation(twindow& w)
|
||||
{
|
||||
add_to_friends_->set_active(false);
|
||||
add_to_ignores_->set_active(false);
|
||||
remove_from_list_->set_active(false);
|
||||
switch (info_.relation) {
|
||||
case user_info::FRIEND:
|
||||
relation_->set_label("On friends list");
|
||||
add_to_ignores_->set_active(true);
|
||||
remove_from_list_->set_active(true);
|
||||
break;
|
||||
case user_info::IGNORED:
|
||||
relation_->set_label("On ignores list");
|
||||
add_to_friends_->set_active(true);
|
||||
remove_from_list_->set_active(true);
|
||||
break;
|
||||
case user_info::NEUTRAL:
|
||||
relation_->set_label("Neither a friend nor ignored");
|
||||
add_to_friends_->set_active(true);
|
||||
add_to_ignores_->set_active(true);
|
||||
break;
|
||||
case user_info::ME:
|
||||
relation_->set_label("You");
|
||||
break;
|
||||
default:
|
||||
relation_->set_label("Error");
|
||||
}
|
||||
w.invalidate_layout();
|
||||
}
|
||||
|
||||
void tlobby_player_info::add_to_friends_button_callback(twindow& w)
|
||||
{
|
||||
preferences::add_friend(info_.name);
|
||||
info_.relation = user_info::FRIEND;
|
||||
update_relation(w);
|
||||
}
|
||||
|
||||
void tlobby_player_info::add_to_ignores_button_callback(twindow& w)
|
||||
{
|
||||
preferences::add_ignore(info_.name);
|
||||
info_.relation = user_info::IGNORED;
|
||||
update_relation(w);
|
||||
}
|
||||
|
||||
void tlobby_player_info::remove_from_list_button_callback(twindow& w)
|
||||
{
|
||||
preferences::remove_friend(info_.name);
|
||||
preferences::remove_ignore(info_.name);
|
||||
info_.relation = user_info::NEUTRAL;
|
||||
update_relation(w);
|
||||
}
|
||||
|
||||
void tlobby_player_info::start_whisper_button_callback(twindow& w)
|
||||
{
|
||||
result_open_whisper_ = true;
|
||||
w.close();
|
||||
}
|
||||
|
||||
void tlobby_player_info::check_status_button_callback(twindow& w)
|
||||
{
|
||||
chat_.send_command("query", "status " + info_.name);
|
||||
w.close();
|
||||
}
|
||||
|
||||
void tlobby_player_info::kick_button_callback(twindow& w)
|
||||
{
|
||||
do_kick_ban(false);
|
||||
w.close();
|
||||
}
|
||||
|
||||
void tlobby_player_info::kick_ban_button_callback(twindow& w)
|
||||
{
|
||||
do_kick_ban(true);
|
||||
w.close();
|
||||
}
|
||||
|
||||
void tlobby_player_info::do_kick_ban(bool ban)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << (ban ? "kban" : "kick ") << info_.name;
|
||||
if (ban && !time_->get_value().empty()) {
|
||||
ss << " " << time_->get_value();
|
||||
}
|
||||
if (!reason_->get_value().empty()) {
|
||||
ss << " " << reason_->get_value();
|
||||
}
|
||||
|
||||
chat_.send_command("query", ss.str());
|
||||
}
|
||||
|
||||
} //end namespace gui2
|
89
src/gui/dialogs/lobby_player_info.hpp
Normal file
89
src/gui/dialogs/lobby_player_info.hpp
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2009 by Tomasz Sniatowski <kailoran@gmail.com>
|
||||
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 version 2
|
||||
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_LOBBY_PLAYER_INFO_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_LOBBY_PLAYER_INFO_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
#include "config.hpp"
|
||||
#include "chat_events.hpp"
|
||||
#include "lobby_data.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
class tbutton;
|
||||
class tlabel;
|
||||
class ttext_box;
|
||||
|
||||
class tlobby_player_info : public tdialog
|
||||
{
|
||||
public:
|
||||
tlobby_player_info(events::chat_handler& chat, user_info& info, const lobby_info& li);
|
||||
|
||||
~tlobby_player_info();
|
||||
|
||||
bool result_open_whisper() const { return result_open_whisper_; }
|
||||
|
||||
private:
|
||||
/** Inherited from tdialog. */
|
||||
twindow* build_window(CVideo& video);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void post_show(twindow& window);
|
||||
|
||||
void update_relation(twindow& w);
|
||||
|
||||
void add_to_friends_button_callback(twindow& w);
|
||||
|
||||
void add_to_ignores_button_callback(twindow& w);
|
||||
|
||||
void remove_from_list_button_callback(twindow& w);
|
||||
|
||||
void start_whisper_button_callback(twindow& w);
|
||||
|
||||
void check_status_button_callback(twindow& w);
|
||||
|
||||
void kick_button_callback(twindow& w);
|
||||
|
||||
void kick_ban_button_callback(twindow& w);
|
||||
|
||||
void do_kick_ban(bool ban);
|
||||
|
||||
events::chat_handler& chat_;
|
||||
|
||||
user_info& info_;
|
||||
|
||||
ttext_box* reason_;
|
||||
|
||||
ttext_box* time_;
|
||||
|
||||
tlabel* relation_;
|
||||
|
||||
tbutton* add_to_friends_;
|
||||
|
||||
tbutton* add_to_ignores_;
|
||||
|
||||
tbutton* remove_from_list_;
|
||||
|
||||
bool result_open_whisper_;
|
||||
|
||||
const lobby_info& lobby_info_;
|
||||
};
|
||||
|
||||
} //end namespace gui2
|
||||
|
||||
#endif
|
|
@ -100,6 +100,7 @@ static void fill_window_types()
|
|||
window_type_list[EDITOR_SETTINGS] = "editor_settings";
|
||||
#endif
|
||||
window_type_list[LOBBY_MAIN] = "lobby_main";
|
||||
window_type_list[LOBBY_PLAYER_INFO] = "lobby_player_info";
|
||||
}
|
||||
|
||||
const std::string& get_id(const twindow_type window_type)
|
||||
|
|
|
@ -73,6 +73,7 @@ enum twindow_type {
|
|||
GAME_SAVE_MESSAGE, /**< Save game dialog with additional message. */
|
||||
GAME_SAVE_OOS, /**< Save game dialog for processing OOS. */
|
||||
LOBBY_MAIN, /**< Main MP lobby screen */
|
||||
LOBBY_PLAYER_INFO, /**< MP lobby player info dialog */
|
||||
COUNT /**<
|
||||
* The last one to hold the number of items and as
|
||||
* sentinel.
|
||||
|
|
Loading…
Add table
Reference in a new issue