Mercurial > mm7
annotate GUIProgressBar.cpp @ 2449:e40805af239b
commenting AI
author | zipi |
---|---|
date | Thu, 24 Jul 2014 19:55:55 +0100 |
parents | 2b10278bc7ac |
children | b054ea5daf45 |
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 | |
2429 | 30 //int v6; // edi@8 |
0 | 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; | |
2429 | 59 //v6 = (int)&field_10; |
0 | 60 do |
61 { | |
2429 | 62 if ( field_10[v4] == 1 ) |
0 | 63 ++v5; |
64 ++v4; | |
65 } | |
66 while ( v4 <= 5 ); | |
67 if ( v5 == 5 ) | |
2429 | 68 memset(field_10, 0, 8); |
0 | 69 v7 = rand() % 5 + 1; |
2429 | 70 if ( field_10[v7] == 1 ) |
0 | 71 { |
72 do | |
73 v7 = rand() % 5 + 1; | |
2429 | 74 while ( field_10[v7] == 1 ); |
0 | 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 switch (pParty->alignment) | |
90 { | |
91 case PartyAlignment_Good: pIcons_LOD->_410522(&pBardata, "bardata-b", 2); break; | |
92 case PartyAlignment_Neutral: pIcons_LOD->_410522(&pBardata, "bardata", 2); break; | |
93 case PartyAlignment_Evil: pIcons_LOD->_410522(&pBardata, "bardata-c", 2); break; | |
1545 | 94 default: Error("Invalid alignment type: %u", pParty->alignment); |
0 | 95 } |
373 | 96 |
0 | 97 uProgressCurrent = 0; |
98 uProgressMax = 26; | |
99 Draw(); | |
100 return true; | |
101 } | |
102 | |
103 //----- (004435BB) -------------------------------------------------------- | |
104 void GUIProgressBar::Reset(unsigned __int8 uMaxProgress) | |
105 { | |
106 field_9 = 0; | |
107 uProgressCurrent = 0; | |
108 uProgressMax = uMaxProgress; | |
109 } | |
110 | |
111 //----- (004435CD) -------------------------------------------------------- | |
112 void GUIProgressBar::Progress() | |
113 { | |
114 ++this->uProgressCurrent; | |
2271 | 115 if ( this->uProgressCurrent > this->uProgressMax ) |
116 this->uProgressCurrent = this->uProgressMax; | |
0 | 117 Draw(); |
118 } | |
119 | |
120 //----- (004435E2) -------------------------------------------------------- | |
121 void GUIProgressBar::Release() | |
122 { | |
123 int v3; // edi@7 | |
124 | |
2440 | 125 pLoadingBg.Release(); |
2271 | 126 if ( this->uType == 1 ) |
0 | 127 { |
2271 | 128 if ( this->uProgressCurrent != this->uProgressMax ) |
0 | 129 { |
2271 | 130 this->uProgressCurrent = this->uProgressMax - 1; |
0 | 131 Progress(); |
132 } | |
2271 | 133 v3 = (int)&this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask; |
134 free(this->pLoadingProgress.pLevelOfDetail0_prolly_alpha_mask); | |
135 free(this->pLoadingProgress.pPalette16); | |
136 this->pLoadingProgress.pPalette16 = 0; | |
0 | 137 } |
138 else | |
139 { | |
2271 | 140 if ( !this->pBardata.pLevelOfDetail0_prolly_alpha_mask ) |
0 | 141 return; |
2271 | 142 free(this->pBardata.pLevelOfDetail0_prolly_alpha_mask); |
143 v3 = (int)&this->pBardata.pPalette16; | |
144 free(this->pBardata.pPalette16); | |
145 this->pBardata.pLevelOfDetail0_prolly_alpha_mask = 0; | |
0 | 146 } |
147 *(int *)v3 = 0; | |
148 } | |
149 | |
150 //----- (00443670) -------------------------------------------------------- | |
151 void GUIProgressBar::Draw() | |
152 { | |
153 pRenderer->BeginScene(); | |
154 if (uType != TYPE_Fullscreen) | |
155 { | |
710 | 156 if (pBardata.pLevelOfDetail0_prolly_alpha_mask) |
0 | 157 { |
2271 | 158 pRenderer->Sub01(); |
2153 | 159 |
2098 | 160 pRenderer->DrawTextureIndexed(80, 122, &pBardata);//прогрессбар для данжей |
161 pRenderer->DrawTextureTransparent(100, 146, &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(uIconID_TurnHour, 0)->uTextureID]); | |
162 //pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), | |
163 //16, pRenderer->uTargetRMask); | |
164 pRenderer->FillRectFast(174, 164, floorf(((double)(113 * uProgressCurrent) / (double)uProgressMax) + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), | |
165 16, 0xF800); | |
166 pRenderer->EndScene(); | |
167 pRenderer->Present(); | |
168 return; | |
0 | 169 } |
170 pRenderer->EndScene(); | |
171 return; | |
172 } | |
173 | |
174 if (!pLoadingBg.pPixels) | |
1421 | 175 { |
2098 | 176 pRenderer->EndScene(); |
1421 | 177 return; |
178 } | |
0 | 179 |
180 pRenderer->DrawTextureRGB(0, 0, &pLoadingBg); | |
2098 | 181 pRenderer->SetRasterClipRect(0, 0, 639, 479); |
182 pRenderer->SetTextureClipRect(172, 459, 15 * (signed int)(signed __int64)((double)(300 * uProgressCurrent) / (double)uProgressMax) / 15 + 172, 471); | |
183 pRenderer->DrawTextureTransparent(172, 459, &pLoadingProgress); | |
727 | 184 pRenderer->ResetTextureClipRect(); |
0 | 185 pRenderer->EndScene(); |
186 pRenderer->Present(); | |
187 } |