Mercurial > mm7
annotate GUIProgressBar.cpp @ 2125:ba3de1337989
house animations working
round renamed to round_to_int
author | zipi |
---|---|
date | Thu, 26 Dec 2013 22:46:49 +0000 |
parents | 7810cb3a5fb7 |
children | d28d3c006077 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1038
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1038
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1038
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1038
diff
changeset
|
4 |
0 | 5 #include "GUIProgressBar.h" |
6 #include "LOD.h" | |
7 #include "Mouse.h" | |
8 #include "Party.h" | |
9 #include "Render.h" | |
10 #include "IconFrameTable.h" | |
11 | |
12 #include "mm7_data.h" | |
13 | |
14 | |
15 | |
16 | |
17 struct GUIProgressBar *pGameLoadingUI_ProgressBar = new GUIProgressBar; | |
18 | |
19 | |
20 | |
21 | |
434 | 22 //----- (00Initialize) -------------------------------------------------------- |
23 bool GUIProgressBar::Initialize(Type type) | |
0 | 24 { |
25 //GUIProgressBar *v2; // esi@1 | |
26 signed int v4; // eax@7 | |
27 int v5; // ecx@8 | |
28 int v6; // edi@8 | |
29 int v7; // edx@14 | |
373 | 30 //const char *v8; // [sp-8h] [bp-84h]@20 |
31 //unsigned int v9; // [sp-4h] [bp-80h]@20 | |
0 | 32 char Str1[64]; // [sp+4h] [bp-78h]@16 |
33 | |
434 | 34 switch (type) |
0 | 35 { |
434 | 36 case TYPE_None: |
37 return true; | |
38 | |
39 case TYPE_Box: | |
40 case TYPE_Fullscreen: | |
41 break; | |
42 | |
43 default: | |
1545 | 44 Error("Invalid GUIProgressBar type: %u", type); |
0 | 45 } |
46 | |
47 //v2 = this; | |
48 if (pLoadingBg.pPixels) | |
49 return false; | |
50 | |
51 uType = type; | |
52 | |
53 v4 = 1; | |
54 if (uType == TYPE_Fullscreen) | |
55 { | |
56 v5 = 0; | |
57 v6 = (int)&field_10; | |
58 do | |
59 { | |
60 if ( *(char *)(v6 + v4) == 1 ) | |
61 ++v5; | |
62 ++v4; | |
63 } | |
64 while ( v4 <= 5 ); | |
65 if ( v5 == 5 ) | |
66 memset(&field_10, 0, 8u); | |
67 v7 = rand() % 5 + 1; | |
68 if ( *(&field_10 + v7) == 1 ) | |
69 { | |
70 do | |
71 v7 = rand() % 5 + 1; | |
72 while ( *(char *)(v6 + v7) == 1 ); | |
73 } | |
74 sprintf(Str1, "loading%d.pcx", v7); | |
75 pLoadingBg.Load(Str1, 2); | |
76 uProgressCurrent = 0; | |
77 uX = 122; | |
78 uY = 151; | |
79 uWidth = 449; | |
80 uHeight = 56; | |
81 uProgressMax = 26; | |
82 pIcons_LOD->_410522(&pLoadingProgress, "loadprog", 2u); | |
83 Draw(); | |
84 return true; | |
85 } | |
373 | 86 |
87 /*if ( !pParty->uAlignment ) | |
0 | 88 { |
89 v9 = 2; | |
90 v8 = "bardata-b"; | |
91 goto LABEL_23; | |
92 } | |
93 if ( pParty->uAlignment == 1 ) | |
94 { | |
95 v9 = 2; | |
96 v8 = "bardata"; | |
97 goto LABEL_23; | |
98 } | |
99 if ( pParty->uAlignment == 2 ) | |
100 { | |
101 v9 = 2; | |
102 v8 = "bardata-c"; | |
103 LABEL_23: | |
104 pIcons_LOD->_410522(&pBardata, v8, v9); | |
373 | 105 }*/ |
106 switch (pParty->alignment) | |
107 { | |
108 case PartyAlignment_Good: pIcons_LOD->_410522(&pBardata, "bardata-b", 2); break; | |
109 case PartyAlignment_Neutral: pIcons_LOD->_410522(&pBardata, "bardata", 2); break; | |
110 case PartyAlignment_Evil: pIcons_LOD->_410522(&pBardata, "bardata-c", 2); break; | |
1545 | 111 default: Error("Invalid alignment type: %u", pParty->alignment); |
0 | 112 } |
373 | 113 |
0 | 114 uProgressCurrent = 0; |
115 uProgressMax = 26; | |
116 Draw(); | |
117 return true; | |
118 } | |
119 | |
120 //----- (004435BB) -------------------------------------------------------- | |
121 void GUIProgressBar::Reset(unsigned __int8 uMaxProgress) | |
122 { | |
123 field_9 = 0; | |
124 uProgressCurrent = 0; | |
125 uProgressMax = uMaxProgress; | |
126 } | |
127 | |
128 //----- (004435CD) -------------------------------------------------------- | |
129 void GUIProgressBar::Progress() | |
130 { | |
131 unsigned __int8 v1; // al@1 | |
132 | |
133 ++this->uProgressCurrent; | |
134 v1 = this->uProgressMax; | |
135 if ( this->uProgressCurrent > v1 ) | |
136 this->uProgressCurrent = v1; | |
137 Draw(); | |
138 } | |
139 | |
140 //----- (004435E2) -------------------------------------------------------- | |
141 void GUIProgressBar::Release() | |
142 { | |
143 GUIProgressBar *v1; // esi@1 | |
144 char v2; // al@5 | |
145 int v3; // edi@7 | |
146 | |
147 v1 = this; | |
148 if ( v1->uType == 1 ) | |
149 { | |
150 if ( !v1->pLoadingBg.pPixels ) | |
151 return; | |
152 v2 = v1->uProgressMax; | |
153 if ( v1->uProgressCurrent != v2 ) | |
154 { | |
155 v1->uProgressCurrent = v2 - 1; | |
156 Progress(); | |
157 } | |
158 free(v1->pLoadingBg.pPixels); | |
710 | 159 v3 = (int)&v1->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask; |
160 free(v1->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask); | |
0 | 161 free(v1->pLoadingProgress.pPalette16); |
162 v1->pLoadingProgress.pPalette16 = 0; | |
163 v1->pLoadingBg.pPixels = 0; | |
164 } | |
165 else | |
166 { | |
710 | 167 if ( !v1->pBardata.pLevelOfDetail0_prolly_alpha_mask ) |
0 | 168 return; |
710 | 169 free(v1->pBardata.pLevelOfDetail0_prolly_alpha_mask); |
0 | 170 v3 = (int)&v1->pBardata.pPalette16; |
171 free(v1->pBardata.pPalette16); | |
710 | 172 v1->pBardata.pLevelOfDetail0_prolly_alpha_mask = 0; |
0 | 173 } |
174 *(int *)v3 = 0; | |
175 } | |
176 | |
177 //----- (00443670) -------------------------------------------------------- | |
178 void GUIProgressBar::Draw() | |
179 { | |
180 pRenderer->BeginScene(); | |
181 if (uType != TYPE_Fullscreen) | |
182 { | |
710 | 183 if (pBardata.pLevelOfDetail0_prolly_alpha_mask) |
0 | 184 { |
185 if (pRenderer->pRenderD3D) | |
186 { | |
187 if (!pRenderer->bWindowMode) | |
188 pRenderer->_49FD3A(); | |
189 } | |
2098 | 190 pRenderer->DrawTextureIndexed(80, 122, &pBardata);//прогрессбар для данжей |
191 pRenderer->DrawTextureTransparent(100, 146, &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconID_TurnHour, 0)->uTextureID]); | |
192 //pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), | |
193 //16, pRenderer->uTargetRMask); | |
194 pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), | |
195 16, 0xF800); | |
196 pRenderer->EndScene(); | |
197 pRenderer->Present(); | |
198 return; | |
0 | 199 } |
200 pRenderer->EndScene(); | |
201 return; | |
202 } | |
203 | |
204 if (!pLoadingBg.pPixels) | |
1421 | 205 { |
2098 | 206 pRenderer->EndScene(); |
1421 | 207 return; |
208 } | |
0 | 209 |
210 pRenderer->DrawTextureRGB(0, 0, &pLoadingBg); | |
2098 | 211 pRenderer->SetRasterClipRect(0, 0, 639, 479); |
212 pRenderer->SetTextureClipRect(172, 459, 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, 471); | |
213 pRenderer->DrawTextureTransparent(172, 459, &pLoadingProgress); | |
727 | 214 pRenderer->ResetTextureClipRect(); |
0 | 215 pRenderer->EndScene(); |
216 pRenderer->Present(); | |
217 } |