Commit d1326a92 authored by Mike Kremer's avatar Mike Kremer
Browse files

Default light sources won't be added to ini file anymore when saving settings.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9204 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0f2471ea
......@@ -83,7 +83,8 @@ LightObject::LightObject( ) :
* Copy Constructor - generates a copy of the given object
*/
LightObject::LightObject(const LightObject & _object) :
BaseObjectData(_object)
BaseObjectData(_object),
defaultLightSource_(false)
{
init(_object.lightNode_);
......
......@@ -79,9 +79,19 @@ class DLLEXPORT LightObject : public BaseObjectData {
*/
virtual void update(UpdateType _type = UPDATE_ALL);
/// Is light default light source?
bool defaultLight() const { return defaultLightSource_; }
/// Set light object to be default light
void defaultLight( const bool _default ) { defaultLightSource_ = _default; }
private:
LightSource lightSource_;
/// True if light is default light source initially
/// added to a blank scene
bool defaultLightSource_;
/** @} */
//===========================================================================
......
......@@ -61,6 +61,8 @@
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/common/RecentFiles.hh>
#include <ObjectTypes/Light/Light.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <QFile>
......@@ -704,6 +706,14 @@ void Core::writeIniFile(QString _filename,
for ( PluginFunctions::ObjectIterator o_it(restriction) ;
o_it != PluginFunctions::objectsEnd(); ++o_it) {
QString file = o_it->path() + OpenFlipper::Options::dirSeparator() + o_it->name();
// Don't save default light source objects
LightObject* light = 0;
PluginFunctions::getObject( o_it->id(), light );
if(light != 0) {
if(light->defaultLight()) continue;
}
if (QFile(file).exists()){
// Add a section for this object
sectionName = o_it->name();
......@@ -729,8 +739,16 @@ void Core::writeIniFile(QString _filename,
// Tell plugins to save their information for the given object
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ;
o_it != PluginFunctions::objectsEnd(); ++o_it)
o_it != PluginFunctions::objectsEnd(); ++o_it) {
// Don't save default light source objects
LightObject* light = 0;
PluginFunctions::getObject( o_it->id(), light );
if(light != 0) {
if(light->defaultLight()) continue;
}
emit iniSave( ini , o_it->id() );
}
}
......
......@@ -45,6 +45,8 @@
#include "OpenFlipper/common/GlobalOptions.hh"
#include <ObjectTypes/Light/Light.hh>
#include "OpenFlipper/BasePlugin/PluginFunctions.hh"
#include "OpenFlipper/widgets/loadWidget/loadWidget.hh"
......@@ -210,6 +212,13 @@ void Core::saveSettings(){
filename += "obj";
}
}
// Don't save default light source objects
LightObject* light = 0;
PluginFunctions::getObject( o_it->id(), light );
if(light != 0) {
if(light->defaultLight()) continue;
}
// decide whether to use saveObject or saveObjectTo
if ( !QFile(filename).exists() || !askOverwrite->isChecked() )
......
......@@ -181,10 +181,12 @@ int TypeLightPlugin::addDefaultLight(QString _name) {
// call the local function to update names
object->setName( _name );
object->defaultLight(true);
object->update();
object->hide();
emit emptyObjectAdded (object->id() );
return object->id();
......@@ -201,6 +203,8 @@ int TypeLightPlugin::addEmpty() {
QFileInfo f(name);
object->setName( f.fileName() );
object->defaultLight(false);
object->update();
object->hide();
......@@ -223,9 +227,7 @@ void TypeLightPlugin::addedEmptyObject(int _id) {
if(!light) return;
// Skip default light sources
if(light->name() == DEF0) return;
if(light->name() == DEF1) return;
if(light->name() == DEF2) return;
if(light->defaultLight()) return;
removeDefaultLights();
lightSources_.push_back(_id);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment