1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Better army widget

This commit is contained in:
nordsoft
2023-09-10 16:56:41 +02:00
parent 96433436dd
commit e912a2db38
3 changed files with 145 additions and 209 deletions

View File

@@ -31,7 +31,6 @@ ArmyWidget::ArmyWidget(CArmedInstance & a, QWidget *parent) :
for(int i = 0; i < TOTAL_SLOTS; ++i)
{
uiCounts[i]->setText("1");
uiSlots[i]->addItem("");
uiSlots[i]->setItemData(0, -1);
@@ -64,7 +63,7 @@ void ArmyWidget::obtainData()
{
auto * creature = army.getCreature(SlotID(i));
uiSlots[i]->setCurrentIndex(searchItemIndex(i, creature->getId()));
uiCounts[i]->setText(QString::number(army.getStackCount(SlotID(i))));
uiCounts[i]->setValue(army.getStackCount(SlotID(i)));
}
}
@@ -88,7 +87,7 @@ bool ArmyWidget::commitChanges()
else
{
isArmed = true;
int amount = uiCounts[i]->text().toInt();
int amount = uiCounts[i]->value();
if(amount)
{
army.setCreature(SlotID(i), creId, amount);

View File

@@ -35,7 +35,7 @@ private:
Ui::ArmyWidget *ui;
CArmedInstance & army;
std::array<QLineEdit*, TOTAL_SLOTS> uiCounts;
std::array<QSpinBox*, TOTAL_SLOTS> uiCounts;
std::array<QComboBox*, TOTAL_SLOTS> uiSlots;
};

View File

@@ -20,8 +20,8 @@
<string>Army settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0">
<widget class="QComboBox" name="slot6">
<item row="5" column="0">
<widget class="QComboBox" name="slot5">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -40,6 +40,16 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QComboBox" name="slot6">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QComboBox" name="slot2">
<property name="sizePolicy">
@@ -50,164 +60,6 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="count6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="count2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="count1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="count5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QRadioButton" name="formationWide">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Wide formation</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="count3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="slot1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="slot0">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QComboBox" name="slot4">
<property name="sizePolicy">
@@ -218,33 +70,8 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="count4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QComboBox" name="slot5">
<item row="0" column="0">
<widget class="QComboBox" name="slot0">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -253,29 +80,14 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="count0">
<item row="1" column="0">
<widget class="QComboBox" name="slot1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
</widget>
</item>
<item row="8" column="0">
@@ -291,6 +103,131 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QRadioButton" name="formationWide">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Wide formation</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="count0">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="count1">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="count2">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="count3">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="count4">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="count5">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="count6">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::PlusMinus</enum>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>