373
|
1 #include <assert.h>
|
|
2
|
0
|
3 #include "GUIProgressBar.h"
|
|
4 #include "LOD.h"
|
|
5 #include "Mouse.h"
|
|
6 #include "Party.h"
|
|
7 #include "Render.h"
|
|
8 #include "IconFrameTable.h"
|
|
9
|
|
10 #include "mm7_data.h"
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15 struct GUIProgressBar *pGameLoadingUI_ProgressBar = new GUIProgressBar;
|
|
16
|
|
17
|
|
18
|
|
19
|
434
|
20 //----- (00Initialize) --------------------------------------------------------
|
|
21 bool GUIProgressBar::Initialize(Type type)
|
0
|
22 {
|
|
23 //GUIProgressBar *v2; // esi@1
|
|
24 signed int v4; // eax@7
|
|
25 int v5; // ecx@8
|
|
26 int v6; // edi@8
|
|
27 int v7; // edx@14
|
373
|
28 //const char *v8; // [sp-8h] [bp-84h]@20
|
|
29 //unsigned int v9; // [sp-4h] [bp-80h]@20
|
0
|
30 char Str1[64]; // [sp+4h] [bp-78h]@16
|
|
31
|
434
|
32 switch (type)
|
0
|
33 {
|
434
|
34 case TYPE_None:
|
|
35 return true;
|
|
36
|
|
37 case TYPE_Box:
|
|
38 case TYPE_Fullscreen:
|
|
39 break;
|
|
40
|
|
41 default:
|
|
42 assert(false && "Invalid GUIProgressBar type");
|
0
|
43 }
|
|
44
|
|
45 //v2 = this;
|
|
46 if (pAsyncMouse)
|
|
47 pAsyncMouse->Suspend();
|
|
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;
|
|
111 default: assert(false);
|
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 (pAsyncMouse)
|
|
149 pAsyncMouse->Resume();
|
|
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);
|
0
|
218 pRenderer->Clip(0xACu, 0x1CBu,
|
|
219 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172,
|
|
220 0x1D7u);
|
|
221 pRenderer->DrawTextureTransparent(0xACu, 0x1CBu, &pLoadingProgress);
|
|
222 pRenderer->ResetClip();
|
|
223 LABEL_11:
|
|
224 pRenderer->EndScene();
|
|
225 pRenderer->Present();
|
|
226 } |