1
0
Fork 0

(svn r16733) -Codechange: Move rebuilding and sorting the town list out of TownDirectoryWindow::OnPaint.

release/1.0
alberth 2009-07-03 21:38:41 +00:00
parent ab67cf0031
commit 50ca187524
1 changed files with 16 additions and 18 deletions

View File

@ -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();
} }
}; };