mirror of https://github.com/OpenTTD/OpenTTD
(svn r15221) -Change [FS#2574]: only show missing NewGRFs when opening the content download window from a NewGRF list and there are missing NewGRFs, otherwise show just all NewGRFs the system knows.
parent
67a2dd12e8
commit
8382b76b0f
|
@ -3779,4 +3779,6 @@ STR_CONTENT_ERROR_COULD_NOT_EXTRACT :{WHITE}Could no
|
||||||
|
|
||||||
STR_CONTENT_INTRO_BUTTON :{BLACK}Check online content
|
STR_CONTENT_INTRO_BUTTON :{BLACK}Check online content
|
||||||
STR_CONTENT_INTRO_BUTTON_TIP :{BLACK}Check for new and updated content to download
|
STR_CONTENT_INTRO_BUTTON_TIP :{BLACK}Check for new and updated content to download
|
||||||
|
STR_CONTENT_INTRO_MISSING_BUTTON :{BLACK}Find missing content online
|
||||||
|
STR_CONTENT_INTRO_MISSING_BUTTON_TIP :{BLACK}Check whether the missing content can be found online
|
||||||
########
|
########
|
||||||
|
|
|
@ -218,7 +218,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||||
ContentInfo *ci = *iter;
|
ContentInfo *ci = *iter;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (ContentIterator iter2 = this->infos.Begin(); iter2 != this->infos.End(); iter2++) {
|
for (ContentIterator iter2 = this->infos.Begin(); iter2 != this->infos.End(); iter2++) {
|
||||||
ContentInfo *ci2 = *iter;
|
ContentInfo *ci2 = *iter2;
|
||||||
if (ci->type == ci2->type && ci->unique_id == ci2->unique_id &&
|
if (ci->type == ci2->type && ci->unique_id == ci2->unique_id &&
|
||||||
(!send_md5sum || memcmp(ci->md5sum, ci2->md5sum, sizeof(ci->md5sum)) == 0)) {
|
(!send_md5sum || memcmp(ci->md5sum, ci2->md5sum, sizeof(ci->md5sum)) == 0)) {
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -746,6 +746,13 @@ void ClientNetworkContentSocketHandler::CheckDependencyState(ContentInfo *ci)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientNetworkContentSocketHandler::Clear()
|
||||||
|
{
|
||||||
|
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) delete *iter;
|
||||||
|
|
||||||
|
this->infos.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
/*** CALLBACK ***/
|
/*** CALLBACK ***/
|
||||||
|
|
||||||
void ClientNetworkContentSocketHandler::OnConnect(bool success)
|
void ClientNetworkContentSocketHandler::OnConnect(bool success)
|
||||||
|
|
|
@ -117,6 +117,8 @@ public:
|
||||||
ConstContentIterator Get(uint32 index) const { return this->infos.Get(index); }
|
ConstContentIterator Get(uint32 index) const { return this->infos.Get(index); }
|
||||||
/** Get the end of the content inf iterator. */
|
/** Get the end of the content inf iterator. */
|
||||||
ConstContentIterator End() const { return this->infos.End(); }
|
ConstContentIterator End() const { return this->infos.End(); }
|
||||||
|
/** Clear all downloaded content information. */
|
||||||
|
void Clear();
|
||||||
|
|
||||||
/** Add a callback to this class */
|
/** Add a callback to this class */
|
||||||
void AddCallback(ContentCallback *cb) { this->callbacks.Include(cb); }
|
void AddCallback(ContentCallback *cb) { this->callbacks.Include(cb); }
|
||||||
|
|
|
@ -684,6 +684,7 @@ static const WindowDesc _network_content_list_desc = {
|
||||||
void ShowNetworkContentListWindow(ContentVector *cv, ContentType type)
|
void ShowNetworkContentListWindow(ContentVector *cv, ContentType type)
|
||||||
{
|
{
|
||||||
#if defined(WITH_ZLIB)
|
#if defined(WITH_ZLIB)
|
||||||
|
_network_content_client.Clear();
|
||||||
if (cv == NULL) {
|
if (cv == NULL) {
|
||||||
_network_content_client.RequestContentList(type);
|
_network_content_client.RequestContentList(type);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -399,6 +399,18 @@ struct NewGRFWindow : public Window {
|
||||||
this->widget[SNGRFS_PRESET_LIST].data = STR_JUST_RAW_STRING;
|
this->widget[SNGRFS_PRESET_LIST].data = STR_JUST_RAW_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool has_missing = false;
|
||||||
|
for (const GRFConfig *c = this->list; !has_missing && c != NULL; c = c->next) {
|
||||||
|
has_missing = c->status == GCS_NOT_FOUND || HasBit(c->flags, GCF_COMPATIBLE);
|
||||||
|
}
|
||||||
|
if (has_missing) {
|
||||||
|
this->widget[SNGRFS_CONTENT_DOWNLOAD].data = STR_CONTENT_INTRO_MISSING_BUTTON;
|
||||||
|
this->widget[SNGRFS_CONTENT_DOWNLOAD].tooltips = STR_CONTENT_INTRO_MISSING_BUTTON_TIP;
|
||||||
|
} else {
|
||||||
|
this->widget[SNGRFS_CONTENT_DOWNLOAD].data = STR_CONTENT_INTRO_BUTTON;
|
||||||
|
this->widget[SNGRFS_CONTENT_DOWNLOAD].tooltips = STR_CONTENT_INTRO_BUTTON_TIP;
|
||||||
|
}
|
||||||
|
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
|
|
||||||
/* Draw NewGRF list */
|
/* Draw NewGRF list */
|
||||||
|
@ -597,6 +609,8 @@ struct NewGRFWindow : public Window {
|
||||||
/* Only show the things in the current list, or everything when nothing's selected */
|
/* Only show the things in the current list, or everything when nothing's selected */
|
||||||
ContentVector cv;
|
ContentVector cv;
|
||||||
for (const GRFConfig *c = this->list; c != NULL; c = c->next) {
|
for (const GRFConfig *c = this->list; c != NULL; c = c->next) {
|
||||||
|
if (c->status != GCS_NOT_FOUND && !HasBit(c->flags, GCF_COMPATIBLE)) continue;
|
||||||
|
|
||||||
ContentInfo *ci = new ContentInfo();
|
ContentInfo *ci = new ContentInfo();
|
||||||
ci->type = CONTENT_TYPE_NEWGRF;
|
ci->type = CONTENT_TYPE_NEWGRF;
|
||||||
ci->state = ContentInfo::DOES_NOT_EXIST;
|
ci->state = ContentInfo::DOES_NOT_EXIST;
|
||||||
|
|
Loading…
Reference in New Issue