From 3dae696b414d9141b3faa6872f3723332b7b6395 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 19 Jul 2020 21:20:27 +0100 Subject: Remove ProtocolPalettes --- src/Protocol/ProtocolPalettes.cpp | 107 -------------------------------------- 1 file changed, 107 deletions(-) delete mode 100644 src/Protocol/ProtocolPalettes.cpp (limited to 'src/Protocol/ProtocolPalettes.cpp') diff --git a/src/Protocol/ProtocolPalettes.cpp b/src/Protocol/ProtocolPalettes.cpp deleted file mode 100644 index 2dc0857a9..000000000 --- a/src/Protocol/ProtocolPalettes.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "Globals.h" -#include "ProtocolPalettes.h" -#include "../BlockTypePalette.h" - - - - - -void ProtocolPalettes::load(const AString & aProtocolFolder) -{ - auto contents = cFile::GetFolderContents(aProtocolFolder); - for (const auto & c: contents) - { - auto fullName = aProtocolFolder + cFile::PathSeparator() + c; - if (cFile::IsFolder(fullName)) - { - loadSingleVersion(c, fullName); - } - } -} - - - - - -std::shared_ptr ProtocolPalettes::blockTypePalette(const AString & aProtocolVersion) const -{ - cCSLock lock(mCS); - auto itr = mPalettes.find(aProtocolVersion); - if (itr == mPalettes.end()) - { - return nullptr; - } - return itr->second.mBlockTypePalette; -} - - - - - -std::vector ProtocolPalettes::protocolVersions() const -{ - cCSLock lock(mCS); - - std::vector res; - for (const auto & p: mPalettes) - { - res.push_back(p.first); - } - return res; -} - - - - - -void ProtocolPalettes::loadSingleVersion(const AString & aProtocolVersion, const AString & aFolder) -{ - // Get the file list, sort by name - auto contents = cFile::GetFolderContents(aFolder); - std::sort(contents.begin(), contents.end()); - - // Load files into the palettes: - cCSLock lock(mCS); - auto & pal = mPalettes[aProtocolVersion]; - for (const auto & c: contents) - { - if (c.length() < 8) - { - // Name too short, can't have the ".btp.txt" etc. suffix - continue; - } - auto fnam = aFolder + cFile::PathSeparator() + c; - if (!cFile::IsFile(fnam)) - { - continue; - } - auto fileType = c.substr(c.length() - 8); - if ((fileType == ".btp.txt") || (c == "blocks.json")) - { - try - { - pal.mBlockTypePalette->loadFromString(cFile::ReadWholeFile(fnam)); - } - catch (...) - { - // Ignore silently - } - } - else if ((fileType == ".itp.txt") || (c == "items.json")) - { - // TODO: Load item type palette - } - } -} - - - - - -//////////////////////////////////////////////////////////////////////////////// -// ProtocolPalettes::Palettes: - -ProtocolPalettes::Palettes::Palettes(): - mBlockTypePalette(new BlockTypePalette) -{ -} -- cgit v1.2.3