World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
UICredits.cpp
См. документацию.
1 #include "GUI/UI/UICredits.h"
2 
3 #include <cstdint>
4 #include <sstream>
5 
7 #include "Engine/LOD.h"
8 #include "GUI/GUIFont.h"
9 #include "GUI/GUIWindow.h"
10 #include "GUI/UI/UIMainMenu.h"
12 #include "Platform/Api.h"
13 #include "Platform/OSWindow.h"
14 
16  GUIWindow(WINDOW_Credits, 0, 0, window->GetWidth(), window->GetHeight(), 0) {
17  pFontQuick = GUIFont::LoadFont("quick.fnt", "FONTPAL", NULL);
18  pFontCChar = GUIFont::LoadFont("cchar.fnt", "FONTPAL", NULL);
19 
20  mm6title = assets->GetImage_PCXFromIconsLOD("mm6title.pcx");
21 
22  char *text = (char *)pEvents_LOD->LoadCompressedTexture("credits.txt");
23 
24  GUIWindow credit_window;
25  credit_window.uFrameWidth = 250;
26  credit_window.uFrameHeight = 440;
27  credit_window.uFrameX = 389;
28  credit_window.uFrameY = 19;
29 
30  width = 250;
31  height = pFontQuick->GetStringHeight2(pFontCChar, text, &credit_window, 0, 1) + 2 * credit_window.uFrameHeight;
32  // cred_texture = Image::Create(width, height, IMAGE_FORMAT_A8R8G8B8);
33  cred_texture = render->CreateTexture_Blank(width, height, IMAGE_FORMAT_A8R8G8B8);
34 
35  // дать шрифт и цвета тексту
37  Color16(0x70u, 0x8Fu, 0xFEu), Color16(0xECu, 0xE6u, 0x9Cu),
38  text, cred_texture);
39 
40  render->Update_Texture(cred_texture);
41  free(text);
42 
43  move_Y = 0;
44  tick = 0;
45 
46  CreateButton(0, 0, 0, 0, 1, 0, UIMSG_Escape, 0, 27, "");
47 }
48 
51  mm6title->Release();
53 }
54 
56  GUIWindow credit_window;
57  credit_window.uFrameWidth = 250;
58  credit_window.uFrameHeight = 440;
59  credit_window.uFrameX = 389;
60  credit_window.uFrameY = 19;
61 
62  render->DrawTextureNew(0, 0, mm6title);
63  render->SetUIClipRect(credit_window.uFrameX, credit_window.uFrameY,
64  credit_window.uFrameX + credit_window.uFrameWidth,
65  credit_window.uFrameY + credit_window.uFrameHeight);
66  render->DrawTextureOffset(credit_window.uFrameX, credit_window.uFrameY, 0, move_Y, cred_texture);
67  render->ResetUIClipRect();
68  tick++;
69  if (tick == 4) {
70  tick = 0;
71  ++move_Y;
72  }
73  if (move_Y >= cred_texture->GetHeight()) {
75  }
76 }
77 
79  while (!pMessageQueue_50CBD0->Empty()) {
80  UIMessageType pUIMessageType;
81  int pParam;
82  int param2;
83  pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &pParam, &param2);
84 
85  switch (pUIMessageType) { // For buttons of window MainMenu
86  case UIMSG_Escape:
88  break;
89  default:
90  break;
91  }
92  }
93 }
94 
97 
99 
100  GUICredits *pWindow_Credits = new GUICredits();
103 
104  while (GetCurrentMenuID() == MENU_CREDITSPROC) {
105  window->PeekMessageLoop();
106  if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) {
107  OS_WaitMessage();
108  continue;
109  }
110 
111  render->BeginScene();
112  {
113  pWindow_Credits->EventLoop();
115  }
116  render->EndScene();
117  render->Present();
118  }
119 
121  pAudioPlayer->StopAll(1);
122 
123  pWindow_Credits->Release();
124  delete pWindow_Credits;
125 }
OSWindow.h
GUICredits::~GUICredits
virtual ~GUICredits()
Definition: UICredits.cpp:49
GUICredits::move_Y
int move_Y
Definition: UICredits.h:26
UIMessageType
UIMessageType
Definition: GUIWindow.h:13
GUIMessageQueue::Empty
bool Empty()
Definition: GUIWindow.h:659
UIMSG_Escape
@ UIMSG_Escape
Definition: GUIWindow.h:96
LOD.h
Image::GetHeight
unsigned int GetHeight()
Definition: Image.cpp:230
GUIWindow
Definition: GUIWindow.h:433
GUIFont::DrawCreditsEntry
void DrawCreditsEntry(GUIFont *pSecondFont, int uFrameX, int uFrameY, unsigned int w, unsigned int h, uint16_t firstColor, uint16_t secondColor, const String &pString, Image *image)
Definition: GUIFont.cpp:611
GUICredits::mm6title
Image * mm6title
Definition: UICredits.h:21
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
LOD::File::LoadCompressedTexture
void * LoadCompressedTexture(const String &pContainer, size_t *data_size=nullptr)
Definition: LOD.cpp:921
SetCurrentMenuID
void SetCurrentMenuID(MENU_STATE uMenu)
Definition: GUIWindow.cpp:128
GUICredits::GUICredits
GUICredits()
Definition: UICredits.cpp:15
height
EGLSurface EGLint EGLint EGLint EGLint height
Definition: SDL_egl.h:1596
GUIMessageQueue::Flush
void Flush()
Definition: GUIWindow.cpp:159
GUICredits::pFontQuick
GUIFont * pFontQuick
Definition: UICredits.h:18
AudioPlayer::MusicPlayTrack
void MusicPlayTrack(enum MusicID eTrack)
Definition: AudioPlayer.cpp:109
MENU_MAIN
@ MENU_MAIN
Definition: GUIWindow.h:251
AssetsManager::GetImage_PCXFromIconsLOD
Texture * GetImage_PCXFromIconsLOD(const String &name)
Definition: AssetsManager.cpp:81
GUIWindow::Release
virtual void Release()
Definition: GUIWindow.cpp:292
GUIFont.h
GUIFont::GetStringHeight2
int GetStringHeight2(GUIFont *secondFont, const String &text_str, GUIWindow *pWindow, int startX, int a6)
Definition: GUIFont.cpp:747
GUIWindow::uFrameWidth
unsigned int uFrameWidth
Definition: GUIWindow.h:470
current_screen_type
enum CURRENT_SCREEN current_screen_type
Definition: GUIWindow.cpp:83
AudioPlayer::StopAll
void StopAll(int sample_id)
Definition: AudioPlayer.cpp:189
GetCurrentMenuID
MENU_STATE GetCurrentMenuID()
Definition: GUIWindow.cpp:133
IMAGE_FORMAT_A8R8G8B8
@ IMAGE_FORMAT_A8R8G8B8
Definition: Image.h:7
AudioPlayer::MusicStop
void MusicStop()
Definition: AudioPlayer.cpp:140
IRender.h
GUICredits
Definition: UICredits.h:7
GUICredits::ExecuteCredits
static void ExecuteCredits()
Definition: UICredits.cpp:95
CURRENT_SCREEN::SCREEN_CREATORS
@ SCREEN_CREATORS
GUIWindow::uFrameHeight
unsigned int uFrameHeight
Definition: GUIWindow.h:471
GUIFont::LoadFont
static GUIFont * LoadFont(const char *pFontFile, const char *pFontPalette,...)
Definition: GUIFont.cpp:56
width
EGLSurface EGLint EGLint EGLint width
Definition: SDL_egl.h:1596
pIcons_LOD
LODFile_IconsBitmaps * pIcons_LOD
Definition: LOD.cpp:12
window
EGLSurface EGLNativeWindowType * window
Definition: SDL_egl.h:1580
MUSIC_Credits
@ MUSIC_Credits
Definition: AudioPlayer.h:109
GUI_UpdateWindows
void GUI_UpdateWindows()
Definition: GUIWindow.cpp:956
UIMainMenu.h
GUIMessageQueue::PopMessage
void PopMessage(UIMessageType *pMsg, int *pParam, int *a4)
Definition: GUIWindow.cpp:174
GUICredits::tick
int tick
Definition: UICredits.h:27
GUICredits::cred_texture
Texture * cred_texture
Definition: UICredits.h:25
GUIWindow::uFrameY
unsigned int uFrameY
Definition: GUIWindow.h:469
pEvents_LOD
LODFile_IconsBitmaps * pEvents_LOD
Definition: LOD.cpp:10
AudioPlayer.h
MENU_CREDITSPROC
@ MENU_CREDITSPROC
Definition: GUIWindow.h:259
LODFile_IconsBitmaps::RemoveTexturesPackFromTextureList
void RemoveTexturesPackFromTextureList()
Definition: LOD.cpp:74
GUICredits::pFontCChar
GUIFont * pFontCChar
Definition: UICredits.h:19
GUICredits::Update
virtual void Update()
Definition: UICredits.cpp:55
assets
AssetsManager * assets
Definition: AssetsManager.cpp:12
WINDOW_Credits
@ WINDOW_Credits
Definition: GUIWindow.h:347
dword_6BE364_game_settings_1
int dword_6BE364_game_settings_1
Definition: mm7_data.cpp:714
GUIWindow::uFrameX
unsigned int uFrameX
Definition: GUIWindow.h:468
pAudioPlayer
AudioPlayer * pAudioPlayer
Definition: AudioPlayer.cpp:20
GUIWindow.h
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
UICredits.h
GUICredits::EventLoop
void EventLoop()
Definition: UICredits.cpp:78
OS_WaitMessage
void OS_WaitMessage()
Definition: Lin.cpp:32
Image::Release
bool Release()
Definition: Image.cpp:335
Api.h
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52