Allow editing border dimensions

This commit is contained in:
GriffinR 2020-03-14 03:44:55 -04:00
parent 629abd3c06
commit c0a512803e
12 changed files with 645 additions and 398 deletions

View file

@ -7,15 +7,15 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1117</width> <width>1117</width>
<height>747</height> <height>788</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>porymap</string> <string>porymap</string>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QGridLayout" name="gridLayout_15">
<item> <item row="0" column="0">
<widget class="QSplitter" name="splitter_main"> <widget class="QSplitter" name="splitter_main">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -512,7 +512,7 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="pushButton_ChangeDimensions">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Change a map layout's width and height.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Change a map layout's width and height.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
@ -561,8 +561,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>469</width> <width>545</width>
<height>608</height> <height>628</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_8"> <layout class="QGridLayout" name="gridLayout_8">
@ -736,305 +736,6 @@
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
</property> </property>
<item row="0" column="0">
<widget class="QFrame" name="frame_Tilesets">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_PrimaryTileset">
<property name="text">
<string>Primary Tileset</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="NoScrollComboBox" name="comboBox_PrimaryTileset">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Primary Tileset&lt;/p&gt;&lt;p&gt;Defines the first 0x200 metatiles available for the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_SecondaryTileset">
<property name="text">
<string>Secondary Tileset</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="NoScrollComboBox" name="comboBox_SecondaryTileset">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Secondary Tileset&lt;/p&gt;&lt;p&gt;Defines the second 0x200 metatiles available for the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="frame_currentMetatileSelection">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>92</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>92</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<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>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Selection</string>
</property>
<layout class="QGridLayout" name="gridLayout_17">
<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="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea_6">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_6">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<height>77</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing">
<number>0</number>
</property>
<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>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGraphicsView" name="graphicsView_currentMetatileSelection">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="interactive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Border</string>
</property>
<layout class="QGridLayout" name="gridLayout_16">
<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="spacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QGraphicsView" name="graphicsView_BorderMetatile">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>48</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The border is a 2x2 metatile which is repeated outside of the map layout's boundary. Draw on this border area to modify it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QScrollArea" name="scrollArea_2"> <widget class="QScrollArea" name="scrollArea_2">
<property name="sizePolicy"> <property name="sizePolicy">
@ -1064,10 +765,10 @@
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>8</x>
<y>0</y> <y>0</y>
<width>307</width> <width>221</width>
<height>362</height> <height>324</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -1160,6 +861,309 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QFrame" name="frame_currentMetatileSelection">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>92</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>92</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<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>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Selection</string>
</property>
<layout class="QGridLayout" name="gridLayout_17">
<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="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea_6">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_6">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>256</width>
<height>74</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing">
<number>0</number>
</property>
<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>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGraphicsView" name="graphicsView_currentMetatileSelection">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="interactive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>110</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>110</height>
</size>
</property>
<property name="title">
<string>Border</string>
</property>
<layout class="QGridLayout" name="gridLayout_16">
<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="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<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="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>231</width>
<height>83</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_18">
<item row="0" column="0">
<widget class="QGraphicsView" name="graphicsView_BorderMetatile">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The border is a group of metatiles which are repeated outside of the map layout's boundary. Draw on this border area to modify it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QSlider" name="horizontalSlider_MetatileZoom"> <widget class="QSlider" name="horizontalSlider_MetatileZoom">
<property name="minimum"> <property name="minimum">
@ -1176,6 +1180,64 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QFrame" name="frame_Tilesets">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_PrimaryTileset">
<property name="text">
<string>Primary Tileset</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="NoScrollComboBox" name="comboBox_PrimaryTileset">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Primary Tileset&lt;/p&gt;&lt;p&gt;Defines the first 0x200 metatiles available for the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_SecondaryTileset">
<property name="text">
<string>Secondary Tileset</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="NoScrollComboBox" name="comboBox_SecondaryTileset">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Secondary Tileset&lt;/p&gt;&lt;p&gt;Defines the second 0x200 metatiles available for the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_collision"> <widget class="QWidget" name="tab_collision">
@ -1344,8 +1406,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>381</width> <width>371</width>
<height>657</height> <height>684</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_7"> <layout class="QGridLayout" name="gridLayout_7">
@ -1618,7 +1680,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>430</width> <width>430</width>
<height>568</height> <height>575</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -2095,21 +2157,21 @@
</widget> </widget>
</item> </item>
<item row="11" column="0"> <item row="11" column="0">
<widget class="QLabel" name="label_FloorNumber"> <widget class="QLabel" name="label_FloorNumber">
<property name="text"> <property name="text">
<string>Floor Number</string> <string>Floor Number</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="1"> <item row="11" column="1">
<widget class="QSpinBox" name="spinBox_FloorNumber"> <widget class="QSpinBox" name="spinBox_FloorNumber">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Floor number to be used for maps with elevators.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Floor number to be used for maps with elevators.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>127</number> <number>127</number>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -2548,8 +2610,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>826</width> <width>818</width>
<height>557</height> <height>574</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_14"> <layout class="QGridLayout" name="gridLayout_14">
@ -2813,7 +2875,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1117</width> <width>1117</width>
<height>21</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">

View file

