1 /************************************************************************************
2 
3 	AstroMenace
4 	Hardcore 3D space scroll-shooter with spaceship upgrade possibilities.
5 	Copyright (c) 2006-2019 Mikhail Kurinnoi, Viewizard
6 
7 
8 	AstroMenace is free software: you can redistribute it and/or modify
9 	it under the terms of the GNU General Public License as published by
10 	the Free Software Foundation, either version 3 of the License, or
11 	(at your option) any later version.
12 
13 	AstroMenace is distributed in the hope that it will be useful,
14 	but WITHOUT ANY WARRANTY; without even the implied warranty of
15 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 	GNU General Public License for more details.
17 
18 	You should have received a copy of the GNU General Public License
19 	along with AstroMenace. If not, see <https://www.gnu.org/licenses/>.
20 
21 
22 	Website: https://viewizard.com/
23 	Project: https://github.com/viewizard/astromenace
24 	E-mail: viewizard@viewizard.com
25 
26 *************************************************************************************/
27 
28 // FIXME ostringstream is not so fast, move all string initialization into setup,
29 //       all ostringstream-related code should be called only one time in init
30 
31 // TODO translate comments
32 
33 #include "../game.h"
34 #include "../config/config.h"
35 #include "../ui/font.h"
36 #include "../ui/cursor.h"
37 #include "../assets/audio.h"
38 #include "../assets/texture.h"
39 #include "../object3d/space_ship/space_ship.h"
40 #include <sstream>
41 #include <iomanip>
42 
43 // NOTE switch to nested namespace definition (namespace A::B::C { ... }) (since C++17)
44 namespace viewizard {
45 namespace astromenace {
46 
47 extern std::weak_ptr<cSpaceShip> WorkshopFighterGame;
48 extern float CurrentAlert2;
49 extern float CurrentAlert3;
50 
51 void WorkshopDrawShip(std::weak_ptr<cSpaceShip> &SpaceShip, int Mode);
52 
53 float GetShipEngineSystemEnergyUse(int Num);
54 float GetShipProtectionSystemEnergyUse(int Num);
55 float GetShipRechargeEnergy(int Num);
56 
57 
58 // проблемы с энергией
59 extern bool NeedMoreEnergyDialog;
60 // Номер, для проигрывания голосового сообщения об проблемы с энергией
61 unsigned int VoiceNeedMoreEnergy{0};
62 
63 
64 // что рисовать в диалоге 6,7,8
65 extern int DialogSystem;
66 
67 
68 // текущий номер системы в мастерской
69 int CurrentSystemStockNum = 1;
70 
71 
72 
GetCurrentSustemStockNumBase()73 int GetCurrentSustemStockNumBase()
74 {
75 	switch (CurrentSystemStockNum) {
76 	case 1:
77 	case 2:
78 	case 3:
79 	case 4:
80 		return 1;
81 
82 	case 5:
83 	case 6:
84 	case 7:
85 	case 8:
86 		return 5;
87 
88 	case 9:
89 	case 10:
90 	case 11:
91 	case 12:
92 		return 9;
93 
94 	case 13:
95 	case 14:
96 	case 15:
97 	case 16:
98 		return 13;
99 
100 	case 17:
101 	case 18:
102 	case 19:
103 	case 20:
104 		return 17;
105 
106 	default:
107 		std::cerr << __func__ << "(): " << "wrong CurrentSystemStockNum.\n";
108 		break;
109 	}
110 
111 	return 0;
112 }
113 
114 
115 
GetSystemName(int Num)116 const char *GetSystemName(int Num)
117 {
118 	switch (Num) {
119 	case 1:
120 		return "Jet Engine";
121 	case 2:
122 		return "Photon Jet";
123 	case 3:
124 		return "Plasma Jet";
125 	case 4:
126 		return "Antimatter";
127 
128 	case 5:
129 		return "Ion Battery";
130 	case 6:
131 		return "Nuclear";
132 	case 7:
133 		return "Plasma";
134 	case 8:
135 		return "Antimatter";
136 
137 	case 9:
138 		return "Base O.T.C.";
139 	case 10:
140 		return "Hamerik O.T.C.";
141 	case 11:
142 		return "Neo M.O.T.C.";
143 	case 12:
144 		return "Supra M.O.T.C.";
145 
146 	case 13:
147 		return "Mechanical";
148 	case 14:
149 		return "Hydraulic";
150 	case 15:
151 		return "Magnetic";
152 	case 16:
153 		return "Vacuum";
154 
155 	case 17:
156 		return "Repair NaRs";
157 	case 18:
158 		return "Layer";
159 	case 19:
160 		return "Energy Shield";
161 	case 20:
162 		return "Deflector";
163 
164 	default:
165 		std::cerr << __func__ << "(): " << "wrong Num.\n";
166 		break;
167 	}
168 
169 	return nullptr;
170 }
171 
172 
173 
174 
GetSystemIcon(int Num)175 GLtexture GetSystemIcon(int Num)
176 {
177 	switch (Num) {
178 	case -4:
179 		return GetPreloadedTextureAsset("menu/system_empty.tga");
180 	case -3:
181 		return GetPreloadedTextureAsset("menu/system_empty.tga");
182 	case -2:
183 		return GetPreloadedTextureAsset("menu/system_empty.tga");
184 	case -1:
185 		return GetPreloadedTextureAsset("menu/system_empty.tga");
186 	case 0:
187 		return GetPreloadedTextureAsset("menu/system_empty.tga");
188 
189 	case 1:
190 		return GetPreloadedTextureAsset("menu/system_engine1.tga");
191 	case 2:
192 		return GetPreloadedTextureAsset("menu/system_engine2.tga");
193 	case 3:
194 		return GetPreloadedTextureAsset("menu/system_engine3.tga");
195 	case 4:
196 		return GetPreloadedTextureAsset("menu/system_engine4.tga");
197 
198 	case 5:
199 		return GetPreloadedTextureAsset("menu/system_power1.tga");
200 	case 6:
201 		return GetPreloadedTextureAsset("menu/system_power2.tga");
202 	case 7:
203 		return GetPreloadedTextureAsset("menu/system_power3.tga");
204 	case 8:
205 		return GetPreloadedTextureAsset("menu/system_power4.tga");
206 
207 	case 9:
208 		return GetPreloadedTextureAsset("menu/system_target1.tga");
209 	case 10:
210 		return GetPreloadedTextureAsset("menu/system_target2.tga");
211 	case 11:
212 		return GetPreloadedTextureAsset("menu/system_target3.tga");
213 	case 12:
214 		return GetPreloadedTextureAsset("menu/system_target4.tga");
215 
216 	case 13:
217 		return GetPreloadedTextureAsset("menu/system_mechan1.tga");
218 	case 14:
219 		return GetPreloadedTextureAsset("menu/system_mechan2.tga");
220 	case 15:
221 		return GetPreloadedTextureAsset("menu/system_mechan3.tga");
222 	case 16:
223 		return GetPreloadedTextureAsset("menu/system_mechan4.tga");
224 
225 	case 17:
226 		return GetPreloadedTextureAsset("menu/system_protect1.tga");
227 	case 18:
228 		return GetPreloadedTextureAsset("menu/system_protect2.tga");
229 	case 19:
230 		return GetPreloadedTextureAsset("menu/system_protect3.tga");
231 	case 20:
232 		return GetPreloadedTextureAsset("menu/system_protect4.tga");
233 
234 	default:
235 		std::cerr << __func__ << "(): " << "wrong Num.\n";
236 		break;
237 	}
238 
239 	return 0;
240 }
241 
242 
243 
GetSystemCost(int Num)244 int GetSystemCost(int Num)
245 {
246 	switch (Num) {
247 	case 1:
248 		return 200;
249 	case 2:
250 		return 1500;
251 	case 3:
252 		return 3000;
253 	case 4:
254 		return 6000;
255 
256 	case 5:
257 		return 250;
258 	case 6:
259 		return 2000;
260 	case 7:
261 		return 7000;
262 	case 8:
263 		return 15000;
264 
265 	case 9:
266 		return 100;
267 	case 10:
268 		return 1000;
269 	case 11:
270 		return 3000;
271 	case 12:
272 		return 6000;
273 
274 	case 13:
275 		return 150;
276 	case 14:
277 		return 1000;
278 	case 15:
279 		return 3000;
280 	case 16:
281 		return 7000;
282 
283 	case 17:
284 		return 2500;
285 	case 18:
286 		return 6000;
287 	case 19:
288 		return 10000;
289 	case 20:
290 		return 15000;
291 
292 	default:
293 		std::cerr << __func__ << "(): " << "wrong Num.\n";
294 		break;
295 	}
296 
297 	return 0;
298 }
299 
300 
301 
302 
303 
SellCurrentSystem()304 void SellCurrentSystem()
305 {
306 	if ((CurrentSystemStockNum >= 1) && (CurrentSystemStockNum <= 4)) {
307 		ChangeGameConfig().Profile[CurrentProfile].Money += GetSystemCost(GameConfig().Profile[CurrentProfile].EngineSystem);
308 		ChangeGameConfig().Profile[CurrentProfile].EngineSystem = 0;
309 		SetEarthSpaceFighterEngine(WorkshopFighterGame, GameConfig().Profile[CurrentProfile].EngineSystem);
310 	}
311 	if ((CurrentSystemStockNum >= 5) && (CurrentSystemStockNum <= 8)) {
312 		ChangeGameConfig().Profile[CurrentProfile].Money += GetSystemCost(GameConfig().Profile[CurrentProfile].PowerSystem+4);
313 		ChangeGameConfig().Profile[CurrentProfile].PowerSystem = 0;
314 	}
315 	if ((CurrentSystemStockNum >= 9) && (CurrentSystemStockNum <= 12)) {
316 		ChangeGameConfig().Profile[CurrentProfile].Money += GetSystemCost(GameConfig().Profile[CurrentProfile].TargetingSystem+8);
317 		ChangeGameConfig().Profile[CurrentProfile].TargetingSystem = 0;
318 	}
319 	if ((CurrentSystemStockNum >= 13) && (CurrentSystemStockNum <= 16)) {
320 		ChangeGameConfig().Profile[CurrentProfile].Money += GetSystemCost(GameConfig().Profile[CurrentProfile].TargetingMechanicSystem+12);
321 		ChangeGameConfig().Profile[CurrentProfile].TargetingMechanicSystem = 0;
322 	}
323 	if ((CurrentSystemStockNum >= 17) && (CurrentSystemStockNum <= 20)) {
324 		ChangeGameConfig().Profile[CurrentProfile].Money += GetSystemCost(GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem+16);
325 		ChangeGameConfig().Profile[CurrentProfile].AdvancedProtectionSystem = 0;
326 
327 		SetEarthSpaceFighterArmor(WorkshopFighterGame, GameConfig().Profile[CurrentProfile].ShipHullUpgrade - 1);
328 	}
329 }
330 
331 
BuyCurrentSystem()332 void BuyCurrentSystem()
333 {
334 	if ((CurrentSystemStockNum >= 1) && (CurrentSystemStockNum <= 4)) {
335 		if (GameConfig().Profile[CurrentProfile].EngineSystem != 0)
336 			ChangeGameConfig().Profile[CurrentProfile].Money += GetSystemCost(GameConfig().Profile[CurrentProfile].EngineSystem);
337 		ChangeGameConfig().Profile[CurrentProfile].EngineSystem = CurrentSystemStockNum;
338 		ChangeGameConfig().Profile[CurrentProfile].Money -= GetSystemCost(GameConfig().Profile[CurrentProfile].EngineSystem);
339 
340 		SetEarthSpaceFighterEngine(WorkshopFighterGame, GameConfig().Profile[CurrentProfile].EngineSystem);
341 	}
342 	if ((CurrentSystemStockNum >= 5) && (CurrentSystemStockNum <= 8)) {
343 		if (GameConfig().Profile[CurrentProfile].PowerSystem != 0)
344 			ChangeGameConfig().Profile[CurrentProfile].Money += GetSystemCost(GameConfig().Profile[CurrentProfile].PowerSystem + 4);
345 		ChangeGameConfig().Profile[CurrentProfile].PowerSystem = CurrentSystemStockNum - 4;
346 		ChangeGameConfig().Profile[CurrentProfile].Money -= GetSystemCost(GameConfig().Profile[CurrentProfile].PowerSystem + 4);
347 	}
348 	if ((CurrentSystemStockNum >= 9) && (CurrentSystemStockNum <= 12)) {
349 		if (GameConfig().Profile[CurrentProfile].TargetingSystem != 0)
350 			ChangeGameConfig().Profile[CurrentProfile].Money += GetSystemCost(GameConfig().Profile[CurrentProfile].TargetingSystem + 8);
351 		ChangeGameConfig().Profile[CurrentProfile].TargetingSystem = CurrentSystemStockNum - 8;
352 		ChangeGameConfig().Profile[CurrentProfile].Money -= GetSystemCost(GameConfig().Profile[CurrentProfile].TargetingSystem + 8);
353 	}
354 	if ((CurrentSystemStockNum >= 13) && (CurrentSystemStockNum <= 16)) {
355 		if (GameConfig().Profile[CurrentProfile].TargetingMechanicSystem != 0)
356 			ChangeGameConfig().Profile[CurrentProfile].Money += GetSystemCost(GameConfig().Profile[CurrentProfile].TargetingMechanicSystem + 12);
357 		ChangeGameConfig().Profile[CurrentProfile].TargetingMechanicSystem = CurrentSystemStockNum - 12;
358 		ChangeGameConfig().Profile[CurrentProfile].Money -= GetSystemCost(GameConfig().Profile[CurrentProfile].TargetingMechanicSystem + 12);
359 	}
360 	if ((CurrentSystemStockNum >= 17) && (CurrentSystemStockNum <= 20)) {
361 		if (GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem != 0)
362 			ChangeGameConfig().Profile[CurrentProfile].Money += GetSystemCost(GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem + 16);
363 		ChangeGameConfig().Profile[CurrentProfile].AdvancedProtectionSystem = CurrentSystemStockNum - 16;
364 		ChangeGameConfig().Profile[CurrentProfile].Money -= GetSystemCost(GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem + 16);
365 		SetEarthSpaceFighterArmor(WorkshopFighterGame, GameConfig().Profile[CurrentProfile].ShipHullUpgrade - 1);
366 	}
367 }
368 
369 
370 
371 
372 
373 
374 
375 
376 
377 
378 
379 
380 
381 
382 // для кнопок, чтобы проигрывать наведение
383 // последние координаты кнопки на которую наводились
384 int NeedPlayWorkshopOnButtonSoundX = 0;
385 int NeedPlayWorkshopOnButtonSoundY = 0;
386 
387 
388 
389 
390 //------------------------------------------------------------------------------------
391 // покупка-установка систем корабля
392 //------------------------------------------------------------------------------------
Workshop_Workshop()393 void Workshop_Workshop()
394 {
395 	sRECT SrcRect(0, 0, 256, 256);
396 	sRECT DstRect(GameConfig().InternalWidth / 2 - 256, 0, GameConfig().InternalWidth / 2 - 256 + 512, 412);
397 	vw_Draw2D(DstRect, SrcRect, GetPreloadedTextureAsset("menu/back_spot.tga"), true, 0.35f * MenuContentTransp);
398 
399 
400 
401 	vw_End2DMode();
402 	WorkshopDrawShip(WorkshopFighterGame, 1);
403 	vw_Start2DMode(-1,1);
404 
405 
406 	SrcRect(0,0,210,600);
407 	DstRect(GameConfig().InternalWidth/2-492, 50-10, GameConfig().InternalWidth/2-492+210, 50+600-10);
408 	vw_Draw2D(DstRect, SrcRect, GetPreloadedTextureAsset("menu/workshop_panel2.tga"), true, MenuContentTransp);
409 
410 
411 
412 	// выводим иконки систем в магазине, по которым тоже можно кликать
413 
414 	float Current = 0.4f;
415 
416 	SrcRect(0,0,128,128);
417 	DstRect(GameConfig().InternalWidth/2-451, 60, GameConfig().InternalWidth/2-451+128, 60+128);
418 	if (vw_MouseOverRect(DstRect) && !isDialogBoxDrawing()) {
419 		if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) {
420 			PlayMenuSFX(eMenuSFX::OverBigButton, 1.0f);
421 			NeedPlayWorkshopOnButtonSoundX = DstRect.left;
422 			NeedPlayWorkshopOnButtonSoundY = DstRect.top;
423 		}
424 
425 		SetCursorStatus(eCursorStatus::ActionAllowed);
426 		if (vw_GetMouseLeftClick(true)) {
427 			CurrentSystemStockNum = GetCurrentSustemStockNumBase();
428 			PlayMenuSFX(eMenuSFX::Click, 1.0f);
429 		}
430 
431 		Current = 0.7f;
432 	} else {
433 		if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) {
434 			NeedPlayWorkshopOnButtonSoundX = 0;
435 			NeedPlayWorkshopOnButtonSoundY = 0;
436 		}
437 	}
438 	if (CurrentSystemStockNum == GetCurrentSustemStockNumBase()) {
439 		Current = 1.0f;
440 	}
441 	vw_Draw2D(DstRect, SrcRect, GetSystemIcon(GetCurrentSustemStockNumBase()), true, MenuContentTransp*Current);
442 	int Size = vw_TextWidth(vw_GetText(GetSystemName(GetCurrentSustemStockNumBase())));
443 	float WScale = 0;
444 	if (Size > 128) {
445 		Size = 128;
446 		WScale = -128;
447 	}
448 	vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::white}, MenuContentTransp*Current, vw_GetTextUTF32(GetSystemName(GetCurrentSustemStockNumBase())));
449 
450 
451 
452 
453 	Current = 0.4f;
454 
455 	SrcRect(0,0,128,128);
456 	DstRect(GameConfig().InternalWidth/2-451, 200, GameConfig().InternalWidth/2-451+128, 200+128);
457 	if (vw_MouseOverRect(DstRect) && !isDialogBoxDrawing()) {
458 		if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) {
459 			PlayMenuSFX(eMenuSFX::OverBigButton, 1.0f);
460 			NeedPlayWorkshopOnButtonSoundX = DstRect.left;
461 			NeedPlayWorkshopOnButtonSoundY = DstRect.top;
462 		}
463 
464 		SetCursorStatus(eCursorStatus::ActionAllowed);
465 		if (vw_GetMouseLeftClick(true)) {
466 			CurrentSystemStockNum = GetCurrentSustemStockNumBase()+1;
467 			PlayMenuSFX(eMenuSFX::Click, 1.0f);
468 		}
469 
470 		Current = 0.7f;
471 	} else {
472 		if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) {
473 			NeedPlayWorkshopOnButtonSoundX = 0;
474 			NeedPlayWorkshopOnButtonSoundY = 0;
475 		}
476 	}
477 	if (CurrentSystemStockNum == GetCurrentSustemStockNumBase()+1) {
478 		Current = 1.0f;
479 	}
480 	vw_Draw2D(DstRect, SrcRect, GetSystemIcon(GetCurrentSustemStockNumBase()+1), true, MenuContentTransp*Current);
481 	Size = vw_TextWidth(vw_GetText(GetSystemName(GetCurrentSustemStockNumBase()+1)));
482 	WScale = 0;
483 	if (Size > 128) {
484 		Size = 128;
485 		WScale = -128;
486 	}
487 	vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::white}, MenuContentTransp*Current, vw_GetTextUTF32(GetSystemName(GetCurrentSustemStockNumBase()+1)));
488 
489 
490 
491 
492 	Current = 0.4f;
493 
494 	SrcRect(0,0,128,128);
495 	DstRect(GameConfig().InternalWidth/2-451, 340, GameConfig().InternalWidth/2-451+128, 340+128);
496 	if (vw_MouseOverRect(DstRect) && !isDialogBoxDrawing()) {
497 		if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) {
498 			PlayMenuSFX(eMenuSFX::OverBigButton, 1.0f);
499 			NeedPlayWorkshopOnButtonSoundX = DstRect.left;
500 			NeedPlayWorkshopOnButtonSoundY = DstRect.top;
501 		}
502 
503 		SetCursorStatus(eCursorStatus::ActionAllowed);
504 		if (vw_GetMouseLeftClick(true)) {
505 			CurrentSystemStockNum = GetCurrentSustemStockNumBase()+2;
506 			PlayMenuSFX(eMenuSFX::Click, 1.0f);
507 		}
508 
509 		Current = 0.7f;
510 	} else {
511 		if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) {
512 			NeedPlayWorkshopOnButtonSoundX = 0;
513 			NeedPlayWorkshopOnButtonSoundY = 0;
514 		}
515 	}
516 	if (CurrentSystemStockNum == GetCurrentSustemStockNumBase()+2) {
517 		Current = 1.0f;
518 	}
519 	vw_Draw2D(DstRect, SrcRect, GetSystemIcon(GetCurrentSustemStockNumBase()+2), true, MenuContentTransp*Current);
520 	Size = vw_TextWidth(vw_GetText(GetSystemName(GetCurrentSustemStockNumBase()+2)));
521 	WScale = 0;
522 	if (Size > 128) {
523 		Size = 128;
524 		WScale = -128;
525 	}
526 	vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::white}, MenuContentTransp*Current, vw_GetTextUTF32(GetSystemName(GetCurrentSustemStockNumBase()+2)));
527 
528 
529 
530 
531 	Current = 0.4f;
532 
533 	SrcRect(0,0,128,128);
534 	DstRect(GameConfig().InternalWidth/2-451, 610-128, GameConfig().InternalWidth/2-451+128, 610);
535 	if (vw_MouseOverRect(DstRect) && !isDialogBoxDrawing()) {
536 		if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) {
537 			PlayMenuSFX(eMenuSFX::OverBigButton, 1.0f);
538 			NeedPlayWorkshopOnButtonSoundX = DstRect.left;
539 			NeedPlayWorkshopOnButtonSoundY = DstRect.top;
540 		}
541 
542 		SetCursorStatus(eCursorStatus::ActionAllowed);
543 		if (vw_GetMouseLeftClick(true)) {
544 			CurrentSystemStockNum = GetCurrentSustemStockNumBase()+3;
545 			PlayMenuSFX(eMenuSFX::Click, 1.0f);
546 		}
547 
548 		Current = 0.7f;
549 	} else {
550 		if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) {
551 			NeedPlayWorkshopOnButtonSoundX = 0;
552 			NeedPlayWorkshopOnButtonSoundY = 0;
553 		}
554 	}
555 	if (CurrentSystemStockNum == GetCurrentSustemStockNumBase()+3) {
556 		Current = 1.0f;
557 	}
558 	vw_Draw2D(DstRect, SrcRect, GetSystemIcon(GetCurrentSustemStockNumBase()+3), true, MenuContentTransp*Current);
559 	Size = vw_TextWidth(vw_GetText(GetSystemName(GetCurrentSustemStockNumBase()+3)));
560 	WScale = 0;
561 	if (Size > 128) {
562 		Size = 128;
563 		WScale = -128;
564 	}
565 	vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::white}, MenuContentTransp*Current, vw_GetTextUTF32(GetSystemName(GetCurrentSustemStockNumBase()+3)));
566 
567 
568 
569 	vw_SetFontSize(24);
570 	vw_DrawTextUTF32(GameConfig().InternalWidth/2-475, 630, 0, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::white}, MenuContentTransp, vw_GetTextUTF32("System Stock"));
571 	ResetFontSize();
572 
573 
574 
575 
576 
577 
578 
579 
580 
581 
582 
583 
584 	SrcRect(0,0,210,600);
585 	DstRect(GameConfig().InternalWidth/2+282, 50-10, GameConfig().InternalWidth/2+492, 50+600-10);
586 	vw_Draw2D(DstRect, SrcRect, GetPreloadedTextureAsset("menu/workshop_panel2+.tga"), true, MenuContentTransp);
587 
588 
589 
590 	// проверяем, а все ли нормально с энергией... если не нормально, будем моргать и выведем соотв. надпись
591 	bool NeedMoreEnergy = false;
592 
593 	if (GameConfig().Profile[CurrentProfile].PowerSystem != 0) {
594 
595 		float Have = GetShipRechargeEnergy(GameConfig().Profile[CurrentProfile].PowerSystem);
596 
597 		float Need = 0.0f;
598 
599 		// если это не аркадный режим, нужно учитывать двигатель
600 		if ((GameConfig().Profile[CurrentProfile].SpaceShipControlMode != 1) &&
601 		    (GameConfig().Profile[CurrentProfile].EngineSystem != 0))
602 			Need += GetShipEngineSystemEnergyUse(GameConfig().Profile[CurrentProfile].EngineSystem);
603 		// если есть спец система, ее нужно тоже учитывать
604 		if (GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem != 0)
605 			Need += GetShipProtectionSystemEnergyUse(GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem);
606 
607 		// слабый реактор
608 		if (Need >= Have) NeedMoreEnergy = true;
609 
610 	} else {
611 		// у нас вообще нет реактора... караул!!!
612 		NeedMoreEnergy = true;
613 	}
614 
615 	// выводим информационную надпись + голосовое сообщение
616 	if (NeedMoreEnergy) {
617 		// запускаем голос...
618 		if (!vw_IsSoundAvailable(VoiceNeedMoreEnergy))
619 			VoiceNeedMoreEnergy = PlayVoicePhrase(eVoicePhrase::ReactorMalfunction, 1.0f);
620 
621 		// вывод текста
622 		int SizeI = (GameConfig().InternalWidth - vw_TextWidthUTF32(vw_GetTextUTF32("Warning! Low energy recharge rate!"))) / 2;
623 		vw_DrawTextUTF32(SizeI, 60, 0, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::red}, CurrentAlert3 * MenuContentTransp, vw_GetTextUTF32("Warning! Low energy recharge rate!"));
624 
625 		SizeI = (GameConfig().InternalWidth - vw_TextWidthUTF32(vw_GetTextUTF32("Could be problems with"))) / 2;
626 		vw_DrawTextUTF32(SizeI, 80, 0, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::red}, CurrentAlert3 * MenuContentTransp, vw_GetTextUTF32("Could be problems with"));
627 
628 		SizeI = (GameConfig().InternalWidth - vw_TextWidthUTF32(vw_GetTextUTF32("systems function and/or weapons recharge!"))) / 2;
629 		vw_DrawTextUTF32(SizeI, 100, 0, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::red}, CurrentAlert3 * MenuContentTransp, vw_GetTextUTF32("systems function and/or weapons recharge!"));
630 	}
631 
632 
633 
634 
635 	// сбор данных
636 	int Cost = 0;
637 	bool CanSell = false;
638 	bool CanBuy = true;
639 
640 	// Engine
641 	DstRect(GameConfig().InternalWidth/2+337, 70, GameConfig().InternalWidth/2+437, 70+100);
642 
643 	if ((CurrentSystemStockNum >= 1) && (CurrentSystemStockNum <= 4)) {
644 		if (GameConfig().Profile[CurrentProfile].EngineSystem != 0) {
645 			CanSell = true;
646 			Cost = GetSystemCost(GameConfig().Profile[CurrentProfile].EngineSystem);
647 			if (Cost + GameConfig().Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum))
648 				CanBuy = false;
649 		} else {
650 			if (GameConfig().Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum))
651 				CanBuy = false;
652 		}
653 	}
654 
655 
656 	// Power
657 	DstRect(GameConfig().InternalWidth/2+337, 180, GameConfig().InternalWidth/2+437, 180+100);
658 
659 	if ((CurrentSystemStockNum >= 5) && (CurrentSystemStockNum <= 8)) {
660 		if (GameConfig().Profile[CurrentProfile].PowerSystem != 0) {
661 			CanSell = true;
662 			Cost = GetSystemCost(GameConfig().Profile[CurrentProfile].PowerSystem + 4);
663 			if (Cost + GameConfig().Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum))
664 				CanBuy = false;
665 		} else {
666 			if (GameConfig().Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum))
667 				CanBuy = false;
668 		}
669 	}
670 
671 	// Target
672 	DstRect(GameConfig().InternalWidth/2+337, 290, GameConfig().InternalWidth/2+437, 290+100);
673 
674 	if ((CurrentSystemStockNum >= 9) && (CurrentSystemStockNum <= 12)) {
675 		if (GameConfig().Profile[CurrentProfile].TargetingSystem != 0) {
676 			CanSell = true;
677 			Cost = GetSystemCost(GameConfig().Profile[CurrentProfile].TargetingSystem+8);
678 			if (Cost + GameConfig().Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum))
679 				CanBuy = false;
680 		} else {
681 			if (GameConfig().Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum))
682 				CanBuy = false;
683 		}
684 	}
685 
686 
687 	// Mech
688 	DstRect(GameConfig().InternalWidth/2+337, 400, GameConfig().InternalWidth/2+437, 400+100);
689 	if ((CurrentSystemStockNum >= 13) && (CurrentSystemStockNum <= 16)) {
690 		if (GameConfig().Profile[CurrentProfile].TargetingMechanicSystem != 0) {
691 			CanSell = true;
692 			Cost = GetSystemCost(GameConfig().Profile[CurrentProfile].TargetingMechanicSystem + 12);
693 			if (Cost + GameConfig().Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum))
694 				CanBuy = false;
695 		} else {
696 			if (GameConfig().Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum))
697 				CanBuy = false;
698 		}
699 	}
700 
701 	// Protect
702 	DstRect(GameConfig().InternalWidth/2+337, 510, GameConfig().InternalWidth/2+437, 510+100);
703 	if ((CurrentSystemStockNum >= 17) && (CurrentSystemStockNum <= 20)) {
704 		if (GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem != 0) {
705 			CanSell = true;
706 			Cost = GetSystemCost(GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem+16);
707 			if (Cost + GameConfig().Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum))
708 				CanBuy = false;
709 		} else {
710 			if (GameConfig().Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum))
711 				CanBuy = false;
712 		}
713 	}
714 
715 
716 
717 	// прорисовка
718 
719 
720 	// Engine
721 	SrcRect(0,0,128,128);
722 	DstRect(GameConfig().InternalWidth/2+337, 70, GameConfig().InternalWidth/2+437, 70+100);
723 	Current = 0.5f;
724 	sRGBCOLOR tmpColor{sRGBCOLOR{eRGBCOLOR::white}};
725 
726 	if (NeedMoreEnergy &&
727 	    (GameConfig().Profile[CurrentProfile].EngineSystem != 0) &&
728 	    (GameConfig().Profile[CurrentProfile].SpaceShipControlMode != 1))
729 		tmpColor = sRGBCOLOR{eRGBCOLOR::red};
730 
731 
732 	if ((CurrentSystemStockNum >= 1) && (CurrentSystemStockNum <= 4)) {
733 		if (!NeedMoreEnergy ||
734 		    (GameConfig().Profile[CurrentProfile].EngineSystem == 0) ||
735 		    (GameConfig().Profile[CurrentProfile].SpaceShipControlMode == 1)) {
736 			if (CanBuy)
737 				tmpColor = sRGBCOLOR{0.0f, 0.8f, 0.0f};
738 			else
739 				tmpColor = sRGBCOLOR{eRGBCOLOR::orange};
740 		}
741 
742 		Current = 1.0f;
743 	}
744 
745 	if (vw_MouseOverRect(DstRect) && !isDialogBoxDrawing()) {
746 		if ((NeedPlayWorkshopOnButtonSoundX != DstRect.left) ||
747 		    (NeedPlayWorkshopOnButtonSoundY != DstRect.top)) {
748 			PlayMenuSFX(eMenuSFX::OverBigButton, 1.0f);
749 			NeedPlayWorkshopOnButtonSoundX = DstRect.left;
750 			NeedPlayWorkshopOnButtonSoundY = DstRect.top;
751 		}
752 
753 		Current = 1.0f;
754 		SetCursorStatus(eCursorStatus::ActionAllowed);
755 		if (vw_GetMouseLeftClick(true)) {
756 			CurrentSystemStockNum = 1;
757 			PlayMenuSFX(eMenuSFX::Click, 1.0f);
758 		}
759 	} else {
760 		if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) {
761 			NeedPlayWorkshopOnButtonSoundX = 0;
762 			NeedPlayWorkshopOnButtonSoundY = 0;
763 		}
764 	}
765 	if (GameConfig().Profile[CurrentProfile].EngineSystem <= 0) {
766 		vw_Draw2D(DstRect, SrcRect, GetSystemIcon(-4), true, Current*MenuContentTransp);
767 
768 		Size = vw_TextWidthUTF32(vw_GetTextUTF32("empty"));
769 		WScale = 0;
770 		if (Size > 128) {
771 			Size = 128;
772 			WScale = -128;
773 		}
774 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.top-4, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32("empty"));
775 
776 		Size = vw_TextWidthUTF32(vw_GetTextUTF32("Spaceship Engine"));
777 		WScale = 0;
778 		if (Size > 128) {
779 			Size = 128;
780 			WScale = -128;
781 		}
782 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32("Spaceship Engine"));
783 	} else {
784 		vw_Draw2D(DstRect, SrcRect, GetSystemIcon(GameConfig().Profile[CurrentProfile].EngineSystem), true, Current*MenuContentTransp);
785 
786 		Size = vw_TextWidthUTF32(vw_GetTextUTF32(GetSystemName(GameConfig().Profile[CurrentProfile].EngineSystem)));
787 		WScale = 0;
788 		if (Size > 128) {
789 			Size = 128;
790 			WScale = -128;
791 		}
792 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-70, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32(GetSystemName(GameConfig().Profile[CurrentProfile].EngineSystem)));
793 	}
794 
795 
796 	// Power
797 	DstRect(GameConfig().InternalWidth/2+337, 180, GameConfig().InternalWidth/2+437, 180+100);
798 	tmpColor = sRGBCOLOR{eRGBCOLOR::white};
799 
800 	if (NeedMoreEnergy)
801 		tmpColor = sRGBCOLOR{eRGBCOLOR::red};
802 
803 	Current = 0.5f;
804 	if ((CurrentSystemStockNum >= 5) && (CurrentSystemStockNum <= 8)) {
805 		if (!NeedMoreEnergy) {
806 			if (CanBuy)
807 				tmpColor = sRGBCOLOR{0.0f, 0.8f, 0.0f};
808 			else
809 				tmpColor = sRGBCOLOR{eRGBCOLOR::orange};
810 		}
811 		Current = 1.0f;
812 	}
813 
814 	if (vw_MouseOverRect(DstRect) && !isDialogBoxDrawing()) {
815 		if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) {
816 			PlayMenuSFX(eMenuSFX::OverBigButton, 1.0f);
817 			NeedPlayWorkshopOnButtonSoundX = DstRect.left;
818 			NeedPlayWorkshopOnButtonSoundY = DstRect.top;
819 		}
820 
821 		Current = 1.0f;
822 		SetCursorStatus(eCursorStatus::ActionAllowed);
823 		if (vw_GetMouseLeftClick(true)) {
824 			CurrentSystemStockNum = 5;
825 			PlayMenuSFX(eMenuSFX::Click, 1.0f);
826 		}
827 	} else {
828 		if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) {
829 			NeedPlayWorkshopOnButtonSoundX = 0;
830 			NeedPlayWorkshopOnButtonSoundY = 0;
831 		}
832 	}
833 
834 	if (GameConfig().Profile[CurrentProfile].PowerSystem <= 0) {
835 		vw_Draw2D(DstRect, SrcRect, GetSystemIcon(-2), true, Current*MenuContentTransp);
836 
837 		Size = vw_TextWidthUTF32(vw_GetTextUTF32("empty"));
838 		WScale = 0;
839 		if (Size > 128) {
840 			Size = 128;
841 			WScale = -128;
842 		}
843 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.top-4, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32("empty"));
844 
845 		Size = vw_TextWidthUTF32(vw_GetTextUTF32("Power Source"));
846 		WScale = 0;
847 		if (Size > 128) {
848 			Size = 128;
849 			WScale = -128;
850 		}
851 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32("Power Source"));
852 	} else {
853 		vw_Draw2D(DstRect, SrcRect, GetSystemIcon(GameConfig().Profile[CurrentProfile].PowerSystem + 4), true, Current * MenuContentTransp);
854 
855 		Size = vw_TextWidthUTF32(vw_GetTextUTF32(GetSystemName(GameConfig().Profile[CurrentProfile].PowerSystem + 4)));
856 		WScale = 0;
857 		if (Size > 128) {
858 			Size = 128;
859 			WScale = -128;
860 		}
861 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-70, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32(GetSystemName(GameConfig().Profile[CurrentProfile].PowerSystem + 4)));
862 	}
863 
864 
865 
866 	// Target
867 	DstRect(GameConfig().InternalWidth/2+337, 290, GameConfig().InternalWidth/2+437, 290+100);
868 	tmpColor = sRGBCOLOR{eRGBCOLOR::white};
869 
870 	Current = 0.5f;
871 	if ((CurrentSystemStockNum >= 9) && (CurrentSystemStockNum <= 12)) {
872 		if (CanBuy)
873 			tmpColor = sRGBCOLOR{0.0f, 0.8f, 0.0f};
874 		else
875 			tmpColor = sRGBCOLOR{eRGBCOLOR::orange};
876 
877 		Current = 1.0f;
878 	}
879 
880 	if (vw_MouseOverRect(DstRect) && !isDialogBoxDrawing()) {
881 		if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) {
882 			PlayMenuSFX(eMenuSFX::OverBigButton, 1.0f);
883 			NeedPlayWorkshopOnButtonSoundX = DstRect.left;
884 			NeedPlayWorkshopOnButtonSoundY = DstRect.top;
885 		}
886 
887 		Current = 1.0f;
888 		SetCursorStatus(eCursorStatus::ActionAllowed);
889 		if (vw_GetMouseLeftClick(true)) {
890 			CurrentSystemStockNum = 9;
891 			PlayMenuSFX(eMenuSFX::Click, 1.0f);
892 		}
893 	} else {
894 		if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) {
895 			NeedPlayWorkshopOnButtonSoundX = 0;
896 			NeedPlayWorkshopOnButtonSoundY = 0;
897 		}
898 	}
899 
900 	if (GameConfig().Profile[CurrentProfile].TargetingSystem <= 0) {
901 		vw_Draw2D(DstRect, SrcRect, GetSystemIcon(-1), true, Current*MenuContentTransp);
902 
903 		Size = vw_TextWidthUTF32(vw_GetTextUTF32("empty"));
904 		WScale = 0;
905 		if (Size > 128) {
906 			Size = 128;
907 			WScale = -128;
908 		}
909 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.top-4, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32("empty"));
910 
911 		Size = vw_TextWidthUTF32(vw_GetTextUTF32("Optical Computer"));
912 		WScale = 0;
913 		if (Size > 128) {
914 			Size = 128;
915 			WScale = -128;
916 		}
917 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32("Optical Computer"));
918 	} else {
919 		vw_Draw2D(DstRect, SrcRect, GetSystemIcon(GameConfig().Profile[CurrentProfile].TargetingSystem + 8), true, Current * MenuContentTransp);
920 
921 		Size = vw_TextWidthUTF32(vw_GetTextUTF32(GetSystemName(GameConfig().Profile[CurrentProfile].TargetingSystem + 8)));
922 		WScale = 0;
923 		if (Size > 128) {
924 			Size = 128;
925 			WScale = -128;
926 		}
927 		vw_DrawTextUTF32(DstRect.left+(DstRect.right - DstRect.left-Size) / 2, DstRect.bottom-70, WScale, 0, 1.0f, tmpColor, Current * MenuContentTransp, vw_GetTextUTF32(GetSystemName(GameConfig().Profile[CurrentProfile].TargetingSystem + 8)));
928 	}
929 
930 
931 
932 	// Mech
933 	DstRect(GameConfig().InternalWidth/2+337, 400, GameConfig().InternalWidth/2+437, 400+100);
934 	tmpColor = sRGBCOLOR{eRGBCOLOR::white};
935 
936 	Current = 0.5f;
937 	if ((CurrentSystemStockNum >= 13) && (CurrentSystemStockNum <= 16)) {
938 		if (CanBuy)
939 			tmpColor = sRGBCOLOR{0.0f, 0.8f, 0.0f};
940 		else
941 			tmpColor = sRGBCOLOR{eRGBCOLOR::orange};
942 
943 		Current = 1.0f;
944 	}
945 
946 	if (vw_MouseOverRect(DstRect) && !isDialogBoxDrawing()) {
947 		if ((NeedPlayWorkshopOnButtonSoundX != DstRect.left) ||
948 		    (NeedPlayWorkshopOnButtonSoundY != DstRect.top)) {
949 			PlayMenuSFX(eMenuSFX::OverBigButton, 1.0f);
950 			NeedPlayWorkshopOnButtonSoundX = DstRect.left;
951 			NeedPlayWorkshopOnButtonSoundY = DstRect.top;
952 		}
953 
954 		Current = 1.0f;
955 		SetCursorStatus(eCursorStatus::ActionAllowed);
956 		if (vw_GetMouseLeftClick(true)) {
957 			PlayMenuSFX(eMenuSFX::Click, 1.0f);
958 			CurrentSystemStockNum = 13;
959 		}
960 	} else {
961 		if ((NeedPlayWorkshopOnButtonSoundX == DstRect.left) &&
962 		    (NeedPlayWorkshopOnButtonSoundY == DstRect.top)) {
963 			NeedPlayWorkshopOnButtonSoundX = 0;
964 			NeedPlayWorkshopOnButtonSoundY = 0;
965 		}
966 	}
967 
968 	if (GameConfig().Profile[CurrentProfile].TargetingMechanicSystem <= 0) {
969 		vw_Draw2D(DstRect, SrcRect, GetSystemIcon(-3), true, Current*MenuContentTransp);
970 
971 		Size = vw_TextWidthUTF32(vw_GetTextUTF32("empty"));
972 		WScale = 0;
973 		if (Size > 128) {
974 			Size = 128;
975 			WScale = -128;
976 		}
977 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.top-4, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32("empty"));
978 
979 		Size = vw_TextWidthUTF32(vw_GetTextUTF32("Targeting System"));
980 		WScale = 0;
981 		if (Size > 128) {
982 			Size = 128;
983 			WScale = -128;
984 		}
985 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32("Targeting System"));
986 	} else {
987 		vw_Draw2D(DstRect, SrcRect, GetSystemIcon(GameConfig().Profile[CurrentProfile].TargetingMechanicSystem + 12), true, Current * MenuContentTransp);
988 
989 		Size = vw_TextWidthUTF32(vw_GetTextUTF32(GetSystemName(GameConfig().Profile[CurrentProfile].TargetingMechanicSystem + 12)));
990 		WScale = 0;
991 		if (Size > 128) {
992 			Size = 128;
993 			WScale = -128;
994 		}
995 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-70, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32(GetSystemName(GameConfig().Profile[CurrentProfile].TargetingMechanicSystem + 12)));
996 	}
997 
998 
999 
1000 	// Protect
1001 	DstRect(GameConfig().InternalWidth/2+337, 510, GameConfig().InternalWidth/2+437, 510+100);
1002 	tmpColor = sRGBCOLOR{eRGBCOLOR::white};
1003 
1004 	if (NeedMoreEnergy && (GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem != 0))
1005 		tmpColor = sRGBCOLOR{eRGBCOLOR::red};
1006 
1007 	Current = 0.5f;
1008 	if ((CurrentSystemStockNum >= 17) && (CurrentSystemStockNum <= 20)) {
1009 		if (!NeedMoreEnergy || (GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem == 0)) {
1010 			if (CanBuy)
1011 				tmpColor = sRGBCOLOR{0.0f, 0.8f, 0.0f};
1012 			else
1013 				tmpColor = sRGBCOLOR{eRGBCOLOR::orange};
1014 		}
1015 		Current = 1.0f;
1016 	}
1017 
1018 	if (vw_MouseOverRect(DstRect) && !isDialogBoxDrawing()) {
1019 		if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) {
1020 			PlayMenuSFX(eMenuSFX::OverBigButton, 1.0f);
1021 			NeedPlayWorkshopOnButtonSoundX = DstRect.left;
1022 			NeedPlayWorkshopOnButtonSoundY = DstRect.top;
1023 		}
1024 
1025 		Current = 1.0f;
1026 		SetCursorStatus(eCursorStatus::ActionAllowed);
1027 		if (vw_GetMouseLeftClick(true)) {
1028 			PlayMenuSFX(eMenuSFX::Click, 1.0f);
1029 			CurrentSystemStockNum = 17;
1030 		}
1031 	} else {
1032 		if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) {
1033 			NeedPlayWorkshopOnButtonSoundX = 0;
1034 			NeedPlayWorkshopOnButtonSoundY = 0;
1035 		}
1036 	}
1037 
1038 	if (GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem <= 0) {
1039 		vw_Draw2D(DstRect, SrcRect, GetSystemIcon(0), true, Current*MenuContentTransp);
1040 
1041 		Size = vw_TextWidthUTF32(vw_GetTextUTF32("empty"));
1042 		WScale = 0;
1043 		if (Size > 128) {
1044 			Size = 128;
1045 			WScale = -128;
1046 		}
1047 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.top-4, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32("empty"));
1048 
1049 		Size = vw_TextWidthUTF32(vw_GetTextUTF32("Advanced System"));
1050 		WScale = 0;
1051 		if (Size > 128) {
1052 			Size = 128;
1053 			WScale = -128;
1054 		}
1055 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32("Advanced System"));
1056 
1057 	} else {
1058 		vw_Draw2D(DstRect, SrcRect, GetSystemIcon(GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem + 16), true, Current*MenuContentTransp);
1059 
1060 		Size = vw_TextWidthUTF32(vw_GetTextUTF32(GetSystemName(GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem + 16)));
1061 		WScale = 0;
1062 		if (Size > 128) {
1063 			Size = 128;
1064 			WScale = -128;
1065 		}
1066 		vw_DrawTextUTF32(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-70, WScale, 0, 1.0f, tmpColor, Current*MenuContentTransp, vw_GetTextUTF32(GetSystemName(GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem + 16)));
1067 	}
1068 
1069 
1070 
1071 	vw_SetFontSize(24);
1072 	vw_DrawTextUTF32(GameConfig().InternalWidth/2+475-vw_TextWidthUTF32(vw_GetTextUTF32("Installed Systems")), 630, 0, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::white}, MenuContentTransp, vw_GetTextUTF32("Installed Systems"));
1073 	ResetFontSize();
1074 
1075 	// текущая система
1076 	vw_DrawTextUTF32(GameConfig().InternalWidth/2-250, 430, 0, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::yellow}, MenuContentTransp, vw_GetTextUTF32("Selected System"));
1077 	vw_DrawTextUTF32(GameConfig().InternalWidth/2+250-vw_TextWidthUTF32(vw_GetTextUTF32("Installed System")), 430, 0, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::yellow}, MenuContentTransp, vw_GetTextUTF32("Installed System"));
1078 
1079 	float tmpTransp{MenuContentTransp};
1080 	tmpColor = sRGBCOLOR{eRGBCOLOR::white};
1081 	std::ostringstream tmpStream;
1082 	tmpStream << std::fixed << std::setprecision(0)
1083 		  << vw_GetText("Cost") << ": " << GetSystemCost(CurrentSystemStockNum);
1084 	if (!CanBuy) {
1085 		tmpTransp = MenuContentTransp * CurrentAlert3;
1086 		tmpColor = sRGBCOLOR{eRGBCOLOR::orange};
1087 	}
1088 	vw_DrawText(GameConfig().InternalWidth/2-250, 485, 0, 0, 1.0f, tmpColor, tmpTransp, tmpStream.str());
1089 
1090 	tmpStream.clear();
1091 	tmpStream.str(std::string{});
1092 	tmpStream << vw_GetText("Cost") << ": " << Cost;
1093 	vw_DrawText(GameConfig().InternalWidth/2+250-vw_TextWidth(tmpStream.str()), 485, 0, 0, 1.0f, sRGBCOLOR{eRGBCOLOR::white}, MenuContentTransp, tmpStream.str());
1094 
1095 
1096 	if (DrawButton128_2(GameConfig().InternalWidth/2-250,580-55, vw_GetTextUTF32("Info"), MenuContentTransp, false)) {
1097 		SetCurrentDialogBox(eDialogBox::ShowSystemsInfo);
1098 		DialogSystem = CurrentSystemStockNum;
1099 	}
1100 
1101 	if (DrawButton128_2(GameConfig().InternalWidth/2+250-128, 580-55, vw_GetTextUTF32("Info"), MenuContentTransp, !CanSell)) {
1102 		SetCurrentDialogBox(eDialogBox::ShowSystemsInfo);
1103 
1104 		NeedMoreEnergyDialog = NeedMoreEnergy;
1105 
1106 		if ((CurrentSystemStockNum >= 1) && (CurrentSystemStockNum <= 4))
1107 			DialogSystem = GameConfig().Profile[CurrentProfile].EngineSystem;
1108 		if ((CurrentSystemStockNum >= 5) && (CurrentSystemStockNum <= 8))
1109 			DialogSystem = GameConfig().Profile[CurrentProfile].PowerSystem + 4;
1110 		if ((CurrentSystemStockNum >= 9) && (CurrentSystemStockNum <= 12))
1111 			DialogSystem = GameConfig().Profile[CurrentProfile].TargetingSystem + 8;
1112 		if ((CurrentSystemStockNum >= 13) && (CurrentSystemStockNum <= 16))
1113 			DialogSystem = GameConfig().Profile[CurrentProfile].TargetingMechanicSystem + 12;
1114 		if ((CurrentSystemStockNum >= 17) && (CurrentSystemStockNum <= 20))
1115 			DialogSystem = GameConfig().Profile[CurrentProfile].AdvancedProtectionSystem + 16;
1116 	}
1117 
1118 
1119 	if (DrawButton128_2(GameConfig().InternalWidth/2-250, 50+580-55, vw_GetTextUTF32("Buy"), MenuContentTransp, !CanBuy)) {
1120 		BuyCurrentSystem();
1121 	}
1122 	// покупка, если 2 раза кликнули на иконку текущей системы
1123 	DstRect(GameConfig().InternalWidth/2-451, 55+128+20, GameConfig().InternalWidth/2-451+128, 55+128+128+20);
1124 	if (vw_MouseOverRect(DstRect) && !isDialogBoxDrawing() && CanBuy && vw_GetMouseLeftDoubleClick(true))
1125 		BuyCurrentSystem();
1126 
1127 
1128 
1129 	if (DrawButton128_2(GameConfig().InternalWidth/2+250-128, 50+580-55, vw_GetTextUTF32("Sell"), MenuContentTransp, !CanSell))
1130 		SellCurrentSystem();
1131 
1132 
1133 	// вывод информации
1134 	vw_SetFontSize(20);
1135 
1136 	tmpTransp = MenuContentTransp;
1137 	tmpColor = sRGBCOLOR{eRGBCOLOR::yellow};
1138 	tmpStream.clear();
1139 	tmpStream.str(std::string{});
1140 	tmpStream << vw_GetText("Money") << ": "
1141 		  << GameConfig().Profile[CurrentProfile].Money;
1142 	int SizeI = (GameConfig().InternalWidth - vw_TextWidth(tmpStream.str())) / 2;
1143 	if (!CanBuy) {
1144 		tmpTransp = MenuContentTransp * CurrentAlert3;
1145 		tmpColor = sRGBCOLOR{eRGBCOLOR::orange};
1146 	}
1147 	vw_DrawText(SizeI, 630, 0, 0, 1.0f, tmpColor, tmpTransp, tmpStream.str());
1148 
1149 	ResetFontSize();
1150 }
1151 
1152 } // astromenace namespace
1153 } // viewizard namespace
1154