add region map image editor with basic functionality
This commit is contained in:
parent
c3e41976e8
commit
7cffe07579
13 changed files with 1783 additions and 8 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -2,12 +2,14 @@ porymap.pro.user
|
|||
*.autosave
|
||||
*.stash
|
||||
*.o
|
||||
moc_*
|
||||
qrc_*
|
||||
porymap.app*
|
||||
porymap
|
||||
porymap.cfg
|
||||
porymap.log
|
||||
Makefile
|
||||
|
||||
# Generated UI header
|
||||
# Qt generated files
|
||||
ui_*.h
|
||||
|
||||
moc_*.h
|
||||
moc_*.cpp
|
||||
qrc_*.cpp
|
||||
|
|
|
@ -237,7 +237,7 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>false</bool>
|
||||
|
@ -1066,8 +1066,8 @@
|
|||
<rect>
|
||||
<x>8</x>
|
||||
<y>0</y>
|
||||
<width>221</width>
|
||||
<height>328</height>
|
||||
<width>222</width>
|
||||
<height>353</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -2693,6 +2693,785 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Region Map</string>
|
||||
</attribute>
|
||||
<widget class="QScrollArea" name="scrollArea_CM_Metatiles">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>420</y>
|
||||
<width>301</width>
|
||||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_CM_Metatiles">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>8</x>
|
||||
<y>0</y>
|
||||
<width>283</width>
|
||||
<height>179</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_15">
|
||||
<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>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer_CMM_South">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGraphicsView" name="graphicsView_City_Map_Metatiles">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_CMM_West">
|
||||
<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_CMM_East">
|
||||
<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>
|
||||
<widget class="QTabWidget" name="tabWidget_Region_Map">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>19</x>
|
||||
<y>9</y>
|
||||
<width>381</width>
|
||||
<height>291</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_RM_BkgImg">
|
||||
<attribute name="title">
|
||||
<string>Background Image</string>
|
||||
</attribute>
|
||||
<widget class="QScrollArea" name="scrollArea_RM_BkgImg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>321</width>
|
||||
<height>211</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>319</width>
|
||||
<height>209</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_18">
|
||||
<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="1" column="1">
|
||||
<widget class="QGraphicsView" name="graphicsView_Region_Map_BkgImg">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
<property name="dragMode">
|
||||
<enum>QGraphicsView::NoDrag</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_RMBI_West">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_RMBI_South">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>166</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_RMBI_East">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_RMBI_North">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>166</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_RM_Layout">
|
||||
<attribute name="title">
|
||||
<string>Map Layout</string>
|
||||
</attribute>
|
||||
<widget class="QScrollArea" name="scrollArea_RM_Layout">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>321</width>
|
||||
<height>211</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_9">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>319</width>
|
||||
<height>209</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_19">
|
||||
<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="1" column="1">
|
||||
<widget class="QGraphicsView" name="graphicsView_Region_Map_Layout">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
<property name="dragMode">
|
||||
<enum>QGraphicsView::NoDrag</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_RML_West">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_RML_South">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>166</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_RML_East">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_RML_North">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>166</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QScrollArea" name="scrollArea_City_Map">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>380</y>
|
||||
<width>261</width>
|
||||
<height>251</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_City_Map">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>259</width>
|
||||
<height>249</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_20">
|
||||
<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="1" column="1">
|
||||
<widget class="QGraphicsView" name="graphicsView_City_Map">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
<property name="dragMode">
|
||||
<enum>QGraphicsView::NoDrag</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_CM_West">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_CM_South">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>166</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_CM_East">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_CM_North">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>166</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QStackedWidget" name="stackedWidget_RM_Options">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>440</x>
|
||||
<y>20</y>
|
||||
<width>351</width>
|
||||
<height>291</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_RM_BkgImg_Options">
|
||||
<widget class="QScrollArea" name="scrollArea_RM_Metatiles">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>281</width>
|
||||
<height>261</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_RM_Metatiles">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>8</x>
|
||||
<y>0</y>
|
||||
<width>263</width>
|
||||
<height>259</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_21">
|
||||
<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>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer_RMM_South">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGraphicsView" name="graphicsView_RegionMap_Tiles">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustIgnored</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_RMM_West">
|
||||
<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_RMM_East">
|
||||
<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>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_RM_Layout_Options">
|
||||
<widget class="QFrame" name="frame_10">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>40</y>
|
||||
<width>261</width>
|
||||
<height>170</height>
|
||||
</rect>
|
||||
</property>
|
||||
<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_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Connected Map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBox_RM_Connected_Map">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The section of the region map which the map is grouped under. This also determines the name of the map that is display when the player enters it.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Weather</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBox_Weather_2">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The default weather for this map.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBox_Type_2">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>The map type is a general attribute, which is used for many different things. For example. it determines whether biking or running is allowed.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="text">
|
||||
<string>Show Location Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_ShowLocation_2">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Whether or not to display the location name when the player enters the map.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="text">
|
||||
<string>Battle scene</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="comboBox_BattleScene_2">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Determines the type of battle scene graphics to use.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
179
include/core/regionmapeditor.h
Normal file
179
include/core/regionmapeditor.h
Normal file
|
@ -0,0 +1,179 @@
|
|||
#ifndef REGIONMAP_H
|
||||
#define REGIONMAP_H
|
||||
|
||||
#include "project.h"
|
||||
#include "map.h"
|
||||
#include "tilemaptileselector.h"
|
||||
//#include "block.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
|
||||
// if editing map bins, will need to remake the graphics when editing
|
||||
// are the scenes set in the editor / project / mainwindow files?
|
||||
|
||||
/*
|
||||
* - display the region map background image
|
||||
* - edit the region_map_layout.h layout
|
||||
* - edit city maps metatile layout and JUST save the mapname_num.bin
|
||||
* - edit
|
||||
* who edits pokenav_city_maps 1 and 2?
|
||||
* users can: - add the incbins probably themselves
|
||||
* - add
|
||||
* - edit region map background image
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* Editor:
|
||||
* - void displayCityMapMetatileSelector
|
||||
* - void displayRegionMapTileSelector
|
||||
* - void selectRegionMapTile(QString mapname)
|
||||
* - QGraphicsScene *scene_city_map_metatiles
|
||||
* - TilemapTileSelector *city_map_metatile_selector_item
|
||||
* - Tileset *city_map_squares (or tileset_city_map?)
|
||||
* - Tileset *tileset_region_map
|
||||
*
|
||||
* MainWindow:
|
||||
*
|
||||
*
|
||||
* Project:
|
||||
*
|
||||
*/
|
||||
|
||||
// rename this struct
|
||||
struct CityMapPosition
|
||||
{
|
||||
//
|
||||
//QString filename; // eg. dewford_0
|
||||
QString tilemap;// eg. "dewford_0"
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
// class that holds data for each square in this project
|
||||
// struct?
|
||||
// TODO: change char / uint8_t to unsigned
|
||||
class RegionMapSquare
|
||||
{
|
||||
public:
|
||||
//
|
||||
// are positions layout positions? (yes) so out of bounds are all (-1, -1) <-- how it's used in code
|
||||
// (GetRegionMapLocationPosition)
|
||||
// or image positions
|
||||
int x = -1;// x position, 0-indexed from top left
|
||||
int y = -1;// y position, 0-indexed from top left
|
||||
uint8_t tile_img_id;// tilemap ids for the background image
|
||||
bool has_map = false;// whether this square is linked to a map or is empty
|
||||
QString map_name;// name of the map associated with this square (if has_map is true): eg. "MAUVILLE_CITY"
|
||||
// ^ use project mapsec to names table
|
||||
bool has_city_map;// whether there is a city map on this grid
|
||||
//QList<struct CityMapPosition> city_maps;
|
||||
QString city_map_name;// filename of the city_map tilemap
|
||||
//bool is_flyable;//? needed ?
|
||||
friend class RegionMap;// not necessary if instance? what
|
||||
};
|
||||
|
||||
class RegionMap : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
//public:
|
||||
// explicit Map(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
RegionMap() = default;
|
||||
|
||||
~RegionMap() {
|
||||
delete mapname_abbr;
|
||||
delete layout_map_names;
|
||||
//delete background_image_tiles;
|
||||
//delete map_squares;
|
||||
//delete background_image_selector_item;
|
||||
};
|
||||
|
||||
static QMap<QString, QList<struct CityMapPosition>> ruby_city_maps_;
|
||||
static QString mapSecToMapConstant(QString);
|
||||
|
||||
//RegionMapSquare *map_squares = nullptr;// array of RegionMapSquares
|
||||
QList<RegionMapSquare> map_squares;
|
||||
|
||||
QString temp_path;// delete this
|
||||
QString city_map_squares_path;
|
||||
QString region_map_png_path;
|
||||
QString region_map_bin_path;// = QString::null;
|
||||
QString city_map_header_path;//dafuq is this?
|
||||
QString region_map_layout_path;
|
||||
|
||||
//QMap<QString, somthing> something;// name of map : info about city map, position in layoit, etc.
|
||||
//QMap<QString, TilemapTile*> regionMapLayoutTng; // mapName : tilemaptileselector
|
||||
// maybe position data to select correct square when changing map on side but only if map is a valid
|
||||
//QList<uint8_t> *background_image_tiles;// the visible ones anyways // using list because replace
|
||||
//TilemapTileSelector *background_image_selector_item;// ?
|
||||
QMap<QString, QString> *mapname_abbr;// layout shortcuts mapname:region_map_layout defines (both ways)
|
||||
// make this a QHash?? <-- no because something
|
||||
QStringList *layout_map_names;
|
||||
// uint8_t border_tile;
|
||||
|
||||
bool hasUnsavedChanges();
|
||||
|
||||
void init(Project*);//QString);
|
||||
|
||||
// parseutil.cpp ?
|
||||
void readBkgImgBin();
|
||||
void readCityMaps();// more complicated
|
||||
void readLayout(QMap<QString, QString>*);
|
||||
|
||||
QString newAbbr(QString);// makes a *unique* 5 character abbreviation from mapname to add to mapname_abbr
|
||||
|
||||
// editing functions
|
||||
// if they are booleans, returns true if successful?
|
||||
bool placeTile(char, int, int);// place tile at x, y
|
||||
bool removeTile(char, int, int);// replaces with 0x00 byte at x,y
|
||||
bool placeMap(QString, int, int);
|
||||
bool removeMap(QString, int, int);
|
||||
bool removeMap(QString);// remove all instances of map
|
||||
|
||||
void save();
|
||||
void saveBkgImgBin();
|
||||
void saveLayout();
|
||||
void saveCityMaps();
|
||||
|
||||
void update();// update the view in case something is broken?
|
||||
void resize(int, int);
|
||||
void setWidth(int);
|
||||
void setHeight(int);
|
||||
int width();
|
||||
int height();
|
||||
QSize imgSize();
|
||||
unsigned getTileId(int, int);
|
||||
|
||||
// implement these here?
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
void test(QMap<QString, QString>*);// remove when done testing obvi
|
||||
|
||||
// TODO: move read / write functions to private (and others)
|
||||
private:
|
||||
//
|
||||
int layout_width_;
|
||||
int layout_height_;
|
||||
int img_width_;
|
||||
int img_height_;
|
||||
int img_index_(int, int);// returns index int at x,y args (x + y * width_ * 2) // 2 because
|
||||
int layout_index_(int, int);
|
||||
|
||||
//protected:
|
||||
//
|
||||
|
||||
//signals:
|
||||
//
|
||||
};
|
||||
|
||||
//TilemapTileSelector *city_map_metatile_selector_item = nullptr;
|
||||
|
||||
#endif // REGIONMAP_H
|
|
@ -19,6 +19,8 @@
|
|||
#include "currentselectedmetatilespixmapitem.h"
|
||||
#include "collisionpixmapitem.h"
|
||||
#include "mappixmapitem.h"
|
||||
#include "regionmappixmapitem.h"
|
||||
#include "regionmapeditor.h"
|
||||
#include "settings.h"
|
||||
#include "movablerect.h"
|
||||
#include "cursortilerect.h"
|
||||
|
@ -77,6 +79,33 @@ public:
|
|||
void updateCustomMapHeaderValues(QTableWidget *);
|
||||
Tileset *getCurrentMapPrimaryTileset();
|
||||
|
||||
//
|
||||
RegionMap *region_map;
|
||||
void loadRegionMapData();
|
||||
|
||||
QGraphicsScene *scene_region_map_image = nullptr;
|
||||
QGraphicsScene *scene_region_map_layout = nullptr;//?
|
||||
QGraphicsScene *scene_region_map_tiles = nullptr;
|
||||
TilemapTileSelector *mapsquare_selector_item = nullptr;
|
||||
RegionMapPixmapItem *region_map_item = nullptr;
|
||||
|
||||
void displayRegionMap();
|
||||
void displayRegionMapTileSelector();
|
||||
|
||||
// selectedTileChanged, hoveredTileChanged, hoveredTileCleared
|
||||
void onRegionMapTileSelectorSelectedTileChanged();
|
||||
void onRegionMapTileSelectorHoveredTileChanged(unsigned);
|
||||
void onRegionMapTileSelectorHoveredTileCleared();
|
||||
|
||||
private slots:
|
||||
void onHoveredRegionMapTileChanged(int, int);
|
||||
void onHoveredRegionMapTileCleared();
|
||||
void mouseEvent_region_map(QGraphicsSceneMouseEvent *, RegionMapPixmapItem *);
|
||||
|
||||
public:
|
||||
QString regionMapTabStatusbarMessage;// TODO: make this name not terrible
|
||||
//
|
||||
|
||||
DraggablePixmapItem *addMapEvent(Event *event);
|
||||
void selectMapEvent(DraggablePixmapItem *object);
|
||||
void selectMapEvent(DraggablePixmapItem *object, bool toggle);
|
||||
|
@ -105,6 +134,7 @@ public:
|
|||
QGraphicsScene *scene_selected_border_metatiles = nullptr;
|
||||
QGraphicsScene *scene_collision_metatiles = nullptr;
|
||||
QGraphicsScene *scene_elevation_metatiles = nullptr;
|
||||
|
||||
MetatileSelector *metatile_selector_item = nullptr;
|
||||
|
||||
BorderMetatilesPixmapItem *selected_border_metatiles_item = nullptr;
|
||||
|
|
|
@ -65,6 +65,8 @@ private slots:
|
|||
void on_checkBox_AllowBiking_clicked(bool checked);
|
||||
void on_checkBox_AllowEscapeRope_clicked(bool checked);
|
||||
|
||||
void on_tabWidget_Region_Map_currentChanged(int);
|
||||
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
|
||||
void on_actionUndo_triggered();
|
||||
|
|
36
include/ui/regionmappixmapitem.h
Normal file
36
include/ui/regionmappixmapitem.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef REGIONMAPPIXMAPITEM_H
|
||||
#define REGIONMAPPIXMAPITEM_H
|
||||
|
||||
#include "regionmapeditor.h"
|
||||
#include "tilemaptileselector.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
||||
class RegionMapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RegionMapPixmapItem(RegionMap *rmap, TilemapTileSelector *tile_selector) {
|
||||
this->region_map = rmap;
|
||||
this->tile_selector = tile_selector;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
RegionMap *region_map;
|
||||
TilemapTileSelector *tile_selector;
|
||||
|
||||
virtual void paint(QGraphicsSceneMouseEvent*);
|
||||
virtual void select(QGraphicsSceneMouseEvent*);
|
||||
virtual void draw();
|
||||
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, RegionMapPixmapItem *);
|
||||
void hoveredRegionMapTileChanged(int x, int y);
|
||||
void hoveredRegionMapTileCleared();
|
||||
|
||||
protected:
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
};
|
||||
|
||||
#endif // REGIONMAPPIXMAPITEM_H
|
51
include/ui/tilemaptileselector.h
Normal file
51
include/ui/tilemaptileselector.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
#ifndef TILEMAPTILESELECTOR_H
|
||||
#define TILEMAPTILESELECTOR_H
|
||||
|
||||
#include "selectablepixmapitem.h"
|
||||
|
||||
class TilemapTileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TilemapTileSelector(QPixmap pixmap): SelectablePixmapItem(8, 8, 1, 1) {
|
||||
this->pixmap = pixmap;
|
||||
this->numTilesWide = 16;
|
||||
this->selectedTile = 0x00;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
void draw();
|
||||
void select(unsigned tileId);
|
||||
unsigned getSelectedTile();
|
||||
|
||||
int pixelWidth;
|
||||
int pixelHeight;
|
||||
|
||||
unsigned selectedTile;
|
||||
|
||||
// TODO: which of these need to be made public?
|
||||
// call this tilemap? or is tilemap the binary file?
|
||||
QPixmap pixmap;// pointer?
|
||||
QImage currTile;// image of just the currently selected tile to draw onto graphicsview
|
||||
QImage tileImg(unsigned tileId);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
||||
|
||||
private:
|
||||
int numTilesWide;
|
||||
int numTiles;
|
||||
void updateSelectedTile();
|
||||
unsigned getTileId(int x, int y);
|
||||
QPoint getTileIdCoords(unsigned);
|
||||
unsigned getValidTileId(unsigned);// TODO: implement this to prevent segfaults
|
||||
|
||||
signals:
|
||||
void hoveredTileChanged(unsigned);
|
||||
void hoveredTileCleared();
|
||||
void selectedTileChanged(unsigned);
|
||||
};
|
||||
|
||||
#endif // TILEMAPTILESELECTOR_H
|
|
@ -28,6 +28,7 @@ SOURCES += src/core/block.cpp \
|
|||
src/core/parseutil.cpp \
|
||||
src/core/tile.cpp \
|
||||
src/core/tileset.cpp \
|
||||
src/core/regionmapeditor.cpp \
|
||||
src/ui/aboutporymap.cpp \
|
||||
src/ui/bordermetatilespixmapitem.cpp \
|
||||
src/ui/collisionpixmapitem.cpp \
|
||||
|
@ -40,6 +41,7 @@ SOURCES += src/core/block.cpp \
|
|||
src/ui/graphicsview.cpp \
|
||||
src/ui/imageproviders.cpp \
|
||||
src/ui/mappixmapitem.cpp \
|
||||
src/ui/regionmappixmapitem.cpp \
|
||||
src/ui/mapsceneeventfilter.cpp \
|
||||
src/ui/metatilelayersitem.cpp \
|
||||
src/ui/metatileselector.cpp \
|
||||
|
@ -53,6 +55,7 @@ SOURCES += src/core/block.cpp \
|
|||
src/ui/tileseteditor.cpp \
|
||||
src/ui/tileseteditormetatileselector.cpp \
|
||||
src/ui/tileseteditortileselector.cpp \
|
||||
src/ui/tilemaptileselector.cpp \
|
||||
src/ui/newmappopup.cpp \
|
||||
src/config.cpp \
|
||||
src/editor.cpp \
|
||||
|
@ -78,6 +81,7 @@ HEADERS += include/core/block.h \
|
|||
include/core/parseutil.h \
|
||||
include/core/tile.h \
|
||||
include/core/tileset.h \
|
||||
include/core/regionmapeditor.h \
|
||||
include/ui/aboutporymap.h \
|
||||
include/ui/bordermetatilespixmapitem.h \
|
||||
include/ui/collisionpixmapitem.h \
|
||||
|
@ -90,6 +94,7 @@ HEADERS += include/core/block.h \
|
|||
include/ui/graphicsview.h \
|
||||
include/ui/imageproviders.h \
|
||||
include/ui/mappixmapitem.h \
|
||||
include/ui/regionmappixmapitem.h \
|
||||
include/ui/mapsceneeventfilter.h \
|
||||
include/ui/metatilelayersitem.h \
|
||||
include/ui/metatileselector.h \
|
||||
|
@ -103,6 +108,7 @@ HEADERS += include/core/block.h \
|
|||
include/ui/tileseteditor.h \
|
||||
include/ui/tileseteditormetatileselector.h \
|
||||
include/ui/tileseteditortileselector.h \
|
||||
include/ui/tilemaptileselector.h \
|
||||
include/ui/newmappopup.h \
|
||||
include/config.h \
|
||||
include/editor.h \
|
||||
|
|
402
src/core/regionmapeditor.cpp
Normal file
402
src/core/regionmapeditor.cpp
Normal file
|
@ -0,0 +1,402 @@
|
|||
#include "regionmapeditor.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <QImage>
|
||||
|
||||
|
||||
|
||||
// TODO: add logging / config stuff
|
||||
|
||||
// IN: ROUTE_101 ... OUT: MAP_ROUTE101
|
||||
// eg. SOUTHERN_ISLAND -> MAP_SOUTHERN_ISLAND -> SouthernIsland(n) -> SouthernIsland_Exterior
|
||||
// MT_CHIMNEY -> MAP_MT_CHIMNEY -> MtChimney(y)
|
||||
// ROUTE_101 -> MAP_ROUTE101 -> Route101(y)
|
||||
// TODO: move this maybe? would I be able to call it from this file if it was in map.cpp?
|
||||
QString RegionMap::mapSecToMapConstant(QString mapSectionName) {
|
||||
//
|
||||
QString mapConstantName = "MAP_";
|
||||
QString sectionNameTemp = mapSectionName.replace("ROUTE_","ROUTE");
|
||||
mapConstantName += sectionNameTemp;
|
||||
return mapConstantName;
|
||||
}
|
||||
|
||||
// TODO: verify these are in the correct order
|
||||
// also TODO: read this from the project somehow
|
||||
QMap<QString, QList<struct CityMapPosition>> RegionMap::ruby_city_maps_ = QMap<QString, QList<struct CityMapPosition>>({
|
||||
{"LavaridgeTown", {
|
||||
{"lavaridge_0.bin", 5, 3},
|
||||
}},
|
||||
{"FallarborTown", {
|
||||
{"fallarbor_0.bin", 3, 0},
|
||||
}},
|
||||
{"FortreeCity", {
|
||||
{"fortree_0.bin", 12, 0},
|
||||
}},
|
||||
{"SlateportCity", {
|
||||
{"slateport_0.bin", 8, 10},
|
||||
{"slateport_1.bin", 8, 11},
|
||||
}},
|
||||
{"RustboroCity", {
|
||||
{"rustboro_0.bin", 0, 5},
|
||||
{"rustboro_1.bin", 0, 6},
|
||||
}},
|
||||
{"PacifidlogTown", {
|
||||
{"pacifidlog_0.bin", 17, 10},
|
||||
}},
|
||||
{"MauvilleCity", {
|
||||
{"mauville_0.bin", 8, 6},
|
||||
{"mauville_1.bin", 9, 6},
|
||||
}},
|
||||
{"OldaleTown", {
|
||||
{"oldale_0.bin", 4, 9},
|
||||
}},
|
||||
{"LilycoveCity", {
|
||||
{"lilycove_0.bin", 18, 3},
|
||||
{"lilycove_1.bin", 19, 3},
|
||||
}},
|
||||
{"LittlerootTown", {
|
||||
{"littleroot_0.bin", 4, 11},
|
||||
}},
|
||||
{"DewfordTown", {
|
||||
{"dewford_0.bin", 2, 14},
|
||||
}},
|
||||
{"SootopolisCity", {
|
||||
{"sootopolis_0.bin", 21, 7},
|
||||
}},
|
||||
{"EverGrandeCity", {
|
||||
{"ever_grande_0.bin", 27, 8},
|
||||
{"ever_grande_1.bin", 27, 9},
|
||||
}},
|
||||
{"VerdanturfTown", {
|
||||
{"verdanturf_0.bin", 4, 6},
|
||||
}},
|
||||
{"MossdeepCity", {
|
||||
{"mossdeep_0.bin", 24, 5},
|
||||
{"mossdeep_1.bin", 25, 5},
|
||||
}},
|
||||
{"PetalburgCity", {
|
||||
{"petalburg_0.bin", 1, 9},
|
||||
}},
|
||||
});
|
||||
|
||||
void RegionMap::init(Project *pro) {
|
||||
QString path = pro->root;
|
||||
//
|
||||
// TODO: in the future, allow these to be adjustable (and save values)
|
||||
// possibly use a config file?
|
||||
layout_width_ = 28;
|
||||
layout_height_ = 15;
|
||||
|
||||
img_width_ = layout_width_ + 4;
|
||||
img_height_ = layout_height_ + 5;
|
||||
|
||||
//city_map_squares_path = QString();
|
||||
temp_path = path;// delete this
|
||||
region_map_bin_path = path + "/graphics/pokenav/region_map_map.bin";
|
||||
region_map_png_path = path + "/graphics/pokenav/region_map.png";
|
||||
region_map_layout_path = path + "/src/data/region_map_layout.h";
|
||||
|
||||
readBkgImgBin();
|
||||
readLayout(pro->mapConstantsToMapNames);
|
||||
readCityMaps();
|
||||
|
||||
//tryGetMap();
|
||||
|
||||
//saveBkgImgBin();
|
||||
//saveLayout();
|
||||
test(pro->mapConstantsToMapNames);
|
||||
}
|
||||
|
||||
// as of now, this needs to be called first because it initializes all the
|
||||
// RegionMapSquare s in the list
|
||||
// TODO: if the tileId is not valid for the provided image, make sure it does not crash
|
||||
void RegionMap::readBkgImgBin() {
|
||||
QFile binFile(region_map_bin_path);
|
||||
if (!binFile.open(QIODevice::ReadOnly)) return;
|
||||
|
||||
QByteArray mapBinData = binFile.readAll();
|
||||
binFile.close();
|
||||
|
||||
// the two is because lines are skipped for some reason
|
||||
// (maybe that is because there could be multiple layers?)
|
||||
// background image is also 32x20
|
||||
for (int m = 0; m < img_height_; m++) {
|
||||
for (int n = 0; n < img_width_; n++) {
|
||||
RegionMapSquare square;// =
|
||||
square.tile_img_id = mapBinData.at(n + m * img_width_ * 2);
|
||||
map_squares.append(square);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RegionMap::saveBkgImgBin() {
|
||||
QByteArray data(4096,0);// use a constant here? maybe read the original size?
|
||||
|
||||
for (int m = 0; m < img_height_; m++) {
|
||||
for (int n = 0; n < img_width_; n++) {
|
||||
data[n + m * img_width_ * 2] = map_squares[n + m * img_width_].tile_img_id;
|
||||
}
|
||||
}
|
||||
|
||||
QFile file(region_map_bin_path);
|
||||
if (!file.open(QIODevice::WriteOnly)) return;
|
||||
file.write(data);
|
||||
file.close();
|
||||
}
|
||||
|
||||
// done
|
||||
void RegionMap::readLayout(QMap<QString, QString> *qmap) {
|
||||
QFile file(region_map_layout_path);
|
||||
if (!file.open(QIODevice::ReadOnly)) return;
|
||||
|
||||
QMap<QString, QString> * abbr = new QMap<QString, QString>;
|
||||
|
||||
QString line, text;
|
||||
QStringList *captured = new QStringList;
|
||||
|
||||
QTextStream in(&file);
|
||||
while (!in.atEnd()) {
|
||||
line = in.readLine();
|
||||
if (line.startsWith("#define")) {
|
||||
QStringList split = line.split(QRegularExpression("\\s+"));
|
||||
abbr->insert(split[2].replace("MAPSEC_",""), split[1]);
|
||||
} else {
|
||||
text += line.remove(" ");
|
||||
}
|
||||
}
|
||||
QRegularExpression re("{(.*?)}");
|
||||
*captured = re.match(text).captured(1).split(",");
|
||||
captured->removeAll({});
|
||||
|
||||
// replace abbreviations with names
|
||||
for (int i = 0; i < captured->length(); i++) {
|
||||
QString value = (*captured)[i];
|
||||
if (value.startsWith("R(")) {// routes are different
|
||||
captured->replace(i, QString("ROUTE_%1").arg(value.mid(2,3)));
|
||||
} else {
|
||||
captured->replace(i, abbr->key(value));
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: improve this?
|
||||
for (int m = 0, i = 0; m < layout_height_; m++) {
|
||||
for (int n = 0; n < layout_width_; n++) {
|
||||
i = img_index_(n,m);
|
||||
QString secname = (*captured)[layout_index_(n,m)];
|
||||
if (secname != "NOTHING") map_squares[i].has_map = true;
|
||||
map_squares[i].map_name = qmap->value(mapSecToMapConstant(secname));
|
||||
map_squares[i].x = n;
|
||||
map_squares[i].y = m;
|
||||
}
|
||||
}
|
||||
mapname_abbr = abbr;
|
||||
layout_map_names = captured;
|
||||
file.close();
|
||||
}
|
||||
|
||||
// does it matter that it doesn't save in order?
|
||||
// do i need to use a QList<Pair> ??
|
||||
void RegionMap::saveLayout() {
|
||||
//
|
||||
QString layout_text = "";
|
||||
QString mapsec = "MAPSEC_";
|
||||
QString define = "#define ";
|
||||
QString array_start = "static const u8 sRegionMapLayout[] =\n{";
|
||||
QString array_close = "\n};\n";
|
||||
QString tab = " ";
|
||||
|
||||
for (QString key : mapname_abbr->keys()) {
|
||||
layout_text += define + mapname_abbr->value(key) + tab + mapsec + key + "\n";
|
||||
}
|
||||
|
||||
layout_text += "\n" + array_start;// + + array_close;//oops
|
||||
|
||||
//qDebug() << *layout_map_names;
|
||||
int cnt = 0;
|
||||
for (QString s : *layout_map_names) {
|
||||
//
|
||||
if (!(cnt % layout_width_)) {
|
||||
layout_text += "\n" + tab;
|
||||
}
|
||||
if (s.startsWith("ROUTE_")) {
|
||||
layout_text += QString("R(%1)").arg(s.replace("ROUTE_","")) + ", ";
|
||||
} else {
|
||||
layout_text += mapname_abbr->value(s) + ", ";
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
|
||||
//layout_text.
|
||||
layout_text += array_close;
|
||||
|
||||
QFile file(region_map_layout_path);
|
||||
if (!file.open(QIODevice::WriteOnly)) return;
|
||||
file.write(layout_text.toUtf8());
|
||||
file.close();
|
||||
}
|
||||
|
||||
void RegionMap::readCityMaps() {
|
||||
//
|
||||
//for (int m = 0; m < layout_height_; m++) {
|
||||
// QString tester;
|
||||
// for (int n = 0; n < layout_width_; n++) {
|
||||
// tester += (QString::number(img_index_(n,m)).rightJustified(3, '.') + " ");
|
||||
// }
|
||||
// qDebug() << tester;
|
||||
//}
|
||||
//for (auto map : map_squares) {
|
||||
for (int map = 0; map < map_squares.size(); map++) {
|
||||
//
|
||||
if (map_squares[map].has_map) {
|
||||
//
|
||||
if (ruby_city_maps_.contains(map_squares[map].map_name)) {
|
||||
map_squares[map].has_city_map = true;
|
||||
//map_squares[map].city_map_name = ruby_city_maps_.value(map_squares[map].map_name)[0].tilemap;
|
||||
QList<struct CityMapPosition> city_maps = ruby_city_maps_.value(map_squares[map].map_name);
|
||||
for (auto city_map : city_maps) {
|
||||
//
|
||||
if (city_map.x == map_squares[map].x
|
||||
&& city_map.y == map_squares[map].y)
|
||||
//
|
||||
map_squares[map].city_map_name = city_map.tilemap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//done
|
||||
QString RegionMap::newAbbr(QString mapname) {
|
||||
QString abbr;
|
||||
QStringList words = mapname.split("_");
|
||||
|
||||
if (words.length() == 1) {
|
||||
abbr = (words[0] + "_____X").left(6);
|
||||
} else {
|
||||
abbr = (words.front() + "___X").left(4) + "_" + words.back().at(0);
|
||||
}
|
||||
|
||||
// to guarantee unique abbreviations (up to 14)
|
||||
QString extra_chars = "23456789BCDEF";
|
||||
int count = 0;
|
||||
while ((*mapname_abbr).values().contains(abbr)) {
|
||||
abbr.replace(5,1,extra_chars[count]);
|
||||
count++;
|
||||
}
|
||||
return abbr;
|
||||
}
|
||||
|
||||
// layout coords to image index
|
||||
int RegionMap::img_index_(int x, int y) {
|
||||
return ((x + 1) + (y + 2) * img_width_);
|
||||
}
|
||||
|
||||
// layout coords to layout index
|
||||
int RegionMap::layout_index_(int x, int y) {
|
||||
return (x + y * layout_width_);
|
||||
}
|
||||
|
||||
// img coords to layout index?
|
||||
// img coords to img index?
|
||||
|
||||
void RegionMap::test(QMap<QString, QString>* qmap) {
|
||||
//
|
||||
bool debug_rmap = false;
|
||||
|
||||
if (debug_rmap) {
|
||||
for (auto square : map_squares) {
|
||||
qDebug() << "(" << square.x << "," << square.y << ")"
|
||||
<< square.tile_img_id
|
||||
<< square.has_map
|
||||
<< square.map_name
|
||||
<< square.has_city_map
|
||||
<< square.city_map_name
|
||||
;
|
||||
//if (qmap->contains(mapSecToMapConstant(square.map_name)))
|
||||
// extras += qmap->value(mapSecToMapConstant(square.map_name)) + " ";
|
||||
//else
|
||||
// extras += "nothing ";
|
||||
}
|
||||
|
||||
QPixmap png(region_map_png_path);
|
||||
//png.load(region_map_png_path);
|
||||
qDebug() << "png num 8x8 tiles" << QString("0x%1").arg((png.width()/8) * (png.height() / 8), 2, 16, QChar('0'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int RegionMap::width() {
|
||||
return this->img_width_;
|
||||
}
|
||||
|
||||
int RegionMap::height() {
|
||||
return this->img_height_;
|
||||
}
|
||||
|
||||
// TODO: remove +2 and put elsewhere
|
||||
QSize RegionMap::imgSize() {
|
||||
return QSize(img_width_ * 8 + 2, img_height_ * 8 + 2);
|
||||
}
|
||||
|
||||
// TODO: rename to getTileIdAt()?
|
||||
unsigned RegionMap::getTileId(int x, int y) {
|
||||
//
|
||||
return map_squares[x + y * img_width_].tile_img_id;
|
||||
//qDebug() << x << y;
|
||||
//return 0;
|
||||
}
|
||||
|
||||
// sidenote: opening the map from MAPSEC_x will not always be right
|
||||
// there needs to be a mapsections to mapname QMap
|
||||
// otherwie, look for the first map with right substring
|
||||
// mapConstantsToMapNames [MAP_ROUTE106] = "Route106"
|
||||
// eg. SOUTHERN_ISLAND -> MAP_SOUTHERN_ISLAND -> SouthernIsland(n) -> SouthernIsland_Exterior
|
||||
// MT_CHIMNEY -> MAP_MT_CHIMNEY -> MtChimney(y)
|
||||
// ROUTE_101 -> MAP_ROUTE101 -> Route101(y)
|
||||
// (or synchronize these for consistency in the repos :: underscore / no underscore)
|
||||
|
||||
// TODO: change debugs to logs
|
||||
void RegionMap::save() {
|
||||
//
|
||||
qDebug() << "saving region map image tilemap at" << region_map_bin_path << "\n"
|
||||
;//<< "saving region map layout at" << region_map_layout_path << "\n";
|
||||
|
||||
saveBkgImgBin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -19,12 +19,16 @@ Editor::Editor(Ui::MainWindow* ui)
|
|||
this->settings = new Settings();
|
||||
this->playerViewRect = new MovableRect(&this->settings->playerViewRectEnabled, 30 * 8, 20 * 8, qRgb(255, 255, 255));
|
||||
this->cursorMapTileRect = new CursorTileRect(&this->settings->cursorTileRectEnabled, qRgb(255, 255, 255));
|
||||
this->region_map = new RegionMap;// TODO: why is this here?
|
||||
}
|
||||
|
||||
void Editor::saveProject() {
|
||||
if (project) {
|
||||
project->saveAllMaps();
|
||||
project->saveAllDataStructures();
|
||||
if (region_map) {
|
||||
region_map->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +37,9 @@ void Editor::save() {
|
|||
project->saveMap(map);
|
||||
project->saveAllDataStructures();
|
||||
}
|
||||
if (project && region_map) {
|
||||
region_map->save();
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::undo() {
|
||||
|
@ -600,6 +607,9 @@ void Editor::displayMap() {
|
|||
scene->addItem(this->playerViewRect);
|
||||
scene->addItem(this->cursorMapTileRect);
|
||||
|
||||
displayRegionMapTileSelector();//?
|
||||
displayRegionMap();
|
||||
|
||||
if (map_item) {
|
||||
map_item->setVisible(false);
|
||||
}
|
||||
|
@ -1261,6 +1271,93 @@ void Editor::deleteEvent(Event *event) {
|
|||
//updateSelectedObjects();
|
||||
}
|
||||
|
||||
void Editor::loadRegionMapData() {
|
||||
//
|
||||
region_map->init(project);
|
||||
}
|
||||
|
||||
// TODO: get this to display on a decent scale
|
||||
void Editor::displayRegionMapTileSelector() {
|
||||
//
|
||||
this->mapsquare_selector_item = new TilemapTileSelector(QPixmap(this->region_map->region_map_png_path));
|
||||
this->mapsquare_selector_item->draw();
|
||||
|
||||
this->scene_region_map_tiles = new QGraphicsScene;
|
||||
this->scene_region_map_tiles->addItem(this->mapsquare_selector_item);
|
||||
|
||||
connect(this->mapsquare_selector_item, &TilemapTileSelector::selectedTileChanged,
|
||||
this, &Editor::onRegionMapTileSelectorSelectedTileChanged);// TODO: remove this?
|
||||
connect(this->mapsquare_selector_item, &TilemapTileSelector::hoveredTileChanged,
|
||||
this, &Editor::onRegionMapTileSelectorHoveredTileChanged);
|
||||
connect(this->mapsquare_selector_item, &TilemapTileSelector::hoveredTileCleared,
|
||||
this, &Editor::onRegionMapTileSelectorHoveredTileCleared);
|
||||
|
||||
this->ui->graphicsView_RegionMap_Tiles->setScene(this->scene_region_map_tiles);
|
||||
this->ui->graphicsView_RegionMap_Tiles->setFixedSize(this->mapsquare_selector_item->pixelWidth + 2,
|
||||
this->mapsquare_selector_item->pixelHeight + 2);
|
||||
}
|
||||
|
||||
// TODO: change the signal slot to new syntax
|
||||
void Editor::displayRegionMap() {
|
||||
//
|
||||
this->region_map_item = new RegionMapPixmapItem(this->region_map, this->mapsquare_selector_item);
|
||||
connect(region_map_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*, RegionMapPixmapItem*)),
|
||||
this, SLOT(mouseEvent_region_map(QGraphicsSceneMouseEvent*, RegionMapPixmapItem*)));
|
||||
connect(region_map_item, SIGNAL(hoveredRegionMapTileChanged(int, int)),
|
||||
this, SLOT(onHoveredRegionMapTileChanged(int, int)));
|
||||
connect(region_map_item, SIGNAL(hoveredRegionMapTileCleared()),
|
||||
this, SLOT(onHoveredRegionMapTileCleared()));
|
||||
this->region_map_item->draw();
|
||||
|
||||
this->scene_region_map_image = new QGraphicsScene;
|
||||
this->scene_region_map_image->addItem(this->region_map_item);
|
||||
this->scene_region_map_image->setSceneRect(this->scene_region_map_image->sceneRect());
|
||||
|
||||
//this->scene_region_map_image->scale(2, 2);
|
||||
this->ui->graphicsView_Region_Map_BkgImg->setScene(this->scene_region_map_image);
|
||||
this->ui->graphicsView_Region_Map_BkgImg->setFixedSize(this->region_map->imgSize());
|
||||
//this->ui->graphicsView_Region_Map_BkgImg->scale(2.0, 2.0);
|
||||
}
|
||||
|
||||
void Editor::onRegionMapTileSelectorSelectedTileChanged() {
|
||||
//
|
||||
}
|
||||
|
||||
void Editor::onRegionMapTileSelectorHoveredTileChanged(unsigned tileId) {
|
||||
QString message = QString("Tile: 0x") + QString("%1").arg(tileId, 4, 16, QChar('0')).toUpper();
|
||||
this->ui->statusBar->showMessage(message);
|
||||
}
|
||||
|
||||
void Editor::onRegionMapTileSelectorHoveredTileCleared() {
|
||||
//
|
||||
QString message = QString("Selected Tile: 0x") + QString("%1").arg(this->mapsquare_selector_item->selectedTile, 4, 16, QChar('0')).toUpper();
|
||||
this->ui->statusBar->showMessage(message);
|
||||
}
|
||||
|
||||
void Editor::onHoveredRegionMapTileChanged(int x, int y) {
|
||||
//
|
||||
regionMapTabStatusbarMessage = QString("x: %1, y: %2 Tile: 0x").arg(x).arg(y) + QString("%1").arg(this->region_map->getTileId(x, y), 4, 16, QChar('0')).toUpper();
|
||||
this->ui->statusBar->showMessage(regionMapTabStatusbarMessage);
|
||||
}
|
||||
|
||||
void Editor::onHoveredRegionMapTileCleared() {
|
||||
//
|
||||
this->ui->statusBar->clearMessage();
|
||||
}
|
||||
|
||||
void Editor::mouseEvent_region_map(QGraphicsSceneMouseEvent *event, RegionMapPixmapItem *item) {
|
||||
//
|
||||
if (event->buttons() & Qt::RightButton) {
|
||||
//
|
||||
item->select(event);
|
||||
} else if (event->buttons() & Qt::MiddleButton) {
|
||||
// TODO: add functionality here? replace or?
|
||||
} else {
|
||||
//
|
||||
item->paint(event);
|
||||
}
|
||||
}
|
||||
|
||||
// It doesn't seem to be possible to prevent the mousePress event
|
||||
// from triggering both event's DraggablePixmapItem and the background mousePress.
|
||||
// Since the DraggablePixmapItem's event fires first, we can set a temp
|
||||
|
@ -1274,6 +1371,5 @@ void Editor::objectsView_onMousePress(QMouseEvent *event) {
|
|||
selected_events->append(first);
|
||||
updateSelectedEvents();
|
||||
}
|
||||
|
||||
selectingEvent = false;
|
||||
}
|
||||
|
|
|
@ -263,11 +263,13 @@ bool MainWindow::openProject(QString dir) {
|
|||
setWindowTitle(editor->project->getProjectTitle());
|
||||
loadDataStructures();
|
||||
populateMapList();
|
||||
editor->loadRegionMapData();
|
||||
success = setMap(getDefaultMap(), true);
|
||||
} else {
|
||||
setWindowTitle(editor->project->getProjectTitle());
|
||||
loadDataStructures();
|
||||
populateMapList();
|
||||
editor->loadRegionMapData();
|
||||
}
|
||||
|
||||
if (success) {
|
||||
|
@ -596,6 +598,11 @@ void MainWindow::on_checkBox_AllowEscapeRope_clicked(bool checked)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_tabWidget_Region_Map_currentChanged(int index) {
|
||||
//
|
||||
ui->stackedWidget_RM_Options->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void MainWindow::loadDataStructures() {
|
||||
Project *project = editor->project;
|
||||
project->readMapLayouts();
|
||||
|
|
73
src/ui/regionmappixmapitem.cpp
Normal file
73
src/ui/regionmappixmapitem.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#include "regionmappixmapitem.h"
|
||||
#include "imageproviders.h"
|
||||
|
||||
|
||||
|
||||
// the function that draws the map on the scene
|
||||
// (qnqlogous to Map::render)
|
||||
// TODO: figure out why this is being called twice!!
|
||||
void RegionMapPixmapItem::draw() {
|
||||
if (!region_map) return;
|
||||
|
||||
QImage image(region_map->width() * 8, region_map->height() * 8, QImage::Format_RGBA8888);
|
||||
|
||||
QPainter painter(&image);
|
||||
for (int i = 0; i < region_map->map_squares.size(); i++) {
|
||||
QImage img = this->tile_selector->tileImg(region_map->map_squares[i].tile_img_id);
|
||||
int x = i % region_map->width();
|
||||
int y = i / region_map->width();
|
||||
QPoint pos = QPoint(x * 8, y * 8);
|
||||
painter.drawImage(pos, img);
|
||||
}
|
||||
painter.end();
|
||||
|
||||
this->setPixmap(QPixmap::fromImage(image));
|
||||
}
|
||||
|
||||
void RegionMapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
||||
if (region_map) {
|
||||
if (event->type() == QEvent::GraphicsSceneMousePress) {
|
||||
} else {
|
||||
QPointF pos = event->pos();
|
||||
int x = static_cast<int>(pos.x()) / 8;
|
||||
int y = static_cast<int>(pos.y()) / 8;
|
||||
this->region_map->map_squares[x + y * region_map->width()].tile_img_id = this->tile_selector->selectedTile;
|
||||
}
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
void RegionMapPixmapItem::select(QGraphicsSceneMouseEvent *event) {
|
||||
QPointF pos = event->pos();
|
||||
int x = static_cast<int>(pos.x()) / 8;
|
||||
int y = static_cast<int>(pos.y()) / 8;
|
||||
this->tile_selector->select(this->region_map->getTileId(x, y));
|
||||
}
|
||||
|
||||
void RegionMapPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
||||
int x = static_cast<int>(event->pos().x()) / 8;
|
||||
int y = static_cast<int>(event->pos().y()) / 8;
|
||||
emit this->hoveredRegionMapTileChanged(x, y);
|
||||
}
|
||||
|
||||
void RegionMapPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
||||
emit this->hoveredRegionMapTileCleared();
|
||||
}
|
||||
|
||||
void RegionMapPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||
QPointF pos = event->pos();
|
||||
int x = static_cast<int>(pos.x()) / 8;
|
||||
int y = static_cast<int>(pos.y()) / 8;
|
||||
emit mouseEvent(event, this);
|
||||
}
|
||||
|
||||
void RegionMapPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||
int x = static_cast<int>(event->pos().x()) / 8;
|
||||
int y = static_cast<int>(event->pos().y()) / 8;
|
||||
emit this->hoveredRegionMapTileChanged(x, y);
|
||||
emit mouseEvent(event, this);
|
||||
}
|
||||
|
||||
void RegionMapPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||
emit mouseEvent(event, this);
|
||||
}
|
112
src/ui/tilemaptileselector.cpp
Normal file
112
src/ui/tilemaptileselector.cpp
Normal file
|
@ -0,0 +1,112 @@
|
|||
#include "tilemaptileselector.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
void TilemapTileSelector::draw() {
|
||||
size_t width_ = this->pixmap.width();
|
||||
this->pixelWidth = width_;
|
||||
size_t height_ = this->pixmap.height();
|
||||
this->pixelHeight = height_;
|
||||
size_t ntiles_ = (width_/8) * (height_/8);// length_
|
||||
|
||||
this->numTilesWide = width_ / 8;
|
||||
this->numTiles = ntiles_;
|
||||
|
||||
this->setPixmap(this->pixmap);
|
||||
this->drawSelection();
|
||||
}
|
||||
|
||||
//*
|
||||
void TilemapTileSelector::select(unsigned tileId) {
|
||||
QPoint coords = this->getTileIdCoords(tileId);
|
||||
SelectablePixmapItem::select(coords.x(), coords.y(), 0, 0);
|
||||
this->selectedTile = tileId;
|
||||
emit selectedTileChanged(tileId);
|
||||
}
|
||||
//*/
|
||||
|
||||
//*
|
||||
void TilemapTileSelector::updateSelectedTile() {
|
||||
QPoint origin = this->getSelectionStart();
|
||||
this->selectedTile = this->getTileId(origin.x(), origin.y());
|
||||
}
|
||||
//*/
|
||||
|
||||
unsigned TilemapTileSelector::getSelectedTile() {
|
||||
return this->selectedTile;
|
||||
}
|
||||
|
||||
//*
|
||||
unsigned TilemapTileSelector::getTileId(int x, int y) {
|
||||
int index = y * this->numTilesWide + x;
|
||||
return index < this->numTiles ? index : this->numTiles % index;
|
||||
}
|
||||
//*/
|
||||
|
||||
//*
|
||||
void TilemapTileSelector::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||
SelectablePixmapItem::mousePressEvent(event);
|
||||
this->updateSelectedTile();
|
||||
emit selectedTileChanged(this->selectedTile);
|
||||
}
|
||||
//*/
|
||||
|
||||
//*
|
||||
void TilemapTileSelector::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||
SelectablePixmapItem::mouseMoveEvent(event);
|
||||
this->updateSelectedTile();
|
||||
emit hoveredTileChanged(this->selectedTile);
|
||||
emit selectedTileChanged(this->selectedTile);
|
||||
}
|
||||
//*/
|
||||
|
||||
//*
|
||||
void TilemapTileSelector::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||
SelectablePixmapItem::mouseReleaseEvent(event);
|
||||
this->updateSelectedTile();
|
||||
emit selectedTileChanged(this->selectedTile);
|
||||
}
|
||||
//*/
|
||||
|
||||
//*
|
||||
void TilemapTileSelector::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
||||
QPoint pos = this->getCellPos(event->pos());
|
||||
unsigned tileId = this->getTileId(pos.x(), pos.y());
|
||||
emit this->hoveredTileChanged(tileId);
|
||||
}
|
||||
//*/
|
||||
|
||||
//*
|
||||
void TilemapTileSelector::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) {
|
||||
emit this->hoveredTileCleared();
|
||||
}
|
||||
//*/
|
||||
|
||||
//*
|
||||
QPoint TilemapTileSelector::getTileIdCoords(unsigned tileId) {
|
||||
int index = tileId < this->numTiles ? tileId : this->numTiles % tileId;// TODO: change this?
|
||||
return QPoint(index % this->numTilesWide, index / this->numTilesWide);// ? is this right?
|
||||
}
|
||||
//*/
|
||||
|
||||
QImage TilemapTileSelector::tileImg(unsigned tileId) {
|
||||
//
|
||||
QPoint pos = getTileIdCoords(tileId);
|
||||
return pixmap.copy(pos.x() * 8, pos.y() * 8, 8, 8).toImage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue