From 46f714e3ccb1949706c734944b4ecc3adde0dec3 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 2 Feb 2012 16:35:12 +0000 Subject: settings with defaults --- bin/data/settings.xml | 6 ++++-- map4.cbp | 3 +++ map4.layout | 9 ++++++--- src/main.cpp | 2 +- src/testApp.cpp | 23 +++++++++++++---------- src/testApp.h | 4 ++-- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/bin/data/settings.xml b/bin/data/settings.xml index 3ef31a3..47e851e 100644 --- a/bin/data/settings.xml +++ b/bin/data/settings.xml @@ -1,9 +1,11 @@ - + - + + + diff --git a/map4.cbp b/map4.cbp index 154fa93..c0eaebd 100644 --- a/map4.cbp +++ b/map4.cbp @@ -111,6 +111,9 @@ + + diff --git a/map4.layout b/map4.layout index 75b17ee..2967843 100644 --- a/map4.layout +++ b/map4.layout @@ -4,6 +4,9 @@ + + + @@ -11,7 +14,7 @@ - + @@ -19,8 +22,8 @@ - - + + diff --git a/src/main.cpp b/src/main.cpp index a0adc83..15650ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,7 +17,7 @@ int main( ){ ofAppGlutWindow window; - //ofSetupOpenGL(&window, 2048,768, OF_FULLSCREEN); // <-------- setup the GL context + //ofSetupOpenGL(&window, 1024,768, OF_FULLSCREEN); // <-------- setup the GL context ofSetupOpenGL(&window, 1024,300, OF_WINDOW); glutIgnoreKeyRepeat(1); glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); //these don't work!!! diff --git a/src/testApp.cpp b/src/testApp.cpp index 37717fa..f8078fb 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -1,7 +1,7 @@ #include "testApp.h" //-------------------------------------------------------------- testApp::~testApp(){ - saveSettings(); + saveSettings("settings.xml"); } //-------------------------------------------------------------- void testApp::setup(){ @@ -23,12 +23,12 @@ void testApp::setup(){ //ofDisableArbTex(); - texture.loadMovie("gradblend01.mov"); + texture.loadMovie("stripey2.mov"); texture.play(); mode=CALIBRATE; - loadSettings(); + loadSettings("settings.xml"); light=true; } @@ -99,8 +99,10 @@ void testApp::keyPressed(int key){ activeView=1; break; case 'p': - saveSettings(); - printf("saved settings.xml\n"); + saveSettings("settings.xml"); + break; + case 'z': + loadSettings("defaults.xml"); break; case '/': light=!light; @@ -110,10 +112,10 @@ void testApp::keyPressed(int key){ } } -void testApp::loadSettings(){ +void testApp::loadSettings(string filename){ //viewport settings are float/ normalised to 0..1 - if( !XML.loadFile("settings.xml") ){ - printf("unable to load settings.xml check data/ folder\n"); + if( !XML.loadFile(filename) ){ + printf("unable to load %s check data/ folder\n",filename.c_str()); }else{ if(XML.pushTag("map4")) { numViews=XML.getNumTags("view"); @@ -142,7 +144,7 @@ void testApp::loadSettings(){ //activeView=0; } //-------------------------------------------------------------- -void testApp::saveSettings(){ +void testApp::saveSettings(string filename){ //either re-navigate the whole thing OR //save the number to the vp OR //send a pointer to the vp @@ -160,7 +162,8 @@ void testApp::saveSettings(){ } XML.popTag(); } - XML.saveFile("settings.xml"); + XML.saveFile(filename); + printf("saved %s\n",filename.c_str()); } //-------------------------------------------------------------- void testApp::keyReleased(int key){ diff --git a/src/testApp.h b/src/testApp.h index 07c043f..d0710e2 100644 --- a/src/testApp.h +++ b/src/testApp.h @@ -39,8 +39,8 @@ class testApp : public ofBaseApp{ void update(); void draw(); - void loadSettings(); - void saveSettings(); + void loadSettings(string filename); + void saveSettings(string filename); void keyPressed (int key); void keyReleased(int key); void mouseMoved(int x, int y ); -- cgit v1.2.3