Pac-Man Evolution
Loading...
Searching...
No Matches
Menu.cpp
1/*----------------------------------------------------------------------
2Pac-Man Evolution - Roberto Prieto
3Copyright (C) 2018-2024 MegaStorm Systems
4
5This software is provided 'as-is', without any express or implied
6warranty. In no event will the authors be held liable for any damages
7arising from the use of this software.
8
9Permission is granted to anyone to use this software for any purpose,
10including commercial applications, and to alter it and redistribute it
11freely, subject to the following restrictions:
12
131. The origin of this software must not be misrepresented; you must not
14claim that you wrote the original software. If you use this software
15in a product, an acknowledgment in the product documentation would be
16appreciated but is not required.
172. Altered source versions must be plainly marked as such, and must not be
18misrepresented as being the original software.
193. This notice may not be removed or altered from any source distribution.
20
21------------------------------------------------------------------------
22
23Menu class
24
25------------------------------------------------------------------------ */
26
27#include "Menu.h"
28#include "ResourceManager.h"
29#include "Pac-Man_Evolution.h"
30
31Menu::Menu()
32{
33}
34
35Menu::~Menu()
36{
37}
38
39// Process the widget events and call associated handlers
40// Return PME_LOOP, PME_BREAK or PME_EXIT
41Sint32 Menu::processEvent(const Sint32 idWidget, const Sint32 iValue)
42{
43 Panel* pPanel = Main::Instance().IGUIMgr().getPanel(ResourceManager::Instance().get(RM_PANEL_MENU));
44 Main& mC64 = Main::Instance();
45 Sint32 iRet = PME_LOOP;
46
47 // Manage our events
48 switch(idWidget)
49 {
50 case ID_EXIT:
51 mC64.ISoundMgr().get(ResourceManager::Instance().get(RM_SND_CLICKOK))->play();
52 iRet = PME_EXIT;
53 break;
54 case ID_STANDARDGAME:
55 mC64.ISoundMgr().get(ResourceManager::Instance().get(RM_SND_CLICKOK))->play();
56 iRet = PME_GAME_STANDARD;
57 break;
58 case ID_EVOLUTIONGAME:
59 mC64.ISoundMgr().get(ResourceManager::Instance().get(RM_SND_CLICKOK))->play();
60 iRet = PME_GAME_EVOLUTION;
61 break;
62 case ID_WORKBENCHGAME:
63 mC64.ISoundMgr().get(ResourceManager::Instance().get(RM_SND_CLICKOK))->play();
64 iRet = PME_GAME_WORKBENCH;
65 break;
66 case ID_HALLOFFAME:
67 mC64.ISoundMgr().get(ResourceManager::Instance().get(RM_SND_CLICKOK))->play();
68 iRet = PME_HOF;
69 break;
70 }
71
72 return iRet;
73}
74
75// Render method
76Sint32 Menu::render(Sint32 iMode)
77{
78 SDL_Rect rDst;
79 Sint32 iSW = 0, iSH = 0;
80 Screen* pScreen = Main::Instance().IConfigMgr().get();
81 if(pScreen != nullptr) pScreen->getSize(&iSW, &iSH);
82
83 // Render background centered
84 Image* pImage = Main::Instance().IImageMgr().get(ResourceManager::Instance().get(RM_IMG_MENU));
85 if(pImage != nullptr)
86 {
87 rDst.w = pImage->getSurface()->w;
88 rDst.h = pImage->getSurface()->h;
89 rDst.x = (iSW - rDst.w) / 2;
90 rDst.y = (iSH - rDst.h) / 2;
91 pImage->render(0, nullptr, &rDst);
92 }
93 return PME_LOOP;
94}