network_chat_gui.cpp File Reference

GUI for handling chat messages. More...

#include <stdarg.h>
#include "../stdafx.h"
#include "../gfx_func.h"
#include "../strings_func.h"
#include "../blitter/factory.hpp"
#include "../console_func.h"
#include "../video/video_driver.hpp"
#include "../table/sprites.h"
#include "../querystring_gui.h"
#include "../town.h"
#include "../window_func.h"
#include "../core/geometry_func.hpp"
#include "network.h"
#include "network_client.h"
#include "network_base.h"
#include "table/strings.h"

Go to the source code of this file.

Data Structures

struct  ChatMessage
 Container for a message. More...
struct  NetworkChatWindow
 Window to enter the chat message in. More...

Enumerations

enum  NetWorkChatWidgets {
  NWCW_CLOSE, NWCW_BACKGROUND, NWCW_DESTINATION, NWCW_TEXTBOX,
  NWCW_SENDBUTTON
}
 

Widget numbers of the chat window.

More...

Functions

 assert_compile ((int) DRAW_STRING_BUFFER >=(int) NETWORK_CHAT_LENGTH+NETWORK_NAME_LENGTH+40)
 The draw buffer must be able to contain the chat message, client name and the "[All]" message, some spaces and possible translations of [All] to other languages.
static uint GetChatMessageCount ()
 Count the chat messages.
void CDECL NetworkAddChatMessage (TextColour colour, uint duration, const char *message,...)
 Add a text message to the 'chat window' to be shown.
void NetworkReInitChatBoxSize ()
 Initialize all font-dependent chat box sizes.
void NetworkInitChatMessage ()
 Initialize all buffers of the chat visualisation.
void NetworkUndrawChatMessage ()
 Hide the chatbox.
void NetworkChatMessageLoop ()
 Check if a message is expired.
void NetworkDrawChatMessage ()
 Draw the chat message-box.
static void SendChat (const char *buf, DestType type, int dest)
 Send an actual chat message.
void ShowNetworkChatQueryWindow (DestType type, int dest)
 Show the chat window.

Variables

static const uint NETWORK_CHAT_LINE_SPACING = 3
 Spacing between chat lines.
static ChatMessage_chatmsg_list = NULL
 The actual chat message list.
static bool _chatmessage_dirty = false
 Does the chat message need repainting?
static bool _chatmessage_visible = false
 Is a chat message visible.
static bool _chat_tab_completion_active
 Whether tab completion is active.
static uint MAX_CHAT_MESSAGES = 0
 The limit of chat messages to show.
static PointDimension _chatmsg_box
 The chatbox grows from the bottom so the coordinates are pixels from the left and pixels from the bottom.
static uint8 * _chatmessage_backup = NULL
 Backup in case text is moved.
static const NWidgetPart _nested_chat_window_widgets []
 The widgets of the chat window.
static const WindowDesc _chat_window_desc (WDP_MANUAL, 640, 14, WC_SEND_NETWORK_MSG, WC_NONE, 0, _nested_chat_window_widgets, lengthof(_nested_chat_window_widgets))
 The description of the chat window.

Detailed Description

GUI for handling chat messages.

Definition in file network_chat_gui.cpp.


Enumeration Type Documentation

Widget numbers of the chat window.

Definition at line 287 of file network_chat_gui.cpp.


Function Documentation

assert_compile ( (int) DRAW_STRING_BUFFER >=(int) NETWORK_CHAT_LENGTH+NETWORK_NAME_LENGTH 40  ) 

The draw buffer must be able to contain the chat message, client name and the "[All]" message, some spaces and possible translations of [All] to other languages.

static uint GetChatMessageCount (  )  [inline, static]

Count the chat messages.

Returns:
The number of chat messages.

Definition at line 65 of file network_chat_gui.cpp.

Referenced by NetworkAddChatMessage(), and NetworkDrawChatMessage().

