mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-06 15:29:02 +00:00
Changed: #1301 Added random and full cycle modes(for rotation and flip values too) adding zone on landscape.
This commit is contained in:
parent
0823243f10
commit
54391eaebf
3 changed files with 74 additions and 13 deletions
|
@ -38,6 +38,8 @@ namespace LandscapeEditor
|
||||||
|
|
||||||
ListZonesWidget::ListZonesWidget(QWidget *parent)
|
ListZonesWidget::ListZonesWidget(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
|
m_rotCycle(0),
|
||||||
|
m_flipCycle(0),
|
||||||
m_listZonesModel(0),
|
m_listZonesModel(0),
|
||||||
m_zoneBuilder(0)
|
m_zoneBuilder(0)
|
||||||
{
|
{
|
||||||
|
@ -101,24 +103,70 @@ void ListZonesWidget::updateUi()
|
||||||
m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase());
|
m_listZonesModel->rebuildModel(m_zoneBuilder->pixmapDatabase());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ListZonesWidget::currentZoneName() const
|
QString ListZonesWidget::currentZoneName()
|
||||||
{
|
{
|
||||||
QString zoneName = "";
|
QString zoneName = "";
|
||||||
QModelIndex index = m_ui.listView->currentIndex();
|
QModelIndex index = m_ui.listView->currentIndex();
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
zoneName = index.data().toString();
|
zoneName = index.data().toString();
|
||||||
|
if (m_ui.zoneSelectComboBox->currentIndex() == 1)
|
||||||
|
{
|
||||||
|
// Random value
|
||||||
|
if (m_listSelection.size() > 0)
|
||||||
|
{
|
||||||
|
uint32 randZone = uint32(NLMISC::frand(m_listSelection.size()));
|
||||||
|
NLMISC::clamp(randZone, (uint32)0, uint32(m_listSelection.size() - 1));
|
||||||
|
zoneName = m_listSelection[randZone];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_ui.zoneSelectComboBox->currentIndex() == 2)
|
||||||
|
{
|
||||||
|
// Full cycle
|
||||||
|
zoneName = m_listSelection[m_zoneNameCycle];
|
||||||
|
m_zoneNameCycle++;
|
||||||
|
m_zoneNameCycle = m_zoneNameCycle % m_listSelection.size();
|
||||||
|
}
|
||||||
return zoneName;
|
return zoneName;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ListZonesWidget::currentRot() const
|
int ListZonesWidget::currentRot()
|
||||||
{
|
{
|
||||||
return m_ui.rotComboBox->currentIndex();
|
int rot = m_ui.rotComboBox->currentIndex();
|
||||||
|
if (rot == 4)
|
||||||
|
{
|
||||||
|
// Random value
|
||||||
|
uint32 randRot = uint32(NLMISC::frand(4.0));
|
||||||
|
NLMISC::clamp(randRot, (uint32)0, (uint32)3);
|
||||||
|
rot = int(randRot);
|
||||||
|
}
|
||||||
|
else if (rot == 5)
|
||||||
|
{
|
||||||
|
// Full cycle
|
||||||
|
rot = m_rotCycle;
|
||||||
|
m_rotCycle++;
|
||||||
|
m_rotCycle = m_rotCycle % 4;
|
||||||
|
}
|
||||||
|
return rot;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ListZonesWidget::currentFlip() const
|
int ListZonesWidget::currentFlip()
|
||||||
{
|
{
|
||||||
return m_ui.flipComboBox->currentIndex();
|
int flip = m_ui.flipComboBox->currentIndex();
|
||||||
|
if (flip == 2)
|
||||||
|
{
|
||||||
|
// Random value
|
||||||
|
uint32 randFlip = uint32(NLMISC::frand(2.0));
|
||||||
|
NLMISC::clamp (randFlip, (uint32)0, (uint32)1);
|
||||||
|
flip = int(randFlip);
|
||||||
|
}
|
||||||
|
else if (flip == 3)
|
||||||
|
{
|
||||||
|
// Full cycle
|
||||||
|
flip = m_flipCycle;
|
||||||
|
m_flipCycle++;
|
||||||
|
m_flipCycle = m_flipCycle % 2;
|
||||||
|
}
|
||||||
|
return flip;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ListZonesWidget::isNotPropogate() const
|
bool ListZonesWidget::isNotPropogate() const
|
||||||
|
@ -234,11 +282,12 @@ void ListZonesWidget::updateListZones()
|
||||||
std::vector<NLLIGO::CZoneBankElement *> currentSelection;
|
std::vector<NLLIGO::CZoneBankElement *> currentSelection;
|
||||||
zoneBank.getSelection (currentSelection);
|
zoneBank.getSelection (currentSelection);
|
||||||
|
|
||||||
QStringList listSelection;
|
m_listSelection.clear();
|
||||||
|
m_zoneNameCycle = 0;
|
||||||
for (size_t i = 0; i < currentSelection.size(); ++i)
|
for (size_t i = 0; i < currentSelection.size(); ++i)
|
||||||
listSelection << currentSelection[i]->getName().c_str();
|
m_listSelection << currentSelection[i]->getName().c_str();
|
||||||
|
|
||||||
m_listZonesModel->setListZones(listSelection);
|
m_listZonesModel->setListZones(m_listSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListZonesWidget::disableSignals(bool block)
|
void ListZonesWidget::disableSignals(bool block)
|
||||||
|
|
|
@ -45,9 +45,9 @@ public:
|
||||||
|
|
||||||
void updateUi();
|
void updateUi();
|
||||||
void setZoneBuilder(ZoneBuilder *zoneBuilder);
|
void setZoneBuilder(ZoneBuilder *zoneBuilder);
|
||||||
QString currentZoneName() const;
|
QString currentZoneName();
|
||||||
int currentRot() const;
|
int currentRot();
|
||||||
int currentFlip() const;
|
int currentFlip();
|
||||||
bool isNotPropogate() const;
|
bool isNotPropogate() const;
|
||||||
bool isForce() const;
|
bool isForce() const;
|
||||||
|
|
||||||
|
@ -62,6 +62,10 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
void disableSignals(bool block);
|
void disableSignals(bool block);
|
||||||
|
|
||||||
|
int m_rotCycle, m_flipCycle;
|
||||||
|
int m_zoneNameCycle;
|
||||||
|
QStringList m_listSelection;
|
||||||
|
|
||||||
ListZonesModel *m_listZonesModel;
|
ListZonesModel *m_listZonesModel;
|
||||||
ZoneBuilder *m_zoneBuilder;
|
ZoneBuilder *m_zoneBuilder;
|
||||||
Ui::ListZonesWidget m_ui;
|
Ui::ListZonesWidget m_ui;
|
||||||
|
|
|
@ -39,7 +39,12 @@
|
||||||
<widget class="QComboBox" name="categoryValueComboBox_1"/>
|
<widget class="QComboBox" name="categoryValueComboBox_1"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="0" column="3">
|
||||||
<widget class="QComboBox" name="comboBox_11">
|
<widget class="QComboBox" name="zoneSelectComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Select</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Random</string>
|
<string>Random</string>
|
||||||
|
@ -297,6 +302,9 @@
|
||||||
<property name="verticalScrollMode">
|
<property name="verticalScrollMode">
|
||||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Loading…
Reference in a new issue