diff options
author | madmaxoft <github@xoft.cz> | 2014-09-22 18:33:18 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-09-22 21:52:37 +0200 |
commit | 583532e1b927e1b9af9782e35c7f2d089e997254 (patch) | |
tree | 89eee174088c08acca9e250507adf669274b1540 | |
parent | QtBiomeVisualiser: Moved the generator setup into a side-pane. (diff) | |
download | cuberite-583532e1b927e1b9af9782e35c7f2d089e997254.tar cuberite-583532e1b927e1b9af9782e35c7f2d089e997254.tar.gz cuberite-583532e1b927e1b9af9782e35c7f2d089e997254.tar.bz2 cuberite-583532e1b927e1b9af9782e35c7f2d089e997254.tar.lz cuberite-583532e1b927e1b9af9782e35c7f2d089e997254.tar.xz cuberite-583532e1b927e1b9af9782e35c7f2d089e997254.tar.zst cuberite-583532e1b927e1b9af9782e35c7f2d089e997254.zip |
-rw-r--r-- | Tools/QtBiomeVisualiser/ChunkSource.cpp | 12 | ||||
-rw-r--r-- | Tools/QtBiomeVisualiser/ChunkSource.h | 7 | ||||
-rw-r--r-- | Tools/QtBiomeVisualiser/MainWindow.cpp | 10 |
3 files changed, 13 insertions, 16 deletions
diff --git a/Tools/QtBiomeVisualiser/ChunkSource.cpp b/Tools/QtBiomeVisualiser/ChunkSource.cpp index 54da2afe5..d8cecbaa4 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.cpp +++ b/Tools/QtBiomeVisualiser/ChunkSource.cpp @@ -142,8 +142,8 @@ static void biomesToImage(cChunkDef::BiomeMap & a_Biomes, Chunk::Image & a_Image //////////////////////////////////////////////////////////////////////////////// // BioGenSource: -BioGenSource::BioGenSource(QString a_WorldIniPath) : - m_WorldIniPath(a_WorldIniPath), +BioGenSource::BioGenSource(cIniFilePtr a_IniFile) : + m_IniFile(a_IniFile), m_Mtx(QMutex::Recursive) { reload(); @@ -171,14 +171,10 @@ void BioGenSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChu void BioGenSource::reload() { - cIniFile ini; - ini.ReadFile(m_WorldIniPath.toStdString()); - int seed = ini.GetValueSetI("Seed", "Seed", 0); + int seed = m_IniFile->GetValueSetI("Seed", "Seed", 0); bool unused = false; QMutexLocker lock(&m_Mtx); - m_BiomeGen.reset(cBiomeGen::CreateBiomeGen(ini, seed, unused)); - lock.unlock(); - ini.WriteFile(m_WorldIniPath.toStdString()); + m_BiomeGen.reset(cBiomeGen::CreateBiomeGen(*m_IniFile, seed, unused)); } diff --git a/Tools/QtBiomeVisualiser/ChunkSource.h b/Tools/QtBiomeVisualiser/ChunkSource.h index a5612da01..05e8ac5de 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.h +++ b/Tools/QtBiomeVisualiser/ChunkSource.h @@ -12,6 +12,7 @@ class cBiomeGen; typedef std::shared_ptr<cBiomeGen> cBiomeGenPtr; class cIniFile; +typedef std::shared_ptr<cIniFile> cIniFilePtr; @@ -41,15 +42,15 @@ class BioGenSource : { public: /** Constructs a new BioGenSource based on the biome generator that is defined in the specified world.ini file. */ - BioGenSource(QString a_WorldIniPath); + BioGenSource(cIniFilePtr a_IniFile); // ChunkSource overrides: virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override; virtual void reload(void) override; protected: - /** Path to the world.ini file from which the m_WorldIni is regenerated on reload requests. */ - QString m_WorldIniPath; + /** The world.ini contents from which the generator is created and re-created on reload(). */ + cIniFilePtr m_IniFile; /** The generator used for generating biomes. */ std::unique_ptr<cBiomeGen> m_BiomeGen; diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp index f9915901d..c55d85082 100644 --- a/Tools/QtBiomeVisualiser/MainWindow.cpp +++ b/Tools/QtBiomeVisualiser/MainWindow.cpp @@ -53,12 +53,12 @@ MainWindow::~MainWindow() void MainWindow::newGenerator() { - // TODO - - // (Re-)open the generator setup dialog: + // (Re-)open the generator setup dialog with empty settings: openGeneratorSetup(""); - // TODO + // Set the chunk source: + m_BiomeView->setChunkSource(std::shared_ptr<BioGenSource>(new BioGenSource(m_GeneratorSetup->getIniFile()))); + m_BiomeView->redraw(); } @@ -78,7 +78,7 @@ void MainWindow::openGenerator() openGeneratorSetup(worldIni.toStdString()); // Set the chunk source: - m_BiomeView->setChunkSource(std::shared_ptr<BioGenSource>(new BioGenSource(worldIni))); + m_BiomeView->setChunkSource(std::shared_ptr<BioGenSource>(new BioGenSource(m_GeneratorSetup->getIniFile()))); m_BiomeView->redraw(); } |