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