comparison GUI/UI/Books/TownPortalBook.cpp @ 2548:87e5590d034b

All Books windows are refactored into respective classes
author a.parshin
date Tue, 12 May 2015 03:24:19 +0200
parents
children 0c67be4ec900
comparison
equal deleted inserted replaced
2547:fed97f15d1e1 2548:87e5590d034b
1 #include "Engine/Engine.h"
2 #include "Engine/LOD.h"
3 #include "Engine/Party.h"
4 #include "Engine/texts.h"
5 #include "Engine/Graphics/IRender.h"
6
7 #include "GUI/GUIFont.h"
8 #include "GUI/UI/Books/TownPortalBook.h"
9
10 #include "IO/Mouse.h"
11
12 static int pTownPortalBook_xs[6] = { 260, 324, 147, 385, 390, 19 };
13 static int pTownPortalBook_ys[6] = { 206, 84, 182, 239, 17, 283 };
14 static int pTownPortalBook_ws[6] = { 80, 66, 68, 72, 67, 74 };
15 static int pTownPortalBook_hs[6] = { 55, 56, 65, 67, 67, 59 };
16
17 GUIWindow_TownPortalBook::GUIWindow_TownPortalBook(const char *a1) :
18 GUIWindow_Book()
19 {
20 this->Hint = a1; // inherited from GUIWindow::GUIWindow
21 this->ptr_1C = (void *)WINDOW_TownPortal; // inherited from GUIWindow::GUIWindow
22 BasicBookInitialization();
23
24 // ----------------------------------------------
25 // 00411BFC GUIWindow::InitializeBookView -- part
26 pTexture_CurrentBook = pIcons_LOD->LoadTexturePtr("townport", TEXTURE_16BIT_PALETTE);
27 pTexture_TownPortalIcons[0] = pIcons_LOD->LoadTexturePtr("tpharmndy", TEXTURE_16BIT_PALETTE);
28 pTexture_TownPortalIcons[1] = pIcons_LOD->LoadTexturePtr("tpelf", TEXTURE_16BIT_PALETTE);
29 pTexture_TownPortalIcons[2] = pIcons_LOD->LoadTexturePtr("tpwarlock", TEXTURE_16BIT_PALETTE);
30 pTexture_TownPortalIcons[3] = pIcons_LOD->LoadTexturePtr("tpisland", TEXTURE_16BIT_PALETTE);
31 pTexture_TownPortalIcons[4] = pIcons_LOD->LoadTexturePtr("tpheaven", TEXTURE_16BIT_PALETTE);
32 pTexture_TownPortalIcons[5] = pIcons_LOD->LoadTexturePtr("tphell", TEXTURE_16BIT_PALETTE);
33
34 for (uint i = 0; i < 6; ++i)
35 CreateButton(
36 pTownPortalBook_xs[i],
37 pTownPortalBook_ys[i],
38 pTownPortalBook_ws[i],
39 pTownPortalBook_hs[i],
40 1, 182, UIMSG_ClickTownInTP, i, 0, "", nullptr
41 );
42 }
43
44
45 void GUIWindow_TownPortalBook::Update()
46 {
47 // -----------------------------------
48 // 004156F0 GUI_UpdateWindows --- part
49 // {
50 // BookUI_Draw((WindowType)(int)ptr_1C);
51 // }
52
53 // ----- (00413CC6) --------------------------------------------------------
54 // void BookUI_Draw(WindowType book) --- part
55 // {
56 pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
57 // BookUI_DrawTownPortalMap();
58
59 // ----- (00411150) --------------------------------------------------------
60 // void BookUI_DrawTownPortalMap()
61 // {
62 int v3; // edi@17
63 GUIWindow TownPortalWindow; // [sp+Ch] [bp-64h]@1
64 POINT a2; // [sp+68h] [bp-8h]@17
65
66 pRenderer->ClearZBuffer(0, 479);
67 pRenderer->DrawTextureIndexedAlpha(8, 8, pTexture_CurrentBook);
68 pRenderer->DrawTextureIndexedAlpha(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
69
70 TownPortalWindow.uFrameX = game_viewport_x;
71 TownPortalWindow.uFrameY = game_viewport_y;
72 TownPortalWindow.uFrameWidth = game_viewport_width;
73 TownPortalWindow.uFrameHeight = game_viewport_height;
74 TownPortalWindow.uFrameZ = game_viewport_z;
75 TownPortalWindow.uFrameW = game_viewport_w;
76
77 const uint fountain_bits_lut[] =
78 {
79 PARTY_QUEST_FOUNTAIN_HARMONDALE,
80 PARTY_QUEST_FOUNTAIN_PIERPONT,
81 PARTY_QUEST_FOUNTAIN_NIGHON,
82 PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE,
83 PARTY_QUEST_FOUNTAIN_CELESTIA,
84 PARTY_QUEST_FOUNTAIN_THE_PIT
85 };
86 for (uint i = 0; i < 6; ++i)
87 {
88
89 if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[i]))
90 pRenderer->DrawMaskToZBuffer(
91 pTownPortalBook_xs[i],
92 pTownPortalBook_ys[i],
93 pTexture_TownPortalIcons[i], i + 1
94 );
95 }
96
97 pMouse->GetCursorPos(&a2);
98 v3 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF;
99
100 if (v3)
101 {
102 if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[v3 - 1]))
103 pRenderer->DrawTextureIndexed(pTownPortalBook_xs[v3 - 1], pTownPortalBook_ys[v3 - 1], pTexture_TownPortalIcons[v3 - 1]);
104 }
105 TownPortalWindow.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3);
106 }