Added dialog to add events to object
This commit is contained in:
@ -11,6 +11,7 @@ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
|
||||
HEADERS += \
|
||||
codeeditorwidget.h \
|
||||
constantsmodel.h \
|
||||
dialogs/addeventdialog.h \
|
||||
dialogs/codeeditordialog.h \
|
||||
dialogs/createspritedialog.h \
|
||||
dialogs/fontpropertiesdialog.h \
|
||||
@ -54,6 +55,7 @@ HEADERS += \
|
||||
SOURCES += main.cpp \
|
||||
codeeditorwidget.cpp \
|
||||
constantsmodel.cpp \
|
||||
dialogs/addeventdialog.cpp \
|
||||
dialogs/codeeditordialog.cpp \
|
||||
dialogs/createspritedialog.cpp \
|
||||
dialogs/fontpropertiesdialog.cpp \
|
||||
@ -94,6 +96,7 @@ SOURCES += main.cpp \
|
||||
triggersmodel.cpp
|
||||
|
||||
FORMS += \
|
||||
dialogs/addeventdialog.ui \
|
||||
dialogs/codeeditordialog.ui \
|
||||
dialogs/createspritedialog.ui \
|
||||
dialogs/fontpropertiesdialog.ui \
|
||||
|
48
dialogs/addeventdialog.cpp
Normal file
48
dialogs/addeventdialog.cpp
Normal 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
28
dialogs/addeventdialog.h
Normal 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
166
dialogs/addeventdialog.ui
Normal 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&w</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButtonMouse">
|
||||
<property name="text">
|
||||
<string>&Mouse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="pushButtonKeyRelease">
|
||||
<property name="text">
|
||||
<string>Ke&y Release</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="pushButtonAlarm">
|
||||
<property name="text">
|
||||
<string>&Alarm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="pushButtonStep">
|
||||
<property name="text">
|
||||
<string>&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&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&ther</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="pushButtonCollision">
|
||||
<property name="text">
|
||||
<string>C&ollision</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButtonDestroy">
|
||||
<property name="text">
|
||||
<string>&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 &Press</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QPushButton" name="pushButtonKeyboard">
|
||||
<property name="text">
|
||||
<string>&Keyboard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="pushButtonTrigger">
|
||||
<property name="text">
|
||||
<string>&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>
|
@ -25,7 +25,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelName">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditName</cstring>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelName">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditName</cstring>
|
||||
|
@ -7,17 +7,18 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "projectcontainer.h"
|
||||
#include "projecttreemodel.h"
|
||||
#include "objecteventsmodel.h"
|
||||
#include "objectactionsmodel.h"
|
||||
#include "addeventdialog.h"
|
||||
|
||||
ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel &projectModel, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::ObjectPropertiesDialog>()},
|
||||
m_object{object},
|
||||
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_spritesMenu{new QMenu{m_ui->toolButtonSprite}},
|
||||
m_spriteName{object.spriteName}
|
||||
@ -106,6 +107,7 @@ void ObjectPropertiesDialog::accept()
|
||||
m_object.solid = m_ui->checkBoxSolid->isChecked();
|
||||
m_object.depth = m_ui->spinBoxDepth->value();
|
||||
m_object.persistent = m_ui->checkBoxPersistent->isChecked();
|
||||
m_object.events = std::move(m_events);
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
@ -157,7 +159,17 @@ void ObjectPropertiesDialog::showInformation()
|
||||
|
||||
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()
|
||||
|
@ -3,14 +3,15 @@
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
#include "projectcontainer.h"
|
||||
|
||||
class QMenu;
|
||||
namespace Ui { class ObjectPropertiesDialog; }
|
||||
struct Object;
|
||||
class ProjectTreeModel;
|
||||
class ObjectEventsModel;
|
||||
class ObjectActionsModel;
|
||||
class Sprite;
|
||||
|
||||
class ObjectPropertiesDialog : public QDialog
|
||||
{
|
||||
@ -48,6 +49,8 @@ private:
|
||||
Object &m_object;
|
||||
ProjectTreeModel &m_projectModel;
|
||||
|
||||
std::map<Object::EventType, QString> m_events;
|
||||
|
||||
const std::unique_ptr<ObjectEventsModel> m_eventsModel;
|
||||
const std::unique_ptr<ObjectActionsModel> m_actionsModel;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelName">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditName</cstring>
|
||||
|
@ -114,18 +114,18 @@
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelName">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEditName">
|
||||
<property name="toolTip">
|
||||
<string>The name of the path</string>
|
||||
@ -189,7 +189,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelX">
|
||||
<property name="text">
|
||||
<string>X:</string>
|
||||
<string>&X:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxX</cstring>
|
||||
@ -209,7 +209,7 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelY">
|
||||
<property name="text">
|
||||
<string>Y:</string>
|
||||
<string>&Y:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxY</cstring>
|
||||
@ -229,7 +229,7 @@
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelSp">
|
||||
<property name="text">
|
||||
<string>sp:</string>
|
||||
<string>s&p:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxSp</cstring>
|
||||
@ -269,7 +269,7 @@
|
||||
<string>Add the point to the path</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
<string>&Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -279,7 +279,7 @@
|
||||
<string>Insert the point before the current one</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Insert</string>
|
||||
<string>&Insert</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -289,7 +289,7 @@
|
||||
<string>Delete the point from the path</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
<string>&Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -329,14 +329,14 @@
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonStraight">
|
||||
<property name="text">
|
||||
<string>Straight lines</string>
|
||||
<string>&Straight lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonSmooth">
|
||||
<property name="text">
|
||||
<string>Smooth curves</string>
|
||||
<string>S&mooth curves</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -348,7 +348,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelPrecision">
|
||||
<property name="text">
|
||||
<string>Precision:</string>
|
||||
<string>P&recision:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinBoxPrecision</cstring>
|
||||
|
@ -16,7 +16,7 @@ ScriptPropertiesDialog::ScriptPropertiesDialog(Script &script, ProjectTreeModel
|
||||
m_lineEditName{new QLineEdit{this}}
|
||||
{
|
||||
{
|
||||
auto label = new QLabel{tr("Name:"), this};
|
||||
auto label = new QLabel{tr("&Name:"), this};
|
||||
label->setBuddy(m_lineEditName);
|
||||
addToolbarWidget(label);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelName">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditName</cstring>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelName">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditName</cstring>
|
||||
@ -153,7 +153,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginX">
|
||||
<property name="text">
|
||||
<string>X:</string>
|
||||
<string>&X:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -173,7 +173,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="labelOriginY">
|
||||
<property name="text">
|
||||
<string>Y:</string>
|
||||
<string>&Y:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="labelName">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lineEditName</cstring>
|
||||
|
BIN
icons/event-create.png
Normal file
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
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
BIN
icons/event-step.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -1,19 +1,58 @@
|
||||
#include "objecteventsmodel.h"
|
||||
|
||||
ObjectEventsModel::ObjectEventsModel(QObject *parent) :
|
||||
QAbstractListModel{parent}
|
||||
#include <QDebug>
|
||||
#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
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 0;
|
||||
return m_events.size();
|
||||
}
|
||||
|
||||
QVariant ObjectEventsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
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 {};
|
||||
}
|
||||
|
@ -2,13 +2,23 @@
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "projectcontainer.h"
|
||||
|
||||
class ObjectEventsModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ObjectEventsModel(QObject *parent = nullptr);
|
||||
explicit ObjectEventsModel(std::map<Object::EventType, QString> &events, QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent) 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;
|
||||
};
|
||||
|
@ -73,135 +73,164 @@ QDataStream &operator>>(QDataStream &ds, std::vector<T> &list)
|
||||
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)
|
||||
{
|
||||
ds << sprite.name;
|
||||
ds << sprite.pixmaps;
|
||||
ds << sprite.origin.x;
|
||||
ds << sprite.origin.y;
|
||||
ds << sprite.preciseCollisionChecking;
|
||||
ds << sprite.separateCollisionMasks;
|
||||
ds << sprite.name
|
||||
<< sprite.pixmaps
|
||||
<< sprite.origin.x
|
||||
<< sprite.origin.y
|
||||
<< sprite.preciseCollisionChecking
|
||||
<< sprite.separateCollisionMasks;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Sprite &sprite)
|
||||
{
|
||||
ds >> sprite.name;
|
||||
ds >> sprite.pixmaps;
|
||||
ds >> sprite.origin.x;
|
||||
ds >> sprite.origin.y;
|
||||
ds >> sprite.preciseCollisionChecking;
|
||||
ds >> sprite.separateCollisionMasks;
|
||||
ds >> sprite.name
|
||||
>> sprite.pixmaps
|
||||
>> sprite.origin.x
|
||||
>> sprite.origin.y
|
||||
>> sprite.preciseCollisionChecking
|
||||
>> sprite.separateCollisionMasks;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Sound &sound)
|
||||
{
|
||||
ds << sound.name;
|
||||
ds << sound.type;
|
||||
ds << sound.path;
|
||||
ds << sound.effects.chorus;
|
||||
ds << sound.effects.flanger;
|
||||
ds << sound.effects.gargle;
|
||||
ds << sound.effects.echo;
|
||||
ds << sound.effects.reverb;
|
||||
ds << sound.volume;
|
||||
ds << sound.pan;
|
||||
ds << sound.preload;
|
||||
ds << sound.name
|
||||
<< sound.type
|
||||
<< sound.path
|
||||
<< sound.effects.chorus
|
||||
<< sound.effects.flanger
|
||||
<< sound.effects.gargle
|
||||
<< sound.effects.echo
|
||||
<< sound.effects.reverb
|
||||
<< sound.volume
|
||||
<< sound.pan
|
||||
<< sound.preload;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Sound &sound)
|
||||
{
|
||||
ds >> sound.name;
|
||||
ds >> sound.type;
|
||||
ds >> sound.path;
|
||||
ds >> sound.effects.chorus;
|
||||
ds >> sound.effects.flanger;
|
||||
ds >> sound.effects.gargle;
|
||||
ds >> sound.effects.echo;
|
||||
ds >> sound.effects.reverb;
|
||||
ds >> sound.volume;
|
||||
ds >> sound.pan;
|
||||
ds >> sound.preload;
|
||||
ds >> sound.name
|
||||
>> sound.type
|
||||
>> sound.path
|
||||
>> sound.effects.chorus
|
||||
>> sound.effects.flanger
|
||||
>> sound.effects.gargle
|
||||
>> sound.effects.echo
|
||||
>> sound.effects.reverb
|
||||
>> sound.volume
|
||||
>> sound.pan
|
||||
>> sound.preload;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Background &background)
|
||||
{
|
||||
ds << background.name;
|
||||
ds << background.pixmap;
|
||||
ds << background.tileset;
|
||||
ds << background.name
|
||||
<< background.pixmap
|
||||
<< background.tileset;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Background &background)
|
||||
{
|
||||
ds >> background.name;
|
||||
ds >> background.pixmap;
|
||||
ds >> background.tileset;
|
||||
ds >> background.name
|
||||
>> background.pixmap
|
||||
>> background.tileset;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Path::Point &point)
|
||||
{
|
||||
ds << point.point;
|
||||
ds << point.sp;
|
||||
ds << point.point
|
||||
<< point.sp;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Path::Point &point)
|
||||
{
|
||||
ds >> point.point;
|
||||
ds >> point.sp;
|
||||
ds >> point.point
|
||||
>> point.sp;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Path &path)
|
||||
{
|
||||
ds << path.name;
|
||||
ds << path.points;
|
||||
ds << path.type;
|
||||
ds << path.closed;
|
||||
ds << path.precision;
|
||||
ds << path.name
|
||||
<< path.points
|
||||
<< path.type
|
||||
<< path.closed
|
||||
<< path.precision;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Path &path)
|
||||
{
|
||||
ds >> path.name;
|
||||
ds >> path.points;
|
||||
ds >> path.type;
|
||||
ds >> path.closed;
|
||||
ds >> path.precision;
|
||||
ds >> path.name
|
||||
>> path.points
|
||||
>> path.type
|
||||
>> path.closed
|
||||
>> path.precision;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Script &script)
|
||||
{
|
||||
ds << script.name;
|
||||
ds << script.script;
|
||||
ds << script.name
|
||||
<< script.script;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Script &script)
|
||||
{
|
||||
ds >> script.name;
|
||||
ds >> script.script;
|
||||
ds >> script.name
|
||||
>> script.script;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Font &font)
|
||||
{
|
||||
ds << font.name;
|
||||
ds << font.font;
|
||||
ds << font.name
|
||||
<< font.font;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Font &font)
|
||||
{
|
||||
ds >> font.name;
|
||||
ds >> font.font;
|
||||
ds >> font.name
|
||||
>> font.font;
|
||||
return ds;
|
||||
}
|
||||
|
||||
@ -219,23 +248,25 @@ QDataStream &operator>>(QDataStream &ds, TimeLine &timeLine)
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Object &object)
|
||||
{
|
||||
ds << object.name;
|
||||
ds << object.spriteName;
|
||||
ds << object.visible;
|
||||
ds << object.solid;
|
||||
ds << object.depth;
|
||||
ds << object.persistent;
|
||||
ds << object.name
|
||||
<< object.spriteName
|
||||
<< object.visible
|
||||
<< object.solid
|
||||
<< object.depth
|
||||
<< object.persistent
|
||||
<< object.events;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Object &object)
|
||||
{
|
||||
ds >> object.name;
|
||||
ds >> object.spriteName;
|
||||
ds >> object.visible;
|
||||
ds >> object.solid;
|
||||
ds >> object.depth;
|
||||
ds >> object.persistent;
|
||||
ds >> object.name
|
||||
>> object.spriteName
|
||||
>> object.visible
|
||||
>> object.solid
|
||||
>> object.depth
|
||||
>> object.persistent
|
||||
>> object.events;
|
||||
return ds;
|
||||
}
|
||||
|
||||
@ -253,29 +284,29 @@ QDataStream &operator>>(QDataStream &ds, Room &room)
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const ProjectContainer &project)
|
||||
{
|
||||
ds << project.sprites;
|
||||
ds << project.sounds;
|
||||
ds << project.backgrounds;
|
||||
ds << project.paths;
|
||||
ds << project.scripts;
|
||||
ds << project.fonts;
|
||||
ds << project.timeLines;
|
||||
ds << project.objects;
|
||||
ds << project.rooms;
|
||||
ds << project.sprites
|
||||
<< project.sounds
|
||||
<< project.backgrounds
|
||||
<< project.paths
|
||||
<< project.scripts
|
||||
<< project.fonts
|
||||
<< project.timeLines
|
||||
<< project.objects
|
||||
<< project.rooms;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, ProjectContainer &project)
|
||||
{
|
||||
ds >> project.sprites;
|
||||
ds >> project.sounds;
|
||||
ds >> project.backgrounds;
|
||||
ds >> project.paths;
|
||||
ds >> project.scripts;
|
||||
ds >> project.fonts;
|
||||
ds >> project.timeLines;
|
||||
ds >> project.objects;
|
||||
ds >> project.rooms;
|
||||
ds >> project.sprites
|
||||
>> project.sounds
|
||||
>> project.backgrounds
|
||||
>> project.paths
|
||||
>> project.scripts
|
||||
>> project.fonts
|
||||
>> project.timeLines
|
||||
>> project.objects
|
||||
>> project.rooms;
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
@ -84,12 +84,19 @@ struct TimeLine
|
||||
|
||||
struct Object
|
||||
{
|
||||
enum class EventType {
|
||||
Create,
|
||||
Step,
|
||||
Destroy
|
||||
};
|
||||
|
||||
QString name;
|
||||
QString spriteName;
|
||||
bool visible{true};
|
||||
bool solid{};
|
||||
int depth{};
|
||||
bool persistent{};
|
||||
std::map<EventType, QString> events;
|
||||
};
|
||||
|
||||
struct Room
|
||||
|
@ -76,5 +76,8 @@
|
||||
<file>icons/info.png</file>
|
||||
<file>icons/merge.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>
|
||||
</RCC>
|
||||
|
Reference in New Issue
Block a user