Commit e3ce0b5d authored by Gerhard Stein's avatar Gerhard Stein

More menu files, and the keen engine no go into the right subdirectory. Please...

More menu files, and the keen engine no go into the right subdirectory. Please don't use this commit yet. I need to clean it up first
parent aa1f3b11
/*
* CAudioSettings.cpp
*
* Created on: 28.11.2009
* Author: gerstrong
*/
#include "CAudioSettings.h"
#include <base/utils/StringUtils.h>
#include <widgets/GsButton.h>
#include "common/CSettings.h"
#include "sdl/music/CMusic.h"
#include "sdl/sound/CSound.h"
CAudioSettings::CAudioSettings() :
CBaseMenu(GsRect<float>(0.075f, 0.24f, 0.85f, 0.4f) )
{
mpRate = new CGUIComboSelection( "Rate", g_pSound->getAvailableRateList());
mpMenuDialog->addControl( mpRate );
mpStereo = new CGUISwitch( "Stereo" );
mpMenuDialog->addControl( mpStereo );
mpDepth = new CGUIComboSelection( "Depth", filledStrList( 2, "8-bit", "16-bit" ) );
mpMenuDialog->addControl( mpDepth );
mpSBToggle = new CGUIComboSelection( "Card", filledStrList( 2, "PC Speaker", "Soundblaster" ) );
mpMenuDialog->addControl( mpSBToggle );
mpSoundVolume = new CGUINumberControl( "Sound Vol", 0, SDL_MIX_MAXVOLUME, 8, g_pSound->getSoundVolume() );
mpMenuDialog->addControl( mpSoundVolume );
mpMusicVolume = new CGUINumberControl( "Music Vol", 0, SDL_MIX_MAXVOLUME, 8, g_pSound->getMusicVolume() );
mpMenuDialog->addControl( mpMusicVolume );
setMenuLabel("SNDEFFMENULABEL");
}
void CAudioSettings::init()
{
mAudioSpec = g_pSound->getAudioSpec();
mSoundblaster = g_pSound->getSoundBlasterMode();
mSoundVolume = mpSoundVolume->getSelection();
mpRate->setSelection( itoa(mAudioSpec.freq) );
mpStereo->enable( mAudioSpec.channels == 2 );
mpDepth->setSelection( mAudioSpec.format == AUDIO_U8 ? "8-bit" : "16-bit" );
mpSBToggle->setSelection( mSoundblaster ? "Soundblaster" : "PC Speaker" );
g_pMusicPlayer->play();
}
void CAudioSettings::ponder(const float deltaT)
{
CBaseMenu::ponder(0);
if( mSoundVolume != mpSoundVolume->getSelection() )
g_pSound->playSound(SOUND_GET_ITEM);
mSoundVolume = mpSoundVolume->getSelection();
g_pSound->setSoundVolume( mSoundVolume );
g_pSound->setMusicVolume( mpMusicVolume->getSelection() );
}
void CAudioSettings::release()
{
mAudioSpec.freq = atoi( mpRate->getSelection().c_str() );
mAudioSpec.channels = mpStereo->isEnabled() ? 2 : 1;
mAudioSpec.format = mpDepth->getSelection() == "8-bit" ? AUDIO_U8 : AUDIO_S16;
mSoundblaster = ( mpSBToggle->getSelection() == "Soundblaster" ? true : false );
g_pSound->unloadSoundData();
g_pSound->destroy();
g_pSound->setSettings(mAudioSpec, mSoundblaster);
g_pSound->init();
g_pSound->loadSoundData();
g_pMusicPlayer->reload();
g_pSettings->saveDrvCfg();
}
/*
* CAudioSettings.h
*
* Created on: 28.11.2009
* Author: gerstrong
*/
#ifndef CAUDIOSETTINGS_H_
#define CAUDIOSETTINGS_H_
#include <widgets/GsBaseMenu.h>
#include <widgets/GsComboSelection.h>
#include <widgets/GsSwitch.h>
#include <widgets/GsNumberControl.h>
#include "fileio/CExeFile.h"
#include <SDL.h>
#include <string>
class CAudioSettings : public CBaseMenu
{
public:
CAudioSettings();
void init();
void ponder(const float deltaT);
void release();
private:
CGUIComboSelection *mpRate;
CGUISwitch *mpStereo;
CGUIComboSelection *mpDepth;
CGUIComboSelection *mpSBToggle;
CGUINumberControl *mpSoundVolume;
CGUINumberControl *mpMusicVolume;
SDL_AudioSpec mAudioSpec;
bool mSoundblaster;
// This one does not really set the volume at all, it only verifies, if it changed...
int mSoundVolume;
};
#endif /* CAUDIOSETTINGS_H_ */
/*
* CCameraSettings.cpp
*
* Created on: 22.05.2010
* Author: gerstrong
*/
#include <base/video/CVideoDriver.h>
#include "CCameraSettings.h"
#include "common/CSettings.h"
#include <base/utils/StringUtils.h>
CCameraSettings::CCameraSettings():
CBaseMenu(GsRect<float>(0.1f, 0.24f, 0.8f, 0.4f) ),
m_CameraBounds(gVideoDriver.getCameraBounds())
{
mpLeftAdjust = new CGUINumberControl( "Left",
50, 270, 10, 60 );
mpMenuDialog->addControl( mpLeftAdjust );
mpRightAdjust = new CGUINumberControl( "Right",
50, 270, 10, 60 );
mpMenuDialog->addControl( mpRightAdjust );
mpTopAdjust = new CGUINumberControl( "Top",
50, 150, 10, 60 );
mpMenuDialog->addControl( mpTopAdjust );
mpBottomAdjust = new CGUINumberControl( "Bottom",
50, 150, 10, 60 );
mpMenuDialog->addControl( mpBottomAdjust );
mpSpeedAdjust = new CGUINumberControl( "Speed",
1, 50, 1, 25 );
mpMenuDialog->addControl( mpSpeedAdjust );
setMenuLabel("OPTIONSMENULABEL");
}
void CCameraSettings::init()
{
// Load the config into the GUI
mpLeftAdjust->setSelection( m_CameraBounds.left );
mpRightAdjust->setSelection( m_CameraBounds.right );
mpTopAdjust->setSelection( m_CameraBounds.up );
mpBottomAdjust->setSelection( m_CameraBounds.down );
mpSpeedAdjust->setSelection( m_CameraBounds.speed );
}
void CCameraSettings::release()
{
// Save the config from the GUI
m_CameraBounds.left = mpLeftAdjust->getSelection();
m_CameraBounds.right = mpRightAdjust->getSelection();
m_CameraBounds.up = mpTopAdjust->getSelection();
m_CameraBounds.down = mpBottomAdjust->getSelection();
m_CameraBounds.speed = mpSpeedAdjust->getSelection();
gVideoDriver.saveCameraBounds(m_CameraBounds);
g_pSettings->saveDrvCfg();
}
/*
* CCameraSettings.h
*
* Created on: 22.05.2010
* Author: gerstrong
*/