summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-03-28 17:39:03 +0000
committerpeter1138 <peter1138@openttd.org>2009-03-28 17:39:03 +0000
commit9f8f342a6aa3bd0e7f39a587b2a27f86efb2dbf1 (patch)
tree19cea6cbdc8407209b665e5cf7835dc2d8e1ea41 /src
parent7284ae3f77ccf07a71d55d35fb3edfd3a41bf9c9 (diff)
downloadopenttd-9f8f342a6aa3bd0e7f39a587b2a27f86efb2dbf1.tar.xz
(svn r15883) -Codechange: Make a widget enum for the sign list and use widget offsets instead of direct locations.
Diffstat (limited to 'src')
-rw-r--r--src/signs_gui.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 3ed9f395a..c1fa1dace 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -70,6 +70,16 @@ struct SignList {
const Sign *SignList::last_sign = NULL;
+/** Enum referring to the widgets of the sign list window */
+enum SignListWidgets {
+ SLW_CLOSEBOX = 0,
+ SLW_CAPTION,
+ SLW_STICKY,
+ SLW_LIST,
+ SLW_SCROLLBAR,
+ SLW_RESIZE,
+};
+
struct SignListWindow : Window, SignList {
SignListWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
@@ -94,9 +104,9 @@ struct SignListWindow : Window, SignList {
this->DrawWidgets();
/* No signs? */
- int y = 16; // offset from top of widget
+ int y = this->widget[SLW_LIST].top + 2; // offset from top of widget
if (this->vscroll.count == 0) {
- DrawString(2, 346, y, STR_304A_NONE, TC_FROMSTRING);
+ DrawString(this->widget[SLW_LIST].left + 2, this->widget[SLW_LIST].right, y, STR_304A_NONE, TC_FROMSTRING);
return;
}
@@ -104,18 +114,18 @@ struct SignListWindow : Window, SignList {
for (uint16 i = this->vscroll.pos; i < this->vscroll.cap + this->vscroll.pos && i < this->vscroll.count; i++) {
const Sign *si = this->signs[i];
- if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, 4, y + 1);
+ if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, this->widget[SLW_LIST].left + 4, y + 1);
SetDParam(0, si->index);
- DrawString(22, 346, y, STR_SIGN_NAME, TC_YELLOW);
+ DrawString(this->widget[SLW_LIST].left + 22, this->widget[SLW_LIST].right, y, STR_SIGN_NAME, TC_YELLOW);
y += 10;
}
}
virtual void OnClick(Point pt, int widget)
{
- if (widget == 3) {
- uint32 id_v = (pt.y - 15) / 10;
+ if (widget == SLW_LIST) {
+ uint32 id_v = (pt.y - this->widget[SLW_LIST].top - 1) / 10;
if (id_v >= this->vscroll.cap) return;
id_v += this->vscroll.pos;