World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Класс GUIWindow_Spellbook

#include <Spellbook.h>

+ Граф наследования:GUIWindow_Spellbook:
+ Граф связей класса GUIWindow_Spellbook:

Открытые члены

 GUIWindow_Spellbook ()
 
virtual ~GUIWindow_Spellbook ()
 
virtual void Update ()
 
virtual void Release ()
 
void OpenSpellbook ()
 
void OpenSpellbookPage (int page)
 
- Открытые члены унаследованные от GUIWindow
 GUIWindow ()
 
 GUIWindow (WindowType windowType, unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, int pButton, const String &hint=String())
 
virtual ~GUIWindow ()
 
GUIButtonCreateButton (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 * >())
 
bool Contains (unsigned int x, unsigned int y)
 
void DrawFlashingInputCursor (int uX, int uY, GUIFont *a2)
 
int DrawTextInRect (GUIFont *font, unsigned int x, unsigned int y, unsigned int color, const char *text, int rect_width, int reverse_text)
 
int DrawTextInRect (GUIFont *font, unsigned int x, unsigned int y, unsigned int color, String &str, int rect_width, int reverse_text)
 
void DrawText (GUIFont *font, int x, int y, unsigned short uFontColor, const char *str, bool present_time_transparency=false, int max_text_height=0, int uFontShadowColor=0)
 
void DrawText (GUIFont *font, int x, int y, unsigned short uFontColor, const String &str, bool present_time_transparency=false, int max_text_height=0, int uFontShadowColor=0)
 
void DrawTitleText (GUIFont *font, int horizontal_margin, int vertical_margin, unsigned __int16 uDefaultColor, const char *pInString, int line_spacing)
 
void DrawTitleText (GUIFont *font, int horizontal_margin, int vertical_margin, unsigned __int16 uDefaultColor, const String &str, int line_spacing)
 
void DrawShops_next_generation_time_string (GameTime time)
 
void HouseDialogManager ()
 
void DrawMessageBox (bool inside_game_viewport)
 
GUIButtonGetControl (unsigned int uID)
 
void _41D08F_set_keyboard_control_group (int num_buttons, int a3, int a4, int a5)
 
void _41D73D_draw_buff_tooltip ()
 
void DeleteButtons ()
 

Дополнительные унаследованные члены

- Открытые статические члены унаследованные от GUIWindow
static void InitializeGUI ()
 
- Открытые атрибуты унаследованные от GUIWindow
unsigned int uFrameX
 
unsigned int uFrameY
 
unsigned int uFrameWidth
 
unsigned int uFrameHeight
 
unsigned int uFrameZ
 
unsigned int uFrameW
 
WindowType eWindowType
 
union {
   void *   ptr_1C
 
   unsigned int   par1C
 
}; 
 
int field_24
 
int pNumPresenceButton
 
int pCurrentPosActiveItem
 
int field_30
 
int field_34
 
int pStartingPosActiveItem
 
int receives_keyboard_input_2
 
bool receives_keyboard_input
 
String sHint
 
std::vector< GUIButton * > vButtons
 
Mousemouse = nullptr
 
Loglog = nullptr
 

Подробное описание

См. определение в файле Spellbook.h строка 4

Конструктор(ы)

◆ GUIWindow_Spellbook()

GUIWindow_Spellbook::GUIWindow_Spellbook ( )

См. определение в файле Spellbook.cpp строка 53

54  : GUIWindow(WINDOW_SpellBook, 0, 0, window->GetWidth(), window->GetHeight(), 0) {
56  pEventTimer->Pause();
57 
59  OpenSpellbook();
60 
61  pAudioPlayer->PlaySound(SOUND_48, 0, 0, -1, 0, 0);
62  viewparams->field_48 = 1;
63 }

Перекрестные ссылки current_screen_type, ViewingParams::field_48, InitializeSpellBookTextures(), OpenSpellbook(), pAudioPlayer, Timer::Pause(), pEventTimer, AudioPlayer::PlaySound(), SCREEN_SPELL_BOOK, SOUND_48 и viewparams.

