diff --git a/example/bin/data/magslideshow_settings.xml b/example/bin/data/magslideshow_settings.xml
new file mode 100644
index 0000000..e16b25b
--- /dev/null
+++ b/example/bin/data/magslideshow_settings.xml
@@ -0,0 +1,11 @@
+
+ 1920
+ 1080
+ 1
+
+ PING-PONG
+
+
+
+ FitProportionally
+
\ No newline at end of file
diff --git a/example/bin/data/ofxpimapper.xml b/example/bin/data/ofxpimapper.xml
index 46b5816..b9b1861 100644
--- a/example/bin/data/ofxpimapper.xml
+++ b/example/bin/data/ofxpimapper.xml
@@ -73,31 +73,9 @@
fbo
Slide Show Source
-
- 1920
- 1080
- 1
-
- PING-PONG
-
-
-
- FitProportionally
-
1
-
- 1920
- 1080
- 1
-
- PING-PONG
-
-
-
- FitProportionally
-
diff --git a/example/src/ofApp.cpp b/example/src/ofApp.cpp
index e691269..d4d9395 100644
--- a/example/src/ofApp.cpp
+++ b/example/src/ofApp.cpp
@@ -18,26 +18,12 @@ void ofApp::setup(){
// Create the slide show source.
slideShowSource = new magSlideShowSource();
- // Create the settings struct for the slide show.
-
- // Initialize the slide show with our settings.
- // If it fails, initialize from default settings
-
-
// Register our sources:
piMapper.registerFboSource(crossSource);
piMapper.registerFboSource(customSource);
piMapper.registerFboSource(slideShowSource);
piMapper.setup();
- // Slide show needs to be loaded after piMapper is set up:
- if (!slideShowSource->loadFromXml())
- {
- ofLogNotice("setup") << "loading magSlideShowSource XML settings failed. Initializing from default values";
- magSlideShowSource::Settings sets;
- slideShowSource->initialize(sets);
- }
-
// The info layer is hidden by default, press to toggle
// piMapper.showInfo();
diff --git a/src/Sources/magSlideShowSource.cpp b/src/Sources/magSlideShowSource.cpp
index 437047f..a3367a1 100644
--- a/src/Sources/magSlideShowSource.cpp
+++ b/src/Sources/magSlideShowSource.cpp
@@ -10,12 +10,20 @@
#include "SettingsLoader.h"
#include "magSlideTransitionFactory.h"
+const std::string magSlideShowSource::SettingsFileName = "magslideshow_settings.xml";
+
magSlideShowSource::magSlideShowSource() {
name = "Slide Show Source";
currentSlideIndex = 0;
isPlaying = false;
directoryWatcher = 0;
doInit = false;
+ if (!loadFromXml(SettingsFileName))
+ {
+ ofLogError("magSlideShowSource") << "Could not find slide show settings file " << SettingsFileName;
+ Settings sets;
+ initialize(sets);
+ }
}
magSlideShowSource::~magSlideShowSource() {
@@ -218,21 +226,20 @@ bool magSlideShowSource::createFromFolderContents(std::string path) {
}
}
-bool magSlideShowSource::loadFromXml() {
- auto *loader = ofx::piMapper::SettingsLoader::instance();
+bool magSlideShowSource::loadFromXml(std::string path) {
auto xml = ofxXmlSettings();
Settings settings;
- if (!xml.load(loader->getLastLoadedFilename()))
+ if (!xml.load(path))
{
- ofLogError("magSlideShowSource") << "Could not load settings file " << loader->getLastLoadedFilename();
+ ofLogError("magSlideShowSource") << "Could not load settings file " << path;
return false;
}
- xml.pushTag("surfaces");
+// xml.pushTag("surfaces");
if (!xml.pushTag("magSlideShow"))
{
- ofLogError("magSlideShowSource") << "Slide show settings not found in " << loader->getLastLoadedFilename();
+ ofLogError("magSlideShowSource") << "Slide show settings not found in " << path;
return false;
}
@@ -349,20 +356,18 @@ void magSlideShowSource::addSlide(std::shared_ptr slide) {
// Add transitions:
- if (!settings.transitionName.empty())
- {
- static ofParameterGroup bogusParamGroup; // This is temporary so that things compile
+ static ofParameterGroup bogusParamGroup; // This is temporary so that things compile
- auto tf = magSlideTransitionFactory::instance();
+ auto tf = magSlideTransitionFactory::instance();
// slide->buildIn = tf->createTransition(settings.transitionName,
// slide,
// bogusParamGroup,
// slide->buildInDuration);
- slide->transition = tf->createTransition(settings.transitionName,
- slide,
- bogusParamGroup,
- slide->buildOutDuration);
- }
+ slide->transition = tf->createTransition(settings.transitionName,
+ slide,
+ bogusParamGroup,
+ slide->buildOutDuration);
+
//// void method(const void * sender, ArgumentsType &args)
ofAddListener(slide->slideStateChangedEvent, this, &magSlideShowSource::slideStateChanged);
ofAddListener(slide->slideCompleteEvent, this, &magSlideShowSource::slideComplete);
diff --git a/src/Sources/magSlideShowSource.h b/src/Sources/magSlideShowSource.h
index 3f58a2f..e82b158 100644
--- a/src/Sources/magSlideShowSource.h
+++ b/src/Sources/magSlideShowSource.h
@@ -17,6 +17,11 @@ class magSlide;
class magSlideShowSource : public ofx::piMapper::FboSource {
public:
magSlideShowSource();
+
+ /**
+ * Default settings file name.
+ */
+ static const std::string SettingsFileName;
struct Settings; // forward declaration
bool initialize(magSlideShowSource::Settings settings);
void setup() override;
@@ -35,8 +40,7 @@ class magSlideShowSource : public ofx::piMapper::FboSource {
* otherwise. Check the console for the specific error.
*/
bool createFromFolderContents(std::string path);
-
- bool loadFromXml();
+ bool loadFromXml(std::string path);
void addSlide(std::shared_ptr slide);
void play();
void pause();
@@ -67,15 +71,14 @@ class magSlideShowSource : public ofx::piMapper::FboSource {
float slideDuration = 5;
/**
- * An optional default transition for the slide show.
+ * The default transition for the slide show.
*/
- std::string transitionName = "";
+ std::string transitionName = "Dissolve";
/**
- * An optional default transition duration. If no transition
- * is specified, this value is ignored;
+ * Default transition duration.
*/
- float transitionDuration = 0;
+ float transitionDuration = 1;
/**
* If specified, all applicable files in the folder will