src/network/network_chat_gui.cpp
author rubidium
Tue, 16 Dec 2008 17:58:27 +0000
changeset 10426 4a77f7049b5e
parent 10310 ca2eb5811a07
permissions -rw-r--r--
(svn r14679) -Fix [FS#2431]: opening the OSK on the chatbox did disable map scrolling (with keyboard) until another window with editbox was opened and closed. Just "refcount" the open edit boxes instead of setting/clearing a bit when opening/closing a window.
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
     1
/* $Id$ */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
     2
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
     3
/** @file network_chat_gui.cpp GUI for handling chat messages. */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
     4
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
     5
#include <stdarg.h> /* va_list */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
     6
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
     7
#ifdef ENABLE_NETWORK
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
     8
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
     9
#include "../stdafx.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    10
#include "network.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    11
#include "network_type.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    12
#include "../date_func.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    13
#include "../gfx_func.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    14
#include "../strings_func.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    15
#include "../blitter/factory.hpp"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    16
#include "../console_func.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    17
#include "../video/video_driver.hpp"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    18
#include "../table/sprites.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    19
#include "../window_gui.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    20
#include "../textbuf_gui.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    21
#include "../querystring_gui.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    22
#include "../town.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    23
#include "../window_func.h"
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    24
#include "../settings_type.h"
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    25
#include "network_internal.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    26
#include "network_client.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    27
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    28
#include "table/strings.h"
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    29
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10134
diff changeset
    30
/* The draw buffer must be able to contain the chat message, client name and the "[All]" message,
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    31
 * some spaces and possible translations of [All] to other languages. */
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    32
assert_compile((int)DRAW_STRING_BUFFER >= (int)NETWORK_CHAT_LENGTH + NETWORK_NAME_LENGTH + 40);
9901
602720bd2d53 (svn r14051) -Codechange: enumify the DrawString buffer length.
rubidium
parents: 9898
diff changeset
    33
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    34
enum {
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    35
	NETWORK_CHAT_LINE_HEIGHT = 13,
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    36
};
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    37
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    38
struct ChatMessage {
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    39
	char message[DRAW_STRING_BUFFER];
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    40
	uint16 color;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    41
	Date end_date;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    42
};
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    43
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    44
/* used for chat window */
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    45
static ChatMessage *_chatmsg_list = NULL;
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    46
static bool _chatmessage_dirty = false;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    47
static bool _chatmessage_visible = false;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    48
static bool _chat_tab_completion_active;
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    49
static uint MAX_CHAT_MESSAGES = 0;
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    50
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    51
/* The chatbox grows from the bottom so the coordinates are pixels from
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    52
 * the left and pixels from the bottom. The height is the maximum height */
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    53
static PointDimension _chatmsg_box;
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    54
static uint8 *_chatmessage_backup = NULL;
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    55
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    56
static inline uint GetChatMessageCount()
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    57
{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    58
	uint i = 0;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    59
	for (; i < MAX_CHAT_MESSAGES; i++) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    60
		if (_chatmsg_list[i].message[0] == '\0') break;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    61
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    62
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    63
	return i;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    64
}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    65
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    66
/**
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    67
 * Add a text message to the 'chat window' to be shown
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    68
 * @param color The colour this message is to be shown in
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    69
 * @param duration The duration of the chat message in game-days
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    70
 * @param message message itself in printf() style
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    71
 */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    72
void CDECL NetworkAddChatMessage(uint16 color, uint8 duration, const char *message, ...)
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    73
{
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    74
	char buf[DRAW_STRING_BUFFER];
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    75
	const char *bufp;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    76
	va_list va;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    77
	uint msg_count;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    78
	uint16 lines;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    79
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    80
	va_start(va, message);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    81
	vsnprintf(buf, lengthof(buf), message, va);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    82
	va_end(va);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    83
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
    84
	Utf8TrimString(buf, DRAW_STRING_BUFFER);
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    85
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    86
	/* Force linebreaks for strings that are too long */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    87
	lines = GB(FormatStringLinebreaks(buf, _chatmsg_box.width - 8), 0, 16) + 1;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    88
	if (lines >= MAX_CHAT_MESSAGES) return;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    89
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    90
	msg_count = GetChatMessageCount();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    91
	/* We want to add more chat messages than there is free space for, remove 'old' */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    92
	if (lines > MAX_CHAT_MESSAGES - msg_count) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    93
		int i = lines - (MAX_CHAT_MESSAGES - msg_count);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    94
		memmove(&_chatmsg_list[0], &_chatmsg_list[i], sizeof(_chatmsg_list[0]) * (msg_count - i));
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    95
		msg_count = MAX_CHAT_MESSAGES - lines;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    96
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    97
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    98
	for (bufp = buf; lines != 0; lines--) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
    99
		ChatMessage *cmsg = &_chatmsg_list[msg_count++];
10310
ca2eb5811a07 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13
parents: 10295
diff changeset
   100
		strecpy(cmsg->message, bufp, lastof(cmsg->message));
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   101
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10134
diff changeset
   102
		/* The default colour for a message is company colour. Replace this with
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   103
		 * white for any additional lines */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   104
		cmsg->color = (bufp == buf && color & IS_PALETTE_COLOR) ? color : (0x1D - 15) | IS_PALETTE_COLOR;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   105
		cmsg->end_date = _date + duration;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   106
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   107
		bufp += strlen(bufp) + 1; // jump to 'next line' in the formatted string
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   108
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   109
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   110
	_chatmessage_dirty = true;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   111
}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   112
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   113
void NetworkInitChatMessage()
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   114
{
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
   115
	MAX_CHAT_MESSAGES   = _settings_client.gui.network_chat_box_height;
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
   116
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
   117
	_chatmsg_list       = ReallocT(_chatmsg_list, _settings_client.gui.network_chat_box_height);
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
   118
	_chatmsg_box.x      = 10;
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
   119
	_chatmsg_box.y      = 30;
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
   120
	_chatmsg_box.width  = _settings_client.gui.network_chat_box_width;
10134
213b85713d03 (svn r14320) -Fix [FS#2299]: glitch when chatbox window is full and the window is scrolled (yorP)
rubidium
parents: 10132
diff changeset
   121
	_chatmsg_box.height = _settings_client.gui.network_chat_box_height * NETWORK_CHAT_LINE_HEIGHT + 2;
9925
e6abeb1fc804 (svn r14080) -Fix (r14052): assert triggered when drawing chat window with 32bpp-anim blitter (backup buffer was too small)
glx
parents: 9902
diff changeset
   122
	_chatmessage_backup = ReallocT(_chatmessage_backup, _chatmsg_box.width * _chatmsg_box.height * BlitterFactoryBase::GetCurrentBlitter()->GetBytesPerPixel());
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
   123
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   124
	for (uint i = 0; i < MAX_CHAT_MESSAGES; i++) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   125
		_chatmsg_list[i].message[0] = '\0';
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   126
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   127
}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   128
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   129
/** Hide the chatbox */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   130
void NetworkUndrawChatMessage()
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   131
{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   132
	if (_chatmessage_visible) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   133
		Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   134
		/* Sometimes we also need to hide the cursor
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   135
		 *   This is because both textmessage and the cursor take a shot of the
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   136
		 *   screen before drawing.
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   137
		 *   Now the textmessage takes his shot and paints his data before the cursor
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   138
		 *   does, so in the shot of the cursor is the screen-data of the textmessage
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   139
		 *   included when the cursor hangs somewhere over the textmessage. To
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   140
		 *   avoid wrong repaints, we undraw the cursor in that case, and everything
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   141
		 *   looks nicely ;)
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   142
		 * (and now hope this story above makes sense to you ;))
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   143
		 */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   144
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   145
		if (_cursor.visible) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   146
			if (_cursor.draw_pos.x + _cursor.draw_size.x >= _chatmsg_box.x &&
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   147
				_cursor.draw_pos.x <= _chatmsg_box.x + _chatmsg_box.width &&
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   148
				_cursor.draw_pos.y + _cursor.draw_size.y >= _screen.height - _chatmsg_box.y - _chatmsg_box.height &&
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   149
				_cursor.draw_pos.y <= _screen.height - _chatmsg_box.y) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   150
				UndrawMouseCursor();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   151
			}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   152
		}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   153
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   154
		int x      = _chatmsg_box.x;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   155
		int y      = _screen.height - _chatmsg_box.y - _chatmsg_box.height;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   156
		int width  = _chatmsg_box.width;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   157
		int height = _chatmsg_box.height;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   158
		if (y < 0) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   159
			height = max(height + y, min(_chatmsg_box.height, _screen.height));
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   160
			y = 0;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   161
		}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   162
		if (x + width >= _screen.width) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   163
			width = _screen.width - x;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   164
		}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   165
		if (width <= 0 || height <= 0) return;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   166
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   167
		_chatmessage_visible = false;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   168
		/* Put our 'shot' back to the screen */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   169
		blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   170
		/* And make sure it is updated next time */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   171
		_video_driver->MakeDirty(x, y, width, height);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   172
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   173
		_chatmessage_dirty = true;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   174
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   175
}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   176
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   177
/** Check if a message is expired every day */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   178
void NetworkChatMessageDailyLoop()
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   179
{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   180
	for (uint i = 0; i < MAX_CHAT_MESSAGES; i++) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   181
		ChatMessage *cmsg = &_chatmsg_list[i];
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   182
		if (cmsg->message[0] == '\0') continue;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   183
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   184
		/* Message has expired, remove from the list */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   185
		if (cmsg->end_date < _date) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   186
			/* Move the remaining messages over the current message */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   187
			if (i != MAX_CHAT_MESSAGES - 1) memmove(cmsg, cmsg + 1, sizeof(*cmsg) * (MAX_CHAT_MESSAGES - i - 1));
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   188
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   189
			/* Mark the last item as empty */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   190
			_chatmsg_list[MAX_CHAT_MESSAGES - 1].message[0] = '\0';
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   191
			_chatmessage_dirty = true;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   192
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   193
			/* Go one item back, because we moved the array 1 to the left */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   194
			i--;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   195
		}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   196
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   197
}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   198
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   199
/** Draw the chat message-box */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   200
void NetworkDrawChatMessage()
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   201
{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   202
	Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   203
	if (!_chatmessage_dirty) return;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   204
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   205
	/* First undraw if needed */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   206
	NetworkUndrawChatMessage();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   207
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   208
	if (_iconsole_mode == ICONSOLE_FULL) return;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   209
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   210
	/* Check if we have anything to draw at all */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   211
	uint count = GetChatMessageCount();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   212
	if (count == 0) return;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   213
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   214
	int x      = _chatmsg_box.x;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   215
	int y      = _screen.height - _chatmsg_box.y - _chatmsg_box.height;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   216
	int width  = _chatmsg_box.width;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   217
	int height = _chatmsg_box.height;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   218
	if (y < 0) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   219
		height = max(height + y, min(_chatmsg_box.height, _screen.height));
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   220
		y = 0;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   221
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   222
	if (x + width >= _screen.width) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   223
		width = _screen.width - x;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   224
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   225
	if (width <= 0 || height <= 0) return;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   226
9925
e6abeb1fc804 (svn r14080) -Fix (r14052): assert triggered when drawing chat window with 32bpp-anim blitter (backup buffer was too small)
glx
parents: 9902
diff changeset
   227
	assert(blitter->BufferSize(width, height) <= (int)(_chatmsg_box.width * _chatmsg_box.height * blitter->GetBytesPerPixel()));
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   228
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   229
	/* Make a copy of the screen as it is before painting (for undraw) */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   230
	blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   231
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   232
	_cur_dpi = &_screen; // switch to _screen painting
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   233
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   234
	/* Paint a half-transparent box behind the chat messages */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   235
	GfxFillRect(
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   236
			_chatmsg_box.x,
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
   237
			_screen.height - _chatmsg_box.y - count * NETWORK_CHAT_LINE_HEIGHT - 2,
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   238
			_chatmsg_box.x + _chatmsg_box.width - 1,
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   239
			_screen.height - _chatmsg_box.y - 2,
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   240
			PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOR // black, but with some alpha for background
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   241
		);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   242
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   243
	/* Paint the chat messages starting with the lowest at the bottom */
9902
035856ac432b (svn r14052) -Codechange: make the size of the chat message "box" configurable and increase the default size slightly so it can hold the longest chat messages.
rubidium
parents: 9901
diff changeset
   244
	for (uint y = NETWORK_CHAT_LINE_HEIGHT; count-- != 0; y += NETWORK_CHAT_LINE_HEIGHT) {
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   245
		DoDrawString(_chatmsg_list[count].message, _chatmsg_box.x + 3, _screen.height - _chatmsg_box.y - y + 1, _chatmsg_list[count].color);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   246
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   247
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   248
	/* Make sure the data is updated next flush */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   249
	_video_driver->MakeDirty(x, y, width, height);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   250
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   251
	_chatmessage_visible = true;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   252
	_chatmessage_dirty = false;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   253
}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   254
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   255
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   256
static void SendChat(const char *buf, DestType type, int dest)
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   257
{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   258
	if (StrEmpty(buf)) return;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   259
	if (!_network_server) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   260
		SEND_COMMAND(PACKET_CLIENT_CHAT)((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   261
	} else {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   262
		NetworkServerSendChat((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf, NETWORK_SERVER_INDEX);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   263
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   264
}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   265
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   266
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   267
struct NetworkChatWindow : public QueryStringBaseWindow {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   268
	DestType dtype;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   269
	int dest;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   270
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   271
	NetworkChatWindow (const WindowDesc *desc, DestType type, int dest) : QueryStringBaseWindow(NETWORK_CHAT_LENGTH, desc)
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   272
	{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   273
		this->LowerWidget(2);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   274
		this->dtype   = type;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   275
		this->dest    = dest;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   276
		this->afilter = CS_ALPHANUMERAL;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   277
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 0);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   278
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   279
		InvalidateWindowData(WC_NEWS_WINDOW, 0, this->height);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   280
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   281
		_chat_tab_completion_active = false;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   282
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   283
		this->FindWindowPlacementAndResize(desc);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   284
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   285
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   286
	~NetworkChatWindow ()
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   287
	{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   288
		InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   289
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   290
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   291
	/**
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   292
	 * Find the next item of the list of things that can be auto-completed.
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   293
	 * @param item The current indexed item to return. This function can, and most
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   294
	 *     likely will, alter item, to skip empty items in the arrays.
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   295
	 * @return Returns the char that matched to the index.
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   296
	 */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   297
	const char *ChatTabCompletionNextItem(uint *item)
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   298
	{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   299
		static char chat_tab_temp_buffer[64];
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   300
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   301
		/* First, try clients */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   302
		if (*item < MAX_CLIENT_INFO) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   303
			/* Skip inactive clients */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   304
			while (_network_client_info[*item].client_index == NETWORK_EMPTY_INDEX && *item < MAX_CLIENT_INFO) (*item)++;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   305
			if (*item < MAX_CLIENT_INFO) return _network_client_info[*item].client_name;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   306
		}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   307
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   308
		/* Then, try townnames */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   309
		/* Not that the following assumes all town indices are adjacent, ie no
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   310
		* towns have been deleted. */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   311
		if (*item <= (uint)MAX_CLIENT_INFO + GetMaxTownIndex()) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   312
			const Town *t;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   313
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   314
			FOR_ALL_TOWNS_FROM(t, *item - MAX_CLIENT_INFO) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   315
				/* Get the town-name via the string-system */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   316
				SetDParam(0, t->index);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   317
				GetString(chat_tab_temp_buffer, STR_TOWN, lastof(chat_tab_temp_buffer));
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   318
				return &chat_tab_temp_buffer[0];
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   319
			}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   320
		}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   321
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   322
		return NULL;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   323
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   324
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   325
	/**
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   326
	 * Find what text to complete. It scans for a space from the left and marks
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   327
	 *  the word right from that as to complete. It also writes a \0 at the
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   328
	 *  position of the space (if any). If nothing found, buf is returned.
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   329
	 */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   330
	static char *ChatTabCompletionFindText(char *buf)
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   331
	{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   332
		char *p = strrchr(buf, ' ');
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   333
		if (p == NULL) return buf;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   334
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   335
		*p = '\0';
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   336
		return p + 1;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   337
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   338
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   339
	/**
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   340
	 * See if we can auto-complete the current text of the user.
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   341
	 */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   342
	void ChatTabCompletion()
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   343
	{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   344
		static char _chat_tab_completion_buf[NETWORK_CHAT_LENGTH];
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   345
		assert(this->edit_str_size == lengthof(_chat_tab_completion_buf));
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   346
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   347
		Textbuf *tb = &this->text;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   348
		size_t len, tb_len;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   349
		uint item;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   350
		char *tb_buf, *pre_buf;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   351
		const char *cur_name;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   352
		bool second_scan = false;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   353
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   354
		item = 0;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   355
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   356
		/* Copy the buffer so we can modify it without damaging the real data */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   357
		pre_buf = (_chat_tab_completion_active) ? strdup(_chat_tab_completion_buf) : strdup(tb->buf);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   358
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   359
		tb_buf  = ChatTabCompletionFindText(pre_buf);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   360
		tb_len  = strlen(tb_buf);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   361
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   362
		while ((cur_name = ChatTabCompletionNextItem(&item)) != NULL) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   363
			item++;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   364
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   365
			if (_chat_tab_completion_active) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   366
				/* We are pressing TAB again on the same name, is there an other name
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   367
				*  that starts with this? */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   368
				if (!second_scan) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   369
					size_t offset;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   370
					size_t length;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   371
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   372
					/* If we are completing at the begin of the line, skip the ': ' we added */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   373
					if (tb_buf == pre_buf) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   374
						offset = 0;
10276
b60b7e17db62 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents: 10207
diff changeset
   375
						length = (tb->size - 1) - 2;
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   376
					} else {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   377
						/* Else, find the place we are completing at */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   378
						offset = strlen(pre_buf) + 1;
10276
b60b7e17db62 (svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz
parents: 10207
diff changeset
   379
						length = (tb->size - 1) - offset;
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   380
					}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   381
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   382
					/* Compare if we have a match */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   383
					if (strlen(cur_name) == length && strncmp(cur_name, tb->buf + offset, length) == 0) second_scan = true;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   384
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   385
					continue;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   386
				}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   387
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   388
				/* Now any match we make on _chat_tab_completion_buf after this, is perfect */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   389
			}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   390
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   391
			len = strlen(cur_name);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   392
			if (tb_len < len && strncasecmp(cur_name, tb_buf, tb_len) == 0) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   393
				/* Save the data it was before completion */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   394
				if (!second_scan) snprintf(_chat_tab_completion_buf, lengthof(_chat_tab_completion_buf), "%s", tb->buf);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   395
				_chat_tab_completion_active = true;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   396
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   397
				/* Change to the found name. Add ': ' if we are at the start of the line (pretty) */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   398
				if (pre_buf == tb_buf) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   399
					snprintf(tb->buf, this->edit_str_size, "%s: ", cur_name);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   400
				} else {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   401
					snprintf(tb->buf, this->edit_str_size, "%s %s", pre_buf, cur_name);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   402
				}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   403
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   404
				/* Update the textbuffer */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   405
				UpdateTextBufferSize(&this->text);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   406
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   407
				this->SetDirty();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   408
				free(pre_buf);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   409
				return;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   410
			}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   411
		}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   412
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   413
		if (second_scan) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   414
			/* We walked all posibilities, and the user presses tab again.. revert to original text */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   415
			strcpy(tb->buf, _chat_tab_completion_buf);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   416
			_chat_tab_completion_active = false;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   417
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   418
			/* Update the textbuffer */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   419
			UpdateTextBufferSize(&this->text);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   420
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   421
			this->SetDirty();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   422
		}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   423
		free(pre_buf);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   424
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   425
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   426
	virtual void OnPaint()
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   427
	{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   428
		static const StringID chat_captions[] = {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   429
			STR_NETWORK_CHAT_ALL_CAPTION,
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   430
			STR_NETWORK_CHAT_COMPANY_CAPTION,
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   431
			STR_NETWORK_CHAT_CLIENT_CAPTION
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   432
		};
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   433
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   434
		this->DrawWidgets();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   435
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   436
		assert((uint)this->dtype < lengthof(chat_captions));
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   437
		DrawStringRightAligned(this->widget[2].left - 2, this->widget[2].top + 1, chat_captions[this->dtype], TC_BLACK);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   438
		this->DrawEditBox(2);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   439
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   440
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   441
	virtual void OnClick(Point pt, int widget)
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   442
	{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   443
		switch (widget) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   444
			case 2:
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   445
				ShowOnScreenKeyboard(this, 2, 0, 3);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   446
				break;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   447
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   448
			case 3: /* Send */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   449
				SendChat(this->text.buf, this->dtype, this->dest);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   450
			/* FALLTHROUGH */
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   451
			case 0: /* Cancel */ delete this; break;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   452
		}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   453
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   454
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   455
	virtual void OnMouseLoop()
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   456
	{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   457
		this->HandleEditBox(2);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   458
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   459
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   460
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   461
	{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   462
		EventState state = ES_NOT_HANDLED;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   463
		if (keycode == WKC_TAB) {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   464
			ChatTabCompletion();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   465
		} else {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   466
			_chat_tab_completion_active = false;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   467
			switch (this->HandleEditBoxKey(2, key, keycode, state)) {
10132
ba6ac391e138 (svn r14318) -Fix [FS#2296]: OSK of the chat box did not get updated. This as the chatbox got a higher priority than the OSK instead of the usual other way around.
rubidium
parents: 9925
diff changeset
   468
				default: NOT_REACHED();
10295
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
   469
				case HEBR_EDITING: {
10132
ba6ac391e138 (svn r14318) -Fix [FS#2296]: OSK of the chat box did not get updated. This as the chatbox got a higher priority than the OSK instead of the usual other way around.
rubidium
parents: 9925
diff changeset
   470
					Window *osk = FindWindowById(WC_OSK, 0);
ba6ac391e138 (svn r14318) -Fix [FS#2296]: OSK of the chat box did not get updated. This as the chatbox got a higher priority than the OSK instead of the usual other way around.
rubidium
parents: 9925
diff changeset
   471
					if (osk != NULL && osk->parent == this) osk->OnInvalidateData();
ba6ac391e138 (svn r14318) -Fix [FS#2296]: OSK of the chat box did not get updated. This as the chatbox got a higher priority than the OSK instead of the usual other way around.
rubidium
parents: 9925
diff changeset
   472
				} break;
10295
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
   473
				case HEBR_CONFIRM:
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   474
					SendChat(this->text.buf, this->dtype, this->dest);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   475
				/* FALLTHROUGH */
10295
52982b3d0d84 (svn r14534) -Codechange [FS#2382]: Enumify magic return values of HandleEditBox function (Zuu)
glx
parents: 10276
diff changeset
   476
				case HEBR_CANCEL: delete this; break;
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   477
			}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   478
		}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   479
		return state;
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   480
	}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   481
};
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   482
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   483
static const Widget _chat_window_widgets[] = {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   484
{   WWT_CLOSEBOX, RESIZE_NONE,   COLOUR_GREY,   0,  10,  0, 13, STR_00C5,                  STR_018B_CLOSE_WINDOW},
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   485
{      WWT_PANEL, RESIZE_RIGHT,  COLOUR_GREY,  11, 319,  0, 13, 0x0,                       STR_NULL}, // background
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   486
{    WWT_EDITBOX, RESIZE_RIGHT,  COLOUR_GREY,  75, 257,  1, 12, STR_NETWORK_CHAT_OSKTITLE, STR_NULL}, // text box
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   487
{ WWT_PUSHTXTBTN, RESIZE_LR,     COLOUR_GREY, 258, 319,  1, 12, STR_NETWORK_SEND,          STR_NULL}, // send button
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   488
{   WIDGETS_END},
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   489
};
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   490
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   491
static const WindowDesc _chat_window_desc = {
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   492
	WDP_CENTER, -26, 320, 14, 640, 14, // x, y, width, height
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   493
	WC_SEND_NETWORK_MSG, WC_NONE,
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   494
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   495
	_chat_window_widgets,
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   496
};
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   497
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   498
void ShowNetworkChatQueryWindow(DestType type, int dest)
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   499
{
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   500
	DeleteWindowById(WC_SEND_NETWORK_MSG, 0);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   501
	new NetworkChatWindow (&_chat_window_desc, type, dest);
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   502
}
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   503
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents:
diff changeset
   504
#endif /* ENABLE_NETWORK */