World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Файл UISaveLoad.cpp

См. исходные тексты.

Функции

static void UI_DrawSaveLoad (bool save)
 
void MainMenuLoad_EventLoop ()
 
void MainMenuLoad_Loop ()
 

Переменные

Imagesaveload_ui_ls_saved = nullptr
 
Imagesaveload_ui_x_d = nullptr
 
Imagescrollstop = nullptr
 

Функции

◆ UI_DrawSaveLoad()

static void UI_DrawSaveLoad ( bool  save)
static

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

231  {
232  GUIWindow save_load_window;
233  unsigned int pSaveFiles;
234 
236  memset(&save_load_window, 0, 0x54);
237  save_load_window.uFrameX = pGUIWindow_CurrentMenu->uFrameX + 240;
238  save_load_window.uFrameWidth = 220;
239  save_load_window.uFrameY = (pGUIWindow_CurrentMenu->uFrameY - pFontSmallnum->GetHeight()) + 157;
240  save_load_window.uFrameZ = save_load_window.uFrameX + 219;
241  save_load_window.uFrameHeight = pFontSmallnum->GetHeight();
242  save_load_window.uFrameW = pFontSmallnum->GetHeight() + save_load_window.uFrameY - 1;
245  // Draw map name
247 
248  // Draw date
249  GameTime savegame_time = pSavegameHeader[uLoadGameUI_SelectedSlot].playing_time;
250  auto savegame_hour = savegame_time.GetHoursOfDay();
251 
252  save_load_window.uFrameY = pGUIWindow_CurrentMenu->uFrameY + 261;
253  int am;
254  if (savegame_hour >= 12) {
255  savegame_hour -= 12;
256  if (!savegame_hour) {
257  savegame_hour = 12;
258  }
259  am = 1;
260  } else {
261  am = 0;
262  }
263 
264  auto str = StringPrintf(
265  "%s %d:%02d %s\n%d %s %d",
266  localization->GetDayName(savegame_time.GetDaysOfWeek()),
267  savegame_hour,
268  savegame_time.GetMinutesFraction(),
269  localization->GetAmPm(am),
270  savegame_time.GetDaysOfMonth() + 1,
271  localization->GetMonthName(savegame_time.GetMonthsOfYear()),
272  savegame_time.GetYears() + game_starting_year);
273  save_load_window.DrawTitleText(pFontSmallnum, 0, 0, 0, str, 3);
274  }
275 
276  if (pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) {
279  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveGame, 0, 0);
280  } else {
281  if (pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED)
283  }
284 
287  220, 0, localization->GetString(135), 0, 0, 0); // Çàãðóçêà
291  304, 0, localization->GetString(165), 0, 0, 0); // Ïîæàëóéñòà, ïîæîæäèòå
292  } else {
293  if (save) {
294  pSaveFiles = MAX_SAVE_SLOTS;
295 
296  // ingame save scroll bar
297  float ypos3 = (float(pSaveListPosition) / (pSaveFiles - 7)) * 89.f;
298  render->DrawTextureAlphaNew(216 / 640.f, (217 + ypos3) / 480.f, scrollstop);
299  } else {
300  pSaveFiles = uNumSavegameFiles;
301 
302  // load scroll bar
303  float ypos = (float(pSaveListPosition) / (pSaveFiles - 7)) * 89.f;
304  render->DrawTextureAlphaNew((216+ pGUIWindow_CurrentMenu->uFrameX) / 640.f, (217 + pGUIWindow_CurrentMenu->uFrameY + ypos) / 480.f, scrollstop);
305  }
306 
307  int slot_Y = 199;
308  for (uint i = pSaveListPosition; i < pSaveFiles; ++i) {
309  if (slot_Y >= 346) {
310  break;
311  }
312  if (pGUIWindow_CurrentMenu->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS || i != uLoadGameUI_SelectedSlot) {
313  pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 27, slot_Y, i == uLoadGameUI_SelectedSlot ? Color16(0xFF, 0xFF, 0x64) : 0, pSavegameHeader[i].pName, 185, 0);
314  } else {
316  slot_Y, pFontSmallnum);
317  }
318  slot_Y += 21;
319  }
320  }
321 }

