the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2#include "..\Minecraft.World\ArrayWithLength.h"
3
4class DynamicTexture;
5class BufferedImage;
6class HttpTexture;
7class MemTexture;
8class TexturePackRepository;
9class HttpTextureProcessor;
10class MemTextureProcessor;
11class Options;
12using namespace std;
13class IntBuffer;
14class PreStitchedTextureMap;
15class ResourceLocation;
16
17
18typedef enum _TEXTURE_NAME
19{
20 TN__BLUR__MISC_PUMPKINBLUR,
21// TN__BLUR__MISC_VIGNETTE, // Not currently used
22 TN__CLAMP__MISC_SHADOW,
23// TN_ACHIEVEMENT_BG, // Not currently used
24 TN_ART_KZ,
25 TN_ENVIRONMENT_CLOUDS,
26 TN_ENVIRONMENT_RAIN,
27 TN_ENVIRONMENT_SNOW,
28 TN_GUI_GUI,
29 TN_GUI_ICONS,
30 TN_ITEM_ARROWS,
31 TN_ITEM_BOAT,
32 TN_ITEM_CART,
33 TN_ITEM_SIGN,
34 TN_MISC_MAPBG,
35 TN_MISC_MAPICONS,
36 TN_MISC_WATER,
37 TN_MISC_FOOTSTEP,
38 TN_MOB_SADDLE,
39 TN_MOB_SHEEP_FUR,
40 TN_MOB_SPIDER_EYES,
41 TN_PARTICLES,
42 TN_MOB_CHICKEN,
43 TN_MOB_COW,
44 TN_MOB_PIG,
45 TN_MOB_SHEEP,
46 TN_MOB_SQUID,
47 TN_MOB_WOLF,
48 TN_MOB_WOLF_TAME,
49 TN_MOB_WOLF_ANGRY,
50 TN_MOB_CREEPER,
51 TN_MOB_GHAST,
52 TN_MOB_GHAST_FIRE,
53 TN_MOB_ZOMBIE,
54 TN_MOB_PIGZOMBIE,
55 TN_MOB_SKELETON,
56 TN_MOB_SLIME,
57 TN_MOB_SPIDER,
58 TN_MOB_CHAR,
59 TN_MOB_CHAR1,
60 TN_MOB_CHAR2,
61 TN_MOB_CHAR3,
62 TN_MOB_CHAR4,
63 TN_MOB_CHAR5,
64 TN_MOB_CHAR6,
65 TN_MOB_CHAR7,
66 TN_TERRAIN_MOON,
67 TN_TERRAIN_SUN,
68 TN_POWERED_CREEPER,
69
70 // 1.8.2
71 TN_MOB_CAVE_SPIDER,
72 TN_MOB_ENDERMAN,
73 TN_MOB_SILVERFISH,
74 TN_MOB_ENDERMAN_EYES,
75 TN_MISC_EXPLOSION,
76 TN_ITEM_EXPERIENCE_ORB,
77 TN_TILE_CHEST,
78 TN_TILE_LARGE_CHEST,
79
80 // 1.3.2
81 TN_TILE_ENDER_CHEST,
82
83 // 1.0.1
84 TN_MOB_RED_COW,
85 TN_MOB_SNOWMAN,
86 TN_MOB_ENDERDRAGON,
87 TN_MOB_BLAZE,
88 TN_MOB_LAVA,
89 TN_MOB_VILLAGER_VILLAGER,
90 TN_MOB_VILLAGER_FARMER,
91 TN_MOB_VILLAGER_LIBRARIAN,
92 TN_MOB_VILLAGER_PRIEST,
93 TN_MOB_VILLAGER_SMITH,
94 TN_MOB_VILLAGER_BUTCHER,
95 TN_MOB_ENDERDRAGON_ENDERCRYSTAL,
96 TN_MOB_ENDERDRAGON_SHUFFLE,
97 TN_MOB_ENDERDRAGON_BEAM,
98 TN_MOB_ENDERDRAGON_ENDEREYES,
99 TN__BLUR__MISC_GLINT,
100 TN_ITEM_BOOK,
101 TN_MISC_TUNNEL,
102 TN_MISC_PARTICLEFIELD,
103 TN_TERRAIN_MOON_PHASES,
104
105 // 1.2.3
106 TN_MOB_OCELOT,
107 TN_MOB_CAT_BLACK,
108 TN_MOB_CAT_RED,
109 TN_MOB_CAT_SIAMESE,
110 TN_MOB_VILLAGER_GOLEM,
111 TN_MOB_WITHER_SKELETON,
112
113 // TU14
114 TN_MOB_WOLF_COLLAR,
115 TN_MOB_ZOMBIE_VILLAGER,
116
117 // 1.6.4
118 TN_ITEM_LEASHKNOT,
119
120 TN_MISC_BEACON_BEAM,
121
122 TN_MOB_BAT,
123
124 TN_MOB_DONKEY,
125 TN_MOB_HORSE_BLACK,
126 TN_MOB_HORSE_BROWN,
127 TN_MOB_HORSE_CHESTNUT,
128 TN_MOB_HORSE_CREAMY,
129 TN_MOB_HORSE_DARKBROWN,
130 TN_MOB_HORSE_GRAY,
131 TN_MOB_HORSE_MARKINGS_BLACKDOTS,
132 TN_MOB_HORSE_MARKINGS_WHITE,
133 TN_MOB_HORSE_MARKINGS_WHITEDOTS,
134 TN_MOB_HORSE_MARKINGS_WHITEFIELD,
135 TN_MOB_HORSE_SKELETON,
136 TN_MOB_HORSE_WHITE,
137 TN_MOB_HORSE_ZOMBIE,
138 TN_MOB_MULE,
139 TN_MOB_HORSE_ARMOR_DIAMOND,
140 TN_MOB_HORSE_ARMOR_GOLD,
141 TN_MOB_HORSE_ARMOR_IRON,
142
143 TN_MOB_WITCH,
144
145 TN_MOB_WITHER,
146 TN_MOB_WITHER_ARMOR,
147 TN_MOB_WITHER_INVULNERABLE,
148
149 TN_TILE_TRAP_CHEST,
150 TN_TILE_LARGE_TRAP_CHEST,
151 //TN_TILE_XMAS_CHEST,
152 //TN_TILE_LARGE_XMAS_CHEST,
153
154#ifdef _LARGE_WORLDS
155 TN_MISC_ADDITIONALMAPICONS,
156#endif
157
158 TN_DEFAULT_FONT,
159 TN_ALT_FONT,
160
161/* TN_SP1,
162 TN_SP2,
163 TN_SP3,
164 TN_SPF,
165 TN_THST,
166 TN_THIR,
167 TN_THGO,
168 TN_THDI,
169 TN_GPAN,
170 TN_GPCO,
171 TN_GPEN,
172 TN_GPFO,
173 TN_GPTO,
174 TN_GPBA,
175 TN_GPFA,
176 TN_GPME,
177 TN_GPMF,
178 TN_GPMM,
179 TN_GPSE,
180 TN_AH_0006,
181 TN_AH_0003,
182 TN_AH_0007,
183 TN_AH_0005,
184 TN_AH_0004,
185 TN_AH_0001,
186 TN_AH_0002,
187 TN_AT_0001,
188 TN_AT_0002,
189 TN_AT_0003,
190 TN_AT_0004,
191 TN_AT_0005,
192 TN_AT_0006,
193 TN_AT_0007,
194 TN_AT_0008,
195 TN_AT_0009,
196 TN_AT_0010,
197 TN_AT_0011,
198 TN_AT_0012,
199 TN_AP_0001,
200 TN_AP_0002,
201 TN_AP_0003,
202 TN_AP_0004,
203 TN_AP_0005,
204 TN_AP_0006,
205 TN_AP_0007,
206 TN_AP_0009,
207 TN_AP_0010,
208 TN_AP_0011,
209 TN_AP_0012,
210 TN_AP_0013,
211 TN_AP_0014,
212 TN_AP_0015,
213 TN_AP_0016,
214 TN_AP_0017,
215 TN_AP_0018,
216 TN_AA_0001,
217 TN_AT_0013,
218 TN_AT_0014,
219 TN_AT_0015,
220 TN_AT_0016,
221 TN_AT_0017,
222 TN_AT_0018,
223 TN_AP_0019,
224 TN_AP_0020,
225 TN_AP_0021,
226 TN_AP_0022,
227 TN_AP_0023,
228 TN_AH_0008,
229 TN_AH_0009,*/
230
231 TN_GUI_ITEMS,
232 TN_TERRAIN,
233
234 TN_COUNT,
235
236}
237TEXTURE_NAME;
238
239class Textures
240{
241public:
242 static bool MIPMAP;
243 static C4JRender::eTextureFormat TEXTURE_FORMAT;
244
245private:
246 static wchar_t *preLoaded[TN_COUNT];
247 static int preLoadedIdx[TN_COUNT];
248
249 unordered_map<wstring, int> idMap;
250 unordered_map<wstring, intArray> pixelsMap;
251 unordered_map<int, BufferedImage *> loadedImages;
252 //IntBuffer *pixels; // 4J - removed so we don't have a permanent buffer kicking round using up 1MB
253
254 unordered_map<wstring, HttpTexture *> httpTextures;
255 // 4J-PB - Added for GTS textures
256 unordered_map<wstring,MemTexture *> memTextures;
257 Options *options;
258
259private:
260 TexturePackRepository *skins;
261 BufferedImage *missingNo;
262 PreStitchedTextureMap *terrain;
263 PreStitchedTextureMap *items;
264
265 int lastBoundId;
266public:
267 Textures(TexturePackRepository *skins, Options *options);
268
269private:
270 void loadIndexedTextures(); // 4J Added
271
272public:
273 intArray loadTexturePixels(TEXTURE_NAME texId, const wstring& resourceName);
274private:
275 intArray loadTexturePixels(BufferedImage *img);
276 intArray loadTexturePixels(BufferedImage *img, intArray pixels);
277 void setTextureFormat(const wstring& resourceName); // 4J added
278
279public:
280 void bindTexture(const wstring &resourceName);
281 void bindTexture(ResourceLocation *resource); // 4J Added
282 void bindTextureLayers(ResourceLocation *resource); // 4J added
283
284 // 4J Made public for use in XUI controls
285 void bind(int id);
286
287 ResourceLocation *getTextureLocation(shared_ptr<Entity> entity);
288 ResourceLocation *getTextureLocation(int iconType);
289
290public:
291 void clearLastBoundId();
292
293private:
294 int loadTexture(TEXTURE_NAME texId, const wstring& resourceName);
295public:
296 int loadTexture(int idx); // 4J added
297 int getTexture(BufferedImage *img, C4JRender::eTextureFormat format = C4JRender::TEXTURE_FORMAT_RxGyBzAw, bool mipmap = true);
298 void loadTexture(BufferedImage *img, int id);
299 void loadTexture(BufferedImage *img, int id, bool blur, bool clamp);
300private:
301 intArray anaglyph(intArray rawPixels);
302public:
303 void replaceTexture(intArray rawPixels, int w, int h, int id);
304 void replaceTextureDirect(intArray rawPixels, int w, int h, int id); // 4J added as optimisation
305 void replaceTextureDirect(shortArray rawPixels, int w, int h, int id); // 4J added as optimisation
306 void releaseTexture(int id);
307 int loadHttpTexture(const wstring& url, const wstring& backup);
308 int loadHttpTexture(const wstring& url, int backup); // 4J added
309 bool hasHttpTexture(const wstring &url);
310 HttpTexture *addHttpTexture(const wstring& url, HttpTextureProcessor *processor);
311 void removeHttpTexture(const wstring& url);
312
313 // 4J-PB - for the GTS textures
314 int loadMemTexture(const wstring& url, const wstring& backup);
315 int loadMemTexture(const wstring& url, int backup);
316 MemTexture * addMemTexture(const wstring& url, MemTextureProcessor *processor);
317 //MemTexture * getMemTexture(const wstring& url, MemTextureProcessor *processor);
318 void removeMemTexture(const wstring& url);
319
320 void tick(bool updateTextures, bool tickDynamics = true); // 4J added updateTextures parameter & tickDynamics
321public:
322 void reloadAll();
323 void stitch();
324 Icon *getMissingIcon(int type);
325 BufferedImage *readImage(TEXTURE_NAME texId, const wstring& name); // Moved this to public for Font.cpp access
326 // check list of title update textures to see if we need to use the UPDATE: drive
327 static bool IsTUImage(TEXTURE_NAME texId, const wstring& name);
328 static bool IsOriginalImage(TEXTURE_NAME texId, const wstring& name);
329};