+ Граф вызовов:

◆ ~GUIWindow_Spellbook()

virtual GUIWindow_Spellbook::~GUIWindow_Spellbook ( )
inlinevirtual

См. определение в файле Spellbook.h строка 7

7 {}

Методы

◆ Update()

void GUIWindow_Spellbook::Update ( )
virtual

Переопределяет метод предка GUIWindow.

См. определение в файле Spellbook.cpp строка 154

154  {
155  auto player = pPlayers[uActiveCharacter];
156 
157  Image *pTexture; // edx@5
158  int v10; // eax@13
159  unsigned int pX_coord; // esi@18
160  unsigned int pY_coord; // edi@18
161 
162  static unsigned int texture_tab_coord1[9][2] = {
163  {406, 9}, {406, 46}, {406, 84}, {406, 121}, {407, 158},
164  {405, 196}, {405, 234}, {405, 272}, {405, 309}};
165 
166  static unsigned int texture_tab_coord0[9][2] = {
167  {415, 10}, {415, 46}, {415, 83}, {415, 121}, {415, 158},
168  {416, 196}, {416, 234}, {416, 271}, {416, 307}};
169 
171 
172  render->ClearZBuffer(0, 479);
173 
174  for (unsigned int i = 0; i < 9; i++) {
175  if (player->pActiveSkills[PLAYER_SKILL_FIRE + i] || engine->config->debug_all_magic) {
176  auto pPageTexture = ui_spellbook_school_tabs[i][0];
177  if (player->lastOpenedSpellbookPage == i) {
178  pPageTexture = ui_spellbook_school_tabs[i][1];
179  pX_coord = texture_tab_coord1[i][0];
180  pY_coord = texture_tab_coord1[i][1];
181  } else {
182  pPageTexture = ui_spellbook_school_tabs[i][0];
183  pX_coord = texture_tab_coord0[i][0];
184  pY_coord = texture_tab_coord0[i][1];
185  }
186  render->DrawTextureAlphaNew(pX_coord / 640.0f, pY_coord / 480.0f,
187  pPageTexture);
188 
189  PlayerSpellbookChapter *chapter =
190  &player->spellbook.pChapters[player->lastOpenedSpellbookPage];
191  for (unsigned int i = 0; i < 11; ++i) {
192  if (chapter->bIsSpellAvailable[i] || engine->config->debug_all_magic) {
193  // this should check if oplayer knows spell
194  if (SBPageSSpellsTextureList[i+1]) {
195  if (quick_spell_at_page == i+1)
196  pTexture = SBPageCSpellsTextureList[i+1];
197  else
198  pTexture = SBPageSSpellsTextureList[i+1];
199  if (pTexture) {
200  pX_coord =
202  pIconPos[player->lastOpenedSpellbookPage]
204  [player->lastOpenedSpellbookPage]
205  [i+1]]
206  .Xpos;
207  pY_coord =
209  pIconPos[player->lastOpenedSpellbookPage]
211  [player->lastOpenedSpellbookPage]
212  [i+1]]
213  .Ypos;
214 
215  render->DrawTextureAlphaNew(
216  pX_coord / 640.0f, pY_coord / 480.0f, pTexture);
217 
218  //
219 
220  render->ZDrawTextureAlpha(
221  pIconPos[player->lastOpenedSpellbookPage]
223  [player->lastOpenedSpellbookPage]
224  [i+1]]
225  .Xpos /
226  640.0f,
227  pIconPos[player->lastOpenedSpellbookPage]
229  [player->lastOpenedSpellbookPage]
230  [i+1]]
231  .Ypos /
232  480.0f,
233  pTexture, i+1);
234  }
235  }
236  }
237  }
238  }
239  }
240 
241  // if ((11 * player->lastOpenedSpellbookPage) || ((11 *
242  // player->lastOpenedSpellbookPage) + 11))//??? maybe structure need fix
243  //{
244 
245  // }
246 
247  Point pt = mouse->GetCursorPos();
248  if (pt.x < 640 && pt.y < 480) {
249  v10 = render->pActiveZBuffer[pt.x + pSRZBufferLineOffsets[pt.y]] & 0xFFFF;
250  if (v10) {
251  if (SBPageCSpellsTextureList[v10]) {
252  pX_coord =
254  pIconPos[player->lastOpenedSpellbookPage]
255  [pSpellbookSpellIndices[player->lastOpenedSpellbookPage]
256  [v10]]
257  .Xpos;
258  pY_coord =
260  pIconPos[player->lastOpenedSpellbookPage]
261  [pSpellbookSpellIndices[player->lastOpenedSpellbookPage]
262  [v10]]
263  .Ypos;
264 
265  render->DrawTextureAlphaNew(pX_coord / 640.0f, pY_coord / 480.0f,
267  }
268  }
269  }
270 }

