From 053770d4a6827e73aea5074015dc2764f5099f12 Mon Sep 17 00:00:00 2001 From: yexo Date: Mon, 20 Aug 2012 21:03:50 +0000 Subject: (svn r24488) -Feature [FS#5236]: add buttons to view textfiles from the online content window (LordAro) --- src/network/core/tcp_content.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/network/core/tcp_content.cpp') 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(); -- cgit v1.2.3-54-g00ecf