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