Mercurial > mm7
annotate Overlays.cpp @ 1832:f3b106aff057
Merge
author | Ritor1 |
---|---|
date | Mon, 07 Oct 2013 21:57:01 +0600 |
parents | 75fafd8ced59 |
children | 28cb79ae2f6f |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
4 |
0 | 5 #include <stdlib.h> |
6 | |
7 #include "Overlays.h" | |
8 #include "Sprites.h" | |
9 #include "FrameTableInc.h" | |
10 #include "IconFrameTable.h" | |
11 #include "Time.h" | |
12 #include "Party.h" | |
13 #include "TurnEngine.h" | |
14 #include "LOD.h" | |
15 #include "Render.h" | |
569 | 16 #include "GUIWindow.h" |
0 | 17 |
18 #include "mm7_data.h" | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 struct OtherOverlayList *pOtherOverlayList = new OtherOverlayList; // idb | |
25 struct OverlayList *pOverlayList = new OverlayList; | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
783 | 32 // inlined |
33 //----- (mm6c::0045BD50) -------------------------------------------------- | |
34 void OtherOverlayList::Reset() | |
35 { | |
36 for (uint i = 0; i < 50; ++i) | |
37 pOverlays[i].Reset(); | |
38 } | |
0 | 39 |
40 //----- (004418B1) -------------------------------------------------------- | |
41 int OtherOverlayList::_4418B1(int a2, int a3, int a4, int a5) | |
42 { | |
43 return 0; | |
44 } | |
45 | |
46 //----- (004418B6) -------------------------------------------------------- | |
47 int OtherOverlayList::_4418B6(int uOverlayID, __int16 a3, int a4, int a5, __int16 a6) | |
48 { | |
49 signed int v6; // edx@1 | |
50 OtherOverlayList *v7; // eax@1 | |
142 | 51 //signed int result; // eax@4 |
0 | 52 signed int v9; // esi@6 |
53 __int16 v10; // dx@9 | |
54 __int16 v11; // dx@11 | |
55 | |
56 v6 = 0; | |
57 v7 = this; | |
58 while ( v7->pOverlays[0].field_6 > 0 ) | |
59 { | |
60 ++v6; | |
61 v7 = (OtherOverlayList *)((char *)v7 + 20); | |
62 if ( v6 >= 50 ) | |
63 return 0; | |
64 } | |
65 v7->pOverlays[0].field_0 = 0; | |
66 v7->pOverlays[0].field_A = 0; | |
67 v7->pOverlays[0].field_8 = 0; | |
68 v7->pOverlays[0].field_C = a3; | |
69 v9 = 0; | |
70 if ( (signed int)pOverlayList->uNumOverlays <= 0 ) | |
71 { | |
72 LABEL_9: | |
73 v10 = 0; | |
74 } | |
75 else | |
76 { | |
77 while ( uOverlayID != pOverlayList->pOverlays[v9].uOverlayID ) | |
78 { | |
79 ++v9; | |
80 if ( v9 >= (signed int)pOverlayList->uNumOverlays ) | |
81 goto LABEL_9; | |
82 } | |
83 v10 = v9; | |
84 } | |
85 v7->pOverlays[0].field_2 = v10; | |
86 v7->pOverlays[0].field_4 = 0; | |
87 if ( a4 ) | |
88 v11 = a4; | |
89 else | |
90 v11 = 8 * pSpriteFrameTable->pSpriteSFrames[pOverlayList->pOverlays[v10].uSpriteFramesetID].uAnimLength; | |
91 v7->pOverlays[0].field_6 = v11; | |
92 v7->pOverlays[0].field_10 = a5; | |
93 v7->pOverlays[0].field_E = a6; | |
142 | 94 |
95 bRedraw = true; | |
96 return true; | |
0 | 97 } |
98 | |
99 //----- (00441964) -------------------------------------------------------- | |
569 | 100 void OtherOverlayList::DrawTurnBasedIcon(int a2) |
0 | 101 { |
102 unsigned int result; // eax@1 | |
103 IconFrameTable *v3; // ecx@6 | |
104 void *v4; // eax@12 | |
105 unsigned int v5; // [sp-8h] [bp-Ch]@4 | |
106 int v6; // [sp-4h] [bp-8h]@4 | |
107 Texture *v7; // [sp-4h] [bp-8h]@14 | |
108 | |
569 | 109 if ( pCurrentScreen != SCREEN_GAME || !pParty->bTurnBasedModeOn) |
110 return; | |
111 | |
1340 | 112 if ( pTurnEngine->turn_stage == 3 ) |
0 | 113 { |
114 v6 = pEventTimer->uStartTime; | |
115 v5 = pIconIDs_Turn[5 - pTurnEngine->uActionPointsLeft / 26]; | |
116 } | |
117 else | |
118 { | |
1340 | 119 if ( pTurnEngine->turn_stage == 1 ) |
0 | 120 { |
121 v6 = dword_50C994; | |
122 v3 = pIconsFrameTable; | |
123 if ( dword_50C998_turnbased_icon_1A ) | |
124 v5 = uIconID_TurnStart; | |
125 else | |
126 v5 = uIconID_TurnHour; | |
127 goto LABEL_12; | |
128 } | |
1340 | 129 if ( pTurnEngine->turn_stage != 2 ) |
0 | 130 { |
131 v4 = this; | |
132 goto LABEL_14; | |
133 } | |
134 v6 = pEventTimer->uStartTime; | |
135 v5 = uIconID_TurnStop; | |
136 } | |
137 v3 = pIconsFrameTable; | |
138 LABEL_12: | |
139 v4 = pIconsFrameTable->GetFrame(v5, v6); | |
140 LABEL_14: | |
141 v7 = &pIcons_LOD->pTextures[*((short *)v4 + 15)]; | |
142 if ( pRenderer->pRenderD3D ) | |
143 pRenderer->DrawTextureIndexed(0x18Au, 0x120u, v7); | |
144 else | |
145 pRenderer->DrawTextureTransparent(0x18Au, 0x120u, v7); | |
146 result = dword_50C994; | |
147 if ( dword_50C994 < dword_50C998_turnbased_icon_1A ) | |
148 { | |
149 result = pEventTimer->uTimeElapsed + dword_50C994; | |
150 dword_50C994 = result; | |
151 if ( (signed int)result >= dword_50C998_turnbased_icon_1A ) | |
152 dword_50C998_turnbased_icon_1A = 0; | |
153 } | |
154 } | |
155 // 4E28F8: using guessed type int pCurrentScreen; | |
156 // 50C994: using guessed type int dword_50C994; | |
157 // 50C998: using guessed type int dword_50C998_turnbased_icon_1A; | |
158 | |
159 | |
160 //----- (00458D97) -------------------------------------------------------- | |
161 void OverlayList::InitializeSprites() | |
162 { | |
472 | 163 for (uint i = 0; i < uNumOverlays; ++i) |
164 pSpriteFrameTable->InitializeSprite(pOverlays[i].uSpriteFramesetID); | |
0 | 165 } |
166 | |
167 //----- (00458DBC) -------------------------------------------------------- | |
168 void OverlayList::ToFile() | |
169 { | |
170 OverlayList *v1; // esi@1 | |
171 FILE *v2; // eax@1 | |
172 FILE *v3; // edi@1 | |
173 | |
174 v1 = this; | |
175 v2 = fopen("data\\doverlay.bin", "wb"); | |
176 v3 = v2; | |
177 if ( !v2 ) | |
1545 | 178 Error("Unable to save doverlay.bin!"); |
0 | 179 fwrite(v1, 4u, 1u, v2); |
180 fwrite(v1->pOverlays, 8u, v1->uNumOverlays, v3); | |
181 fclose(v3); | |
182 } | |
183 | |
184 //----- (00458E08) -------------------------------------------------------- | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
185 void OverlayList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) |
0 | 186 { |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
187 uint num_mm6_overlays = data_mm6 ? *(int *)data_mm6 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
188 num_mm7_overlays = data_mm7 ? *(int *)data_mm7 : 0, |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
189 num_mm8_overlays = data_mm8 ? *(int *)data_mm8 : 0; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
190 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
191 uNumOverlays = num_mm6_overlays + num_mm7_overlays + num_mm8_overlays; |
1545 | 192 Assert(uNumOverlays); |
193 Assert(!num_mm8_overlays); | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
194 |
1583 | 195 pOverlays = (OverlayDesc *)malloc(uNumOverlays * sizeof(OverlayDesc)); |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
196 memcpy(pOverlays, (char *)data_mm7 + 4, num_mm7_overlays * sizeof(OverlayDesc)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
197 memcpy(pOverlays + num_mm7_overlays, (char *)data_mm6 + 4, num_mm6_overlays * sizeof(OverlayDesc)); |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1340
diff
changeset
|
198 memcpy(pOverlays + num_mm6_overlays + num_mm7_overlays, (char *)data_mm8 + 4, num_mm8_overlays * sizeof(OverlayDesc)); |
0 | 199 } |
200 | |
201 //----- (00458E4F) -------------------------------------------------------- | |
202 bool OverlayList::FromFileTxt(const char *Args) | |
203 { | |
204 OverlayList *v2; // ebx@1 | |
205 __int32 v3; // edi@1 | |
206 FILE *v4; // eax@1 | |
207 unsigned int v5; // esi@3 | |
208 const void *v6; // ST18_4@9 | |
209 void *v7; // eax@9 | |
210 FILE *v8; // ST0C_4@11 | |
211 char *i; // eax@11 | |
212 unsigned __int16 v10; // ax@14 | |
213 const char *v11; // ST1C_4@14 | |
214 int v12; // eax@16 | |
215 OverlayDesc *v13; // ecx@16 | |
216 char v14; // zf@16 | |
217 unsigned int v15; // eax@16 | |
218 char Buf; // [sp+10h] [bp-2F0h]@3 | |
219 FrameTableTxtLine v18; // [sp+204h] [bp-FCh]@4 | |
220 FrameTableTxtLine v19; // [sp+280h] [bp-80h]@4 | |
221 FILE *File; // [sp+2FCh] [bp-4h]@1 | |
222 unsigned int Argsa; // [sp+308h] [bp+8h]@3 | |
223 | |
224 v2 = this; | |
1583 | 225 free(this->pOverlays); |
0 | 226 v3 = 0; |
227 v2->pOverlays = 0; | |
228 v2->uNumOverlays = 0; | |
229 v4 = fopen(Args, "r"); | |
230 File = v4; | |
231 if ( !v4 ) | |
1545 | 232 Error("ObjectDescriptionList::load - Unable to open file: %s."); |
233 | |
0 | 234 v5 = 0; |
235 Argsa = 0; | |
236 if ( fgets(&Buf, 490, v4) ) | |
237 { | |
238 do | |
239 { | |
240 *strchr(&Buf, 10) = 0; | |
703 | 241 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); |
701 | 242 if ( v19.uPropCount && *v19.pProperties[0] != 47 ) |
0 | 243 ++Argsa; |
244 } | |
245 while ( fgets(&Buf, 490, File) ); | |
246 v5 = Argsa; | |
247 v3 = 0; | |
248 } | |
249 v6 = v2->pOverlays; | |
250 v2->uNumOverlays = v5; | |
1583 | 251 v7 = malloc(8 * v5); |
0 | 252 v2->pOverlays = (OverlayDesc *)v7; |
253 if ( v7 == (void *)v3 ) | |
1545 | 254 Error("OverlayDescriptionList::load - Out of Memory!"); |
255 | |
0 | 256 memset(v7, v3, 8 * v2->uNumOverlays); |
257 v8 = File; | |
258 v2->uNumOverlays = v3; | |
259 fseek(v8, v3, v3); | |
260 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) | |
261 { | |
262 *strchr(&Buf, 10) = 0; | |
703 | 263 memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19)); |
701 | 264 if ( v19.uPropCount && *v19.pProperties[0] != 47 ) |
0 | 265 { |
266 v10 = atoi(v19.pProperties[0]); | |
267 v11 = v19.pProperties[1]; | |
268 v2->pOverlays[v2->uNumOverlays].uOverlayID = v10; | |
1104 | 269 if ( _stricmp(v11, "center") ) |
0 | 270 { |
1104 | 271 v12 = _stricmp(v19.pProperties[1], "transparent"); |
0 | 272 v13 = v2->pOverlays; |
273 v14 = v12 == 0; | |
274 v15 = v2->uNumOverlays; | |
275 if ( v14 ) | |
276 v13[v15].uOverlayType = 2; | |
277 else | |
278 v13[v15].uOverlayType = 1; | |
279 } | |
280 else | |
281 { | |
282 v2->pOverlays[v2->uNumOverlays].uOverlayType = 0; | |
283 } | |
284 v2->pOverlays[v2->uNumOverlays++].uSpriteFramesetID = pSpriteFrameTable->FastFindSprite( | |
285 (char *)v19.pProperties[2]); | |
286 } | |
287 } | |
288 fclose(File); | |
289 return 1; | |
290 } | |
291 | |
292 | |
293 //----- (0045855F) -------------------------------------------------------- | |
294 void OtherOverlay::Reset() | |
295 { | |
296 this->field_10 = 65536; | |
297 this->field_A = 0; | |
298 this->field_8 = 0; | |
299 this->field_6 = 0; | |
300 this->field_4 = 0; | |
301 this->field_2 = 0; | |
302 this->field_C = 0; | |
303 this->field_E = 0; | |
304 } | |
305 | |
306 //----- (004584B8) -------------------------------------------------------- | |
307 OtherOverlay::OtherOverlay() | |
308 { | |
309 this->field_A = 0; | |
310 this->field_8 = 0; | |
311 this->field_6 = 0; | |
312 this->field_4 = 0; | |
313 this->field_2 = 0; | |
314 this->field_C = 0; | |
315 this->field_E = 0; | |
316 this->field_10 = 65536; | |
317 } |