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