@ -73,7 +73,7 @@
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_NewMap_Width"> <widget class="QLabel" name="label_NewMap_Width">
<property name="text"> <property name="text">
<string>Width</string> <string>Map Width</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -90,7 +90,7 @@
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_NewMap_Height"> <widget class="QLabel" name="label_NewMap_Height">
<property name="text"> <property name="text">
<string>Height</string> <string>Map Height</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -105,13 +105,47 @@
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_NewMap_BorderWidth">
<property name="text">
<string>Border Width</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="spinBox_NewMap_BorderWidth">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Width (in blocks) of the new map's border.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_NewMap_BorderHeight">
<property name="text">
<string>Border Height</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="spinBox_NewMap_BorderHeight">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Height (in blocks) of the new map's border.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_NewMap_Primary_Tileset"> <widget class="QLabel" name="label_NewMap_Primary_Tileset">
<property name="text"> <property name="text">
<string>Primary Tileset</string> <string>Primary Tileset</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="6" column="1">
<widget class="NoScrollComboBox" name="comboBox_NewMap_Primary_Tileset"> <widget class="NoScrollComboBox" name="comboBox_NewMap_Primary_Tileset">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The primary tileset for the new map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The primary tileset for the new map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -121,14 +155,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="7" column="0">
<widget class="QLabel" name="label_NewMap_Secondary_Tileset"> <widget class="QLabel" name="label_NewMap_Secondary_Tileset">
<property name="text"> <property name="text">
<string>Secondary Tileset</string> <string>Secondary Tileset</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="7" column="1">
<widget class="NoScrollComboBox" name="comboBox_NewMap_Secondary_Tileset"> <widget class="NoScrollComboBox" name="comboBox_NewMap_Secondary_Tileset">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The secondary tileset for the new map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The secondary tileset for the new map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -138,14 +172,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="8" column="0">
<widget class="QLabel" name="label_NewMap_Type"> <widget class="QLabel" name="label_NewMap_Type">
<property name="text"> <property name="text">
<string>Type</string> <string>Type</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="8" column="1">
<widget class="NoScrollComboBox" name="comboBox_NewMap_Type"> <widget class="NoScrollComboBox" name="comboBox_NewMap_Type">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The map type is a general attribute, which is used for many different things. For example. it determines whether biking or running is allowed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The map type is a general attribute, which is used for many different things. For example. it determines whether biking or running is allowed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -155,14 +189,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="9" column="0">
<widget class="QLabel" name="label_NewMap_Location"> <widget class="QLabel" name="label_NewMap_Location">
<property name="text"> <property name="text">
<string>Location</string> <string>Location</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="9" column="1">
<widget class="NoScrollComboBox" name="comboBox_NewMap_Location"> <widget class="NoScrollComboBox" name="comboBox_NewMap_Location">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The section of the region map which the map is grouped under. This also determines the name of the map that is displayed when the player enters it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The section of the region map which the map is grouped under. This also determines the name of the map that is displayed when the player enters it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -172,14 +206,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="10" column="0">
<widget class="QLabel" name="label_NewMap_Flyable"> <widget class="QLabel" name="label_NewMap_Flyable">
<property name="text"> <property name="text">
<string>Can Fly To</string> <string>Can Fly To</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="10" column="1">
<widget class="QCheckBox" name="checkBox_NewMap_Flyable"> <widget class="QCheckBox" name="checkBox_NewMap_Flyable">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether to add a heal location to the new map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether to add a heal location to the new map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -189,56 +223,56 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0"> <item row="11" column="0">
<widget class="QLabel" name="label_NewMap_Allow_Running"> <widget class="QLabel" name="label_NewMap_Allow_Running">
<property name="text"> <property name="text">
<string>Allow Running</string> <string>Allow Running</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="0"> <item row="12" column="0">
<widget class="QLabel" name="label_NewMap_Allow_Biking"> <widget class="QLabel" name="label_NewMap_Allow_Biking">
<property name="text"> <property name="text">
<string>Allow Biking</string> <string>Allow Biking</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="0"> <item row="13" column="0">
<widget class="QLabel" name="label_NewMap_Allow_Escape_Rope"> <widget class="QLabel" name="label_NewMap_Allow_Escape_Rope">
<property name="text"> <property name="text">
<string>Allow Escape Rope</string> <string>Allow Escape Rope</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="11" column="1">
<widget class="QCheckBox" name="checkBox_NewMap_Allow_Running"> <widget class="QCheckBox" name="checkBox_NewMap_Allow_Running">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="1"> <item row="12" column="1">
<widget class="QCheckBox" name="checkBox_NewMap_Allow_Biking"> <widget class="QCheckBox" name="checkBox_NewMap_Allow_Biking">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="1"> <item row="13" column="1">
<widget class="QCheckBox" name="checkBox_NewMap_Allow_Escape_Rope"> <widget class="QCheckBox" name="checkBox_NewMap_Allow_Escape_Rope">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="0"> <item row="14" column="0">
<widget class="QLabel" name="label_NewMap_Floor_Number"> <widget class="QLabel" name="label_NewMap_Floor_Number">
<property name="text"> <property name="text">
<string>Floor Number</string> <string>Floor Number</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="1"> <item row="14" column="1">
<widget class="QSpinBox" name="spinBox_NewMap_Floor_Number"> <widget class="QSpinBox" name="spinBox_NewMap_Floor_Number">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Floor number to be used for maps with elevators.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Floor number to be used for maps with elevators.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>

