Mercurial > mm7
annotate GUIProgressBar.cpp @ 1653:d453ed393d6e
NPCGreetings
author | Ritor1 |
---|---|
date | Wed, 18 Sep 2013 11:04:47 +0600 |
parents | c4ab816fcc5e |
children | 7810cb3a5fb7 |
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 IconFrame *v3; // eax@10 | |
181 float v4; // ST2C_4@10 | |
182 | |
183 //v1 = this; | |
184 pRenderer->BeginScene(); | |
185 if (uType != TYPE_Fullscreen) | |
186 { | |
710 | 187 if (pBardata.pLevelOfDetail0_prolly_alpha_mask) |
0 | 188 { |
189 if (pRenderer->pRenderD3D) | |
190 { | |
191 if (!pRenderer->bWindowMode) | |
192 pRenderer->_49FD3A(); | |
193 } | |
194 pRenderer->DrawTextureIndexed(0x50u, 0x7Au, &pBardata); | |
195 v3 = pIconsFrameTable->GetFrame(uIconID_TurnHour, 0); | |
196 pRenderer->DrawTextureTransparent(0x64u, 0x92u, &pIcons_LOD->pTextures[v3->uTextureID]); | |
197 v4 = (double)(113 * uProgressCurrent) / (double)uProgressMax; | |
198 pRenderer->FillRectFast( | |
199 174, | |
200 164, | |
201 floorf(v4 + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), | |
202 16, | |
203 pRenderer->uTargetRMask); | |
1421 | 204 pRenderer->EndScene(); |
205 pRenderer->Present(); | |
206 return; | |
0 | 207 } |
208 pRenderer->EndScene(); | |
209 return; | |
210 } | |
211 | |
212 if (!pLoadingBg.pPixels) | |
1421 | 213 { |
214 pRenderer->EndScene(); | |
215 return; | |
216 } | |
0 | 217 |
218 pRenderer->DrawTextureRGB(0, 0, &pLoadingBg); | |
709 | 219 pRenderer->SetRasterClipRect(0, 0, 0x27Fu, 0x1DFu); |
727 | 220 pRenderer->SetTextureClipRect(0xACu, 0x1CBu, |
0 | 221 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, |
222 0x1D7u); | |
223 pRenderer->DrawTextureTransparent(0xACu, 0x1CBu, &pLoadingProgress); | |
727 | 224 pRenderer->ResetTextureClipRect(); |
0 | 225 pRenderer->EndScene(); |
226 pRenderer->Present(); | |
227 } |