mirror of https://github.com/OpenTTD/OpenTTD
(svn r14927) -Codechange: constify widget numbers in network chat gui.
parent
0052c85002
commit
729cebda47
|
@ -263,14 +263,22 @@ static void SendChat(const char *buf, DestType type, int dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct NetworkChatWindow : public QueryStringBaseWindow {
|
struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||||
|
private:
|
||||||
|
enum NetWorkChatWidgets {
|
||||||
|
NWCW_CLOSE,
|
||||||
|
NWCW_BACKGROUND,
|
||||||
|
NWCW_TEXTBOX,
|
||||||
|
NWCW_SENDBUTTON,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
DestType dtype;
|
DestType dtype;
|
||||||
int dest;
|
int dest;
|
||||||
|
|
||||||
NetworkChatWindow (const WindowDesc *desc, DestType type, int dest) : QueryStringBaseWindow(NETWORK_CHAT_LENGTH, desc)
|
NetworkChatWindow (const WindowDesc *desc, DestType type, int dest) : QueryStringBaseWindow(NETWORK_CHAT_LENGTH, desc)
|
||||||
{
|
{
|
||||||
this->LowerWidget(2);
|
this->LowerWidget(NWCW_TEXTBOX);
|
||||||
this->dtype = type;
|
this->dtype = type;
|
||||||
this->dest = dest;
|
this->dest = dest;
|
||||||
this->afilter = CS_ALPHANUMERAL;
|
this->afilter = CS_ALPHANUMERAL;
|
||||||
|
@ -441,23 +449,23 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
|
|
||||||
assert((uint)this->dtype < lengthof(chat_captions));
|
assert((uint)this->dtype < lengthof(chat_captions));
|
||||||
DrawStringRightAligned(this->widget[2].left - 2, this->widget[2].top + 1, chat_captions[this->dtype], TC_BLACK);
|
DrawStringRightAligned(this->widget[NWCW_TEXTBOX].left - 2, this->widget[NWCW_TEXTBOX].top + 1, chat_captions[this->dtype], TC_BLACK);
|
||||||
this->DrawEditBox(2);
|
this->DrawEditBox(NWCW_TEXTBOX);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnClick(Point pt, int widget)
|
virtual void OnClick(Point pt, int widget)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case 3: /* Send */
|
/* Send */
|
||||||
SendChat(this->text.buf, this->dtype, this->dest);
|
case NWCW_SENDBUTTON: SendChat(this->text.buf, this->dtype, this->dest);
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case 0: /* Cancel */ delete this; break;
|
case NWCW_CLOSE: /* Cancel */ delete this; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnMouseLoop()
|
virtual void OnMouseLoop()
|
||||||
{
|
{
|
||||||
this->HandleEditBox(2);
|
this->HandleEditBox(NWCW_TEXTBOX);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
||||||
|
@ -467,7 +475,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||||
ChatTabCompletion();
|
ChatTabCompletion();
|
||||||
} else {
|
} else {
|
||||||
_chat_tab_completion_active = false;
|
_chat_tab_completion_active = false;
|
||||||
switch (this->HandleEditBoxKey(2, key, keycode, state)) {
|
switch (this->HandleEditBoxKey(NWCW_TEXTBOX, key, keycode, state)) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
case HEBR_EDITING: {
|
case HEBR_EDITING: {
|
||||||
Window *osk = FindWindowById(WC_OSK, 0);
|
Window *osk = FindWindowById(WC_OSK, 0);
|
||||||
|
|
Loading…
Reference in New Issue