Перекрестные ссылки GUIFont::AlignText_Center(), Color16(), GUIWindow::DrawFlashingInputCursor(), GUIWindow::DrawText(), GUIWindow::DrawTextInRect(), GUIWindow::DrawTitleText(), game_starting_year, Localization::GetAmPm(), GetCurrentMenuID(), Localization::GetDayName(), GameTime::GetDaysOfMonth(), GameTime::GetDaysOfWeek(), GUIFont::GetHeight(), GameTime::GetHoursOfDay(), MapStats::GetMapInfo(), GameTime::GetMinutesFraction(), Localization::GetMonthName(), GameTime::GetMonthsOfYear(), Localization::GetString(), GameTime::GetYears(), localization, MAX_SAVE_SLOTS, MENU_LoadingProcInMainMenu, pFontSmallnum, pGUIWindow_CurrentMenu, MapStats::pInfos, pKeyActionMap, pMapStats, pMessageQueue_50CBD0, MapInfo::pName, KeyboardActionMapping::pPressedKeysBuffer, pSavegameHeader, pSavegameThumbnails, pSavegameUsedSlots, pSaveListPosition, GUIWindow::receives_keyboard_input_2, render, scrollstop, StringPrintf(), GUIWindow::uFrameHeight, GUIWindow::uFrameW, GUIWindow::uFrameWidth, GUIWindow::uFrameX, GUIWindow::uFrameY, GUIWindow::uFrameZ, UIMSG_SaveGame, uLoadGameUI_SelectedSlot и uNumSavegameFiles.

Используется в GUIWindow_Save::Update() и GUIWindow_Load::Update().

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

◆ MainMenuLoad_EventLoop()

void MainMenuLoad_EventLoop ( )

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

323  {
324  while (!pMessageQueue_50CBD0->Empty()) {
325  UIMessageType msg;
326  int param, param2;
327  pMessageQueue_50CBD0->PopMessage(&msg, &param, &param2);
328 
329  switch (msg) {
330  case UIMSG_LoadGame: {
332  break;
334  break;
335  }
336  case UIMSG_SelectLoadSlot: {
337  // main menu save/load wnd clicking on savegame lines
338  if (pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS)
339  pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE);
341  // load clicked line
342  int v26 = param + pSaveListPosition;
343  if (dword_6BE138 == v26) {
344  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveLoadBtn, 0, 0);
345  pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0);
346  }
348  dword_6BE138 = v26;
349  } else {
350  // typing in the line
354  }
355  break;
356  }
357  case UIMSG_SaveLoadBtn: {
359  break;
360  }
361  case UIMSG_DownArrow: {
363  if (pSaveListPosition > (param - 7))
364  pSaveListPosition = (param - 7);
365  // if (pSaveListPosition < 1)
366  // pSaveListPosition = 0;
368  break;
369  }
370  case UIMSG_ArrowUp: {
372  if (pSaveListPosition < 0)
373  pSaveListPosition = 0;
375  break;
376  }
377  case UIMSG_Cancel: {
379  break;
380  }
381  case UIMSG_Escape: {
382  viewparams->field_48 = 1;
383  // if (current_screen_type == SCREEN_LOADGAME)
384  {
385  // crt_deconstruct_ptr_6A0118();
386 
389  pEventTimer->Resume();
390  viewparams->bRedrawGameUI = true;
391  break;
392  }
393  break;
394  }
395  }
396  }
397 }

