Commit 718b1620 authored by Gerhard Stein's avatar Gerhard Stein

Many cleanups

parent 7e8f14b4
**************************************************************
Commander Genius
(c)2008-2016 Gerstrong
(c)2008-2017 Gerstrong
Testing:
(c)2014-2016 Mancus
......@@ -9,7 +9,7 @@ Testing:
Porting and Support:
(c)2010-2016 Pelya (Android-Distro)
(c)2010-2017 Pelya (Android-Distro)
Released under GNU/GPL
......
......@@ -15,28 +15,13 @@
#include <cstdlib>
GsFont::GsFont()
{
setFillWidthTable(8);
}
void GsFont::setFillWidthTable(const int width)
{
mWidthtable.fill(width);
}
///////////////////////////////////
///// Initialization Routines /////
///////////////////////////////////
// We have the colors from 0-15, which are 16 colors in our 4-bit colorspace.
// Colour 16 represents transparency.
// In that case color 16 represents transparency.
const unsigned int COLORKEY_4BIT = 16;
......@@ -46,18 +31,11 @@ bool GsFont::CreateSurface(SDL_Color *Palette, Uint32 Flags,
mFontSurface.create(Flags, width,
height, 8, 0, 0, 0, 0);
/*mFontSurface.reset(SDL_CreateRGBSurface(Flags, width,
height, 8, 0, 0, 0, 0), &SDL_FreeSurface );*/
//GsWeakSurface fontSfc(mFontSurface.get());
mFontSurface.setPaletteColors(Palette);
mFontSurface.setColorKey(COLORKEY_4BIT);
if( mFontSurface )
return true;
else
return false;
if( mFontSurface ) return true;
else return false;
}
......@@ -156,10 +134,8 @@ SDL_Surface *loadfromXPMData(const char **data, const SDL_PixelFormat *format, c
bool GsFont::loadAlternateFont()
{
// Has the Surface of the entire font been loaded?
// Use some if the blit surface settings so it will be shown correctly
SDL_Surface *blit = gVideoDriver.getBlitSurface();
//mFontSurface.reset( loadfromXPMData( alternatefont_xpm, blit->format, blit->flags ), &SDL_FreeSurface );
mFontSurface.createFromSDLSfc( loadfromXPMData( alternatefont_xpm, blit->format, blit->flags ) );
return true;
}
......@@ -170,13 +146,10 @@ void GsFont::loadinternalFont(const char *pixmap[])
{
SDL_Surface *blit = gVideoDriver.getBlitSurface();
mFontSurface.createFromSDLSfc( loadfromXPMData( pixmap, blit->format, blit->flags ) );
auto &fontSfc = mFontSurface;
//GsWeakSurface fontSfc(mFontSurface.get());
mFontSurface.createFromSDLSfc( loadfromXPMData( pixmap, blit->format, blit->flags ) );
#if SDL_VERSION_ATLEAST(2, 0, 0)
//SDL_SetSurfaceBlendMode(mFontSurface.get(), SDL_BLENDMODE_BLEND);
auto &fontSfc = mFontSurface;
fontSfc.setBlendMode(SDL_BLENDMODE_BLEND);
#endif
}
......@@ -253,9 +226,8 @@ Uint32 GsFont::getFGColor()
{
// Here comes the main part. We have to manipulate the Surface the way it gets
// the given color
SDL_Color color[16];
//memcpy( color, mFontSurface->format->palette->colors, 16*sizeof(SDL_Color) );
memcpy( color, mFontSurface.getSDLSurface()->format->palette->colors, 16*sizeof(SDL_Color) );
std::array<SDL_Color, 16> color;
memcpy( color.data(), mFontSurface.getSDLSurface()->format->palette->colors, color.size()*sizeof(SDL_Color) );
SDL_PixelFormat *pPixelformat = gVideoDriver.getBlitSurface()->format;
......@@ -271,7 +243,7 @@ void GsFont::createTextSurface(GsSurface &sfc,
{
SDL_Rect rect;
rect.x = rect.y = 0;
rect.w = getPixelTextWidth(text);
rect.w = calcPixelTextWidth(text);
rect.h = getPixelTextHeight()*calcNumLines(text);
SDL_Surface *blit = gVideoDriver.getBlitSurface();
......@@ -300,7 +272,7 @@ void GsFont::createTextSurface(GsSurface &sfc,
}
unsigned int GsFont::getPixelTextWidth( const std::string& text )
unsigned int GsFont::calcPixelTextWidth( const std::string& text )
{
unsigned int c = 0, width = 0, len = 0;
for( ; c<text.size() ; c++)
......@@ -327,16 +299,11 @@ unsigned int GsFont::getPixelTextWidth( const std::string& text )
unsigned int GsFont::getPixelTextHeight()
{
return mFontSurface.getSDLSurface()->h/16;
}
Uint32 GsFont::getBGColour(const bool highlight)
{
SDL_PixelFormat *format = gVideoDriver.getBlitSurface()->format;
return getBGColour(format, highlight);
}
......@@ -346,24 +313,16 @@ Uint32 GsFont::getBGColour(const bool highlight)
Uint32 GsFont::getBGColour(SDL_PixelFormat *format, const bool highlight)
{
Uint8 r, g, b;
getBGColour( &r, &g, &b, highlight );
return SDL_MapRGB(format, r, g, b);
}
void GsFont::getBGColour(Uint8 *r, Uint8 *g, Uint8 *b, const bool highlight)
{
//GsWeakSurface fontSfc(mFontSurface.get());
auto &fontSfc = mFontSurface;
const Uint32 color = fontSfc.getPixel(0, highlight ? 80 : 16 );
fontSfc.getRGB(color, *r, *g, *b);
}
......@@ -378,10 +337,12 @@ void GsFont::drawCharacter(SDL_Surface* dst, Uint16 character, Uint16 xoff, Uint
{
SDL_Rect scrrect, dstrect;
scrrect.x = (mFontSurface.width()/16)*(character%16);
scrrect.y = (mFontSurface.height()/16)*(character/16);
const auto fontSfcHeight = mFontSurface.height();
const auto fontSfcwidth = mFontSurface.width();
scrrect.x = (fontSfcwidth/16)*(character%16);
scrrect.y = (fontSfcHeight/16)*(character/16);
scrrect.w = dstrect.w = (mWidthtable[character]);
scrrect.h = dstrect.h = (mFontSurface.height()/16);
scrrect.h = dstrect.h = (fontSfcHeight/16);
dstrect.x = xoff; dstrect.y = yoff;
BlitSurface(mFontSurface.getSDLSurface(), &scrrect, dst, &dstrect);
......@@ -405,12 +366,12 @@ void GsFont::drawFont(SDL_Surface* dst,
drawCharacter(dst, c, x, y);
x+=mWidthtable[c];
x += mWidthtable[c];
}
else
{
x=xoff;
y+=8;
x = xoff;
y += 8;
}
}
......@@ -418,7 +379,7 @@ void GsFont::drawFont(SDL_Surface* dst,
void GsFont::drawFontAlpha(SDL_Surface* dst, const std::string& text, Uint16 xoff, Uint16 yoff, const Uint8 alpha)
{
unsigned int i,x=xoff,y=yoff;
unsigned int i, x=xoff, y=yoff;
mFontSurface.setAlpha(alpha);
......@@ -429,13 +390,12 @@ void GsFont::drawFontAlpha(SDL_Surface* dst, const std::string& text, Uint16 xof
if ( !endofText( text.substr(i) ) )
{
drawCharacter(dst, c, x, y);
x+=mWidthtable[c];
x += mWidthtable[c];
}
else
{
x=xoff;
y+=8;
x = xoff;
y += 8;
}
}
......@@ -443,22 +403,14 @@ void GsFont::drawFontAlpha(SDL_Surface* dst, const std::string& text, Uint16 xof
}
void GsFont::drawFontCentered(SDL_Surface* dst, const std::string& text, Uint16 width, Uint16 yoff, bool highlight)
{
drawFontCentered(dst, text, 0, width, yoff, highlight);
}
void GsFont::drawFontCenteredAlpha(SDL_Surface* dst, const std::string& text, Uint16 width, Uint16 yoff, const Uint8 alpha)
{
drawFontCenteredAlpha(dst, text, 0, width, yoff, alpha);
}
void GsFont::drawFontCenteredAlpha(SDL_Surface* dst, const std::string& text, Uint16 x, Uint16 width, Uint16 yoff, const Uint8 alpha)
{
Uint16 xmidpos = 0;
for( unsigned int i=0 ; i<text.size() ; i++)
{
xmidpos += mWidthtable[ static_cast<unsigned int>(text[i]) ];
}
xmidpos = (width-xmidpos)/2+x;
......
......@@ -25,17 +25,40 @@
class GsFont
{
public:
GsFont();
/**
* @brief GsFont 8x8 pixels is the default area used for one character.
* On modern this might be very small
*/
GsFont()
{
setFillWidthTable(8);
}
void setFillWidthTable(const int width);
/**
* @brief setFillWidthTable Sets the width to all the characters
* @param width desired width to set
*/
void setFillWidthTable(const int width)
{
mWidthtable.fill(width);
}
/**
* @brief GsFont Copy constructor
* @param that element to copy
*/
GsFont(const GsFont& that)
{
operator=(that);
}
/**
* @brief operator = Basic assignment operator
* @param that element to copy
* @return Reference to the newly set GsFont instance
*/
GsFont& operator=(const GsFont& that)
{
if(that.mFontSurface)
......@@ -48,10 +71,22 @@ public:
return *this;
}
/**
* @brief CreateSurface Creates a basic font surface
* @param Palette
* @param Flags
* @param width
* @param height
* @return
*/
bool CreateSurface(SDL_Color *Palette, Uint32 Flags, Uint16 width = 128, Uint16 height = 128);
SDL_Surface *SDLSurfacePtr() const { return mFontSurface.getSDLSurface(); }
/**
* @brief loadAlternateFont This loads the internal font found in Alternatefont.xpm
* @return true if it was sucessfully loaded, otherwise false
*/
bool loadAlternateFont();
/**
......@@ -100,29 +135,33 @@ public:
unsigned char g,
unsigned char b);
/*
* \brief This will retrieve the total width in pixels of the Font.
/**
* @brief This will retrieve the total width in pixels of the Font.
* In Galaxy it's more difficult to calculate that since every character has it own with
* \param text Text which will be analyzed to get the full width
* \return the width in pixel units
* @param text Text which will be analyzed to get the full width
* @return the width in pixel units
*/
unsigned int getPixelTextWidth( const std::string& text );
unsigned int calcPixelTextWidth( const std::string& text );
/*
* \brief This will help to get the right height of some Dialog Boxes
* \return height of the text height in pixel units.
/**
* @brief This will help to get the right height of some Dialog Boxes
* @return height of the text height in pixel units.
*/
unsigned int getPixelTextHeight();
unsigned int getPixelTextHeight()
{
const auto height = mFontSurface.getSDLSurface()->h;
return height / 16;
}
/**
* \brief gets the background color of the font
*/
Uint32 getBGColour(const bool highlight = false);
Uint32 getBGColour(const bool highlight = false);
/**
* \brief gets the background color of the font
*/
Uint32 getBGColour(SDL_PixelFormat *format, const bool highlight = false);
Uint32 getBGColour(SDL_PixelFormat *format, const bool highlight = false);
/**
* \brief Components-version
......@@ -130,17 +169,31 @@ public:
void getBGColour(Uint8 *r, Uint8 *g, Uint8 *b, const bool highlight = false);
void drawCharacter(SDL_Surface* dst, Uint16 character, Uint16 xoff, Uint16 yoff);
void drawFont(SDL_Surface* dst, const std::string& text, const Uint16 xoff, const Uint16 yoff, const bool highlight = false);
void drawFont(GsWeakSurface &dst, const std::string& text, const Uint16 xoff, const Uint16 yoff, const bool highlight = false)
{
drawFont(dst.getSDLSurface(), text, xoff, yoff, highlight);
}
void drawFontAlpha(SDL_Surface* dst, const std::string& text, Uint16 xoff, Uint16 yoff, const Uint8 alpha);
void drawFontCentered(SDL_Surface* dst, const std::string& text, Uint16 width, Uint16 yoff, bool highlight = false);
void drawFontCentered(SDL_Surface* dst, const std::string& text, Uint16 width, Uint16 yoff, bool highlight = false)
{
drawFontCentered(dst, text, 0, width, yoff, highlight);
}
void drawFontCentered(SDL_Surface* dst, const std::string& text, Uint16 x, Uint16 width, Uint16 yoff, bool highlight = false);
void drawFontCenteredAlpha(SDL_Surface* dst, const std::string& text, Uint16 x, Uint16 width, Uint16 yoff, Uint16 height, const Uint8 alpha);
void drawFontCenteredAlpha(SDL_Surface* dst, const std::string& text, Uint16 width, Uint16 yoff, const Uint8 alpha);
void drawFontCenteredAlpha(SDL_Surface* dst, const std::string& text, Uint16 width, Uint16 yoff, const Uint8 alpha)
{
drawFontCenteredAlpha(dst, text, 0, width, yoff, alpha);
}
void drawFontCenteredAlpha(SDL_Surface* dst, const std::string& text, Uint16 x, Uint16 width, Uint16 yoff, const Uint8 alpha);
void drawFontCentered(SDL_Surface* dst,
const std::string& text,
......@@ -164,6 +217,7 @@ public:
private:
GsSurface mFontSurface;
//GsSurface mFontSurface2x; /** FontSurface but scaled up using Scale2X filter */
std::array<Uint8, 256> mWidthtable;
};
......
......@@ -15,6 +15,7 @@ void drawMenuInGameButton(const SDL_Rect &buttonRect)
{
SDL_Surface *dst = gVideoDriver.getBlitSurface();
SDL_Rect tempRect = buttonRect;
SDL_FillRect(dst, &tempRect, SDL_MapRGB(dst->format, 255, 0, 0) );
......
......@@ -336,9 +336,6 @@ bool CCamera::outOfSight()
else if( playerDown < camY - cam_height )
outofsight |= true;
if(mp_Map)
return outofsight;
}
......
......@@ -180,6 +180,9 @@ bool CMessages::extractEp4Strings(std::map<std::string, std::string>& StringMap)
setDecodeOffset(0x2F41A);
StringMap.insert( extractNextString( "WARP_LEVEL_TEXT" ) );
setDecodeOffset(0x1EE40);
StringMap.insert( extractNextString( "STORY_TEXT" ) );
return true;
} break;
}
......@@ -211,6 +214,10 @@ bool CMessages::extractEp5Strings(std::map<std::string, std::string>& StringMap)
StringMap.insert( extractNextString( "FUSE_WONDER" ) );
StringMap.insert( extractNextString( "FUSE_CASUAL" ) );
setDecodeOffset(0x1FDE0);
StringMap.insert( extractNextString( "STORY_TEXT" ) );
return true;
} break;
}
......@@ -256,6 +263,10 @@ bool CMessages::extractEp6Strings(std::map<std::string, std::string>& StringMap)
StringMap.insert( extractNextString( "KEEN_GRABBITER_SLEEPY" ) );
StringMap.insert( extractNextString( "KEEN_KEYCARD_REQUIRED" ) );
StringMap.insert( extractNextString( "KEEN_ROPE_REQUIRED" ) );
setDecodeOffset(0x1ED50);
StringMap.insert( extractNextString( "STORY_TEXT" ) );
return true;
} break;
......
......@@ -179,7 +179,7 @@ void CMapPlayGalaxy::render()
int pIt = 0;
auto objVecSize = mObjectPtr.size();
for( int ctr = 0 ; ctr < objVecSize ; ctr++)
for( int ctr = 0 ; ctr < int(objVecSize) ; ctr++)
{
auto &obj = mObjectPtr[objVecSize-ctr-1];
......
......@@ -129,6 +129,9 @@ bool CPassiveGalaxy::init()
#endif
const auto &storyText = gpBehaviorEngine->getString("STORY_TEXT");
mStoryTextVector = explode(storyText, "\n");
return true;
}
......@@ -427,10 +430,17 @@ void CPassiveGalaxy::renderStarWars()
lRect.x = 0; lRect.y = 20;
// Draw some text.
// Draw the title of the story text
GsFont &startwarsFont = gGraphics.getFont(2);
//startwarsFont.drawFontCentered( sfc, "ABCDEFGabcdefg", lRect.x, lRect.w, lRect.y, false);
startwarsFont.drawFontCentered( sfc, mStoryTextVector[0], lRect.x, lRect.w, lRect.y, false);
lRect.y += 20;
startwarsFont.drawFontCentered( sfc, mStoryTextVector[2], lRect.x, lRect.w, lRect.y, false);
lRect.h = sfc->h; lRect.w = sfc->w;
lRect.x = 0; lRect.y = lRect.h-20;
......
......@@ -84,6 +84,11 @@ public:
bool mSwapColors = true;
bool mSkipSection;
/**
* @brief mStoryTextVector Vector of story text blocks
*/
std::vector<std::string> mStoryTextVector;
};
}
......
......@@ -414,11 +414,10 @@ void CPlayGameGalaxy::pumpEvent(const CEvent *evPtr)
g_pSound->playSound( SOUND_LEVEL_DONE );
}
const int oldLevel = m_LevelPlay.getLevelIdx();
int newLevel = 0;
#if USE_PYTHON3
const int oldLevel = m_LevelPlay.getLevelIdx();
auto pModule = gPython.loadModule( "exitToLevel", gKeenFiles.gameDir);
if (pModule != nullptr)
......@@ -488,8 +487,6 @@ void CPlayGameGalaxy::pumpEvent(const CEvent *evPtr)
}
}
// Menu-Button
const SDL_Rect menuButtonRect = {310, 0, 10, 10};
/**
......@@ -506,7 +503,7 @@ void CPlayGameGalaxy::ponder(const float deltaT)
processInput();
// Check if Sandwhich-Menu was clicked
GsRect<float> rRect(menuButtonRect);
GsRect<float> rRect(mMenuButtonRect);
const float w = gVideoDriver.getBlitSurface()->w;
const float h = gVideoDriver.getBlitSurface()->h;
rRect.x /= w; rRect.y /= h;
......@@ -654,8 +651,11 @@ void CPlayGameGalaxy::render()
const bool msgboxactive = !mMessageBoxes.empty();
// The position of the sandwich menu depends on the configured blit resolution
mMenuButtonRect.x = gVideoDriver.getBlitSurface()->w-10;
// Draw a menu button where the mouse/finger might tap on
drawMenuInGameButton(menuButtonRect);
drawMenuInGameButton(mMenuButtonRect);
// Draw some Textboxes with Messages only if one of those is open and needs to be drawn
if(msgboxactive)
......
......@@ -63,6 +63,9 @@ private:
std::vector<bool> mDead;
std::vector<bool> mGameOver;
// Menu-Button
SDL_Rect mMenuButtonRect = {310, 0, 10, 10};
};
}
......
......@@ -35,7 +35,7 @@ mCloseEv(closeEv)
GsRect<Uint16> gameRes = gVideoDriver.getGameResolution();
// Create a surface for that
mMBRect.w = Font.getPixelTextWidth(mText)+16;
mMBRect.w = Font.calcPixelTextWidth(mText)+16;
mMBRect.h = Font.getPixelTextHeight()*(calcNumLines(mText)+1)+16;
mMBRect.x = (gameRes.w-mMBRect.w)/2;
mMBRect.y = (gameRes.h-mMBRect.h)/2;
......
......@@ -43,7 +43,7 @@ blendup(true)
// Create a surface for that
GsRect<Uint16> gameRes = gVideoDriver.getGameResolution();
mMBRect.w = Font.getPixelTextWidth(mText)+16;
mMBRect.w = Font.calcPixelTextWidth(mText)+16;
mMBRect.h = Font.getPixelTextHeight()*(calcNumLines(mText)+1)+16;
mMBRect.x = (gameRes.w-mMBRect.w)/2;
mMBRect.y = (gameRes.h-mMBRect.h)/2;
......@@ -96,7 +96,7 @@ void CMessageBoxSelection::init()
int yoff = 0;
for( auto &it : textList )
{
int xmid = (rect.w-Font.getPixelTextWidth(it))/2+rect.x;
int xmid = (rect.w-Font.calcPixelTextWidth(it))/2+rect.x;
Font.drawFont( pColoredTextSurface, it, xmid, yoff);
yoff += 12;
}
......
......@@ -22,15 +22,24 @@ CAudioSettings::CAudioSettings() :
GalaxyMenu(GsRect<float>(0.075f, 0.24f, 0.85f, 0.4f) )
{
#if !defined(EMBEDDED)
mpRate = new ComboSelection( "Rate", g_pSound->getAvailableRateList());
mpMenuDialog->addControl( mpRate );
#endif
mpStereo = new Switch( "Stereo" );
mpMenuDialog->addControl( mpStereo );
#if !defined(EMBEDDED)
mpDepth = new ComboSelection( "Depth", filledStrList( 2, "8-bit", "16-bit" ) );
mpMenuDialog->addControl( mpDepth );
#endif
mpSBToggle = new ComboSelection( "Card", filledStrList( 2, "PC Speaker", "Soundblaster" ) );
mpMenuDialog->addControl( mpSBToggle );
......@@ -55,9 +64,14 @@ void CAudioSettings::refresh()
mpSoundVolume->setSelection(g_pSound->getSoundVolume());
mpMusicVolume->setSelection(g_pSound->getMusicVolume());
#if !defined(EMBEDDED)
mpRate->setSelection( itoa(mAudioSpec.freq) );
#endif
mpStereo->enable( mAudioSpec.channels == 2 );
#if !defined(EMBEDDED)
mpDepth->setSelection( mAudioSpec.format == AUDIO_U8 ? "8-bit" : "16-bit" );
#endif
mpSBToggle->setSelection( mSoundblaster ? "Soundblaster" : "PC Speaker" );
g_pMusicPlayer->play();
}
......@@ -79,9 +93,15 @@ void CAudioSettings::ponder(const float deltaT)
void CAudioSettings::release()
{
#if !defined(EMBEDDED)
mAudioSpec.freq = atoi( mpRate->getSelection().c_str() );
#endif
mAudioSpec.channels = mpStereo->isEnabled() ? 2 : 1;
#if !defined(EMBEDDED)
mAudioSpec.format = mpDepth->getSelection() == "8-bit" ? AUDIO_U8 : AUDIO_S16;
#endif
mSoundblaster = ( mpSBToggle->getSelection() == "Soundblaster" ? true : false );
......
......@@ -73,11 +73,10 @@ ComputerWrist::ComputerWrist(const int ep) :
GsFont &font = gGraphics.getFont(mFontId);
GsWeakSurface blitsfc(gVideoDriver.getBlitSurface());
const auto numElem = (blitsfc.height()*blitsfc.width());
const auto numLines = (blitsfc.height() - (mUpperBorderBmp.height() + mBottomBorderBmp.height()))/font.getPixelTextHeight();
const int numLines = (blitsfc.height() - (mUpperBorderBmp.height() + mBottomBorderBmp.height()))/font.getPixelTextHeight();
for(int i=0 ; i<numLines ; i++)
for(int i=0 ; i < numLines ; i++)
{
mMinPos.push_back(mLeftBorderBmp.width());
mMaxPos.push_back(blitsfc.width() - (mLeftBorderBmp.width() + mRightBorderBmp.width() + 11) );
......@@ -168,9 +167,9 @@ void ComputerWrist::parseText()
{
GsWeakSurface blitsfc(gVideoDriver.getBlitSurface());
SDL_Rect lRect;
lRect.h = blitsfc.height();
lRect.w = blitsfc.width()-(mLeftBorderBmp.width()+mRightBorderBmp.width());
//SDL_Rect lRect;
//lRect.h = blitsfc.height();
//lRect.w = blitsfc.width()-(mLeftBorderBmp.width()+mRightBorderBmp.width());
// Draw some text.
GsFont &Font = gGraphics.getFont(mFontId);
......
......@@ -29,13 +29,12 @@ SettingsMenu::SettingsMenu() :
GalaxyMenu( GsRect<float>(0.25f, 0.24f, 0.5f, 0.40f) )
{
#if !defined(EMBEDDED)
mpMenuDialog->addControl(new GalaxyButton( "Video",
new OpenMenuEvent( new CVideoSettings() ) ) );
mpMenuDialog->addControl(new GalaxyButton( "Audio",
new OpenMenuEvent( new CAudioSettings() ) ) );
#endif
mpMenuDialog->addControl(new GalaxyButton( "Options",
new OpenMenuEvent( new COptions() ) ) );
......
......@@ -25,14 +25,18 @@ CAudioSettings::CAudioSettings() :
VorticonMenu(GsRect<float>(0.075f, 0.24f, 0.85f, 0.4f) )
{
#if !defined(EMBEDDED)
mpRate = new ComboSelection( "Rate", g_pSound->getAvailableRateList());
mpMenuDialog->addControl( mpRate );
#endif
mpStereo = new Switch( "Stereo" );
mpMenuDialog->addControl( mpStereo );
#if !defined(EMBEDDED)
mpDepth = new ComboSelection( "Depth", filledStrList( 2, "8-bit", "16-bit" ) );
mpMenuDialog->addControl( mpDepth );
#endif
mpSBToggle = new ComboSelection( "Card", filledStrList( 2, "PC Speaker", "Soundblaster" ) );
mpMenuDialog->addControl( mpSBToggle );
......@@ -52,9 +56,15 @@ void CAudioSettings::refresh()
mSoundblaster = g_pSound->getSoundBlasterMode();
mSoundVolume = mpSoundVolume->getSelection();
#if !defined(EMBEDDED)
mpRate->setSelection( itoa(mAudioSpec.freq) );
#endif
mpStereo->enable( mAudioSpec.channels == 2 );
#if !defined(EMBEDDED)
mpDepth->setSelection( mAudioSpec.format == AUDIO_U8 ? "8-bit" : "16-bit" );
#endif
mpSBToggle->setSelection( mSoundblaster ? "Soundblaster" : "PC Speaker" );
g_pMusicPlayer->play();
}
......@@ -76,9 +86,14 @@ void CAudioSettings::ponder(const float deltaT)
void CAudioSettings::release()
{