Events can now contain multiple actions, implemented draggable action icons
@@ -29,6 +29,7 @@ HEADERS += \
|
||||
src/editor/dialogs/genericcodeeditordialog.h \
|
||||
src/editor/editorguiutils.h \
|
||||
src/editor/roomscene.h \
|
||||
src/editor/widgets/actiondragwidget.h \
|
||||
src/editor/widgets/draggabletreeview.h \
|
||||
src/editor/widgets/qlineeditwithmenu.h \
|
||||
src/editor/widgets/qscrollareawithmenu.h \
|
||||
@@ -67,6 +68,7 @@ HEADERS += \
|
||||
src/editor/dialogs/timelinepropertiesdialog.h \
|
||||
src/editor/dialogs/triggersdialog.h \
|
||||
src/editor/dialogs/userdefinedconstantsdialog.h \
|
||||
src/editor/dialogs/actions/movefixeddialog.h \
|
||||
src/editor/models/actionscontainermodel.h \
|
||||
src/editor/models/constantsmodel.h \
|
||||
src/editor/models/includedfilesmodel.h \
|
||||
@@ -86,6 +88,7 @@ SOURCES += \
|
||||
src/editor/dialogs/genericcodeeditordialog.cpp \
|
||||
src/editor/editorguiutils.cpp \
|
||||
src/editor/roomscene.cpp \
|
||||
src/editor/widgets/actiondragwidget.cpp \
|
||||
src/editor/widgets/draggabletreeview.cpp \
|
||||
src/editor/widgets/qlineeditwithmenu.cpp \
|
||||
src/editor/widgets/qscrollareawithmenu.cpp \
|
||||
@@ -124,6 +127,7 @@ SOURCES += \
|
||||
src/editor/dialogs/timelinepropertiesdialog.cpp \
|
||||
src/editor/dialogs/triggersdialog.cpp \
|
||||
src/editor/dialogs/userdefinedconstantsdialog.cpp \
|
||||
src/editor/dialogs/actions/movefixeddialog.cpp \
|
||||
src/editor/models/actionscontainermodel.cpp \
|
||||
src/editor/models/constantsmodel.cpp \
|
||||
src/editor/models/includedfilesmodel.cpp \
|
||||
@@ -164,7 +168,8 @@ FORMS += \
|
||||
src/editor/dialogs/timelinepropertiesdialog.ui \
|
||||
src/editor/dialogs/triggersdialog.ui \
|
||||
src/editor/dialogs/userdefinedconstantsdialog.ui \
|
||||
src/editor/widgets/actionscontainerwidget.ui
|
||||
src/editor/widgets/actionscontainerwidget.ui\
|
||||
src/editor/dialogs/actions/movefixeddialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
src/editor/resources_editor.qrc \
|
||||
|
19
src/editor/dialogs/actions/movefixeddialog.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "movefixeddialog.h"
|
||||
#include "ui_movefixeddialog.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
MoveFixedDialog::MoveFixedDialog(MoveFixedAction &action, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::MoveFixedDialog>()},
|
||||
m_action{action}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
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"});
|
||||
}
|
||||
|
||||
MoveFixedDialog::~MoveFixedDialog() = default;
|
22
src/editor/dialogs/actions/movefixeddialog.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class MoveFixedDialog; }
|
||||
class MoveFixedAction;
|
||||
|
||||
class MoveFixedDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MoveFixedDialog(MoveFixedAction &action, QWidget *parent = nullptr);
|
||||
~MoveFixedDialog() override;
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::MoveFixedDialog> m_ui;
|
||||
|
||||
MoveFixedAction &m_action;
|
||||
};
|
302
src/editor/dialogs/actions/movefixeddialog.ui
Normal file
@@ -0,0 +1,302 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MoveFixedDialog</class>
|
||||
<widget class="QDialog" name="MoveFixedDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>435</width>
|
||||
<height>429</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Move Fixed</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1,0">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../resources_editor.qrc">:/qtgameengine/icons/action-move-fixed.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Applies to</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonSelf">
|
||||
<property name="text">
|
||||
<string>Self</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonOther">
|
||||
<property name="text">
|
||||
<string>Other</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonObject">
|
||||
<property name="text">
|
||||
<string>Object:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="2">
|
||||
<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 row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<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 row="1" column="1">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelDirections">
|
||||
<property name="text">
|
||||
<string>Directions:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/blue-arrow-up.png</normaloff>:/qtgameengine/icons/blue-arrow-up.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pushButton_6">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/blue-arrow-right.png</normaloff>:/qtgameengine/icons/blue-arrow-right.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/blue-arrow-left.png</normaloff>:/qtgameengine/icons/blue-arrow-left.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="pushButton_7">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="pushButton_8">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources_editor.qrc">
|
||||
<normaloff>:/qtgameengine/icons/blue-arrow-down.png</normaloff>:/qtgameengine/icons/blue-arrow-down.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pushButton_9">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelSpeed">
|
||||
<property name="text">
|
||||
<string>Speed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBox"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxRelative">
|
||||
<property name="text">
|
||||
<string>Relative</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../resources_editor.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>MoveFixedDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>MoveFixedDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "projectcontainer.h"
|
||||
|
||||
CodeActionDialog::CodeActionDialog(Action &action, QWidget *parent) :
|
||||
CodeActionDialog::CodeActionDialog(ExecuteCodeAction &action, QWidget *parent) :
|
||||
CodeEditorDialog{tr("Execute Code"), parent},
|
||||
m_action{action},
|
||||
m_radioButtonSelf{new QRadioButton{tr("Self"), this}},
|
||||
@@ -23,9 +23,9 @@ CodeActionDialog::CodeActionDialog(Action &action, QWidget *parent) :
|
||||
addToolbarWidget(m_radioButtonOther);
|
||||
addToolbarWidget(m_radioButtonObject);
|
||||
|
||||
m_radioButtonSelf->setChecked(m_action.appliesTo == Action::AppliesTo::Self);
|
||||
m_radioButtonOther->setChecked(m_action.appliesTo == Action::AppliesTo::Other);
|
||||
m_radioButtonObject->setChecked(m_action.appliesTo == Action::AppliesTo::Object);
|
||||
m_radioButtonSelf->setChecked(m_action.appliesTo == ExecuteCodeAction::AppliesTo::Self);
|
||||
m_radioButtonOther->setChecked(m_action.appliesTo == ExecuteCodeAction::AppliesTo::Other);
|
||||
m_radioButtonObject->setChecked(m_action.appliesTo == ExecuteCodeAction::AppliesTo::Object);
|
||||
|
||||
setScript(m_action.script);
|
||||
|
||||
@@ -46,11 +46,11 @@ void CodeActionDialog::accept()
|
||||
}
|
||||
|
||||
if (m_radioButtonSelf->isChecked())
|
||||
m_action.appliesTo = Action::AppliesTo::Self;
|
||||
m_action.appliesTo = ExecuteCodeAction::AppliesTo::Self;
|
||||
else if (m_radioButtonOther->isChecked())
|
||||
m_action.appliesTo = Action::AppliesTo::Other;
|
||||
m_action.appliesTo = ExecuteCodeAction::AppliesTo::Other;
|
||||
else if (m_radioButtonObject->isChecked())
|
||||
m_action.appliesTo = Action::AppliesTo::Object;
|
||||
m_action.appliesTo = ExecuteCodeAction::AppliesTo::Object;
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(this, tr("No Applies To selected!"), tr("No Applies To selected!"));
|
||||
|
@@ -3,19 +3,19 @@
|
||||
#include "codeeditordialog.h"
|
||||
|
||||
class QRadioButton;
|
||||
struct Action;
|
||||
struct ExecuteCodeAction;
|
||||
|
||||
class CodeActionDialog : public CodeEditorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CodeActionDialog(Action &action, QWidget *parent = nullptr);
|
||||
explicit CodeActionDialog(ExecuteCodeAction &action, QWidget *parent = nullptr);
|
||||
|
||||
void accept() override;
|
||||
|
||||
private:
|
||||
Action &m_action;
|
||||
ExecuteCodeAction &m_action;
|
||||
|
||||
QRadioButton * const m_radioButtonSelf;
|
||||
QRadioButton * const m_radioButtonOther;
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
BIN
src/editor/icons/action-move-fixed.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
src/editor/icons/action-move-free.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
src/editor/icons/action-move-towards.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
src/editor/icons/add (Kopie).png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
src/editor/icons/blue-arrow-down.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
src/editor/icons/blue-arrow-left.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
src/editor/icons/blue-arrow-right.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
src/editor/icons/blue-arrow-up.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
@@ -34,15 +34,39 @@ QVariant ActionsContainerModel::data(const QModelIndex &index, int role) const
|
||||
return {};
|
||||
}
|
||||
|
||||
//const auto &action = m_actionsContainer->at(index.row());
|
||||
const auto &action = *std::next(m_actionsContainer->cbegin(), index.row());
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
case Qt::EditRole:
|
||||
if (std::holds_alternative<MoveFixedAction>(action))
|
||||
return tr("Start moving in a direction");
|
||||
else if (std::holds_alternative<MoveFreeAction>(action))
|
||||
return tr("Set direction and speed of motion");
|
||||
else if (std::holds_alternative<MoveTowardsAction>(action))
|
||||
return tr("Move towards point (99, 99)");
|
||||
else if (std::holds_alternative<ExecuteCodeAction>(action))
|
||||
return tr("Execute a piece of code");
|
||||
else
|
||||
{
|
||||
qWarning() << "unknown action type";
|
||||
return tr("ERROR: Unknown action type");
|
||||
}
|
||||
case Qt::DecorationRole:
|
||||
return QIcon{":/qtgameengine/icons/code-action.png"};
|
||||
if (std::holds_alternative<MoveFixedAction>(action))
|
||||
return QIcon{":/qtgameengine/icons/action-move-fixed.png"};
|
||||
else if (std::holds_alternative<MoveFreeAction>(action))
|
||||
return QIcon{":/qtgameengine/icons/action-move-free.png"};
|
||||
else if (std::holds_alternative<MoveTowardsAction>(action))
|
||||
return QIcon{":/qtgameengine/icons/action-move-towards.png"};
|
||||
else if (std::holds_alternative<ExecuteCodeAction>(action))
|
||||
return QIcon{":/qtgameengine/icons/action-code.png"};
|
||||
else
|
||||
{
|
||||
qWarning() << "unknown action type";
|
||||
return QIcon{":/qtgameengine/icons/action.png"};
|
||||
}
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
@@ -50,6 +74,30 @@ QVariant ActionsContainerModel::data(const QModelIndex &index, int role) const
|
||||
return {};
|
||||
}
|
||||
|
||||
Qt::ItemFlags ActionsContainerModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
auto flags = QAbstractListModel::flags(index);
|
||||
flags |= Qt::ItemIsDragEnabled;
|
||||
flags |= Qt::ItemIsDropEnabled;
|
||||
return flags;
|
||||
}
|
||||
|
||||
Qt::DropActions ActionsContainerModel::supportedDropActions() const
|
||||
{
|
||||
auto actions = QAbstractListModel::supportedDropActions();
|
||||
actions |= Qt::MoveAction;
|
||||
actions |= Qt::TargetMoveAction;
|
||||
return actions;
|
||||
}
|
||||
|
||||
Qt::DropActions ActionsContainerModel::supportedDragActions() const
|
||||
{
|
||||
auto actions = QAbstractListModel::supportedDragActions();
|
||||
actions |= Qt::MoveAction;
|
||||
actions |= Qt::TargetMoveAction;
|
||||
return actions;
|
||||
}
|
||||
|
||||
void ActionsContainerModel::setActionsContainer(ActionsContainer *actionsContainer)
|
||||
{
|
||||
beginResetModel();
|
||||
|
@@ -15,6 +15,9 @@ public:
|
||||
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
|
||||
ActionsContainer *actionsContainer() const { return m_actionsContainer; }
|
||||
void setActionsContainer(ActionsContainer *actionsContainer);
|
||||
|
@@ -1,5 +1,11 @@
|
||||
<RCC>
|
||||
<qresource prefix="/qtgameengine">
|
||||
<file>icons/action.png</file>
|
||||
<file>icons/action-code.png</file>
|
||||
<file>icons/action-move-fixed.png</file>
|
||||
<file>icons/action-move-free.png</file>
|
||||
<file>icons/action-move-towards.png</file>
|
||||
<file>icons/add.png</file>
|
||||
<file>icons/arrow-down.png</file>
|
||||
<file>icons/arrow-left.png</file>
|
||||
<file>icons/arrow-right.png</file>
|
||||
@@ -7,7 +13,9 @@
|
||||
<file>icons/background-file.png</file>
|
||||
<file>icons/background.png</file>
|
||||
<file>icons/cascade.png</file>
|
||||
<file>icons/center.png</file>
|
||||
<file>icons/check.png</file>
|
||||
<file>icons/constants.png</file>
|
||||
<file>icons/copy.png</file>
|
||||
<file>icons/create-executable.png</file>
|
||||
<file>icons/create-group.png</file>
|
||||
@@ -17,12 +25,20 @@
|
||||
<file>icons/delete.png</file>
|
||||
<file>icons/duplicate.png</file>
|
||||
<file>icons/edit.png</file>
|
||||
<file>icons/event-alarm.png</file>
|
||||
<file>icons/event-collision.png</file>
|
||||
<file>icons/event-create.png</file>
|
||||
<file>icons/event-destroy.png</file>
|
||||
<file>icons/event-draw.png</file>
|
||||
<file>icons/event-step.png</file>
|
||||
<file>icons/exit.png</file>
|
||||
<file>icons/export-resources.png</file>
|
||||
<file>icons/extension-packages-file.png</file>
|
||||
<file>icons/extension-packages.png</file>
|
||||
<file>icons/file.png</file>
|
||||
<file>icons/find.png</file>
|
||||
<file>icons/flip-horizontal.png</file>
|
||||
<file>icons/flip-vertical.png</file>
|
||||
<file>icons/folder.png</file>
|
||||
<file>icons/font-file.png</file>
|
||||
<file>icons/font.png</file>
|
||||
@@ -30,11 +46,17 @@
|
||||
<file>icons/game-information.png</file>
|
||||
<file>icons/global-game-settings-file.png</file>
|
||||
<file>icons/global-game-settings.png</file>
|
||||
<file>icons/grid.png</file>
|
||||
<file>icons/help.png</file>
|
||||
<file>icons/import-resources.png</file>
|
||||
<file>icons/info.png</file>
|
||||
<file>icons/isometric.png</file>
|
||||
<file>icons/lock.png</file>
|
||||
<file>icons/merge.png</file>
|
||||
<file>icons/move.png</file>
|
||||
<file>icons/music-file.png</file>
|
||||
<file>icons/new.png</file>
|
||||
<file>icons/object-file.png</file>
|
||||
<file>icons/object.png</file>
|
||||
<file>icons/ok.png</file>
|
||||
<file>icons/open.png</file>
|
||||
@@ -47,47 +69,32 @@
|
||||
<file>icons/publish-game.png</file>
|
||||
<file>icons/redo.png</file>
|
||||
<file>icons/rename.png</file>
|
||||
<file>icons/replace.png</file>
|
||||
<file>icons/room-file.png</file>
|
||||
<file>icons/room.png</file>
|
||||
<file>icons/rotate.png</file>
|
||||
<file>icons/run.png</file>
|
||||
<file>icons/save-as.png</file>
|
||||
<file>icons/save.png</file>
|
||||
<file>icons/scale.png</file>
|
||||
<file>icons/script-file.png</file>
|
||||
<file>icons/script.png</file>
|
||||
<file>icons/sort-x.png</file>
|
||||
<file>icons/sort-y.png</file>
|
||||
<file>icons/sort.png</file>
|
||||
<file>icons/sound-file.png</file>
|
||||
<file>icons/sound-file2.png</file>
|
||||
<file>icons/sound.png</file>
|
||||
<file>icons/sprite-file.png</file>
|
||||
<file>icons/sprite.png</file>
|
||||
<file>icons/tile.png</file>
|
||||
<file>icons/timeline-file.png</file>
|
||||
<file>icons/timeline.png</file>
|
||||
<file>icons/undo.png</file>
|
||||
<file>icons/object-file.png</file>
|
||||
<file>icons/room-file.png</file>
|
||||
<file>icons/timeline-file.png</file>
|
||||
<file>icons/flip-horizontal.png</file>
|
||||
<file>icons/flip-vertical.png</file>
|
||||
<file>icons/scale.png</file>
|
||||
<file>icons/center.png</file>
|
||||
<file>icons/grid.png</file>
|
||||
<file>icons/constants.png</file>
|
||||
<file>icons/add.png</file>
|
||||
<file>icons/replace.png</file>
|
||||
<file>icons/info.png</file>
|
||||
<file>icons/merge.png</file>
|
||||
<file>icons/sort.png</file>
|
||||
<file>icons/event-alarm.png</file>
|
||||
<file>icons/event-collision.png</file>
|
||||
<file>icons/event-create.png</file>
|
||||
<file>icons/event-destroy.png</file>
|
||||
<file>icons/event-step.png</file>
|
||||
<file>icons/action.png</file>
|
||||
<file>icons/code-action.png</file>
|
||||
<file>icons/event-draw.png</file>
|
||||
<file>icons/lock.png</file>
|
||||
<file>icons/unlock.png</file>
|
||||
<file>icons/sort-x.png</file>
|
||||
<file>icons/sort-y.png</file>
|
||||
<file>icons/isometric.png</file>
|
||||
<file>icons/blue-arrow-down.png</file>
|
||||
<file>icons/blue-arrow-left.png</file>
|
||||
<file>icons/blue-arrow-right.png</file>
|
||||
<file>icons/blue-arrow-up.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
40
src/editor/widgets/actiondragwidget.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "actiondragwidget.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
|
||||
ActionDragWidget::ActionDragWidget(QWidget *parent) :
|
||||
QToolButton{parent}
|
||||
{
|
||||
}
|
||||
|
||||
void ActionDragWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QToolButton::mousePressEvent(event);
|
||||
|
||||
if (event->button() == Qt::LeftButton)
|
||||
m_dragStartPosition = event->pos();
|
||||
}
|
||||
|
||||
void ActionDragWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
QToolButton::mouseMoveEvent(event);
|
||||
|
||||
if (!(event->buttons() & Qt::LeftButton))
|
||||
return;
|
||||
|
||||
if ((event->pos() - m_dragStartPosition).manhattanLength()
|
||||
< QApplication::startDragDistance())
|
||||
return;
|
||||
|
||||
QDrag *drag = new QDrag{this};
|
||||
drag->setPixmap(this->icon().pixmap(QSize{32, 32}));
|
||||
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
mimeData->setData("custom", QByteArray{"aaaaaa"});
|
||||
drag->setMimeData(mimeData);
|
||||
|
||||
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
|
||||
}
|
19
src/editor/widgets/actiondragwidget.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QPoint>
|
||||
|
||||
class ActionDragWidget : public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ActionDragWidget(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
QPoint m_dragStartPosition;
|
||||
};
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "models/actionscontainermodel.h"
|
||||
#include "dialogs/codeactiondialog.h"
|
||||
#include "dialogs/actions/movefixeddialog.h"
|
||||
|
||||
ActionsContainerWidget::ActionsContainerWidget(QWidget *parent) :
|
||||
QWidget{parent},
|
||||
@@ -27,6 +28,17 @@ ActionsContainerWidget::ActionsContainerWidget(QWidget *parent) :
|
||||
m_ui->listViewActions, [listView=m_ui->listViewActions](){
|
||||
listView->setCurrentIndex(QModelIndex{});
|
||||
});
|
||||
|
||||
connect(m_ui->toolButtonMoveFixed, &QAbstractButton::clicked,
|
||||
this, [this](){
|
||||
MoveFixedAction action;
|
||||
MoveFixedDialog dialog{action, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
// TODO insert into model
|
||||
emit changed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ActionsContainerWidget::~ActionsContainerWidget() = default;
|
||||
@@ -50,10 +62,21 @@ void ActionsContainerWidget::actionDoubleClicked(const QModelIndex &index)
|
||||
if (!action)
|
||||
return;
|
||||
|
||||
CodeActionDialog dialog{*action, this};
|
||||
if (auto ptr = std::get_if<MoveFixedAction>(action))
|
||||
{
|
||||
MoveFixedDialog dialog{*ptr, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else if (auto ptr = std::get_if<ExecuteCodeAction>(action))
|
||||
{
|
||||
CodeActionDialog dialog{*ptr, this};
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
emit changed();
|
||||
}
|
||||
else
|
||||
QMessageBox::information(this, tr("Not implemented!"), tr("Not implemented!"));
|
||||
}
|
||||
|
||||
void ActionsContainerWidget::actionsContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
|
@@ -313,14 +313,56 @@ QDataStream &operator>>(QDataStream &ds, Font &font)
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Action &action)
|
||||
QDataStream &operator<<(QDataStream &ds, const MoveFixedAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds << action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, MoveFixedAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds >> action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const MoveFreeAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds << action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, MoveFreeAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds >> action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const MoveTowardsAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds << action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, MoveTowardsAction &action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
// ds >> action.;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const ExecuteCodeAction &action)
|
||||
{
|
||||
ds << action.script;
|
||||
ds << action.appliesTo;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Action &action)
|
||||
QDataStream &operator>>(QDataStream &ds, ExecuteCodeAction &action)
|
||||
{
|
||||
ds >> action.script;
|
||||
ds >> action.appliesTo;
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <variant>
|
||||
|
||||
#include <QString>
|
||||
#include <QPixmap>
|
||||
@@ -85,7 +86,19 @@ struct Font
|
||||
} range;
|
||||
};
|
||||
|
||||
struct Action {
|
||||
struct MoveFixedAction {
|
||||
|
||||
};
|
||||
|
||||
struct MoveFreeAction {
|
||||
|
||||
};
|
||||
|
||||
struct MoveTowardsAction {
|
||||
|
||||
};
|
||||
|
||||
struct ExecuteCodeAction {
|
||||
enum class AppliesTo {
|
||||
Self,
|
||||
Other,
|
||||
@@ -96,7 +109,14 @@ struct Action {
|
||||
AppliesTo appliesTo{AppliesTo::Self};
|
||||
};
|
||||
|
||||
using ActionsContainer = std::array<Action, 1>;
|
||||
using Action = std::variant<
|
||||
MoveFixedAction,
|
||||
MoveFreeAction,
|
||||
MoveTowardsAction,
|
||||
ExecuteCodeAction
|
||||
>;
|
||||
|
||||
using ActionsContainer = std::list<Action>;
|
||||
|
||||
struct TimeLine
|
||||
{
|
||||
@@ -141,7 +161,26 @@ struct Object
|
||||
int depth{};
|
||||
bool persistent{};
|
||||
QString parentName;
|
||||
events_container_t events;
|
||||
events_container_t events {
|
||||
{
|
||||
EventType::Create,
|
||||
ActionsContainer {
|
||||
Action { MoveFixedAction{} },
|
||||
Action { MoveFreeAction{} },
|
||||
Action { MoveTowardsAction{} },
|
||||
Action { ExecuteCodeAction{} }
|
||||
}
|
||||
},
|
||||
{
|
||||
EventType::Destroy,
|
||||
ActionsContainer {
|
||||
Action { ExecuteCodeAction{} },
|
||||
Action { MoveTowardsAction{} },
|
||||
Action { MoveFreeAction{} },
|
||||
Action { MoveFixedAction{} }
|
||||
}
|
||||
}
|
||||
};
|
||||
collision_events_container_t collisionEvents;
|
||||
};
|
||||
|
||||
|