(svn r15178) -Change: rename 'update' to 'upgrade' as that's a bit more clear

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
rubidium 16 years ago
parent 052c957a94
commit ff328bf68b

@ -3725,8 +3725,8 @@ STR_CONTENT_NAME_CAPTION_TIP :{BLACK}Name of
STR_CONTENT_MATRIX_TIP :{BLACK}Click on a line to see the details{}Click on the checkbox to select it for downloading
STR_CONTENT_SELECT_ALL_CAPTION :{BLACK}Select all
STR_CONTENT_SELECT_ALL_CAPTION_TIP :{BLACK}Mark all content to be downloaded
STR_CONTENT_SELECT_UPDATES_CAPTION :{BLACK}Select updates
STR_CONTENT_SELECT_UPDATES_CAPTION_TIP :{BLACK}Mark all content that is an update for existing content to be downloaded
STR_CONTENT_SELECT_UPDATES_CAPTION :{BLACK}Select upgrades
STR_CONTENT_SELECT_UPDATES_CAPTION_TIP :{BLACK}Mark all content that is an upgrade for existing content to be downloaded
STR_CONTENT_UNSELECT_ALL_CAPTION :{BLACK}Unselect all
STR_CONTENT_UNSELECT_ALL_CAPTION_TIP :{BLACK}Mark all content to be not downloaded
STR_CONTENT_DOWNLOAD_CAPTION :{BLACK}Download

