Mercurial > mm7
annotate GUI/GUIProgressBar.cpp @ 2575:a76d408c5132 tip
DrawTranslucent -> DrawTextureGrayShade
Removed old texture drawing stuff
author | a.parshin |
---|---|
date | Wed, 09 Mar 2016 01:39:52 +0200 |
parents | 0c67be4ec900 |
children |
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; | |
2575 | 88 |
89 //pIcons_LOD->PlacementLoadTexture(&pLoadingProgress, "loadprog", 2u); | |
90 progressbar_loading = assets->GetImage_16BitColorKey("loadprog", 0x7FF); | |
2502 | 91 Draw(); |
92 return true; | |
93 } | |
94 | |
95 switch (pParty->alignment) | |
96 { | |
2575 | 97 case PartyAlignment_Good: progressbar_dungeon = assets->GetImage_16BitColorKey("bardata-b", 0x7FF); break; |
98 case PartyAlignment_Neutral: progressbar_dungeon = assets->GetImage_16BitColorKey("bardata", 0x7FF); break; | |
99 case PartyAlignment_Evil: progressbar_dungeon = assets->GetImage_16BitColorKey("bardata-c", 0x7FF); break; | |
100 //case PartyAlignment_Good: pIcons_LOD->PlacementLoadTexture(&pBardata, "bardata-b", 2); break; | |
101 //case PartyAlignment_Neutral: pIcons_LOD->PlacementLoadTexture(&pBardata, "bardata", 2); break; | |
102 //case PartyAlignment_Evil: pIcons_LOD->PlacementLoadTexture(&pBardata, "bardata-c", 2); break; | |
2502 | 103 default: Error("Invalid alignment type: %u", pParty->alignment); |
104 } | |
105 | |
106 uProgressCurrent = 0; | |
107 uProgressMax = 26; | |
108 Draw(); | |
109 return true; | |
110 } | |
111 | |
112 //----- (004435BB) -------------------------------------------------------- | |
113 void GUIProgressBar::Reset(unsigned __int8 uMaxProgress) | |
114 { | |
115 field_9 = 0; | |
116 uProgressCurrent = 0; | |
117 uProgressMax = uMaxProgress; | |
118 } | |
119 | |
120 //----- (004435CD) -------------------------------------------------------- | |
121 void GUIProgressBar::Progress() | |
122 { | |
123 ++this->uProgressCurrent; | |
124 if ( this->uProgressCurrent > this->uProgressMax ) | |
125 this->uProgressCurrent = this->uProgressMax; | |
126 Draw(); | |
127 } | |
128 | |
129 //----- (004435E2) -------------------------------------------------------- | |
130 void GUIProgressBar::Release() | |
131 { | |
132 int v3; // edi@7 | |
133 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
134 if (loading_bg) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
135 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
136 loading_bg->Release(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
137 loading_bg = nullptr; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
138 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
139 |
2502 | 140 if ( this->uType == 1 ) |
141 { | |
142 if ( this->uProgressCurrent != this->uProgressMax ) | |
143 { | |
144 this->uProgressCurrent = this->uProgressMax - 1; | |
145 Progress(); | |
146 } | |
2575 | 147 |
148 if (progressbar_loading) | |
149 { | |
150 progressbar_loading->Release(); | |
151 progressbar_loading = nullptr; | |
152 } | |
153 //v3 = (int)&this->pLoadingProgress.paletted_pixels; | |
154 //free(this->pLoadingProgress.paletted_pixels); | |
155 //free(this->pLoadingProgress.pPalette16); | |
156 //this->pLoadingProgress.pPalette16 = 0; | |
157 //*(int *)v3 = 0; | |
2502 | 158 } |
159 else | |
160 { | |
2575 | 161 //if ( !this->pBardata.paletted_pixels) |
162 // return; | |
163 //free(this->pBardata.paletted_pixels); | |
164 //v3 = (int)&this->pBardata.pPalette16; | |
165 //free(this->pBardata.pPalette16); | |
166 //this->pBardata.paletted_pixels = 0; | |
167 //*(int *)v3 = 0; | |
168 if (progressbar_dungeon) | |
169 { | |
170 progressbar_dungeon->Release(); | |
171 progressbar_dungeon = nullptr; | |
172 } | |
2502 | 173 } |
174 } | |
175 | |
176 //----- (00443670) -------------------------------------------------------- | |
177 void GUIProgressBar::Draw() | |
178 { | |
179 pRenderer->BeginScene(); | |
180 if (uType != TYPE_Fullscreen) | |
181 { | |
2575 | 182 //if (pBardata.paletted_pixels) |
2502 | 183 { |
184 pRenderer->Sub01(); | |
185 | |
2575 | 186 pRenderer->DrawTextureAlphaNew(80/640.0f, 122/480.0f, progressbar_dungeon); |
187 pRenderer->DrawTextureAlphaNew(100/640.0f, 146/480.0f, pIconsFrameTable->GetFrame(uIconID_TurnHour, 0)->texture); | |
2502 | 188 //pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), |
189 //16, pRenderer->uTargetRMask); | |
190 pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), | |
191 16, 0xF800); | |
192 pRenderer->EndScene(); | |
193 pRenderer->Present(); | |
194 return; | |
195 } | |
196 pRenderer->EndScene(); | |
197 return; | |
198 } | |
199 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
200 //if (!pLoadingBg.pPixels) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
201 if (!loading_bg) |
2502 | 202 { |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
203 pRenderer->EndScene(); |
2502 | 204 } |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
205 else |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
206 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
207 pRenderer->DrawTextureNew(0, 0, loading_bg); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
208 //pRenderer->SetRasterClipRect(0, 0, 639, 479); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
209 pRenderer->SetUIClipRect(172, 459, 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, 471); |
2575 | 210 pRenderer->DrawTextureAlphaNew(172/640.0f, 459/480.0f, progressbar_loading); |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
211 pRenderer->ResetUIClipRect(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
212 pRenderer->EndScene(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
213 pRenderer->Present(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2541
diff
changeset
|
214 } |
2502 | 215 } |