comparison GUIProgressBar.cpp @ 0:9c0607679772

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