mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r17841) -Codechange: move state changes from OnPaint to OnInvalidate for the content gui.
This commit is contained in:
parent
547677a782
commit
c90885a17e
@ -230,6 +230,7 @@ class NetworkContentListWindow : public QueryStringBaseWindow, ContentCallback {
|
|||||||
|
|
||||||
const ContentInfo *selected; ///< The selected content info
|
const ContentInfo *selected; ///< The selected content info
|
||||||
int list_pos; ///< Our position in the list
|
int list_pos; ///< Our position in the list
|
||||||
|
uint filesize_sum; ///< The sum of all selected file sizes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Re)build the network game list as its amount has changed because
|
* (Re)build the network game list as its amount has changed because
|
||||||
@ -360,6 +361,7 @@ public:
|
|||||||
this->SortContentList();
|
this->SortContentList();
|
||||||
|
|
||||||
this->FindWindowPlacementAndResize(desc);
|
this->FindWindowPlacementAndResize(desc);
|
||||||
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Free everything we allocated */
|
/** Free everything we allocated */
|
||||||
@ -376,35 +378,6 @@ public:
|
|||||||
this->BuildContentList();
|
this->BuildContentList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* To sum all the bytes we intend to download */
|
|
||||||
uint filesize = 0;
|
|
||||||
bool show_select_all = false;
|
|
||||||
bool show_select_upgrade = false;
|
|
||||||
for (ConstContentIterator iter = this->content.Begin(); iter != this->content.End(); iter++) {
|
|
||||||
const ContentInfo *ci = *iter;
|
|
||||||
switch (ci->state) {
|
|
||||||
case ContentInfo::SELECTED:
|
|
||||||
case ContentInfo::AUTOSELECTED:
|
|
||||||
filesize += ci->filesize;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ContentInfo::UNSELECTED:
|
|
||||||
show_select_all = true;
|
|
||||||
show_select_upgrade |= ci->upgrade;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this->SetWidgetDisabledState(NCLWW_DOWNLOAD, filesize == 0 || FindWindowById(WC_NETWORK_STATUS_WINDOW, 0) != NULL);
|
|
||||||
this->SetWidgetDisabledState(NCLWW_UNSELECT, filesize == 0);
|
|
||||||
this->SetWidgetDisabledState(NCLWW_SELECT_ALL, !show_select_all);
|
|
||||||
this->SetWidgetDisabledState(NCLWW_SELECT_UPDATE, !show_select_upgrade);
|
|
||||||
|
|
||||||
this->widget[NCLWW_CANCEL].data = filesize == 0 ? STR_AI_SETTINGS_CLOSE : STR_AI_LIST_CANCEL;
|
|
||||||
|
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
|
|
||||||
/* Edit box to filter for keywords */
|
/* Edit box to filter for keywords */
|
||||||
@ -540,7 +513,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the total download size */
|
/* Draw the total download size */
|
||||||
SetDParam(0, filesize);
|
SetDParam(0, this->filesize_sum);
|
||||||
DrawString(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, this->widget[NCLWW_DETAILS].bottom - 12, STR_CONTENT_TOTAL_DOWNLOAD_SIZE);
|
DrawString(this->widget[NCLWW_DETAILS].left + 5, this->widget[NCLWW_DETAILS].right - 5, this->widget[NCLWW_DETAILS].bottom - 12, STR_CONTENT_TOTAL_DOWNLOAD_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,7 +545,7 @@ public:
|
|||||||
this->content.ForceResort();
|
this->content.ForceResort();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NCLWW_CHECKBOX:
|
case NCLWW_CHECKBOX:
|
||||||
@ -587,22 +560,22 @@ public:
|
|||||||
this->SortContentList();
|
this->SortContentList();
|
||||||
}
|
}
|
||||||
this->ScrollToSelected();
|
this->ScrollToSelected();
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NCLWW_SELECT_ALL:
|
case NCLWW_SELECT_ALL:
|
||||||
_network_content_client.SelectAll();
|
_network_content_client.SelectAll();
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NCLWW_SELECT_UPDATE:
|
case NCLWW_SELECT_UPDATE:
|
||||||
_network_content_client.SelectUpgrade();
|
_network_content_client.SelectUpgrade();
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NCLWW_UNSELECT:
|
case NCLWW_UNSELECT:
|
||||||
_network_content_client.UnselectAll();
|
_network_content_client.UnselectAll();
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NCLWW_CANCEL:
|
case NCLWW_CANCEL:
|
||||||
@ -654,7 +627,7 @@ public:
|
|||||||
if (this->selected != NULL) {
|
if (this->selected != NULL) {
|
||||||
_network_content_client.ToggleSelectedState(this->selected);
|
_network_content_client.ToggleSelectedState(this->selected);
|
||||||
this->content.ForceResort();
|
this->content.ForceResort();
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
return ES_HANDLED;
|
return ES_HANDLED;
|
||||||
}
|
}
|
||||||
@ -679,7 +652,7 @@ public:
|
|||||||
this->ScrollToSelected();
|
this->ScrollToSelected();
|
||||||
|
|
||||||
/* redraw window */
|
/* redraw window */
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
return ES_HANDLED;
|
return ES_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,7 +660,7 @@ public:
|
|||||||
{
|
{
|
||||||
this->content.SetFilterState(!StrEmpty(this->edit_str_buf));
|
this->content.SetFilterState(!StrEmpty(this->edit_str_buf));
|
||||||
this->content.ForceRebuild();
|
this->content.ForceRebuild();
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnResize(Point delta)
|
virtual void OnResize(Point delta)
|
||||||
@ -707,13 +680,13 @@ public:
|
|||||||
virtual void OnReceiveContentInfo(const ContentInfo *rci)
|
virtual void OnReceiveContentInfo(const ContentInfo *rci)
|
||||||
{
|
{
|
||||||
this->content.ForceRebuild();
|
this->content.ForceRebuild();
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnDownloadComplete(ContentID cid)
|
virtual void OnDownloadComplete(ContentID cid)
|
||||||
{
|
{
|
||||||
this->content.ForceResort();
|
this->content.ForceResort();
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnConnect(bool success)
|
virtual void OnConnect(bool success)
|
||||||
@ -723,7 +696,39 @@ public:
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnInvalidateData(int data)
|
||||||
|
{
|
||||||
|
/* To sum all the bytes we intend to download */
|
||||||
|
this->filesize_sum = 0;
|
||||||
|
bool show_select_all = false;
|
||||||
|
bool show_select_upgrade = false;
|
||||||
|
for (ConstContentIterator iter = this->content.Begin(); iter != this->content.End(); iter++) {
|
||||||
|
const ContentInfo *ci = *iter;
|
||||||
|
switch (ci->state) {
|
||||||
|
case ContentInfo::SELECTED:
|
||||||
|
case ContentInfo::AUTOSELECTED:
|
||||||
|
this->filesize_sum += ci->filesize;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ContentInfo::UNSELECTED:
|
||||||
|
show_select_all = true;
|
||||||
|
show_select_upgrade |= ci->upgrade;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->SetWidgetDisabledState(NCLWW_DOWNLOAD, this->filesize_sum == 0 || FindWindowById(WC_NETWORK_STATUS_WINDOW, 0) != NULL);
|
||||||
|
this->SetWidgetDisabledState(NCLWW_UNSELECT, this->filesize_sum == 0);
|
||||||
|
this->SetWidgetDisabledState(NCLWW_SELECT_ALL, !show_select_all);
|
||||||
|
this->SetWidgetDisabledState(NCLWW_SELECT_UPDATE, !show_select_upgrade);
|
||||||
|
|
||||||
|
this->widget[NCLWW_CANCEL].data = this->filesize_sum == 0 ? STR_AI_SETTINGS_CLOSE : STR_AI_LIST_CANCEL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user