annotate GUI/GUIProgressBar.cpp @ 2548:87e5590d034b

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