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