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