From bbec14d904543026f250096899ac2ea1b0306a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Wed, 19 Aug 2015 22:07:44 +0200 Subject: [PATCH] Fixed atmosphere saving to file --- .gitignore | 1 + src/definition/AtmosphereDefinition.cpp | 6 ++++++ src/definition/Scenery.cpp | 2 +- src/interface/modeler/quickapp/MainModelerWindow.cpp | 4 ++++ src/tests/Scenery_Test.cpp | 8 ++++++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index df7cc34..9c56d08 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /nbproject/ /output/ /perf.* +/pic*.png *.pro.user *.pro.user.* qrc_*.cpp diff --git a/src/definition/AtmosphereDefinition.cpp b/src/definition/AtmosphereDefinition.cpp index 627f74d..237f19b 100644 --- a/src/definition/AtmosphereDefinition.cpp +++ b/src/definition/AtmosphereDefinition.cpp @@ -16,6 +16,8 @@ AtmosphereDefinition::~AtmosphereDefinition() void AtmosphereDefinition::save(PackStream* stream) const { + DefinitionNode::save(stream); + stream->write((int*)&model); sun_color.save(stream); stream->write(&sun_radius); @@ -37,6 +39,8 @@ void AtmosphereDefinition::save(PackStream* stream) const void AtmosphereDefinition::load(PackStream* stream) { + DefinitionNode::load(stream); + stream->read((int*)&model); sun_color.load(stream); stream->read(&sun_radius); @@ -64,6 +68,8 @@ void AtmosphereDefinition::load(PackStream* stream) void AtmosphereDefinition::copy(DefinitionNode* _destination) const { + DefinitionNode::copy(_destination); + AtmosphereDefinition* destination = (AtmosphereDefinition*)_destination; daytime->copy(destination->daytime); diff --git a/src/definition/Scenery.cpp b/src/definition/Scenery.cpp index 5bf666c..86d1b07 100644 --- a/src/definition/Scenery.cpp +++ b/src/definition/Scenery.cpp @@ -138,7 +138,7 @@ void Scenery::autoPreset(int seed) validate(); - Logs::debug() << "New scenery generated from seed " << seed << ":\n" << toString() << std::endl; + Logs::debug() << "New scenery generated from seed " << seed << std::endl; } void Scenery::setAtmosphere(AtmosphereDefinition* atmosphere) diff --git a/src/interface/modeler/quickapp/MainModelerWindow.cpp b/src/interface/modeler/quickapp/MainModelerWindow.cpp index 46b1db4..fcf8fd1 100644 --- a/src/interface/modeler/quickapp/MainModelerWindow.cpp +++ b/src/interface/modeler/quickapp/MainModelerWindow.cpp @@ -105,6 +105,10 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event) { render_process->showPreviousRender(); } + else if (event->key() == Qt::Key_F12) + { + Logs::warning() << "Current scenery dump:" << std::endl << scenery->toString() << std::endl; + } else if (event->key() == Qt::Key_Q) { if (event->modifiers() & Qt::ControlModifier) diff --git a/src/tests/Scenery_Test.cpp b/src/tests/Scenery_Test.cpp index 551d976..d7f4491 100644 --- a/src/tests/Scenery_Test.cpp +++ b/src/tests/Scenery_Test.cpp @@ -2,11 +2,16 @@ #include "Scenery.h" #include "Logs.h" +#include "TerrainDefinition.h" +#include "AtmosphereDefinition.h" +#include "FloatNode.h" TEST(Scenery, saveGlobal) { Scenery scenery1; scenery1.autoPreset(); + scenery1.getTerrain()->propWaterHeight()->setValue(0.2); + scenery1.getAtmosphere()->propDayTime()->setValue(0.53); Scenery::FileOperationResult result = scenery1.saveGlobal("/tmp/test_paysages_scenery"); EXPECT_EQ((int)Scenery::FILE_OPERATION_OK, result); @@ -14,4 +19,7 @@ TEST(Scenery, saveGlobal) Scenery scenery2; result = scenery2.loadGlobal("/tmp/test_paysages_scenery"); EXPECT_EQ((int)Scenery::FILE_OPERATION_OK, result); + + EXPECT_DOUBLE_EQ(0.2, scenery2.getTerrain()->propWaterHeight()->getValue()); + EXPECT_DOUBLE_EQ(0.53, scenery2.getAtmosphere()->propDayTime()->getValue()); }