World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
TownPortalBook.cpp
См. документацию.
1 #include "Engine/AssetsManager.h"
2 #include "Engine/Engine.h"
4 #include "Engine/LOD.h"
5 #include "Engine/Localization.h"
6 #include "Engine/Party.h"
7 
8 #include "GUI/GUIFont.h"
10 
11 #include "IO/Mouse.h"
12 
13 static int pTownPortalBook_xs[6] = {260, 324, 147, 385, 390, 19};
14 static int pTownPortalBook_ys[6] = {206, 84, 182, 239, 17, 283};
15 static int pTownPortalBook_ws[6] = {80, 66, 68, 72, 67, 74};
16 static int pTownPortalBook_hs[6] = {55, 56, 65, 67, 67, 59};
17 
18 static std::array<Image *, 6>
19  ui_book_townportal_icons; // [0]Harmonale, [1]Pierpont, [2]Nighon,
20  // [3]Evenmorn Island, [4]Celestia, [5]The Pit
21 
23 
25  : GUIWindow_Book() {
26  // this->sHint = a1; // inherited from GUIWindow::GUIWindow
27  this->ptr_1C =
28  (void *)WINDOW_TownPortal; // inherited from GUIWindow::GUIWindow
30 
31  // ----------------------------------------------
32  // 00411BFC GUIWindow::InitializeBookView -- part
33  ui_book_townportal_background = assets->GetImage_Solid("townport");
34 
35  ui_book_townportal_icons[0] = assets->GetImage_ColorKey("tpharmndy", 0x7FF);
37  ui_book_townportal_icons[2] = assets->GetImage_ColorKey("tpwarlock", 0x7FF);
38  ui_book_townportal_icons[3] = assets->GetImage_ColorKey("tpisland", 0x7FF);
39  ui_book_townportal_icons[4] = assets->GetImage_ColorKey("tpheaven", 0x7FF);
40  ui_book_townportal_icons[5] = assets->GetImage_ColorKey("tphell", 0x7FF);
41 
42  for (uint i = 0; i < 6; ++i)
45  UIMSG_ClickTownInTP, i, 0, "");
46 }
47 
49  // -----------------------------------
50  // 004156F0 GUI_UpdateWindows --- part
51  // {
52  // BookUI_Draw((WindowType)(int)ptr_1C);
53  // }
54 
55  // ----- (00413CC6) --------------------------------------------------------
56  // void BookUI_Draw(WindowType book) --- part
57  // {
58  render->DrawTextureAlphaNew(471 / 640.0f, 445 / 480.0f,
60  // BookUI_DrawTownPortalMap();
61 
62  // ----- (00411150) --------------------------------------------------------
63  // void BookUI_DrawTownPortalMap()
64  // {
65  int v3; // edi@17
66  GUIWindow TownPortalWindow; // [sp+Ch] [bp-64h]@1
67 
68  render->ClearZBuffer(0, 479);
69  render->DrawTextureNew(8 / 640.0f, 8 / 480.0f,
71  render->DrawTextureAlphaNew(471 / 640.0f, 445 / 480.0f,
73 
74  TownPortalWindow.uFrameX = game_viewport_x;
75  TownPortalWindow.uFrameY = game_viewport_y;
76  TownPortalWindow.uFrameWidth = game_viewport_width;
77  TownPortalWindow.uFrameHeight = game_viewport_height;
78  TownPortalWindow.uFrameZ = game_viewport_z;
79  TownPortalWindow.uFrameW = game_viewport_w;
80 
81  const uint fountain_bits_lut[] = {
85  for (uint i = 0; i < 6; ++i) {
86  if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[i]) || engine->config->debug_town_portal)
87  render->ZDrawTextureAlpha(pTownPortalBook_xs[i] / 640.0f,
88  pTownPortalBook_ys[i] / 480.0f,
89  ui_book_townportal_icons[i], i + 1);
90  }
91 
92  Point pt = mouse->GetCursorPos();
93  v3 = render->pActiveZBuffer[pt.x + pSRZBufferLineOffsets[pt.y]] & 0xFFFF;
94 
95  if (v3) {
96  if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[v3 - 1]) || engine->config->debug_town_portal)
97  render->DrawTextureAlphaNew(pTownPortalBook_xs[v3 - 1] / 640.0f,
98  pTownPortalBook_ys[v3 - 1] / 480.0f,
100  }
101  TownPortalWindow.DrawTitleText(pBook2Font, 0, 22, 0,
102  localization->GetString(10), 3);
103 }
GUIWindow::uFrameW
unsigned int uFrameW
Definition: GUIWindow.h:473
PARTY_QUEST_FOUNTAIN_NIGHON
@ PARTY_QUEST_FOUNTAIN_NIGHON
Definition: Party.h:47
Localization::GetString
const char * GetString(unsigned int index) const
Definition: Localization.cpp:13
UIMSG_ClickTownInTP
@ UIMSG_ClickTownInTP
Definition: GUIWindow.h:150
LOD.h
Mouse::GetCursorPos
Point GetCursorPos()
Definition: Mouse.cpp:108
GUIWindow
Definition: GUIWindow.h:433
AssetsManager::GetImage_Solid
Texture * GetImage_Solid(const String &name)
Definition: AssetsManager.cpp:51
ui_exit_cancel_button_background
Image * ui_exit_cancel_button_background
Definition: GUIWindow.cpp:89
ui_book_townportal_background
Image * ui_book_townportal_background
Definition: TownPortalBook.cpp:22
pSRZBufferLineOffsets
std::array< unsigned int, 480 > pSRZBufferLineOffsets
Definition: mm7_data.cpp:511
_449B57_test_bit
bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2)
Definition: Party.cpp:1185
GUIWindow::CreateButton
GUIButton * CreateButton(int x, int y, int width, int height, int a6, int a7, UIMessageType msg, unsigned int msg_param, uint8_t hotkey, const String &label, const std::vector< Image * > &textures=std::vector< Image * >())
Definition: GUIWindow.cpp:717
TownPortalBook.h
engine
std::shared_ptr< Engine > engine
Definition: Engine.cpp:130
game_viewport_width
unsigned int game_viewport_width
Definition: mm7_data.cpp:194
pTownPortalBook_ws
static int pTownPortalBook_ws[6]
Definition: TownPortalBook.cpp:15
pTownPortalBook_hs
static int pTownPortalBook_hs[6]
Definition: TownPortalBook.cpp:16
Party::_quest_bits
unsigned __int8 _quest_bits[64]
Definition: Party.h:291
localization
Localization * localization
Definition: Localization.cpp:11
game_viewport_x
int game_viewport_x
Definition: mm7_data.cpp:196
Point::x
unsigned int x
Definition: Point.h:7
GUIWindow_TownPortalBook::GUIWindow_TownPortalBook
GUIWindow_TownPortalBook()
Definition: TownPortalBook.cpp:24
PARTY_QUEST_FOUNTAIN_THE_PIT
@ PARTY_QUEST_FOUNTAIN_THE_PIT
Definition: Party.h:50
GUIWindow::DrawTitleText
void DrawTitleText(GUIFont *font, int horizontal_margin, int vertical_margin, unsigned __int16 uDefaultColor, const char *pInString, int line_spacing)
Definition: GUIWindow.cpp:665
GUIFont.h
AssetsManager.h
GUIWindow::uFrameWidth
unsigned int uFrameWidth
Definition: GUIWindow.h:470
game_viewport_height
unsigned int game_viewport_height
Definition: mm7_data.cpp:195
GUIWindow::uFrameZ
unsigned int uFrameZ
Definition: GUIWindow.h:472
Engine.h
PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE
@ PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE
Definition: Party.h:51
GUIWindow_TownPortalBook::Update
virtual void Update()
Definition: TownPortalBook.cpp:48
game_viewport_y
int game_viewport_y
Definition: mm7_data.cpp:197
Localization.h
pParty
Party * pParty
Definition: Party.cpp:30
Image
Definition: Image.h:19
IRender.h
AssetsManager::GetImage_ColorKey
Texture * GetImage_ColorKey(const String &name, uint16_t colorkey)
Definition: AssetsManager.cpp:34
GUIWindow::uFrameHeight
unsigned int uFrameHeight
Definition: GUIWindow.h:471
pBook2Font
GUIFont * pBook2Font
Definition: GUIFont.cpp:20
Party.h
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
pTownPortalBook_ys
static int pTownPortalBook_ys[6]
Definition: TownPortalBook.cpp:14
GUIWindow::uFrameY
unsigned int uFrameY
Definition: GUIWindow.h:469
game_viewport_w
int game_viewport_w
Definition: mm7_data.cpp:199
Point::y
unsigned int y
Definition: Point.h:8
GUIWindow_Book
Definition: UIBooks.h:4
GUIWindow_Book::BasicBookInitialization
void BasicBookInitialization()
Definition: UIBooks.cpp:67
WINDOW_TownPortal
@ WINDOW_TownPortal
Definition: GUIWindow.h:335
PARTY_QUEST_FOUNTAIN_CELESTIA
@ PARTY_QUEST_FOUNTAIN_CELESTIA
Definition: Party.h:49
GUIWindow::mouse
Mouse * mouse
Definition: GUIWindow.h:491
assets
AssetsManager * assets
Definition: AssetsManager.cpp:12
uint
unsigned int uint
Definition: MM7.h:4
v3
GLfloat GLfloat GLfloat GLfloat v3
Definition: SDL_opengl_glext.h:696
pTownPortalBook_xs
static int pTownPortalBook_xs[6]
Definition: TownPortalBook.cpp:13
GUIWindow::ptr_1C
void * ptr_1C
Definition: GUIWindow.h:476
GUIWindow::uFrameX
unsigned int uFrameX
Definition: GUIWindow.h:468
Point
Definition: Point.h:3
PARTY_QUEST_FOUNTAIN_PIERPONT
@ PARTY_QUEST_FOUNTAIN_PIERPONT
Definition: Party.h:48
ui_book_townportal_icons
static std::array< Image *, 6 > ui_book_townportal_icons
Definition: TownPortalBook.cpp:19
game_viewport_z
int game_viewport_z
Definition: mm7_data.cpp:198
PARTY_QUEST_FOUNTAIN_HARMONDALE
@ PARTY_QUEST_FOUNTAIN_HARMONDALE
Definition: Party.h:46
Mouse.h
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52