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