Mercurial > mm7
changeset 2551:4008b2f34be0
MainMenu rendering moved from event loop to respective window class
author | a.parshin |
---|---|
date | Tue, 12 May 2015 12:03:30 +0200 |
parents | fb42e2662c38 |
children | ac16f4a3a91e bbef1435eb8d |
files | Engine/Engine.cpp GUI/GUIWindow.cpp GUI/GUIWindow.h GUI/UI/UIMainMenu.cpp GUI/UI/UIMainMenu.h Game/MainMenu.cpp |
diffstat | 6 files changed, 119 insertions(+), 86 deletions(-) [+] |
line wrap: on
line diff
--- a/Engine/Engine.cpp Tue May 12 11:28:22 2015 +0200 +++ b/Engine/Engine.cpp Tue May 12 12:03:30 2015 +0200 @@ -1743,7 +1743,7 @@ int max_flight_height = 4000; //maximum altitude bool use_MMT = false; -bool use_music_folder = true; +bool use_music_folder = false; bool for_refactoring = false; //----- (00462C94) -------------------------------------------------------- @@ -3132,7 +3132,6 @@ pIcons_LOD->uNumLoadedFiles = pIcons_LOD->pFacesLock; pIcons_LOD->pFacesLock = 0; } -// 4ED498: using guessed type char byte_4ED498; //----- (00494820) -------------------------------------------------------- unsigned int __fastcall _494820_training_time(unsigned int a1) @@ -3180,7 +3179,6 @@ } return result; } -// 4EE088: using guessed type __int16 word_4EE088_sound_ids[]; //----- (00443E31) -------------------------------------------------------- void LoadLevel_InitializeLevelStr() @@ -3227,7 +3225,7 @@ } //----- (00443F95) -------------------------------------------------------- -void OnMapLeave() +void OnMapLeave() { _evt_raw *test_event; if (uLevelEVT_NumEvents > 0) @@ -3394,7 +3392,6 @@ strcpy(pCurrentMapName, pMapName); uLevel_StartingPointType = start_point; } -// 6BE35C: using guessed type int uLevel_StartingPointType; //----- (004451A8) -------------------------------------------------------- void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4)
--- a/GUI/GUIWindow.cpp Tue May 12 11:28:22 2015 +0200 +++ b/GUI/GUIWindow.cpp Tue May 12 12:03:30 2015 +0200 @@ -1699,7 +1699,7 @@ } } //----- (00467F9F) -------------------------------------------------------- -void free_book_subwindow() +void free_book_subwindow() { if ( pGUIWindow_ScrollWindow ) {
--- a/GUI/GUIWindow.h Tue May 12 11:28:22 2015 +0200 +++ b/GUI/GUIWindow.h Tue May 12 12:03:30 2015 +0200 @@ -694,7 +694,7 @@ void CreateScrollWindow(); void OnPaperdollLeftClick(); void DrawJoinGuildWindow(int pEventCode); -void DialogueEnding(); +void DialogueEnding(); char sub_4637E0_is_there_popup_onscreen(); void sub_4B3E1E(); void __fastcall ClickNPCTopic(signed int uMessageParam);
--- a/GUI/UI/UIMainMenu.cpp Tue May 12 11:28:22 2015 +0200 +++ b/GUI/UI/UIMainMenu.cpp Tue May 12 12:03:30 2015 +0200 @@ -1,28 +1,106 @@ #define _CRTDBG_MAP_ALLOC +#define _CRT_SECURE_NO_WARNINGS #include <stdlib.h> #include <crtdbg.h> -#define _CRT_SECURE_NO_WARNINGS - #include "Engine/Engine.h" - -#include "..\../IO/Mouse.h" -#include "..\../IO/Keyboard.h" +#include "Engine/LOD.h" +#include "Engine/MMT.h" +#include "Engine/texts.h" +#include "Engine/Graphics/IRender.h" +#include "Engine/Graphics/Viewport.h" +#include "Engine/Graphics/PaletteManager.h" +#include "Engine/Tables/IconFrameTable.h" -#include "..\../GUI/GUIWindow.h" -#include "..\../GUI/GUIFont.h" -#include "..\../Media/Audio/AudioPlayer.h" -#include "..\../Engine/Graphics/Render.h" -#include "..\../Engine/LOD.h" -#include "..\../Engine/Graphics/PaletteManager.h" -#include "..\../Engine/Tables/IconFrameTable.h" -#include "..\../Engine/texts.h" -#include "..\../Engine/MMT.h" +#include "IO/Mouse.h" +#include "IO/Keyboard.h" + +#include "GUI/UI/UIMainMenu.h" +#include "GUI/GUIFont.h" + +#include "Media/Audio/AudioPlayer.h" #include "Game/Game.h" #include "Game/MainMenu.h" + +GUIButton *pMainMenu_BtnExit = nullptr; +GUIButton *pMainMenu_BtnCredits = nullptr; +GUIButton *pMainMenu_BtnLoad = nullptr; +GUIButton *pMainMenu_BtnNew = nullptr; + + + +GUIWindow_MainMenu::GUIWindow_MainMenu() : + GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr) +{ +// ----------------------------------- +// 004627B7 void MainMenu_Loop -- part + Texture *pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); + Texture *pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); + Texture *pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); + Texture *pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); + + pMainMenu_BtnNew = CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0); + pMainMenu_BtnLoad = CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowLoadWindow, 1, 'L', "", pLoad, 0); + pMainMenu_BtnCredits = CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0); + pMainMenu_BtnExit = CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); +} + + +void GUIWindow_MainMenu::Update() +{ +// ----------------------------------- +// 004627B7 void MainMenu_Loop -- part + POINT pt; + pMouse->GetCursorPos(&pt); + GUIWindow *pWindow = this;//pWindow_MainMenu; + if (GetCurrentMenuID() == MENU_SAVELOAD) + pWindow = pGUIWindow_CurrentMenu; + + + if (GetCurrentMenuID() == MENU_MAIN) + { + Texture *pTexture = nullptr; + if (!pModalWindow)// ??? + { + auto pButton = pWindow->pControlsHead; + for (pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext) + { + if (pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ + && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW + && pWindow == pWindow_MainMenu) + { + auto pControlParam = pButton->msg_param; + int pY = 0; + switch (pControlParam) // backlight for buttons + { + case 0: + pTexture = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); + pY = 172; + break; + case 1: + pTexture = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); + pY = 227; + break; + case 2: + pTexture = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); + pY = 282; + break; + case 3: + pTexture = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); + pY = 337; + break; + } + pRenderer->DrawTextureIndexed(495, pY, pTexture); + } + } + } + } +} + + //----- (0041B578) -------------------------------------------------------- void MainMenuUI_LoadFontsAndSomeStuff() {
--- a/GUI/UI/UIMainMenu.h Tue May 12 11:28:22 2015 +0200 +++ b/GUI/UI/UIMainMenu.h Tue May 12 12:03:30 2015 +0200 @@ -1,1 +1,19 @@ -#pragma once \ No newline at end of file +#pragma once +#include "GUI/GUIWindow.h" + + + +extern struct GUIButton *pMainMenu_BtnExit; +extern struct GUIButton *pMainMenu_BtnCredits; +extern struct GUIButton *pMainMenu_BtnLoad; +extern struct GUIButton *pMainMenu_BtnNew; + + + +struct GUIWindow_MainMenu: public GUIWindow +{ + GUIWindow_MainMenu(); + virtual ~GUIWindow_MainMenu() {} + + virtual void Update(); +}; \ No newline at end of file
--- a/Game/MainMenu.cpp Tue May 12 11:28:22 2015 +0200 +++ b/Game/MainMenu.cpp Tue May 12 12:03:30 2015 +0200 @@ -9,21 +9,16 @@ #include "IO/Mouse.h" #include "IO/Keyboard.h" -#include "GUI/GUIWindow.h" -#include "GUI/GUIButton.h" +#include "GUI/UI/UIMainMenu.h" #include "GUI/UI/UIPartyCreation.h" #include "GUI/UI/UISaveLoad.h" +#include "GUI/GUIButton.h" #include "Media/Audio/AudioPlayer.h" #include "Game/MainMenu.h" -GUIButton *pMainMenu_BtnExit = nullptr; -GUIButton *pMainMenu_BtnCredits = nullptr; -GUIButton *pMainMenu_BtnLoad = nullptr; -GUIButton *pMainMenu_BtnNew = nullptr; - RGBTexture main_menu_background; @@ -366,16 +361,7 @@ pIcons_LOD->_inlined_sub2(); - pWindow_MainMenu = new GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, 0); - Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); - Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); - Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); - Texture* pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); - - pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0); - pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowLoadWindow, 1, 'L', "", pLoad, 0); - pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0); - pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); + pWindow_MainMenu = new GUIWindow_MainMenu(); main_menu_background.Release(); main_menu_background.Load("title.pcx", 0); @@ -421,56 +407,10 @@ MainMenu_EventLoop(); GUI_UpdateWindows(); - if (GetCurrentMenuID() != MENU_MAIN) - { - if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) - { - pIcons_LOD->RemoveTexturesPackFromTextureList(); - pGUIWindow_CurrentMenu->Release(); - pGUIWindow_CurrentMenu = 0; - current_screen_type = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - } - } - else - { - if (!pModalWindow)// ??? - { - pButton = pWindow->pControlsHead; - for (pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext) - { - if (pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ - && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW - && pWindow == pWindow_MainMenu) - { - pControlParam = pButton->msg_param; - switch (pControlParam) // backlight for buttons - { - case 0: - pTexture = pNew; - pY = 172; - break; - case 1: - pTexture = pLoad; - pY = 227; - break; - case 2: - pTexture = pCredits; - pY = 282; - break; - case 3: - pTexture = pExit; - pY = 337; - break; - } - pRenderer->DrawTextureIndexed(495, pY, pTexture); - } - } - } - } pRenderer->EndScene(); pRenderer->Present(); } + MainMenu_EventLoop(); pRenderer->BeginScene(); GUI_UpdateWindows();