Added dialog to add events to object

This commit is contained in:
2022-01-13 14:41:17 +01:00
parent 7fdcd5386d
commit 8d45958d45
22 changed files with 474 additions and 124 deletions

View File

@@ -11,6 +11,7 @@ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
HEADERS += \ HEADERS += \
codeeditorwidget.h \ codeeditorwidget.h \
constantsmodel.h \ constantsmodel.h \
dialogs/addeventdialog.h \
dialogs/codeeditordialog.h \ dialogs/codeeditordialog.h \
dialogs/createspritedialog.h \ dialogs/createspritedialog.h \
dialogs/fontpropertiesdialog.h \ dialogs/fontpropertiesdialog.h \
@@ -54,6 +55,7 @@ HEADERS += \
SOURCES += main.cpp \ SOURCES += main.cpp \
codeeditorwidget.cpp \ codeeditorwidget.cpp \
constantsmodel.cpp \ constantsmodel.cpp \
dialogs/addeventdialog.cpp \
dialogs/codeeditordialog.cpp \ dialogs/codeeditordialog.cpp \
dialogs/createspritedialog.cpp \ dialogs/createspritedialog.cpp \
dialogs/fontpropertiesdialog.cpp \ dialogs/fontpropertiesdialog.cpp \
@@ -94,6 +96,7 @@ SOURCES += main.cpp \
triggersmodel.cpp triggersmodel.cpp
FORMS += \ FORMS += \
dialogs/addeventdialog.ui \
dialogs/codeeditordialog.ui \ dialogs/codeeditordialog.ui \
dialogs/createspritedialog.ui \ dialogs/createspritedialog.ui \
dialogs/fontpropertiesdialog.ui \ dialogs/fontpropertiesdialog.ui \

View File

@@ -0,0 +1,48 @@
#include "addeventdialog.h"
#include "ui_addeventdialog.h"
#include <QMessageBox>
AddEventDialog::AddEventDialog(QWidget *parent) :
QDialog{parent},
m_ui{std::make_unique<Ui::AddEventDialog>()}
{
m_ui->setupUi(this);
#ifdef Q_OS_LINUX
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);
#endif
setWindowFlag(Qt::WindowCloseButtonHint);
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Ok))
button->setIcon(QIcon{":/qtgameengine/icons/ok.png"});
if (auto button = m_ui->buttonBox->button(QDialogButtonBox::Cancel))
button->setIcon(QIcon{":/qtgameengine/icons/delete.png"});
connect(m_ui->pushButtonCreate, &QAbstractButton::clicked,
this, [this](){ m_eventType = Object::EventType::Create; accept(); });
connect(m_ui->pushButtonStep, &QAbstractButton::clicked,
this, [this](){ m_eventType = Object::EventType::Step; accept(); });
connect(m_ui->pushButtonDestroy, &QAbstractButton::clicked,
this, [this](){ m_eventType = Object::EventType::Destroy; accept(); });
}
AddEventDialog::~AddEventDialog() = default;
void AddEventDialog::accept()
{
if (!m_eventType)
{
QMessageBox::warning(this, tr("No Event selected!"), tr("No Event selected!"));
return;
}
QDialog::accept();
}
void AddEventDialog::reject()
{
m_eventType = std::nullopt;
QDialog::reject();
}

28
dialogs/addeventdialog.h Normal file
View File

@@ -0,0 +1,28 @@
#pragma once
#include <QDialog>
#include <optional>
#include "projectcontainer.h"
namespace Ui { class AddEventDialog; }
class AddEventDialog : public QDialog
{
Q_OBJECT
public:
explicit AddEventDialog(QWidget *parent = nullptr);
~AddEventDialog();
Object::EventType eventType() const { return *m_eventType; }
void accept() override;
void reject() override;
private:
const std::unique_ptr<Ui::AddEventDialog> m_ui;
std::optional<Object::EventType> m_eventType;
};

166
dialogs/addeventdialog.ui Normal file
View File

