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