mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-24 05:49:17 -06:00
Added scene selector in the SettingsEngine, in the GUI under Global Properties.
Has placeholder functionality for what's coming in the next commit.
This commit is contained in:
@@ -27,18 +27,24 @@
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SettingsEngine : public properties::PropertyOwner {
|
||||
public:
|
||||
SettingsEngine();
|
||||
SettingsEngine();
|
||||
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
properties::FloatProperty _eyeSeparation;
|
||||
void initEyeSeparation();
|
||||
void initSceneFiles();
|
||||
|
||||
properties::FloatProperty _eyeSeparation;
|
||||
properties::OptionProperty _scenes;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
#endif //#ifndef __SETTINGSENGINE_H__
|
||||
|
||||
@@ -416,6 +416,9 @@ bool OpenSpaceEngine::initialize() {
|
||||
ConfigurationManager::KeyShutdownCountdown, _shutdownWait
|
||||
);
|
||||
|
||||
// Initialize the SettingsEngine
|
||||
_settingsEngine->initialize();
|
||||
|
||||
// Load scenegraph
|
||||
Scene* sceneGraph = new Scene;
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
|
||||
@@ -25,17 +25,57 @@
|
||||
#include <openspace/engine/settingsengine.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/configurationmanager.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
|
||||
#include <ghoul/ghoul.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SettingsEngine::SettingsEngine() :
|
||||
_eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f)
|
||||
SettingsEngine::SettingsEngine()
|
||||
: _eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f)
|
||||
, _scenes("scenes", "Scene", properties::OptionProperty::DisplayType::DROPDOWN)
|
||||
{
|
||||
setName("Global Properties");
|
||||
}
|
||||
|
||||
void SettingsEngine::initialize() {
|
||||
initEyeSeparation();
|
||||
initSceneFiles();
|
||||
}
|
||||
|
||||
|
||||
void SettingsEngine::initEyeSeparation() {
|
||||
addProperty(_eyeSeparation);
|
||||
setName("Global");
|
||||
|
||||
// Set interaction to change the window's (SGCT's) eye separation
|
||||
_eyeSeparation.onChange(
|
||||
[this](){ OsEng.windowWrapper().setEyeSeparationDistance(_eyeSeparation); });
|
||||
[this]() { OsEng.windowWrapper().setEyeSeparationDistance(_eyeSeparation); });
|
||||
}
|
||||
|
||||
void SettingsEngine::initSceneFiles() {
|
||||
addProperty(_scenes);
|
||||
|
||||
// Load all matching files in the Scene
|
||||
// TODO: match regex with either with new ghoul readFiles or local code
|
||||
std::string sceneDir = "${SCENE}";
|
||||
std::vector<std::string> scenes = ghoul::filesystem::Directory(sceneDir).readFiles();
|
||||
for (std::size_t i = 0; i < scenes.size(); ++i) {
|
||||
_scenes.addOption(i, scenes[i]);
|
||||
}
|
||||
|
||||
// Set interaction to change ConfigurationManager and schedule the load
|
||||
_scenes.onChange(
|
||||
[this]() {
|
||||
std::string sceneFile = _scenes.getDescriptionByValue(_scenes);
|
||||
OsEng.configurationManager().setValue(
|
||||
ConfigurationManager::KeyConfigScene, sceneFile);
|
||||
std::cout << "For a relatively atomic commit, just pretending to load "
|
||||
<< sceneFile << std::endl;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user