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