Перекрестные ссылки ViewingParams::bRedrawGameUI, current_screen_type, dword_6BE138, GUIMessageQueue::Empty(), KeyboardActionMapping::EnterText(), ViewingParams::field_48, MENU_LoadingProcInMainMenu, MENU_MAIN, pBtnArrowUp, pBtnCancel, pBtnDownArrow, pBtnLoadSlot, pEventTimer, pGUIWindow_CurrentMenu, pKeyActionMap, pMessageQueue_50CBD0, GUIMessageQueue::PopMessage(), KeyboardActionMapping::pPressedKeysBuffer, pSavegameHeader, pSavegameUsedSlots, pSaveListPosition, GUIWindow::receives_keyboard_input_2, Timer::Resume(), SCREEN_GAME, SCREEN_SAVEGAME, SetCurrentMenuID(), KeyboardActionMapping::SetWindowInputStatus(), GUIWindow::uFrameX, GUIWindow::uFrameY, UIMSG_ArrowUp, UIMSG_Cancel, UIMSG_DownArrow, UIMSG_Escape, UIMSG_LoadGame, UIMSG_SaveLoadBtn, UIMSG_SelectLoadSlot, uLoadGameUI_SelectedSlot, KeyboardActionMapping::uNumKeysPressed и viewparams.

Используется в MainMenuLoad_Loop().

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

◆ MainMenuLoad_Loop()

void MainMenuLoad_Loop ( )

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

399  {
402 
404  window->PeekMessageLoop();
405  if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) {
406  OS_WaitMessage();
407  continue;
408  }
409 
410  render->BeginScene();
413  render->Present();
414  }
415 
417  pGUIWindow_CurrentMenu = nullptr;
418 }

Перекрестные ссылки current_screen_type, dword_6BE364_game_settings_1, GetCurrentMenuID(), GUI_UpdateWindows(), MainMenuLoad_EventLoop(), MENU_SAVELOAD, OS_WaitMessage(), pGUIWindow_CurrentMenu, GUIWindow::Release(), render и SCREEN_LOADGAME.

Используется в Application::Game::Loop().

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

Переменные

◆ saveload_ui_ls_saved

Image* saveload_ui_ls_saved = nullptr

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

Используется в GUIWindow_Load::GUIWindow_Load() и GUIWindow_Save::GUIWindow_Save().

◆ saveload_ui_x_d

Image* saveload_ui_x_d = nullptr

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

Используется в GUIWindow_Load::GUIWindow_Load() и GUIWindow_Save::GUIWindow_Save().

◆ scrollstop

Image* scrollstop = nullptr

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

Используется в GUIWindow_Load::GUIWindow_Load(), GUIWindow_Save::GUIWindow_Save() и UI_DrawSaveLoad().

