mirror of https://github.com/OpenTTD/OpenTTD
(svn r15178) -Change: rename 'update' to 'upgrade' as that's a bit more clear
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_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 :{BLACK}Select all
|
||||||
STR_CONTENT_SELECT_ALL_CAPTION_TIP :{BLACK}Mark all content to be downloaded
|
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 :{BLACK}Select upgrades
|
||||||
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_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 :{BLACK}Unselect all
|
||||||
STR_CONTENT_UNSELECT_ALL_CAPTION_TIP :{BLACK}Mark all content to be not downloaded
|
STR_CONTENT_UNSELECT_ALL_CAPTION_TIP :{BLACK}Mark all content to be not downloaded
|
||||||
STR_CONTENT_DOWNLOAD_CAPTION :{BLACK}Download
|
STR_CONTENT_DOWNLOAD_CAPTION :{BLACK}Download
|
||||||
|
|
|
@ -71,7 +71,7 @@ struct ContentInfo {
|
||||||
uint8 tag_count; ///< Number of tags
|
uint8 tag_count; ///< Number of tags
|
||||||
char (*tags)[32]; ///< Malloced array of tags (strings)
|
char (*tags)[32]; ///< Malloced array of tags (strings)
|
||||||
State state; ///< Whether the content info is selected (for download)
|
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 */
|
/** Clear everything in the struct */
|
||||||
ContentInfo();
|
ContentInfo();
|
||||||
|
@ -103,7 +103,7 @@ class NetworkContentSocketHandler : public NetworkTCPSocketHandler {
|
||||||
protected:
|
protected:
|
||||||
struct sockaddr_in client_addr; ///< The address we're connected to.
|
struct sockaddr_in client_addr; ///< The address we're connected to.
|
||||||
NetworkRecvStatus CloseConnection();
|
NetworkRecvStatus CloseConnection();
|
||||||
void Close();
|
virtual void Close();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client requesting a list of content info:
|
* 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;
|
ci->state = ContentInfo::ALREADY_HERE;
|
||||||
} else {
|
} else {
|
||||||
ci->state = ContentInfo::UNSELECTED;
|
ci->state = ContentInfo::UNSELECTED;
|
||||||
if (proc(ci, false)) ci->update = true;
|
if (proc(ci, false)) ci->upgrade = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ci->state = ContentInfo::UNSELECTED;
|
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) {
|
memcmp(ci->md5sum, ici->md5sum, sizeof(ci->md5sum)) == 0) {
|
||||||
/* Preserve the name if possible */
|
/* Preserve the name if possible */
|
||||||
if (StrEmpty(ci->name)) strecpy(ci->name, ici->name, lastof(ci->name));
|
if (StrEmpty(ci->name)) strecpy(ci->name, ici->name, lastof(ci->name));
|
||||||
|
if (ici->IsSelected()) ci->state = ici->state;
|
||||||
|
|
||||||
delete ici;
|
delete ici;
|
||||||
*iter = ci;
|
*iter = ci;
|
||||||
|
@ -145,6 +146,14 @@ DEF_CONTENT_RECEIVE_COMMAND(Client, PACKET_CONTENT_SERVER_INFO)
|
||||||
|
|
||||||
void ClientNetworkContentSocketHandler::RequestContentList(ContentType type)
|
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();
|
this->Connect();
|
||||||
|
|
||||||
Packet *p = new Packet(PACKET_CONTENT_CLIENT_INFO_LIST);
|
Packet *p = new Packet(PACKET_CONTENT_CLIENT_INFO_LIST);
|
||||||
|
@ -457,10 +466,12 @@ void ClientNetworkContentSocketHandler::Connect()
|
||||||
/**
|
/**
|
||||||
* Disconnect from the content server.
|
* Disconnect from the content server.
|
||||||
*/
|
*/
|
||||||
void ClientNetworkContentSocketHandler::Disconnect()
|
void ClientNetworkContentSocketHandler::Close()
|
||||||
{
|
{
|
||||||
if (this->sock == INVALID_SOCKET) return;
|
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)
|
void ClientNetworkContentSocketHandler::Select(ContentID cid)
|
||||||
{
|
{
|
||||||
ContentInfo *ci = this->GetContent(cid);
|
ContentInfo *ci = this->GetContent(cid);
|
||||||
if (ci->state != ContentInfo::UNSELECTED) return;
|
if (ci == NULL || ci->state != ContentInfo::UNSELECTED) return;
|
||||||
|
|
||||||
ci->state = ContentInfo::SELECTED;
|
ci->state = ContentInfo::SELECTED;
|
||||||
this->CheckDependencyState(ci);
|
this->CheckDependencyState(ci);
|
||||||
|
@ -545,7 +556,7 @@ void ClientNetworkContentSocketHandler::Select(ContentID cid)
|
||||||
void ClientNetworkContentSocketHandler::Unselect(ContentID cid)
|
void ClientNetworkContentSocketHandler::Unselect(ContentID cid)
|
||||||
{
|
{
|
||||||
ContentInfo *ci = this->GetContent(cid);
|
ContentInfo *ci = this->GetContent(cid);
|
||||||
if (!ci->IsSelected()) return;
|
if (ci == NULL || !ci->IsSelected()) return;
|
||||||
|
|
||||||
ci->state = ContentInfo::UNSELECTED;
|
ci->state = ContentInfo::UNSELECTED;
|
||||||
this->CheckDependencyState(ci);
|
this->CheckDependencyState(ci);
|
||||||
|
@ -564,11 +575,11 @@ void ClientNetworkContentSocketHandler::SelectAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Select everything that's an update for something we've got */
|
/** 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++) {
|
for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
|
||||||
ContentInfo *ci = *iter;
|
ContentInfo *ci = *iter;
|
||||||
if (ci->state == ContentInfo::UNSELECTED && ci->update) {
|
if (ci->state == ContentInfo::UNSELECTED && ci->upgrade) {
|
||||||
ci->state = ContentInfo::SELECTED;
|
ci->state = ContentInfo::SELECTED;
|
||||||
this->CheckDependencyState(ci);
|
this->CheckDependencyState(ci);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ public:
|
||||||
|
|
||||||
void Connect();
|
void Connect();
|
||||||
void SendReceive();
|
void SendReceive();
|
||||||
void Disconnect();
|
void Close();
|
||||||
|
|
||||||
void RequestContentList(ContentType type);
|
void RequestContentList(ContentType type);
|
||||||
void RequestContentList(uint count, const ContentID *content_ids);
|
void RequestContentList(uint count, const ContentID *content_ids);
|
||||||
|
@ -101,7 +101,7 @@ public:
|
||||||
void Select(ContentID cid);
|
void Select(ContentID cid);
|
||||||
void Unselect(ContentID cid);
|
void Unselect(ContentID cid);
|
||||||
void SelectAll();
|
void SelectAll();
|
||||||
void SelectUpdate();
|
void SelectUpgrade();
|
||||||
void UnselectAll();
|
void UnselectAll();
|
||||||
void ToggleSelectedState(const ContentInfo *ci);
|
void ToggleSelectedState(const ContentInfo *ci);
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ public:
|
||||||
/* To sum all the bytes we intend to download */
|
/* To sum all the bytes we intend to download */
|
||||||
uint filesize = 0;
|
uint filesize = 0;
|
||||||
bool show_select_all = false;
|
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++) {
|
for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
|
||||||
const ContentInfo *ci = *iter;
|
const ContentInfo *ci = *iter;
|
||||||
switch (ci->state) {
|
switch (ci->state) {
|
||||||
|
@ -236,7 +236,7 @@ public:
|
||||||
|
|
||||||
case ContentInfo::UNSELECTED:
|
case ContentInfo::UNSELECTED:
|
||||||
show_select_all = true;
|
show_select_all = true;
|
||||||
show_select_update |= ci->update;
|
show_select_upgrade |= ci->upgrade;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -247,7 +247,7 @@ public:
|
||||||
this->SetWidgetDisabledState(NCLWW_DOWNLOAD, filesize == 0);
|
this->SetWidgetDisabledState(NCLWW_DOWNLOAD, filesize == 0);
|
||||||
this->SetWidgetDisabledState(NCLWW_UNSELECT, filesize == 0);
|
this->SetWidgetDisabledState(NCLWW_UNSELECT, filesize == 0);
|
||||||
this->SetWidgetDisabledState(NCLWW_SELECT_ALL, !show_select_all);
|
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();
|
this->DrawWidgets();
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ public:
|
||||||
const uint max_y = this->widget[NCLWW_DETAILS].bottom - 15;
|
const uint max_y = this->widget[NCLWW_DETAILS].bottom - 15;
|
||||||
y = this->widget[NCLWW_DETAILS].top + 55;
|
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);
|
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 += 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;
|
y += 11;
|
||||||
|
@ -413,7 +413,7 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NCLWW_SELECT_UPDATE:
|
case NCLWW_SELECT_UPDATE:
|
||||||
_network_content_client.SelectUpdate();
|
_network_content_client.SelectUpgrade();
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -565,14 +565,7 @@ void ShowNetworkContentListWindow(ContentVector *cv, ContentType type)
|
||||||
{
|
{
|
||||||
#if defined(WITH_ZLIB)
|
#if defined(WITH_ZLIB)
|
||||||
if (cv == NULL) {
|
if (cv == NULL) {
|
||||||
if (type == CONTENT_TYPE_END) {
|
_network_content_client.RequestContentList(type);
|
||||||
_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);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
_network_content_client.RequestContentList(cv, true);
|
_network_content_client.RequestContentList(cv, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue