aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/TexturePackRepository.h
blob: 2b66df43b545560c6eafc4d8df06c93b345bed51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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);
};