2502
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
2541
|
6 #include "Engine/Engine.h"
|
|
7
|
2502
|
8 #include "GUIProgressBar.h"
|
|
9 #include "Engine/LOD.h"
|
|
10 #include "Engine/Party.h"
|
|
11 #include "Engine/Graphics/Render.h"
|
|
12 #include "Engine/Tables/IconFrameTable.h"
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17 struct GUIProgressBar *pGameLoadingUI_ProgressBar = new GUIProgressBar;
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22 //----- (00Initialize) --------------------------------------------------------
|
|
23 bool GUIProgressBar::Initialize(Type type)
|
|
24 {
|
|
25 //GUIProgressBar *v2; // esi@1
|
|
26 signed int v4; // eax@7
|
|
27 int v5; // ecx@8
|
|
28 //int v6; // edi@8
|
|
29 int v7; // edx@14
|
|
30 //const char *v8; // [sp-8h] [bp-84h]@20
|
|
31 //unsigned int v9; // [sp-4h] [bp-80h]@20
|
|
32 char Str1[64]; // [sp+4h] [bp-78h]@16
|
|
33
|
|
34 switch (type)
|
|
35 {
|
|
36 case TYPE_None:
|
|
37 return true;
|
|
38
|
|
39 case TYPE_Box:
|
|
40 case TYPE_Fullscreen:
|
|
41 break;
|
|
42
|
|
43 default:
|
|
44 Error("Invalid GUIProgressBar type: %u", type);
|
|
45 }
|
|
46
|
|
47 //v2 = this;
|
|
48 if (pLoadingBg.pPixels)
|
|
49 return false;
|
|
50
|
|
51 uType = type;
|
|
52
|
|
53 v4 = 1;
|
|
54 if (uType == TYPE_Fullscreen)
|
|
55 {
|
|
56 v5 = 0;
|
|
57 //v6 = (int)&field_10;
|
|
58 do
|
|
59 {
|
|
60 if ( field_10[v4] == 1 )
|
|
61 ++v5;
|
|
62 ++v4;
|
|
63 }
|
|
64 while ( v4 <= 5 );
|
|
65 if ( v5 == 5 )
|
|
66 memset(field_10, 0, 8);
|
|
67 v7 = rand() % 5 + 1;
|
|
68 if ( field_10[v7] == 1 )
|
|
69 {
|
|
70 do
|
|
71 v7 = rand() % 5 + 1;
|
|
72 while ( field_10[v7] == 1 );
|
|
73 }
|
|
74 sprintf(Str1, "loading%d.pcx", v7);
|
|
75 pLoadingBg.Load(Str1, 2);
|
|
76 uProgressCurrent = 0;
|
|
77 uX = 122;
|
|
78 uY = 151;
|
|
79 uWidth = 449;
|
|
80 uHeight = 56;
|
|
81 uProgressMax = 26;
|
|
82 pIcons_LOD->_410522(&pLoadingProgress, "loadprog", 2u);
|
|
83 Draw();
|
|
84 return true;
|
|
85 }
|
|
86
|
|
87 switch (pParty->alignment)
|
|
88 {
|
|
89 case PartyAlignment_Good: pIcons_LOD->_410522(&pBardata, "bardata-b", 2); break;
|
|
90 case PartyAlignment_Neutral: pIcons_LOD->_410522(&pBardata, "bardata", 2); break;
|
|
91 case PartyAlignment_Evil: pIcons_LOD->_410522(&pBardata, "bardata-c", 2); break;
|
|
92 default: Error("Invalid alignment type: %u", pParty->alignment);
|
|
93 }
|
|
94
|
|
95 uProgressCurrent = 0;
|
|
96 uProgressMax = 26;
|
|
97 Draw();
|
|
98 return true;
|
|
99 }
|
|
100
|
|
101 //----- (004435BB) --------------------------------------------------------
|
|
102 void GUIProgressBar::Reset(unsigned __int8 uMaxProgress)
|
|
103 {
|
|
104 field_9 = 0;
|
|
105 uProgressCurrent = 0;
|
|
106 uProgressMax = uMaxProgress;
|
|
107 }
|
|
108
|
|
109 //----- (004435CD) --------------------------------------------------------
|
|
110 void GUIProgressBar::Progress()
|
|
111 {
|
|
112 ++this->uProgressCurrent;
|
|
113 if ( this->uProgressCurrent > this->uProgressMax )
|
|
114 this->uProgressCurrent = this->uProgressMax;
|
|
115 Draw();
|
|
116 }
|
|
117
|
|
118 //----- (004435E2) --------------------------------------------------------
|
|
119 void GUIProgressBar::Release()
|
|
120 {
|
|
121 int v3; // edi@7
|
|
122
|
|
123 pLoadingBg.Release();
|
|
124 if ( this->uType == 1 )
|
|
125 {
|
|
126 if ( this->uProgressCurrent != this->uProgressMax )
|
|
127 {
|
|
128 this->uProgressCurrent = this->uProgressMax - 1;
|
|
129 Progress();
|
|
130 }
|
|
131 v3 = (int)&this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask;
|
|
132 free(this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask);
|
|
133 free(this->pLoadingProgress.pPalette16);
|
|
134 this->pLoadingProgress.pPalette16 = 0;
|
|
135 }
|
|
136 else
|
|
137 {
|
|
138 if ( !this->pBardata.pLevelOfDetail0_prolly_alpha_mask )
|
|
139 return;
|
|
140 free(this->pBardata.pLevelOfDetail0_prolly_alpha_mask);
|
|
141 v3 = (int)&this->pBardata.pPalette16;
|
|
142 free(this->pBardata.pPalette16);
|
|
143 this->pBardata.pLevelOfDetail0_prolly_alpha_mask = 0;
|
|
144 }
|
|
145 *(int *)v3 = 0;
|
|
146 }
|
|
147
|
|
148 //----- (00443670) --------------------------------------------------------
|
|
149 void GUIProgressBar::Draw()
|
|
150 {
|
|
151 pRenderer->BeginScene();
|
|
152 if (uType != TYPE_Fullscreen)
|
|
153 {
|
|
154 if (pBardata.pLevelOfDetail0_prolly_alpha_mask)
|
|
155 {
|
|
156 pRenderer->Sub01();
|
|
157
|
|
158 pRenderer->DrawTextureIndexed(80, 122, &pBardata);//прогрессбар для данжей
|
2524
|
159 pRenderer->DrawTextureIndexedAlpha(100, 146, &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconID_TurnHour, 0)->uTextureID]);
|
2502
|
160 //pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15),
|
|
161 //16, pRenderer->uTargetRMask);
|
|
162 pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15),
|
|
163 16, 0xF800);
|
|
164 pRenderer->EndScene();
|
|
165 pRenderer->Present();
|
|
166 return;
|
|
167 }
|
|
168 pRenderer->EndScene();
|
|
169 return;
|
|
170 }
|
|
171
|
|
172 if (!pLoadingBg.pPixels)
|
|
173 {
|
|
174 pRenderer->EndScene();
|
|
175 return;
|
|
176 }
|
|
177
|
|
178 pRenderer->DrawTextureRGB(0, 0, &pLoadingBg);
|
2525
|
179 //pRenderer->SetRasterClipRect(0, 0, 639, 479);
|
2524
|
180 pRenderer->SetUIClipRect(172, 459, 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, 471);
|
|
181 pRenderer->DrawTextureIndexedAlpha(172, 459, &pLoadingProgress);
|
|
182 pRenderer->ResetUIClipRect();
|
2502
|
183 pRenderer->EndScene();
|
|
184 pRenderer->Present();
|
|
185 } |