diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/TexturePackRepository.h | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/TexturePackRepository.h')
| -rw-r--r-- | Minecraft.Client/TexturePackRepository.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Minecraft.Client/TexturePackRepository.h b/Minecraft.Client/TexturePackRepository.h new file mode 100644 index 00000000..2b66df43 --- /dev/null +++ b/Minecraft.Client/TexturePackRepository.h @@ -0,0 +1,77 @@ +#pragma once +#include "TexturePack.h" +using namespace std; + +class Minecraft; + +class TexturePackRepository +{ +public: + static const DWORD DEFAULT_TEXTURE_PACK_ID = 0; + static const DWORD FOLDER_TEST_TEXTURE_PACK_ID = 1; + static const DWORD DLC_TEST_TEXTURE_PACK_ID = 2; +private: + static TexturePack *DEFAULT_TEXTURE_PACK; + TexturePack *m_dummyTexturePack; + TexturePack *m_dummyDLCTexturePack; + + Minecraft *minecraft; + File workDir; + File multiplayerDir; + vector<TexturePack *> *texturePacks; + vector<TexturePack *> m_texturePacksToDelete; + + unordered_map<DWORD, TexturePack *> cacheById; + + TexturePack *selected; + TexturePack *lastSelected; + bool usingWeb; + static const int MAX_WEB_FILESIZE = 10 * 1000 * 1000; // 10 Megabytes + +public: + TexturePackRepository(File workingDirectory, Minecraft *minecraft); + void addDebugPacks(); +private: + void createWorkingDirecoryUnlessExists(); + +public: + bool selectSkin(TexturePack *skin); + + void selectWebSkin(const wstring &url); + +private: + void downloadWebSkin(const wstring &url, File file); + +public: + bool isUsingWebSkin(); + void resetWebSkin(); + void updateList(); + +private: + wstring getIdOrNull(File file); + vector<File> getWorkDirContents(); + +public: + vector<TexturePack *> *getAll(); + + TexturePack *getSelected(); + bool shouldPromptForWebSkin(); + bool canUseWebSkin(); + bool isUsingDefaultSkin() { return selected == DEFAULT_TEXTURE_PACK; } // 4J Added + TexturePack *getDefault() { return DEFAULT_TEXTURE_PACK; } // 4J Added + + vector< pair<DWORD,wstring> > *getTexturePackIdNames(); + bool selectTexturePackById(DWORD id); // 4J Added + TexturePack *getTexturePackById(DWORD id); // 4J Added + + TexturePack *addTexturePackFromDLC(DLCPack *dlcPack, DWORD id); + void clearInvalidTexturePacks(); + void updateUI(); + bool needsUIUpdate(); +private: + void removeTexturePackById(DWORD id); +public: + unsigned int getTexturePackCount(); + TexturePack *getTexturePackByIndex(unsigned int index); + unsigned int getTexturePackIndex(unsigned int id); +}; |
