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/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="icon">
|
<attribute name="icon">
|
||||||
<iconset resource="resources/images.qrc">
|
<iconset resource="../resources/images.qrc">
|
||||||
<normaloff>:/icons/map.ico</normaloff>:/icons/map.ico</iconset>
|
<normaloff>:/icons/map.ico</normaloff>:/icons/map.ico</iconset>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -177,7 +177,7 @@
|
||||||
<string>Paint</string>
|
<string>Paint</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources/images.qrc">
|
<iconset resource="../resources/images.qrc">
|
||||||
<normaloff>:/icons/pencil.ico</normaloff>:/icons/pencil.ico</iconset>
|
<normaloff>:/icons/pencil.ico</normaloff>:/icons/pencil.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
|
@ -203,7 +203,7 @@
|
||||||
<string>Select</string>
|
<string>Select</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources/images.qrc">
|
<iconset resource="../resources/images.qrc">
|
||||||
<normaloff>:/icons/cursor.ico</normaloff>:/icons/cursor.ico</iconset>
|
<normaloff>:/icons/cursor.ico</normaloff>:/icons/cursor.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
|
@ -220,7 +220,7 @@
|
||||||
<string>Fill</string>
|
<string>Fill</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources/images.qrc">
|
<iconset resource="../resources/images.qrc">
|
||||||
<normaloff>:/icons/fill_color.ico</normaloff>:/icons/fill_color.ico</iconset>
|
<normaloff>:/icons/fill_color.ico</normaloff>:/icons/fill_color.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
|
@ -237,7 +237,7 @@
|
||||||
<string>Dropper</string>
|
<string>Dropper</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources/images.qrc">
|
<iconset resource="../resources/images.qrc">
|
||||||
<normaloff>:/icons/pipette.ico</normaloff>:/icons/pipette.ico</iconset>
|
<normaloff>:/icons/pipette.ico</normaloff>:/icons/pipette.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
|
@ -254,7 +254,7 @@
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources/images.qrc">
|
<iconset resource="../resources/images.qrc">
|
||||||
<normaloff>:/icons/move.ico</normaloff>:/icons/move.ico</iconset>
|
<normaloff>:/icons/move.ico</normaloff>:/icons/move.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
|
@ -271,7 +271,7 @@
|
||||||
<string>Shift</string>
|
<string>Shift</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources/images.qrc">
|
<iconset resource="../resources/images.qrc">
|
||||||
<normaloff>:/icons/shift.ico</normaloff>:/icons/shift.ico</iconset>
|
<normaloff>:/icons/shift.ico</normaloff>:/icons/shift.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
|
@ -1355,7 +1355,7 @@
|
||||||
<string>New Object</string>
|
<string>New Object</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources/images.qrc">
|
<iconset resource="../resources/images.qrc">
|
||||||
<normaloff>:/icons/add.ico</normaloff>:/icons/add.ico</iconset>
|
<normaloff>:/icons/add.ico</normaloff>:/icons/add.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolButtonStyle">
|
<property name="toolButtonStyle">
|
||||||
|
@ -1384,7 +1384,7 @@
|
||||||
<string>Delete</string>
|
<string>Delete</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="resources/images.qrc">
|
<iconset resource="../resources/images.qrc">
|
||||||
<normaloff>:/icons/delete.ico</normaloff>:/icons/delete.ico</iconset>
|
<normaloff>:/icons/delete.ico</normaloff>:/icons/delete.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolButtonStyle">
|
<property name="toolButtonStyle">
|
||||||
|
@ -2127,6 +2127,8 @@
|
||||||
<addaction name="actionEyedropper"/>
|
<addaction name="actionEyedropper"/>
|
||||||
<addaction name="actionMove"/>
|
<addaction name="actionMove"/>
|
||||||
<addaction name="actionMap_Shift"/>
|
<addaction name="actionMap_Shift"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionTileset_Editor"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuEdit"/>
|
<addaction name="menuEdit"/>
|
||||||
|
@ -2268,6 +2270,11 @@
|
||||||
<string>P</string>
|
<string>P</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionTileset_Editor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tileset Editor</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
@ -2288,7 +2295,7 @@
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="resources/images.qrc"/>
|
<include location="../resources/images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</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 updatePrimaryTileset(QString tilesetLabel);
|
||||||
void updateSecondaryTileset(QString tilesetLabel);
|
void updateSecondaryTileset(QString tilesetLabel);
|
||||||
void toggleBorderVisibility(bool visible);
|
void toggleBorderVisibility(bool visible);
|
||||||
|
Tileset *getCurrentMapPrimaryTileset();
|
||||||
|
|
||||||
DraggablePixmapItem *addMapEvent(Event *event);
|
DraggablePixmapItem *addMapEvent(Event *event);
|
||||||
void selectMapEvent(DraggablePixmapItem *object);
|
void selectMapEvent(DraggablePixmapItem *object);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
|
#include "tileseteditor.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
@ -123,8 +124,11 @@ private slots:
|
||||||
|
|
||||||
void resetMapViewScale();
|
void resetMapViewScale();
|
||||||
|
|
||||||
|
void on_actionTileset_Editor_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
TilesetEditor *tilesetEditor;
|
||||||
QStandardItemModel *mapListModel;
|
QStandardItemModel *mapListModel;
|
||||||
QList<QStandardItem*> *mapGroupsModel;
|
QList<QStandardItem*> *mapGroupsModel;
|
||||||
QMap<QString, QModelIndex> mapListIndexes;
|
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/noscrollcombobox.cpp \
|
||||||
src/ui/noscrollspinbox.cpp \
|
src/ui/noscrollspinbox.cpp \
|
||||||
src/ui/selectablepixmapitem.cpp \
|
src/ui/selectablepixmapitem.cpp \
|
||||||
|
src/ui/tileseteditor.cpp \
|
||||||
src/editor.cpp \
|
src/editor.cpp \
|
||||||
src/main.cpp \
|
src/main.cpp \
|
||||||
src/mainwindow.cpp \
|
src/mainwindow.cpp \
|
||||||
|
@ -74,13 +75,15 @@ HEADERS += include/core/block.h \
|
||||||
include/ui/noscrollcombobox.h \
|
include/ui/noscrollcombobox.h \
|
||||||
include/ui/noscrollspinbox.h \
|
include/ui/noscrollspinbox.h \
|
||||||
include/ui/selectablepixmapitem.h \
|
include/ui/selectablepixmapitem.h \
|
||||||
|
include/ui/tileseteditor.h \
|
||||||
include/editor.h \
|
include/editor.h \
|
||||||
include/mainwindow.h \
|
include/mainwindow.h \
|
||||||
include/project.h \
|
include/project.h \
|
||||||
include/settings.h
|
include/settings.h
|
||||||
|
|
||||||
FORMS += forms/mainwindow.ui \
|
FORMS += forms/mainwindow.ui \
|
||||||
forms/eventpropertiesframe.ui
|
forms/eventpropertiesframe.ui \
|
||||||
|
forms/tileseteditor.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources/images.qrc
|
resources/images.qrc
|
||||||
|
|
|
@ -987,6 +987,12 @@ void Editor::toggleBorderVisibility(bool visible)
|
||||||
this->setConnectionsVisibility(visible);
|
this->setConnectionsVisibility(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tileset* Editor::getCurrentMapPrimaryTileset()
|
||||||
|
{
|
||||||
|
QString tilesetLabel = map->layout->tileset_primary_label;
|
||||||
|
return project->getTileset(tilesetLabel);
|
||||||
|
}
|
||||||
|
|
||||||
void DraggablePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) {
|
void DraggablePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) {
|
||||||
active = true;
|
active = true;
|
||||||
last_x = static_cast<int>(mouse->pos().x() + this->pos().x()) / 16;
|
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;
|
bool visible = selected != 0;
|
||||||
editor->toggleBorderVisibility(visible);
|
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