added a graphical front end to various mp commands, replacing the whisper dialog
This commit is contained in:
parent
87c5d1e929
commit
862030b806
7 changed files with 671 additions and 7 deletions
478
data/gui/default/window/mp_cmd_wrapper.cfg
Normal file
478
data/gui/default/window/mp_cmd_wrapper.cfg
Normal file
|
@ -0,0 +1,478 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### A graphical front-end to various commands in the multiplayer lobby
|
||||
###
|
||||
|
||||
[window]
|
||||
id = "mp_cmd_wrapper"
|
||||
description =_ "Multiplayer command wrapper 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"
|
||||
[label]
|
||||
definition = "title"
|
||||
|
||||
label = _ "Messaging"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
|
||||
label = _ "Message:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
|
||||
[text_box]
|
||||
id = "message"
|
||||
definition = "default"
|
||||
|
||||
label = ""
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "send_msg"
|
||||
definition = "default"
|
||||
|
||||
label = _ "Send a private message"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "top"
|
||||
border_size = 30
|
||||
[spacer]
|
||||
definition = "default"
|
||||
[/spacer]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[label]
|
||||
definition = "title"
|
||||
|
||||
label = _ "Friends/Ignored List"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "add_friend"
|
||||
|
||||
label = _ "Add As Friend"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "add_ignore"
|
||||
|
||||
label = _ "Add As Ignore"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "remove"
|
||||
|
||||
label = _ "Remove"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "top"
|
||||
border_size = 30
|
||||
[spacer]
|
||||
definition = "default"
|
||||
[/spacer]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[label]
|
||||
definition = "title"
|
||||
|
||||
label = _ "Moderating"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
|
||||
label = _ "Reason:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[text_box]
|
||||
id = "reason"
|
||||
definition = "default"
|
||||
|
||||
label = ""
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
|
||||
label = _ "Time:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[text_box]
|
||||
id = "time"
|
||||
definition = "default"
|
||||
|
||||
label = ""
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "status"
|
||||
|
||||
label = _ "Status"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "kick"
|
||||
|
||||
label = _ "Kick"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[button]
|
||||
definition = "default"
|
||||
id = "ban"
|
||||
|
||||
label = _ "Ban"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
border = "top"
|
||||
border_size = 30
|
||||
[spacer]
|
||||
definition = "default"
|
||||
[/spacer]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[label]
|
||||
definition = "default"
|
||||
id = "user_label"
|
||||
|
||||
label = ""
|
||||
[/label]
|
||||
|
||||
[/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]
|
|
@ -219,6 +219,7 @@ wesnoth_sources = Split("""
|
|||
gui/dialogs/mp_connect.cpp
|
||||
gui/dialogs/mp_create_game.cpp
|
||||
gui/dialogs/mp_method_selection.cpp
|
||||
gui/dialogs/mp_cmd_wrapper.cpp
|
||||
gui/dialogs/title_screen.cpp
|
||||
gui/dialogs/wml_message.cpp
|
||||
gui/widgets/button.cpp
|
||||
|
|
106
src/gui/dialogs/mp_cmd_wrapper.cpp
Normal file
106
src/gui/dialogs/mp_cmd_wrapper.cpp
Normal file
|
@ -0,0 +1,106 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2009 by Thomas Baumhauer <thomas.baumhauer@NOSPAMgmail.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/mp_cmd_wrapper.hpp"
|
||||
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/dialogs/field.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/*WIKI
|
||||
* @page = GUIWindowWML
|
||||
* @order = 2_mp_cmd_wrapper
|
||||
*
|
||||
* == Multiplayer command wrapper ==
|
||||
*
|
||||
* This shows a dialog that provides a graphical front-end
|
||||
* to various commands in the multiplayer lobby
|
||||
*
|
||||
* @start_table = container
|
||||
* message (text_box) Text to send as a private message
|
||||
* reason (text_box) The reason for a ban
|
||||
* time (text_box) The time the ban lasts
|
||||
* [send_message] (button) Execute /msg
|
||||
* [add_friend] (button) Execute /friend
|
||||
* [add_ignore] (button) Execute /ignore
|
||||
* [remove] (button) Execute /remove
|
||||
* [status] (button) Execute /query status
|
||||
* [kick] (button) Execute /query kick
|
||||
* [ban] (button) Execute /query kban
|
||||
* @end_table
|
||||
*/
|
||||
|
||||
tmp_cmd_wrapper::tmp_cmd_wrapper(const t_string& user) :
|
||||
message_(), reason_(), time_(), user_(user) { }
|
||||
|
||||
twindow* tmp_cmd_wrapper::build_window(CVideo& video)
|
||||
{
|
||||
return build(video, get_id(MP_CMD_WRAPPER));
|
||||
}
|
||||
|
||||
void tmp_cmd_wrapper::pre_show(CVideo& /*video*/, twindow& window)
|
||||
{
|
||||
ttext_box* message =
|
||||
dynamic_cast<ttext_box*>(window.find_widget("message", false));
|
||||
if(message) window.keyboard_capture(message);
|
||||
|
||||
tlabel* label =
|
||||
dynamic_cast<tlabel*>(window.find_widget("user_label", false));
|
||||
if(label) label->set_label(user_);
|
||||
|
||||
|
||||
tbutton* b =
|
||||
dynamic_cast<tbutton*>(window.find_widget("send_msg", false));
|
||||
if(b) b->set_retval(7);
|
||||
|
||||
b = dynamic_cast<tbutton*>(window.find_widget("add_friend", false));
|
||||
if(b) b->set_retval(1);
|
||||
|
||||
b = dynamic_cast<tbutton*>(window.find_widget("add_ignore", false));
|
||||
if(b) b->set_retval(2);
|
||||
|
||||
b = dynamic_cast<tbutton*>(window.find_widget("remove", false));
|
||||
if(b) b->set_retval(3);
|
||||
|
||||
b = dynamic_cast<tbutton*>(window.find_widget("status", false));
|
||||
if(b) b->set_retval(4);
|
||||
|
||||
b = dynamic_cast<tbutton*>(window.find_widget("kick", false));
|
||||
if(b) b->set_retval(5);
|
||||
|
||||
b = dynamic_cast<tbutton*>(window.find_widget("ban", false));
|
||||
if(b) b->set_retval(6);
|
||||
|
||||
}
|
||||
|
||||
void tmp_cmd_wrapper::post_show(twindow& window)
|
||||
{
|
||||
ttext_box* message =
|
||||
dynamic_cast<ttext_box*>(window.find_widget("message", false));
|
||||
message_ = message ? message_ = message->get_value() : "";
|
||||
|
||||
ttext_box* reason =
|
||||
dynamic_cast<ttext_box*>(window.find_widget("reason", false));
|
||||
reason_ = reason ? reason_ = reason->get_value() : "";
|
||||
|
||||
ttext_box* time =
|
||||
dynamic_cast<ttext_box*>(window.find_widget("time", false));
|
||||
time_ = time ? time_ = time->get_value() : "";
|
||||
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
52
src/gui/dialogs/mp_cmd_wrapper.hpp
Normal file
52
src/gui/dialogs/mp_cmd_wrapper.hpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2009 by Thomas Baumhauer <thomas.baumhauer@NOSPAMgmail.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_MP_CMD_WRAPPER_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_MP_CMD_WRAPPER_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
#include "tstring.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
class tmp_cmd_wrapper : public tdialog
|
||||
{
|
||||
public:
|
||||
tmp_cmd_wrapper(const t_string& user);
|
||||
|
||||
const std::string& message() const { return message_; }
|
||||
const std::string& reason() const { return reason_; }
|
||||
const std::string& time() const { return time_; }
|
||||
|
||||
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);
|
||||
|
||||
std::string message_;
|
||||
std::string reason_;
|
||||
std::string time_;
|
||||
|
||||
t_string user_;
|
||||
};
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif // GUI_DIALOGS_MP_CMD_WRAPPER_HPP_INCLUDED
|
||||
|
|
@ -73,6 +73,7 @@ static void fill_window_types()
|
|||
window_type_list[MP_METHOD_SELECTION] = "mp_method_selection";
|
||||
window_type_list[MP_SERVER_LIST] = "mp_server_list";
|
||||
window_type_list[MP_LOGIN] = "mp_login";
|
||||
window_type_list[MP_CMD_WRAPPER] = "mp_cmd_wrapper";
|
||||
window_type_list[MP_CREATE_GAME] = "mp_create_game";
|
||||
window_type_list[TITLE_SCREEN] = "title_screen";
|
||||
#ifndef DISABLE_EDITOR2
|
||||
|
|
|
@ -55,6 +55,7 @@ enum twindow_type {
|
|||
*/
|
||||
MP_SERVER_LIST, /**< The mp server list dialog. */
|
||||
MP_LOGIN, /**< The mp login dialog. */
|
||||
MP_CMD_WRAPPER, /**< graphical front-end to various mp commands*/
|
||||
MP_CREATE_GAME, /**< The mp creation dialog. */
|
||||
#ifndef DISABLE_EDITOR2
|
||||
EDITOR_NEW_MAP, /**< New map dialog. */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "construct_dialog.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "gui/dialogs/mp_cmd_wrapper.hpp"
|
||||
#include "log.hpp"
|
||||
#include "marked-up_text.hpp"
|
||||
#include "multiplayer_ui.hpp"
|
||||
|
@ -388,15 +389,39 @@ void ui::handle_event(const SDL_Event& event)
|
|||
}
|
||||
if(users_menu_.double_clicked()) {
|
||||
std::string usr_text = user_list_[users_menu_.selection()];
|
||||
std::string caption = _("Send a private message to ") + usr_text;
|
||||
gui::dialog d(disp(), _("Whisper"), caption, gui::OK_CANCEL);
|
||||
d.set_textbox( _("Message: "));
|
||||
Uint32 show_time = SDL_GetTicks();
|
||||
if (!(d.show() || d.textbox_text().empty())) {
|
||||
std::stringstream msg;
|
||||
msg << "/msg " << usr_text << ' ' << d.textbox_text();
|
||||
chat_handler::do_speak(msg.str());
|
||||
|
||||
gui2::tmp_cmd_wrapper dlg(_("Selected user: ") + usr_text);
|
||||
dlg.show(disp().video());
|
||||
|
||||
std::stringstream msg;
|
||||
switch(dlg.get_retval()) {
|
||||
case 1:
|
||||
msg << "/friend " << usr_text;
|
||||
break;
|
||||
case 2:
|
||||
msg << "/ignore " << usr_text;
|
||||
break;
|
||||
case 3:
|
||||
msg << "/remove " << usr_text;
|
||||
break;
|
||||
case 4:
|
||||
msg << "/query status " << usr_text;
|
||||
break;
|
||||
case 5:
|
||||
msg << "/query kick " << usr_text;
|
||||
break;
|
||||
case 6:
|
||||
msg << "/query kban " << usr_text;
|
||||
if(!dlg.time().empty()) msg << ' ' << dlg.time();
|
||||
if(!dlg.reason().empty()) msg << ' ' << dlg.reason();
|
||||
break;
|
||||
case 7:
|
||||
if(!dlg.message().empty()) msg << "/msg " << usr_text << ' ' << dlg.message();
|
||||
}
|
||||
|
||||
chat_handler::do_speak(msg.str());
|
||||
|
||||
if(show_time + 60000 < SDL_GetTicks()) {
|
||||
//if the dialog has been open for a long time, refresh the lobby
|
||||
config request;
|
||||
|
|
Loading…
Add table
Reference in a new issue