QtBiomeVisualiser: generator source is read from generator setup ini.
This commit is contained in:
parent
10c5d50566
commit
583532e1b9
@ -142,8 +142,8 @@ static void biomesToImage(cChunkDef::BiomeMap & a_Biomes, Chunk::Image & a_Image
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// BioGenSource:
|
// BioGenSource:
|
||||||
|
|
||||||
BioGenSource::BioGenSource(QString a_WorldIniPath) :
|
BioGenSource::BioGenSource(cIniFilePtr a_IniFile) :
|
||||||
m_WorldIniPath(a_WorldIniPath),
|
m_IniFile(a_IniFile),
|
||||||
m_Mtx(QMutex::Recursive)
|
m_Mtx(QMutex::Recursive)
|
||||||
{
|
{
|
||||||
reload();
|
reload();
|
||||||
@ -171,14 +171,10 @@ void BioGenSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChu
|
|||||||
|
|
||||||
void BioGenSource::reload()
|
void BioGenSource::reload()
|
||||||
{
|
{
|
||||||
cIniFile ini;
|
int seed = m_IniFile->GetValueSetI("Seed", "Seed", 0);
|
||||||
ini.ReadFile(m_WorldIniPath.toStdString());
|
|
||||||
int seed = ini.GetValueSetI("Seed", "Seed", 0);
|
|
||||||
bool unused = false;
|
bool unused = false;
|
||||||
QMutexLocker lock(&m_Mtx);
|
QMutexLocker lock(&m_Mtx);
|
||||||
m_BiomeGen.reset(cBiomeGen::CreateBiomeGen(ini, seed, unused));
|
m_BiomeGen.reset(cBiomeGen::CreateBiomeGen(*m_IniFile, seed, unused));
|
||||||
lock.unlock();
|
|
||||||
ini.WriteFile(m_WorldIniPath.toStdString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
class cBiomeGen;
|
class cBiomeGen;
|
||||||
typedef std::shared_ptr<cBiomeGen> cBiomeGenPtr;
|
typedef std::shared_ptr<cBiomeGen> cBiomeGenPtr;
|
||||||
class cIniFile;
|
class cIniFile;
|
||||||
|
typedef std::shared_ptr<cIniFile> cIniFilePtr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -41,15 +42,15 @@ class BioGenSource :
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Constructs a new BioGenSource based on the biome generator that is defined in the specified world.ini file. */
|
/** 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:
|
// ChunkSource overrides:
|
||||||
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override;
|
virtual void getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChunk) override;
|
||||||
virtual void reload(void) override;
|
virtual void reload(void) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Path to the world.ini file from which the m_WorldIni is regenerated on reload requests. */
|
/** The world.ini contents from which the generator is created and re-created on reload(). */
|
||||||
QString m_WorldIniPath;
|
cIniFilePtr m_IniFile;
|
||||||
|
|
||||||
/** The generator used for generating biomes. */
|
/** The generator used for generating biomes. */
|
||||||
std::unique_ptr<cBiomeGen> m_BiomeGen;
|
std::unique_ptr<cBiomeGen> m_BiomeGen;
|
||||||
|
@ -53,12 +53,12 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
void MainWindow::newGenerator()
|
void MainWindow::newGenerator()
|
||||||
{
|
{
|
||||||
// TODO
|
// (Re-)open the generator setup dialog with empty settings:
|
||||||
|
|
||||||
// (Re-)open the generator setup dialog:
|
|
||||||
openGeneratorSetup("");
|
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());
|
openGeneratorSetup(worldIni.toStdString());
|
||||||
|
|
||||||
// Set the chunk source:
|
// 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();
|
m_BiomeView->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user