mirror of https://github.com/OpenTTD/OpenTTD
(svn r16733) -Codechange: Move rebuilding and sorting the town list out of TownDirectoryWindow::OnPaint.
parent
ab67cf0031
commit
50ca187524
|
@ -537,23 +537,21 @@ private:
|
||||||
|
|
||||||
GUITownList towns;
|
GUITownList towns;
|
||||||
|
|
||||||
void BuildTownList()
|
void BuildSortTownList()
|
||||||
{
|
{
|
||||||
if (!this->towns.NeedRebuild()) return;
|
if (this->towns.NeedRebuild()) {
|
||||||
|
this->towns.Clear();
|
||||||
|
|
||||||
this->towns.Clear();
|
const Town *t;
|
||||||
|
FOR_ALL_TOWNS(t) {
|
||||||
|
*this->towns.Append() = t;
|
||||||
|
}
|
||||||
|
|
||||||
const Town *t;
|
this->towns.Compact();
|
||||||
FOR_ALL_TOWNS(t) {
|
this->towns.RebuildDone();
|
||||||
*this->towns.Append() = t;
|
SetVScrollCount(this, this->towns.Length()); // Update scrollbar as well.
|
||||||
}
|
}
|
||||||
|
/* Always sort the towns. */
|
||||||
this->towns.Compact();
|
|
||||||
this->towns.RebuildDone();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SortTownList()
|
|
||||||
{
|
|
||||||
last_town = NULL;
|
last_town = NULL;
|
||||||
this->towns.Sort();
|
this->towns.Sort();
|
||||||
}
|
}
|
||||||
|
@ -598,6 +596,7 @@ public:
|
||||||
this->towns.SetListing(this->last_sorting);
|
this->towns.SetListing(this->last_sorting);
|
||||||
this->towns.SetSortFuncs(this->sorter_funcs);
|
this->towns.SetSortFuncs(this->sorter_funcs);
|
||||||
this->towns.ForceRebuild();
|
this->towns.ForceRebuild();
|
||||||
|
this->BuildSortTownList();
|
||||||
}
|
}
|
||||||
|
|
||||||
~TownDirectoryWindow()
|
~TownDirectoryWindow()
|
||||||
|
@ -607,11 +606,6 @@ public:
|
||||||
|
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
this->BuildTownList();
|
|
||||||
this->SortTownList();
|
|
||||||
|
|
||||||
SetVScrollCount(this, this->towns.Length());
|
|
||||||
|
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,6 +653,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
this->towns.SetSortType(0);
|
this->towns.SetSortType(0);
|
||||||
}
|
}
|
||||||
|
this->BuildSortTownList();
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -668,6 +663,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
this->towns.SetSortType(1);
|
this->towns.SetSortType(1);
|
||||||
}
|
}
|
||||||
|
this->BuildSortTownList();
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -694,6 +690,7 @@ public:
|
||||||
|
|
||||||
virtual void OnHundredthTick()
|
virtual void OnHundredthTick()
|
||||||
{
|
{
|
||||||
|
this->BuildSortTownList();
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,6 +706,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
this->towns.ForceResort();
|
this->towns.ForceResort();
|
||||||
}
|
}
|
||||||
|
this->BuildSortTownList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue