summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Tools/QtBiomeVisualiser/ChunkSource.cpp12
-rw-r--r--Tools/QtBiomeVisualiser/ChunkSource.h7
-rw-r--r--Tools/QtBiomeVisualiser/MainWindow.cpp10
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();
}