2499
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
2541
|
6
|
|
7 #include "Engine/Engine.h"
|
2575
|
8 #include "Engine/Serialization/LegacyImages.h"
|
2541
|
9
|
2499
|
10 #include "IconFrameTable.h"
|
|
11 #include "../LOD.h"
|
|
12 #include "FrameTableInc.h"
|
|
13
|
2575
|
14
|
|
15 Icon *IconFrameTable::GetIcon(unsigned int idx)
|
|
16 {
|
|
17 if (idx < this->uNumIcons)
|
|
18 return &this->pIcons[idx];
|
|
19 return nullptr;
|
|
20 }
|
|
21
|
|
22 Icon *IconFrameTable::GetIcon(const char *pIconName)
|
|
23 {
|
|
24 for (unsigned int i = 0; i < this->uNumIcons; i++)
|
|
25 {
|
|
26 if (!_stricmp(pIconName, this->pIcons[i].GetAnimationName()))
|
|
27 return &this->pIcons[i];
|
|
28 }
|
|
29 return nullptr;
|
|
30 }
|
|
31
|
|
32
|
|
33
|
2499
|
34 //----- (00494F3A) --------------------------------------------------------
|
|
35 unsigned int IconFrameTable::FindIcon(const char *pIconName)
|
|
36 {
|
|
37 for ( uint i = 0; i < (signed int)this->uNumIcons; i++ )
|
|
38 {
|
2575
|
39 if ( !_stricmp(pIconName, this->pIcons[i].GetAnimationName()) )
|
2499
|
40 return i;
|
|
41 }
|
|
42 return 0;
|
|
43 }
|
|
44
|
|
45 //----- (00494F70) --------------------------------------------------------
|
2575
|
46 Icon *IconFrameTable::GetFrame(unsigned int uIconID, unsigned int frame_time)
|
2499
|
47 {
|
|
48 int v6; // edx@3
|
|
49 uint i;
|
|
50
|
2575
|
51 if ( this->pIcons[uIconID].uFlags & 1 && this->pIcons[uIconID].GetAnimLength() != 0 )
|
2499
|
52 {
|
2575
|
53 int t = frame_time;
|
|
54
|
|
55 t = (t /*/ 8*/) % (unsigned __int16)this->pIcons[uIconID].GetAnimLength();
|
|
56 t /= 8;
|
|
57 for ( i = uIconID; t > this->pIcons[i].GetAnimTime(); i++ )
|
|
58 t -= this->pIcons[i].GetAnimTime();
|
2499
|
59 return &this->pIcons[i];
|
|
60 }
|
|
61 else
|
|
62 return &this->pIcons[uIconID];
|
|
63 }
|
|
64
|
|
65 //----- (00494FBF) --------------------------------------------------------
|
|
66 void IconFrameTable::InitializeAnimation(unsigned int uIconID)
|
|
67 {
|
|
68 if ( uIconID && (signed int)uIconID <= (signed int)this->uNumIcons )
|
|
69 {
|
|
70 for ( uint i = uIconID; ; ++i )
|
|
71 {
|
2575
|
72 //this->pIcons[i].uTextureID = pIcons_LOD->LoadTexture(this->pIcons[i].pTextureName, TEXTURE_16BIT_PALETTE);
|
|
73 this->pIcons[i].texture = assets->GetImage_16BitColorKey(this->pIcons[i].pTextureName, 0x7FF);
|
2499
|
74 if ( !(this->pIcons[i].uFlags & 1) )
|
|
75 break;
|
|
76 }
|
|
77 }
|
|
78 }
|
|
79
|
|
80 //----- (0049500A) --------------------------------------------------------
|
|
81 void IconFrameTable::ToFile()
|
|
82 {
|
|
83 //IconFrameTable *v1; // esi@1
|
|
84 FILE *v2; // eax@1
|
|
85 //FILE *v3; // edi@1
|
|
86
|
|
87 //IconFrameTable* Str = this;
|
|
88
|
|
89 //v1 = Str;
|
|
90 v2 = fopen("data\\dift.bin", "wb");
|
|
91 //v3 = v2;
|
|
92 if ( !v2 )
|
|
93 Error("Unable to save dift.bin!");
|
|
94 fwrite(this, 4, 1, v2);
|
|
95 fwrite(this->pIcons, 0x20u, this->uNumIcons, v2);
|
|
96 fclose(v2);
|
|
97 }
|
|
98
|
|
99 //----- (00495056) --------------------------------------------------------
|
|
100 void IconFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8)
|
|
101 {
|
|
102 uint num_mm6_frames = data_mm6 ? *(int *)data_mm6 : 0,
|
|
103 num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0,
|
|
104 num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0;
|
|
105
|
|
106 uNumIcons = num_mm6_frames + num_mm7_frames + num_mm8_frames;
|
|
107 Assert(uNumIcons);
|
2575
|
108 Assert(!num_mm6_frames);
|
2499
|
109 Assert(!num_mm8_frames);
|
|
110
|
2575
|
111 IconFrame_MM7 *pIcons = (IconFrame_MM7 *)malloc(uNumIcons * sizeof(IconFrame_MM7));
|
|
112 memcpy(pIcons, (char *)data_mm7 + 4, num_mm7_frames * sizeof(IconFrame_MM7));
|
|
113 //memcpy(pIcons + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(IconFrame_MM7));
|
|
114 //memcpy(pIcons + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(IconFrame_MM7));
|
|
115
|
|
116 this->pIcons = new Icon[uNumIcons];
|
|
117 for (unsigned int i = 0; i < uNumIcons; ++i)
|
|
118 {
|
|
119 pIcons[i].Deserialize(&this->pIcons[i]);
|
|
120
|
|
121 this->pIcons[i].id = i;
|
|
122 }
|
2499
|
123 }
|
|
124
|
2575
|
125 /*
|
2499
|
126 //----- (0049509D) --------------------------------------------------------
|
|
127 int IconFrameTable::FromFileTxt(const char *Args)
|
|
128 {
|
|
129 //IconFrameTable *v2; // ebx@1
|
|
130 FILE *v3; // eax@1
|
|
131 int v4; // esi@3
|
|
132 void *v5; // eax@10
|
|
133 FILE *v6; // ST0C_4@12
|
|
134 char *i; // eax@12
|
|
135 const char *v8; // ST00_4@15
|
|
136 int v9; // eax@16
|
|
137 int v10; // edx@20
|
|
138 int v11; // ecx@21
|
|
139 int v12; // eax@22
|
|
140 signed int j; // edx@25
|
2575
|
141 IconFrame_MM7 *v14; // ecx@26
|
2499
|
142 int v15; // esi@26
|
|
143 int k; // eax@27
|
|
144 signed int result; // eax@11
|
|
145 char Buf; // [sp+Ch] [bp-2F8h]@3
|
|
146 FrameTableTxtLine v19; // [sp+200h] [bp-104h]@4
|
|
147 FrameTableTxtLine v20; // [sp+27Ch] [bp-88h]@4
|
|
148 int v21; // [sp+2F8h] [bp-Ch]@3
|
|
149 int v22; // [sp+2FCh] [bp-8h]@3
|
|
150 FILE *File; // [sp+300h] [bp-4h]@1
|
|
151 int Argsa; // [sp+30Ch] [bp+8h]@26
|
|
152
|
|
153 //v2 = this;
|
|
154 //TileTable::dtor((TileTable *)this);
|
|
155 __debugbreak();//Ritor1: this function not used
|
|
156 v3 = fopen(Args, "r");
|
|
157 File = v3;
|
|
158 if ( !v3 )
|
|
159 Error("IconFrameTable::load - Unable to open file: %s.", Args);
|
|
160 v4 = 0;
|
|
161 v21 = 0;
|
|
162 v22 = 1;
|
|
163 if ( fgets(&Buf, 490, v3) )
|
|
164 {
|
|
165 do
|
|
166 {
|
|
167 *strchr(&Buf, 10) = 0;
|
|
168 memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20));
|
|
169 if ( v20.uPropCount && *v20.pProperties[0] != 47 )
|
|
170 {
|
|
171 if ( v20.uPropCount < 3 )
|
|
172 Error("IconFrameTable::loadText, too few arguments, %s line %i.", Args, v22);
|
|
173 ++v21;
|
|
174 }
|
|
175 ++v22;
|
|
176 }
|
|
177 while ( fgets(&Buf, 490, File) );
|
|
178 v4 = v21;
|
|
179 }
|
|
180 this->uNumIcons = v4;
|
|
181 v5 = malloc(32 * v4);//, "I Frames");
|
2575
|
182 this->pIcons = (IconFrame_MM7 *)v5;
|
2499
|
183 if ( v5 )
|
|
184 {
|
|
185 v6 = File;
|
|
186 this->uNumIcons = 0;
|
|
187 fseek(v6, 0, 0);
|
|
188 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
|
|
189 {
|
|
190 *strchr(&Buf, 10) = 0;
|
|
191 memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20));
|
|
192 if ( v20.uPropCount && *v20.pProperties[0] != 47 )
|
|
193 {
|
|
194 strcpy(this->pIcons[this->uNumIcons].pAnimationName, v20.pProperties[0]);
|
|
195 strcpy(this->pIcons[this->uNumIcons].pTextureName, v20.pProperties[1]);
|
|
196 v8 = v20.pProperties[2];
|
|
197 this->pIcons[this->uNumIcons].uFlags = 0;
|
|
198 if ( !_stricmp(v8, "new") )
|
|
199 {
|
|
200 v9 = (int)&this->pIcons[this->uNumIcons].uFlags;
|
|
201 *(char *)v9 |= 4u;
|
|
202 }
|
|
203 this->pIcons[this->uNumIcons].uAnimTime = atoi(v20.pProperties[3]);
|
|
204 this->pIcons[this->uNumIcons].uAnimLength = 0;
|
|
205 this->pIcons[this->uNumIcons++].uTextureID = 0;
|
|
206 }
|
|
207 }
|
|
208 fclose(File);
|
|
209 v10 = 0;
|
|
210 if ( (signed int)(this->uNumIcons - 1) > 0 )
|
|
211 {
|
|
212 v11 = 0;
|
|
213 do
|
|
214 {
|
|
215 v12 = (int)&this->pIcons[v11];
|
|
216 if ( !(*(char *)(v12 + 60) & 4) )
|
|
217 *(char *)(v12 + 28) |= 1u;
|
|
218 ++v10;
|
|
219 ++v11;
|
|
220 }
|
|
221 while ( v10 < (signed int)(this->uNumIcons - 1) );
|
|
222 }
|
|
223 for ( j = 0; j < (signed int)this->uNumIcons; *(short *)(Argsa + 26) = v15 )
|
|
224 {
|
|
225 v14 = this->pIcons;
|
|
226 Argsa = (int)&v14[j];
|
|
227 v15 = *(short *)(Argsa + 24);
|
|
228 if ( *(char *)(Argsa + 28) & 1 )
|
|
229 {
|
|
230 ++j;
|
|
231 for ( k = (int)&v14[j]; *(char *)(k + 28) & 1; k += 32 )
|
|
232 {
|
|
233 v15 += *(short *)(k + 24);
|
|
234 ++j;
|
|
235 }
|
|
236 LOWORD(v15) = v14[j].uAnimTime + v15;
|
|
237 }
|
|
238 ++j;
|
|
239 }
|
|
240 result = 1;
|
|
241 }
|
|
242 else
|
|
243 {
|
|
244 fclose(File);
|
|
245 result = 0;
|
|
246 }
|
|
247 return result;
|
2575
|
248 }*/
|
|
249
|
|
250 /*
|
2499
|
251 //----- (0042EB78) --------------------------------------------------------
|
|
252 int IconFrameTable::GetIconAnimLength(unsigned int uIconID)
|
|
253 {
|
|
254 return 8 * this->pIcons[uIconID].uAnimLength;
|
2575
|
255 }*/ |