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