Перекрестные ссылки PlayerSpellbookChapter::bIsSpellAvailable, BookUI_Spellbook_DrawCurrentSchoolBackground(), engine, Mouse::GetCursorPos(), GUIWindow::mouse, pIconPos, PLAYER_SKILL_FIRE, pPlayers, pSpellbookSpellIndices, pSRZBufferLineOffsets, pViewport, quick_spell_at_page, render, SBPageCSpellsTextureList, SBPageSSpellsTextureList, uActiveCharacter, ui_spellbook_school_tabs, Viewport::uViewportTL_X, Viewport::uViewportTL_Y, Point::x и Point::y.

+ Граф вызовов:

◆ Release()

void GUIWindow_Spellbook::Release ( )
virtual

Переопределяет метод предка GUIWindow.

См. определение в файле Spellbook.cpp строка 272

272  {
275 
277 }

Перекрестные ссылки OnCloseSpellBook(), OnCloseSpellBookPage() и GUIWindow::Release().

+ Граф вызовов:

◆ OpenSpellbook()

void GUIWindow_Spellbook::OpenSpellbook ( )

GUIButton *result; // eax@25

См. определение в файле Spellbook.cpp строка 72

72  {
73  Player *pPlayer; // edi@1
74  // GUIWindow *pWindow; // esi@1
75  // unsigned int v3; // ebp@1
76  int v4; // eax@3
78  int a2; // [sp+10h] [bp-8h]@1
79  // int v7; // [sp+14h] [bp-4h]@1
80 
81  pPlayer = pPlayers[uActiveCharacter];
82  // pWindow = this;
84  // v3 = 0;
85  a2 = 0;
86 
87  PlayerSpellbookChapter *chapter =
88  &pPlayer->spellbook.pChapters[pPlayer->lastOpenedSpellbookPage];
89  for (uint i = 0; i < 11; ++i) {
90  if (!chapter->bIsSpellAvailable[i] && !engine->config->debug_all_magic)
91  continue;
92 
93  v4 = pPlayer->lastOpenedSpellbookPage;
94  // v4 = (12 * pPlayer->lastOpenedSpellbookPage +
95  // pSpellbookSpellIndices[pPlayer->lastOpenedSpellbookPage][i + 1]);
97  pIconPos[v4][pSpellbookSpellIndices[v4][i + 1]].Xpos,
99  pIconPos[v4][pSpellbookSpellIndices[v4][i + 1]]
100  .Ypos, // dword_4E20D0
101  SBPageSSpellsTextureList[i + 1]->GetWidth(),
102  SBPageSSpellsTextureList[i + 1]->GetHeight(), 1, 79,
103  UIMSG_SelectSpell, i, 0, "");
104  ++a2;
105  // ++v3;
106  }
107  // while ( (signed int)v3 < 11 );
108 
109  CreateButton(0, 0, 0, 0, 1, 0, UIMSG_SpellBook_PressTab, 0, '\t', "");
110  if (a2) _41D08F_set_keyboard_control_group(a2, 0, 0, 0);
111 
112  if (pPlayer->pActiveSkills[PLAYER_SKILL_FIRE] || engine->config->debug_all_magic)
113  CreateButton(399, 10, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 0, 0,
115  if (pPlayer->pActiveSkills[PLAYER_SKILL_AIR] || engine->config->debug_all_magic)
116  CreateButton(399, 46, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 1, 0,
118  if (pPlayer->pActiveSkills[PLAYER_SKILL_WATER] || engine->config->debug_all_magic)
119  CreateButton(399, 83, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 2, 0,
121  if (pPlayer->pActiveSkills[PLAYER_SKILL_EARTH] || engine->config->debug_all_magic)
122  CreateButton(399, 121, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 3, 0,
124  if (pPlayer->pActiveSkills[PLAYER_SKILL_SPIRIT] || engine->config->debug_all_magic)
125  CreateButton(399, 158, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 4, 0,
127  if (pPlayer->pActiveSkills[PLAYER_SKILL_MIND] || engine->config->debug_all_magic)
128  CreateButton(400, 196, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 5, 0,
130  if (pPlayer->pActiveSkills[PLAYER_SKILL_BODY] || engine->config->debug_all_magic)
131  CreateButton(400, 234, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 6, 0,
133  if (pPlayer->pActiveSkills[PLAYER_SKILL_LIGHT] || engine->config->debug_all_magic)
134  CreateButton(400, 271, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 7, 0,
136  if (pPlayer->pActiveSkills[PLAYER_SKILL_DARK] || engine->config->debug_all_magic)
137  CreateButton(400, 307, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 8, 0,
139 
144  476, 450, 48, 32, 1, 78, UIMSG_ClickInstallRemoveQuickSpellBtn, 0, 0,
148  localization->GetString(79));
149  pBtn_CloseBook = CreateButton(561, 450, 48, 32, 1, 0, UIMSG_Escape, 0, 0,
150  localization->GetString(79),
151  {{ui_spellbook_btn_close_click}});
152 }

Перекрестные ссылки GUIWindow::_41D08F_set_keyboard_control_group(), PlayerSpellbookChapter::bIsSpellAvailable, GUIWindow::CreateButton(), engine, Image::GetHeight(), Localization::GetSpellSchoolName(), Localization::GetString(), Image::GetWidth(), Player::lastOpenedSpellbookPage, LoadSpellbook(), localization, Player::pActiveSkills, pBtn_CloseBook, pBtn_InstallRemoveSpell, PlayerSpells::pChapters, pIconPos, PLAYER_SKILL_AIR, PLAYER_SKILL_BODY, PLAYER_SKILL_DARK, PLAYER_SKILL_EARTH, PLAYER_SKILL_FIRE, PLAYER_SKILL_LIGHT, PLAYER_SKILL_MIND, PLAYER_SKILL_SPIRIT, PLAYER_SKILL_WATER, pPlayers, pSpellbookSpellIndices, pViewport, SBPageSSpellsTextureList, Player::spellbook, uActiveCharacter, ui_spellbook_btn_close, ui_spellbook_btn_quckspell, ui_spellbook_btn_quckspell_click, UIMSG_ClickInstallRemoveQuickSpellBtn, UIMSG_Escape, UIMSG_OpenSpellbookPage, UIMSG_SelectSpell, UIMSG_SpellBook_PressTab, Viewport::uViewportTL_X и Viewport::uViewportTL_Y.

Используется в GUIWindow_Spellbook() и OpenSpellbookPage().

+ Граф вызовов:
+ Граф вызова функции:

◆ OpenSpellbookPage()

void GUIWindow_Spellbook::OpenSpellbookPage ( int  page)

См. определение в файле Spellbook.cpp строка 65

65  {
67  pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = page;
68  OpenSpellbook();
69  pAudioPlayer->PlaySound((SoundID)(SOUND_TurnPageU + rand() % 2), 0, 0, -1, 0, 0);
70 }

Перекрестные ссылки OnCloseSpellBookPage(), OpenSpellbook(), pAudioPlayer, AudioPlayer::PlaySound(), pPlayers, SOUND_TurnPageU и uActiveCharacter.

+ Граф вызовов:

Объявления и описания членов классов находятся в файлах:
Player
Definition: Player.h:401
ViewingParams::field_48
int field_48
Definition: Viewport.h:75
Localization::GetString
const char * GetString(unsigned int index) const
Definition: Localization.cpp:13
UIMSG_Escape
@ UIMSG_Escape
Definition: GUIWindow.h:96
Image::GetHeight
unsigned int GetHeight()
Definition: Image.cpp:230
SOUND_TurnPageU
@ SOUND_TurnPageU
Definition: AudioPlayer.h:75
Mouse::GetCursorPos
Point GetCursorPos()
Definition: Mouse.cpp:108
Viewport::uViewportTL_Y
int uViewportTL_Y
Definition: Viewport.h:23
pSRZBufferLineOffsets
std::array< unsigned int, 480 > pSRZBufferLineOffsets
Definition: mm7_data.cpp:511
ui_spellbook_btn_quckspell
Image * ui_spellbook_btn_quckspell
Definition: Spellbook.cpp:42
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
pIconPos
std::array< std::array< struct SpellBookIconPos, 12 >, 9 > pIconPos
Definition: Spells.cpp:307
pBtn_CloseBook
GUIButton * pBtn_CloseBook
Definition: GUIButton.cpp:14
CURRENT_SCREEN::SCREEN_SPELL_BOOK
@ SCREEN_SPELL_BOOK
AudioPlayer::PlaySound
void PlaySound(SoundID eSoundID, int pid, unsigned int uNumRepeats, int x, int y, int a7)
Definition: AudioPlayer.cpp:195
engine
std::shared_ptr< Engine > engine
Definition: Engine.cpp:130
OnCloseSpellBookPage
void OnCloseSpellBookPage()
Definition: Spellbook.cpp:382
PLAYER_SKILL_EARTH
@ PLAYER_SKILL_EARTH
Definition: Player.h:186
GUIWindow::GUIWindow
GUIWindow()
Definition: GUIWindow.cpp:765
PLAYER_SKILL_MIND
@ PLAYER_SKILL_MIND
Definition: Player.h:188
localization
Localization * localization
Definition: Localization.cpp:11
Point::x
unsigned int x
Definition: Point.h:7
Player::lastOpenedSpellbookPage
char lastOpenedSpellbookPage
Definition: Player.h:773
GUIWindow::Release
virtual void Release()
Definition: GUIWindow.cpp:292
SBPageSSpellsTextureList
std::array< Image *, 12 > SBPageSSpellsTextureList
Definition: Spellbook.cpp:48
UIMSG_SpellBook_PressTab
@ UIMSG_SpellBook_PressTab
Definition: GUIWindow.h:37
Player::pActiveSkills
std::array< unsigned __int16, 37 > pActiveSkills
Definition: Player.h:711
pPlayers
NZIArray< struct Player *, 5 > pPlayers
Definition: Player.cpp:46
PLAYER_SKILL_FIRE
@ PLAYER_SKILL_FIRE
Definition: Player.h:183
current_screen_type
enum CURRENT_SCREEN current_screen_type
Definition: GUIWindow.cpp:83
GUIWindow_Spellbook::OpenSpellbook
void OpenSpellbook()
Definition: Spellbook.cpp:72
GUIWindow::_41D08F_set_keyboard_control_group
void _41D08F_set_keyboard_control_group(int num_buttons, int a3, int a4, int a5)
Definition: GUIWindow.cpp:273
PLAYER_SKILL_LIGHT
@ PLAYER_SKILL_LIGHT
Definition: Player.h:190
UIMSG_SelectSpell
@ UIMSG_SelectSpell
Definition: GUIWindow.h:71
Image::GetWidth
unsigned int GetWidth()
Definition: Image.cpp:217
PlayerSpellbookChapter::bIsSpellAvailable
std::array< char, 11 > bIsSpellAvailable
Definition: Player.h:284
Image
Definition: Image.h:19
PLAYER_SKILL_SPIRIT
@ PLAYER_SKILL_SPIRIT
Definition: Player.h:187
viewparams
struct ViewingParams * viewparams
Definition: mm7_data.cpp:22
quick_spell_at_page
int quick_spell_at_page
Definition: mm7_data.cpp:530
PlayerSpells::pChapters
std::array< PlayerSpellbookChapter, 9 > pChapters
Definition: Player.h:304
ui_spellbook_school_tabs
std::array< std::array< Image *, 2 >, 9 > ui_spellbook_school_tabs
Definition: Spellbook.cpp:51
Localization::GetSpellSchoolName
const char * GetSpellSchoolName(unsigned int index) const
Definition: Localization.h:27
PLAYER_SKILL_AIR
@ PLAYER_SKILL_AIR
Definition: Player.h:184
LoadSpellbook
void LoadSpellbook(unsigned int spell_school)
Definition: Spellbook.cpp:279
window
EGLSurface EGLNativeWindowType * window
Definition: SDL_egl.h:1580
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
PLAYER_SKILL_WATER
@ PLAYER_SKILL_WATER
Definition: Player.h:185
Timer::Pause
void Pause()
Definition: Time.cpp:19
pBtn_InstallRemoveSpell
GUIButton * pBtn_InstallRemoveSpell
Definition: GUIButton.cpp:15
PlayerSpellbookChapter
Definition: Player.h:283
pSpellbookSpellIndices
std::array< std::array< unsigned char, 12 >, 9 > pSpellbookSpellIndices
Definition: Spellbook.cpp:30
UIMSG_ClickInstallRemoveQuickSpellBtn
@ UIMSG_ClickInstallRemoveQuickSpellBtn
Definition: GUIWindow.h:73
pViewport
struct Viewport * pViewport
Definition: mm7_data.cpp:21
InitializeSpellBookTextures
void InitializeSpellBookTextures()
Definition: Spellbook.cpp:321
Point::y
unsigned int y
Definition: Point.h:8
SBPageCSpellsTextureList
std::array< Image *, 12 > SBPageCSpellsTextureList
Definition: Spellbook.cpp:47
GUIWindow::mouse
Mouse * mouse
Definition: GUIWindow.h:491
uint
unsigned int uint
Definition: MM7.h:4
BookUI_Spellbook_DrawCurrentSchoolBackground
static void BookUI_Spellbook_DrawCurrentSchoolBackground()
Definition: Spellbook.cpp:307
uActiveCharacter
unsigned int uActiveCharacter
Definition: mm7_data.cpp:555
ui_spellbook_btn_close
Image * ui_spellbook_btn_close
Definition: Spellbook.cpp:44
SoundID
SoundID
Definition: AudioPlayer.h:10
OnCloseSpellBook
void OnCloseSpellBook()
Definition: Spellbook.cpp:344
PLAYER_SKILL_DARK
@ PLAYER_SKILL_DARK
Definition: Player.h:191
PLAYER_SKILL_BODY
@ PLAYER_SKILL_BODY
Definition: Player.h:189
pAudioPlayer
AudioPlayer * pAudioPlayer
Definition: AudioPlayer.cpp:20
Point
Definition: Point.h:3
WINDOW_SpellBook
@ WINDOW_SpellBook
Definition: GUIWindow.h:303
ui_spellbook_btn_quckspell_click
Image * ui_spellbook_btn_quckspell_click
Definition: Spellbook.cpp:43
Viewport::uViewportTL_X
int uViewportTL_X
Definition: Viewport.h:22
pEventTimer
Timer * pEventTimer
Definition: Time.cpp:8
SOUND_48
@ SOUND_48
Definition: AudioPlayer.h:21
UIMSG_OpenSpellbookPage
@ UIMSG_OpenSpellbookPage
Definition: GUIWindow.h:72
Player::spellbook
PlayerSpells spellbook
Definition: Player.h:716
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52