MENU_SAVELOAD
@ MENU_SAVELOAD
Definition: GUIWindow.h:254
OnButtonClick2
Definition: GUIWindow.h:523
uLoadGameUI_SelectedSlot
unsigned int uLoadGameUI_SelectedSlot
Definition: mm7_data.cpp:693
GUIWindow::DrawText
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)
Definition: GUIWindow.cpp:694
ViewingParams::field_48
int field_48
Definition: Viewport.h:75
GUIWindow::uFrameW
unsigned int uFrameW
Definition: GUIWindow.h:473
KeyboardActionMapping::EnterText
void EnterText(int a2, int max_string_len, GUIWindow *pWindow)
Definition: Keyboard.cpp:181
UIMessageType
UIMessageType
Definition: GUIWindow.h:13
GUIMessageQueue::Empty
bool Empty()
Definition: GUIWindow.h:659
Localization::GetString
const char * GetString(unsigned int index) const
Definition: Localization.cpp:13
UIMSG_Escape
@ UIMSG_Escape
Definition: GUIWindow.h:96
pBtnArrowUp
GUIButton * pBtnArrowUp
Definition: GUIButton.cpp:86
MapStats::pInfos
MapInfo pInfos[77]
Definition: MapInfo.h:79
GUIWindow_Load
Definition: UISaveLoad.h:21
GUIWindow
Definition: GUIWindow.h:433
Timer::Resume
void Resume()
Definition: Time.cpp:27
pBtnCancel
GUIButton * pBtnCancel
Definition: GUIButton.cpp:87
pGUIWindow_CurrentMenu
GUIWindow * pGUIWindow_CurrentMenu
Definition: GUIWindow.cpp:54
SetCurrentMenuID
void SetCurrentMenuID(MENU_STATE uMenu)
Definition: GUIWindow.cpp:128
MapStats::GetMapInfo
MAP_TYPE GetMapInfo(const String &Str2)
Definition: MapInfo.cpp:225
GameTime::GetDaysOfWeek
int GetDaysOfWeek() const
Definition: Time.h:40
GameTime::GetDaysOfMonth
int GetDaysOfMonth() const
Definition: Time.h:41
UIMSG_SaveGame
@ UIMSG_SaveGame
Definition: GUIWindow.h:68
game_starting_year
int game_starting_year
Definition: mm7_data.cpp:193
localization
Localization * localization
Definition: Localization.cpp:11
MENU_MAIN
@ MENU_MAIN
Definition: GUIWindow.h:251
scrollstop
Image * scrollstop
Definition: UISaveLoad.cpp:33
pSavegameUsedSlots
std::array< unsigned int, MAX_SAVE_SLOTS > pSavegameUsedSlots
Definition: SaveLoad.cpp:43
uNumSavegameFiles
unsigned int uNumSavegameFiles
Definition: SaveLoad.cpp:42
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
GUIWindow::Release
virtual void Release()
Definition: GUIWindow.cpp:292
GUIFont::GetHeight
unsigned int GetHeight() const
Definition: GUIFont.cpp:84
GameTime::GetYears
int GetYears() const
Definition: Time.h:35
GUIWindow::uFrameWidth
unsigned int uFrameWidth
Definition: GUIWindow.h:470
GUIWindow::receives_keyboard_input_2
int receives_keyboard_input_2
Definition: GUIWindow.h:486
GUIWindow::uFrameZ
unsigned int uFrameZ
Definition: GUIWindow.h:472
current_screen_type
enum CURRENT_SCREEN current_screen_type
Definition: GUIWindow.cpp:83
pMapStats
struct MapStats * pMapStats
Definition: mm7_data.cpp:20
GameTime::GetMinutesFraction
int GetMinutesFraction() const
Definition: Time.h:38
OnSaveLoad
Definition: GUIWindow.h:558
GetCurrentMenuID
MENU_STATE GetCurrentMenuID()
Definition: GUIWindow.cpp:133
UIMSG_DownArrow
@ UIMSG_DownArrow
Definition: GUIWindow.h:130
OnCancel3
Definition: GUIWindow.h:588
GUIWindow::DrawTextInRect
int DrawTextInRect(GUIFont *font, unsigned int x, unsigned int y, unsigned int color, const char *text, int rect_width, int reverse_text)
Definition: GUIWindow.cpp:702
UIMSG_ArrowUp
@ UIMSG_ArrowUp
Definition: GUIWindow.h:129
GUIFont::AlignText_Center
unsigned int AlignText_Center(unsigned int width, const String &str)
Definition: GUIFont.cpp:306
CURRENT_SCREEN::SCREEN_LOADGAME
@ SCREEN_LOADGAME
param
GLfloat param
Definition: SDL_opengl_glext.h:373
viewparams
struct ViewingParams * viewparams
Definition: mm7_data.cpp:22
GUIWindow::uFrameHeight
unsigned int uFrameHeight
Definition: GUIWindow.h:471
KeyboardActionMapping::pPressedKeysBuffer
char pPressedKeysBuffer[257]
Definition: Keyboard.h:66
CURRENT_SCREEN::SCREEN_SAVEGAME
@ SCREEN_SAVEGAME
pSavegameThumbnails
std::array< Image *, MAX_SAVE_SLOTS > pSavegameThumbnails
Definition: SaveLoad.cpp:44
MainMenuLoad_EventLoop
void MainMenuLoad_EventLoop()
Definition: UISaveLoad.cpp:323
pSaveListPosition
int pSaveListPosition
Definition: mm7_data.cpp:692
window
EGLSurface EGLNativeWindowType * window
Definition: SDL_egl.h:1580
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
GameTime::GetHoursOfDay
int GetHoursOfDay() const
Definition: Time.h:39
GUI_UpdateWindows
void GUI_UpdateWindows()
Definition: GUIWindow.cpp:956
MapInfo::pName
String pName
Definition: MapInfo.h:38
UIMSG_SaveLoadBtn
@ UIMSG_SaveLoadBtn
Definition: GUIWindow.h:131
GUIMessageQueue::PopMessage
void PopMessage(UIMessageType *pMsg, int *pParam, int *a4)
Definition: GUIWindow.cpp:174
UIMSG_Cancel
@ UIMSG_Cancel
Definition: GUIWindow.h:133
KeyboardActionMapping::SetWindowInputStatus
void SetWindowInputStatus(int a2)
Definition: Keyboard.cpp:195
Localization::GetAmPm
const char * GetAmPm(unsigned int index) const
Definition: Localization.h:79
GUIWindow::uFrameY
unsigned int uFrameY
Definition: GUIWindow.h:469
GUIWindow::DrawFlashingInputCursor
void DrawFlashingInputCursor(int uX, int uY, GUIFont *a2)
Definition: GUIWindow.cpp:759
pBtnLoadSlot
GUIButton * pBtnLoadSlot
Definition: GUIButton.cpp:88
UIMSG_LoadGame
@ UIMSG_LoadGame
Definition: GUIWindow.h:67
pBtnDownArrow
GUIButton * pBtnDownArrow
Definition: GUIButton.cpp:85
MAX_SAVE_SLOTS
constexpr unsigned int MAX_SAVE_SLOTS
Definition: SaveLoad.h:33
GameTime::GetMonthsOfYear
int GetMonthsOfYear() const
Definition: Time.h:43
MENU_LoadingProcInMainMenu
@ MENU_LoadingProcInMainMenu
Definition: GUIWindow.h:260
CURRENT_SCREEN::SCREEN_GAME
@ SCREEN_GAME
Localization::GetMonthName
const char * GetMonthName(unsigned int index) const
Definition: Localization.h:19
pKeyActionMap
struct KeyboardActionMapping * pKeyActionMap
Definition: Keyboard.cpp:35
UIMSG_SelectLoadSlot
@ UIMSG_SelectLoadSlot
Definition: GUIWindow.h:132
uint
unsigned int uint
Definition: MM7.h:4
ViewingParams::bRedrawGameUI
int bRedrawGameUI
Definition: Viewport.h:74
dword_6BE364_game_settings_1
int dword_6BE364_game_settings_1
Definition: mm7_data.cpp:714
Localization::GetDayName
const char * GetDayName(unsigned int index) const
Definition: Localization.h:15
GUIWindow::uFrameX
unsigned int uFrameX
Definition: GUIWindow.h:468
KeyboardActionMapping::uNumKeysPressed
uint8_t uNumKeysPressed
Definition: Keyboard.h:67
dword_6BE138
int dword_6BE138
Definition: mm7_data.cpp:704
pMessageQueue_50CBD0
struct GUIMessageQueue * pMessageQueue_50CBD0
Definition: GUIWindow.cpp:86
Color16
uint16_t Color16(uint32_t r, uint32_t g, uint32_t b)
Definition: Engine.cpp:148
StringPrintf
String StringPrintf(const char *fmt,...)
Definition: Strings.cpp:9
pEventTimer
Timer * pEventTimer
Definition: Time.cpp:8
GameTime
Definition: Time.h:14
OS_WaitMessage
void OS_WaitMessage()
Definition: Lin.cpp:32
pFontSmallnum
GUIFont * pFontSmallnum
Definition: GUIFont.cpp:25
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52
pSavegameHeader
std::array< SavegameHeader, MAX_SAVE_SLOTS > pSavegameHeader
Definition: SaveLoad.cpp:45