0
|
1 #include "GUIProgressBar.h"
|
|
2 #include "LOD.h"
|
|
3 #include "Mouse.h"
|
|
4 #include "Party.h"
|
|
5 #include "Render.h"
|
|
6 #include "IconFrameTable.h"
|
|
7
|
|
8 #include "mm7_data.h"
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13 struct GUIProgressBar *pGameLoadingUI_ProgressBar;
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18 //----- (00443484) --------------------------------------------------------
|
|
19 bool GUIProgressBar::_443484(int a2)
|
|
20 {
|
|
21 GUIProgressBar *v2; // esi@1
|
|
22 signed int v4; // eax@7
|
|
23 int v5; // ecx@8
|
|
24 int v6; // edi@8
|
|
25 int v7; // edx@14
|
|
26 const char *v8; // [sp-8h] [bp-84h]@20
|
|
27 unsigned int v9; // [sp-4h] [bp-80h]@20
|
|
28 char Str1[64]; // [sp+4h] [bp-78h]@16
|
|
29
|
|
30 v2 = this;
|
2
|
31 if (pAsyncMouse)
|
0
|
32 pAsyncMouse->Suspend();
|
|
33 if ( v2->pLoadingBg.pPixels )
|
|
34 return 0;
|
|
35 if ( a2 )
|
|
36 v2->uType = a2;
|
|
37 v4 = 1;
|
|
38 if ( v2->uType == 1 )
|
|
39 {
|
|
40 v5 = 0;
|
|
41 v6 = (int)&v2->field_10;
|
|
42 do
|
|
43 {
|
|
44 if ( *(char *)(v6 + v4) == 1 )
|
|
45 ++v5;
|
|
46 ++v4;
|
|
47 }
|
|
48 while ( v4 <= 5 );
|
|
49 if ( v5 == 5 )
|
|
50 memset(&v2->field_10, 0, 8u);
|
|
51 v7 = rand() % 5 + 1;
|
|
52 if ( *(&v2->field_10 + v7) == 1 )
|
|
53 {
|
|
54 do
|
|
55 v7 = rand() % 5 + 1;
|
|
56 while ( *(char *)(v6 + v7) == 1 );
|
|
57 }
|
|
58 sprintfex(Str1, "loading%d.pcx", v7);
|
|
59 v2->pLoadingBg.Load(Str1, 2);
|
|
60 v2->uProgressCurrent = 0;
|
|
61 v2->uX = 122;
|
|
62 v2->uY = 151;
|
|
63 v2->uWidth = 449;
|
|
64 v2->uHeight = 56;
|
|
65 v2->uProgressMax = 26;
|
|
66 pIcons_LOD->_410522(&v2->pLoadingProgress, "loadprog", 2u);
|
|
67 Draw();
|
|
68 return 1;
|
|
69 }
|
|
70 if ( !pParty->uAlignment )
|
|
71 {
|
|
72 v9 = 2;
|
|
73 v8 = "bardata-b";
|
|
74 goto LABEL_23;
|
|
75 }
|
|
76 if ( pParty->uAlignment == 1 )
|
|
77 {
|
|
78 v9 = 2;
|
|
79 v8 = "bardata";
|
|
80 goto LABEL_23;
|
|
81 }
|
|
82 if ( pParty->uAlignment == 2 )
|
|
83 {
|
|
84 v9 = 2;
|
|
85 v8 = "bardata-c";
|
|
86 LABEL_23:
|
|
87 pIcons_LOD->_410522(&v2->pBardata, v8, v9);
|
|
88 }
|
|
89 v2->uProgressCurrent = 0;
|
|
90 v2->uProgressMax = 26;
|
|
91 Draw();
|
|
92 return 1;
|
|
93 }
|
|
94
|
|
95 //----- (004435BB) --------------------------------------------------------
|
|
96 void GUIProgressBar::Reset(unsigned __int8 uMaxProgress)
|
|
97 {
|
|
98 this->field_9 = 0;
|
|
99 this->uProgressCurrent = 0;
|
|
100 this->uProgressMax = uMaxProgress;
|
|
101 }
|
|
102
|
|
103 //----- (004435CD) --------------------------------------------------------
|
|
104 void GUIProgressBar::Progress()
|
|
105 {
|
|
106 unsigned __int8 v1; // al@1
|
|
107
|
|
108 ++this->uProgressCurrent;
|
|
109 v1 = this->uProgressMax;
|
|
110 if ( this->uProgressCurrent > v1 )
|
|
111 this->uProgressCurrent = v1;
|
|
112 Draw();
|
|
113 }
|
|
114
|
|
115 //----- (004435E2) --------------------------------------------------------
|
|
116 void GUIProgressBar::Release()
|
|
117 {
|
|
118 GUIProgressBar *v1; // esi@1
|
|
119 char v2; // al@5
|
|
120 int v3; // edi@7
|
|
121
|
|
122 v1 = this;
|
2
|
123 if (pAsyncMouse)
|
0
|
124 pAsyncMouse->Resume();
|
|
125 if ( v1->uType == 1 )
|
|
126 {
|
|
127 if ( !v1->pLoadingBg.pPixels )
|
|
128 return;
|
|
129 v2 = v1->uProgressMax;
|
|
130 if ( v1->uProgressCurrent != v2 )
|
|
131 {
|
|
132 v1->uProgressCurrent = v2 - 1;
|
|
133 Progress();
|
|
134 }
|
|
135 free(v1->pLoadingBg.pPixels);
|
|
136 v3 = (int)&v1->pLoadingProgress.pLevelOfDetail0;
|
|
137 free(v1->pLoadingProgress.pLevelOfDetail0);
|
|
138 free(v1->pLoadingProgress.pPalette16);
|
|
139 v1->pLoadingProgress.pPalette16 = 0;
|
|
140 v1->pLoadingBg.pPixels = 0;
|
|
141 }
|
|
142 else
|
|
143 {
|
|
144 if ( !v1->pBardata.pLevelOfDetail0 )
|
|
145 return;
|
|
146 free(v1->pBardata.pLevelOfDetail0);
|
|
147 v3 = (int)&v1->pBardata.pPalette16;
|
|
148 free(v1->pBardata.pPalette16);
|
|
149 v1->pBardata.pLevelOfDetail0 = 0;
|
|
150 }
|
|
151 *(int *)v3 = 0;
|
|
152 }
|
|
153
|
|
154 //----- (00443670) --------------------------------------------------------
|
|
155 void GUIProgressBar::Draw()
|
|
156 {
|
|
157 GUIProgressBar *v1; // edi@1
|
|
158 Render *v2; // ecx@2
|
|
159 IconFrame *v3; // eax@10
|
|
160 float v4; // ST2C_4@10
|
|
161
|
|
162 v1 = this;
|
|
163 pRenderer->BeginScene();
|
|
164 if ( v1->uType != 1 )
|
|
165 {
|
|
166 if ( v1->pBardata.pLevelOfDetail0 )
|
|
167 {
|
|
168 if ( pRenderer->pRenderD3D )
|
|
169 {
|
|
170 if ( !pRenderer->bWindowMode )
|
|
171 pRenderer->_49FD3A((int)v1);
|
|
172 }
|
|
173 pRenderer->DrawTextureIndexed(0x50u, 0x7Au, &v1->pBardata);
|
|
174 v3 = pIconsFrameTable->GetFrame(uIconID_TurnHour, 0);
|
|
175 pRenderer->DrawTextureTransparent(0x64u, 0x92u, &pIcons_LOD->pTextures[v3->uTextureID]);
|
|
176 v4 = (double)(113 * v1->uProgressCurrent) / (double)v1->uProgressMax;
|
|
177 pRenderer->FillRect2(
|
|
178 0,
|
|
179 174,
|
|
180 164,
|
|
181 COERCE_UNSIGNED_INT64(v4 + 6.7553994e15),
|
|
182 16,
|
|
183 LOWORD(pRenderer->uTargetRMask));
|
|
184 goto LABEL_11;
|
|
185 }
|
|
186 v2 = pRenderer;
|
|
187 LABEL_6:
|
|
188 pRenderer->EndScene();
|
|
189 return;
|
|
190 }
|
|
191 v2 = pRenderer;
|
|
192 if ( !v1->pLoadingBg.pPixels )
|
|
193 goto LABEL_6;
|
|
194 pRenderer->DrawTextureRGB(0, 0, &v1->pLoadingBg);
|
|
195 pRenderer->Clip_v2(0, 0, 0x27Fu, 0x1DFu);
|
|
196 pRenderer->Clip(
|
|
197 0xACu,
|
|
198 0x1CBu,
|
|
199 15 * (signed int)(signed __int64)((double)(300 * v1->uProgressCurrent) / (double)v1->uProgressMax) / 15 + 172,
|
|
200 0x1D7u);
|
|
201 pRenderer->DrawTextureTransparent(0xACu, 0x1CBu, &v1->pLoadingProgress);
|
|
202 pRenderer->ResetClip();
|
|
203 LABEL_11:
|
|
204 pRenderer->EndScene();
|
|
205 pRenderer->Present();
|
|
206 } |