@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddEventDialog</class>
<widget class="QDialog" name="AddEventDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>265</width>
<height>220</height>
</rect>
</property>
<property name="windowTitle">
<string>Choose the Event to Add</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<widget class="QPushButton" name="pushButtonDraw">
<property name="text">
<string>Dra&amp;w</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButtonMouse">
<property name="text">
<string>&amp;Mouse</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="pushButtonKeyRelease">
<property name="text">
<string>Ke&amp;y Release</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pushButtonAlarm">
<property name="text">
<string>&amp;Alarm</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButtonStep">
<property name="text">
<string>&amp;Step</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/event-step.png</normaloff>:/qtgameengine/icons/event-step.png</iconset>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pushButtonCreate">
<property name="text">
<string>C&amp;reate</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/event-create.png</normaloff>:/qtgameengine/icons/event-create.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButtonOther">
<property name="text">
<string>O&amp;ther</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="pushButtonCollision">
<property name="text">
<string>C&amp;ollision</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButtonDestroy">
<property name="text">
<string>&amp;Destroy</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/event-destroy.png</normaloff>:/qtgameengine/icons/event-destroy.png</iconset>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButtonKeyPress">
<property name="text">
<string>Key &amp;Press</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="pushButtonKeyboard">
<property name="text">
<string>&amp;Keyboard</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="pushButtonTrigger">
<property name="text">
<string>&amp;Trigger</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddEventDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>132</x>
<y>196</y>
</hint>
<hint type="destinationlabel">
<x>132</x>
<y>108</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddEventDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>132</x>
<y>196</y>
</hint>
<hint type="destinationlabel">
<x>132</x>
<y>108</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -25,7 +25,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelName"> <widget class="QLabel" name="labelName">
<property name="text"> <property name="text">
<string>Name:</string> <string>&amp;Name:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>lineEditName</cstring> <cstring>lineEditName</cstring>

View File

@@ -23,7 +23,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelName"> <widget class="QLabel" name="labelName">
<property name="text"> <property name="text">
<string>Name:</string> <string>&amp;Name:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>lineEditName</cstring> <cstring>lineEditName</cstring>

View File

@@ -7,17 +7,18 @@
#include <algorithm> #include <algorithm>
#include "projectcontainer.h"
#include "projecttreemodel.h" #include "projecttreemodel.h"
#include "objecteventsmodel.h" #include "objecteventsmodel.h"
#include "objectactionsmodel.h" #include "objectactionsmodel.h"
#include "addeventdialog.h"
ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel &projectModel, QWidget *parent) : ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel &projectModel, QWidget *parent) :
QDialog{parent}, QDialog{parent},
m_ui{std::make_unique<Ui::ObjectPropertiesDialog>()}, m_ui{std::make_unique<Ui::ObjectPropertiesDialog>()},
m_object{object}, m_object{object},
m_projectModel{projectModel}, m_projectModel{projectModel},
m_eventsModel{std::make_unique<ObjectEventsModel>()}, m_events{m_object.events},
m_eventsModel{std::make_unique<ObjectEventsModel>(m_events)},
m_actionsModel{std::make_unique<ObjectActionsModel>()}, m_actionsModel{std::make_unique<ObjectActionsModel>()},
m_spritesMenu{new QMenu{m_ui->toolButtonSprite}}, m_spritesMenu{new QMenu{m_ui->toolButtonSprite}},
m_spriteName{object.spriteName} m_spriteName{object.spriteName}
@@ -106,6 +107,7 @@ void ObjectPropertiesDialog::accept()
m_object.solid = m_ui->checkBoxSolid->isChecked(); m_object.solid = m_ui->checkBoxSolid->isChecked();
m_object.depth = m_ui->spinBoxDepth->value(); m_object.depth = m_ui->spinBoxDepth->value();
m_object.persistent = m_ui->checkBoxPersistent->isChecked(); m_object.persistent = m_ui->checkBoxPersistent->isChecked();
m_object.events = std::move(m_events);
QDialog::accept(); QDialog::accept();
} }
@@ -157,7 +159,17 @@ void ObjectPropertiesDialog::showInformation()
void ObjectPropertiesDialog::addEvent() void ObjectPropertiesDialog::addEvent()
{ {
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented")); AddEventDialog dialog{this};
if (dialog.exec() == QDialog::Accepted)
{
if (!m_events.contains(dialog.eventType()))
{
m_eventsModel->beginResetModel();
m_events[dialog.eventType()];
m_eventsModel->endResetModel();
m_unsavedChanges = true;
}
}
} }
void ObjectPropertiesDialog::deleteEvent() void ObjectPropertiesDialog::deleteEvent()

View File

