Change 2x2 limit to 4x2 on tileset editor selection

This commit is contained in:
Diegoisawesome 2018-10-08 21:10:57 -05:00
parent c102a2b7d0
commit 41a0c1d2d2
5 changed files with 129 additions and 94 deletions

View file

@ -202,6 +202,12 @@
<enum>Qt::Horizontal</enum>
</property>
<widget class="QFrame" name="frame_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
@ -580,6 +586,12 @@
</layout>
</widget>
<widget class="QFrame" name="frame_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>

View file

@ -30,6 +30,21 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="1" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
@ -138,6 +153,70 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Metatile Properties</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Bottom/Top</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Metatile Behavior</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QComboBox" name="comboBox_metatileBehaviors"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Layer Type</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QComboBox" name="comboBox_layerType"/>
</item>
<item row="1" column="0">
<widget class="QGraphicsView" name="graphicsView_metatileLayers">
<property name="minimumSize">
<size>
<width>66</width>
<height>34</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>66</width>
<height>34</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
@ -164,6 +243,16 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBox_xFlip">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
@ -171,6 +260,13 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBox_yFlip">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
@ -184,24 +280,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBox_xFlip">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBox_yFlip">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="0" colspan="2">
<widget class="QGraphicsView" name="graphicsView_selectedTile">
<property name="minimumSize">
<size>
@ -211,7 +290,7 @@
</property>
<property name="maximumSize">
<size>
<width>34</width>
<width>66</width>
<height>34</height>
</size>
</property>
@ -229,70 +308,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Metatile Properties</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Bottom/Top</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGraphicsView" name="graphicsView_metatileLayers">
<property name="minimumSize">
<size>
<width>66</width>
<height>34</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>66</width>
<height>34</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Metatile Behavior</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QComboBox" name="comboBox_metatileBehaviors"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Layer Type</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QComboBox" name="comboBox_layerType"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
@ -311,6 +326,18 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">

View file

@ -9,7 +9,7 @@
class MetatileLayersItem: public SelectablePixmapItem {
Q_OBJECT
public:
MetatileLayersItem(Metatile *metatile, Tileset *primaryTileset, Tileset *secondaryTileset): SelectablePixmapItem(16, 16, 2, 2) {
MetatileLayersItem(Metatile *metatile, Tileset *primaryTileset, Tileset *secondaryTileset): SelectablePixmapItem(16, 16, 4, 2) {
this->metatile = metatile;
this->primaryTileset = primaryTileset;
this->secondaryTileset = secondaryTileset;

View file

@ -7,7 +7,7 @@
class TilesetEditorTileSelector: public SelectablePixmapItem {
Q_OBJECT
public:
TilesetEditorTileSelector(Tileset *primaryTileset, Tileset *secondaryTileset): SelectablePixmapItem(16, 16, 2, 2) {
TilesetEditorTileSelector(Tileset *primaryTileset, Tileset *secondaryTileset): SelectablePixmapItem(16, 16, 4, 2) {
this->primaryTileset = primaryTileset;
this->secondaryTileset = secondaryTileset;
this->numTilesWide = 16;

View file

@ -195,21 +195,17 @@ void TilesetEditor::onSelectedTilesChanged() {
void TilesetEditor::onMetatileLayerTileChanged(int x, int y) {
Metatile *prevMetatile = this->metatile->copy();
int maxTileIndex = x < 2 ? 3 : 7;
QPoint dimensions = this->tileSelector->getSelectionDimensions();
QList<Tile> tiles = this->tileSelector->getSelectedTiles();
int selectedTileIndex = 0;
for (int j = 0; j < dimensions.y(); j++) {
for (int i = 0; i < dimensions.x(); i++) {
int tileIndex = ((x + i) / 2 * 4) + ((y + j) * 2) + ((x + i) % 2);
if (tileIndex <= maxTileIndex) {
Tile tile = this->metatile->tiles->at(tileIndex);
tile.tile = tiles.at(selectedTileIndex).tile;
tile.xflip = tiles.at(selectedTileIndex).xflip;
tile.yflip = tiles.at(selectedTileIndex).yflip;
tile.palette = tiles.at(selectedTileIndex).palette;
(*this->metatile->tiles)[tileIndex] = tile;
}
Tile *tile = &(*this->metatile->tiles)[tileIndex];
tile->tile = tiles.at(selectedTileIndex).tile;
tile->xflip = tiles.at(selectedTileIndex).xflip;
tile->yflip = tiles.at(selectedTileIndex).yflip;
tile->palette = tiles.at(selectedTileIndex).palette;
selectedTileIndex++;
}
}