(svn r16689) -Codechange: Allow for rendering of parameterized text of nested widgets in Window::DrawWidget, adapt intro and town directory windows.

This commit is contained in:
alberth
2009-06-28 22:23:26 +00:00
parent d5a42ee825
commit baab325b54
4 changed files with 103 additions and 58 deletions

View File

@@ -613,29 +613,40 @@ public:
SetVScrollCount(this, this->towns.Length());
this->DrawWidgets();
this->DrawSortButtonState(this->towns.SortType() == 0 ? TDW_SORTNAME : TDW_SORTPOPULATION, this->towns.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
}
{
int n = 0;
uint16 i = this->vscroll.pos;
int y = this->nested_array[TDW_CENTERTOWN]->pos_y + 2;
virtual void DrawWidget(const Rect &r, int widget) const
{
switch(widget) {
case TDW_SORTNAME:
if (this->towns.SortType() == 0) this->DrawSortButtonState(widget, this->towns.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
break;
while (i < this->towns.Length()) {
const Town *t = this->towns[i];
case TDW_SORTPOPULATION:
if (this->towns.SortType() != 0) this->DrawSortButtonState(widget, this->towns.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
break;
assert(t->xy != INVALID_TILE);
case TDW_CENTERTOWN: {
int n = 0;
int y = r.top + 2;
for (uint i = this->vscroll.pos; i < this->towns.Length(); i++) {
const Town *t = this->towns[i];
SetDParam(0, t->index);
SetDParam(1, t->population);
DrawString(2, this->width - 2, y, STR_TOWN_DIRECTORY_TOWN);
assert(t->xy != INVALID_TILE);
y += this->townline_height;
i++;
if (++n == this->vscroll.cap) break; // max number of towns in 1 window
}
SetDParam(0, t->index);
SetDParam(1, t->population);
DrawString(r.left + 2, r.right - 2, y, STR_TOWN_DIRECTORY_TOWN);
SetDParam(0, GetWorldPopulation());
DrawString(3, this->width - 3, this->height - 12 + 2, STR_TOWN_POPULATION);
y += this->townline_height;
if (++n == this->vscroll.cap) break; // max number of towns in 1 window
}
} break;
case TDW_EMPTYBOTTOM:
SetDParam(0, GetWorldPopulation());
DrawString(r.left + 3, r.right - 3, r.top + 2, STR_TOWN_POPULATION);
break;
}
}