View file

@ -6,9 +6,12 @@
class HistoryItem { class HistoryItem {
public: public:
Blockdata *metatiles; Blockdata *metatiles;
Blockdata *border;
int layoutWidth; int layoutWidth;
int layoutHeight; int layoutHeight;
HistoryItem(Blockdata *metatiles, int layoutWidth, int layoutHeight); int borderWidth;
int borderHeight;
HistoryItem(Blockdata *metatiles, Blockdata *border, int layoutWidth, int layoutHeight, int borderWidth, int borderHeight);
~HistoryItem(); ~HistoryItem();
}; };

View file

@ -17,6 +17,10 @@
#define DEFAULT_BORDER_WIDTH 2 #define DEFAULT_BORDER_WIDTH 2
#define DEFAULT_BORDER_HEIGHT 2 #define DEFAULT_BORDER_HEIGHT 2
// Number of metatiles to draw out from edge of map. Could allow modification of this in the future.
// porymap will reflect changes to it, but the value is hard-coded in the projects at the moment
#define BORDER_DISTANCE 6
class Map : public QObject class Map : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -65,7 +69,8 @@ public:
int getBorderHeight(); int getBorderHeight();
QPixmap render(bool ignoreCache, MapLayout * fromLayout = nullptr); QPixmap render(bool ignoreCache, MapLayout * fromLayout = nullptr);
QPixmap renderCollision(qreal opacity, bool ignoreCache); QPixmap renderCollision(qreal opacity, bool ignoreCache);
bool blockChanged(int, Blockdata*); bool mapBlockChanged(int i, Blockdata * cache);
bool borderBlockChanged(int i, Blockdata * cache);
void cacheBlockdata(); void cacheBlockdata();
void cacheCollision(); void cacheCollision();
Block *getBlock(int x, int y); Block *getBlock(int x, int y);
@ -82,12 +87,14 @@ public:
void addEvent(Event*); void addEvent(Event*);
QPixmap renderConnection(MapConnection, MapLayout *); QPixmap renderConnection(MapConnection, MapLayout *);
QPixmap renderBorder(); QPixmap renderBorder();
void setDimensions(int newWidth, int newHeight, bool setNewBlockData = true); void setDimensions(int newWidth, int newHeight, bool setNewBlockdata = true);
void setBorderDimensions(int newWidth, int newHeight, bool setNewBlockdata = true);
void cacheBorder(); void cacheBorder();
bool hasUnsavedChanges(); bool hasUnsavedChanges();
private: private:
void setNewDimensionsBlockdata(int newWidth, int newHeight); void setNewDimensionsBlockdata(int newWidth, int newHeight);
void setNewBorderDimensionsBlockdata(int newWidth, int newHeight);
signals: signals:
void mapChanged(Map *map); void mapChanged(Map *map);

View file

@ -119,7 +119,7 @@ private slots:
void on_comboBox_EmergeMap_currentTextChanged(const QString &mapName); void on_comboBox_EmergeMap_currentTextChanged(const QString &mapName);
void on_comboBox_PrimaryTileset_currentTextChanged(const QString &arg1); void on_comboBox_PrimaryTileset_currentTextChanged(const QString &arg1);
void on_comboBox_SecondaryTileset_currentTextChanged(const QString &arg1); void on_comboBox_SecondaryTileset_currentTextChanged(const QString &arg1);
void on_pushButton_clicked(); void on_pushButton_ChangeDimensions_clicked();
void on_checkBox_smartPaths_stateChanged(int selected); void on_checkBox_smartPaths_stateChanged(int selected);
void on_checkBox_Visibility_clicked(bool checked); void on_checkBox_Visibility_clicked(bool checked);
void on_checkBox_ToggleBorder_stateChanged(int arg1); void on_checkBox_ToggleBorder_stateChanged(int arg1);

View file

