r95 - trunk/src
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Wed Feb 23 10:06:42 EST 2005
Author: jonas
Date: 2005-02-23 10:06:42 -0500 (Wed, 23 Feb 2005)
New Revision: 95
Modified:
trunk/src/gfxeng.cpp
trunk/src/gfxeng.h
trunk/src/menu.cpp
trunk/src/menu.h
trunk/src/scenario.cpp
trunk/src/sfxeng.cpp
trunk/src/sfxeng.h
Log:
- Enhanced the ConfigMenu
- Improved the menu position code
- Introduced music playback functions, moved decision to Scenario (Map)
Modified: trunk/src/gfxeng.cpp
===================================================================
--- trunk/src/gfxeng.cpp 2005-02-23 12:47:07 UTC (rev 94)
+++ trunk/src/gfxeng.cpp 2005-02-23 15:06:42 UTC (rev 95)
@@ -294,9 +294,16 @@
Uint16 h;
for (Uint8 i=0; i< menu->getSize(); i++) {
if (i<=menu->currententry) {
- h=(screen->h+menu->font_title->getHeight()-(menu->getSize()-i-1)*DFONT-(menu->getSize()-i-1)*(menu->font->getHeight())-menu->font_high->getHeight())/2;
+ h=(screen->h+menu->font_title->getHeight()-(menu->getSize()-1)*DFONT-(menu->getSize()-1)*(menu->font->getHeight())-menu->font_high->getHeight())/2
+ -DFONT
+ +i*DFONT
+ +i*(menu->font->getHeight());
} else {
- h=(screen->h+menu->font_title->getHeight()-(menu->getSize()-i-1)*DFONT-(menu->getSize()-i)*(menu->font->getHeight()))/2;
+ h=(screen->h+menu->font_title->getHeight()-(menu->getSize()-1)*DFONT-(menu->getSize()-1)*(menu->font->getHeight())-menu->font_high->getHeight())/2
+ -DFONT
+ +i*DFONT
+ +(i-1)*(menu->font->getHeight())
+ +(menu->font_high->getHeight());
}
if (i==menu->currententry) menu->font_high->writeCenter(screen,menu->entries[i],h);
else menu->font->writeCenter(screen,menu->entries[i],h);
Modified: trunk/src/gfxeng.h
===================================================================
--- trunk/src/gfxeng.h 2005-02-23 12:47:07 UTC (rev 94)
+++ trunk/src/gfxeng.h 2005-02-23 15:06:42 UTC (rev 95)
@@ -3,7 +3,7 @@
#define BAR_HEIGHT 138
#define ICON_SIZE 46
-#define DFONT 40
+#define DFONT 10
#define UPDATE_NOTHING 0x00
#define UPDATE_BAR 0x01
@@ -16,7 +16,7 @@
frames per seconds. Always run time resizing and fullscreen switching.
*/
class GraphicsEngine {
- friend class ConfigMenu;
+ friend class GraphicConfigMenu;
public:
GraphicsEngine();
~GraphicsEngine();
Modified: trunk/src/menu.cpp
===================================================================
--- trunk/src/menu.cpp 2005-02-23 12:47:07 UTC (rev 94)
+++ trunk/src/menu.cpp 2005-02-23 15:06:42 UTC (rev 95)
@@ -139,17 +139,70 @@
ConfigMenu::ConfigMenu(): Menu() {
title="-== CONFIGURATION MENU ==-";
- entries.resize(2);
+ entries.resize(3);
update();
}
void ConfigMenu::act() {
switch (currententry) {
case 0: {
+ setMenu(new GraphicConfigMenu());
+ break;
+ }
+ case 1: {
+ setMenu(new KeyConfigMenu());
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+}
+void ConfigMenu::update() {
+ entries[0]="Graphic settings";
+ entries[1]="Keyboard settings";
+ entries[2]="Save settings";
+}
+
+
+KeyConfigMenu::KeyConfigMenu(): Menu() {
+ title="-== KEYBOARD SETTINGS ==-";
+ entries.resize(11);
+ update();
+}
+void KeyConfigMenu::act() { }
+void KeyConfigMenu::update() {
+ entries[0]="Move left: [" + string(SDL_GetKeyName(config.keybind[KEY_LEFT])) + "]";
+ entries[1]="Move right: [" + string(SDL_GetKeyName(config.keybind[KEY_RIGHT])) + "]";
+ entries[2]="Move up: [" + string(SDL_GetKeyName(config.keybind[KEY_UP])) + "]";
+ entries[3]="Move down: [" + string(SDL_GetKeyName(config.keybind[KEY_DOWN])) + "]";
+ entries[4]="Special 1: [" + string(SDL_GetKeyName(config.keybind[KEY_SP1])) + "]";
+ entries[5]="Special 2: [" + string(SDL_GetKeyName(config.keybind[KEY_SP2])) + "]";
+ entries[6]="Activate: [" + string(SDL_GetKeyName(config.keybind[KEY_ACT])) + "]";
+ entries[7]="Use item: [" + string(SDL_GetKeyName(config.keybind[KEY_USE])) + "]";
+ entries[8]="Switch player: [" + string(SDL_GetKeyName(config.keybind[KEY_SWITCH])) + "]";
+ entries[9]="Drop item: [" + string(SDL_GetKeyName(config.keybind[KEY_DROP])) + "]";
+ entries[10]="Pause game: [" + string(SDL_GetKeyName(config.keybind[KEY_PAUSE])) + "]";
+}
+
+
+GraphicConfigMenu::GraphicConfigMenu(): Menu() {
+ title="-== GRAPHIC SETTINGS ==-";
+ entries.resize(4);
+ update();
+}
+void GraphicConfigMenu::act() {
+ switch (currententry) {
+ case 1: {
+ gfxeng->toggleFullScreen();
+ gfxeng->update(UPDATE_ALL);
+ break;
+ }
+ case 2: {
gfxeng->toggleFPS();
gfxeng->update(UPDATE_MENU);
break;
}
- case 1: {
+ case 3: {
gfxeng->togglePlayerBar();
gfxeng->update(UPDATE_ALL);
break;
@@ -160,8 +213,9 @@
}
update();
}
-void ConfigMenu::update() {
- entries[0]="Show FPS: "+string((gfxeng->show_fps) ? "ON" : "OFF");
- entries[1]="Show Player Bar: "+string((gfxeng->show_bar) ? "ON" : "OFF");
+void GraphicConfigMenu::update() {
+ entries[0]="Resolution: " + itos(gfxeng->screen->w) + " x " + itos(gfxeng->screen->h) + " (" + itos(config.bpp) + " bpp)";
+ entries[1]="Fullscreen: " + string((gfxeng->fullscreen) ? "ON" : "OFF");
+ entries[2]="Show FPS: "+string((gfxeng->show_fps) ? "ON" : "OFF");
+ entries[3]="Show Player Bar: "+string((gfxeng->show_bar) ? "ON" : "OFF");
}
-
Modified: trunk/src/menu.h
===================================================================
--- trunk/src/menu.h 2005-02-23 12:47:07 UTC (rev 94)
+++ trunk/src/menu.h 2005-02-23 15:06:42 UTC (rev 95)
@@ -80,4 +80,22 @@
void update();
};
+class GraphicConfigMenu : public Menu {
+ public:
+ GraphicConfigMenu();
+ virtual void act();
+ private:
+ /// Helper function
+ void update();
+};
+
+class KeyConfigMenu : public Menu {
+ public:
+ KeyConfigMenu();
+ virtual void act();
+ private:
+ /// Helper function
+ void update();
+};
+
#endif
Modified: trunk/src/scenario.cpp
===================================================================
--- trunk/src/scenario.cpp 2005-02-23 12:47:07 UTC (rev 94)
+++ trunk/src/scenario.cpp 2005-02-23 15:06:42 UTC (rev 95)
@@ -3,6 +3,7 @@
#include "players_common.h"
#include "imgcache.h"
#include "sndcache.h"
+#include "sfxeng.h"
#include "physics.h"
#include "scenario.h"
@@ -53,6 +54,7 @@
int Scenario::loadMap(string mapname) {
reinitMap();
+ sfxeng->playMusic((config.datadir + "01theme.wav").c_str());
name=mapname;
ifstream mapfile;
string tmpline;
Modified: trunk/src/sfxeng.cpp
===================================================================
--- trunk/src/sfxeng.cpp 2005-02-23 12:47:07 UTC (rev 94)
+++ trunk/src/sfxeng.cpp 2005-02-23 15:06:42 UTC (rev 95)
@@ -14,10 +14,7 @@
cout << "Opened audio at " << config.audio_rate << " Hz " << (config.audio_format&0xFF) << " bit " << ((config.audio_channels > 1) ? "stereo" : "mono") << endl;
disabled=false;
}
-
- if (!disabled) theme = Mix_LoadMUS("data/01theme.wav");
- if (!disabled) Mix_FadeInMusic(theme, -1, 5000);
- if (!disabled) Mix_VolumeMusic(MIX_MAX_VOLUME/4);
+ theme=NULL;
#endif
}
@@ -29,6 +26,24 @@
}
#endif
}
+void SoundsEngine::playMusic(string name) {
+#ifdef SDL_MIXER
+ if (!disabled) {
+ if (theme) Mix_FreeMusic(theme);
+ theme = Mix_LoadMUS(name.c_str());
+ Mix_FadeInMusic(theme, -1, 5000);
+ Mix_VolumeMusic(MIX_MAX_VOLUME/4);
+ }
+#endif
+}
+void SoundsEngine::stopMusic() {
+#ifdef SDL_MIXER
+ if (!disabled) {
+ if (theme) Mix_FreeMusic(theme);
+ theme=NULL;
+ }
+#endif
+}
void SoundsEngine::pauseMusic() {
#ifdef SDL_MIXER
if (!disabled) Mix_PauseMusic();
Modified: trunk/src/sfxeng.h
===================================================================
--- trunk/src/sfxeng.h 2005-02-23 12:47:07 UTC (rev 94)
+++ trunk/src/sfxeng.h 2005-02-23 15:06:42 UTC (rev 95)
@@ -12,6 +12,8 @@
~SoundsEngine();
/// Play the specified sound
void playWAV(Mix_Chunk* wav);
+ void playMusic(string);
+ void stopMusic();
void pauseMusic();
void resumeMusic();
private:
More information about the lostpenguins-commits
mailing list