Ported services and sound, now just GUI left
This commit is contained in:
@@ -417,6 +417,12 @@
|
||||
<File
|
||||
RelativePath=".\src\include\DataModelV3\SelectionService.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\include\DataModelV3\SoundInstance.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\include\DataModelV3\SoundService.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\include\DataModelV3\WorkspaceInstance.h">
|
||||
</File>
|
||||
@@ -524,12 +530,6 @@
|
||||
<Filter
|
||||
Name="DataModelV2"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\BaseButtonInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\BaseGuiInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\DataModelInstance.cpp">
|
||||
<FileConfiguration
|
||||
@@ -560,12 +560,6 @@
|
||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\GuiRootInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\ImageButtonInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\Instance.cpp">
|
||||
<FileConfiguration
|
||||
@@ -638,15 +632,9 @@
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\SoundService.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\TextButtonInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ThumbnailGeneratorInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\ToggleImageButtonInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\WorkspaceInstance.cpp">
|
||||
<FileConfiguration
|
||||
@@ -662,9 +650,31 @@
|
||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\XplicitNgine\XplicitNgine.cpp">
|
||||
</File>
|
||||
<Filter
|
||||
Name="Gui"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\BaseButtonInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\BaseGuiInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\GuiRootInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\ImageButtonInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\TextButtonInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\ToggleImageButtonInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\XplicitNgine\XplicitNgine.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Helpers">
|
||||
@@ -730,6 +740,36 @@
|
||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV3\SoundInstance.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV3\SoundService.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV3\WorkspaceInstance.cpp">
|
||||
</File>
|
||||
|
||||
@@ -11,7 +11,7 @@ using namespace B3D;
|
||||
//#include "GuiRootInstance.h"
|
||||
//#include "ThumbnailGeneratorInstance.h"
|
||||
#include "XplicitNgine/XplicitNgine.h"
|
||||
//#include "SoundService.h"
|
||||
#include "SoundService.h"
|
||||
#include "LightingInstance.h"
|
||||
|
||||
// Libraries
|
||||
@@ -32,7 +32,7 @@ namespace B3D {
|
||||
LevelInstance* getLevel();
|
||||
XplicitNgine* getEngine();
|
||||
// ThumbnailGeneratorInstance* getThumbnailGenerator();
|
||||
// SoundService* getSoundService();
|
||||
SoundService* getSoundService();
|
||||
LightingInstance* getLighting();
|
||||
|
||||
std::string message;
|
||||
@@ -55,7 +55,7 @@ namespace B3D {
|
||||
SelectionService* selectionService;
|
||||
// ThumbnailGeneratorInstance* thumbnailGenerator;
|
||||
XplicitNgine* xplicitNgine;
|
||||
// SoundService* soundService;
|
||||
SoundService* soundService;
|
||||
LightingInstance* lightingInstance;
|
||||
bool running;
|
||||
|
||||
|
||||
30
src/include/DataModelV3/SoundInstance.h
Normal file
30
src/include/DataModelV3/SoundInstance.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include "Instance.h"
|
||||
namespace B3D{
|
||||
class SoundInstance : public Instance
|
||||
{
|
||||
public:
|
||||
SoundInstance(void);
|
||||
~SoundInstance(void);
|
||||
|
||||
// Getters
|
||||
float getSoundVolume();
|
||||
std::string getSoundId();
|
||||
bool isPlayedOnRemove();
|
||||
bool isLooped();
|
||||
|
||||
// Setters
|
||||
void setSoundVolume(float newVolume);
|
||||
void setSoundId(std::string newSoundId);
|
||||
void setIsPlayedOnRemove(bool isPlayed);
|
||||
void setIsLooped(bool isLooped);
|
||||
|
||||
// Functions
|
||||
void play();
|
||||
private:
|
||||
float soundVolume;
|
||||
std::string soundId;
|
||||
bool playOnRemove;
|
||||
bool looped;
|
||||
};
|
||||
}
|
||||
17
src/include/DataModelV3/SoundService.h
Normal file
17
src/include/DataModelV3/SoundService.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "Instance.h"
|
||||
#include "SoundInstance.h"
|
||||
namespace B3D
|
||||
{
|
||||
class SoundService : public Instance
|
||||
{
|
||||
public:
|
||||
SoundService(void);
|
||||
~SoundService(void);
|
||||
|
||||
float getMusicVolume();
|
||||
void playSound(Instance* sound);
|
||||
private:
|
||||
float musicVolume;
|
||||
};
|
||||
}
|
||||
@@ -12,7 +12,7 @@ DataModelInstance::DataModelInstance(void)
|
||||
//guiRoot = new GuiRootInstance();
|
||||
level = new LevelInstance();
|
||||
//thumbnailGenerator = new ThumbnailGeneratorInstance();
|
||||
//soundService = new SoundService();
|
||||
soundService = new SoundService();
|
||||
lightingInstance = new LightingInstance();
|
||||
|
||||
selectionService = new SelectionService();
|
||||
@@ -25,7 +25,7 @@ DataModelInstance::DataModelInstance(void)
|
||||
// Parent stuff
|
||||
workspace->setParent(this);
|
||||
level->setParent(this);
|
||||
//soundService->setParent(this);
|
||||
soundService->setParent(this);
|
||||
lightingInstance->setParent(this);
|
||||
|
||||
running = false;
|
||||
@@ -326,11 +326,11 @@ LevelInstance* DataModelInstance::getLevel()
|
||||
return thumbnailGenerator;
|
||||
}*/
|
||||
|
||||
//TODO implement
|
||||
/*SoundService* DataModelInstance::getSoundService()
|
||||
|
||||
SoundService* DataModelInstance::getSoundService()
|
||||
{
|
||||
return soundService;
|
||||
}*/
|
||||
}
|
||||
|
||||
//TODO implement
|
||||
LightingInstance* DataModelInstance::getLighting()
|
||||
|
||||
53
src/source/DataModelV3/SoundInstance.cpp
Normal file
53
src/source/DataModelV3/SoundInstance.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "DataModelV3/SoundInstance.h"
|
||||
#include "DataModelV3/DataModelInstance.h"
|
||||
|
||||
using namespace B3D;
|
||||
|
||||
SoundInstance::SoundInstance()
|
||||
{
|
||||
name = "Sound";
|
||||
|
||||
soundVolume = 0.5;
|
||||
soundId = "";
|
||||
playOnRemove = false;
|
||||
looped = false;
|
||||
}
|
||||
|
||||
SoundInstance::~SoundInstance(void)
|
||||
{
|
||||
if(isPlayedOnRemove())
|
||||
play();
|
||||
}
|
||||
|
||||
// Functions
|
||||
void SoundInstance::play()
|
||||
{
|
||||
parentDataModel->getSoundService()->playSound(this);
|
||||
}
|
||||
|
||||
// Getters
|
||||
float SoundInstance::getSoundVolume()
|
||||
{
|
||||
return soundVolume;
|
||||
}
|
||||
|
||||
bool SoundInstance::isPlayedOnRemove()
|
||||
{
|
||||
return playOnRemove;
|
||||
}
|
||||
|
||||
std::string SoundInstance::getSoundId()
|
||||
{
|
||||
return soundId;
|
||||
}
|
||||
|
||||
bool SoundInstance::isLooped()
|
||||
{
|
||||
return looped;
|
||||
}
|
||||
|
||||
// Setters
|
||||
void SoundInstance::setSoundId(std::string newSoundId)
|
||||
{
|
||||
soundId = newSoundId;
|
||||
}
|
||||
113
src/source/DataModelV3/SoundService.cpp
Normal file
113
src/source/DataModelV3/SoundService.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#include "DataModelV3/SoundService.h"
|
||||
#include "StringFunctions.h"
|
||||
#include "AudioPlayer.h"
|
||||
|
||||
using namespace B3D;
|
||||
SoundService::SoundService()
|
||||
{
|
||||
Instance::Instance("SoundService");
|
||||
name = "SoundService";
|
||||
musicVolume = 0.3f;
|
||||
canDelete = false;
|
||||
|
||||
// Create stock sounds
|
||||
SoundInstance* stockSound = new SoundInstance();
|
||||
|
||||
// Victory
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Victory");
|
||||
stockSound->setSoundId("/content/sounds/victory.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Boing
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Boing");
|
||||
stockSound->setSoundId("/content/sounds/bass.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Bomb
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Bomb");
|
||||
stockSound->setSoundId("/content/sounds/collide.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Ping
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Ping");
|
||||
stockSound->setSoundId("/content/sounds/electronicpingshort.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Break
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Break");
|
||||
stockSound->setSoundId("/content/sounds/glassbreak.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Splat
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Splat");
|
||||
stockSound->setSoundId("/content/sounds/splat.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Swoosh
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Swoosh");
|
||||
stockSound->setSoundId("/content/sounds/swoosh.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Snap
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Snap");
|
||||
stockSound->setSoundId("/content/sounds/snap.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Page
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Page");
|
||||
stockSound->setSoundId("/content/sounds/pageturn.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Click
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Click");
|
||||
stockSound->setSoundId("/content/sounds/switch.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Clock
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Clock");
|
||||
stockSound->setSoundId("/content/sounds/clickfast.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// Step
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("Step");
|
||||
stockSound->setSoundId("/content/sounds/SWITCH3.wav");
|
||||
stockSound->setParent(this);
|
||||
|
||||
// StepOn
|
||||
stockSound = new SoundInstance();
|
||||
stockSound->setName("StepOn");
|
||||
stockSound->setSoundId("/content/sounds/flashbulb.wav");
|
||||
stockSound->setParent(this);
|
||||
}
|
||||
|
||||
SoundService::~SoundService(void)
|
||||
{
|
||||
}
|
||||
|
||||
void SoundService::playSound(Instance* sound)
|
||||
{
|
||||
// Try to dynamic_cast it to SoundInstance
|
||||
SoundInstance* sndInst = dynamic_cast<SoundInstance*>(sound);
|
||||
if(sndInst != NULL)
|
||||
{
|
||||
std::string soundId = sndInst->getSoundId();
|
||||
AudioPlayer::playSound(GetFileInPath(soundId));
|
||||
}
|
||||
}
|
||||
|
||||
float SoundService::getMusicVolume()
|
||||
{
|
||||
return musicVolume;
|
||||
}
|
||||
Reference in New Issue
Block a user