Mercurial > mm7
comparison Engine/Tables/IconFrameTable.cpp @ 2575:a76d408c5132 tip
DrawTranslucent -> DrawTextureGrayShade
Removed old texture drawing stuff
author | a.parshin |
---|---|
date | Wed, 09 Mar 2016 01:39:52 +0200 |
parents | a902abdfc7f2 |
children |
comparison
equal
deleted
inserted
replaced
2574:dd36326a9994 | 2575:a76d408c5132 |
---|---|
3 #include <crtdbg.h> | 3 #include <crtdbg.h> |
4 | 4 |
5 #define _CRT_SECURE_NO_WARNINGS | 5 #define _CRT_SECURE_NO_WARNINGS |
6 | 6 |
7 #include "Engine/Engine.h" | 7 #include "Engine/Engine.h" |
8 #include "Engine/Serialization/LegacyImages.h" | |
8 | 9 |
9 #include "IconFrameTable.h" | 10 #include "IconFrameTable.h" |
10 #include "../LOD.h" | 11 #include "../LOD.h" |
11 #include "FrameTableInc.h" | 12 #include "FrameTableInc.h" |
12 | 13 |
14 | |
15 Icon *IconFrameTable::GetIcon(unsigned int idx) | |
16 { | |
17 if (idx < this->uNumIcons) | |
18 return &this->pIcons[idx]; | |
19 return nullptr; | |
20 } | |
21 | |
22 Icon *IconFrameTable::GetIcon(const char *pIconName) | |
23 { | |
24 for (unsigned int i = 0; i < this->uNumIcons; i++) | |
25 { | |
26 if (!_stricmp(pIconName, this->pIcons[i].GetAnimationName())) | |
27 return &this->pIcons[i]; | |
28 } | |
29 return nullptr; | |
30 } | |
31 | |
32 | |
33 | |
13 //----- (00494F3A) -------------------------------------------------------- | 34 //----- (00494F3A) -------------------------------------------------------- |
14 unsigned int IconFrameTable::FindIcon(const char *pIconName) | 35 unsigned int IconFrameTable::FindIcon(const char *pIconName) |
15 { | 36 { |
16 for ( uint i = 0; i < (signed int)this->uNumIcons; i++ ) | 37 for ( uint i = 0; i < (signed int)this->uNumIcons; i++ ) |
17 { | 38 { |
18 if ( !_stricmp(pIconName, this->pIcons[i].pAnimationName) ) | 39 if ( !_stricmp(pIconName, this->pIcons[i].GetAnimationName()) ) |
19 return i; | 40 return i; |
20 } | 41 } |
21 return 0; | 42 return 0; |
22 } | 43 } |
23 | 44 |
24 //----- (00494F70) -------------------------------------------------------- | 45 //----- (00494F70) -------------------------------------------------------- |
25 IconFrame *IconFrameTable::GetFrame(unsigned int uIconID, unsigned int uFrameID) | 46 Icon *IconFrameTable::GetFrame(unsigned int uIconID, unsigned int frame_time) |
26 { | 47 { |
27 int v6; // edx@3 | 48 int v6; // edx@3 |
28 uint i; | 49 uint i; |
29 | 50 |
30 if ( this->pIcons[uIconID].uFlags & 1 && this->pIcons[uIconID].uAnimLength != 0 ) | 51 if ( this->pIcons[uIconID].uFlags & 1 && this->pIcons[uIconID].GetAnimLength() != 0 ) |
31 { | 52 { |
32 v6 = ((signed int)uFrameID >> 3) % (unsigned __int16)this->pIcons[uIconID].uAnimLength; | 53 int t = frame_time; |
33 for ( i = uIconID; v6 > this->pIcons[i].uAnimTime; i++ ) | 54 |
34 v6 -= this->pIcons[i].uAnimTime; | 55 t = (t /*/ 8*/) % (unsigned __int16)this->pIcons[uIconID].GetAnimLength(); |
56 t /= 8; | |
57 for ( i = uIconID; t > this->pIcons[i].GetAnimTime(); i++ ) | |
58 t -= this->pIcons[i].GetAnimTime(); | |
35 return &this->pIcons[i]; | 59 return &this->pIcons[i]; |
36 } | 60 } |
37 else | 61 else |
38 return &this->pIcons[uIconID]; | 62 return &this->pIcons[uIconID]; |
39 } | 63 } |
43 { | 67 { |
44 if ( uIconID && (signed int)uIconID <= (signed int)this->uNumIcons ) | 68 if ( uIconID && (signed int)uIconID <= (signed int)this->uNumIcons ) |
45 { | 69 { |
46 for ( uint i = uIconID; ; ++i ) | 70 for ( uint i = uIconID; ; ++i ) |
47 { | 71 { |
48 this->pIcons[i].uTextureID = pIcons_LOD->LoadTexture(this->pIcons[i].pTextureName, TEXTURE_16BIT_PALETTE); | 72 //this->pIcons[i].uTextureID = pIcons_LOD->LoadTexture(this->pIcons[i].pTextureName, TEXTURE_16BIT_PALETTE); |
73 this->pIcons[i].texture = assets->GetImage_16BitColorKey(this->pIcons[i].pTextureName, 0x7FF); | |
49 if ( !(this->pIcons[i].uFlags & 1) ) | 74 if ( !(this->pIcons[i].uFlags & 1) ) |
50 break; | 75 break; |
51 } | 76 } |
52 } | 77 } |
53 } | 78 } |
78 num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0, | 103 num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0, |
79 num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0; | 104 num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0; |
80 | 105 |
81 uNumIcons = num_mm6_frames + num_mm7_frames + num_mm8_frames; | 106 uNumIcons = num_mm6_frames + num_mm7_frames + num_mm8_frames; |
82 Assert(uNumIcons); | 107 Assert(uNumIcons); |
108 Assert(!num_mm6_frames); | |
83 Assert(!num_mm8_frames); | 109 Assert(!num_mm8_frames); |
84 | 110 |
85 pIcons = (IconFrame *)malloc(uNumIcons * sizeof(IconFrame)); | 111 IconFrame_MM7 *pIcons = (IconFrame_MM7 *)malloc(uNumIcons * sizeof(IconFrame_MM7)); |
86 memcpy(pIcons, (char *)data_mm7 + 4, num_mm7_frames * sizeof(IconFrame)); | 112 memcpy(pIcons, (char *)data_mm7 + 4, num_mm7_frames * sizeof(IconFrame_MM7)); |
87 memcpy(pIcons + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(IconFrame)); | 113 //memcpy(pIcons + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(IconFrame_MM7)); |
88 memcpy(pIcons + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(IconFrame)); | 114 //memcpy(pIcons + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(IconFrame_MM7)); |
89 } | 115 |
90 | 116 this->pIcons = new Icon[uNumIcons]; |
117 for (unsigned int i = 0; i < uNumIcons; ++i) | |
118 { | |
119 pIcons[i].Deserialize(&this->pIcons[i]); | |
120 | |
121 this->pIcons[i].id = i; | |
122 } | |
123 } | |
124 | |
125 /* | |
91 //----- (0049509D) -------------------------------------------------------- | 126 //----- (0049509D) -------------------------------------------------------- |
92 int IconFrameTable::FromFileTxt(const char *Args) | 127 int IconFrameTable::FromFileTxt(const char *Args) |
93 { | 128 { |
94 //IconFrameTable *v2; // ebx@1 | 129 //IconFrameTable *v2; // ebx@1 |
95 FILE *v3; // eax@1 | 130 FILE *v3; // eax@1 |
101 int v9; // eax@16 | 136 int v9; // eax@16 |
102 int v10; // edx@20 | 137 int v10; // edx@20 |
103 int v11; // ecx@21 | 138 int v11; // ecx@21 |
104 int v12; // eax@22 | 139 int v12; // eax@22 |
105 signed int j; // edx@25 | 140 signed int j; // edx@25 |
106 IconFrame *v14; // ecx@26 | 141 IconFrame_MM7 *v14; // ecx@26 |
107 int v15; // esi@26 | 142 int v15; // esi@26 |
108 int k; // eax@27 | 143 int k; // eax@27 |
109 signed int result; // eax@11 | 144 signed int result; // eax@11 |
110 char Buf; // [sp+Ch] [bp-2F8h]@3 | 145 char Buf; // [sp+Ch] [bp-2F8h]@3 |
111 FrameTableTxtLine v19; // [sp+200h] [bp-104h]@4 | 146 FrameTableTxtLine v19; // [sp+200h] [bp-104h]@4 |
142 while ( fgets(&Buf, 490, File) ); | 177 while ( fgets(&Buf, 490, File) ); |
143 v4 = v21; | 178 v4 = v21; |
144 } | 179 } |
145 this->uNumIcons = v4; | 180 this->uNumIcons = v4; |
146 v5 = malloc(32 * v4);//, "I Frames"); | 181 v5 = malloc(32 * v4);//, "I Frames"); |
147 this->pIcons = (IconFrame *)v5; | 182 this->pIcons = (IconFrame_MM7 *)v5; |
148 if ( v5 ) | 183 if ( v5 ) |
149 { | 184 { |
150 v6 = File; | 185 v6 = File; |
151 this->uNumIcons = 0; | 186 this->uNumIcons = 0; |
152 fseek(v6, 0, 0); | 187 fseek(v6, 0, 0); |
208 { | 243 { |
209 fclose(File); | 244 fclose(File); |
210 result = 0; | 245 result = 0; |
211 } | 246 } |
212 return result; | 247 return result; |
213 } | 248 }*/ |
249 | |
250 /* | |
214 //----- (0042EB78) -------------------------------------------------------- | 251 //----- (0042EB78) -------------------------------------------------------- |
215 int IconFrameTable::GetIconAnimLength(unsigned int uIconID) | 252 int IconFrameTable::GetIconAnimLength(unsigned int uIconID) |
216 { | 253 { |
217 return 8 * this->pIcons[uIconID].uAnimLength; | 254 return 8 * this->pIcons[uIconID].uAnimLength; |
218 } | 255 }*/ |