mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(svn r25999) -Add: When calling the 'content select' console command without args, display all selected content
This commit is contained in:
parent
a0cad0c1ea
commit
9088972738
@ -1716,6 +1716,22 @@ struct ConsoleContentCallback : public ContentCallback {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outputs content state information to console
|
||||||
|
* @param ci the content info
|
||||||
|
*/
|
||||||
|
static void OutputContentState(const ContentInfo *const ci)
|
||||||
|
{
|
||||||
|
static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music", "Game script", "GS library" };
|
||||||
|
assert_compile(lengthof(types) == CONTENT_TYPE_END - CONTENT_TYPE_BEGIN);
|
||||||
|
static const char * const states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" };
|
||||||
|
static const TextColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
|
||||||
|
|
||||||
|
char buf[sizeof(ci->md5sum) * 2 + 1];
|
||||||
|
md5sumToString(buf, lastof(buf), ci->md5sum);
|
||||||
|
IConsolePrintF(state_to_colour[ci->state], "%d, %s, %s, %s, %08X, %s", ci->id, types[ci->type - 1], states[ci->state], ci->name, ci->unique_id, buf);
|
||||||
|
}
|
||||||
|
|
||||||
DEF_CONSOLE_CMD(ConContent)
|
DEF_CONSOLE_CMD(ConContent)
|
||||||
{
|
{
|
||||||
static ContentCallback *cb = NULL;
|
static ContentCallback *cb = NULL;
|
||||||
@ -1728,7 +1744,7 @@ DEF_CONSOLE_CMD(ConContent)
|
|||||||
IConsoleHelp("Query, select and download content. Usage: 'content update|upgrade|select [all|id]|unselect [all|id]|state|download'");
|
IConsoleHelp("Query, select and download content. Usage: 'content update|upgrade|select [all|id]|unselect [all|id]|state|download'");
|
||||||
IConsoleHelp(" update: get a new list of downloadable content; must be run first");
|
IConsoleHelp(" update: get a new list of downloadable content; must be run first");
|
||||||
IConsoleHelp(" upgrade: select all items that are upgrades");
|
IConsoleHelp(" upgrade: select all items that are upgrades");
|
||||||
IConsoleHelp(" select: select a specific item given by its id or 'all' to select all");
|
IConsoleHelp(" select: select a specific item given by its id or 'all' to select all. If no parameter is given, all selected content will be listed");
|
||||||
IConsoleHelp(" unselect: unselect a specific item given by its id or 'all' to unselect all");
|
IConsoleHelp(" unselect: unselect a specific item given by its id or 'all' to unselect all");
|
||||||
IConsoleHelp(" state: show the download/select state of all downloadable content");
|
IConsoleHelp(" state: show the download/select state of all downloadable content");
|
||||||
IConsoleHelp(" download: download all content you've selected");
|
IConsoleHelp(" download: download all content you've selected");
|
||||||
@ -1747,10 +1763,13 @@ DEF_CONSOLE_CMD(ConContent)
|
|||||||
|
|
||||||
if (strcasecmp(argv[1], "select") == 0) {
|
if (strcasecmp(argv[1], "select") == 0) {
|
||||||
if (argc <= 2) {
|
if (argc <= 2) {
|
||||||
IConsoleError("You must enter the id.");
|
/* List selected content */
|
||||||
return false;
|
IConsolePrintF(CC_WHITE, "id, type, state, name");
|
||||||
|
for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
|
||||||
|
if ((*iter)->state != ContentInfo::SELECTED && (*iter)->state != ContentInfo::AUTOSELECTED) continue;
|
||||||
|
OutputContentState(*iter);
|
||||||
}
|
}
|
||||||
if (strcasecmp(argv[2], "all") == 0) {
|
} else if (strcasecmp(argv[2], "all") == 0) {
|
||||||
_network_content_client.SelectAll();
|
_network_content_client.SelectAll();
|
||||||
} else {
|
} else {
|
||||||
_network_content_client.Select((ContentID)atoi(argv[2]));
|
_network_content_client.Select((ContentID)atoi(argv[2]));
|
||||||
@ -1774,15 +1793,7 @@ DEF_CONSOLE_CMD(ConContent)
|
|||||||
if (strcasecmp(argv[1], "state") == 0) {
|
if (strcasecmp(argv[1], "state") == 0) {
|
||||||
IConsolePrintF(CC_WHITE, "id, type, state, name");
|
IConsolePrintF(CC_WHITE, "id, type, state, name");
|
||||||
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++) {
|
||||||
static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music", "Game script", "GS library" };
|
OutputContentState(*iter);
|
||||||
assert_compile(lengthof(types) == CONTENT_TYPE_END - CONTENT_TYPE_BEGIN);
|
|
||||||
static const char * const states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" };
|
|
||||||
static const TextColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
|
|
||||||
|
|
||||||
const ContentInfo *ci = *iter;
|
|
||||||
char buf[sizeof(ci->md5sum) * 2 + 1];
|
|
||||||
md5sumToString(buf, lastof(buf), ci->md5sum);
|
|
||||||
IConsolePrintF(state_to_colour[ci->state], "%d, %s, %s, %s, %08X, %s", ci->id, types[ci->type - 1], states[ci->state], ci->name, ci->unique_id, buf);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user