diff options
author | yexo <yexo@openttd.org> | 2012-08-20 21:03:50 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2012-08-20 21:03:50 +0000 |
commit | 053770d4a6827e73aea5074015dc2764f5099f12 (patch) | |
tree | 96a52d0905c9b76231f7f82d1cb0ab9a27d2c974 /src/network/core | |
parent | fe31aa28c422f1fab32ab3b72d8369d539c8496e (diff) | |
download | openttd-053770d4a6827e73aea5074015dc2764f5099f12.tar.xz |
(svn r24488) -Feature [FS#5236]: add buttons to view textfiles from the online content window (LordAro)
Diffstat (limited to 'src/network/core')
-rw-r--r-- | src/network/core/tcp_content.cpp | 51 | ||||
-rw-r--r-- | src/network/core/tcp_content.h | 1 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/network/core/tcp_content.cpp b/src/network/core/tcp_content.cpp index 131501a5c..7d8a898ef 100644 --- a/src/network/core/tcp_content.cpp +++ b/src/network/core/tcp_content.cpp @@ -14,6 +14,13 @@ #ifdef ENABLE_NETWORK #include "../../stdafx.h" +#include "../../textfile_gui.h" +#include "../../fileio_func.h" +#include "../../newgrf_config.h" +#include "../../base_media_base.h" +#include "../../ai/ai.hpp" +#include "../../game/game.hpp" +#include "../../fios.h" #include "tcp_content.h" /** Clear everything in the struct */ @@ -86,6 +93,50 @@ bool ContentInfo::IsValid() const return this->state < ContentInfo::INVALID && this->type >= CONTENT_TYPE_BEGIN && this->type < CONTENT_TYPE_END; } +/** + * Search a textfile file next to this file in the content list. + * @param type The type of the textfile to search for. + * @return The filename for the textfile, \c NULL otherwise. + */ +const char *ContentInfo::GetTextfile(TextfileType type) const +{ + if (this->state == INVALID) return NULL; + const char *tmp; + switch (this->type) { + default: NOT_REACHED(); + case CONTENT_TYPE_AI: + tmp = AI::GetScannerInfo()->FindMainScript(this, true); + break; + case CONTENT_TYPE_AI_LIBRARY: + tmp = AI::GetScannerLibrary()->FindMainScript(this, true); + break; + case CONTENT_TYPE_GAME: + tmp = Game::GetScannerInfo()->FindMainScript(this, true); + break; + case CONTENT_TYPE_GAME_LIBRARY: + tmp = Game::GetScannerLibrary()->FindMainScript(this, true); + break; + case CONTENT_TYPE_NEWGRF: + tmp = FindGRFConfig(BSWAP32(this->unique_id), FGCM_EXACT, this->md5sum)->filename; + break; + case CONTENT_TYPE_BASE_GRAPHICS: + tmp = TryGetBaseSetFile(this, true, BaseGraphics::GetAvailableSets()); + break; + case CONTENT_TYPE_BASE_SOUNDS: + tmp = TryGetBaseSetFile(this, true, BaseSounds::GetAvailableSets()); + break; + case CONTENT_TYPE_BASE_MUSIC: + tmp = TryGetBaseSetFile(this, true, BaseMusic::GetAvailableSets()); + break; + case CONTENT_TYPE_SCENARIO: + case CONTENT_TYPE_HEIGHTMAP: + tmp = FindScenario(this, true); + break; + } + if (tmp == NULL) return NULL; + return ::GetTextfile(type, GetContentInfoSubDir(this->type), tmp); +} + void NetworkContentSocketHandler::Close() { CloseConnection(); diff --git a/src/network/core/tcp_content.h b/src/network/core/tcp_content.h index 8e06bedb0..57e02d2a7 100644 --- a/src/network/core/tcp_content.h +++ b/src/network/core/tcp_content.h @@ -91,6 +91,7 @@ struct ContentInfo { size_t Size() const; bool IsSelected() const; bool IsValid() const; + const char *GetTextfile(TextfileType type) const; }; /** Base socket handler for all Content TCP sockets */ |