paysages : Added GUI state saving/loading.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@364 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-06-27 10:30:00 +00:00 committed by ThunderK
parent f5d2396256
commit 834f96d3a6
13 changed files with 197 additions and 56 deletions

View file

@ -24,6 +24,7 @@ GUI :
* Improved curve rendering. * Improved curve rendering.
* New material editor. * New material editor.
* Added render timer. * Added render timer.
* Previews locations and render params are now saved.
* Added camera location to previews. * Added camera location to previews.
Misc : Misc :

1
TODO
View file

@ -13,7 +13,6 @@ Technology Preview 2 :
- Render tab previews should not rerender when changing render options. - Render tab previews should not rerender when changing render options.
- Add layer sorting/naming. - Add layer sorting/naming.
- Add logarithmic sliders for some float values. - Add logarithmic sliders for some float values.
- Save GUI config (views, render params).
- Improve previews. - Improve previews.
=> Add a right click menu for toggles and modes => Add a right click menu for toggles and modes
=> Add user markers on OSD => Add user markers on OSD

View file

@ -104,6 +104,28 @@ void BaseForm::hideButtons()
button_revert->hide(); button_revert->hide();
} }
void BaseForm::savePack(PackStream* stream)
{
// Save previews status
// TODO Ensure same order in save and load
QList<BasePreview*> list_previews = previews->findChildren<BasePreview*>("_form_preview_");
for (int i = 0; i < list_previews.size(); i++)
{
list_previews[i]->savePack(stream);
}
}
void BaseForm::loadPack(PackStream* stream)
{
// Load previews status
// TODO Ensure same order in save and load
QList<BasePreview*> list_previews = previews->findChildren<BasePreview*>("_form_preview_");
for (int i = 0; i < list_previews.size(); i++)
{
list_previews[i]->loadPack(stream);
}
}
void BaseForm::configChangeEvent() void BaseForm::configChangeEvent()
{ {
if (auto_apply) if (auto_apply)

View file

@ -10,6 +10,7 @@
#include "../lib_paysages/noise.h" #include "../lib_paysages/noise.h"
#include "../lib_paysages/curve.h" #include "../lib_paysages/curve.h"
#include "../lib_paysages/color.h" #include "../lib_paysages/color.h"
#include "../lib_paysages/pack.h"
class BaseForm:public QWidget class BaseForm:public QWidget
{ {
@ -18,6 +19,8 @@ class BaseForm:public QWidget
public: public:
BaseForm(QWidget* parent, bool auto_apply=false, bool with_layers=false); BaseForm(QWidget* parent, bool auto_apply=false, bool with_layers=false);
void hideButtons(); void hideButtons();
virtual void savePack(PackStream* stream);
virtual void loadPack(PackStream* stream);
signals: signals:
void configApplied(); void configApplied();

View file

@ -309,6 +309,21 @@ void BasePreview::addOsd(QString name)
setMouseTracking(true); setMouseTracking(true);
} }
void BasePreview::savePack(PackStream* stream)
{
packWriteDouble(stream, &this->xoffset);
packWriteDouble(stream, &this->yoffset);
packWriteDouble(stream, &this->scaling);
}
void BasePreview::loadPack(PackStream* stream)
{
packReadDouble(stream, &this->xoffset);
packReadDouble(stream, &this->yoffset);
packReadDouble(stream, &this->scaling);
emit contentChange();
}
void BasePreview::initDrawers() void BasePreview::initDrawers()
{ {
_drawing_manager = new PreviewDrawingManager(); _drawing_manager = new PreviewDrawingManager();

View file

@ -9,6 +9,7 @@
#include <QList> #include <QList>
#include <QLabel> #include <QLabel>
#include "previewosd.h" #include "previewosd.h"
#include "../lib_paysages/pack.h"
class BasePreview : public QWidget { class BasePreview : public QWidget {
Q_OBJECT Q_OBJECT
@ -19,6 +20,9 @@ public:
void addOsd(QString name); void addOsd(QString name);
virtual void savePack(PackStream* stream);
virtual void loadPack(PackStream* stream);
static void initDrawers(); static void initDrawers();
static void stopDrawers(); static void stopDrawers();
static void reviveAll(); static void reviveAll();

View file

@ -143,6 +143,28 @@ FormRender::~FormRender()
} }
} }
void FormRender::savePack(PackStream* stream)
{
BaseForm::savePack(stream);
packWriteInt(stream, &_params.width);
packWriteInt(stream, &_params.height);
packWriteInt(stream, &_params.antialias);
packWriteInt(stream, &_params.quality);
}
void FormRender::loadPack(PackStream* stream)
{
BaseForm::loadPack(stream);
packReadInt(stream, &_params.width);
packReadInt(stream, &_params.height);
packReadInt(stream, &_params.antialias);
packReadInt(stream, &_params.quality);
revertConfig();
}
void FormRender::revertConfig() void FormRender::revertConfig()
{ {
sceneryGetCamera(&_camera); sceneryGetCamera(&_camera);

View file

@ -14,6 +14,9 @@ public:
explicit FormRender(QWidget *parent = 0); explicit FormRender(QWidget *parent = 0);
~FormRender(); ~FormRender();
virtual void savePack(PackStream* stream);
virtual void loadPack(PackStream* stream);
public slots: public slots:
virtual void revertConfig(); virtual void revertConfig();
virtual void applyConfig(); virtual void applyConfig();

View file

@ -27,6 +27,7 @@
#include "../lib_paysages/main.h" #include "../lib_paysages/main.h"
#include "../lib_paysages/auto.h" #include "../lib_paysages/auto.h"
#include "../lib_paysages/scenery.h" #include "../lib_paysages/scenery.h"
#include "tools.h"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
@ -130,6 +131,8 @@ QMainWindow(parent)
setWindowTitle("Paysages 3D"); setWindowTitle("Paysages 3D");
setWindowIcon(QIcon("images/logo_32.png")); setWindowIcon(QIcon("images/logo_32.png"));
scenerySetCustomDataCallback(MainWindow::guiSaveCallback, MainWindow::guiLoadCallback, this);
refreshAll(); refreshAll();
} }
@ -145,6 +148,8 @@ bool MainWindow::event(QEvent* event)
void MainWindow::refreshAll() void MainWindow::refreshAll()
{ {
logDebug("[MainWindow] Refreshing whole UI");
// Refresh all tabs // Refresh all tabs
QList<BaseForm*> list_forms = this->findChildren<BaseForm*>("_base_form_"); QList<BaseForm*> list_forms = this->findChildren<BaseForm*>("_base_form_");
for (int i = 0; i < list_forms.size(); i++) for (int i = 0; i < list_forms.size(); i++)
@ -254,3 +259,35 @@ void MainWindow::explore3D()
refreshAll(); refreshAll();
} }
} }
void MainWindow::guiSaveCallback(PackStream* stream, void* data)
{
((MainWindow*)data)->guiSave(stream);
}
void MainWindow::guiLoadCallback(PackStream* stream, void* data)
{
((MainWindow*)data)->guiLoad(stream);
}
void MainWindow::guiSave(PackStream* stream)
{
// Save all tabs status
// TODO Ensure same order in save and load
QList<BaseForm*> list_forms = this->findChildren<BaseForm*>("_base_form_");
for (int i = 0; i < list_forms.size(); i++)
{
list_forms[i]->savePack(stream);
}
}
void MainWindow::guiLoad(PackStream* stream)
{
// Load all tabs status
// TODO Ensure same order in save and load
QList<BaseForm*> list_forms = this->findChildren<BaseForm*>("_base_form_");
for (int i = 0; i < list_forms.size(); i++)
{
list_forms[i]->loadPack(stream);
}
}

View file

@ -3,6 +3,7 @@
#include <QMainWindow> #include <QMainWindow>
#include "formrender.h" #include "formrender.h"
#include "../lib_paysages/pack.h"
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
@ -11,6 +12,9 @@ class MainWindow : public QMainWindow
public: public:
explicit MainWindow(QWidget *parent = 0); explicit MainWindow(QWidget *parent = 0);
virtual bool event(QEvent* event); virtual bool event(QEvent* event);
static void guiSaveCallback(PackStream* stream, void* data);
static void guiLoadCallback(PackStream* stream, void* data);
public slots: public slots:
void refreshAll(); void refreshAll();
@ -25,6 +29,9 @@ public slots:
void explore3D(); void explore3D();
private: private:
void guiSave(PackStream* stream);
void guiLoad(PackStream* stream);
FormRender* _form_render; FormRender* _form_render;
}; };

View file

@ -29,7 +29,7 @@
<translation>Annuler les modifications</translation> <translation>Annuler les modifications</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/baseform.cpp" line="304"/> <location filename="../gui_qt/baseform.cpp" line="326"/>
<source>Layer %1</source> <source>Layer %1</source>
<translation>Niveau %1</translation> <translation>Niveau %1</translation>
</message> </message>
@ -565,17 +565,17 @@ Maintenir Ctrl : Plus rapide</translation>
<translation>Sauvegarder le dernier rendu</translation> <translation>Sauvegarder le dernier rendu</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formrender.cpp" line="212"/> <location filename="../gui_qt/formrender.cpp" line="234"/>
<source>Paysages 3D - Choose a filename to save the last render</source> <source>Paysages 3D - Choose a filename to save the last render</source>
<translation>Paysages 3D - Choisissez un nom de fichier pour le rendu</translation> <translation>Paysages 3D - Choisissez un nom de fichier pour le rendu</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formrender.cpp" line="212"/> <location filename="../gui_qt/formrender.cpp" line="234"/>
<source>Images (*.png *.jpg)</source> <source>Images (*.png *.jpg)</source>
<translation>Images (*.png *.jpg)</translation> <translation>Images (*.png *.jpg)</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formrender.cpp" line="225"/> <location filename="../gui_qt/formrender.cpp" line="247"/>
<source>Can&apos;t write to file : %1</source> <source>Can&apos;t write to file : %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -588,7 +588,7 @@ Maintenir Ctrl : Plus rapide</translation>
<translation type="obsolete">Choisissez un nom de fichier pour le rendu</translation> <translation type="obsolete">Choisissez un nom de fichier pour le rendu</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/formrender.cpp" line="221"/> <location filename="../gui_qt/formrender.cpp" line="243"/>
<source>The picture %1 has been saved.</source> <source>The picture %1 has been saved.</source>
<translation>L&apos;image %1 a é sauvegardée.</translation> <translation>L&apos;image %1 a é sauvegardée.</translation>
</message> </message>
@ -955,144 +955,144 @@ Maintenir Ctrl : Plus rapide</translation>
<context> <context>
<name>MainWindow</name> <name>MainWindow</name>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="81"/> <location filename="../gui_qt/mainwindow.cpp" line="82"/>
<source>Terrain</source> <source>Terrain</source>
<translation>Terrain</translation> <translation>Terrain</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="85"/> <location filename="../gui_qt/mainwindow.cpp" line="86"/>
<source>Textures</source> <source>Textures</source>
<translation>Textures</translation> <translation>Textures</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="89"/> <location filename="../gui_qt/mainwindow.cpp" line="90"/>
<source>Water</source> <source>Water</source>
<translation>Eau</translation> <translation>Eau</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="97"/> <location filename="../gui_qt/mainwindow.cpp" line="98"/>
<source>Atmosphere</source> <source>Atmosphere</source>
<translation>Atmosphère</translation> <translation>Atmosphère</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="123"/> <location filename="../gui_qt/mainwindow.cpp" line="124"/>
<source>&amp;Load</source> <source>&amp;Load</source>
<translation>&amp;Ouvrir</translation> <translation>&amp;Ouvrir</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="123"/> <location filename="../gui_qt/mainwindow.cpp" line="124"/>
<source>Crtl+L</source> <source>Crtl+L</source>
<translation>Ctrl+O</translation> <translation>Ctrl+O</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="124"/> <location filename="../gui_qt/mainwindow.cpp" line="125"/>
<source>&amp;Explore (F2)</source> <source>&amp;Explore (F2)</source>
<translation>&amp;Explorer (F2)</translation> <translation>&amp;Explorer (F2)</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="124"/> <location filename="../gui_qt/mainwindow.cpp" line="125"/>
<source>F2</source> <source>F2</source>
<translation>F2</translation> <translation>F2</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="125"/> <location filename="../gui_qt/mainwindow.cpp" line="126"/>
<source>&amp;Quick <source>&amp;Quick
render (F5)</source> render (F5)</source>
<translation>&amp;Rendu <translation>&amp;Rendu
rapide (F5)</translation> rapide (F5)</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="125"/> <location filename="../gui_qt/mainwindow.cpp" line="126"/>
<source>F5</source> <source>F5</source>
<translation>F5</translation> <translation>F5</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="162"/> <location filename="../gui_qt/mainwindow.cpp" line="167"/>
<source>Camera</source> <source>Camera</source>
<translation type="unfinished">Caméra</translation> <translation type="unfinished">Caméra</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="168"/> <location filename="../gui_qt/mainwindow.cpp" line="173"/>
<source>Do you want to start a new scenery ? Any unsaved changes will be lost.</source> <source>Do you want to start a new scenery ? Any unsaved changes will be lost.</source>
<translation>Voulez-vous commencer un nouveau paysage ? Les modifications non sauvegardées seront perdues.</translation> <translation>Voulez-vous commencer un nouveau paysage ? Les modifications non sauvegardées seront perdues.</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="168"/> <location filename="../gui_qt/mainwindow.cpp" line="173"/>
<source>Paysages 3D - New scenery</source> <source>Paysages 3D - New scenery</source>
<translation>Paysages 3D - Nouvelle scène</translation> <translation>Paysages 3D - Nouvelle scène</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="178"/> <location filename="../gui_qt/mainwindow.cpp" line="183"/>
<source>Paysages 3D - Choose a file to save the scenery</source> <source>Paysages 3D - Choose a file to save the scenery</source>
<translation>Paysages 3D - Choisissez un fichier pour enregistrer la scène</translation> <translation>Paysages 3D - Choisissez un fichier pour enregistrer la scène</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="178"/> <location filename="../gui_qt/mainwindow.cpp" line="183"/>
<location filename="../gui_qt/mainwindow.cpp" line="204"/> <location filename="../gui_qt/mainwindow.cpp" line="209"/>
<source>Paysages 3D Scenery (*.p3d)</source> <source>Paysages 3D Scenery (*.p3d)</source>
<translation>Scène Paysages 3D (*.p3d)</translation> <translation>Scène Paysages 3D (*.p3d)</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="192"/> <location filename="../gui_qt/mainwindow.cpp" line="197"/>
<location filename="../gui_qt/mainwindow.cpp" line="195"/> <location filename="../gui_qt/mainwindow.cpp" line="200"/>
<source>Paysages 3D - File saving error</source> <source>Paysages 3D - File saving error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="192"/> <location filename="../gui_qt/mainwindow.cpp" line="197"/>
<source>Can&apos;t write specified file : %1</source> <source>Can&apos;t write specified file : %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="195"/> <location filename="../gui_qt/mainwindow.cpp" line="200"/>
<source>Unexpected error while saving file : %1</source> <source>Unexpected error while saving file : %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="202"/> <location filename="../gui_qt/mainwindow.cpp" line="207"/>
<source>Do you want to load a scenery from file ? Any unsaved changes will be lost.</source> <source>Do you want to load a scenery from file ? Any unsaved changes will be lost.</source>
<translation>Voulez-vous charger une scène ? Les modifications non sauvegardées seront perdues.</translation> <translation>Voulez-vous charger une scène ? Les modifications non sauvegardées seront perdues.</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="202"/> <location filename="../gui_qt/mainwindow.cpp" line="207"/>
<source>Paysages 3D - Load scenery</source> <source>Paysages 3D - Load scenery</source>
<translation>Paysages 3D - Charger une scène</translation> <translation>Paysages 3D - Charger une scène</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="204"/> <location filename="../gui_qt/mainwindow.cpp" line="209"/>
<source>Paysages 3D - Choose a scenery file to load</source> <source>Paysages 3D - Choose a scenery file to load</source>
<translation>Paysages 3D - Choisissez un fichier de scène à charger</translation> <translation>Paysages 3D - Choisissez un fichier de scène à charger</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="214"/> <location filename="../gui_qt/mainwindow.cpp" line="219"/>
<location filename="../gui_qt/mainwindow.cpp" line="217"/> <location filename="../gui_qt/mainwindow.cpp" line="222"/>
<location filename="../gui_qt/mainwindow.cpp" line="220"/> <location filename="../gui_qt/mainwindow.cpp" line="225"/>
<location filename="../gui_qt/mainwindow.cpp" line="223"/> <location filename="../gui_qt/mainwindow.cpp" line="228"/>
<source>Paysages 3D - File loading error</source> <source>Paysages 3D - File loading error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="214"/> <location filename="../gui_qt/mainwindow.cpp" line="219"/>
<source>Can&apos;t read specified file : %1</source> <source>Can&apos;t read specified file : %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="217"/> <location filename="../gui_qt/mainwindow.cpp" line="222"/>
<source>This file doesn&apos;t look like a Paysages 3D file : %1</source> <source>This file doesn&apos;t look like a Paysages 3D file : %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="220"/> <location filename="../gui_qt/mainwindow.cpp" line="225"/>
<source>This file was created with an incompatible Paysages 3D version : %1</source> <source>This file was created with an incompatible Paysages 3D version : %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="223"/> <location filename="../gui_qt/mainwindow.cpp" line="228"/>
<source>Unexpected error while loading file : %1</source> <source>Unexpected error while loading file : %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="231"/> <location filename="../gui_qt/mainwindow.cpp" line="236"/>
<source>A 3D landscape editing and rendering software. <source>A 3D landscape editing and rendering software.
Authors : Authors :
@ -1106,12 +1106,12 @@ GLib - http://www.gtk.org/
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="93"/> <location filename="../gui_qt/mainwindow.cpp" line="94"/>
<source>Sky</source> <source>Sky</source>
<translation>Ciel</translation> <translation>Ciel</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="101"/> <location filename="../gui_qt/mainwindow.cpp" line="102"/>
<source>Clouds</source> <source>Clouds</source>
<translation>Nuages</translation> <translation>Nuages</translation>
</message> </message>
@ -1120,7 +1120,7 @@ GLib - http://www.gtk.org/
<translation type="obsolete">Eclairage</translation> <translation type="obsolete">Eclairage</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="109"/> <location filename="../gui_qt/mainwindow.cpp" line="110"/>
<source>Render</source> <source>Render</source>
<translation>Rendu</translation> <translation>Rendu</translation>
</message> </message>
@ -1129,22 +1129,22 @@ GLib - http://www.gtk.org/
<translation type="obsolete">&amp;Scène</translation> <translation type="obsolete">&amp;Scène</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="121"/> <location filename="../gui_qt/mainwindow.cpp" line="122"/>
<source>&amp;New</source> <source>&amp;New</source>
<translation>&amp;Nouveau</translation> <translation>&amp;Nouveau</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="121"/> <location filename="../gui_qt/mainwindow.cpp" line="122"/>
<source>Crtl+N</source> <source>Crtl+N</source>
<translation>Ctrl+N</translation> <translation>Ctrl+N</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="122"/> <location filename="../gui_qt/mainwindow.cpp" line="123"/>
<source>&amp;Save</source> <source>&amp;Save</source>
<translation>&amp;Sauvegarder</translation> <translation>&amp;Sauvegarder</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="122"/> <location filename="../gui_qt/mainwindow.cpp" line="123"/>
<source>Crtl+S</source> <source>Crtl+S</source>
<translation>Ctrl+S</translation> <translation>Ctrl+S</translation>
</message> </message>
@ -1181,7 +1181,7 @@ GLib - http://www.gtk.org/
<translation type="obsolete">Ai&amp;de</translation> <translation type="obsolete">Ai&amp;de</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="126"/> <location filename="../gui_qt/mainwindow.cpp" line="127"/>
<source>&amp;About</source> <source>&amp;About</source>
<translation>&amp;A propos</translation> <translation>&amp;A propos</translation>
</message> </message>
@ -1202,7 +1202,7 @@ GLib - http://www.gtk.org/
<translation type="obsolete">Voulez-vous charger un paysage ? Les modifications nons sauvegardées seront perdues.</translation> <translation type="obsolete">Voulez-vous charger un paysage ? Les modifications nons sauvegardées seront perdues.</translation>
</message> </message>
<message> <message>
<location filename="../gui_qt/mainwindow.cpp" line="231"/> <location filename="../gui_qt/mainwindow.cpp" line="236"/>
<source>Paysages 3D</source> <source>Paysages 3D</source>
<translation>Paysages 3D</translation> <translation>Paysages 3D</translation>
</message> </message>

View file

@ -7,15 +7,19 @@
#include "system.h" #include "system.h"
#include "vegetation.h" #include "vegetation.h"
AtmosphereDefinition _atmosphere; static AtmosphereDefinition _atmosphere;
CameraDefinition _camera; static CameraDefinition _camera;
CloudsDefinition _clouds; static CloudsDefinition _clouds;
LightingDefinition _lighting; static LightingDefinition _lighting;
SkyDefinition _sky; static SkyDefinition _sky;
TerrainDefinition _terrain; static TerrainDefinition _terrain;
TexturesDefinition _textures; static TexturesDefinition _textures;
VegetationDefinition* _vegetation; static VegetationDefinition* _vegetation;
WaterDefinition _water; static WaterDefinition _water;
static SceneryCustomDataCallback _custom_save = NULL;
static SceneryCustomDataCallback _custom_load = NULL;
static void* _custom_data = NULL;
void sceneryInit() void sceneryInit()
{ {
@ -39,6 +43,9 @@ void sceneryInit()
_textures = texturesCreateDefinition(); _textures = texturesCreateDefinition();
_vegetation = vegetationCreateDefinition(); _vegetation = vegetationCreateDefinition();
_water = waterCreateDefinition(); _water = waterCreateDefinition();
_custom_save = NULL;
_custom_load = NULL;
} }
void sceneryQuit() void sceneryQuit()
@ -65,6 +72,13 @@ void sceneryQuit()
noiseQuit(); noiseQuit();
} }
void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data)
{
_custom_save = callback_save;
_custom_load = callback_load;
_custom_data = data;
}
void scenerySave(PackStream* stream) void scenerySave(PackStream* stream)
{ {
noiseSave(stream); noiseSave(stream);
@ -77,6 +91,11 @@ void scenerySave(PackStream* stream)
texturesSave(stream, &_textures); texturesSave(stream, &_textures);
vegetationSave(stream, _vegetation); vegetationSave(stream, _vegetation);
waterSave(stream, &_water); waterSave(stream, &_water);
if (_custom_save)
{
_custom_save(stream, _custom_data);
}
} }
void sceneryLoad(PackStream* stream) void sceneryLoad(PackStream* stream)
@ -103,6 +122,11 @@ void sceneryLoad(PackStream* stream)
texturesValidateDefinition(&_textures); texturesValidateDefinition(&_textures);
vegetationValidateDefinition(_vegetation); vegetationValidateDefinition(_vegetation);
waterValidateDefinition(&_water); waterValidateDefinition(&_water);
if (_custom_load)
{
_custom_load(stream, _custom_data);
}
} }
void scenerySetAtmosphere(AtmosphereDefinition* atmosphere) void scenerySetAtmosphere(AtmosphereDefinition* atmosphere)

View file

@ -24,9 +24,13 @@
extern "C" { extern "C" {
#endif #endif
typedef void (*SceneryCustomDataCallback)(PackStream* stream, void* data);
void sceneryInit(); void sceneryInit();
void sceneryQuit(); void sceneryQuit();
void scenerySetCustomDataCallback(SceneryCustomDataCallback callback_save, SceneryCustomDataCallback callback_load, void* data);
void scenerySave(PackStream* stream); void scenerySave(PackStream* stream);
void sceneryLoad(PackStream* stream); void sceneryLoad(PackStream* stream);