@@ -3,14 +3,15 @@
#include <QDialog> #include <QDialog>
#include <memory> #include <memory>
#include <map>
#include "projectcontainer.h"
class QMenu; class QMenu;
namespace Ui { class ObjectPropertiesDialog; } namespace Ui { class ObjectPropertiesDialog; }
struct Object;
class ProjectTreeModel; class ProjectTreeModel;
class ObjectEventsModel; class ObjectEventsModel;
class ObjectActionsModel; class ObjectActionsModel;
class Sprite;
class ObjectPropertiesDialog : public QDialog class ObjectPropertiesDialog : public QDialog
{ {
@@ -48,6 +49,8 @@ private:
Object &m_object; Object &m_object;
ProjectTreeModel &m_projectModel; ProjectTreeModel &m_projectModel;
std::map<Object::EventType, QString> m_events;
const std::unique_ptr<ObjectEventsModel> m_eventsModel; const std::unique_ptr<ObjectEventsModel> m_eventsModel;
const std::unique_ptr<ObjectActionsModel> m_actionsModel; const std::unique_ptr<ObjectActionsModel> m_actionsModel;

View File

@@ -25,7 +25,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelName"> <widget class="QLabel" name="labelName">
<property name="text"> <property name="text">
<string>Name:</string> <string>&amp;Name:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>lineEditName</cstring> <cstring>lineEditName</cstring>

View File

@@ -114,18 +114,18 @@
<number>10</number> <number>10</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QFormLayout" name="formLayout_3">
<item> <item row="0" column="0">
<widget class="QLabel" name="labelName"> <widget class="QLabel" name="labelName">
<property name="text"> <property name="text">
<string>Name:</string> <string>&amp;Name:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>lineEditName</cstring> <cstring>lineEditName</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QLineEdit" name="lineEditName"> <widget class="QLineEdit" name="lineEditName">
<property name="toolTip"> <property name="toolTip">
<string>The name of the path</string> <string>The name of the path</string>
@@ -189,7 +189,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelX"> <widget class="QLabel" name="labelX">
<property name="text"> <property name="text">
<string>X:</string> <string>&amp;X:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>spinBoxX</cstring> <cstring>spinBoxX</cstring>
@@ -209,7 +209,7 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelY"> <widget class="QLabel" name="labelY">
<property name="text"> <property name="text">
<string>Y:</string> <string>&amp;Y:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>spinBoxY</cstring> <cstring>spinBoxY</cstring>
@@ -229,7 +229,7 @@
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="labelSp"> <widget class="QLabel" name="labelSp">
<property name="text"> <property name="text">
<string>sp:</string> <string>s&amp;p:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>spinBoxSp</cstring> <cstring>spinBoxSp</cstring>
@@ -269,7 +269,7 @@
<string>Add the point to the path</string> <string>Add the point to the path</string>
</property> </property>
<property name="text"> <property name="text">
<string>Add</string> <string>&amp;Add</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -279,7 +279,7 @@
<string>Insert the point before the current one</string> <string>Insert the point before the current one</string>
</property> </property>
<property name="text"> <property name="text">
<string>Insert</string> <string>&amp;Insert</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -289,7 +289,7 @@
<string>Delete the point from the path</string> <string>Delete the point from the path</string>
</property> </property>
<property name="text"> <property name="text">
<string>Delete</string> <string>&amp;Delete</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -329,14 +329,14 @@
<item> <item>
<widget class="QRadioButton" name="radioButtonStraight"> <widget class="QRadioButton" name="radioButtonStraight">
<property name="text"> <property name="text">
<string>Straight lines</string> <string>&amp;Straight lines</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButtonSmooth"> <widget class="QRadioButton" name="radioButtonSmooth">
<property name="text"> <property name="text">
<string>Smooth curves</string> <string>S&amp;mooth curves</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -348,7 +348,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelPrecision"> <widget class="QLabel" name="labelPrecision">
<property name="text"> <property name="text">
<string>Precision:</string> <string>P&amp;recision:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>spinBoxPrecision</cstring> <cstring>spinBoxPrecision</cstring>

View File

@@ -16,7 +16,7 @@ ScriptPropertiesDialog::ScriptPropertiesDialog(Script &script, ProjectTreeModel
m_lineEditName{new QLineEdit{this}} m_lineEditName{new QLineEdit{this}}
{ {
{ {
auto label = new QLabel{tr("Name:"), this}; auto label = new QLabel{tr("&Name:"), this};
label->setBuddy(m_lineEditName); label->setBuddy(m_lineEditName);
addToolbarWidget(label); addToolbarWidget(label);
} }

View File

@@ -23,7 +23,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelName"> <widget class="QLabel" name="labelName">
<property name="text"> <property name="text">
<string>Name:</string> <string>&amp;Name:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>lineEditName</cstring> <cstring>lineEditName</cstring>

View File

@@ -25,7 +25,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelName"> <widget class="QLabel" name="labelName">
<property name="text"> <property name="text">
<string>Name:</string> <string>&amp;Name:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>lineEditName</cstring> <cstring>lineEditName</cstring>
@@ -153,7 +153,7 @@
<item> <item>
<widget class="QLabel" name="labelOriginX"> <widget class="QLabel" name="labelOriginX">
<property name="text"> <property name="text">
<string>X:</string> <string>&amp;X:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -173,7 +173,7 @@
<item> <item>
<widget class="QLabel" name="labelOriginY"> <widget class="QLabel" name="labelOriginY">
<property name="text"> <property name="text">
<string>Y:</string> <string>&amp;Y:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>

View File

@@ -23,7 +23,7 @@
<item> <item>
<widget class="QLabel" name="labelName"> <widget class="QLabel" name="labelName">
<property name="text"> <property name="text">
<string>Name:</string> <string>&amp;Name:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>lineEditName</cstring> <cstring>lineEditName</cstring>

BIN
icons/event-create.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
icons/event-destroy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

BIN
icons/event-step.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,19 +1,58 @@
#include "objecteventsmodel.h" #include "objecteventsmodel.h"
ObjectEventsModel::ObjectEventsModel(QObject *parent) : #include <QDebug>
QAbstractListModel{parent} #include <QIcon>
#include "futurecpp.h"
ObjectEventsModel::ObjectEventsModel(std::map<Object::EventType, QString> &events, QObject *parent) :
QAbstractListModel{parent},
m_events{events}
{ {
} }
int ObjectEventsModel::rowCount(const QModelIndex &parent) const int ObjectEventsModel::rowCount(const QModelIndex &parent) const
{ {
Q_UNUSED(parent) Q_UNUSED(parent)
return 0; return m_events.size();
} }
QVariant ObjectEventsModel::data(const QModelIndex &index, int role) const QVariant ObjectEventsModel::data(const QModelIndex &index, int role) const
{ {
Q_UNUSED(index) Q_UNUSED(index)
Q_UNUSED(role)
if (index.row() < 0 || index.row() >= m_events.size())
{
qWarning() << "row out of bounds" << index.row();
return {};
}
const auto &pair = *std::next(std::cbegin(m_events), index.row());
switch (role)
{
case Qt::DisplayRole:
case Qt::EditRole:
switch (pair.first)
{
case Object::EventType::Create: return tr("Create");
case Object::EventType::Step: return tr("Step");
case Object::EventType::Destroy: return tr("Destroy");
default:
qWarning() << "unknown event type" << std::to_underlying(pair.first);
return QString::number(std::to_underlying(pair.first));
}
case Qt::DecorationRole:
switch (pair.first)
{
case Object::EventType::Create: return QIcon{":/qtgameengine/icons/event-create.png"};
case Object::EventType::Step: return QIcon{":/qtgameengine/icons/event-step.png"};
case Object::EventType::Destroy: return QIcon{":/qtgameengine/icons/event-destroy.png"};
default:
qWarning() << "unknown event type" << std::to_underlying(pair.first);
return {};
}
}
return {}; return {};
} }

View File

@@ -2,13 +2,23 @@
#include <QAbstractListModel> #include <QAbstractListModel>
#include <map>
#include "projectcontainer.h"
class ObjectEventsModel : public QAbstractListModel class ObjectEventsModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ObjectEventsModel(QObject *parent = nullptr); explicit ObjectEventsModel(std::map<Object::EventType, QString> &events, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent) const override; int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override; QVariant data(const QModelIndex &index, int role) const override;
using QAbstractListModel::beginResetModel;
using QAbstractListModel::endResetModel;
private:
std::map<Object::EventType, QString> &m_events;
}; };

View File

@@ -73,135 +73,164 @@ QDataStream &operator>>(QDataStream &ds, std::vector<T> &list)
return ds; return ds;
} }
template<typename Tkey, typename Tvalue>
QDataStream &operator<<(QDataStream &ds, const std::map<Tkey, Tvalue> &map)
{
{
int entries = map.size();
ds << entries;
}
for (auto iter = std::cbegin(map); iter != std::cend(map); iter++)
ds << iter->first << iter->second;
return ds;
}
template<typename Tkey, typename Tvalue>
QDataStream &operator>>(QDataStream &ds, std::map<Tkey, Tvalue> &map)
{
int entries;
ds >> entries;
for (int i = 0; i < entries; i++)
{
Tkey key;
Tvalue value;
ds >> key
>> value;
map[std::move(key)] = std::move(value);
}
return ds;
}
QDataStream &operator<<(QDataStream &ds, const Sprite &sprite) QDataStream &operator<<(QDataStream &ds, const Sprite &sprite)
{ {
ds << sprite.name; ds << sprite.name
ds << sprite.pixmaps; << sprite.pixmaps
ds << sprite.origin.x; << sprite.origin.x
ds << sprite.origin.y; << sprite.origin.y
ds << sprite.preciseCollisionChecking; << sprite.preciseCollisionChecking
ds << sprite.separateCollisionMasks; << sprite.separateCollisionMasks;
return ds; return ds;
} }
QDataStream &operator>>(QDataStream &ds, Sprite &sprite) QDataStream &operator>>(QDataStream &ds, Sprite &sprite)
{ {
ds >> sprite.name; ds >> sprite.name
ds >> sprite.pixmaps; >> sprite.pixmaps
ds >> sprite.origin.x; >> sprite.origin.x
ds >> sprite.origin.y; >> sprite.origin.y
ds >> sprite.preciseCollisionChecking; >> sprite.preciseCollisionChecking
ds >> sprite.separateCollisionMasks; >> sprite.separateCollisionMasks;
return ds; return ds;
} }
QDataStream &operator<<(QDataStream &ds, const Sound &sound) QDataStream &operator<<(QDataStream &ds, const Sound &sound)
{ {
ds << sound.name; ds << sound.name
ds << sound.type; << sound.type
ds << sound.path; << sound.path
ds << sound.effects.chorus; << sound.effects.chorus
ds << sound.effects.flanger; << sound.effects.flanger
ds << sound.effects.gargle; << sound.effects.gargle
ds << sound.effects.echo; << sound.effects.echo
ds << sound.effects.reverb; << sound.effects.reverb
ds << sound.volume; << sound.volume
ds << sound.pan; << sound.pan
ds << sound.preload; << sound.preload;
return ds; return ds;
} }
QDataStream &operator>>(QDataStream &ds, Sound &sound) QDataStream &operator>>(QDataStream &ds, Sound &sound)
{ {
ds >> sound.name; ds >> sound.name
ds >> sound.type; >> sound.type
ds >> sound.path; >> sound.path
ds >> sound.effects.chorus; >> sound.effects.chorus
ds >> sound.effects.flanger; >> sound.effects.flanger
ds >> sound.effects.gargle; >> sound.effects.gargle
ds >> sound.effects.echo; >> sound.effects.echo
ds >> sound.effects.reverb; >> sound.effects.reverb
ds >> sound.volume; >> sound.volume
ds >> sound.pan; >> sound.pan
ds >> sound.preload; >> sound.preload;
return ds; return ds;
} }
QDataStream &operator<<(QDataStream &ds, const Background &background) QDataStream &operator<<(QDataStream &ds, const Background &background)
{ {
ds << background.name; ds << background.name
ds << background.pixmap; << background.pixmap
ds << background.tileset; << background.tileset;
return ds; return ds;
} }
QDataStream &operator>>(QDataStream &ds, Background &background) QDataStream &operator>>(QDataStream &ds, Background &background)
{ {
ds >> background.name; ds >> background.name
ds >> background.pixmap; >> background.pixmap
ds >> background.tileset; >> background.tileset;
return ds; return ds;
} }
QDataStream &operator<<(QDataStream &ds, const Path::Point &point) QDataStream &operator<<(QDataStream &ds, const Path::Point &point)
{ {
ds << point.point; ds << point.point
ds << point.sp; << point.sp;
return ds; return ds;
} }
QDataStream &operator>>(QDataStream &ds, Path::Point &point) QDataStream &operator>>(QDataStream &ds, Path::Point &point)
{ {
ds >> point.point; ds >> point.point
ds >> point.sp; >> point.sp;
return ds; return ds;
} }
QDataStream &operator<<(QDataStream &ds, const Path &path) QDataStream &operator<<(QDataStream &ds, const Path &path)
{ {
ds << path.name; ds << path.name
ds << path.points; << path.points
ds << path.type; << path.type
ds << path.closed; << path.closed
ds << path.precision; << path.precision;
return ds; return ds;
} }
QDataStream &operator>>(QDataStream &ds, Path &path) QDataStream &operator>>(QDataStream &ds, Path &path)
{ {
ds >> path.name; ds >> path.name
ds >> path.points; >> path.points
ds >> path.type; >> path.type
ds >> path.closed; >> path.closed
ds >> path.precision; >> path.precision;
return ds; return ds;
} }
QDataStream &operator<<(QDataStream &ds, const Script &script) QDataStream &operator<<(QDataStream &ds, const Script &script)
{ {
ds << script.name; ds << script.name
ds << script.script; << script.script;
return ds; return ds;
} }
QDataStream &operator>>(QDataStream &ds, Script &script) QDataStream &operator>>(QDataStream &ds, Script &script)
{ {
ds >> script.name; ds >> script.name
ds >> script.script; >> script.script;
return ds; return ds;
} }
QDataStream &operator<<(QDataStream &ds, const Font &font) QDataStream &operator<<(QDataStream &ds, const Font &font)
{ {
ds << font.name; ds << font.name
ds << font.font; << font.font;
return ds; return ds;
} }
QDataStream &operator>>(QDataStream &ds, Font &font) QDataStream &operator>>(QDataStream &ds, Font &font)
{ {
ds >> font.name; ds >> font.name
ds >> font.font; >> font.font;
return ds; return ds;
} }
@@ -219,23 +248,25 @@ QDataStream &operator>>(QDataStream &ds, TimeLine &timeLine)
QDataStream &operator<<(QDataStream &ds, const Object &object) QDataStream &operator<<(QDataStream &ds, const Object &object)
{ {
ds << object.name; ds << object.name
ds << object.spriteName; << object.spriteName
ds << object.visible; << object.visible
ds << object.solid; << object.solid
ds << object.depth; << object.depth
ds << object.persistent; << object.persistent
<< object.events;
return ds; return ds;
} }
QDataStream &operator>>(QDataStream &ds, Object &object) QDataStream &operator>>(QDataStream &ds, Object &object)
{ {
ds >> object.name; ds >> object.name
ds >> object.spriteName; >> object.spriteName
ds >> object.visible; >> object.visible
ds >> object.solid; >> object.solid
ds >> object.depth; >> object.depth
ds >> object.persistent; >> object.persistent
>> object.events;
return ds; return ds;
} }
@@ -253,29 +284,29 @@ QDataStream &operator>>(QDataStream &ds, Room &room)
QDataStream &operator<<(QDataStream &ds, const ProjectContainer &project) QDataStream &operator<<(QDataStream &ds, const ProjectContainer &project)
{ {
ds << project.sprites; ds << project.sprites
ds << project.sounds; << project.sounds
ds << project.backgrounds; << project.backgrounds
ds << project.paths; << project.paths
ds << project.scripts; << project.scripts
ds << project.fonts; << project.fonts
ds << project.timeLines; << project.timeLines
ds << project.objects; << project.objects
ds << project.rooms; << project.rooms;
return ds; return ds;
} }
QDataStream &operator>>(QDataStream &ds, ProjectContainer &project) QDataStream &operator>>(QDataStream &ds, ProjectContainer &project)
{ {
ds >> project.sprites; ds >> project.sprites
ds >> project.sounds; >> project.sounds
ds >> project.backgrounds; >> project.backgrounds
ds >> project.paths; >> project.paths
ds >> project.scripts; >> project.scripts
ds >> project.fonts; >> project.fonts
ds >> project.timeLines; >> project.timeLines
ds >> project.objects; >> project.objects
ds >> project.rooms; >> project.rooms;
return ds; return ds;
} }

View File

@@ -84,12 +84,19 @@ struct TimeLine
struct Object struct Object
{ {
enum class EventType {
Create,
Step,
Destroy
};
QString name; QString name;
QString spriteName; QString spriteName;
bool visible{true}; bool visible{true};
bool solid{}; bool solid{};
int depth{}; int depth{};
bool persistent{}; bool persistent{};
std::map<EventType, QString> events;
}; };
struct Room struct Room

View File

@@ -76,5 +76,8 @@
<file>icons/info.png</file> <file>icons/info.png</file>
<file>icons/merge.png</file> <file>icons/merge.png</file>
<file>icons/sort.png</file> <file>icons/sort.png</file>
<file>icons/event-create.png</file>
<file>icons/event-destroy.png</file>
<file>icons/event-step.png</file>
</qresource> </qresource>
</RCC> </RCC>