@ -1,13 +1,17 @@
#include "historyitem.h" #include "historyitem.h"
HistoryItem::HistoryItem(Blockdata *metatiles, int layoutWidth, int layoutHeight) { HistoryItem::HistoryItem(Blockdata *metatiles, Blockdata *border, int layoutWidth, int layoutHeight, int borderWidth, int borderHeight) {
this->metatiles = metatiles; this->metatiles = metatiles;
this->border = border;
this->layoutWidth = layoutWidth; this->layoutWidth = layoutWidth;
this->layoutHeight = layoutHeight; this->layoutHeight = layoutHeight;
this->borderWidth = borderWidth;
this->borderHeight = borderHeight;
} }
HistoryItem::~HistoryItem() { HistoryItem::~HistoryItem() {
if (this->metatiles) delete this->metatiles; if (this->metatiles) delete this->metatiles;
if (this->border) delete this->border;
} }
RegionMapHistoryItem::RegionMapHistoryItem(int which, QVector<uint8_t> tiles, QString cityMap) { RegionMapHistoryItem::RegionMapHistoryItem(int which, QVector<uint8_t> tiles, QString cityMap) {

View file

@ -67,7 +67,7 @@ int Map::getBorderHeight() {
return layout->border_height.toInt(nullptr, 0); return layout->border_height.toInt(nullptr, 0);
} }
bool Map::blockChanged(int i, Blockdata *cache) { bool Map::mapBlockChanged(int i, Blockdata *cache) {
if (!cache) if (!cache)
return true; return true;
if (!layout->blockdata) if (!layout->blockdata)
@ -84,6 +84,23 @@ bool Map::blockChanged(int i, Blockdata *cache) {
return layout->blockdata->blocks->value(i) != cache->blocks->value(i); return layout->blockdata->blocks->value(i) != cache->blocks->value(i);
} }
bool Map::borderBlockChanged(int i, Blockdata *cache) {
if (!cache)
return true;
if (!layout->border)
return true;
if (!cache->blocks)
return true;
if (!layout->border->blocks)
return true;
if (cache->blocks->length() <= i)
return true;
if (layout->border->blocks->length() <= i)
return true;
return layout->border->blocks->value(i) != cache->blocks->value(i);
}
void Map::cacheBorder() { void Map::cacheBorder() {
if (layout->cached_border) delete layout->cached_border; if (layout->cached_border) delete layout->cached_border;
layout->cached_border = new Blockdata; layout->cached_border = new Blockdata;
@ -135,7 +152,7 @@ QPixmap Map::renderCollision(qreal opacity, bool ignoreCache) {
} }
QPainter painter(&collision_image); QPainter painter(&collision_image);
for (int i = 0; i < layout->blockdata->blocks->length(); i++) { for (int i = 0; i < layout->blockdata->blocks->length(); i++) {
if (!ignoreCache && layout->cached_collision && !blockChanged(i, layout->cached_collision)) { if (!ignoreCache && layout->cached_collision && !mapBlockChanged(i, layout->cached_collision)) {
continue; continue;
} }
changed_any = true; changed_any = true;
@ -179,7 +196,7 @@ QPixmap Map::render(bool ignoreCache = false, MapLayout * fromLayout) {
QPainter painter(&image); QPainter painter(&image);
for (int i = 0; i < layout->blockdata->blocks->length(); i++) { for (int i = 0; i < layout->blockdata->blocks->length(); i++) {
if (!ignoreCache && !blockChanged(i, layout->cached_blockdata)) { if (!ignoreCache && !mapBlockChanged(i, layout->cached_blockdata)) {
continue; continue;
} }
changed_any = true; changed_any = true;
@ -204,27 +221,33 @@ QPixmap Map::render(bool ignoreCache = false, MapLayout * fromLayout) {
} }
QPixmap Map::renderBorder() { QPixmap Map::renderBorder() {
bool changed_any = false; bool changed_any = false, border_resized = false;
int width_ = getBorderWidth(); int width_ = getBorderWidth();
int height_ = getBorderHeight(); int height_ = getBorderHeight();
if (layout->border_image.isNull()) { if (layout->border_image.isNull()) {
layout->border_image = QImage(width_ * 16, height_ * 16, QImage::Format_RGBA8888); layout->border_image = QImage(width_ * 16, height_ * 16, QImage::Format_RGBA8888);
changed_any = true; changed_any = true;
} }
if (layout->border_image.width() != width_ * 16 || layout->border_image.height() != height_ * 16) {
layout->border_image = QImage(width_ * 16, height_ * 16, QImage::Format_RGBA8888);
border_resized = true;
}
if (!(layout->border && layout->border->blocks)) { if (!(layout->border && layout->border->blocks)) {
layout->border_pixmap = layout->border_pixmap.fromImage(layout->border_image); layout->border_pixmap = layout->border_pixmap.fromImage(layout->border_image);
return layout->border_pixmap; return layout->border_pixmap;
} }
QPainter painter(&layout->border_image); QPainter painter(&layout->border_image);
for (int i = 0; i < layout->border->blocks->length(); i++) { for (int i = 0; i < layout->border->blocks->length(); i++) {
if (!blockChanged(i, layout->cached_border)) { if (!border_resized && !borderBlockChanged(i, layout->cached_border)) {
continue; continue;
} }
changed_any = true; changed_any = true;
Block block = layout->border->blocks->value(i); Block block = layout->border->blocks->value(i);
QImage metatile_image = getMetatileImage(block.tile, layout->tileset_primary, layout->tileset_secondary); uint16_t tile = block.tile;
int map_y = i / width_; QImage metatile_image = getMetatileImage(tile, layout->tileset_primary, layout->tileset_secondary);
int map_x = i % width_; int map_y = width_ ? i / width_ : 0;
int map_x = width_ ? i % width_ : 0;
painter.drawImage(QPoint(map_x * 16, map_y * 16), metatile_image); painter.drawImage(QPoint(map_x * 16, map_y * 16), metatile_image);
} }
painter.end(); painter.end();
@ -240,23 +263,23 @@ QPixmap Map::renderConnection(MapConnection connection, MapLayout * fromLayout)
int x, y, w, h; int x, y, w, h;
if (connection.direction == "up") { if (connection.direction == "up") {
x = 0; x = 0;
y = getHeight() - 6; y = getHeight() - BORDER_DISTANCE;
w = getWidth(); w = getWidth();
h = 6; h = BORDER_DISTANCE;
} else if (connection.direction == "down") { } else if (connection.direction == "down") {
x = 0; x = 0;
y = 0; y = 0;
w = getWidth(); w = getWidth();
h = 6; h = BORDER_DISTANCE;
} else if (connection.direction == "left") { } else if (connection.direction == "left") {
x = getWidth() - 6; x = getWidth() - BORDER_DISTANCE;
y = 0; y = 0;
w = 6; w = BORDER_DISTANCE;
h = getHeight(); h = getHeight();
} else if (connection.direction == "right") { } else if (connection.direction == "right") {
x = 0; x = 0;
y = 0; y = 0;
w = 6; w = BORDER_DISTANCE;
h = getHeight(); h = getHeight();
} else { } else {
// this should not happen // this should not happen
@ -289,6 +312,25 @@ void Map::setNewDimensionsBlockdata(int newWidth, int newHeight) {
layout->blockdata->copyFrom(newBlockData); layout->blockdata->copyFrom(newBlockData);
} }
void Map::setNewBorderDimensionsBlockdata(int newWidth, int newHeight) {
int oldWidth = getBorderWidth();
int oldHeight = getBorderHeight();
Blockdata* newBlockData = new Blockdata;
for (int y = 0; y < newHeight; y++)
for (int x = 0; x < newWidth; x++) {
if (x < oldWidth && y < oldHeight) {
int index = y * oldWidth + x;
newBlockData->addBlock(layout->border->blocks->value(index));
} else {
newBlockData->addBlock(0);
}
}
layout->border->copyFrom(newBlockData);
}
void Map::setDimensions(int newWidth, int newHeight, bool setNewBlockdata) { void Map::setDimensions(int newWidth, int newHeight, bool setNewBlockdata) {
if (setNewBlockdata) { if (setNewBlockdata) {
setNewDimensionsBlockdata(newWidth, newHeight); setNewDimensionsBlockdata(newWidth, newHeight);
@ -300,6 +342,17 @@ void Map::setDimensions(int newWidth, int newHeight, bool setNewBlockdata) {
emit mapChanged(this); emit mapChanged(this);
} }
void Map::setBorderDimensions(int newWidth, int newHeight, bool setNewBlockdata) {
if (setNewBlockdata) {
setNewBorderDimensionsBlockdata(newWidth, newHeight);
}
layout->border_width = QString::number(newWidth);
layout->border_height = QString::number(newHeight);
emit mapChanged(this);
}
Block* Map::getBlock(int x, int y) { Block* Map::getBlock(int x, int y) {
if (layout->blockdata && layout->blockdata->blocks) { if (layout->blockdata && layout->blockdata->blocks) {
if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) { if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
@ -354,35 +407,64 @@ void Map::_floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_
} }
void Map::undo() { void Map::undo() {
bool redraw = false, changed = false;
HistoryItem *commit = metatileHistory.back(); HistoryItem *commit = metatileHistory.back();
if (!commit) if (!commit)
return; return;
if (layout->blockdata) { if (layout->blockdata) {
layout->blockdata->copyFrom(commit->metatiles); layout->blockdata->copyFrom(commit->metatiles);
if (commit->layoutWidth != this->getWidth() || commit->layoutHeight != this->getHeight()) if (commit->layoutWidth != this->getWidth() || commit->layoutHeight != this->getHeight()) {
{
this->setDimensions(commit->layoutWidth, commit->layoutHeight, false); this->setDimensions(commit->layoutWidth, commit->layoutHeight, false);
emit mapNeedsRedrawing(); redraw = true;
} }
changed = true;
}
if (layout->border) {
layout->border->copyFrom(commit->border);
if (commit->borderWidth != this->getBorderWidth() || commit->borderHeight != this->getBorderHeight()) {
this->setBorderDimensions(commit->borderWidth, commit->borderHeight, false);
redraw = true;
}
changed = true;
}
if (redraw) {
emit mapNeedsRedrawing();
}
if (changed) {
emit mapChanged(this); emit mapChanged(this);
} }
} }
void Map::redo() { void Map::redo() {
bool redraw = false, changed = false;
HistoryItem *commit = metatileHistory.next(); HistoryItem *commit = metatileHistory.next();
if (!commit) if (!commit)
return; return;
if (layout->blockdata) { if (layout->blockdata) {
layout->blockdata->copyFrom(commit->metatiles); layout->blockdata->copyFrom(commit->metatiles);
if (commit->layoutWidth != this->getWidth() || commit->layoutHeight != this->getHeight()) if (commit->layoutWidth != this->getWidth() || commit->layoutHeight != this->getHeight()) {
{
this->setDimensions(commit->layoutWidth, commit->layoutHeight, false); this->setDimensions(commit->layoutWidth, commit->layoutHeight, false);
emit mapNeedsRedrawing(); redraw = true;
} }
changed = true;
}
if (layout->border) {
layout->border->copyFrom(commit->border);
if (commit->borderWidth != this->getBorderWidth() || commit->borderHeight != this->getBorderHeight()) {
this->setBorderDimensions(commit->borderWidth, commit->borderHeight, false);
redraw = true;
}
changed = true;
}
if (redraw) {
emit mapNeedsRedrawing();
}
if (changed) {
emit mapChanged(this); emit mapChanged(this);
} }
} }
@ -392,14 +474,22 @@ void Map::commit() {
return; return;
} }
int layoutWidth = this->getWidth();
int layoutHeight = this->getHeight();
int borderWidth = this->getBorderWidth();
int borderHeight = this->getBorderHeight();
if (layout->blockdata) { if (layout->blockdata) {
HistoryItem *item = metatileHistory.current(); HistoryItem *item = metatileHistory.current();
bool atCurrentHistory = item bool atCurrentHistory = item
&& layout->blockdata->equals(item->metatiles) && layout->blockdata->equals(item->metatiles)
&& this->getWidth() == item->layoutWidth && layout->border->equals(item->border)
&& this->getHeight() == item->layoutHeight; && layoutWidth == item->layoutWidth
&& layoutHeight == item->layoutHeight
&& borderWidth == item->borderWidth
&& borderHeight == item->borderHeight;
if (!atCurrentHistory) { if (!atCurrentHistory) {
HistoryItem *commit = new HistoryItem(layout->blockdata->copy(), this->getWidth(), this->getHeight()); HistoryItem *commit = new HistoryItem(layout->blockdata->copy(), layout->border->copy(), layoutWidth, layoutHeight, borderWidth, borderHeight);
metatileHistory.push(commit); metatileHistory.push(commit);
emit mapChanged(this); emit mapChanged(this);
} }

View file

@ -1136,10 +1136,10 @@ void Editor::displayMapMetatiles() {
int tw = 16; int tw = 16;
int th = 16; int th = 16;
scene->setSceneRect( scene->setSceneRect(
-6 * tw, -BORDER_DISTANCE * tw,
-6 * th, -BORDER_DISTANCE * th,
map_item->pixmap().width() + 12 * tw, map_item->pixmap().width() + (BORDER_DISTANCE * 2) * tw,
map_item->pixmap().height() + 12 * th map_item->pixmap().height() + (BORDER_DISTANCE * 2) * th
); );
} }
@ -1335,8 +1335,8 @@ void Editor::displayMapBorder() {
borderItems.clear(); borderItems.clear();
QPixmap pixmap = map->renderBorder(); QPixmap pixmap = map->renderBorder();
for (int y = -6; y < map->getHeight() + 6; y += map->getBorderHeight()) for (int y = -BORDER_DISTANCE; y < map->getHeight() + BORDER_DISTANCE; y += map->getBorderHeight())
for (int x = -6; x < map->getWidth() + 6; x += map->getBorderWidth()) { for (int x = -BORDER_DISTANCE; x < map->getWidth() + BORDER_DISTANCE; x += map->getBorderWidth()) {
QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap); QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap);
item->setX(x * 16); item->setX(x * 16);
item->setY(y * 16); item->setY(y * 16);

View file

@ -2150,7 +2150,7 @@ void MainWindow::on_comboBox_SecondaryTileset_currentTextChanged(const QString &
} }
} }
void MainWindow::on_pushButton_clicked() void MainWindow::on_pushButton_ChangeDimensions_clicked()
{ {
QDialog dialog(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint); QDialog dialog(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
dialog.setWindowTitle("Change Map Dimensions"); dialog.setWindowTitle("Change Map Dimensions");
@ -2160,15 +2160,31 @@ void MainWindow::on_pushButton_clicked()
QSpinBox *widthSpinBox = new QSpinBox(); QSpinBox *widthSpinBox = new QSpinBox();
QSpinBox *heightSpinBox = new QSpinBox(); QSpinBox *heightSpinBox = new QSpinBox();
QSpinBox *bwidthSpinBox = new QSpinBox();
QSpinBox *bheightSpinBox = new QSpinBox();
widthSpinBox->setMinimum(1); widthSpinBox->setMinimum(1);
heightSpinBox->setMinimum(1); heightSpinBox->setMinimum(1);
bwidthSpinBox->setMinimum(1);
bheightSpinBox->setMinimum(1);
// See below for explanation of maximum map dimensions // See below for explanation of maximum map dimensions
widthSpinBox->setMaximum(0x1E7); widthSpinBox->setMaximum(0x1E7);
heightSpinBox->setMaximum(0x1D1); heightSpinBox->setMaximum(0x1D1);
// Maximum based only on data type (u8) of map border width/height
bwidthSpinBox->setMaximum(255);
bheightSpinBox->setMaximum(255);
widthSpinBox->setValue(editor->map->getWidth()); widthSpinBox->setValue(editor->map->getWidth());
heightSpinBox->setValue(editor->map->getHeight()); heightSpinBox->setValue(editor->map->getHeight());
form.addRow(new QLabel("Width"), widthSpinBox); bwidthSpinBox->setValue(editor->map->getBorderWidth());
form.addRow(new QLabel("Height"), heightSpinBox); bheightSpinBox->setValue(editor->map->getBorderHeight());
if (projectConfig.getUseCustomBorderSize()) {
form.addRow(new QLabel("Map Width"), widthSpinBox);
form.addRow(new QLabel("Map Height"), heightSpinBox);
form.addRow(new QLabel("Border Width"), bwidthSpinBox);
form.addRow(new QLabel("Border Height"), bheightSpinBox);
} else {
form.addRow(new QLabel("Width"), widthSpinBox);
form.addRow(new QLabel("Height"), heightSpinBox);
}
QLabel *errorLabel = new QLabel(); QLabel *errorLabel = new QLabel();
QPalette errorPalette; QPalette errorPalette;
@ -2178,7 +2194,7 @@ void MainWindow::on_pushButton_clicked()
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);
form.addRow(&buttonBox); form.addRow(&buttonBox);
connect(&buttonBox, &QDialogButtonBox::accepted, [&dialog, &widthSpinBox, &heightSpinBox, &errorLabel](){ connect(&buttonBox, &QDialogButtonBox::accepted, [&dialog, &widthSpinBox, &heightSpinBox, &bwidthSpinBox, &bheightSpinBox, &errorLabel](){
// Ensure width and height are an acceptable size. // Ensure width and height are an acceptable size.
// The maximum number of metatiles in a map is the following: // The maximum number of metatiles in a map is the following:
// max = (width + 15) * (height + 14) // max = (width + 15) * (height + 14)
@ -2190,8 +2206,8 @@ void MainWindow::on_pushButton_clicked()
dialog.accept(); dialog.accept();
} else { } else {
QString errorText = QString("Error: The specified width and height are too large.\n" QString errorText = QString("Error: The specified width and height are too large.\n"
"The maximum width and height is the following: (width + 15) * (height + 14) <= 10240\n" "The maximum map width and height is the following: (width + 15) * (height + 14) <= 10240\n"
"The specified width and height was: (%1 + 15) * (%2 + 14) = %3") "The specified map width and height was: (%1 + 15) * (%2 + 14) = %3")
.arg(widthSpinBox->value()) .arg(widthSpinBox->value())
.arg(heightSpinBox->value()) .arg(heightSpinBox->value())
.arg(numMetatiles); .arg(numMetatiles);
@ -2205,6 +2221,7 @@ void MainWindow::on_pushButton_clicked()
if (dialog.exec() == QDialog::Accepted) { if (dialog.exec() == QDialog::Accepted) {
editor->map->setDimensions(widthSpinBox->value(), heightSpinBox->value()); editor->map->setDimensions(widthSpinBox->value(), heightSpinBox->value());
editor->map->setBorderDimensions(bwidthSpinBox->value(), bheightSpinBox->value());
editor->map->commit(); editor->map->commit();
onMapNeedsRedrawing(); onMapNeedsRedrawing();
} }

View file

@ -617,6 +617,8 @@ void Project::setNewMapLayout(Map* map) {
layout->name = QString("%1_Layout").arg(map->name); layout->name = QString("%1_Layout").arg(map->name);
layout->width = "20"; layout->width = "20";
layout->height = "20"; layout->height = "20";
layout->border_width = DEFAULT_BORDER_WIDTH;
layout->border_height = DEFAULT_BORDER_HEIGHT;
layout->border_path = QString("data/layouts/%1/border.bin").arg(map->name); layout->border_path = QString("data/layouts/%1/border.bin").arg(map->name);
layout->blockdata_path = QString("data/layouts/%1/map.bin").arg(map->name); layout->blockdata_path = QString("data/layouts/%1/map.bin").arg(map->name);
layout->tileset_primary_label = "gTileset_General"; layout->tileset_primary_label = "gTileset_General";
@ -1074,7 +1076,11 @@ bool Project::loadMapBorder(Map *map) {
void Project::setNewMapBorder(Map *map) { void Project::setNewMapBorder(Map *map) {
Blockdata *blockdata = new Blockdata; Blockdata *blockdata = new Blockdata;
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) { if (map->getBorderWidth() != DEFAULT_BORDER_WIDTH || map->getBorderHeight() != DEFAULT_BORDER_HEIGHT) {
for (int i = 0; i < map->getBorderWidth() * map->getBorderHeight(); i++) {
blockdata->addBlock(0);
}
} else if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
blockdata->addBlock(qint16(0x0014)); blockdata->addBlock(qint16(0x0014));
blockdata->addBlock(qint16(0x0015)); blockdata->addBlock(qint16(0x0015));
blockdata->addBlock(qint16(0x001C)); blockdata->addBlock(qint16(0x001C));

View file

@ -8,10 +8,12 @@ void BorderMetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
QPointF pos = event->pos(); QPointF pos = event->pos();
int x = static_cast<int>(pos.x()) / 16; int x = static_cast<int>(pos.x()) / 16;
int y = static_cast<int>(pos.y()) / 16; int y = static_cast<int>(pos.y()) / 16;
int width = map->getBorderWidth();
int height = map->getBorderHeight();
for (int i = 0; i < selectionDimensions.x() && (i + x) < map->getBorderWidth(); i++) { for (int i = 0; i < selectionDimensions.x() && (i + x) < width; i++) {
for (int j = 0; j < selectionDimensions.y() && (j + y) < map->getBorderHeight(); j++) { for (int j = 0; j < selectionDimensions.y() && (j + y) < height; j++) {
int blockIndex = (j + y) * map->getBorderWidth() + (i + x); int blockIndex = (j + y) * width + (i + x);
uint16_t tile = selectedMetatiles->at(j * selectionDimensions.x() + i); uint16_t tile = selectedMetatiles->at(j * selectionDimensions.x() + i);
(*map->layout->border->blocks)[blockIndex].tile = tile; (*map->layout->border->blocks)[blockIndex].tile = tile;
} }
@ -22,15 +24,17 @@ void BorderMetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
void BorderMetatilesPixmapItem::draw() { void BorderMetatilesPixmapItem::draw() {
QImage image(16 * map->getBorderWidth(), 16 * map->getBorderHeight(), QImage::Format_RGBA8888); int width = map->getBorderWidth();
int height = map->getBorderHeight();
QImage image(16 * width, 16 * height, QImage::Format_RGBA8888);
QPainter painter(&image); QPainter painter(&image);
QVector<Block> *blocks = map->layout->border->blocks; QVector<Block> *blocks = map->layout->border->blocks;
for (int i = 0; i < map->getBorderWidth(); i++) { for (int i = 0; i < width; i++) {
for (int j = 0; j < map->getBorderHeight(); j++) { for (int j = 0; j < height; j++) {
int x = i * 16; int x = i * 16;
int y = j * 16; int y = j * 16;
int index = j * map->getBorderWidth() + i; int index = j * width + i;
QImage metatile_image = getMetatileImage(blocks->value(index).tile, map->layout->tileset_primary, map->layout->tileset_secondary); QImage metatile_image = getMetatileImage(blocks->value(index).tile, map->layout->tileset_primary, map->layout->tileset_secondary);
QPoint metatile_origin = QPoint(x, y); QPoint metatile_origin = QPoint(x, y);
painter.drawImage(metatile_origin, metatile_image); painter.drawImage(metatile_origin, metatile_image);

View file

@ -62,11 +62,15 @@ void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
ui->comboBox_NewMap_Secondary_Tileset->setCurrentText(project->mapLayouts.value(layoutId)->tileset_secondary_label); ui->comboBox_NewMap_Secondary_Tileset->setCurrentText(project->mapLayouts.value(layoutId)->tileset_secondary_label);
ui->spinBox_NewMap_Width->setDisabled(true); ui->spinBox_NewMap_Width->setDisabled(true);
ui->spinBox_NewMap_Height->setDisabled(true); ui->spinBox_NewMap_Height->setDisabled(true);
ui->spinBox_NewMap_BorderWidth->setDisabled(true);
ui->spinBox_NewMap_BorderHeight->setDisabled(true);
ui->comboBox_NewMap_Primary_Tileset->setDisabled(true); ui->comboBox_NewMap_Primary_Tileset->setDisabled(true);
ui->comboBox_NewMap_Secondary_Tileset->setDisabled(true); ui->comboBox_NewMap_Secondary_Tileset->setDisabled(true);
} else { } else {
ui->spinBox_NewMap_Width->setValue(20); ui->spinBox_NewMap_Width->setValue(20);
ui->spinBox_NewMap_Height->setValue(20); ui->spinBox_NewMap_Height->setValue(20);
ui->spinBox_NewMap_BorderWidth->setValue(DEFAULT_BORDER_WIDTH);
ui->spinBox_NewMap_BorderHeight->setValue(DEFAULT_BORDER_HEIGHT);
} }
ui->comboBox_NewMap_Type->addItems(*project->mapTypes); ui->comboBox_NewMap_Type->addItems(*project->mapTypes);
@ -108,6 +112,17 @@ void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
ui->label_NewMap_Floor_Number->setVisible(true); ui->label_NewMap_Floor_Number->setVisible(true);
break; break;
} }
if (projectConfig.getUseCustomBorderSize()) {
ui->spinBox_NewMap_BorderWidth->setVisible(true);
ui->spinBox_NewMap_BorderHeight->setVisible(true);
ui->label_NewMap_BorderWidth->setVisible(true);
ui->label_NewMap_BorderHeight->setVisible(true);
} else {
ui->spinBox_NewMap_BorderWidth->setVisible(false);
ui->spinBox_NewMap_BorderHeight->setVisible(false);
ui->label_NewMap_BorderWidth->setVisible(false);
ui->label_NewMap_BorderHeight->setVisible(false);
}
} }
void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) { void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) {
@ -154,8 +169,13 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
layout->name = QString("%1_Layout").arg(newMap->name); layout->name = QString("%1_Layout").arg(newMap->name);
layout->width = QString::number(this->ui->spinBox_NewMap_Width->value()); layout->width = QString::number(this->ui->spinBox_NewMap_Width->value());
layout->height = QString::number(this->ui->spinBox_NewMap_Height->value()); layout->height = QString::number(this->ui->spinBox_NewMap_Height->value());
layout->border_width = QString::number(DEFAULT_BORDER_WIDTH); if (projectConfig.getUseCustomBorderSize()) {
layout->border_height = QString::number(DEFAULT_BORDER_HEIGHT); layout->border_width = QString::number(this->ui->spinBox_NewMap_BorderWidth->value());
layout->border_height = QString::number(this->ui->spinBox_NewMap_BorderHeight->value());
} else {
layout->border_width = QString::number(DEFAULT_BORDER_WIDTH);
layout->border_height = QString::number(DEFAULT_BORDER_HEIGHT);
}
layout->tileset_primary_label = this->ui->comboBox_NewMap_Primary_Tileset->currentText(); layout->tileset_primary_label = this->ui->comboBox_NewMap_Primary_Tileset->currentText();
layout->tileset_secondary_label = this->ui->comboBox_NewMap_Secondary_Tileset->currentText(); layout->tileset_secondary_label = this->ui->comboBox_NewMap_Secondary_Tileset->currentText();
layout->border_path = QString("data/layouts/%1/border.bin").arg(newMapName); layout->border_path = QString("data/layouts/%1/border.bin").arg(newMapName);