Mercurial > mm7
annotate GUI/GUIProgressBar.cpp @ 2572:d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
author | a.parshin |
---|---|
date | Sat, 05 Mar 2016 01:51:54 +0200 |
parents | a902abdfc7f2 |
children | 0c67be4ec900 |
rev | line source |
---|---|
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" |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
7 #include "Engine/AssetsManager.h" |
2541 | 8 |
2502 | 9 #include "GUIProgressBar.h" |
10 #include "Engine/LOD.h" | |
11 #include "Engine/Party.h" | |
12 #include "Engine/Graphics/Render.h" | |
13 #include "Engine/Tables/IconFrameTable.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; | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
49 if (loading_bg) |
2502 | 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); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
76 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
77 wchar_t image_name[1024]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
78 swprintf(image_name, L"loading%d.pcx", v7); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
79 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
80 loading_bg = assets->GetImage_PCXFromIconsLOD(image_name); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
81 //pLoadingBg.Load(Str1, 2); |
2502 | 82 uProgressCurrent = 0; |
83 uX = 122; | |
84 uY = 151; | |
85 uWidth = 449; | |
86 uHeight = 56; | |
87 uProgressMax = 26; | |
88 pIcons_LOD->_410522(&pLoadingProgress, "loadprog", 2u); | |
89 Draw(); | |
90 return true; | |
91 } | |
92 | |
93 switch (pParty->alignment) | |
94 { | |
95 case PartyAlignment_Good: pIcons_LOD->_410522(&pBardata, "bardata-b", 2); break; | |
96 case PartyAlignment_Neutral: pIcons_LOD->_410522(&pBardata, "bardata", 2); break; | |
97 case PartyAlignment_Evil: pIcons_LOD->_410522(&pBardata, "bardata-c", 2); break; | |
98 default: Error("Invalid alignment type: %u", pParty->alignment); | |
99 } | |
100 | |
101 uProgressCurrent = 0; | |
102 uProgressMax = 26; | |
103 Draw(); | |
104 return true; | |
105 } | |
106 | |
107 //----- (004435BB) -------------------------------------------------------- | |
108 void GUIProgressBar::Reset(unsigned __int8 uMaxProgress) | |
109 { | |
110 field_9 = 0; | |
111 uProgressCurrent = 0; | |
112 uProgressMax = uMaxProgress; | |
113 } | |
114 | |
115 //----- (004435CD) -------------------------------------------------------- | |
116 void GUIProgressBar::Progress() | |
117 { | |
118 ++this->uProgressCurrent; | |
119 if ( this->uProgressCurrent > this->uProgressMax ) | |
120 this->uProgressCurrent = this->uProgressMax; | |
121 Draw(); | |
122 } | |
123 | |
124 //----- (004435E2) -------------------------------------------------------- | |
125 void GUIProgressBar::Release() | |
126 { | |
127 int v3; // edi@7 | |
128 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
129 if (loading_bg) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
130 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
131 loading_bg->Release(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
132 loading_bg = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
133 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
134 |
2502 | 135 if ( this->uType == 1 ) |
136 { | |
137 if ( this->uProgressCurrent != this->uProgressMax ) | |
138 { | |
139 this->uProgressCurrent = this->uProgressMax - 1; | |
140 Progress(); | |
141 } | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
142 v3 = (int)&this->pLoadingProgress.paletted_pixels; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
143 free(this->pLoadingProgress.paletted_pixels); |
2502 | 144 free(this->pLoadingProgress.pPalette16); |
145 this->pLoadingProgress.pPalette16 = 0; | |
146 } | |
147 else | |
148 { | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
149 if ( !this->pBardata.paletted_pixels) |
2502 | 150 return; |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
151 free(this->pBardata.paletted_pixels); |
2502 | 152 v3 = (int)&this->pBardata.pPalette16; |
153 free(this->pBardata.pPalette16); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
154 this->pBardata.paletted_pixels = 0; |
2502 | 155 } |
156 *(int *)v3 = 0; | |
157 } | |
158 | |
159 //----- (00443670) -------------------------------------------------------- | |
160 void GUIProgressBar::Draw() | |
161 { | |
162 pRenderer->BeginScene(); | |
163 if (uType != TYPE_Fullscreen) | |
164 { | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
165 if (pBardata.paletted_pixels) |
2502 | 166 { |
167 pRenderer->Sub01(); | |
168 | |
169 pRenderer->DrawTextureIndexed(80, 122, &pBardata);//прогрессбар для данжей | |
2524 | 170 pRenderer->DrawTextureIndexedAlpha(100, 146, &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconID_TurnHour, 0)->uTextureID]); |
2502 | 171 //pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), |
172 //16, pRenderer->uTargetRMask); | |
173 pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), | |
174 16, 0xF800); | |
175 pRenderer->EndScene(); | |
176 pRenderer->Present(); | |
177 return; | |
178 } | |
179 pRenderer->EndScene(); | |
180 return; | |
181 } | |
182 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
183 //if (!pLoadingBg.pPixels) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
184 if (!loading_bg) |
2502 | 185 { |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
186 pRenderer->EndScene(); |
2502 | 187 } |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
188 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
189 { |
2502 | 190 |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
191 pRenderer->DrawTextureNew(0, 0, loading_bg); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
192 //pRenderer->SetRasterClipRect(0, 0, 639, 479); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
193 pRenderer->SetUIClipRect(172, 459, 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, 471); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
194 pRenderer->DrawTextureIndexedAlpha(172, 459, &pLoadingProgress); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
195 pRenderer->ResetUIClipRect(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
196 pRenderer->EndScene(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
197 pRenderer->Present(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
198 } |
2502 | 199 } |