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