summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-09-22 21:51:59 +0200
committermadmaxoft <github@xoft.cz>2014-09-22 21:52:38 +0200
commit83588fb0aad5c8597df783792c946c27327f1a40 (patch)
tree986aac86163c6ccc380886480c8c277f17d68742 /Tools
parentQtBiomeVisualiser: generator source is read from generator setup ini. (diff)
downloadcuberite-83588fb0aad5c8597df783792c946c27327f1a40.tar
cuberite-83588fb0aad5c8597df783792c946c27327f1a40.tar.gz
cuberite-83588fb0aad5c8597df783792c946c27327f1a40.tar.bz2
cuberite-83588fb0aad5c8597df783792c946c27327f1a40.tar.lz
cuberite-83588fb0aad5c8597df783792c946c27327f1a40.tar.xz
cuberite-83588fb0aad5c8597df783792c946c27327f1a40.tar.zst
cuberite-83588fb0aad5c8597df783792c946c27327f1a40.zip
Diffstat (limited to '')
-rw-r--r--Tools/QtBiomeVisualiser/ChunkSource.cpp2
-rw-r--r--Tools/QtBiomeVisualiser/GeneratorSetup.cpp44
-rw-r--r--Tools/QtBiomeVisualiser/GeneratorSetup.h7
-rw-r--r--Tools/QtBiomeVisualiser/MainWindow.cpp9
-rw-r--r--Tools/QtBiomeVisualiser/QtBiomeVisualiser.pro4
5 files changed, 49 insertions, 17 deletions
diff --git a/Tools/QtBiomeVisualiser/ChunkSource.cpp b/Tools/QtBiomeVisualiser/ChunkSource.cpp
index d8cecbaa4..f7174b624 100644
--- a/Tools/QtBiomeVisualiser/ChunkSource.cpp
+++ b/Tools/QtBiomeVisualiser/ChunkSource.cpp
@@ -171,7 +171,7 @@ void BioGenSource::getChunkBiomes(int a_ChunkX, int a_ChunkZ, ChunkPtr a_DestChu
void BioGenSource::reload()
{
- int seed = m_IniFile->GetValueSetI("Seed", "Seed", 0);
+ int seed = m_IniFile->GetValueSetI("Generator", "Seed", 0);
bool unused = false;
QMutexLocker lock(&m_Mtx);
m_BiomeGen.reset(cBiomeGen::CreateBiomeGen(*m_IniFile, seed, unused));
diff --git a/Tools/QtBiomeVisualiser/GeneratorSetup.cpp b/Tools/QtBiomeVisualiser/GeneratorSetup.cpp
index d512d2b90..239965409 100644
--- a/Tools/QtBiomeVisualiser/GeneratorSetup.cpp
+++ b/Tools/QtBiomeVisualiser/GeneratorSetup.cpp
@@ -27,22 +27,27 @@ GeneratorSetup::GeneratorSetup(const AString & a_IniFileName, QWidget * a_Parent
super(a_Parent),
m_IniFile(new cIniFile())
{
- // The generator name is in a separate form layout at the top, always present:
+ // The seed and generator name is in a separate form layout at the top, always present:
+ m_eSeed = new QLineEdit();
+ m_eSeed->setValidator(new QIntValidator());
+ m_eSeed->setText("0");
+ m_eSeed->setProperty("INI.ItemName", QVariant("Seed"));
m_cbGenerator = new QComboBox();
m_cbGenerator->setMinimumWidth(120);
for (size_t i = 0; i < ARRAYCOUNT(s_GeneratorNames); i++)
{
m_cbGenerator->addItem(s_GeneratorNames[i]);
}
- QFormLayout * nameLayout = new QFormLayout();
- nameLayout->addRow(new QLabel(tr("Generator")), m_cbGenerator);
+ QFormLayout * baseLayout = new QFormLayout();
+ baseLayout->addRow(new QLabel(tr("Seed")), m_eSeed);
+ baseLayout->addRow(new QLabel(tr("Generator")), m_cbGenerator);
// The rest of the controls are in a dynamically created form layout:
m_FormLayout = new QFormLayout();
// The main layout joins these two vertically:
m_MainLayout = new QVBoxLayout();
- m_MainLayout->addLayout(nameLayout);
+ m_MainLayout->addLayout(baseLayout);
m_MainLayout->addLayout(m_FormLayout);
m_MainLayout->addStretch();
setLayout(m_MainLayout);
@@ -51,18 +56,20 @@ GeneratorSetup::GeneratorSetup(const AString & a_IniFileName, QWidget * a_Parent
if (!a_IniFileName.empty() && m_IniFile->ReadFile(a_IniFileName))
{
m_cbGenerator->setCurrentText(QString::fromStdString(m_IniFile->GetValue("Generator", "BiomeGen")));
+ m_eSeed->setText(QString::number(m_IniFile->GetValueI("Generator", "Seed")));
}
else
{
m_IniFile->SetValue("Generator", "Generator", "Composable");
m_IniFile->SetValue("Generator", "BiomeGen", m_cbGenerator->currentText().toStdString());
bool dummy;
- delete cBiomeGen::CreateBiomeGen(*m_IniFile, m_Seed, dummy);
+ delete cBiomeGen::CreateBiomeGen(*m_IniFile, 0, dummy);
}
updateFromIni();
- // Connect the combo change even only after the data has been loaded:
- connect(m_cbGenerator, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(generatorChanged(QString)));
+ // Connect the change events only after the data has been loaded:
+ connect(m_cbGenerator, SIGNAL(currentIndexChanged(QString)), this, SLOT(generatorChanged(QString)));
+ connect(m_eSeed, SIGNAL(textChanged(QString)), this, SLOT(editChanged(QString)));
}
@@ -92,6 +99,20 @@ void GeneratorSetup::generatorChanged(const QString & a_NewName)
// Read all values from the INI file and put them into the form layout:
updateFromIni();
+
+ // Notify of the changes:
+ emit generatorUpdated();
+}
+
+
+
+
+
+void GeneratorSetup::editChanged(const QString & a_NewValue)
+{
+ QString itemName = sender()->property("INI.ItemName").toString();
+ m_IniFile->SetValue("Generator", itemName.toStdString(), a_NewValue.toStdString());
+ emit generatorUpdated();
}
@@ -111,12 +132,16 @@ void GeneratorSetup::updateFromIni()
for (int i = 0; i < numItems; i++)
{
AString itemName = m_IniFile->GetValueName(keyID, i);
- AString itemValue = m_IniFile->GetValue(keyID, i);
if ((itemName == "Generator") || (itemName == "BiomeGen"))
{
// These special cases are not to be added
continue;
}
+ AString itemValue = m_IniFile->GetValue(keyID, i);
+
+ QLineEdit * edit = new QLineEdit();
+ edit->setText(QString::fromStdString(itemValue));
+ edit->setProperty("INI.ItemName", QVariant(QString::fromStdString(itemName)));
// Remove the generator name prefix from the item name, for clarity purposes:
if (NoCaseCompare(itemName.substr(0, generatorNameLen), generatorName) == 0)
@@ -124,8 +149,7 @@ void GeneratorSetup::updateFromIni()
itemName.erase(0, generatorNameLen);
}
- QLineEdit * edit = new QLineEdit();
- edit->setText(QString::fromStdString(itemValue));
+ connect(edit, SIGNAL(textChanged(QString)), this, SLOT(editChanged(QString)));
m_FormLayout->addRow(new QLabel(QString::fromStdString(itemName)), edit);
} // for i - INI values[]
}
diff --git a/Tools/QtBiomeVisualiser/GeneratorSetup.h b/Tools/QtBiomeVisualiser/GeneratorSetup.h
index 0594e1998..e72d3abbc 100644
--- a/Tools/QtBiomeVisualiser/GeneratorSetup.h
+++ b/Tools/QtBiomeVisualiser/GeneratorSetup.h
@@ -32,14 +32,21 @@ public:
cIniFilePtr getIniFile() { return m_IniFile; }
signals:
+ /** Emitted when the generator parameters have changed. */
+ void generatorUpdated();
public slots:
/** Called when the user selects a different generator from the top combobox.
Re-creates m_IniFile and updates the form layout. */
void generatorChanged(const QString & a_NewName);
+protected slots:
+ /** Called when any of the edit widgets are changed. */
+ void editChanged(const QString & a_NewValue);
+
protected:
QComboBox * m_cbGenerator;
+ QLineEdit * m_eSeed;
QVBoxLayout * m_MainLayout;
QFormLayout * m_FormLayout;
diff --git a/Tools/QtBiomeVisualiser/MainWindow.cpp b/Tools/QtBiomeVisualiser/MainWindow.cpp
index c55d85082..a2cfa7794 100644
--- a/Tools/QtBiomeVisualiser/MainWindow.cpp
+++ b/Tools/QtBiomeVisualiser/MainWindow.cpp
@@ -27,7 +27,7 @@ MainWindow::MainWindow(QWidget * parent) :
m_BiomeView = new BiomeView();
m_MainLayout = new QHBoxLayout();
- m_MainLayout->addWidget(m_BiomeView);
+ m_MainLayout->addWidget(m_BiomeView, 1);
m_MainLayout->setMenuBar(menuBar());
m_MainLayout->setMargin(0);
QWidget * central = new QWidget();
@@ -57,7 +57,8 @@ void MainWindow::newGenerator()
openGeneratorSetup("");
// Set the chunk source:
- m_BiomeView->setChunkSource(std::shared_ptr<BioGenSource>(new BioGenSource(m_GeneratorSetup->getIniFile())));
+ cIniFilePtr iniFile = m_GeneratorSetup->getIniFile();
+ m_BiomeView->setChunkSource(std::shared_ptr<BioGenSource>(new BioGenSource(iniFile)));
m_BiomeView->redraw();
}
@@ -260,7 +261,6 @@ QString MainWindow::getWorldName(const AString & a_Path)
return QString();
}
AString name = nbt.GetName(1);
- OutputDebugStringA(name.c_str());
int levelNameTag = nbt.FindTagByPath(nbt.GetRoot(), "Data\\LevelName");
if ((levelNameTag <= 0) || (nbt.GetType(levelNameTag) != TAG_String))
{
@@ -286,6 +286,9 @@ void MainWindow::openGeneratorSetup(const AString & a_IniFileName)
m_LineSeparator->setStyleSheet(QString("background-color: #c0c0c0;"));
m_MainLayout->addWidget(m_LineSeparator);
m_MainLayout->addWidget(m_GeneratorSetup);
+
+ // Connect the signals from the setup pane:
+ connect(m_GeneratorSetup, SIGNAL(generatorUpdated()), m_BiomeView, SLOT(reload()));
}
diff --git a/Tools/QtBiomeVisualiser/QtBiomeVisualiser.pro b/Tools/QtBiomeVisualiser/QtBiomeVisualiser.pro
index 2ed1be719..4275f73eb 100644
--- a/Tools/QtBiomeVisualiser/QtBiomeVisualiser.pro
+++ b/Tools/QtBiomeVisualiser/QtBiomeVisualiser.pro
@@ -89,8 +89,6 @@ INCLUDEPATH += $$_PRO_FILE_PWD_ \
CONFIG += C++11
-OTHER_FILES += \
- ../../lib/zlib/example.c.txt \
- ../../lib/zlib/minigzip.c.txt
+OTHER_FILES +=