annotate GUIProgressBar.cpp @ 0:8b8875f5b359

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