resize region map tilemaps
This commit is contained in:
parent
cff77ad58e
commit
f7a0e02f95
13 changed files with 306 additions and 249 deletions
|
@ -50,42 +50,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<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="QCheckBox" name="checkBox_crop">
|
|
||||||
<property name="text">
|
|
||||||
<string>Crop View to Map Size</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<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>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -196,7 +160,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>466</width>
|
<width>466</width>
|
||||||
<height>350</height>
|
<height>351</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_18">
|
<layout class="QGridLayout" name="gridLayout_18">
|
||||||
|
@ -317,7 +281,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>466</width>
|
<width>466</width>
|
||||||
<height>350</height>
|
<height>351</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_19">
|
<layout class="QGridLayout" name="gridLayout_19">
|
||||||
|
@ -438,7 +402,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>466</width>
|
<width>466</width>
|
||||||
<height>350</height>
|
<height>351</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_24">
|
<layout class="QGridLayout" name="gridLayout_24">
|
||||||
|
@ -588,7 +552,7 @@
|
||||||
<x>8</x>
|
<x>8</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>278</width>
|
<width>278</width>
|
||||||
<height>341</height>
|
<height>342</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -1126,6 +1090,7 @@
|
||||||
<string>File</string>
|
<string>File</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="action_RegionMap_Save"/>
|
<addaction name="action_RegionMap_Save"/>
|
||||||
|
<addaction name="actionSave_All"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuEdit">
|
<widget class="QMenu" name="menuEdit">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -1157,7 +1122,7 @@
|
||||||
</action>
|
</action>
|
||||||
<action name="action_RegionMap_Resize">
|
<action name="action_RegionMap_Resize">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Resize</string>
|
<string>Resize Tilemap</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+R</string>
|
<string>Ctrl+R</string>
|
||||||
|
@ -1193,6 +1158,11 @@
|
||||||
<string>Import City Map Image Tiles...</string>
|
<string>Import City Map Image Tiles...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionSave_All">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save All</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>564</width>
|
<width>564</width>
|
||||||
<height>1016</height>
|
<height>902</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -43,27 +43,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="message_width">
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: #ff5c33</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="1">
|
|
||||||
<widget class="QLabel" name="message_height">
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: #ff5c33</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="0" colspan="2">
|
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Tilemap Properties</string>
|
<string>Tilemap Properties</string>
|
||||||
|
@ -112,25 +92,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QSpinBox" name="config_tilemapWidth">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>75</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>255</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLabel" name="message_tilemapWidth">
|
<widget class="QLabel" name="message_tilemapWidth">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
|
@ -167,16 +128,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
|
||||||
<widget class="QLabel" name="message_tilemapHeight">
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: #ff5c33</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="label_7">
|
<widget class="QLabel" name="label_7">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -292,6 +243,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="10" column="0">
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="text">
|
||||||
|
<string>palette path</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="10" column="1">
|
<item row="10" column="1">
|
||||||
<widget class="QFrame" name="frame_3">
|
<widget class="QFrame" name="frame_3">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
|
@ -326,17 +284,39 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="0">
|
<item row="5" column="1">
|
||||||
<widget class="QLabel" name="label_11">
|
<widget class="QLabel" name="message_tilemapHeight">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">color: #ff5c33</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>palette path</string>
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="config_tilemapWidth">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>255</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="0" colspan="2">
|
<item row="6" column="0" colspan="2">
|
||||||
<widget class="QGroupBox" name="group_layout">
|
<widget class="QGroupBox" name="group_layout">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Layout Properties</string>
|
<string>Layout Properties</string>
|
||||||
|
@ -620,7 +600,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="13" column="0">
|
<item row="9" column="0">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
@ -633,7 +613,7 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="13" column="1">
|
<item row="9" column="1">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
@ -643,52 +623,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>width</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QSpinBox" name="config_width">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>75</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>height</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="1">
|
|
||||||
<widget class="QSpinBox" name="config_height">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>75</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -38,8 +38,9 @@ struct MapSectionEntry
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RegionMap
|
class RegionMap : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
RegionMap() = delete;
|
RegionMap() = delete;
|
||||||
RegionMap(Project *);
|
RegionMap(Project *);
|
||||||
|
@ -64,7 +65,7 @@ public:
|
||||||
void saveConfig();// ? or do this in the editor only?
|
void saveConfig();// ? or do this in the editor only?
|
||||||
void saveOptions(int id, QString sec, QString name, int x, int y);
|
void saveOptions(int id, QString sec, QString name, int x, int y);
|
||||||
|
|
||||||
void resize(int width, int height);
|
void resizeTilemap(int width, int height, bool update = true);
|
||||||
void resetSquare(int index);
|
void resetSquare(int index);
|
||||||
void clearLayout();
|
void clearLayout();
|
||||||
void clearImage();
|
void clearImage();
|
||||||
|
@ -86,6 +87,9 @@ public:
|
||||||
void setTile(int index, TilemapTile &tile);
|
void setTile(int index, TilemapTile &tile);
|
||||||
void setTileData(int index, unsigned id, bool hFlip, bool vFlip, int palette);
|
void setTileData(int index, unsigned id, bool hFlip, bool vFlip, int palette);
|
||||||
int getMapSquareIndex(int x, int y);
|
int getMapSquareIndex(int x, int y);
|
||||||
|
|
||||||
|
QString getAlias() { return this->alias; }
|
||||||
|
poryjson::Json::object config();
|
||||||
|
|
||||||
QString palPath();
|
QString palPath();
|
||||||
QString pngPath();
|
QString pngPath();
|
||||||
|
@ -141,6 +145,11 @@ public:
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
|
|
||||||
|
void emitDisplay();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void mapNeedsDisplaying();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// TODO: defaults needed?
|
// TODO: defaults needed?
|
||||||
tsl::ordered_map<QString, MapSectionEntry> *region_map_entries = nullptr;
|
tsl::ordered_map<QString, MapSectionEntry> *region_map_entries = nullptr;
|
||||||
|
@ -150,9 +159,6 @@ private:
|
||||||
int tilemap_width;
|
int tilemap_width;
|
||||||
int tilemap_height;
|
int tilemap_height;
|
||||||
|
|
||||||
int region_width;
|
|
||||||
int region_height;
|
|
||||||
|
|
||||||
int layout_width;
|
int layout_width;
|
||||||
int layout_height;
|
int layout_height;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@ enum RMCommandId {
|
||||||
ID_EditLayout,
|
ID_EditLayout,
|
||||||
ID_ResizeLayout,
|
ID_ResizeLayout,
|
||||||
ID_EditEntry,
|
ID_EditEntry,
|
||||||
|
ID_RemoveEntry,
|
||||||
|
ID_AddEntry,
|
||||||
|
ID_ResizeTilemap,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +31,7 @@ public:
|
||||||
bool mergeWith(const QUndoCommand *command) override;
|
bool mergeWith(const QUndoCommand *command) override;
|
||||||
int id() const override { return RMCommandId::ID_EditTilemap; }
|
int id() const override { return RMCommandId::ID_EditTilemap; }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
RegionMap *map;
|
RegionMap *map;
|
||||||
|
|
||||||
QByteArray oldTilemap;
|
QByteArray oldTilemap;
|
||||||
|
@ -110,6 +113,8 @@ public:
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
|
int id() const override { return RMCommandId::ID_RemoveEntry; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,10 +125,28 @@ public:
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
|
||||||
|
int id() const override { return RMCommandId::ID_AddEntry; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// ResizeTilemap
|
|
||||||
|
|
||||||
// ResizeMap
|
/// ResizeTilemap
|
||||||
|
class ResizeTilemap : public EditTilemap {
|
||||||
|
public:
|
||||||
|
ResizeTilemap(RegionMap *map, QByteArray oldTilemap, QByteArray newTilemap,
|
||||||
|
int oldWidth, int oldHeight, int newWidth, int newHeight, QUndoCommand *parent = nullptr);
|
||||||
|
|
||||||
|
void undo() override;
|
||||||
|
void redo() override;
|
||||||
|
|
||||||
|
int id() const override { return RMCommandId::ID_ResizeTilemap; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int oldWidth;
|
||||||
|
int oldHeight;
|
||||||
|
int newWidth;
|
||||||
|
int newHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // REGIONMAPEDITCOMMANDS_H
|
#endif // REGIONMAPEDITCOMMANDS_H
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
void onRegionMapEntriesSelectedTileChanged(QString) {};
|
void onRegionMapEntriesSelectedTileChanged(QString) {};
|
||||||
void onRegionMapEntryDragged(int, int);
|
void onRegionMapEntryDragged(int, int);
|
||||||
|
|
||||||
void resize(int width, int height);
|
void resizeTilemap(int width, int height);
|
||||||
|
|
||||||
QObjectList shortcutableObjects() const;
|
QObjectList shortcutableObjects() const;
|
||||||
|
|
||||||
|
@ -87,6 +87,8 @@ private:
|
||||||
RegionMapPixmapItem *region_map_item = nullptr;
|
RegionMapPixmapItem *region_map_item = nullptr;
|
||||||
CityMapPixmapItem *city_map_item = nullptr;
|
CityMapPixmapItem *city_map_item = nullptr;
|
||||||
|
|
||||||
|
bool saveRegionMap(RegionMap *map);
|
||||||
|
void saveConfig();
|
||||||
bool loadRegionMapEntries();
|
bool loadRegionMapEntries();
|
||||||
bool saveRegionMapEntries();
|
bool saveRegionMapEntries();
|
||||||
tsl::ordered_map<QString, MapSectionEntry> region_map_entries;
|
tsl::ordered_map<QString, MapSectionEntry> region_map_entries;
|
||||||
|
@ -122,6 +124,7 @@ private:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_action_RegionMap_Save_triggered();
|
void on_action_RegionMap_Save_triggered();
|
||||||
|
void on_actionSave_All_triggered();
|
||||||
void on_action_RegionMap_Resize_triggered();
|
void on_action_RegionMap_Resize_triggered();
|
||||||
void on_action_RegionMap_ClearImage_triggered();
|
void on_action_RegionMap_ClearImage_triggered();
|
||||||
void on_action_RegionMap_ClearLayout_triggered();
|
void on_action_RegionMap_ClearLayout_triggered();
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
this->tile_selector = tile_selector;
|
this->tile_selector = tile_selector;
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
RegionMap *region_map;
|
RegionMap *region_map = nullptr;
|
||||||
TilemapTileSelector *tile_selector;
|
TilemapTileSelector *tile_selector;
|
||||||
|
|
||||||
virtual void paint(QGraphicsSceneMouseEvent *);
|
virtual void paint(QGraphicsSceneMouseEvent *);
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
"region_maps": [
|
"region_maps": [
|
||||||
{
|
{
|
||||||
"alias": "hoenn",
|
"alias": "hoenn",
|
||||||
"width": 32,
|
|
||||||
"height": 20,
|
|
||||||
"tilemap": {
|
"tilemap": {
|
||||||
"width": 64,
|
"width": 64,
|
||||||
"height": 64,
|
"height": 64,
|
||||||
|
@ -22,8 +20,6 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"alias": "pokedex area screen",
|
"alias": "pokedex area screen",
|
||||||
"width": 32,
|
|
||||||
"height": 20,
|
|
||||||
"tilemap": {
|
"tilemap": {
|
||||||
"width": 32,
|
"width": 32,
|
||||||
"height": 32,
|
"height": 32,
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
"region_maps": [
|
"region_maps": [
|
||||||
{
|
{
|
||||||
"alias": "kanto",
|
"alias": "kanto",
|
||||||
"width": 30,
|
|
||||||
"height": 20,
|
|
||||||
"tilemap": {
|
"tilemap": {
|
||||||
"width": 30,
|
"width": 30,
|
||||||
"height": 20,
|
"height": 20,
|
||||||
|
@ -23,8 +21,6 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"alias": "sevii_123",
|
"alias": "sevii_123",
|
||||||
"width": 30,
|
|
||||||
"height": 20,
|
|
||||||
"tilemap": {
|
"tilemap": {
|
||||||
"width": 30,
|
"width": 30,
|
||||||
"height": 20,
|
"height": 20,
|
||||||
|
@ -44,8 +40,6 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"alias": "sevii_45",
|
"alias": "sevii_45",
|
||||||
"width": 30,
|
|
||||||
"height": 20,
|
|
||||||
"tilemap": {
|
"tilemap": {
|
||||||
"width": 30,
|
"width": 30,
|
||||||
"height": 20,
|
"height": 20,
|
||||||
|
@ -65,8 +59,6 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"alias": "sevii_67",
|
"alias": "sevii_67",
|
||||||
"width": 30,
|
|
||||||
"height": 20,
|
|
||||||
"tilemap": {
|
"tilemap": {
|
||||||
"width": 30,
|
"width": 30,
|
||||||
"height": 20,
|
"height": 20,
|
||||||
|
|
|
@ -31,8 +31,6 @@ bool RegionMap::loadMapData(poryjson::Json data) {
|
||||||
poryjson::Json::object mapObject = data.object_items();
|
poryjson::Json::object mapObject = data.object_items();
|
||||||
|
|
||||||
this->alias = mapObject["alias"].string_value();
|
this->alias = mapObject["alias"].string_value();
|
||||||
this->region_width = mapObject["width"].int_value();
|
|
||||||
this->region_height = mapObject["height"].int_value();
|
|
||||||
|
|
||||||
poryjson::Json tilemapJson = mapObject["tilemap"];
|
poryjson::Json tilemapJson = mapObject["tilemap"];
|
||||||
poryjson::Json layoutJson = mapObject["layout"];
|
poryjson::Json layoutJson = mapObject["layout"];
|
||||||
|
@ -260,6 +258,41 @@ void RegionMap::save() {
|
||||||
saveLayout();
|
saveLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
poryjson::Json::object RegionMap::config() {
|
||||||
|
poryjson::Json::object config;
|
||||||
|
|
||||||
|
config["alias"] = this->alias;
|
||||||
|
|
||||||
|
poryjson::Json::object tilemapObject;
|
||||||
|
tilemapObject["width"] = this->tilemap_width;
|
||||||
|
tilemapObject["height"] = this->tilemap_height;
|
||||||
|
|
||||||
|
QMap<TilemapFormat, QString> tilemapFormatMap = { {TilemapFormat::Plain, "plain"}, {TilemapFormat::BPP_4, "4bpp"}, {TilemapFormat::BPP_8, "8bpp"} };
|
||||||
|
tilemapObject["format"] = tilemapFormatMap[this->tilemap_format];
|
||||||
|
tilemapObject["tileset_path"] = this->tileset_path;
|
||||||
|
tilemapObject["tilemap_path"] = this->tilemap_path;
|
||||||
|
if (!this->palette_path.isEmpty()) {
|
||||||
|
tilemapObject["palette"] = this->palette_path;
|
||||||
|
}
|
||||||
|
config["tilemap"] = tilemapObject;
|
||||||
|
|
||||||
|
if (this->layout_format != LayoutFormat::None) {
|
||||||
|
poryjson::Json::object layoutObject;
|
||||||
|
layoutObject["width"] = this->layout_width;
|
||||||
|
layoutObject["height"] = this->layout_height;
|
||||||
|
layoutObject["offset_left"] = this->offset_left;
|
||||||
|
layoutObject["offset_top"] = this->offset_top;
|
||||||
|
QMap<LayoutFormat, QString> layoutFormatMap = { {LayoutFormat::Binary, "binary"}, {LayoutFormat::CArray, "C array"} };
|
||||||
|
layoutObject["format"] = layoutFormatMap[this->layout_format];
|
||||||
|
layoutObject["path"] = this->layout_path;
|
||||||
|
config["layout"] = layoutObject;
|
||||||
|
} else {
|
||||||
|
config["layout"] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
void RegionMap::saveTilemap() {
|
void RegionMap::saveTilemap() {
|
||||||
QFile tilemapFile(fullPath(this->tilemap_path));
|
QFile tilemapFile(fullPath(this->tilemap_path));
|
||||||
if (!tilemapFile.open(QIODevice::WriteOnly)) {
|
if (!tilemapFile.open(QIODevice::WriteOnly)) {
|
||||||
|
@ -354,9 +387,52 @@ void RegionMap::replaceSection(QString oldSection, QString newSection) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMap::resize(int newWidth, int newHeight) {
|
void RegionMap::resizeTilemap(int newWidth, int newHeight, bool update) {
|
||||||
// TODO
|
auto tilemapCopy = this->tilemap;
|
||||||
|
int oldWidth = this->tilemap_width;
|
||||||
|
int oldHeight = this->tilemap_height;
|
||||||
|
this->tilemap_width = newWidth;
|
||||||
|
this->tilemap_height = newHeight;
|
||||||
|
|
||||||
|
if (update) {
|
||||||
|
QByteArray tilemapArray;
|
||||||
|
QDataStream dataStream(&tilemapArray, QIODevice::WriteOnly);
|
||||||
|
dataStream.setByteOrder(QDataStream::LittleEndian);
|
||||||
|
switch (this->tilemap_format) {
|
||||||
|
case TilemapFormat::Plain:
|
||||||
|
for (int y = 0; y < newHeight; y++)
|
||||||
|
for (int x = 0; x < newWidth; x++) {
|
||||||
|
if (y < oldHeight && x < oldWidth) {
|
||||||
|
int i = x + y * oldWidth;
|
||||||
|
uint8_t tile = tilemapCopy[i]->raw();
|
||||||
|
dataStream << tile;
|
||||||
|
} else {
|
||||||
|
uint8_t tile = 0;
|
||||||
|
dataStream << tile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TilemapFormat::BPP_4:
|
||||||
|
case TilemapFormat::BPP_8:
|
||||||
|
for (int y = 0; y < newHeight; y++)
|
||||||
|
for (int x = 0; x < newWidth; x++) {
|
||||||
|
if (y < oldHeight && x < oldWidth) {
|
||||||
|
int i = x + y * oldWidth;
|
||||||
|
uint16_t tile = tilemapCopy[i]->raw();
|
||||||
|
dataStream << tile;
|
||||||
|
} else {
|
||||||
|
uint16_t tile = 0;
|
||||||
|
dataStream << tile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setTilemap(tilemapArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMap::emitDisplay() {
|
||||||
|
emit mapNeedsDisplaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray RegionMap::getTilemap() {
|
QByteArray RegionMap::getTilemap() {
|
||||||
|
|
|
@ -225,4 +225,37 @@ void RemoveEntry::undo() {
|
||||||
QUndoCommand::undo();
|
QUndoCommand::undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
|
ResizeTilemap::ResizeTilemap(RegionMap *map, QByteArray oldTilemap, QByteArray newTilemap,
|
||||||
|
int oldWidth, int oldHeight, int newWidth, int newHeight, QUndoCommand *parent)
|
||||||
|
: EditTilemap(map, oldTilemap, newTilemap, -1, parent) {
|
||||||
|
setText("Resize Tilemap");
|
||||||
|
|
||||||
|
this->oldWidth = oldWidth;
|
||||||
|
this->oldHeight = oldHeight;
|
||||||
|
this->newWidth = newWidth;
|
||||||
|
this->newHeight = newHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResizeTilemap::redo() {
|
||||||
|
QUndoCommand::redo();
|
||||||
|
|
||||||
|
if (!map) return;
|
||||||
|
|
||||||
|
map->resizeTilemap(this->newWidth, this->newHeight, false);
|
||||||
|
map->setTilemap(this->newTilemap);
|
||||||
|
map->emitDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResizeTilemap::undo() {
|
||||||
|
if (!map) return;
|
||||||
|
|
||||||
|
map->resizeTilemap(this->oldWidth, this->oldHeight, false);
|
||||||
|
map->setTilemap(this->oldTilemap);
|
||||||
|
map->emitDisplay();
|
||||||
|
|
||||||
|
QUndoCommand::undo();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,21 +22,19 @@
|
||||||
using OrderedJson = poryjson::Json;
|
using OrderedJson = poryjson::Json;
|
||||||
using OrderedJsonDoc = poryjson::JsonDoc;
|
using OrderedJsonDoc = poryjson::JsonDoc;
|
||||||
|
|
||||||
RegionMapEditor::RegionMapEditor(QWidget *parent, Project *project_) :
|
RegionMapEditor::RegionMapEditor(QWidget *parent, Project *project) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::RegionMapEditor)
|
ui(new Ui::RegionMapEditor)
|
||||||
{
|
{
|
||||||
this->ui->setupUi(this);
|
this->ui->setupUi(this);
|
||||||
this->project = project_;
|
this->project = project;
|
||||||
this->ui->action_RegionMap_Resize->setVisible(false);
|
|
||||||
this->initShortcuts();
|
this->initShortcuts();
|
||||||
this->restoreWindowState();
|
this->restoreWindowState();
|
||||||
//on_verticalSlider_Zoom_Map_Image_valueChanged(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionMapEditor::~RegionMapEditor()
|
RegionMapEditor::~RegionMapEditor()
|
||||||
{
|
{
|
||||||
delete ui;
|
this->region_map = nullptr;
|
||||||
// deletion must be done in this order else crashes
|
// deletion must be done in this order else crashes
|
||||||
auto stacks = this->history.stacks();
|
auto stacks = this->history.stacks();
|
||||||
for (auto *stack : stacks) {
|
for (auto *stack : stacks) {
|
||||||
|
@ -55,6 +53,7 @@ RegionMapEditor::~RegionMapEditor()
|
||||||
delete scene_city_map_image;
|
delete scene_city_map_image;
|
||||||
delete scene_region_map_layout;
|
delete scene_region_map_layout;
|
||||||
delete scene_region_map_tiles;
|
delete scene_region_map_tiles;
|
||||||
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::restoreWindowState() {
|
void RegionMapEditor::restoreWindowState() {
|
||||||
|
@ -81,10 +80,6 @@ void RegionMapEditor::initShortcuts() {
|
||||||
ui->menuEdit->addAction(undoAction);
|
ui->menuEdit->addAction(undoAction);
|
||||||
ui->menuEdit->addAction(redoAction);
|
ui->menuEdit->addAction(redoAction);
|
||||||
|
|
||||||
connect(&(this->history), &QUndoGroup::indexChanged, [this](int) {
|
|
||||||
on_tabWidget_Region_Map_currentChanged(this->ui->tabWidget_Region_Map->currentIndex());
|
|
||||||
});
|
|
||||||
|
|
||||||
shortcutsConfig.load();
|
shortcutsConfig.load();
|
||||||
shortcutsConfig.setDefaultShortcuts(shortcutableObjects());
|
shortcutsConfig.setDefaultShortcuts(shortcutableObjects());
|
||||||
applyUserShortcuts();
|
applyUserShortcuts();
|
||||||
|
@ -433,6 +428,10 @@ bool RegionMapEditor::load() {
|
||||||
newMap->setEntries(&this->region_map_entries);
|
newMap->setEntries(&this->region_map_entries);
|
||||||
newMap->loadMapData(o);
|
newMap->loadMapData(o);
|
||||||
|
|
||||||
|
connect(newMap, &RegionMap::mapNeedsDisplaying, [this]() {
|
||||||
|
displayRegionMap();
|
||||||
|
});
|
||||||
|
|
||||||
region_maps[alias] = newMap;
|
region_maps[alias] = newMap;
|
||||||
|
|
||||||
this->history.addStack(&(newMap->editHistory));
|
this->history.addStack(&(newMap->editHistory));
|
||||||
|
@ -448,6 +447,10 @@ bool RegionMapEditor::load() {
|
||||||
setRegionMap(region_maps.begin()->second);
|
setRegionMap(region_maps.begin()->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(&(this->history), &QUndoGroup::indexChanged, [this](int) {
|
||||||
|
on_tabWidget_Region_Map_currentChanged(this->ui->tabWidget_Region_Map->currentIndex());
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,23 +480,56 @@ bool RegionMapEditor::loadCityMaps() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_action_RegionMap_Save_triggered() {
|
bool RegionMapEditor::saveRegionMap(RegionMap *map) {
|
||||||
// TODO: add "Save All" to save all region maps
|
//
|
||||||
this->region_map->save();
|
if (!map) return false;
|
||||||
|
|
||||||
// save entries
|
map->save();
|
||||||
saveRegionMapEntries();
|
|
||||||
|
|
||||||
// save config
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::saveConfig() {
|
||||||
|
OrderedJson::array mapArray;
|
||||||
|
for (auto it : this->region_maps) {
|
||||||
|
OrderedJson::object obj = it.second->config();
|
||||||
|
mapArray.append(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderedJson::object mapsObject;
|
||||||
|
mapsObject["region_maps"] = mapArray;
|
||||||
|
|
||||||
|
OrderedJson newConfigJson(mapsObject);
|
||||||
QString filepath = QString("%1/src/data/region_map/porymap_config.json").arg(this->project->root);
|
QString filepath = QString("%1/src/data/region_map/porymap_config.json").arg(this->project->root);
|
||||||
QFile file(filepath);
|
QFile file(filepath);
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
logError(QString("Error: Could not open %1 for writing").arg(filepath));
|
logError(QString("Error: Could not open %1 for writing").arg(filepath));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
OrderedJsonDoc jsonDoc(&(this->rmConfigJson));
|
OrderedJsonDoc jsonDoc(&newConfigJson);
|
||||||
jsonDoc.dump(&file);
|
jsonDoc.dump(&file);
|
||||||
file.close();
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_action_RegionMap_Save_triggered() {
|
||||||
|
// TODO: add "Save All" to save all region maps
|
||||||
|
saveRegionMap(this->region_map);
|
||||||
|
|
||||||
|
// save entries
|
||||||
|
saveRegionMapEntries();
|
||||||
|
|
||||||
|
// save config
|
||||||
|
saveConfig();
|
||||||
|
|
||||||
|
this->hasUnsavedChanges = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegionMapEditor::on_actionSave_All_triggered() {
|
||||||
|
for (auto it : this->region_maps) {
|
||||||
|
saveRegionMap(it.second);
|
||||||
|
}
|
||||||
|
saveRegionMapEntries();
|
||||||
|
saveConfig();
|
||||||
|
|
||||||
this->hasUnsavedChanges = false;
|
this->hasUnsavedChanges = false;
|
||||||
}
|
}
|
||||||
|
@ -520,7 +556,6 @@ void RegionMapEditor::updateLayerDisplayed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_comboBox_regionSelector_textActivated(const QString ®ion) {
|
void RegionMapEditor::on_comboBox_regionSelector_textActivated(const QString ®ion) {
|
||||||
//
|
|
||||||
if (this->region_maps.contains(region)) {
|
if (this->region_maps.contains(region)) {
|
||||||
setRegionMap(region_maps.at(region));
|
setRegionMap(region_maps.at(region));
|
||||||
}
|
}
|
||||||
|
@ -596,6 +631,8 @@ void RegionMapEditor::updateRegionMapLayoutOptions(int index) {
|
||||||
this->ui->comboBox_RM_ConnectedMap->setCurrentText(this->region_map->squareMapSection(index));
|
this->ui->comboBox_RM_ConnectedMap->setCurrentText(this->region_map->squareMapSection(index));
|
||||||
this->ui->comboBox_RM_ConnectedMap->blockSignals(false);
|
this->ui->comboBox_RM_ConnectedMap->blockSignals(false);
|
||||||
|
|
||||||
|
this->ui->pushButton_RM_Options_delete->setEnabled(this->region_map->squareHasMap(index));
|
||||||
|
|
||||||
this->ui->spinBox_RM_LayoutWidth->blockSignals(true);
|
this->ui->spinBox_RM_LayoutWidth->blockSignals(true);
|
||||||
this->ui->spinBox_RM_LayoutHeight->blockSignals(true);
|
this->ui->spinBox_RM_LayoutHeight->blockSignals(true);
|
||||||
this->ui->spinBox_RM_LayoutWidth->setMinimum(1);
|
this->ui->spinBox_RM_LayoutWidth->setMinimum(1);
|
||||||
|
@ -910,6 +947,8 @@ void RegionMapEditor::onHoveredRegionMapTileCleared() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::mouseEvent_region_map(QGraphicsSceneMouseEvent *event, RegionMapPixmapItem *item) {
|
void RegionMapEditor::mouseEvent_region_map(QGraphicsSceneMouseEvent *event, RegionMapPixmapItem *item) {
|
||||||
|
static unsigned actionId_ = 0;
|
||||||
|
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int x = static_cast<int>(pos.x()) / 8;
|
int x = static_cast<int>(pos.x()) / 8;
|
||||||
int y = static_cast<int>(pos.y()) / 8;
|
int y = static_cast<int>(pos.y()) / 8;
|
||||||
|
@ -920,9 +959,17 @@ void RegionMapEditor::mouseEvent_region_map(QGraphicsSceneMouseEvent *event, Reg
|
||||||
item->select(event);
|
item->select(event);
|
||||||
//} else if (event->buttons() & Qt::MiddleButton) {// TODO
|
//} else if (event->buttons() & Qt::MiddleButton) {// TODO
|
||||||
} else {
|
} else {
|
||||||
item->paint(event);
|
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||||
this->region_map_layout_item->draw();
|
actionId_++;
|
||||||
this->hasUnsavedChanges = true;
|
} else {
|
||||||
|
QByteArray oldTilemap = this->region_map->getTilemap();
|
||||||
|
item->paint(event);
|
||||||
|
QByteArray newTilemap = this->region_map->getTilemap();
|
||||||
|
EditTilemap *command = new EditTilemap(this->region_map, oldTilemap, newTilemap, actionId_);
|
||||||
|
this->region_map->commit(command);
|
||||||
|
//this->region_map_layout_item->draw();
|
||||||
|
this->hasUnsavedChanges = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,7 +1007,7 @@ void RegionMapEditor::mouseEvent_city_map(QGraphicsSceneMouseEvent *event, CityM
|
||||||
|
|
||||||
void RegionMapEditor::on_tabWidget_Region_Map_currentChanged(int index) {
|
void RegionMapEditor::on_tabWidget_Region_Map_currentChanged(int index) {
|
||||||
this->ui->stackedWidget_RM_Options->setCurrentIndex(index);
|
this->ui->stackedWidget_RM_Options->setCurrentIndex(index);
|
||||||
if (!region_map) return;
|
if (!this->region_map) return;
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1019,8 +1066,6 @@ void RegionMapEditor::on_comboBox_layoutLayer_textActivated(const QString &text)
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_spinBox_RM_Entry_x_valueChanged(int x) {
|
void RegionMapEditor::on_spinBox_RM_Entry_x_valueChanged(int x) {
|
||||||
//tryInsertNewMapEntry(activeEntry);
|
|
||||||
qDebug() << "spinBox_RM_Entry_x valueChanged" << x;
|
|
||||||
if (!this->region_map_entries.contains(activeEntry)) return;
|
if (!this->region_map_entries.contains(activeEntry)) return;
|
||||||
MapSectionEntry oldEntry = this->region_map_entries[activeEntry];
|
MapSectionEntry oldEntry = this->region_map_entries[activeEntry];
|
||||||
this->region_map_entries[activeEntry].x = x;
|
this->region_map_entries[activeEntry].x = x;
|
||||||
|
@ -1036,7 +1081,6 @@ void RegionMapEditor::on_spinBox_RM_Entry_x_valueChanged(int x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_spinBox_RM_Entry_y_valueChanged(int y) {
|
void RegionMapEditor::on_spinBox_RM_Entry_y_valueChanged(int y) {
|
||||||
//tryInsertNewMapEntry(activeEntry);
|
|
||||||
if (!this->region_map_entries.contains(activeEntry)) return;
|
if (!this->region_map_entries.contains(activeEntry)) return;
|
||||||
MapSectionEntry oldEntry = this->region_map_entries[activeEntry];
|
MapSectionEntry oldEntry = this->region_map_entries[activeEntry];
|
||||||
this->region_map_entries[activeEntry].y = y;
|
this->region_map_entries[activeEntry].y = y;
|
||||||
|
@ -1052,7 +1096,6 @@ void RegionMapEditor::on_spinBox_RM_Entry_y_valueChanged(int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_spinBox_RM_Entry_width_valueChanged(int width) {
|
void RegionMapEditor::on_spinBox_RM_Entry_width_valueChanged(int width) {
|
||||||
//tryInsertNewMapEntry(activeEntry);
|
|
||||||
if (!this->region_map_entries.contains(activeEntry)) return;
|
if (!this->region_map_entries.contains(activeEntry)) return;
|
||||||
MapSectionEntry oldEntry = this->region_map_entries[activeEntry];
|
MapSectionEntry oldEntry = this->region_map_entries[activeEntry];
|
||||||
this->region_map_entries[activeEntry].width = width;
|
this->region_map_entries[activeEntry].width = width;
|
||||||
|
@ -1064,7 +1107,6 @@ void RegionMapEditor::on_spinBox_RM_Entry_width_valueChanged(int width) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_spinBox_RM_Entry_height_valueChanged(int height) {
|
void RegionMapEditor::on_spinBox_RM_Entry_height_valueChanged(int height) {
|
||||||
//tryInsertNewMapEntry(activeEntry);
|
|
||||||
if (!this->region_map_entries.contains(activeEntry)) return;
|
if (!this->region_map_entries.contains(activeEntry)) return;
|
||||||
MapSectionEntry oldEntry = this->region_map_entries[activeEntry];
|
MapSectionEntry oldEntry = this->region_map_entries[activeEntry];
|
||||||
this->region_map_entries[activeEntry].height = height;
|
this->region_map_entries[activeEntry].height = height;
|
||||||
|
@ -1076,7 +1118,6 @@ void RegionMapEditor::on_spinBox_RM_Entry_height_valueChanged(int height) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_spinBox_RM_LayoutWidth_valueChanged(int value) {
|
void RegionMapEditor::on_spinBox_RM_LayoutWidth_valueChanged(int value) {
|
||||||
//
|
|
||||||
if (this->region_map) {
|
if (this->region_map) {
|
||||||
int oldWidth = this->region_map->layoutWidth();
|
int oldWidth = this->region_map->layoutWidth();
|
||||||
int oldHeight = this->region_map->layoutHeight();
|
int oldHeight = this->region_map->layoutHeight();
|
||||||
|
@ -1179,23 +1220,21 @@ void RegionMapEditor::on_pushButton_CityMap_add_clicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_action_RegionMap_Resize_triggered() {
|
void RegionMapEditor::on_action_RegionMap_Resize_triggered() {
|
||||||
// TODO: this whole feature
|
|
||||||
/*
|
|
||||||
QDialog popup(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
QDialog popup(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
||||||
popup.setWindowTitle("New Region Map Dimensions");
|
popup.setWindowTitle("New Tilemap Dimensions");
|
||||||
popup.setWindowModality(Qt::NonModal);
|
popup.setWindowModality(Qt::NonModal);
|
||||||
|
|
||||||
QFormLayout form(&popup);
|
QFormLayout form(&popup);
|
||||||
|
|
||||||
QSpinBox *widthSpinBox = new QSpinBox();
|
// TODO: limits do not go smaller than layout
|
||||||
QSpinBox *heightSpinBox = new QSpinBox();
|
QSpinBox *widthSpinBox = new QSpinBox;
|
||||||
widthSpinBox->setMinimum(32);
|
QSpinBox *heightSpinBox = new QSpinBox;
|
||||||
heightSpinBox->setMinimum(20);
|
widthSpinBox->setMinimum(16);
|
||||||
widthSpinBox->setMaximum(128);// TODO: find real limits... 128
|
heightSpinBox->setMinimum(16);
|
||||||
|
widthSpinBox->setMaximum(128);
|
||||||
heightSpinBox->setMaximum(128);
|
heightSpinBox->setMaximum(128);
|
||||||
// TODO width, height
|
widthSpinBox->setValue(this->region_map->tilemapWidth());
|
||||||
widthSpinBox->setValue(this->region_map->width());
|
heightSpinBox->setValue(this->region_map->tilemapHeight());
|
||||||
heightSpinBox->setValue(this->region_map->height());
|
|
||||||
form.addRow(new QLabel("Width"), widthSpinBox);
|
form.addRow(new QLabel("Width"), widthSpinBox);
|
||||||
form.addRow(new QLabel("Height"), heightSpinBox);
|
form.addRow(new QLabel("Height"), heightSpinBox);
|
||||||
|
|
||||||
|
@ -1206,24 +1245,25 @@ void RegionMapEditor::on_action_RegionMap_Resize_triggered() {
|
||||||
connect(&buttonBox, &QDialogButtonBox::accepted, &popup, &QDialog::accept);
|
connect(&buttonBox, &QDialogButtonBox::accepted, &popup, &QDialog::accept);
|
||||||
|
|
||||||
if (popup.exec() == QDialog::Accepted) {
|
if (popup.exec() == QDialog::Accepted) {
|
||||||
resize(widthSpinBox->value(), heightSpinBox->value());
|
resizeTilemap(widthSpinBox->value(), heightSpinBox->value());
|
||||||
RegionMapHistoryItem *commit = new RegionMapHistoryItem(
|
|
||||||
RegionMapEditorBox::BackgroundImage, this->region_map->getTiles(), widthSpinBox->value(), heightSpinBox->value()
|
|
||||||
);
|
|
||||||
history.push(commit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->hasUnsavedChanges = true;
|
|
||||||
*/
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::resize(int w, int h) {
|
void RegionMapEditor::resizeTilemap(int width, int height) {
|
||||||
this->region_map->resize(w, h);
|
QByteArray oldTilemap = this->region_map->getTilemap();
|
||||||
this->currIndex = this->region_map->padLeft() * w + this->region_map->padTop();
|
int oldWidth = this->region_map->tilemapWidth();
|
||||||
displayRegionMapImage();
|
int oldHeight = this->region_map->tilemapHeight();
|
||||||
displayRegionMapLayout();
|
this->region_map->resizeTilemap(width, height);
|
||||||
displayRegionMapLayoutOptions();
|
QByteArray newTilemap = this->region_map->getTilemap();
|
||||||
|
int newWidth = this->region_map->tilemapWidth();
|
||||||
|
int newHeight = this->region_map->tilemapHeight();
|
||||||
|
ResizeTilemap *commit = new ResizeTilemap(this->region_map, oldTilemap, newTilemap, oldWidth, oldHeight, newWidth, newHeight);
|
||||||
|
this->region_map->editHistory.push(commit);
|
||||||
|
this->currIndex = this->region_map->padLeft() * width + this->region_map->padTop();
|
||||||
|
//displayRegionMapImage();
|
||||||
|
//displayRegionMapLayout();
|
||||||
|
//displayRegionMapLayoutOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_action_Swap_triggered() {
|
void RegionMapEditor::on_action_Swap_triggered() {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "regionmappixmapitem.h"
|
#include "regionmappixmapitem.h"
|
||||||
#include "regionmapeditcommands.h"
|
#include "regionmapeditcommands.h"
|
||||||
|
|
||||||
static unsigned actionId_ = 0;
|
|
||||||
|
|
||||||
void RegionMapPixmapItem::draw() {
|
void RegionMapPixmapItem::draw() {
|
||||||
if (!region_map) return;
|
if (!region_map) return;
|
||||||
|
|
||||||
|
@ -23,25 +21,17 @@ void RegionMapPixmapItem::draw() {
|
||||||
|
|
||||||
void RegionMapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
void RegionMapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
||||||
if (region_map) {
|
if (region_map) {
|
||||||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
QPointF pos = event->pos();
|
||||||
actionId_++;
|
int x = static_cast<int>(pos.x()) / 8;
|
||||||
} else {
|
int y = static_cast<int>(pos.y()) / 8;
|
||||||
QPointF pos = event->pos();
|
int index = x + y * region_map->tilemapWidth();
|
||||||
int x = static_cast<int>(pos.x()) / 8;
|
this->region_map->setTileData(index,
|
||||||
int y = static_cast<int>(pos.y()) / 8;
|
this->tile_selector->selectedTile,
|
||||||
int index = x + y * region_map->tilemapWidth();
|
this->tile_selector->tile_hFlip,
|
||||||
QByteArray oldTilemap = this->region_map->getTilemap();
|
this->tile_selector->tile_vFlip,
|
||||||
this->region_map->setTileData(index,
|
this->tile_selector->tile_palette
|
||||||
this->tile_selector->selectedTile,
|
);
|
||||||
this->tile_selector->tile_hFlip,
|
draw();
|
||||||
this->tile_selector->tile_vFlip,
|
|
||||||
this->tile_selector->tile_palette
|
|
||||||
);
|
|
||||||
QByteArray newTilemap = this->region_map->getTilemap();
|
|
||||||
EditTilemap *command = new EditTilemap(this->region_map, oldTilemap, newTilemap, actionId_);
|
|
||||||
this->region_map->commit(command);
|
|
||||||
draw();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,6 @@ RegionMapPropertiesDialog::~RegionMapPropertiesDialog()
|
||||||
|
|
||||||
void RegionMapPropertiesDialog::hideMessages() {
|
void RegionMapPropertiesDialog::hideMessages() {
|
||||||
ui->message_alias->setVisible(false);
|
ui->message_alias->setVisible(false);
|
||||||
ui->message_width->setVisible(false);
|
|
||||||
ui->message_height->setVisible(false);
|
|
||||||
ui->message_tilemapFormat->setVisible(false);
|
ui->message_tilemapFormat->setVisible(false);
|
||||||
ui->message_tilemapWidth->setVisible(false);
|
ui->message_tilemapWidth->setVisible(false);
|
||||||
ui->message_tilemapHeight->setVisible(false);
|
ui->message_tilemapHeight->setVisible(false);
|
||||||
|
@ -48,8 +46,6 @@ void RegionMapPropertiesDialog::setProperties(poryjson::Json json) {
|
||||||
|
|
||||||
// Region Map Properties
|
// Region Map Properties
|
||||||
ui->config_alias->setText(object["alias"].string_value());
|
ui->config_alias->setText(object["alias"].string_value());
|
||||||
ui->config_width->setValue(object["width"].int_value());
|
|
||||||
ui->config_height->setValue(object["height"].int_value());
|
|
||||||
|
|
||||||
// Tilemap properties
|
// Tilemap properties
|
||||||
poryjson::Json::object tilemap = object["tilemap"].object_items();
|
poryjson::Json::object tilemap = object["tilemap"].object_items();
|
||||||
|
@ -82,8 +78,6 @@ poryjson::Json RegionMapPropertiesDialog::saveToJson() {
|
||||||
// TODO: make sure next comment is not a lie
|
// TODO: make sure next comment is not a lie
|
||||||
// data should already be verified and valid at this point
|
// data should already be verified and valid at this point
|
||||||
config["alias"] = ui->config_alias->text();
|
config["alias"] = ui->config_alias->text();
|
||||||
config["width"] = ui->config_width->value();
|
|
||||||
config["height"] = ui->config_height->value();
|
|
||||||
|
|
||||||
poryjson::Json::object tilemapObject;
|
poryjson::Json::object tilemapObject;
|
||||||
tilemapObject["width"] = ui->config_tilemapWidth->value();
|
tilemapObject["width"] = ui->config_tilemapWidth->value();
|
||||||
|
|
Loading…
Reference in a new issue