sound volumes are now read from and saved to config.rc + bugfix
- fixed calling of IMGUIClear() when the view state changed (was previously called only when the game state changed)main
parent
33683e817d
commit
b8f0ed31e3
|
@ -10,6 +10,7 @@ Makefile
|
||||||
start
|
start
|
||||||
runtests
|
runtests
|
||||||
run_asteroids
|
run_asteroids
|
||||||
|
config.rc
|
||||||
|
|
||||||
./doc/html/*
|
./doc/html/*
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ BEGIN_ENUM(Event)
|
||||||
DECL_ENUM_ELEMENT(EventAccelerateStart),
|
DECL_ENUM_ELEMENT(EventAccelerateStart),
|
||||||
DECL_ENUM_ELEMENT(EventAccelerateStop),
|
DECL_ENUM_ELEMENT(EventAccelerateStop),
|
||||||
DECL_ENUM_ELEMENT(EventLevelComplete),
|
DECL_ENUM_ELEMENT(EventLevelComplete),
|
||||||
DECL_ENUM_ELEMENT(EventChangeGameState),
|
DECL_ENUM_ELEMENT(EventChangeViewState),
|
||||||
DECL_ENUM_ELEMENT(EventGameOver),
|
DECL_ENUM_ELEMENT(EventGameOver),
|
||||||
DECL_ENUM_ELEMENT(EventShipExplode),
|
DECL_ENUM_ELEMENT(EventShipExplode),
|
||||||
DECL_ENUM_ELEMENT(EventPlayerDied),
|
DECL_ENUM_ELEMENT(EventPlayerDied),
|
||||||
|
|
|
@ -17,13 +17,13 @@ int Controller::OnInit (int argc, char *argv[]) {
|
||||||
mBindings[SDLK_F8] = "toggleconsole";
|
mBindings[SDLK_F8] = "toggleconsole";
|
||||||
mBindings[SDLK_F9] = "set playerspeed 5.0";
|
mBindings[SDLK_F9] = "set playerspeed 5.0";
|
||||||
|
|
||||||
Engine::RegisterListener (this, EventChangeGameState);
|
Engine::RegisterListener (this, EventChangeViewState);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Controller::OnReceiveEvent (const Engine::EventBasePtr &event) {
|
bool Controller::OnReceiveEvent (const Engine::EventBasePtr &event) {
|
||||||
if (event->mEventType == EventChangeGameState) {
|
if (event->mEventType == EventChangeViewState) {
|
||||||
IMGUIClear();
|
IMGUIClear();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -374,11 +374,6 @@ void Model::ProceedToNextLevel () {
|
||||||
|
|
||||||
void Model::SetGameState (const unsigned int &state) {
|
void Model::SetGameState (const unsigned int &state) {
|
||||||
mLastGameState = mGameState;
|
mLastGameState = mGameState;
|
||||||
|
|
||||||
Engine::EventBasePtr changegamestate_event (new Engine::EventBase());
|
|
||||||
changegamestate_event->mEventType = EventChangeGameState;
|
|
||||||
QueueEvent (changegamestate_event);
|
|
||||||
|
|
||||||
mGameState = state;
|
mGameState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -664,21 +664,18 @@ void View::DrawUiOptions() {
|
||||||
DrawPageTitle ("Options");
|
DrawPageTitle ("Options");
|
||||||
SelectFont ("console.ttf size=23");
|
SelectFont ("console.ttf size=23");
|
||||||
|
|
||||||
// Enter your name
|
Engine::GUI::Label (10, "Effects Volume: ", screen_right * 0.5 - 150, 240);
|
||||||
std::string player_name = GetModel()->GetPlayerName();
|
|
||||||
|
|
||||||
Engine::GUI::Label (1, "Effects Volume: ", screen_right * 0.5 - 150, 240);
|
|
||||||
|
|
||||||
float effects_volume = Engine::GetEffectsVolume();
|
float effects_volume = Engine::GetEffectsVolume();
|
||||||
if (Engine::GUI::VerticalSlider (2, screen_right * 0.5 - 100, 250, 250, 16, 0., 1., effects_volume)) {
|
if (Engine::GUI::VerticalSlider (1, screen_right * 0.5 - 100, 250, 250, 16, 0., 1., effects_volume)) {
|
||||||
Engine::LogDebug ("Setting effects volume to: %f", effects_volume);
|
Engine::LogDebug ("Setting effects volume to: %f", effects_volume);
|
||||||
Engine::SetEffectsVolume(effects_volume);
|
Engine::SetEffectsVolume(effects_volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::GUI::Label (3, "Music Volume: ", screen_right * 0.5 - 150, 300);
|
Engine::GUI::Label (11, "Music Volume: ", screen_right * 0.5 - 150, 300);
|
||||||
|
|
||||||
float music_volume = Engine::GetMusicVolume();
|
float music_volume = Engine::GetMusicVolume();
|
||||||
if (Engine::GUI::VerticalSlider (4, screen_right * 0.5 - 100, 310, 250, 16, 0., 1., music_volume)) {
|
if (Engine::GUI::VerticalSlider (2, screen_right * 0.5 - 100, 310, 250, 16, 0., 1., music_volume)) {
|
||||||
Engine::LogDebug ("Setting music volume to: %f", music_volume);
|
Engine::LogDebug ("Setting music volume to: %f", music_volume);
|
||||||
Engine::SetMusicVolume(music_volume);
|
Engine::SetMusicVolume(music_volume);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,11 @@ class View : public Engine::ViewBase {
|
||||||
void PushViewState (const ViewState state) {
|
void PushViewState (const ViewState state) {
|
||||||
Engine::LogDebug ("Pushing ViewState %s", GetStringViewState(state));
|
Engine::LogDebug ("Pushing ViewState %s", GetStringViewState(state));
|
||||||
mViewStateStack.push(state);
|
mViewStateStack.push(state);
|
||||||
|
|
||||||
|
// Fire the view state change event to properly clear the IMGUI state
|
||||||
|
Engine::EventBasePtr changeviewstate_event (new Engine::EventBase());
|
||||||
|
changeviewstate_event->mEventType = EventChangeViewState;
|
||||||
|
QueueEvent (changeviewstate_event);
|
||||||
}
|
}
|
||||||
/** \brief Returns the current ViewState */
|
/** \brief Returns the current ViewState */
|
||||||
ViewState GetViewState () {
|
ViewState GetViewState () {
|
||||||
|
@ -92,12 +97,22 @@ class View : public Engine::ViewBase {
|
||||||
current_name = GetStringViewState(mViewStateStack.top());
|
current_name = GetStringViewState(mViewStateStack.top());
|
||||||
|
|
||||||
Engine::LogDebug("Popped ViewState: %s current %s remaining: %u", popped_name.c_str(), current_name.c_str(), mViewStateStack.size());
|
Engine::LogDebug("Popped ViewState: %s current %s remaining: %u", popped_name.c_str(), current_name.c_str(), mViewStateStack.size());
|
||||||
|
|
||||||
|
// Fire the view state change event to properly clear the IMGUI state
|
||||||
|
Engine::EventBasePtr changeviewstate_event (new Engine::EventBase());
|
||||||
|
changeviewstate_event->mEventType = EventChangeViewState;
|
||||||
|
QueueEvent (changeviewstate_event);
|
||||||
}
|
}
|
||||||
/** \brief Removes all elements of the ViewState stack */
|
/** \brief Removes all elements of the ViewState stack */
|
||||||
void ResetViewState() {
|
void ResetViewState() {
|
||||||
Engine::LogDebug ("Resetting ViewState stack");
|
Engine::LogDebug ("Resetting ViewState stack");
|
||||||
while (mViewStateStack.size())
|
while (mViewStateStack.size())
|
||||||
mViewStateStack.pop();
|
mViewStateStack.pop();
|
||||||
|
|
||||||
|
// Fire the view state change event to properly clear the IMGUI state
|
||||||
|
Engine::EventBasePtr changeviewstate_event (new Engine::EventBase());
|
||||||
|
changeviewstate_event->mEventType = EventChangeViewState;
|
||||||
|
QueueEvent (changeviewstate_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// \todo [high] add Resource Manager!
|
// \todo [high] add Resource Manager!
|
||||||
|
|
|
@ -44,14 +44,18 @@ int main (int argc, char* argv[]) {
|
||||||
engine.GetView()->SetGridSize (8,8);
|
engine.GetView()->SetGridSize (8,8);
|
||||||
dynamic_cast<asteroids::Physics*>(engine.GetPhysics())->SetWorldSize (28, 20);
|
dynamic_cast<asteroids::Physics*>(engine.GetPhysics())->SetWorldSize (28, 20);
|
||||||
|
|
||||||
|
// run the default commands and load the configuration
|
||||||
Engine::RunCommand ("exec asteroids.rc");
|
Engine::RunCommand ("exec asteroids.rc");
|
||||||
|
Engine::RunCommand ("exec config.rc");
|
||||||
Engine::LogMessage("Warning: muting sound!");
|
|
||||||
Engine::SetEffectsVolume(0.);
|
|
||||||
Engine::SetMusicVolume(0.);
|
|
||||||
|
|
||||||
engine.MainLoop ();
|
engine.MainLoop ();
|
||||||
|
|
||||||
|
// save the configuration
|
||||||
|
std::ofstream config_file ("config.rc");
|
||||||
|
config_file << "set effects_volume " << Engine::GetEffectsVolume() << std::endl;
|
||||||
|
config_file << "set music_volume " << Engine::GetMusicVolume() << std::endl;
|
||||||
|
config_file.close();
|
||||||
|
|
||||||
SDL_WM_SetIcon(NULL,NULL);
|
SDL_WM_SetIcon(NULL,NULL);
|
||||||
SDL_FreeSurface (image);
|
SDL_FreeSurface (image);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "Variables.h"
|
#include "Variables.h"
|
||||||
|
#include "SoundBaseGlobal.h"
|
||||||
|
|
||||||
namespace Engine {
|
namespace Engine {
|
||||||
|
|
||||||
|
@ -8,6 +9,19 @@ bool Cmd_Set (const std::vector<std::string> args) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special variable sound_volume
|
||||||
|
if (args[0] == "effects_volume") {
|
||||||
|
SetEffectsVolume(atof(args[1].c_str()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// special variable music_volume
|
||||||
|
if (args[0] == "music_volume") {
|
||||||
|
SetMusicVolume(atof(args[1].c_str()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Variable *test = GetVariable (args[0]);
|
Variable *test = GetVariable (args[0]);
|
||||||
if (test) {
|
if (test) {
|
||||||
test->SetStringValue (args[1]);
|
test->SetStringValue (args[1]);
|
||||||
|
|
|
@ -72,7 +72,6 @@
|
||||||
* todos within the code have a look at the \ref todo.
|
* todos within the code have a look at the \ref todo.
|
||||||
*
|
*
|
||||||
* \todo [high] Create a simple racing or asteroids game
|
* \todo [high] Create a simple racing or asteroids game
|
||||||
* \todo [high] Enable saving of music and effects volume
|
|
||||||
* \todo [med] Use shared_ptr instead of raw pointers for the Entities
|
* \todo [med] Use shared_ptr instead of raw pointers for the Entities
|
||||||
* \todo [med] Clear all references of EntityVisualState and EntityGameState
|
* \todo [med] Clear all references of EntityVisualState and EntityGameState
|
||||||
* \todo [med] Clarify functionalities of CreateEntity, KillEntity, RegisterEntity, UnregisterEntity (which frees memory, which does only change the state of the Model?)
|
* \todo [med] Clarify functionalities of CreateEntity, KillEntity, RegisterEntity, UnregisterEntity (which frees memory, which does only change the state of the Model?)
|
||||||
|
@ -88,9 +87,10 @@
|
||||||
* Engine::Module::Init()
|
* Engine::Module::Init()
|
||||||
*
|
*
|
||||||
* Done:
|
* Done:
|
||||||
|
* \todo [high] (28-11-2010) Enable saving of music and effects volume
|
||||||
* \todo [high] (28-11-2010) Allow transitions when player dies
|
* \todo [high] (28-11-2010) Allow transitions when player dies
|
||||||
* \todo [high] (11-09-2010) Since introduction of the IMGUI pressing 'space' in the menu crashes the game
|
* \todo [high] (11-09-2010) Since introduction of the IMGUI pressing 'space' in the menu crashes the game
|
||||||
* - [high] In Physics remove dependancy on the Model to pass on collision
|
* - [high] In Physics remove dependancy on the Model to pass on collision
|
||||||
* events
|
* events
|
||||||
* - [high] Fix Physics bug when two actors collide actively (i.e. velocity
|
* - [high] Fix Physics bug when two actors collide actively (i.e. velocity
|
||||||
* towards each other)
|
* towards each other)
|
||||||
|
|
Loading…
Reference in New Issue