summaryrefslogtreecommitdiff
path: root/src/network/network_chat_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-11-14 22:50:35 +0000
committerfrosch <frosch@openttd.org>2012-11-14 22:50:35 +0000
commitf5d8ba5d7f90abc72db6c0470da383ecf82da487 (patch)
tree3dbbbbe18733005c5851251dac62314d871b2b30 /src/network/network_chat_gui.cpp
parentdcfb2af871b76a7b65fb959b2f4ebc2da2f9e4d3 (diff)
downloadopenttd-f5d8ba5d7f90abc72db6c0470da383ecf82da487.tar.xz
(svn r24742) -Codechange: Remove QueryStringBaseWindow and store QueryStrings per widget instead.
Diffstat (limited to 'src/network/network_chat_gui.cpp')
-rw-r--r--src/network/network_chat_gui.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index 36eb9a68d..dca244a37 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -284,10 +284,11 @@ static void SendChat(const char *buf, DestType type, int dest)
}
/** Window to enter the chat message in. */
-struct NetworkChatWindow : public QueryStringBaseWindow {
+struct NetworkChatWindow : public Window {
DestType dtype; ///< The type of destination.
StringID dest_string; ///< String representation of the destination.
int dest; ///< The identifier of the destination.
+ QueryString message_editbox; ///< Message editbox.
/**
* Create a chat input window.
@@ -295,13 +296,14 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
* @param type The type of destination.
* @param dest The actual destination index.
*/
- NetworkChatWindow(const WindowDesc *desc, DestType type, int dest) : QueryStringBaseWindow(NETWORK_CHAT_LENGTH)
+ NetworkChatWindow(const WindowDesc *desc, DestType type, int dest) : message_editbox(NETWORK_CHAT_LENGTH)
{
this->dtype = type;
this->dest = dest;
- this->cancel_button = WID_NC_CLOSE;
- this->ok_button = WID_NC_SENDBUTTON;
- this->afilter = CS_ALPHANUMERAL;
+ this->querystrings[WID_NC_TEXTBOX] = &this->message_editbox;
+ this->message_editbox.cancel_button = WID_NC_CLOSE;
+ this->message_editbox.ok_button = WID_NC_SENDBUTTON;
+ this->message_editbox.afilter = CS_ALPHANUMERAL;
static const StringID chat_captions[] = {
STR_NETWORK_CHAT_ALL_CAPTION,
@@ -383,9 +385,9 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
void ChatTabCompletion()
{
static char _chat_tab_completion_buf[NETWORK_CHAT_LENGTH];
- assert(this->text.max_bytes == lengthof(_chat_tab_completion_buf));
+ assert(this->message_editbox.text.max_bytes == lengthof(_chat_tab_completion_buf));
- Textbuf *tb = &this->text;
+ Textbuf *tb = &this->message_editbox.text;
size_t len, tb_len;
uint item;
char *tb_buf, *pre_buf;
@@ -437,9 +439,9 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
/* Change to the found name. Add ': ' if we are at the start of the line (pretty) */
if (pre_buf == tb_buf) {
- this->text.Print("%s: ", cur_name);
+ this->message_editbox.text.Print("%s: ", cur_name);
} else {
- this->text.Print("%s %s", pre_buf, cur_name);
+ this->message_editbox.text.Print("%s %s", pre_buf, cur_name);
}
this->SetDirty();
@@ -450,7 +452,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
if (second_scan) {
/* We walked all posibilities, and the user presses tab again.. revert to original text */
- this->text.Assign(_chat_tab_completion_buf);
+ this->message_editbox.text.Assign(_chat_tab_completion_buf);
_chat_tab_completion_active = false;
this->SetDirty();
@@ -491,7 +493,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
{
switch (widget) {
/* Send */
- case WID_NC_SENDBUTTON: SendChat(this->text.buf, this->dtype, this->dest);
+ case WID_NC_SENDBUTTON: SendChat(this->message_editbox.text.buf, this->dtype, this->dest);
/* FALL THROUGH */
case WID_NC_CLOSE: /* Cancel */ delete this; break;
}