annotate GUIProgressBar.cpp @ 142:8b8fd4d83fdc

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