Commit d9bfb9ac authored by Gerhard Stein's avatar Gerhard Stein

New Menus, closeable icons and stack for better Management

parent dcff3ae6
......@@ -45,7 +45,8 @@ struct GameEntry
};
class CGameLauncher {
class CGameLauncher
{
public:
CGameLauncher();
......
......@@ -13,7 +13,7 @@
#include "Menu/CLoadMenu.h"
#include "Menu/CSelectionMenu.h"
CMenu::CMenu(char menu_mode,
/*CMenu::CMenu(char menu_mode,
CSavedGame &SavedGame,
Uint8 DlgTheme,
bool &restartVideo) :
......@@ -39,7 +39,7 @@ m_restartVideo(restartVideo)
{}
void CMenu::init( menutypes menu_type )
{
{*/
/*m_menu_type = menu_type;
m_selection = NO_SELECTION; // Nothing has been selected yet.
......@@ -81,10 +81,10 @@ void CMenu::init( menutypes menu_type )
default:
break;
}*/
}
/*}
void CMenu::initMainMenu()
{
{*/
/*mp_Dialog = new CDialog(17, 10, INPUT_MODE_UP_DOWN,m_dlg_theme);
// Being at Intro, Title or Demo mode
......@@ -111,13 +111,13 @@ void CMenu::initMainMenu()
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 1, 7, "End Game");
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 1, 8, "Quit");
}*/
}
/*}
////
// Process
////
void CMenu::process()
{
{*/
/*if( g_pInput->getHoldedKey(KM) && g_pInput->getHoldedKey(KO) && g_pInput->getHoldedKey(KD) )
{
cleanup();
......@@ -174,10 +174,10 @@ void CMenu::process()
processMainMenu();
}*/
}
/*}
void CMenu::processMainMenu()
{
{*/
/*if( m_selection != NO_SELECTION )
{
if( m_menu_mode == PASSIVE )
......@@ -208,13 +208,13 @@ void CMenu::processMainMenu()
}
}
}*/
}
/*}
////
// Cleanup Routines
////
void CMenu::cleanup()
{
{*/
// Close the old menu
/*while(!m_SubMenus.empty())
{
......@@ -222,10 +222,10 @@ void CMenu::cleanup()
m_SubMenus.pop_back();
}
SAFE_DELETE(mp_Dialog);*/
}
//}
CMenu::~CMenu()
/*CMenu::~CMenu()
{
//cleanup();
}
}*/
......@@ -18,13 +18,13 @@
#include "fileio/CExeFile.h"
#include "common/CBehaviorEngine.h"
class CMenu : public CBaseMenu
class CMenu //: public CBaseMenu
{
public:
CMenu(char menu_mode,
/*CMenu(char menu_mode,
CSavedGame &SavedGame,
Uint8 DlgTheme,
bool &restartVideo );
bool &restartVideo );*/
// Getters
bool getChooseGame() { return m_choosegame; }
......@@ -49,7 +49,7 @@ public:
void cleanup();
virtual ~CMenu();
//virtual ~CMenu();
bool m_demoback;
......
......@@ -15,10 +15,9 @@
#define SAFE_DELETE(x) if(x) { delete x; x = NULL; }
CAudioSettings::CAudioSettings(Uint8 dlg_theme) :
CBaseMenu(dlg_theme)
CBaseMenu(dlg_theme, CRect<float>(0.25f, 0.24f, 0.5f, 0.5f) )
{
mpMenuDialog = new CGUIDialog(CRect<float>(0.25f, 0.24f, 0.5f, 0.5f));
mpMenuDialog->setBackground(CGUIDialog::VORTICON);
mpMenuDialog->setBackground( CGUIDialog::VORTICON );
mpMenuDialog->addControl(new CGUIButton( "Quit",
new GMQuit(),
......
......@@ -7,15 +7,27 @@
#include "sdl/input/CInput.h"
#include "CBaseMenu.h"
#include "common/Menu/CMenuController.h"
CBaseMenu::CBaseMenu(const Uint8 dlgTheme) /*:
m_mustclose(false),
CBaseMenu::CBaseMenu(const Uint8 dlgTheme, const CRect<float>& rect) :
/*m_mustclose(false),
m_selection(NO_SELECTION),
mp_Dialog(NULL),
m_dlg_theme(dlg_theme),
m_suspended(false),
m_noenter(false)*/
{}
mpMenuDialog(new CGUIDialog(rect) )
{
/*mpReturnButton = new CGUIButton( "x",
new CloseMenuEvent(),
CGUIButton::NONE );*/
mpMenuDialog->addControl( new CGUIButton( "x",
new CloseMenuEvent(),
CGUIButton::NONE ), CRect<float>(0.0f, 0.0f, 0.14f, 0.14f) );
}
void CBaseMenu::process()
{
......@@ -43,7 +55,7 @@ void CBaseMenu::process()
}
CBaseMenu::~CBaseMenu()
/*CBaseMenu::~CBaseMenu()
{
}
}*/
......@@ -13,6 +13,7 @@ const int NO_SELECTION = -1;
#include "dialog/CDialog.h"
#include "SmartPointer.h"
#include "gui/CGUIDialog.h"
#include "gui/CGUIButton.h"
// Which Menu has to be shown?
......@@ -37,18 +38,32 @@ enum menumodes{
ACTIVE, PASSIVE
};
class CBaseMenu {
class CBaseMenu
{
public:
CBaseMenu(const Uint8 dlgTheme);
enum Property
{
CLOSEABLE,
CANGOBACK
};
CBaseMenu( const Uint8 dlgTheme, const CRect<float>& rect );
// Processes the stuff that the menus have in common
virtual void process();
virtual ~CBaseMenu();
//virtual ~CBaseMenu();
void setProperty( const Property newProperty )
{
//mpReturnButton->setText( newProperty == CLOSEABLE ? "x" : "\021" );
}
protected:
SmartPointer<CGUIDialog> mpMenuDialog;
SmartPointer<CGUIButton> mpReturnButton;
};
#endif /* CBASEMENU_H_ */
......@@ -8,10 +8,10 @@
#include "CCameraSettings.h"
#include "../../StringUtils.h"
CCameraSettings::CCameraSettings(Uint8 dlg_theme):
/*CCameraSettings::CCameraSettings(Uint8 dlg_theme):
CBaseMenu(dlg_theme),
m_CameraBounds(g_pVideoDriver->getCameraBounds())
{
{*/
/*std::string buf;
mp_Dialog = new CDialog(18, 13, INPUT_MODE_UP_DOWN, m_dlg_theme);
......@@ -28,10 +28,10 @@ m_CameraBounds(g_pVideoDriver->getCameraBounds())
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 1, 11, " "+itoa(m_CameraBounds.speed));
mp_Dialog->setInputMode(INPUT_MODE_COUNTER);*/
}
/*}
void CCameraSettings::processSpecific()
{
{*/
/*if(mp_Dialog->getSelection() == 2)
{
mp_Dialog->m_min = 50;
......@@ -99,9 +99,9 @@ void CCameraSettings::processSpecific()
}
}*/
#endif
}
/*}
CCameraSettings::~CCameraSettings()
{
g_pVideoDriver->saveCameraBounds(m_CameraBounds);
}
}*/
......@@ -9,11 +9,11 @@
#define SAFE_DELETE(x) if(x) { delete x; x = NULL; }
CConfirmMenu::CConfirmMenu(const std::string &question, bool &to_be_confirmed, Uint8 dlg_theme) :
/*CConfirmMenu::CConfirmMenu(const std::string &question, bool &to_be_confirmed, Uint8 dlg_theme) :
CBaseMenu(dlg_theme),
m_question(question),
m_to_be_confirmed(to_be_confirmed)
{
{*/
/*mp_Dialog = new CDialog(22, 5, 'l',m_dlg_theme);
std::string text;
......@@ -30,18 +30,18 @@ m_to_be_confirmed(to_be_confirmed)
mp_Dialog->addObject(DLG_OBJ_TEXT, 1, 1, text);
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 1, 3, "Yes");
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 15, 3, "No");*/
}
/*}
void CConfirmMenu::processSpecific()
{
{*/
/*if( m_selection != NO_SELECTION )
{
m_to_be_confirmed = (m_selection == 1) ? true : false;
m_mustclose = true;
}*/
}
/*}
CConfirmMenu::~CConfirmMenu()
{
//SAFE_DELETE(mp_Dialog);
}
}*/
......@@ -32,12 +32,11 @@ const std::string actionsnames[MAX_COMMANDS] =
};
CControlsettings::CControlsettings( const Uint8 dlg_theme ) :
CBaseMenu(dlg_theme)/*,
CBaseMenu( dlg_theme, CRect<float>(0.25f, 0.24f, 0.5f, 0.5f) )/*,
m_chosenPlayer(0),
m_waiting_for_input(false)*/
{
mpMenuDialog = new CGUIDialog(CRect<float>(0.25f, 0.24f, 0.5f, 0.5f));
mpMenuDialog->setBackground(CGUIDialog::VORTICON);
/*mpMenuDialog->addControl(new CGUIButton( "Video",
......
......@@ -17,7 +17,7 @@
#define SAFE_DELETE(x) if(x) { delete x; x = NULL; }
CHelpMenu::CHelpMenu(CInfoScene *&p_InfoScene, Uint8 dlg_theme,
/*CHelpMenu::CHelpMenu(CInfoScene *&p_InfoScene, Uint8 dlg_theme,
CExeFile &ExeFile,
bool &hideobjects) :
CBaseMenu(dlg_theme),
......@@ -26,7 +26,7 @@ mp_InfoScene(p_InfoScene),
m_Episode(ExeFile.getEpisode()),
m_GamePath(ExeFile.getDataDirectory()),
m_hideobjects(hideobjects)
{
{*/
/*mp_Dialog = new CDialog(18, 10, INPUT_MODE_UP_DOWN,m_dlg_theme);
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 1, 1, "The Menu");
......@@ -37,7 +37,7 @@ m_hideobjects(hideobjects)
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 1, 6, "About CG");
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 1, 7, "Credits");
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 1, 8, "Previews!");*/
}
/*}
void CHelpMenu::processSpecific()
{
......@@ -77,9 +77,9 @@ void CHelpMenu::processSpecific()
m_selection = NO_SELECTION;
m_mustclose = true;
}*/
}
/*}
CHelpMenu::~CHelpMenu()
{
//SAFE_DELETE(mp_Dialog);
}
}*/
......@@ -8,10 +8,10 @@
#include "CLoadMenu.h"
#include "fileio/CSavedGame.h"
CLoadMenu::CLoadMenu(Uint8 dlg_theme, CSavedGame &SavedGame) :
/*CLoadMenu::CLoadMenu(Uint8 dlg_theme, CSavedGame &SavedGame) :
CBaseMenu(dlg_theme),
m_SavedGame(SavedGame)
{
{*/
/*mp_Dialog = new CDialog(MENU_WIDTH, 22, INPUT_MODE_UP_DOWN, m_dlg_theme);
// Load the state-file list
......@@ -29,10 +29,10 @@ m_SavedGame(SavedGame)
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 1, i, text);
}*/
}
/*}
void CLoadMenu::processSpecific()
{
{*/
/*if( m_selection != NO_SELECTION)
{
if(mp_Dialog->m_name == m_SavedGame.getEmptyString())
......@@ -47,10 +47,10 @@ void CLoadMenu::processSpecific()
}
m_selection = NO_SELECTION;
}*/
}
/*}
CLoadMenu::~CLoadMenu()
{
{*/
/*if(mp_Dialog) delete mp_Dialog;
mp_Dialog = NULL;*/
}
//}
/*
* CMainMenu.cpp
*
* Created on: 19.02.2012
* Author: gerstrong
*/
#include "CMainMenu.h"
#include "common/Menu/CMenuController.h"
#include "common/Menu/CSettingsMenu.h"
#include "common/CBehaviorEngine.h"
#include "gui/CGUIButton.h"
#include "core/CGameMode.h"
CMainMenu::CMainMenu( const Uint8 dlgTheme ) :
CBaseMenu( dlgTheme, CRect<float>(0.25f, 0.24f, 0.5f, 0.5f) )
{
// Create the Menu Dialog and entries
mpMenuDialog->setBackground(CGUIDialog::VORTICON);
CGUIButton *button = new CGUIButton( "New Game", new StartGameplayEvent(), CGUIButton::VORTICON );
mpMenuDialog->addControl( button, CRect<float>(0.05f, 0.08f, 0.9f, 0.07f) );
mpMenuDialog->addControl(new CGUIButton( "Settings",
new OpenMenuEvent( new CSettingsMenu(dlgTheme) ),
CGUIButton::VORTICON ),
CRect<float>(0.05f, 0.16f, 0.9f, 0.07f) );
mpMenuDialog->addControl(new CGUIButton( "Quit", new GMQuit(), CGUIButton::VORTICON ),
CRect<float>(0.05f, 0.24f, 0.9f, 0.07f) );
}
/*
* CMainMenu.h
*
* Created on: 19.02.2012
* Author: gerstrong
*/
#include "CBaseMenu.h"
#include "SmartPointer.h"
#include "gui/CGUIDialog.h"
#ifndef CMAINMENU_H_
#define CMAINMENU_H_
class CMainMenu : public CBaseMenu {
public:
CMainMenu(const Uint8 dlgTheme);
};
#endif /* CMAINMENU_H_ */
/*
* CMenuController.cpp
*
* Created on: 19.02.2012
* Author: gerstrong
*/
#include "CMenuController.h"
#include "common/CBehaviorEngine.h"
void CMenuController::process()
{
// process any triggered Game Control related event
CEventContainer &EventContainer = g_pBehaviorEngine->EventList();
if(!EventContainer.empty())
{
if( OpenMenuEvent* openMenu = EventContainer.occurredEvent<OpenMenuEvent>() )
{
mpMenu = openMenu->mMenuDialogPointer;
if( !mMenuStack.empty() )
mpMenu->setProperty( CBaseMenu::CANGOBACK );
mMenuStack.push_back( mpMenu );
EventContainer.pop_Event();
}
if( EventContainer.occurredEvent<CloseMenuEvent>() )
{
mMenuStack.pop_back();
mpMenu = mMenuStack.back();
EventContainer.pop_Event();
}
}
if( !mMenuStack.empty() )
mpMenu->process();
}
/*
* CMenuController.h
*
* Created on: 19.02.2012
* Author: gerstrong
*/
#include "CBaseMenu.h"
#include "engine/CEvent.h"
#ifndef CMENUCONTROLLER_H_
#define CMENUCONTROLLER_H_
/**
* Events
*/
struct OpenMenuEvent : CEvent
{
OpenMenuEvent(CBaseMenu* menuDlgPtr) : mMenuDialogPointer(menuDlgPtr) {};
SmartPointer<CBaseMenu> mMenuDialogPointer;
};
struct CloseMenuEvent : CEvent
{};
/**
* Class Declaration
*/
class CMenuController
{
public:
void process();
private:
SmartPointer<CBaseMenu> mpMenu;
std::list< SmartPointer<CBaseMenu> > mMenuStack;
};
#endif /* CMENUCONTROLLER_H_ */
......@@ -12,10 +12,9 @@
COptions::COptions( const Uint8 dlg_theme ) :
CBaseMenu(dlg_theme)
CBaseMenu( dlg_theme, CRect<float>(0.25f, 0.24f, 0.5f, 0.5f) )
{
mpMenuDialog = new CGUIDialog(CRect<float>(0.25f, 0.24f, 0.5f, 0.5f));
mpMenuDialog->setBackground(CGUIDialog::VORTICON);
/*mpMenuDialog->addControl(new CGUIButton( "Video",
......
......@@ -14,7 +14,7 @@
#include <list>
#include <string>
CProfilesMenu::CProfilesMenu(Uint8 dlg_theme) :
/*CProfilesMenu::CProfilesMenu(Uint8 dlg_theme) :
CBaseMenu(dlg_theme)
{
std::list<std::string> profile_list;
......@@ -25,7 +25,7 @@ CBaseMenu(dlg_theme)
}
void CProfilesMenu::processSpecific()
{
{*/
/*if(mp_SubMenu.get())
{
mp_SubMenu->processCommon();
......@@ -48,12 +48,12 @@ void CProfilesMenu::processSpecific()
mp_SubMenu = NULL;
m_mustclose = true;
}*/
}
//}
/**
* \brief This sets the default settings for a classic gameplay
*/
void CProfilesMenu::setDefaultClassic()
/*void CProfilesMenu::setDefaultClassic()
{
stOption *p_option = g_pBehaviorEngine->m_option;
g_pSettings->loadDrvCfg();
......@@ -74,12 +74,12 @@ void CProfilesMenu::setDefaultClassic()
p_option[OPT_IMPPOGO].value = 0;
p_option[OPT_HUD].value = 0;
g_pSettings->saveDrvCfg();
}
}*/
/**
* \brief This sets the default settings for an enhanced gameplay
*/
void CProfilesMenu::setDefaultEnhanced()
/*void CProfilesMenu::setDefaultEnhanced()
{
stOption *p_option = g_pBehaviorEngine->m_option;
g_pSettings->loadDrvCfg();
......@@ -97,4 +97,4 @@ void CProfilesMenu::setDefaultEnhanced()
p_option[OPT_IMPPOGO].value = 1;
p_option[OPT_HUD].value = 1;
g_pSettings->saveDrvCfg();
}
}*/
......@@ -12,14 +12,12 @@
#include <ctime>
#define SAFE_DELETE(x) if(x) { delete x; x = NULL; }
CSaveMenu::CSaveMenu(Uint8 dlg_theme, CSavedGame &SavedGame) :
/*CSaveMenu::CSaveMenu(Uint8 dlg_theme, CSavedGame &SavedGame) :
CBaseMenu(dlg_theme),
mp_OverwriteMenu(NULL),
m_SavedGame(SavedGame),
m_overwrite(false)
{
{*/
/*std::string text;
mp_Dialog = new CDialog(MENU_WIDTH, 22, INPUT_MODE_UP_DOWN, m_dlg_theme);
m_selection = NO_SELECTION;
......@@ -37,10 +35,10 @@ m_overwrite(false)
}
mp_Dialog->addObject(DLG_OBJ_OPTION_TEXT, 1, i, text);
}*/
}
/*}
void CSaveMenu::processSpecific()
{
{*/
/*if(!mp_OverwriteMenu)
{
if( m_selection != NO_SELECTION )
......@@ -111,14 +109,14 @@ void CSaveMenu::processSpecific()
}
}*/
}
/*}
void CSaveMenu::saveSelection()
{
{*/
/*mp_Dialog->setObjectText(m_selection, mp_Dialog->m_name);
m_SavedGame.prepareSaveGame(m_selection+1, mp_Dialog->m_name);
m_selection = NO_SELECTION;
mp_Dialog->setInputMode(INPUT_MODE_UP_DOWN);*/
}
//}
......@@ -20,9 +20,8 @@
#define SAFE_DELETE(x) if(x) { delete x; x = NULL; }
CSettingsMenu::CSettingsMenu( const Uint8 dlgtheme ) :
CBaseMenu(dlgtheme)
CBaseMenu( dlgtheme, CRect<float>(0.25f, 0.24f, 0.5f, 0.5f) )
{
mpMenuDialog = new CGUIDialog(CRect<float>(0.25f, 0.24f, 0.5f, 0.5f));
mpMenuDialog->setBackground(CGUIDialog::VORTICON);
mpMenuDialog->addControl(new CGUIButton( "Video",
......@@ -45,10 +44,10 @@ CBaseMenu(dlgtheme)
CGUIButton::VORTICON ),
CRect<float>(0.05f, 0.32f, 0.9f, 0.07f) );
mpMenuDialog->addControl(new CGUIButton( "Profile",
/*mpMenuDialog->addControl(new CGUIButton( "Profile",
new OpenMenuEvent( new CProfilesMenu(dlgtheme) ),
CGUIButton::VORTICON ),
CRect<float>(0.05f, 0.40f, 0.9f, 0.07f) );
CRect<float>(0.05f, 0.40f, 0.9f, 0.07f) );*/
}
......
......@@ -17,9 +17,8 @@
#define SAFE_DELETE(x) if(x) { delete x; x = NULL; }
CVideoSettings::CVideoSettings(const Uint8 dlg_theme) :
CBaseMenu(dlg_theme)
CBaseMenu(dlg_theme, CRect<float>(0.15f, 0.24f, 0.7f, 0.5f) )
{
mpMenuDialog = new CGUIDialog(CRect<float>(0.25f, 0.24f, 0.5f, 0.5f));
mpMenuDialog->setBackground(CGUIDialog::VORTICON);
std::list<std::string> List;
......
......@@ -12,9 +12,9 @@
#include "sdl/sound/CSound.h"
#include "sdl/input/CInput.h"
CVolumeSettings::CVolumeSettings(Uint8 dlg_theme) :
/*CVolumeSettings::CVolumeSettings(Uint8 dlg_theme) :
CBaseMenu(dlg_theme)
{
{*/
/*mp_Dialog = new CDialog(24, 7, INPUT_MODE_UP_DOWN, m_dlg_theme);
m_noenter = true;
......@@ -34,10 +34,10 @@ CBaseMenu(dlg_theme)
mp_Dialog->setInputMode(INPUT_MODE_SLIDER);
mp_Dialog->processInput();
mp_Dialog->setSelection(2);*/
}
/*}
void CVolumeSettings::processSpecific()
{
{*/
/*if(mp_Dialog->getSelection() == 2)
{
g_pSound->setMusicVolume(mp_Dialog->m_dlgobject.at(2)->m_Option->m_value*8);
......@@ -48,4 +48,4 @@ void CVolumeSettings::processSpecific()
g_pSound->setSoundVolume(mp_Dialog->m_dlgobject.at(4)->m_Option->m_value*8);
mp_Dialog->m_noise = true;
}*/
}
//}
/*
* MenuEvents.h
*
* Created on: 29.01.2012
* Author: gerstrong
*/
#ifndef MENUEVENTS_H_
#define MENUEVENTS_H_
#include "engine/CEvent.h"
// Open the menu where you choose the players
struct MEOpenPlayersMenu : CEvent {};
#endif /* MENUEVENTS_H_ */
......@@ -47,7 +47,7 @@ void CGameLauncherMenu::init()
if(m_firsttime)
{
m_firsttime = false;
mp_FirstTimeMenu = new CProfilesMenu(DLG_THEME_RED);
//mp_FirstTimeMenu = new CProfilesMenu(DLG_THEME_RED);
}
// Load the graphics for menu and background.
......@@ -190,7 +190,7 @@ void CGameLauncherMenu::process()
if(!mp_FirstTimeMenu.empty())
{
mp_FirstTimeMenu->processCommon();
mp_FirstTimeMenu->processSpecific();
//mp_FirstTimeMenu->processSpecific();