summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2009-01-08 22:33:54 +0000
committerbelugas <belugas@openttd.org>2009-01-08 22:33:54 +0000
commitf0033f800327c1bf13270e93c1703efc6a831a26 (patch)
tree5709a6aa5cc095a9f31bb034bd0d5c8966e4a090
parent544e04fe620b6fd55c49f8cf04bf1222b2aae055 (diff)
downloadopenttd-f0033f800327c1bf13270e93c1703efc6a831a26.tar.xz
(svn r14927) -Codechange: constify widget numbers in network chat gui.
-rw-r--r--src/network/network_chat_gui.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index 4a1e209b3..8968007ea 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -263,14 +263,22 @@ static void SendChat(const char *buf, DestType type, int dest)
}
}
-
struct NetworkChatWindow : public QueryStringBaseWindow {
+private:
+ enum NetWorkChatWidgets {
+ NWCW_CLOSE,
+ NWCW_BACKGROUND,
+ NWCW_TEXTBOX,
+ NWCW_SENDBUTTON,
+ };
+
+public:
DestType dtype;
int dest;
NetworkChatWindow (const WindowDesc *desc, DestType type, int dest) : QueryStringBaseWindow(NETWORK_CHAT_LENGTH, desc)
{
- this->LowerWidget(2);
+ this->LowerWidget(NWCW_TEXTBOX);
this->dtype = type;
this->dest = dest;
this->afilter = CS_ALPHANUMERAL;
@@ -441,23 +449,23 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
this->DrawWidgets();
assert((uint)this->dtype < lengthof(chat_captions));
- DrawStringRightAligned(this->widget[2].left - 2, this->widget[2].top + 1, chat_captions[this->dtype], TC_BLACK);
- this->DrawEditBox(2);
+ DrawStringRightAligned(this->widget[NWCW_TEXTBOX].left - 2, this->widget[NWCW_TEXTBOX].top + 1, chat_captions[this->dtype], TC_BLACK);
+ this->DrawEditBox(NWCW_TEXTBOX);
}
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
- case 3: /* Send */
- SendChat(this->text.buf, this->dtype, this->dest);
+ /* Send */
+ case NWCW_SENDBUTTON: SendChat(this->text.buf, this->dtype, this->dest);
/* FALLTHROUGH */
- case 0: /* Cancel */ delete this; break;
+ case NWCW_CLOSE: /* Cancel */ delete this; break;
}
}
virtual void OnMouseLoop()
{
- this->HandleEditBox(2);
+ this->HandleEditBox(NWCW_TEXTBOX);
}
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
@@ -467,7 +475,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
ChatTabCompletion();
} else {
_chat_tab_completion_active = false;
- switch (this->HandleEditBoxKey(2, key, keycode, state)) {
+ switch (this->HandleEditBoxKey(NWCW_TEXTBOX, key, keycode, state)) {
default: NOT_REACHED();
case HEBR_EDITING: {
Window *osk = FindWindowById(WC_OSK, 0);