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