mirror of https://github.com/OpenTTD/OpenTTD
(svn r17318) -Codechange: remove state changes from the OnPaint of the industry directory
parent
6870aed528
commit
5fe9c44862
|
@ -804,21 +804,23 @@ protected:
|
||||||
GUIIndustryList industries;
|
GUIIndustryList industries;
|
||||||
|
|
||||||
/** (Re)Build industries list */
|
/** (Re)Build industries list */
|
||||||
void BuildIndustriesList()
|
void BuildSortIndustriesList()
|
||||||
{
|
{
|
||||||
if (!this->industries.NeedRebuild()) return;
|
if (this->industries.NeedRebuild()) {
|
||||||
|
this->industries.Clear();
|
||||||
|
|
||||||
this->industries.Clear();
|
const Industry *i;
|
||||||
|
FOR_ALL_INDUSTRIES(i) {
|
||||||
|
*this->industries.Append() = i;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG(misc, 3, "Building industry list");
|
this->industries.Compact();
|
||||||
|
this->industries.RebuildDone();
|
||||||
const Industry *i;
|
SetVScrollCount(this, this->industries.Length()); // Update scrollbar as well.
|
||||||
FOR_ALL_INDUSTRIES(i) {
|
|
||||||
*this->industries.Append() = i;
|
|
||||||
}
|
}
|
||||||
|
this->last_industry = NULL;
|
||||||
this->industries.Compact();
|
this->industries.Sort();
|
||||||
this->industries.RebuildDone();
|
this->InvalidateWidget(IDW_INDUSTRY_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -902,18 +904,6 @@ protected:
|
||||||
return (r == 0) ? IndustryNameSorter(a, b) : r;
|
return (r == 0) ? IndustryNameSorter(a, b) : r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sort the industries list */
|
|
||||||
void SortIndustriesList()
|
|
||||||
{
|
|
||||||
if (!this->industries.Sort()) return;
|
|
||||||
|
|
||||||
/* Reset name sorter sort cache */
|
|
||||||
this->last_industry = NULL;
|
|
||||||
|
|
||||||
/* Set the modified widget dirty */
|
|
||||||
this->InvalidateWidget(IDW_INDUSTRY_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndustryDirectoryWindow(const WindowDesc *desc, WindowNumber number) : Window(desc, number)
|
IndustryDirectoryWindow(const WindowDesc *desc, WindowNumber number) : Window(desc, number)
|
||||||
{
|
{
|
||||||
|
@ -925,8 +915,7 @@ public:
|
||||||
this->industries.SetListing(this->last_sorting);
|
this->industries.SetListing(this->last_sorting);
|
||||||
this->industries.SetSortFuncs(this->sorter_funcs);
|
this->industries.SetSortFuncs(this->sorter_funcs);
|
||||||
this->industries.ForceRebuild();
|
this->industries.ForceRebuild();
|
||||||
this->industries.NeedResort();
|
this->BuildSortIndustriesList();
|
||||||
this->SortIndustriesList();
|
|
||||||
|
|
||||||
this->widget[IDW_DROPDOWN_CRITERIA].data = this->sorter_names[this->industries.SortType()];
|
this->widget[IDW_DROPDOWN_CRITERIA].data = this->sorter_names[this->industries.SortType()];
|
||||||
}
|
}
|
||||||
|
@ -938,11 +927,6 @@ public:
|
||||||
|
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
BuildIndustriesList();
|
|
||||||
SortIndustriesList();
|
|
||||||
|
|
||||||
SetVScrollCount(this, this->industries.Length());
|
|
||||||
|
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
this->DrawSortButtonState(IDW_DROPDOWN_ORDER, this->industries.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
|
this->DrawSortButtonState(IDW_DROPDOWN_ORDER, this->industries.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
|
||||||
|
|
||||||
|
@ -1023,6 +1007,12 @@ public:
|
||||||
this->vscroll.cap += delta.y / 10;
|
this->vscroll.cap += delta.y / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void OnHundredthTick()
|
||||||
|
{
|
||||||
|
this->BuildSortIndustriesList();
|
||||||
|
this->SetDirty();
|
||||||
|
}
|
||||||
|
|
||||||
virtual void OnInvalidateData(int data)
|
virtual void OnInvalidateData(int data)
|
||||||
{
|
{
|
||||||
if (data == 0) {
|
if (data == 0) {
|
||||||
|
@ -1030,7 +1020,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
this->industries.ForceResort();
|
this->industries.ForceResort();
|
||||||
}
|
}
|
||||||
this->InvalidateWidget(IDW_INDUSTRY_LIST);
|
this->BuildSortIndustriesList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue