From 99683c6569febdf7e0131632e4fce99c1722ca18 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 30 Jul 2014 11:10:15 +0200 Subject: [PATCH] Save and load the tilebank texture path. --- .../src/plugins/tile_editor/tile_editor_main_window.cpp | 7 +++++++ code/studio/src/plugins/tile_editor/tile_model.h | 5 +++++ code/studio/src/plugins/tile_editor/tilebank_loader.cpp | 2 ++ code/studio/src/plugins/tile_editor/tilebank_saver.cpp | 2 ++ 4 files changed, 16 insertions(+) diff --git a/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp b/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp index 427494ab4..df1194e4b 100644 --- a/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp +++ b/code/studio/src/plugins/tile_editor/tile_editor_main_window.cpp @@ -584,6 +584,7 @@ void TileEditorMainWindow::onChooseTexturePath() m_texturePath = path; m_ui->tileBankTexturePathPB->setText( path ); + m_tileModel->setTexturePath( path ); } void TileEditorMainWindow::onOrientedStateChanged( int state ) @@ -742,6 +743,12 @@ void TileEditorMainWindow::onTileBankLoaded() m_ui->listView128->reset(); m_ui->listView256->reset(); m_ui->listViewTransition->reset(); + + QString path = m_tileModel->texturePath(); + if( path.isEmpty() ) + m_ui->tileBankTexturePathPB->setText( "..." ); + else + m_ui->tileBankTexturePathPB->setText( path ); } TileModel* TileEditorMainWindow::createTileModel() diff --git a/code/studio/src/plugins/tile_editor/tile_model.h b/code/studio/src/plugins/tile_editor/tile_model.h index f18e60fd3..f2efdb8d4 100644 --- a/code/studio/src/plugins/tile_editor/tile_model.h +++ b/code/studio/src/plugins/tile_editor/tile_model.h @@ -95,6 +95,9 @@ public: void clear(); + void setTexturePath( const QString &path ){ m_texturePath = path; } + QString texturePath() const{ return m_texturePath; } + public Q_SLOTS: void selectFilenameDisplay(bool selected); void selectIndexDisplay(bool selected); @@ -109,6 +112,8 @@ private: //QList m_tiles; //int m_activeEditChannel; Node *rootItem; + + QString m_texturePath; }; #endif // TILE_MODEL_H diff --git a/code/studio/src/plugins/tile_editor/tilebank_loader.cpp b/code/studio/src/plugins/tile_editor/tilebank_loader.cpp index 2c1d15c06..f51413026 100644 --- a/code/studio/src/plugins/tile_editor/tilebank_loader.cpp +++ b/code/studio/src/plugins/tile_editor/tilebank_loader.cpp @@ -166,5 +166,7 @@ bool TileBankLoader::load( const char *filename, TileModel *model, QList< Land > p->loadLands( lands ); p->loadTileSets( model ); + model->setTexturePath( p->bank.getAbsPath().c_str() ); + return false; } diff --git a/code/studio/src/plugins/tile_editor/tilebank_saver.cpp b/code/studio/src/plugins/tile_editor/tilebank_saver.cpp index f650fb0d8..faec90bc4 100644 --- a/code/studio/src/plugins/tile_editor/tilebank_saver.cpp +++ b/code/studio/src/plugins/tile_editor/tilebank_saver.cpp @@ -223,6 +223,8 @@ bool TileBankSaver::save( const char *fileName, const TileModel* model, const QL p->addLands( lands ); p->addTileSets( model, lands ); + p->bank.setAbsPath( model->texturePath().toUtf8().constData() ); + // Save to file NLMISC::COFile f; bool b = f.open( fileName, false, false, false );