@ -71,7 +71,7 @@ struct ContentInfo {
uint8 tag_count; ///< Number of tags
char (*tags)[32]; ///< Malloced array of tags (strings)
State state; ///< Whether the content info is selected (for download)
bool update; ///< This item is an update
bool upgrade; ///< This item is an upgrade
/** Clear everything in the struct */
ContentInfo();
@ -103,7 +103,7 @@ class NetworkContentSocketHandler : public NetworkTCPSocketHandler {
protected:
struct sockaddr_in client_addr; ///< The address we're connected to.
NetworkRecvStatus CloseConnection();
void Close();
virtual void Close();
/**
* Client requesting a list of content info:

@ -100,7 +100,7 @@ DEF_CONTENT_RECEIVE_COMMAND(Client, PACKET_CONTENT_SERVER_INFO)
ci->state = ContentInfo::ALREADY_HERE;
} else {
ci->state = ContentInfo::UNSELECTED;
if (proc(ci, false)) ci->update = true;
if (proc(ci, false)) ci->upgrade = true;
}
} else {
ci->state = ContentInfo::UNSELECTED;
@ -116,6 +116,7 @@ DEF_CONTENT_RECEIVE_COMMAND(Client, PACKET_CONTENT_SERVER_INFO)
memcmp(ci->md5sum, ici->md5sum, sizeof(ci->md5sum)) == 0) {
/* Preserve the name if possible */
if (StrEmpty(ci->name)) strecpy(ci->name, ici->name, lastof(ci->name));
if (ici->IsSelected()) ci->state = ici->state;
delete ici;
*iter = ci;
@ -145,6 +146,14 @@ DEF_CONTENT_RECEIVE_COMMAND(Client, PACKET_CONTENT_SERVER_INFO)
void ClientNetworkContentSocketHandler::RequestContentList(ContentType type)
{
if (type == CONTENT_TYPE_END) {
this->RequestContentList(CONTENT_TYPE_BASE_GRAPHICS);
this->RequestContentList(CONTENT_TYPE_AI);
this->RequestContentList(CONTENT_TYPE_NEWGRF);
this->RequestContentList(CONTENT_TYPE_AI_LIBRARY);
return;
}
this->Connect();
Packet *p = new Packet(PACKET_CONTENT_CLIENT_INFO_LIST);
@ -457,10 +466,12 @@ void ClientNetworkContentSocketHandler::Connect()
/**
* Disconnect from the content server.
*/
void ClientNetworkContentSocketHandler::Disconnect()
void ClientNetworkContentSocketHandler::Close()
{
if (this->sock == INVALID_SOCKET) return;
this->Close();
NetworkContentSocketHandler::Close();
this->OnDisconnect();
}
/**
@ -532,7 +543,7 @@ ContentInfo *ClientNetworkContentSocketHandler::GetContent(ContentID cid)
void ClientNetworkContentSocketHandler::Select(ContentID cid)
{
ContentInfo *ci = this->GetContent(cid);
if (ci->state != ContentInfo::UNSELECTED) return;
if (ci == NULL || ci->state != ContentInfo::UNSELECTED) return;
ci->state = ContentInfo::SELECTED;
this->CheckDependencyState(ci);
@ -545,7 +556,7 @@ void ClientNetworkContentSocketHandler::Select(ContentID cid)
void ClientNetworkContentSocketHandler::Unselect(ContentID cid)
{
ContentInfo *ci = this->GetContent(cid);
if (!ci->IsSelected()) return;
if (ci == NULL || !ci->IsSelected()) return;
ci->state = ContentInfo::UNSELECTED;
this->CheckDependencyState(ci);
@ -564,11 +575,11 @@ void ClientNetworkContentSocketHandler::SelectAll()
}
/** Select everything that's an update for something we've got */
void ClientNetworkContentSocketHandler::SelectUpdate()
void ClientNetworkContentSocketHandler::SelectUpgrade()
{
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
ContentInfo *ci = *iter;
if (ci->state == ContentInfo::UNSELECTED && ci->update) {
if (ci->state == ContentInfo::UNSELECTED && ci->upgrade) {
ci->state = ContentInfo::SELECTED;
this->CheckDependencyState(ci);
}

@ -90,7 +90,7 @@ public:
void Connect();
void SendReceive();
void Disconnect();
void Close();
void RequestContentList(ContentType type);
void RequestContentList(uint count, const ContentID *content_ids);
@ -101,7 +101,7 @@ public:
void Select(ContentID cid);
void Unselect(ContentID cid);
void SelectAll();
void SelectUpdate();
void SelectUpgrade();
void UnselectAll();
void ToggleSelectedState(const ContentInfo *ci);

@ -225,7 +225,7 @@ public:
/* To sum all the bytes we intend to download */
uint filesize = 0;
bool show_select_all = false;
bool show_select_update = false;
bool show_select_upgrade = false;
for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
const ContentInfo *ci = *iter;
switch (ci->state) {
@ -236,7 +236,7 @@ public:
case ContentInfo::UNSELECTED:
show_select_all = true;
show_select_update |= ci->update;
show_select_upgrade |= ci->upgrade;
break;
default:
@ -247,7 +247,7 @@ public:
this->SetWidgetDisabledState(NCLWW_DOWNLOAD, filesize == 0);
this->SetWidgetDisabledState(NCLWW_UNSELECT, filesize == 0);
this->SetWidgetDisabledState(NCLWW_SELECT_ALL, !show_select_all);
this->SetWidgetDisabledState(NCLWW_SELECT_UPDATE, !show_select_update);
this->SetWidgetDisabledState(NCLWW_SELECT_UPDATE, !show_select_upgrade);
this->DrawWidgets();
@ -292,7 +292,7 @@ public:
const uint max_y = this->widget[NCLWW_DETAILS].bottom - 15;
y = this->widget[NCLWW_DETAILS].top + 55;
if (this->selected->update) {
if (this->selected->upgrade) {
SetDParam(0, STR_CONTENT_TYPE_BASE_GRAPHICS + this->selected->type - CONTENT_TYPE_BASE_GRAPHICS);
y += DrawStringMultiLine(this->widget[NCLWW_DETAILS].left + 5, y, STR_CONTENT_DETAIL_UPDATE, this->widget[NCLWW_DETAILS].right - this->widget[NCLWW_DETAILS].left - 5, max_y - y);
y += 11;
@ -413,7 +413,7 @@ public:
break;
case NCLWW_SELECT_UPDATE:
_network_content_client.SelectUpdate();
_network_content_client.SelectUpgrade();
this->SetDirty();
break;
@ -565,14 +565,7 @@ void ShowNetworkContentListWindow(ContentVector *cv, ContentType type)
{
#if defined(WITH_ZLIB)
if (cv == NULL) {
if (type == CONTENT_TYPE_END) {
_network_content_client.RequestContentList(CONTENT_TYPE_BASE_GRAPHICS);
_network_content_client.RequestContentList(CONTENT_TYPE_AI);
_network_content_client.RequestContentList(CONTENT_TYPE_NEWGRF);
_network_content_client.RequestContentList(CONTENT_TYPE_AI_LIBRARY);
} else {
_network_content_client.RequestContentList(type);
}
_network_content_client.RequestContentList(type);
} else {
_network_content_client.RequestContentList(cv, true);
}

Loading…
Cancel
Save