diff options
author | alberth <alberth@openttd.org> | 2009-06-28 21:23:37 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2009-06-28 21:23:37 +0000 |
commit | d5a42ee82574aa77c73e2c4b2ff1ecc20323cc38 (patch) | |
tree | 82aba974962ceac41159340b1723fa943ce18384 /src/town_gui.cpp | |
parent | 058bb5d6c301a8aee5a52fa26e6b6fa0c395d57e (diff) | |
download | openttd-d5a42ee82574aa77c73e2c4b2ff1ecc20323cc38.tar.xz |
(svn r16688) -Codechange: Some cleanup of intro screen and town directory.
Diffstat (limited to 'src/town_gui.cpp')
-rw-r--r-- | src/town_gui.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/town_gui.cpp b/src/town_gui.cpp index ae4142dfe..9731d35cd 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -524,11 +524,13 @@ static const NWidgetPart _nested_town_directory_widgets[] = { EndContainer(), }; +/** Town directory window class. */ struct TownDirectoryWindow : public Window { private: /* Runtime saved values */ static Listing last_sorting; static const Town *last_town; + int townline_height; ///< Height of a single town line in the town directory window. /* Constants for sorting towns */ static GUITownList::SortFunction * const sorter_funcs[]; @@ -588,6 +590,7 @@ private: public: TownDirectoryWindow(const WindowDesc *desc) : Window() { + this->townline_height = FONT_HEIGHT_NORMAL; this->InitNested(desc, 0); this->vscroll.cap = this->nested_array[TDW_CENTERTOWN]->current_y / this->resize.step_height; @@ -615,7 +618,7 @@ public: { int n = 0; uint16 i = this->vscroll.pos; - int y = 28; + int y = this->nested_array[TDW_CENTERTOWN]->pos_y + 2; while (i < this->towns.Length()) { const Town *t = this->towns[i]; @@ -626,7 +629,7 @@ public: SetDParam(1, t->population); DrawString(2, this->width - 2, y, STR_TOWN_DIRECTORY_TOWN); - y += 10; + y += this->townline_height; i++; if (++n == this->vscroll.cap) break; // max number of towns in 1 window } @@ -658,7 +661,7 @@ public: break; case TDW_CENTERTOWN: { // Click on Town Matrix - uint16 id_v = (pt.y - 28) / 10; + uint16 id_v = (pt.y - this->nested_array[widget]->pos_y - 2) / this->townline_height; if (id_v >= this->vscroll.cap) return; // click out of bounds @@ -685,7 +688,7 @@ public: virtual void OnResize(Point delta) { - this->vscroll.cap += delta.y / 10; + this->vscroll.cap += delta.y / this->townline_height; } virtual void OnInvalidateData(int data) @@ -802,6 +805,7 @@ static const NWidgetPart _nested_found_town_widgets[] = { EndContainer(), }; +/** Found a town window class. */ struct FoundTownWindow : Window { private: |