Mercurial > mm7
annotate GUIProgressBar.cpp @ 2425:d922225a6081
Hot key for mm7 main menu
author | Ritor1 |
---|---|
date | Wed, 23 Jul 2014 16:06:17 +0600 |
parents | 0313c761d203 |
children | 6d5877899730 |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2153
diff
changeset
|
5 #define _CRT_SECURE_NO_WARNINGS |
0 | 6 #include "GUIProgressBar.h" |
2336 | 7 #include "ErrorHandling.h" |
0 | 8 #include "LOD.h" |
9 #include "Mouse.h" | |
10 #include "Party.h" | |
11 #include "Render.h" | |
12 #include "IconFrameTable.h" | |
13 | |
14 #include "mm7_data.h" | |
15 | |
16 | |
17 | |
18 | |
19 struct GUIProgressBar *pGameLoadingUI_ProgressBar = new GUIProgressBar; | |
20 | |
21 | |
22 | |
23 | |
434 | 24 //----- (00Initialize) -------------------------------------------------------- |
25 bool GUIProgressBar::Initialize(Type type) | |
0 | 26 { |
27 //GUIProgressBar *v2; // esi@1 | |
28 signed int v4; // eax@7 | |
29 int v5; // ecx@8 | |
30 int v6; // edi@8 | |
31 int v7; // edx@14 | |
373 | 32 //const char *v8; // [sp-8h] [bp-84h]@20 |
33 //unsigned int v9; // [sp-4h] [bp-80h]@20 | |
0 | 34 char Str1[64]; // [sp+4h] [bp-78h]@16 |
35 | |
434 | 36 switch (type) |
0 | 37 { |
434 | 38 case TYPE_None: |
39 return true; | |
40 | |
41 case TYPE_Box: | |
42 case TYPE_Fullscreen: | |
43 break; | |
44 | |
45 default: | |
1545 | 46 Error("Invalid GUIProgressBar type: %u", type); |
0 | 47 } |
48 | |
49 //v2 = this; | |
50 if (pLoadingBg.pPixels) | |
51 return false; | |
52 | |
53 uType = type; | |
54 | |
55 v4 = 1; | |
56 if (uType == TYPE_Fullscreen) | |
57 { | |
58 v5 = 0; | |
59 v6 = (int)&field_10; | |
60 do | |
61 { | |
2420 | 62 if ( *(char *)(v6 + v4) == 1 ) //Uninitialized memory access (v6) |
0 | 63 ++v5; |
64 ++v4; | |
65 } | |
66 while ( v4 <= 5 ); | |
67 if ( v5 == 5 ) | |
2271 | 68 memset(&field_10, 0, 8); |
0 | 69 v7 = rand() % 5 + 1; |
70 if ( *(&field_10 + v7) == 1 ) | |
71 { | |
72 do | |
73 v7 = rand() % 5 + 1; | |
74 while ( *(char *)(v6 + v7) == 1 ); | |
75 } | |
76 sprintf(Str1, "loading%d.pcx", v7); | |
77 pLoadingBg.Load(Str1, 2); | |
78 uProgressCurrent = 0; | |
79 uX = 122; | |
80 uY = 151; | |
81 uWidth = 449; | |
82 uHeight = 56; | |
83 uProgressMax = 26; | |
84 pIcons_LOD->_410522(&pLoadingProgress, "loadprog", 2u); | |
85 Draw(); | |
86 return true; | |
87 } | |
373 | 88 |
89 /*if ( !pParty->uAlignment ) | |
0 | 90 { |
91 v9 = 2; | |
92 v8 = "bardata-b"; | |
93 goto LABEL_23; | |
94 } | |
95 if ( pParty->uAlignment == 1 ) | |
96 { | |
97 v9 = 2; | |
98 v8 = "bardata"; | |
99 goto LABEL_23; | |
100 } | |
101 if ( pParty->uAlignment == 2 ) | |
102 { | |
103 v9 = 2; | |
104 v8 = "bardata-c"; | |
105 LABEL_23: | |
106 pIcons_LOD->_410522(&pBardata, v8, v9); | |
373 | 107 }*/ |
108 switch (pParty->alignment) | |
109 { | |
110 case PartyAlignment_Good: pIcons_LOD->_410522(&pBardata, "bardata-b", 2); break; | |
111 case PartyAlignment_Neutral: pIcons_LOD->_410522(&pBardata, "bardata", 2); break; | |
112 case PartyAlignment_Evil: pIcons_LOD->_410522(&pBardata, "bardata-c", 2); break; | |
1545 | 113 default: Error("Invalid alignment type: %u", pParty->alignment); |
0 | 114 } |
373 | 115 |
0 | 116 uProgressCurrent = 0; |
117 uProgressMax = 26; | |
118 Draw(); | |
119 return true; | |
120 } | |
121 | |
122 //----- (004435BB) -------------------------------------------------------- | |
123 void GUIProgressBar::Reset(unsigned __int8 uMaxProgress) | |
124 { | |
125 field_9 = 0; | |
126 uProgressCurrent = 0; | |
127 uProgressMax = uMaxProgress; | |
128 } | |
129 | |
130 //----- (004435CD) -------------------------------------------------------- | |
131 void GUIProgressBar::Progress() | |
132 { | |
133 ++this->uProgressCurrent; | |
2271 | 134 if ( this->uProgressCurrent > this->uProgressMax ) |
135 this->uProgressCurrent = this->uProgressMax; | |
0 | 136 Draw(); |
137 } | |
138 | |
139 //----- (004435E2) -------------------------------------------------------- | |
140 void GUIProgressBar::Release() | |
141 { | |
142 int v3; // edi@7 | |
143 | |
2271 | 144 if ( this->uType == 1 ) |
0 | 145 { |
2271 | 146 if ( !this->pLoadingBg.pPixels ) |
0 | 147 return; |
2271 | 148 if ( this->uProgressCurrent != this->uProgressMax ) |
0 | 149 { |
2271 | 150 this->uProgressCurrent = this->uProgressMax - 1; |
0 | 151 Progress(); |
152 } | |
2271 | 153 free(this->pLoadingBg.pPixels); |
154 v3 = (int)&this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask; | |
155 free(this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask); | |
156 free(this->pLoadingProgress.pPalette16); | |
157 this->pLoadingProgress.pPalette16 = 0; | |
158 this->pLoadingBg.pPixels = 0; | |
0 | 159 } |
160 else | |
161 { | |
2271 | 162 if ( !this->pBardata.pLevelOfDetail0_prolly_alpha_mask ) |
0 | 163 return; |
2271 | 164 free(this->pBardata.pLevelOfDetail0_prolly_alpha_mask); |
165 v3 = (int)&this->pBardata.pPalette16; | |
166 free(this->pBardata.pPalette16); | |
167 this->pBardata.pLevelOfDetail0_prolly_alpha_mask = 0; | |
0 | 168 } |
169 *(int *)v3 = 0; | |
170 } | |
171 | |
172 //----- (00443670) -------------------------------------------------------- | |
173 void GUIProgressBar::Draw() | |
174 { | |
175 pRenderer->BeginScene(); | |
176 if (uType != TYPE_Fullscreen) | |
177 { | |
710 | 178 if (pBardata.pLevelOfDetail0_prolly_alpha_mask) |
0 | 179 { |
2271 | 180 pRenderer->Sub01(); |
2153 | 181 |
2098 | 182 pRenderer->DrawTextureIndexed(80, 122, &pBardata);//прогрессбар для данжей |
183 pRenderer->DrawTextureTransparent(100, 146, &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconID_TurnHour, 0)->uTextureID]); | |
184 //pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), | |
185 //16, pRenderer->uTargetRMask); | |
186 pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), | |
187 16, 0xF800); | |
188 pRenderer->EndScene(); | |
189 pRenderer->Present(); | |
190 return; | |
0 | 191 } |
192 pRenderer->EndScene(); | |
193 return; | |
194 } | |
195 | |
196 if (!pLoadingBg.pPixels) | |
1421 | 197 { |
2098 | 198 pRenderer->EndScene(); |
1421 | 199 return; |
200 } | |
0 | 201 |
202 pRenderer->DrawTextureRGB(0, 0, &pLoadingBg); | |
2098 | 203 pRenderer->SetRasterClipRect(0, 0, 639, 479); |
204 pRenderer->SetTextureClipRect(172, 459, 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, 471); | |
205 pRenderer->DrawTextureTransparent(172, 459, &pLoadingProgress); | |
727 | 206 pRenderer->ResetTextureClipRect(); |
0 | 207 pRenderer->EndScene(); |
208 pRenderer->Present(); | |
209 } |