Add Tileset Editor window
This commit is contained in:
parent
866926daa5
commit
9abda07c48
9 changed files with 137 additions and 11 deletions
|
@ -73,7 +73,7 @@
|
|||
<string/>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/map.ico</normaloff>:/icons/map.ico</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
|
@ -177,7 +177,7 @@
|
|||
<string>Paint</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/pencil.ico</normaloff>:/icons/pencil.ico</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
|
@ -203,7 +203,7 @@
|
|||
<string>Select</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/cursor.ico</normaloff>:/icons/cursor.ico</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
|
@ -220,7 +220,7 @@
|
|||
<string>Fill</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/fill_color.ico</normaloff>:/icons/fill_color.ico</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
|
@ -237,7 +237,7 @@
|
|||
<string>Dropper</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/pipette.ico</normaloff>:/icons/pipette.ico</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
|
@ -254,7 +254,7 @@
|
|||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/move.ico</normaloff>:/icons/move.ico</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
|
@ -271,7 +271,7 @@
|
|||
<string>Shift</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/shift.ico</normaloff>:/icons/shift.ico</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
|
@ -1355,7 +1355,7 @@
|
|||
<string>New Object</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/add.ico</normaloff>:/icons/add.ico</iconset>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
|
@ -1384,7 +1384,7 @@
|
|||
<string>Delete</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources/images.qrc">
|
||||
<iconset resource="../resources/images.qrc">
|
||||
<normaloff>:/icons/delete.ico</normaloff>:/icons/delete.ico</iconset>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
|
@ -2127,6 +2127,8 @@
|
|||
<addaction name="actionEyedropper"/>
|
||||
<addaction name="actionMove"/>
|
||||
<addaction name="actionMap_Shift"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionTileset_Editor"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
|
@ -2268,6 +2270,11 @@
|
|||
<string>P</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionTileset_Editor">
|
||||
<property name="text">
|
||||
<string>Tileset Editor</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
@ -2288,7 +2295,7 @@
|
|||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="resources/images.qrc"/>
|
||||
<include location="../resources/images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
40
forms/tileseteditor.ui
Normal file
40
forms/tileseteditor.ui
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TilesetEditor</class>
|
||||
<widget class="QMainWindow" name="TilesetEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QGraphicsView" name="graphicsView_PrimaryTilesetMetatiles"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGraphicsView" name="graphicsView_PrimaryTilesetTiles"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -71,6 +71,7 @@ public:
|
|||
void updatePrimaryTileset(QString tilesetLabel);
|
||||
void updateSecondaryTileset(QString tilesetLabel);
|
||||
void toggleBorderVisibility(bool visible);
|
||||
Tileset *getCurrentMapPrimaryTileset();
|
||||
|
||||
DraggablePixmapItem *addMapEvent(Event *event);
|
||||
void selectMapEvent(DraggablePixmapItem *object);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "project.h"
|
||||
#include "map.h"
|
||||
#include "editor.h"
|
||||
#include "tileseteditor.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
|
@ -123,8 +124,11 @@ private slots:
|
|||
|
||||
void resetMapViewScale();
|
||||
|
||||
void on_actionTileset_Editor_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
TilesetEditor *tilesetEditor;
|
||||
QStandardItemModel *mapListModel;
|
||||
QList<QStandardItem*> *mapGroupsModel;
|
||||
QMap<QString, QModelIndex> mapListIndexes;
|
||||
|
|
26
include/ui/tileseteditor.h
Normal file
26
include/ui/tileseteditor.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef TILESETEDITOR_H
|
||||
#define TILESETEDITOR_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "project.h"
|
||||
|
||||
namespace Ui {
|
||||
class TilesetEditor;
|
||||
}
|
||||
|
||||
class TilesetEditor : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TilesetEditor(QWidget *parent = nullptr, Project *project = nullptr);
|
||||
~TilesetEditor();
|
||||
|
||||
private:
|
||||
void displayPrimaryTilesetTiles();
|
||||
Ui::TilesetEditor *ui;
|
||||
Project *project;
|
||||
QString primaryTilesetLabel;
|
||||
};
|
||||
|
||||
#endif // TILESETEDITOR_H
|
|
@ -40,6 +40,7 @@ SOURCES += src/core/block.cpp \
|
|||
src/ui/noscrollcombobox.cpp \
|
||||
src/ui/noscrollspinbox.cpp \
|
||||
src/ui/selectablepixmapitem.cpp \
|
||||
src/ui/tileseteditor.cpp \
|
||||
src/editor.cpp \
|
||||
src/main.cpp \
|
||||
src/mainwindow.cpp \
|
||||
|
@ -74,13 +75,15 @@ HEADERS += include/core/block.h \
|
|||
include/ui/noscrollcombobox.h \
|
||||
include/ui/noscrollspinbox.h \
|
||||
include/ui/selectablepixmapitem.h \
|
||||
include/ui/tileseteditor.h \
|
||||
include/editor.h \
|
||||
include/mainwindow.h \
|
||||
include/project.h \
|
||||
include/settings.h
|
||||
|
||||
FORMS += forms/mainwindow.ui \
|
||||
forms/eventpropertiesframe.ui
|
||||
forms/eventpropertiesframe.ui \
|
||||
forms/tileseteditor.ui
|
||||
|
||||
RESOURCES += \
|
||||
resources/images.qrc
|
||||
|
|
|
@ -987,6 +987,12 @@ void Editor::toggleBorderVisibility(bool visible)
|
|||
this->setConnectionsVisibility(visible);
|
||||
}
|
||||
|
||||
Tileset* Editor::getCurrentMapPrimaryTileset()
|
||||
{
|
||||
QString tilesetLabel = map->layout->tileset_primary_label;
|
||||
return project->getTileset(tilesetLabel);
|
||||
}
|
||||
|
||||
void DraggablePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) {
|
||||
active = true;
|
||||
last_x = static_cast<int>(mouse->pos().x() + this->pos().x()) / 16;
|
||||
|
|
|
@ -1227,3 +1227,16 @@ void MainWindow::on_checkBox_ToggleBorder_stateChanged(int selected)
|
|||
bool visible = selected != 0;
|
||||
editor->toggleBorderVisibility(visible);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionTileset_Editor_triggered()
|
||||
{
|
||||
if (!this->tilesetEditor) {
|
||||
this->tilesetEditor = new TilesetEditor(nullptr, this->editor->project);
|
||||
}
|
||||
|
||||
if (!this->tilesetEditor->isVisible()) {
|
||||
this->tilesetEditor->show();
|
||||
} else {
|
||||
this->tilesetEditor->activateWindow();
|
||||
}
|
||||
}
|
||||
|
|
26
src/ui/tileseteditor.cpp
Normal file
26
src/ui/tileseteditor.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "tileseteditor.h"
|
||||
#include "ui_tileseteditor.h"
|
||||
|
||||
TilesetEditor::TilesetEditor(QWidget *parent, Project *project) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::TilesetEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->project = project;
|
||||
|
||||
displayPrimaryTilesetTiles();
|
||||
}
|
||||
|
||||
TilesetEditor::~TilesetEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TilesetEditor::displayPrimaryTilesetTiles()
|
||||
{
|
||||
Tileset *primaryTileset = this->project->getTileset(this->primaryTilesetLabel);
|
||||
// scene_metatiles = new QGraphicsScene;
|
||||
// metatiles_item = new MetatilesPixmapItem(map);
|
||||
// metatiles_item->draw();
|
||||
// scene_metatiles->addItem(metatiles_item);
|
||||
}
|
Loading…
Reference in a new issue