(svn r16688) -Codechange: Some cleanup of intro screen and town directory.
This commit is contained in:
@@ -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:
|
||||
|
Reference in New Issue
Block a user