void CDECL NetworkAddChatMessage ( TextColour  colour,
uint  duration,
const char *  message,
  ... 
)

Add a text message to the 'chat window' to be shown.

Parameters:
colour The colour this message is to be shown in
duration The duration of the chat message in seconds
message message itself in printf() style

Definition at line 81 of file network_chat_gui.cpp.

References _realtime_tick, ChatMessage::colour, DRAW_STRING_BUFFER, FormatStringLinebreaks(), GB(), GetChatMessageCount(), lastof, lengthof, ChatMessage::message, ChatMessage::remove_time, strecpy(), TC_IS_PALETTE_COLOUR, and Utf8TrimString().

void NetworkChatMessageLoop (  ) 

Check if a message is expired.

Definition at line 193 of file network_chat_gui.cpp.

References _realtime_tick, ChatMessage::message, and ChatMessage::remove_time.

void NetworkInitChatMessage (  ) 
void NetworkReInitChatBoxSize (  ) 

Initialize all font-dependent chat box sizes.

Definition at line 123 of file network_chat_gui.cpp.

References FONT_HEIGHT_NORMAL, Blitter::GetBytesPerPixel(), BlitterFactoryBase::GetCurrentBlitter(), and ReallocT().

Referenced by NetworkInitChatMessage(), and ReInitAllWindows().

static void SendChat ( const char *  buf,
DestType  type,
int  dest 
) [static]

Send an actual chat message.

Parameters:
buf The message to send.
type The type of destination.
dest The actual destination index.

Definition at line 276 of file network_chat_gui.cpp.

References _network_server, CLIENT_ID_SERVER, NetworkServerSendChat(), ClientNetworkGameSocketHandler::SendChat(), and StrEmpty().

Referenced by NetworkChatWindow::OnClick(), and NetworkChatWindow::OnKeyPress().

void ShowNetworkChatQueryWindow ( DestType  type,
int  dest 
)

Show the chat window.

Parameters:
type The type of destination.
dest The actual destination index.

Definition at line 595 of file network_chat_gui.cpp.

References _chat_window_desc, and DeleteWindowByClass().

Referenced by MainWindow::OnKeyPress().


Variable Documentation

const WindowDesc _chat_window_desc(WDP_MANUAL, 640, 14,WC_SEND_NETWORK_MSG, WC_NONE, 0, _nested_chat_window_widgets, lengthof(_nested_chat_window_widgets)) [static]

The description of the chat window.

Referenced by ShowNetworkChatQueryWindow().

The chatbox grows from the bottom so the coordinates are pixels from the left and pixels from the bottom.

The height is the maximum height.

Definition at line 58 of file network_chat_gui.cpp.

Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_CLOSEBOX, COLOUR_GREY, NWCW_CLOSE),
    NWidget(WWT_PANEL, COLOUR_GREY, NWCW_BACKGROUND),
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_TEXT, COLOUR_GREY, NWCW_DESTINATION), SetMinimalSize(62, 12), SetPadding(1, 0, 1, 0), SetDataTip(STR_NULL, STR_NULL),
        NWidget(WWT_EDITBOX, COLOUR_GREY, NWCW_TEXTBOX), SetMinimalSize(100, 12), SetPadding(1, 0, 1, 0), SetResize(1, 0),
                                  SetDataTip(STR_NETWORK_CHAT_OSKTITLE, STR_NULL),
        NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, NWCW_SENDBUTTON), SetMinimalSize(62, 12), SetPadding(1, 0, 1, 0), SetDataTip(STR_NETWORK_CHAT_SEND, STR_NULL),
      EndContainer(),
    EndContainer(),
  EndContainer(),
}

The widgets of the chat window.

Definition at line 567 of file network_chat_gui.cpp.

const uint NETWORK_CHAT_LINE_SPACING = 3 [static]

Spacing between chat lines.

Definition at line 38 of file network_chat_gui.cpp.


Generated on Sun Jun 5 04:20:11 2011 for OpenTTD by  doxygen 1.6.1