Implemented a few room property inputs

This commit is contained in:
2022-01-15 04:48:32 +01:00
parent ffd4c821ef
commit 25e522fd8a
42 changed files with 1507 additions and 294 deletions

View File

@ -22,6 +22,8 @@ INCLUDEPATH += \
HEADERS += \
src/closeeventfilter.h \
src/editor/dialogs/genericcodeeditordialog.h \
src/editor/widgets/roomeditwidget.h \
src/futurecpp.h \
src/projectcontainer.h \
src/editor/jshighlighter.h \
@ -50,7 +52,6 @@ HEADERS += \
src/editor/dialogs/soundpropertiesdialog.h \
src/editor/dialogs/spritepropertiesdialog.h \
src/editor/dialogs/timelinepropertiesdialog.h \
src/editor/dialogs/triggerconditiondialog.h \
src/editor/dialogs/triggersdialog.h \
src/editor/dialogs/userdefinedconstantsdialog.h \
src/editor/models/actionscontainermodel.h \
@ -70,6 +71,8 @@ HEADERS += \
SOURCES += \
src/closeeventfilter.cpp \
src/editor/dialogs/genericcodeeditordialog.cpp \
src/editor/widgets/roomeditwidget.cpp \
src/main.cpp \
src/projectcontainer.cpp \
src/editor/jshighlighter.cpp \
@ -98,7 +101,6 @@ SOURCES += \
src/editor/dialogs/soundpropertiesdialog.cpp \
src/editor/dialogs/spritepropertiesdialog.cpp \
src/editor/dialogs/timelinepropertiesdialog.cpp \
src/editor/dialogs/triggerconditiondialog.cpp \
src/editor/dialogs/triggersdialog.cpp \
src/editor/dialogs/userdefinedconstantsdialog.cpp \
src/editor/models/actionscontainermodel.cpp \

BIN
icons/isometric.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
icons/lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
icons/sort-x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
icons/sort-y.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
icons/unlock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -82,5 +82,10 @@
<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>
</qresource>
</RCC>

View File

@ -22,7 +22,7 @@
<string>Dra&amp;w</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/event-draw.png</normaloff>:/qtgameengine/icons/event-draw.png</iconset>
</property>
</widget>
@ -54,7 +54,7 @@
<string>&amp;Step</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/event-step.png</normaloff>:/qtgameengine/icons/event-step.png</iconset>
</property>
</widget>
@ -65,7 +65,7 @@
<string>C&amp;reate</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/event-create.png</normaloff>:/qtgameengine/icons/event-create.png</iconset>
</property>
</widget>
@ -90,7 +90,7 @@
<string>&amp;Destroy</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/event-destroy.png</normaloff>:/qtgameengine/icons/event-destroy.png</iconset>
</property>
</widget>
@ -131,7 +131,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -14,7 +14,7 @@
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/background-file.png</normaloff>:/qtgameengine/icons/background-file.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
@ -69,7 +69,7 @@
<string>&amp;Load Background</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
</widget>
@ -83,7 +83,7 @@
<string>&amp;Save Background</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
</widget>
@ -97,7 +97,7 @@
<string>&amp;Edit Background</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/edit.png</normaloff>:/qtgameengine/icons/edit.png</iconset>
</property>
</widget>
@ -178,7 +178,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -14,7 +14,7 @@
<string>Code Editor</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/script-file.png</normaloff>:/qtgameengine/icons/script-file.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1">
@ -225,7 +225,7 @@
</layout>
<action name="actionOk">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/ok.png</normaloff>:/qtgameengine/icons/ok.png</iconset>
</property>
<property name="text">
@ -237,7 +237,7 @@
</action>
<action name="actionLoad">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
<property name="text">
@ -249,7 +249,7 @@
</action>
<action name="actionSave">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
<property name="text">
@ -261,7 +261,7 @@
</action>
<action name="actionPrint">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/print.png</normaloff>:/qtgameengine/icons/print.png</iconset>
</property>
<property name="text">
@ -276,7 +276,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/undo.png</normaloff>:/qtgameengine/icons/undo.png</iconset>
</property>
<property name="text">
@ -291,7 +291,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/redo.png</normaloff>:/qtgameengine/icons/redo.png</iconset>
</property>
<property name="text">
@ -306,7 +306,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/cut.png</normaloff>:/qtgameengine/icons/cut.png</iconset>
</property>
<property name="text">
@ -321,7 +321,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/copy.png</normaloff>:/qtgameengine/icons/copy.png</iconset>
</property>
<property name="text">
@ -333,7 +333,7 @@
</action>
<action name="actionPaste">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/paste.png</normaloff>:/qtgameengine/icons/paste.png</iconset>
</property>
<property name="text">
@ -351,7 +351,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/find.png</normaloff>:/qtgameengine/icons/find.png</iconset>
</property>
<property name="text">
@ -369,7 +369,7 @@
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/check.png</normaloff>:/qtgameengine/icons/check.png</iconset>
</property>
<property name="text">
@ -388,7 +388,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -57,7 +57,7 @@
<number>0</number>
</property>
<property name="maximum">
<number>16384</number>
<number>2147483647</number>
</property>
<property name="value">
<number>32</number>
@ -67,7 +67,7 @@
<item row="1" column="1">
<widget class="QSpinBox" name="spinBoxHeight">
<property name="maximum">
<number>16384</number>
<number>2147483647</number>
</property>
<property name="value">
<number>32</number>

View File

@ -168,7 +168,7 @@
</layout>
<action name="actionNew">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
<property name="text">
@ -177,7 +177,7 @@
</action>
<action name="actionCreateFromFile">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
<property name="text">
@ -186,7 +186,7 @@
</action>
<action name="actionAddFromFile">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/create-group.png</normaloff>:/qtgameengine/icons/create-group.png</iconset>
</property>
<property name="text">
@ -198,7 +198,7 @@
</action>
<action name="actionSaveAsPngFile">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
<property name="text">
@ -223,7 +223,7 @@
</action>
<action name="actionCloseSavingChanges">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/ok.png</normaloff>:/qtgameengine/icons/ok.png</iconset>
</property>
<property name="text">
@ -232,7 +232,7 @@
</action>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -14,7 +14,7 @@
<string>Font Properties</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/font-file.png</normaloff>:/qtgameengine/icons/font-file.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -220,7 +220,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -1,7 +1,7 @@
#include "triggerconditiondialog.h"
#include "genericcodeeditordialog.h"
TriggerConditionDialog::TriggerConditionDialog(QWidget *parent) :
CodeEditorDialog{tr("Trigger condition"), parent}
GenericCodeEditorDialog::GenericCodeEditorDialog(const QString &title, QWidget *parent) :
CodeEditorDialog{title, parent}
{
#ifdef Q_OS_LINUX
setWindowFlags((windowFlags() & ~Qt::Dialog) | Qt::Window);

View File

@ -0,0 +1,11 @@
#pragma once
#include "codeeditordialog.h"
class GenericCodeEditorDialog : public CodeEditorDialog
{
Q_OBJECT
public:
explicit GenericCodeEditorDialog(const QString &title, QWidget *parent = nullptr);
};

View File

@ -176,7 +176,7 @@
</layout>
<action name="actionNew">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
<property name="text">
@ -188,7 +188,7 @@
</action>
<action name="actionSaveAsPngFile">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
<property name="text">
@ -200,7 +200,7 @@
</action>
<action name="actionPreviousImage">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-left.png</normaloff>:/qtgameengine/icons/arrow-left.png</iconset>
</property>
<property name="text">
@ -212,7 +212,7 @@
</action>
<action name="actionNextImage">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-right.png</normaloff>:/qtgameengine/icons/arrow-right.png</iconset>
</property>
<property name="text">
@ -224,7 +224,7 @@
</action>
<action name="actionCloseSavingChanges">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/ok.png</normaloff>:/qtgameengine/icons/ok.png</iconset>
</property>
<property name="text">
@ -236,7 +236,7 @@
</action>
<action name="actionLoad">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
<property name="text">
@ -245,7 +245,7 @@
</action>
<action name="actionUndo">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/undo.png</normaloff>:/qtgameengine/icons/undo.png</iconset>
</property>
<property name="text">
@ -254,7 +254,7 @@
</action>
<action name="actionRedo">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/redo.png</normaloff>:/qtgameengine/icons/redo.png</iconset>
</property>
<property name="text">
@ -305,7 +305,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -42,7 +42,7 @@
<string>&amp;Add</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/add.png</normaloff>:/qtgameengine/icons/add.png</iconset>
</property>
</widget>
@ -56,7 +56,7 @@
<string>&amp;Change</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/replace.png</normaloff>:/qtgameengine/icons/replace.png</iconset>
</property>
</widget>
@ -70,7 +70,7 @@
<string>&amp;Delete</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/delete.png</normaloff>:/qtgameengine/icons/delete.png</iconset>
</property>
</widget>
@ -84,7 +84,7 @@
<string>&amp;Clear</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
</widget>
@ -107,7 +107,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -14,7 +14,7 @@
<string>Information about all Objects</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/object-file.png</normaloff>:/qtgameengine/icons/object-file.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1">
@ -58,7 +58,7 @@
</layout>
<action name="actionOk">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/ok.png</normaloff>:/qtgameengine/icons/ok.png</iconset>
</property>
<property name="text">
@ -70,7 +70,7 @@
</action>
<action name="actionSave">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
<property name="text">
@ -82,7 +82,7 @@
</action>
<action name="actionPrint">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/print.png</normaloff>:/qtgameengine/icons/print.png</iconset>
</property>
<property name="text">
@ -94,7 +94,7 @@
</action>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -18,7 +18,7 @@ ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel
m_projectModel{projectModel},
m_events{m_object.events},
m_eventsModel{std::make_unique<ObjectEventsModel>(m_events)},
m_spritesMenu{new QMenu{m_ui->toolButtonSprite}},
m_menuSprites{new QMenu{this}},
m_spriteName{object.spriteName}
{
m_ui->setupUi(this);
@ -33,7 +33,8 @@ ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel
m_ui->lineEditName->setText(m_object.name);
m_ui->lineEditSprite->setText(m_spriteName.isEmpty() ? tr("<no sprite>") : m_spriteName);
updateSpritePreview();
m_ui->toolButtonSprite->setMenu(m_spritesMenu);
m_menuSprites->setParent(m_ui->toolButtonSprite);
m_ui->toolButtonSprite->setMenu(m_menuSprites);
m_ui->checkBoxVisible->setChecked(m_object.visible);
m_ui->checkBoxSolid->setChecked(m_object.solid);
m_ui->spinBoxDepth->setValue(m_object.depth);
@ -83,7 +84,7 @@ ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel
connect(m_ui->checkBoxPersistent, &QCheckBox::toggled,
this, &ObjectPropertiesDialog::changed);
connect(m_spritesMenu, &QMenu::aboutToShow,
connect(m_menuSprites, &QMenu::aboutToShow,
this, &ObjectPropertiesDialog::spritesMenuAboutToShow);
connect(m_ui->listViewEvents->selectionModel(), &QItemSelectionModel::currentChanged,
@ -289,10 +290,10 @@ void ObjectPropertiesDialog::spritePixmapsChanged(const Sprite &sprite)
void ObjectPropertiesDialog::spritesMenuAboutToShow()
{
m_spritesMenu->clear();
m_spritesMenu->addAction(tr("<no sprite>"), this, &ObjectPropertiesDialog::clearSprite);
m_menuSprites->clear();
m_menuSprites->addAction(tr("<no sprite>"), this, &ObjectPropertiesDialog::clearSprite);
for (const auto &sprite : m_projectModel.project()->sprites)
m_spritesMenu->addAction(sprite.pixmaps.empty() ? QPixmap{} : sprite.pixmaps.front(),
m_menuSprites->addAction(sprite.pixmaps.empty() ? QPixmap{} : sprite.pixmaps.front(),
sprite.name,
this,
[&sprite,this](){ setSprite(sprite); });

View File

@ -60,7 +60,7 @@ private:
const std::unique_ptr<ObjectEventsModel> m_eventsModel;
QMenu * const m_spritesMenu;
QMenu * const m_menuSprites;
QString m_spriteName;

View File

@ -14,7 +14,7 @@
<string>Object Properties</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/object-file.png</normaloff>:/qtgameengine/icons/object-file.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0,1">
@ -305,7 +305,7 @@
<string>Show Information</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/info.png</normaloff>:/qtgameengine/icons/info.png</iconset>
</property>
</widget>
@ -416,7 +416,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -3,6 +3,8 @@
#include <QSpinBox>
#include <QLabel>
#include <QMenu>
#include <QToolButton>
#include <QDebug>
#include <QMessageBox>
#include <QSignalBlocker>
@ -16,39 +18,60 @@ PathPropertiesDialog::PathPropertiesDialog(Path &path, ProjectTreeModel &project
m_ui{std::make_unique<Ui::PathPropertiesDialog>()},
m_path{path},
m_projectModel{projectModel},
m_points{path.points},
m_points{m_path.points},
m_pointsModel{std::make_unique<PathPointsModel>(m_points, this)},
m_spinBoxSnapX{new QSpinBox{this}},
m_spinBoxSnapY{new QSpinBox{this}},
m_menuRooms{new QMenu{this}},
m_labelX{new QLabel{tr("x: %0").arg(0)}},
m_labelY{new QLabel{tr("y: %0").arg(0)}},
m_labelArea{new QLabel{tr("Area: (%0,%1)->(%2,%3)").arg(0).arg(0).arg(0).arg(0)}}
{
m_ui->setupUi(this);
m_ui->widget->setPoints(&m_points);
m_ui->pathPointsWidget->setPoints(&m_points);
m_ui->pathPointsWidget->setSnapX(m_path.snapX);
m_ui->pathPointsWidget->setSnapY(m_path.snapY);
m_ui->pathPointsWidget->setGridEnabled(m_path.gridEnabled);
updateTitle();
{
auto label = new QLabel{tr("Snap X:"), this};
label->setBuddy(m_spinBoxSnapX);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(18), label);
int index{18};
{
auto label = new QLabel{tr("Snap &X:"), this};
label->setBuddy(m_spinBoxSnapX);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(index++), label);
}
m_spinBoxSnapX->setValue(m_ui->pathPointsWidget->snapX());
m_spinBoxSnapX->setMaximumWidth(50);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(index++), m_spinBoxSnapX);
{
auto label = new QLabel{tr("Snap &Y:"), this};
label->setBuddy(m_spinBoxSnapY);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(index++), label);
}
m_spinBoxSnapY->setValue(m_ui->pathPointsWidget->snapY());
m_spinBoxSnapY->setMaximumWidth(50);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(index++), m_spinBoxSnapY);
}
m_spinBoxSnapX->setValue(m_ui->widget->gridX());
m_spinBoxSnapX->setMaximumWidth(50);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(19), m_spinBoxSnapX);
m_ui->actionGridEnabled->setChecked(m_ui->pathPointsWidget->gridEnabled());
{
auto label = new QLabel{tr("Snap Y:"), this};
label->setBuddy(m_spinBoxSnapY);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(20), label);
auto toolButton = new QToolButton{this};
toolButton->setText(tr("Show"));
toolButton->setWhatsThis(tr("Indicate the room to show as background"));
toolButton->setIcon(QIcon{":/qtgameengine/icons/room.png"});
toolButton->setPopupMode(QToolButton::InstantPopup);
toolButton->setMenu(m_menuRooms);
m_ui->toolBar->addWidget(toolButton);
}
m_spinBoxSnapY->setValue(m_ui->widget->gridY());
m_spinBoxSnapY->setMaximumWidth(50);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(21), m_spinBoxSnapY);
m_ui->actionGrid->setChecked(m_ui->widget->showGrid());
connect(m_menuRooms, &QMenu::aboutToShow,
this, &PathPropertiesDialog::roomsMenuAboutToShow);
m_ui->treeView->setModel(m_pointsModel.get());
@ -57,7 +80,7 @@ PathPropertiesDialog::PathPropertiesDialog(Path &path, ProjectTreeModel &project
m_ui->checkBoxClosed->setChecked(m_path.closed);
m_ui->spinBoxPrecision->setValue(m_path.precision);
m_ui->widget->setClosed(m_path.closed);
m_ui->pathPointsWidget->setClosed(m_path.closed);
m_labelX->setFrameStyle(QFrame::Sunken);
m_ui->statusbar->addWidget(m_labelX, 1);
@ -76,9 +99,9 @@ PathPropertiesDialog::PathPropertiesDialog(Path &path, ProjectTreeModel &project
m_ui->treeView->setColumnWidth(1, 75);
connect(m_ui->widget, &PathPointsWidget::pointInserted,
connect(m_ui->pathPointsWidget, &PathPointsWidget::pointInserted,
m_pointsModel.get(), &PathPointsModel::pointInserted);
connect(m_ui->widget, &PathPointsWidget::pointMoved,
connect(m_ui->pathPointsWidget, &PathPointsWidget::pointMoved,
m_pointsModel.get(), &PathPointsModel::pointMoved);
connect(&m_projectModel, &ProjectTreeModel::pathNameChanged,
@ -87,27 +110,61 @@ PathPropertiesDialog::PathPropertiesDialog(Path &path, ProjectTreeModel &project
connect(m_ui->treeView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &PathPropertiesDialog::selectionChanged);
connect(m_ui->widget, &PathPointsWidget::gridXChanged,
connect(m_ui->actionUndo, &QAction::triggered,
this, &PathPropertiesDialog::undo);
connect(m_ui->actionClear, &QAction::triggered,
this, &PathPropertiesDialog::clearPath);
connect(m_ui->actionReverse, &QAction::triggered,
this, &PathPropertiesDialog::reversePath);
connect(m_ui->actionShift, &QAction::triggered,
this, &PathPropertiesDialog::shiftPath);
connect(m_ui->actionMirrorHorizontally, &QAction::triggered,
this, &PathPropertiesDialog::mirrorPathHorizontally);
connect(m_ui->actionMirrorVertically, &QAction::triggered,
this, &PathPropertiesDialog::mirrorPathVertically);
connect(m_ui->actionRotate, &QAction::triggered,
this, &PathPropertiesDialog::rotatePath);
connect(m_ui->actionScale, &QAction::triggered,
this, &PathPropertiesDialog::scalePath);
connect(m_ui->actionShiftLeft, &QAction::triggered,
this, &PathPropertiesDialog::shiftViewLeft);
connect(m_ui->actionShiftRight, &QAction::triggered,
this, &PathPropertiesDialog::shiftViewRight);
connect(m_ui->actionShiftUp, &QAction::triggered,
this, &PathPropertiesDialog::shiftViewUp);
connect(m_ui->actionShiftDown, &QAction::triggered,
this, &PathPropertiesDialog::shiftViewDown);
connect(m_ui->actionCenterView, &QAction::triggered,
this, &PathPropertiesDialog::centerView);
connect(m_ui->pathPointsWidget, &PathPointsWidget::snapXChanged,
m_spinBoxSnapX, &QSpinBox::setValue);
connect(m_ui->widget, &PathPointsWidget::gridYChanged,
connect(m_ui->pathPointsWidget, &PathPointsWidget::snapYChanged,
m_spinBoxSnapY, &QSpinBox::setValue);
connect(m_ui->widget, &PathPointsWidget::showGridChanged,
m_ui->actionGrid, &QAction::setChecked);
connect(m_ui->widget, &PathPointsWidget::closedChanged,
connect(m_ui->pathPointsWidget, &PathPointsWidget::gridEnabledChanged,
m_ui->actionGridEnabled, &QAction::setChecked);
connect(m_ui->pathPointsWidget, &PathPointsWidget::closedChanged,
m_ui->checkBoxClosed, &QCheckBox::setChecked);
connect(m_ui->widget, &PathPointsWidget::cursorMoved,
connect(m_ui->pathPointsWidget, &PathPointsWidget::cursorMoved,
this, &PathPropertiesDialog::cursorMoved);
connect(m_ui->widget, &PathPointsWidget::selectedIndexChanged,
connect(m_ui->pathPointsWidget, &PathPointsWidget::selectedIndexChanged,
this, &PathPropertiesDialog::selectedPointChanged);
connect(m_spinBoxSnapX, &QSpinBox::valueChanged,
m_ui->widget, &PathPointsWidget::setGridX);
m_ui->pathPointsWidget, &PathPointsWidget::setSnapX);
connect(m_spinBoxSnapY, &QSpinBox::valueChanged,
m_ui->widget, &PathPointsWidget::setGridY);
connect(m_ui->actionGrid, &QAction::toggled,
m_ui->widget, &PathPointsWidget::setShowGrid);
m_ui->pathPointsWidget, &PathPointsWidget::setSnapY);
connect(m_ui->actionGridEnabled, &QAction::toggled,
m_ui->pathPointsWidget, &PathPointsWidget::setGridEnabled);
connect(m_ui->checkBoxClosed, &QCheckBox::toggled,
m_ui->widget, &PathPointsWidget::setClosed);
m_ui->pathPointsWidget, &PathPointsWidget::setClosed);
connect(m_spinBoxSnapX, &QSpinBox::valueChanged,
this, &PathPropertiesDialog::changed);
connect(m_spinBoxSnapY, &QSpinBox::valueChanged,
this, &PathPropertiesDialog::changed);
connect(m_ui->actionGridEnabled, &QAction::toggled,
this, &PathPropertiesDialog::changed);
connect(m_ui->spinBoxX, &QSpinBox::valueChanged,
this, &PathPropertiesDialog::pointFieldsChanged);
@ -129,17 +186,17 @@ PathPropertiesDialog::PathPropertiesDialog(Path &path, ProjectTreeModel &project
connect(m_pointsModel.get(), &QAbstractTableModel::rowsInserted,
this, &PathPropertiesDialog::changed);
connect(m_pointsModel.get(), &QAbstractTableModel::rowsInserted,
m_ui->widget, qOverload<>(&PathPointsWidget::update));
m_ui->pathPointsWidget, qOverload<>(&PathPointsWidget::update));
connect(m_pointsModel.get(), &QAbstractTableModel::rowsRemoved,
this, &PathPropertiesDialog::changed);
connect(m_pointsModel.get(), &QAbstractTableModel::rowsRemoved,
m_ui->widget, qOverload<>(&PathPointsWidget::update));
m_ui->pathPointsWidget, qOverload<>(&PathPointsWidget::update));
connect(m_pointsModel.get(), &QAbstractTableModel::dataChanged,
this, &PathPropertiesDialog::dataChanged);
connect(m_pointsModel.get(), &QAbstractTableModel::dataChanged,
this, &PathPropertiesDialog::changed);
connect(m_pointsModel.get(), &QAbstractTableModel::dataChanged,
m_ui->widget, qOverload<>(&PathPointsWidget::update));
m_ui->pathPointsWidget, qOverload<>(&PathPointsWidget::update));
connect(m_ui->radioButtonStraight, &QRadioButton::toggled,
this, &PathPropertiesDialog::changed);
connect(m_ui->radioButtonSmooth, &QRadioButton::toggled,
@ -183,8 +240,9 @@ void PathPropertiesDialog::accept()
m_path.closed = m_ui->checkBoxClosed->isChecked();
m_path.precision = m_ui->spinBoxPrecision->value();
// TODO update points
m_path.snapX = m_spinBoxSnapX->value();
m_path.snapY = m_spinBoxSnapY->value();
m_path.gridEnabled = m_ui->actionGridEnabled->isChecked();
QDialog::accept();
}
@ -223,11 +281,11 @@ void PathPropertiesDialog::selectionChanged(const QModelIndex &index)
{
if (!index.isValid())
{
m_ui->widget->setSelectedIndex(std::nullopt);
m_ui->pathPointsWidget->setSelectedIndex(std::nullopt);
return;
}
m_ui->widget->setSelectedIndex(index.row());
m_ui->pathPointsWidget->setSelectedIndex(index.row());
updatePointFields();
}
@ -284,6 +342,71 @@ void PathPropertiesDialog::deletePoint()
}
}
void PathPropertiesDialog::undo()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::clearPath()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::reversePath()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::shiftPath()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::mirrorPathHorizontally()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::mirrorPathVertically()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::rotatePath()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::scalePath()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::shiftViewLeft()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::shiftViewRight()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::shiftViewUp()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::shiftViewDown()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::centerView()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void PathPropertiesDialog::pointFieldsChanged()
{
const auto index = m_ui->treeView->currentIndex();
@ -321,6 +444,18 @@ void PathPropertiesDialog::pathNameChanged(const Path &path)
updateTitle();
}
void PathPropertiesDialog::roomsMenuAboutToShow()
{
m_menuRooms->clear();
qDebug() << "called" << tr("No Room");
m_menuRooms->addAction(tr("No Room"));
for (const auto &room : m_projectModel.project()->rooms)
{
qDebug() << "called" << room.name;
m_menuRooms->addAction(room.name);
}
}
void PathPropertiesDialog::updateTitle()
{
setWindowTitle(tr("Path Properties: %0%1")

View File

@ -9,6 +9,7 @@
class QSpinBox;
class QLabel;
class QMenu;
namespace Ui { class PathPropertiesDialog; }
class ProjectTreeModel;
class PathPointsModel;
@ -34,11 +35,27 @@ private slots:
void insertPoint();
void deletePoint();
void undo();
void clearPath();
void reversePath();
void shiftPath();
void mirrorPathHorizontally();
void mirrorPathVertically();
void rotatePath();
void scalePath();
void shiftViewLeft();
void shiftViewRight();
void shiftViewUp();
void shiftViewDown();
void centerView();
void pointFieldsChanged();
void changed();
void pathNameChanged(const Path &path);
void roomsMenuAboutToShow();
private:
void updateTitle();
void updatePointFields();
@ -59,6 +76,8 @@ private:
QSpinBox * const m_spinBoxSnapX;
QSpinBox * const m_spinBoxSnapY;
QMenu * const m_menuRooms;
QLabel * const m_labelX;
QLabel * const m_labelY;
QLabel * const m_labelArea;

View File

@ -14,7 +14,7 @@
<string>Path Properties</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/path-file.png</normaloff>:/qtgameengine/icons/path-file.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
@ -79,19 +79,18 @@
<addaction name="actionReverse"/>
<addaction name="actionShift"/>
<addaction name="actionMirrorHorizontally"/>
<addaction name="actionFlipVertically"/>
<addaction name="actionMirrorVertically"/>
<addaction name="actionRotate"/>
<addaction name="actionScale"/>
<addaction name="separator"/>
<addaction name="actionShiftLeft"/>
<addaction name="actionShiftRight"/>
<addaction name="actionShiftTop"/>
<addaction name="actionShift_bottom"/>
<addaction name="actionShiftUp"/>
<addaction name="actionShiftDown"/>
<addaction name="actionCenterView"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="actionGrid"/>
<addaction name="actionRoom"/>
<addaction name="actionGridEnabled"/>
</widget>
</item>
</layout>
@ -158,6 +157,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -196,7 +198,7 @@
<string>X-coordinate of the point</string>
</property>
<property name="maximum">
<number>16384</number>
<number>2147483647</number>
</property>
</widget>
</item>
@ -216,7 +218,7 @@
<string>Y-coordinate of the point</string>
</property>
<property name="maximum">
<number>16384</number>
<number>2147483647</number>
</property>
</widget>
</item>
@ -236,7 +238,7 @@
<string>Relative speed at this point (100 = default)</string>
</property>
<property name="maximum">
<number>16384</number>
<number>2147483647</number>
</property>
</widget>
</item>
@ -391,7 +393,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_7" stretch="1,0">
<item>
<widget class="PathPointsWidget" name="widget" native="true">
<widget class="PathPointsWidget" name="pathPointsWidget" native="true">
<property name="minimumSize">
<size>
<width>300</width>
@ -410,7 +412,7 @@
</layout>
<action name="actionOk">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/ok.png</normaloff>:/qtgameengine/icons/ok.png</iconset>
</property>
<property name="text">
@ -422,7 +424,7 @@
</action>
<action name="actionUndo">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/undo.png</normaloff>:/qtgameengine/icons/undo.png</iconset>
</property>
<property name="text">
@ -434,7 +436,7 @@
</action>
<action name="actionClear">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
<property name="text">
@ -446,7 +448,7 @@
</action>
<action name="actionReverse">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/rotate.png</normaloff>:/qtgameengine/icons/rotate.png</iconset>
</property>
<property name="text">
@ -458,7 +460,7 @@
</action>
<action name="actionShift">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/move.png</normaloff>:/qtgameengine/icons/move.png</iconset>
</property>
<property name="text">
@ -470,7 +472,7 @@
</action>
<action name="actionMirrorHorizontally">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/flip-horizontal.png</normaloff>:/qtgameengine/icons/flip-horizontal.png</iconset>
</property>
<property name="text">
@ -480,9 +482,9 @@
<string>Mirror the path horizontally</string>
</property>
</action>
<action name="actionFlipVertically">
<action name="actionMirrorVertically">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/flip-vertical.png</normaloff>:/qtgameengine/icons/flip-vertical.png</iconset>
</property>
<property name="text">
@ -494,7 +496,7 @@
</action>
<action name="actionRotate">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/rotate.png</normaloff>:/qtgameengine/icons/rotate.png</iconset>
</property>
<property name="text">
@ -506,7 +508,7 @@
</action>
<action name="actionScale">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/scale.png</normaloff>:/qtgameengine/icons/scale.png</iconset>
</property>
<property name="text">
@ -518,7 +520,7 @@
</action>
<action name="actionShiftLeft">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-left.png</normaloff>:/qtgameengine/icons/arrow-left.png</iconset>
</property>
<property name="text">
@ -530,7 +532,7 @@
</action>
<action name="actionShiftRight">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-right.png</normaloff>:/qtgameengine/icons/arrow-right.png</iconset>
</property>
<property name="text">
@ -540,9 +542,9 @@
<string>Shift the view to the right</string>
</property>
</action>
<action name="actionShiftTop">
<action name="actionShiftUp">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-up.png</normaloff>:/qtgameengine/icons/arrow-up.png</iconset>
</property>
<property name="text">
@ -552,9 +554,9 @@
<string>Shift the view to the top</string>
</property>
</action>
<action name="actionShift_bottom">
<action name="actionShiftDown">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-down.png</normaloff>:/qtgameengine/icons/arrow-down.png</iconset>
</property>
<property name="text">
@ -566,7 +568,7 @@
</action>
<action name="actionCenterView">
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/center.png</normaloff>:/qtgameengine/icons/center.png</iconset>
</property>
<property name="text">
@ -576,7 +578,7 @@
<string>Center view around the path</string>
</property>
</action>
<action name="actionGrid">
<action name="actionGridEnabled">
<property name="checkable">
<bool>true</bool>
</property>
@ -584,7 +586,7 @@
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/grid.png</normaloff>:/qtgameengine/icons/grid.png</iconset>
</property>
<property name="text">
@ -594,18 +596,6 @@
<string>Toggle the showing of the grid</string>
</property>
</action>
<action name="actionRoom">
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/qtgameengine/icons/room.png</normaloff>:/qtgameengine/icons/room.png</iconset>
</property>
<property name="text">
<string>Room</string>
</property>
<property name="toolTip">
<string>Indicate the room to show as background</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@ -616,7 +606,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -1,14 +1,306 @@
#include "roompropertiesdialog.h"
#include "ui_roompropertiesdialog.h"
#include <QSpinBox>
#include <QLabel>
#include <QToolButton>
#include <QMessageBox>
#include <QDebug>
#include "projectcontainer.h"
#include "models/projecttreemodel.h"
#include "genericcodeeditordialog.h"
RoomPropertiesDialog::RoomPropertiesDialog(Room &room, ProjectTreeModel &projectModel, QWidget *parent) :
QDialog{parent},
m_ui{std::make_unique<Ui::RoomPropertiesDialog>()}
m_ui{std::make_unique<Ui::RoomPropertiesDialog>()},
m_room{room},
m_projectModel{projectModel},
m_creationCode{m_room.creationCode},
m_spinBoxSnapX{new QSpinBox{this}},
m_spinBoxSnapY{new QSpinBox{this}},
m_labelX{new QLabel{tr("x: %0").arg(0)}},
m_labelY{new QLabel{tr("y: %0").arg(0)}}
{
Q_UNUSED(room)
Q_UNUSED(projectModel)
m_ui->setupUi(this);
updateTitle();
m_ui->roomEditWidget->setFixedWidth(m_room.width);
m_ui->roomEditWidget->setFixedHeight(m_room.height);
m_ui->roomEditWidget->setSnapX(m_room.snapX);
m_ui->roomEditWidget->setSnapY(m_room.snapY);
m_ui->roomEditWidget->setGridEnabled(m_room.gridEnabled);
m_ui->roomEditWidget->setIsometricGrid(m_room.isometricGrid);
{
int index{11};
{
auto label = new QLabel{tr("Snap &X:"), this};
label->setBuddy(m_spinBoxSnapX);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(index++), label);
}
m_spinBoxSnapX->setValue(m_ui->roomEditWidget->snapX());
m_spinBoxSnapX->setMaximumWidth(50);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(index++), m_spinBoxSnapX);
{
auto label = new QLabel{tr("Snap &Y:"), this};
label->setBuddy(m_spinBoxSnapY);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(index++), label);
}
m_spinBoxSnapY->setValue(m_ui->roomEditWidget->snapY());
m_spinBoxSnapY->setMaximumWidth(50);
m_ui->toolBar->insertWidget(m_ui->toolBar->actions().at(index++), m_spinBoxSnapY);
}
m_ui->actionGridEnabled->setChecked(m_ui->roomEditWidget->gridEnabled());
m_ui->actionIsometricGrid->setChecked(m_ui->roomEditWidget->isometricGrid());
{
auto toolButton = new QToolButton{this};
toolButton->setText(tr("Show"));
toolButton->setIcon(QIcon{":/qtgameengine/icons/find.png"});
toolButton->setPopupMode(QToolButton::InstantPopup);
toolButton->addAction(m_ui->actionShowObjects);
toolButton->addAction(m_ui->actionShowTiles);
toolButton->addAction(m_ui->actionShowBackgrounds);
toolButton->addAction(m_ui->actionShowForegrounds);
toolButton->addAction(m_ui->actionShowViews);
m_ui->toolBar->addWidget(toolButton);
}
m_ui->scrollArea->setBackgroundRole(QPalette::Dark);
m_labelX->setFrameStyle(QFrame::Sunken);
m_ui->statusbar->addWidget(m_labelX, 1);
m_labelY->setFrameStyle(QFrame::Sunken);
m_ui->statusbar->addWidget(m_labelY, 1);
{
auto frame = new QFrame{this};
frame->setFrameStyle(QFrame::Sunken);
m_ui->statusbar->addPermanentWidget(frame, 4);
}
m_ui->lineEditName->setText(m_room.name);
m_ui->lineEditCaption->setText(m_room.caption);
m_ui->spinBoxWidth->setValue(m_ui->roomEditWidget->width());
m_ui->spinBoxHeight->setValue(m_ui->roomEditWidget->height());
m_ui->spinBoxSpeed->setValue(m_room.speed);
m_ui->checkBoxPersistent->setChecked(m_room.persistent);
connect(&m_projectModel, &ProjectTreeModel::roomNameChanged,
this, &RoomPropertiesDialog::roomNameChanged);
connect(m_ui->actionUndo, &QAction::triggered,
this, &RoomPropertiesDialog::undo);
connect(m_ui->actionClear, &QAction::triggered,
this, &RoomPropertiesDialog::undo);
connect(m_ui->actionShift, &QAction::triggered,
this, &RoomPropertiesDialog::undo);
connect(m_ui->actionSortX, &QAction::triggered,
this, &RoomPropertiesDialog::undo);
connect(m_ui->actionSortY, &QAction::triggered,
this, &RoomPropertiesDialog::undo);
connect(m_ui->actionLock, &QAction::triggered,
this, &RoomPropertiesDialog::undo);
connect(m_ui->actionUnlock, &QAction::triggered,
this, &RoomPropertiesDialog::undo);
connect(m_spinBoxSnapX, &QSpinBox::valueChanged,
m_ui->roomEditWidget, &RoomEditWidget::setSnapX);
connect(m_spinBoxSnapY, &QSpinBox::valueChanged,
m_ui->roomEditWidget, &RoomEditWidget::setSnapY);
connect(m_ui->actionGridEnabled, &QAction::toggled,
m_ui->roomEditWidget, &RoomEditWidget::setGridEnabled);
connect(m_ui->actionIsometricGrid, &QAction::toggled,
m_ui->roomEditWidget, &RoomEditWidget::setIsometricGrid);
connect(m_ui->spinBoxWidth, &QSpinBox::valueChanged,
m_ui->roomEditWidget, &RoomEditWidget::setFixedWidth);
connect(m_ui->spinBoxHeight, &QSpinBox::valueChanged,
m_ui->roomEditWidget, &RoomEditWidget::setFixedHeight);
connect(m_spinBoxSnapX, &QSpinBox::valueChanged,
this, &RoomPropertiesDialog::changed);
connect(m_spinBoxSnapY, &QSpinBox::valueChanged,
this, &RoomPropertiesDialog::changed);
connect(m_ui->actionGridEnabled, &QAction::toggled,
this, &RoomPropertiesDialog::changed);
connect(m_ui->actionIsometricGrid, &QAction::toggled,
this, &RoomPropertiesDialog::changed);
connect(m_ui->lineEditName, &QLineEdit::textChanged,
this, &RoomPropertiesDialog::changed);
connect(m_ui->lineEditCaption, &QLineEdit::textChanged,
this, &RoomPropertiesDialog::changed);
connect(m_ui->spinBoxWidth, &QSpinBox::valueChanged,
this, &RoomPropertiesDialog::changed);
connect(m_ui->spinBoxHeight, &QSpinBox::valueChanged,
this, &RoomPropertiesDialog::changed);
connect(m_ui->spinBoxSpeed, &QSpinBox::valueChanged,
this, &RoomPropertiesDialog::changed);
connect(m_ui->checkBoxPersistent, &QCheckBox::toggled,
this, &RoomPropertiesDialog::changed);
connect(m_ui->pushButtonCreationCode, &QAbstractButton::clicked,
this, &RoomPropertiesDialog::editCreationCode);
connect(m_ui->roomEditWidget, &RoomEditWidget::snapXChanged,
m_spinBoxSnapX, &QSpinBox::setValue);
connect(m_ui->roomEditWidget, &RoomEditWidget::snapYChanged,
m_spinBoxSnapY, &QSpinBox::setValue);
connect(m_ui->roomEditWidget, &RoomEditWidget::gridEnabledChanged,
m_ui->actionGridEnabled, &QAction::setChecked);
connect(m_ui->roomEditWidget, &RoomEditWidget::isometricGridChanged,
m_ui->actionIsometricGrid, &QAction::setChecked);
connect(m_ui->roomEditWidget, &RoomEditWidget::cursorMoved,
this, &RoomPropertiesDialog::cursorMoved);
}
RoomPropertiesDialog::~RoomPropertiesDialog() = default;
void RoomPropertiesDialog::accept()
{
if (!m_unsavedChanges)
{
QDialog::reject();
return;
}
if (m_room.name != m_ui->lineEditName->text())
{
if (!m_projectModel.rename<Room>(m_room, m_ui->lineEditName->text()))
{
QMessageBox::critical(this, tr("Renaming Room failed!"), tr("Renaming Room failed!"));
return;
}
}
m_room.caption = m_ui->lineEditCaption->text();
m_room.width = m_ui->spinBoxWidth->value();
m_room.height = m_ui->spinBoxHeight->value();
m_room.speed = m_ui->spinBoxSpeed->value();
m_room.persistent = m_ui->checkBoxPersistent->isChecked();
m_room.creationCode = m_creationCode;
m_room.snapX = m_spinBoxSnapX->value();
m_room.snapY = m_spinBoxSnapY->value();
m_room.gridEnabled = m_ui->actionGridEnabled->isChecked();
m_room.isometricGrid = m_ui->actionIsometricGrid->isChecked();
QDialog::accept();
}
void RoomPropertiesDialog::reject()
{
if (!m_unsavedChanges)
{
QDialog::reject();
return;
}
const auto result = QMessageBox::warning(
this,
tr("The Room has been modified."),
tr("Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Save
);
switch (result)
{
case QMessageBox::Save:
accept();
return;
case QMessageBox::Discard:
QDialog::reject();
return;
case QMessageBox::Cancel:
return;
default:
qWarning() << "unexpected dialog result" << result;
}
}
void RoomPropertiesDialog::undo()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void RoomPropertiesDialog::clearInstances()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void RoomPropertiesDialog::shiftInstances()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void RoomPropertiesDialog::sortInstancesX()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void RoomPropertiesDialog::sortInstancesY()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void RoomPropertiesDialog::lockInstances()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void RoomPropertiesDialog::unlockInstances()
{
QMessageBox::warning(this, tr("Not yet implemented"), tr("Not yet implemented"));
}
void RoomPropertiesDialog::editCreationCode()
{
GenericCodeEditorDialog dialog{tr("Room Creation Code"), this};
dialog.setScript(m_creationCode);
if (dialog.exec() == QDialog::Accepted)
{
m_creationCode = dialog.script();
changed();
}
}
void RoomPropertiesDialog::changed()
{
if (!m_unsavedChanges)
{
m_unsavedChanges = true;
updateTitle();
}
}
void RoomPropertiesDialog::roomNameChanged(const Room &room)
{
if (&room != &m_room)
return;
{
QSignalBlocker blocker{m_ui->lineEditName};
m_ui->lineEditName->setText(room.name);
}
updateTitle();
}
void RoomPropertiesDialog::cursorMoved(const QPoint &point)
{
m_labelX->setText(tr("X: %0").arg(point.x()));
m_labelY->setText(tr("Y: %0").arg(point.y()));
}
void RoomPropertiesDialog::updateTitle()
{
setWindowTitle(tr("Room Properties: %0%1")
.arg(m_room.name)
.arg(m_unsavedChanges ? tr("*") : QString{})
);
}

View File

@ -4,6 +4,8 @@
#include <memory>
class QSpinBox;
class QLabel;
namespace Ui { class RoomPropertiesDialog; }
struct Room;
class ProjectTreeModel;
@ -16,6 +18,40 @@ public:
explicit RoomPropertiesDialog(Room &room, ProjectTreeModel &projectModel, QWidget *parent = nullptr);
~RoomPropertiesDialog();
void accept() override;
void reject() override;
private slots:
void undo();
void clearInstances();
void shiftInstances();
void sortInstancesX();
void sortInstancesY();
void lockInstances();
void unlockInstances();
void editCreationCode();
void changed();
void roomNameChanged(const Room &room);
void cursorMoved(const QPoint &point);
private:
void updateTitle();
const std::unique_ptr<Ui::RoomPropertiesDialog> m_ui;
Room &m_room;
ProjectTreeModel &m_projectModel;
QString m_creationCode;
bool m_unsavedChanges{};
QSpinBox * const m_spinBoxSnapX;
QSpinBox * const m_spinBoxSnapY;
QLabel * const m_labelX;
QLabel * const m_labelY;
};

View File

@ -6,20 +6,532 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>921</width>
<height>576</height>
</rect>
</property>
<property name="windowTitle">
<string>Room Properties</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/room-file.png</normaloff>:/qtgameengine/icons/room-file.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="movable">
<bool>false</bool>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<addaction name="actionOk"/>
<addaction name="separator"/>
<addaction name="actionUndo"/>
<addaction name="separator"/>
<addaction name="actionClear"/>
<addaction name="actionShift"/>
<addaction name="actionSortX"/>
<addaction name="actionSortY"/>
<addaction name="actionLock"/>
<addaction name="actionUnlock"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="actionGridEnabled"/>
<addaction name="actionIsometricGrid"/>
<addaction name="separator"/>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="tabPosition">
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabObjects">
<attribute name="title">
<string>&amp;Objects</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
</layout>
</widget>
<widget class="QWidget" name="tabSettings">
<attribute name="title">
<string>&amp;Settings</string>
</attribute>
<layout class="QVBoxLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelName">
<property name="text">
<string>&amp;Name:</string>
</property>
<property name="buddy">
<cstring>lineEditName</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditName"/>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelCaption">
<property name="text">
<string>&amp;Caption for the room:</string>
</property>
<property name="buddy">
<cstring>lineEditCaption</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditCaption"/>
</item>
<item>
<layout class="QFormLayout" name="formLayout2">
<item row="0" column="0">
<widget class="QLabel" name="labelWidth">
<property name="text">
<string>&amp;Width:</string>
</property>
<property name="buddy">
<cstring>spinBoxWidth</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBoxWidth">
<property name="maximum">
<number>2147483647</number>
</property>
<property name="value">
<number>640</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelHeight">
<property name="text">
<string>&amp;Height:</string>
</property>
<property name="buddy">
<cstring>spinBoxHeight</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBoxHeight">
<property name="maximum">
<number>2147483647</number>
</property>
<property name="value">
<number>480</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelSpeed">
<property name="text">
<string>S&amp;peed:</string>
</property>
<property name="buddy">
<cstring>spinBoxSpeed</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="spinBoxSpeed">
<property name="maximum">
<number>2147483647</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxPersistent">
<property name="text">
<string>P&amp;ersistent</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<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>
<widget class="QPushButton" name="pushButtonCreationCode">
<property name="text">
<string>CreationCode</string>
</property>
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/script.png</normaloff>:/qtgameengine/icons/script.png</iconset>
</property>
</widget>
</item>
<item>
<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>
</layout>
</item>
<item>
<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>
</layout>
</widget>
<widget class="QWidget" name="tabTiles">
<attribute name="title">
<string>&amp;Tiles</string>
</attribute>
</widget>
<widget class="QWidget" name="tabBackgrounds">
<attribute name="title">
<string>&amp;Backgrounds</string>
</attribute>
</widget>
<widget class="QWidget" name="tabViews">
<attribute name="title">
<string>&amp;Views</string>
</attribute>
</widget>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7" stretch="1,0">
<item>
<widget class="QScrollArea" name="scrollArea">
<widget class="RoomEditWidget" name="roomEditWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>0</width>
<height>0</height>
</rect>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QStatusBar" name="statusbar"/>
</item>
</layout>
</item>
</layout>
</item>
</layout>
<action name="actionOk">
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/ok.png</normaloff>:/qtgameengine/icons/ok.png</iconset>
</property>
<property name="text">
<string>OK</string>
</property>
<property name="toolTip">
<string>Close the form, saving the changes</string>
</property>
</action>
<action name="actionUndo">
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/undo.png</normaloff>:/qtgameengine/icons/undo.png</iconset>
</property>
<property name="text">
<string>Undo</string>
</property>
<property name="toolTip">
<string>Undo the last changes in the room</string>
</property>
</action>
<action name="actionClear">
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
<property name="text">
<string>Clear</string>
</property>
<property name="toolTip">
<string>Clear all instances from the room</string>
</property>
</action>
<action name="actionShift">
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-right.png</normaloff>:/qtgameengine/icons/arrow-right.png</iconset>
</property>
<property name="text">
<string>Shift</string>
</property>
<property name="toolTip">
<string>Shift all instances by a given amount</string>
</property>
</action>
<action name="actionSortX">
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/sort-x.png</normaloff>:/qtgameengine/icons/sort-x.png</iconset>
</property>
<property name="text">
<string>Sort X</string>
</property>
<property name="toolTip">
<string>Sort all instances by x-coordinate</string>
</property>
</action>
<action name="actionSortY">
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/sort-y.png</normaloff>:/qtgameengine/icons/sort-y.png</iconset>
</property>
<property name="text">
<string>Sort Y</string>
</property>
<property name="toolTip">
<string>Sort all instances by y-coordinate</string>
</property>
</action>
<action name="actionLock">
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/lock.png</normaloff>:/qtgameengine/icons/lock.png</iconset>
</property>
<property name="text">
<string>Lock</string>
</property>
<property name="toolTip">
<string>Lock all instances</string>
</property>
</action>
<action name="actionUnlock">
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/unlock.png</normaloff>:/qtgameengine/icons/unlock.png</iconset>
</property>
<property name="text">
<string>Unlock</string>
</property>
<property name="toolTip">
<string>Unlock all instances</string>
</property>
</action>
<action name="actionGridEnabled">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/grid.png</normaloff>:/qtgameengine/icons/grid.png</iconset>
</property>
<property name="text">
<string>Grid</string>
</property>
<property name="toolTip">
<string>Toggle the showing of the grid</string>
</property>
</action>
<action name="actionIsometricGrid">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/isometric.png</normaloff>:/qtgameengine/icons/isometric.png</iconset>
</property>
<property name="text">
<string>Isometric</string>
</property>
<property name="toolTip">
<string>Turn the grid into an isometric grid</string>
</property>
</action>
<action name="actionShowObjects">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Show Objects</string>
</property>
</action>
<action name="actionShowTiles">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Show Tiles</string>
</property>
</action>
<action name="actionShowBackgrounds">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Show Backgrounds</string>
</property>
</action>
<action name="actionShowForegrounds">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Show Foregrounds</string>
</property>
</action>
<action name="actionShowViews">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show Views</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>RoomEditWidget</class>
<extends>QWidget</extends>
<header>widgets/roomeditwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections/>
<connections>
<connection>
<sender>actionOk</sender>
<signal>triggered()</signal>
<receiver>RoomPropertiesDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>363</x>
<y>224</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -14,7 +14,7 @@
<string>Sound Properties</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/sound-file.png</normaloff>:/qtgameengine/icons/sound-file.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
@ -50,7 +50,7 @@
<string>&amp;Load Sound</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
</widget>
@ -64,7 +64,7 @@
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/run.png</normaloff>:/qtgameengine/icons/run.png</iconset>
</property>
</widget>
@ -78,7 +78,7 @@
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/exit.png</normaloff>:/qtgameengine/icons/exit.png</iconset>
</property>
</widget>
@ -94,7 +94,7 @@
<string>Sa&amp;ve Sound</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
</widget>
@ -292,7 +292,7 @@
<string>&amp;Edit Sound</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/sound.png</normaloff>:/qtgameengine/icons/sound.png</iconset>
</property>
</widget>
@ -325,7 +325,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -14,7 +14,7 @@
<string>Sprite Properties</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/sprite-file.png</normaloff>:/qtgameengine/icons/sprite-file.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,1">
@ -67,7 +67,7 @@
<string>&amp;Load Sprite</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
</widget>
@ -81,7 +81,7 @@
<string>&amp;Save Sprite</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
</widget>
@ -95,7 +95,7 @@
<string>&amp;Edit Sprite</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/edit.png</normaloff>:/qtgameengine/icons/edit.png</iconset>
</property>
</widget>
@ -339,7 +339,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -14,7 +14,7 @@
<string>Time Line Properties</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/timeline-file.png</normaloff>:/qtgameengine/icons/timeline-file.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,1">
@ -61,7 +61,7 @@
<string>&amp;Add</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/add.png</normaloff>:/qtgameengine/icons/add.png</iconset>
</property>
</widget>
@ -75,7 +75,7 @@
<string>&amp;Change</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/replace.png</normaloff>:/qtgameengine/icons/replace.png</iconset>
</property>
</widget>
@ -89,7 +89,7 @@
<string>&amp;Delete</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/delete.png</normaloff>:/qtgameengine/icons/delete.png</iconset>
</property>
</widget>
@ -103,7 +103,7 @@
<string>&amp;Shift</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-right.png</normaloff>:/qtgameengine/icons/arrow-right.png</iconset>
</property>
</widget>
@ -117,7 +117,7 @@
<string>C&amp;lear</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
</widget>
@ -131,7 +131,7 @@
<string>D&amp;uplicate</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/copy.png</normaloff>:/qtgameengine/icons/copy.png</iconset>
</property>
</widget>
@ -158,7 +158,7 @@
<string>S&amp;pread</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/scale.png</normaloff>:/qtgameengine/icons/scale.png</iconset>
</property>
</widget>
@ -172,7 +172,7 @@
<string>&amp;Merge</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/merge.png</normaloff>:/qtgameengine/icons/merge.png</iconset>
</property>
</widget>
@ -201,7 +201,7 @@
<string>Show &amp;Information</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/info.png</normaloff>:/qtgameengine/icons/info.png</iconset>
</property>
</widget>
@ -278,7 +278,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -1,11 +0,0 @@
#pragma once
#include "codeeditordialog.h"
class TriggerConditionDialog : public CodeEditorDialog
{
Q_OBJECT
public:
explicit TriggerConditionDialog(QWidget *parent = nullptr);
};

View File

@ -6,7 +6,7 @@
#include "projectcontainer.h"
#include "models/triggersmodel.h"
#include "triggerconditiondialog.h"
#include "genericcodeeditordialog.h"
TriggersDialog::TriggersDialog(ProjectContainer &project, QWidget *parent) :
QDialog{parent},
@ -66,7 +66,7 @@ TriggersDialog::~TriggersDialog() = default;
void TriggersDialog::openCodeEditor()
{
TriggerConditionDialog dialog{this};
GenericCodeEditorDialog dialog{tr("Trigger condition"), this};
dialog.setScript(m_ui->plainTextEdit->toPlainText());
if (dialog.exec() == QDialog::Accepted)
{

View File

@ -40,7 +40,7 @@
<string>&amp;Load</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
</widget>
@ -54,7 +54,7 @@
<string>&amp;Delete</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/delete.png</normaloff>:/qtgameengine/icons/delete.png</iconset>
</property>
</widget>
@ -68,7 +68,7 @@
<string>&amp;Add</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/add.png</normaloff>:/qtgameengine/icons/add.png</iconset>
</property>
</widget>
@ -82,7 +82,7 @@
<string>&amp;Clear</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
</widget>
@ -96,7 +96,7 @@
<string>&amp;Save</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
</widget>
@ -246,7 +246,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -14,7 +14,7 @@
<string>User-Defined Constants</string>
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/constants.png</normaloff>:/qtgameengine/icons/constants.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,0">
@ -39,7 +39,7 @@
<string>&amp;Insert</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/add.png</normaloff>:/qtgameengine/icons/add.png</iconset>
</property>
</widget>
@ -53,7 +53,7 @@
<string>&amp;Sort</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/sort.png</normaloff>:/qtgameengine/icons/sort.png</iconset>
</property>
</widget>
@ -67,7 +67,7 @@
<string>&amp;Delete</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/delete.png</normaloff>:/qtgameengine/icons/delete.png</iconset>
</property>
</widget>
@ -81,7 +81,7 @@
<string>&amp;Load</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
</widget>
@ -95,7 +95,7 @@
<string>&amp;Up</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-up.png</normaloff>:/qtgameengine/icons/arrow-up.png</iconset>
</property>
</widget>
@ -109,7 +109,7 @@
<string>&amp;Add</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/add.png</normaloff>:/qtgameengine/icons/add.png</iconset>
</property>
</widget>
@ -123,7 +123,7 @@
<string>&amp;Clear</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
</widget>
@ -137,7 +137,7 @@
<string>Do&amp;wn</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/arrow-down.png</normaloff>:/qtgameengine/icons/arrow-down.png</iconset>
</property>
</widget>
@ -151,7 +151,7 @@
<string>Sa&amp;ve</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../../../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
</widget>
@ -174,7 +174,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -55,12 +55,10 @@ MainWindow::MainWindow(const QString &filePath, QWidget *parent) :
{
m_ui->setupUi(this);
{
QList<int> sizes;
sizes.append(0.5 * m_ui->splitter->width());
sizes.append(0.5 * m_ui->splitter->width());
m_ui->splitter->setSizes(sizes);
}
m_ui->splitter->setSizes({
m_ui->splitter->width() / 2,
m_ui->splitter->width() / 2
});
m_ui->actionNew->setShortcut(QKeySequence::New);
m_ui->actionOpen->setShortcut(QKeySequence::Open);

View File

@ -264,7 +264,7 @@
</widget>
<action name="actionNew">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/new.png</normaloff>:/qtgameengine/icons/new.png</iconset>
</property>
<property name="text">
@ -273,7 +273,7 @@
</action>
<action name="actionOpen">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/open.png</normaloff>:/qtgameengine/icons/open.png</iconset>
</property>
<property name="text">
@ -282,7 +282,7 @@
</action>
<action name="actionSave">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/save.png</normaloff>:/qtgameengine/icons/save.png</iconset>
</property>
<property name="text">
@ -291,7 +291,7 @@
</action>
<action name="actionSaveAs">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/save-as.png</normaloff>:/qtgameengine/icons/save-as.png</iconset>
</property>
<property name="text">
@ -300,7 +300,7 @@
</action>
<action name="actionCreateExecutable">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/create-executable.png</normaloff>:/qtgameengine/icons/create-executable.png</iconset>
</property>
<property name="text">
@ -309,7 +309,7 @@
</action>
<action name="actionPublishGame">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/publish-game.png</normaloff>:/qtgameengine/icons/publish-game.png</iconset>
</property>
<property name="text">
@ -318,7 +318,7 @@
</action>
<action name="actionImportResources">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/import-resources.png</normaloff>:/qtgameengine/icons/import-resources.png</iconset>
</property>
<property name="text">
@ -327,7 +327,7 @@
</action>
<action name="actionExportResources">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/export-resources.png</normaloff>:/qtgameengine/icons/export-resources.png</iconset>
</property>
<property name="text">
@ -347,7 +347,7 @@
</action>
<action name="actionPreferences">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/preferences.png</normaloff>:/qtgameengine/icons/preferences.png</iconset>
</property>
<property name="text">
@ -359,7 +359,7 @@
</action>
<action name="actionExit">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/exit.png</normaloff>:/qtgameengine/icons/exit.png</iconset>
</property>
<property name="text">
@ -379,7 +379,7 @@
</action>
<action name="actionCreate">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/create.png</normaloff>:/qtgameengine/icons/create.png</iconset>
</property>
<property name="text">
@ -388,7 +388,7 @@
</action>
<action name="actionDuplicate">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/duplicate.png</normaloff>:/qtgameengine/icons/duplicate.png</iconset>
</property>
<property name="text">
@ -400,7 +400,7 @@
</action>
<action name="actionCreateGroup">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/create-group.png</normaloff>:/qtgameengine/icons/create-group.png</iconset>
</property>
<property name="text">
@ -414,7 +414,7 @@
</action>
<action name="actionDelete">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/delete.png</normaloff>:/qtgameengine/icons/delete.png</iconset>
</property>
<property name="text">
@ -423,7 +423,7 @@
</action>
<action name="actionRename">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/rename.png</normaloff>:/qtgameengine/icons/rename.png</iconset>
</property>
<property name="text">
@ -432,7 +432,7 @@
</action>
<action name="actionProperties">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/properties.png</normaloff>:/qtgameengine/icons/properties.png</iconset>
</property>
<property name="text">
@ -444,7 +444,7 @@
</action>
<action name="actionFindResource">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/find.png</normaloff>:/qtgameengine/icons/find.png</iconset>
</property>
<property name="text">
@ -463,7 +463,7 @@
</action>
<action name="actionShowObjectInformation">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/object-file.png</normaloff>:/qtgameengine/icons/object-file.png</iconset>
</property>
<property name="text">
@ -472,7 +472,7 @@
</action>
<action name="actionCreateSprite">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/sprite.png</normaloff>:/qtgameengine/icons/sprite.png</iconset>
</property>
<property name="text">
@ -484,7 +484,7 @@
</action>
<action name="actionCreateSound">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/sound.png</normaloff>:/qtgameengine/icons/sound.png</iconset>
</property>
<property name="text">
@ -496,7 +496,7 @@
</action>
<action name="actionCreateBackground">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/background.png</normaloff>:/qtgameengine/icons/background.png</iconset>
</property>
<property name="text">
@ -508,7 +508,7 @@
</action>
<action name="actionCreatePath">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/path.png</normaloff>:/qtgameengine/icons/path.png</iconset>
</property>
<property name="text">
@ -520,7 +520,7 @@
</action>
<action name="actionCreateScript">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/script.png</normaloff>:/qtgameengine/icons/script.png</iconset>
</property>
<property name="text">
@ -532,7 +532,7 @@
</action>
<action name="actionCreateFont">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/font.png</normaloff>:/qtgameengine/icons/font.png</iconset>
</property>
<property name="text">
@ -544,7 +544,7 @@
</action>
<action name="actionCreateTimeLine">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/timeline.png</normaloff>:/qtgameengine/icons/timeline.png</iconset>
</property>
<property name="text">
@ -556,7 +556,7 @@
</action>
<action name="actionCreateObject">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/object.png</normaloff>:/qtgameengine/icons/object.png</iconset>
</property>
<property name="text">
@ -568,7 +568,7 @@
</action>
<action name="actionCreateRoom">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/room.png</normaloff>:/qtgameengine/icons/room.png</iconset>
</property>
<property name="text">
@ -580,7 +580,7 @@
</action>
<action name="actionGameInformation">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/game-information.png</normaloff>:/qtgameengine/icons/game-information.png</iconset>
</property>
<property name="text">
@ -592,7 +592,7 @@
</action>
<action name="actionGlobalGameSettings">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/global-game-settings.png</normaloff>:/qtgameengine/icons/global-game-settings.png</iconset>
</property>
<property name="text">
@ -604,7 +604,7 @@
</action>
<action name="actionExtensionPackages">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/extension-packages.png</normaloff>:/qtgameengine/icons/extension-packages.png</iconset>
</property>
<property name="text">
@ -616,7 +616,7 @@
</action>
<action name="actionDefineConstants">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/constants.png</normaloff>:/qtgameengine/icons/constants.png</iconset>
</property>
<property name="text">
@ -644,7 +644,7 @@
</action>
<action name="actionRunNormally">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/run.png</normaloff>:/qtgameengine/icons/run.png</iconset>
</property>
<property name="text">
@ -656,7 +656,7 @@
</action>
<action name="actionRunInDebugMode">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/debug.png</normaloff>:/qtgameengine/icons/debug.png</iconset>
</property>
<property name="text">
@ -673,7 +673,7 @@
</action>
<action name="actionContents">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/help.png</normaloff>:/qtgameengine/icons/help.png</iconset>
</property>
<property name="text">
@ -783,7 +783,7 @@
</action>
<action name="actionTile">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/tile.png</normaloff>:/qtgameengine/icons/tile.png</iconset>
</property>
<property name="text">
@ -792,7 +792,7 @@
</action>
<action name="actionCascade">
<property name="icon">
<iconset resource="resources.qrc">
<iconset resource="../../resources.qrc">
<normaloff>:/qtgameengine/icons/cascade.png</normaloff>:/qtgameengine/icons/cascade.png</iconset>
</property>
<property name="text">
@ -827,7 +827,7 @@
</action>
</widget>
<resources>
<include location="resources.qrc"/>
<include location="../../resources.qrc"/>
</resources>
<connections>
<connection>

View File

@ -2,6 +2,7 @@
#include <QDebug>
#include <QPainter>
#include <QPaintEvent>
#include <QMouseEvent>
#include <algorithm>
@ -24,27 +25,27 @@ void PathPointsWidget::setPoints(std::vector<Path::Point> *points)
update();
}
void PathPointsWidget::setShowGrid(bool showGrid)
void PathPointsWidget::setSnapX(int snapX)
{
if (m_showGrid == showGrid)
if (m_snapX == snapX)
return;
emit showGridChanged(m_showGrid = showGrid);
emit snapXChanged(m_snapX = snapX);
update();
}
void PathPointsWidget::setGridX(int gridX)
void PathPointsWidget::setSnapY(int snapY)
{
if (m_gridX == gridX)
if (m_snapY == snapY)
return;
emit gridXChanged(m_gridX = gridX);
emit snapYChanged(m_snapY = snapY);
update();
}
void PathPointsWidget::setGridY(int gridY)
void PathPointsWidget::setGridEnabled(bool gridEnabled)
{
if (m_gridY == gridY)
if (m_gridEnabled == gridEnabled)
return;
emit gridYChanged(m_gridY = gridY);
emit gridEnabledChanged(m_gridEnabled = gridEnabled);
update();
}
@ -64,28 +65,36 @@ void PathPointsWidget::setSelectedIndex(const std::optional<std::size_t> &select
update();
}
void PathPointsWidget::setGridRole(QPalette::ColorRole gridRole)
{
if (gridRole == m_gridRole)
return;
m_gridRole = gridRole;
update();
}
void PathPointsWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
if (m_showGrid)
if (m_gridEnabled)
{
if (!m_gridBrush || m_gridBrush->gridX != m_gridX || m_gridBrush->gridY != m_gridY)
if (!m_gridBrush || m_gridBrush->snapX != m_snapX || m_gridBrush->snapY != m_snapY)
{
QPixmap pixmap{m_gridX, m_gridY};
QPixmap pixmap{m_snapX, m_snapY};
{
QPainter painter{&pixmap};
painter.setPen(palette().color(m_gridRole));
painter.drawLine(0, 0, m_gridX, 0);
painter.drawLine(0, 0, 0, m_gridY);
painter.drawLine(0, 0, m_snapX, 0);
painter.drawLine(0, 0, 0, m_snapY);
painter.fillRect(1, 1, m_gridX - 1, m_gridY - 1, palette().color(backgroundRole()));
painter.fillRect(1, 1, m_snapX - 1, m_snapY - 1, palette().color(backgroundRole()));
}
m_gridBrush = GridBrush {
.gridX = m_gridX,
.gridY = m_gridY,
.snapX = m_snapX,
.snapY = m_snapY,
.brush = QBrush{std:: move(pixmap)}
};
}
@ -216,10 +225,8 @@ void PathPointsWidget::mouseMoveEvent(QMouseEvent *event)
QPoint PathPointsWidget::snapPoint(const QPoint &point) const
{
if (!m_showGrid)
return point;
return QPoint{
(point.x() + (m_gridX / 2)) / m_gridX * m_gridX,
(point.y() + (m_gridY / 2)) / m_gridY * m_gridY,
m_snapX > 1 ? ((point.x() + (m_snapX / 2)) / m_snapX * m_snapX) : point.x(),
m_snapY > 1 ? ((point.y() + (m_snapY / 2)) / m_snapY * m_snapY) : point.y(),
};
}

View File

@ -11,9 +11,9 @@
class PathPointsWidget : public QWidget
{
Q_OBJECT
Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid NOTIFY showGridChanged)
Q_PROPERTY(int gridX READ gridX WRITE setGridX NOTIFY gridXChanged)
Q_PROPERTY(int gridY READ gridY WRITE setGridY NOTIFY gridYChanged)
Q_PROPERTY(int snapX READ snapX WRITE setSnapX NOTIFY snapXChanged)
Q_PROPERTY(int snapY READ snapY WRITE setSnapY NOTIFY snapYChanged)
Q_PROPERTY(bool gridEnabled READ gridEnabled WRITE setGridEnabled NOTIFY gridEnabledChanged)
Q_PROPERTY(bool closed READ closed WRITE setClosed NOTIFY closedChanged)
public:
@ -22,14 +22,14 @@ public:
void setPoints(std::vector<Path::Point> *points);
bool showGrid() const { return m_showGrid; }
void setShowGrid(bool showGrid);
int snapX() const { return m_snapX; }
void setSnapX(int snapX);
int gridX() const { return m_gridX; }
void setGridX(int gridX);
int snapY() const { return m_snapY; }
void setSnapY(int snapY);
int gridY() const { return m_gridY; }
void setGridY(int gridY);
bool gridEnabled() const { return m_gridEnabled; }
void setGridEnabled(bool gridEnabled);
bool closed() const { return m_closed; }
void setClosed(bool closed);
@ -38,12 +38,12 @@ public:
void setSelectedIndex(const std::optional<std::size_t> &selectedIndex);
QPalette::ColorRole gridRole() const { return m_gridRole; }
void setGridRole(QPalette::ColorRole gridRole) { if (gridRole == m_gridRole) return; m_gridRole = gridRole; update(); }
void setGridRole(QPalette::ColorRole gridRole);
signals:
void showGridChanged(bool showGrid);
void gridXChanged(int gridX);
void gridYChanged(int gridY);
void snapXChanged(int snapX);
void snapYChanged(int snapY);
void gridEnabledChanged(bool gridEnabled);
void closedChanged(bool closed);
void selectedIndexChanged(const std::optional<std::size_t> &selectedIndex);
@ -63,9 +63,9 @@ private:
std::vector<Path::Point> *m_points{};
bool m_showGrid{true};
int m_gridX{16};
int m_gridY{16};
int m_snapX{16};
int m_snapY{16};
bool m_gridEnabled{true};
bool m_closed{true};
@ -73,8 +73,8 @@ private:
std::optional<std::size_t> m_dragIndex;
struct GridBrush {
int gridX;
int gridY;
int snapX;
int snapY;
QBrush brush;
};

View File

@ -0,0 +1,112 @@
#include "roomeditwidget.h"
#include <QDebug>
#include <QPainter>
#include <QPaintEvent>
#include <QMouseEvent>
RoomEditWidget::RoomEditWidget(QWidget *parent) :
QWidget{parent}
{
setBackgroundRole(QPalette::Light);
setMouseTracking(true);
setFixedSize(640, 480);
}
void RoomEditWidget::setSnapX(int snapX)
{
if (m_snapX == snapX)
return;
emit snapXChanged(m_snapX = snapX);
update();
}
void RoomEditWidget::setSnapY(int snapY)
{
if (m_snapY == snapY)
return;
emit snapYChanged(m_snapY = snapY);
update();
}
void RoomEditWidget::setGridEnabled(bool gridEnabled)
{
if (m_gridEnabled == gridEnabled)
return;
emit gridEnabledChanged(m_gridEnabled = gridEnabled);
update();
}
void RoomEditWidget::setIsometricGrid(bool isometricGrid)
{
if (m_isometricGrid == isometricGrid)
return;
emit isometricGridChanged(m_isometricGrid = isometricGrid);
update();
}
void RoomEditWidget::setGridRole(QPalette::ColorRole gridRole)
{
if (gridRole == m_gridRole)
return;
m_gridRole = gridRole;
update();
}
void RoomEditWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
if (m_gridEnabled)
{
if (!m_gridBrush || m_gridBrush->snapX != m_snapX || m_gridBrush->snapY != m_snapY)
{
QPixmap pixmap{m_snapX, m_snapY};
{
QPainter painter{&pixmap};
painter.setPen(palette().color(m_gridRole));
painter.drawLine(0, 0, m_snapX, 0);
painter.drawLine(0, 0, 0, m_snapY);
painter.fillRect(1, 1, m_snapX - 1, m_snapY - 1, palette().color(backgroundRole()));
}
m_gridBrush = GridBrush {
.snapX = m_snapX,
.snapY = m_snapY,
.brush = QBrush{std:: move(pixmap)}
};
}
}
else
m_gridBrush = std::nullopt;
QPainter painter{this};
painter.fillRect(rect(), m_gridBrush ? m_gridBrush->brush : palette().color(backgroundRole()));
}
void RoomEditWidget::mousePressEvent(QMouseEvent *event)
{
QWidget::mousePressEvent(event);
}
void RoomEditWidget::mouseReleaseEvent(QMouseEvent *event)
{
QWidget::mouseReleaseEvent(event);
}
void RoomEditWidget::mouseMoveEvent(QMouseEvent *event)
{
QWidget::mouseMoveEvent(event);
emit cursorMoved(snapPoint(event->pos()));
}
QPoint RoomEditWidget::snapPoint(const QPoint &point) const
{
return QPoint{
m_snapX > 1 ? ((point.x() + (m_snapX / 2)) / m_snapX * m_snapX) : point.x(),
m_snapY > 1 ? ((point.y() + (m_snapY / 2)) / m_snapY * m_snapY) : point.y(),
};
}

View File

@ -0,0 +1,65 @@
#pragma once
#include <QWidget>
#include <QPalette>
#include <optional>
class RoomEditWidget : public QWidget
{
Q_OBJECT
Q_PROPERTY(int snapX READ snapX WRITE setSnapX NOTIFY snapXChanged)
Q_PROPERTY(int snapY READ snapY WRITE setSnapY NOTIFY snapYChanged)
Q_PROPERTY(bool gridEnabled READ gridEnabled WRITE setGridEnabled NOTIFY gridEnabledChanged)
Q_PROPERTY(bool isometricGrid READ isometricGrid WRITE setIsometricGrid NOTIFY isometricGridChanged)
public:
explicit RoomEditWidget(QWidget *parent = nullptr);
int snapX() const { return m_snapX; }
void setSnapX(int snapX);
int snapY() const { return m_snapY; }
void setSnapY(int snapY);
bool gridEnabled() const { return m_gridEnabled; }
void setGridEnabled(bool gridEnabled);
bool isometricGrid() const { return m_isometricGrid; }
void setIsometricGrid(bool isometricGrid);
QPalette::ColorRole gridRole() const { return m_gridRole; }
void setGridRole(QPalette::ColorRole gridRole);
signals:
void snapXChanged(int snapX);
void snapYChanged(int snapY);
void gridEnabledChanged(bool gridEnabled);
void isometricGridChanged(bool isometricGrid);
void cursorMoved(const QPoint &point);
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
private:
QPoint snapPoint(const QPoint &point) const;
int m_snapX{16};
int m_snapY{16};
bool m_gridEnabled{true};
bool m_isometricGrid{false};
struct GridBrush {
int snapX;
int snapY;
QBrush brush;
};
std::optional<GridBrush> m_gridBrush;
QPalette::ColorRole m_gridRole{QPalette::Dark};
};

View File

@ -222,7 +222,10 @@ QDataStream &operator<<(QDataStream &ds, const Path &path)
<< path.points
<< path.type
<< path.closed
<< path.precision;
<< path.precision
<< path.snapX
<< path.snapY
<< path.gridEnabled;
return ds;
}
@ -232,7 +235,10 @@ QDataStream &operator>>(QDataStream &ds, Path &path)
>> path.points
>> path.type
>> path.closed
>> path.precision;
>> path.precision
>> path.snapX
>> path.snapY
>> path.gridEnabled;
return ds;
}
@ -318,13 +324,33 @@ QDataStream &operator>>(QDataStream &ds, Object &object)
QDataStream &operator<<(QDataStream &ds, const Room &room)
{
ds << room.name;
ds << room.name
<< room.caption
<< room.width
<< room.height
<< room.speed
<< room.persistent
<< room.creationCode
<< room.snapX
<< room.snapY
<< room.gridEnabled
<< room.isometricGrid;
return ds;
}
QDataStream &operator>>(QDataStream &ds, Room &room)
{
ds >> room.name;
ds >> room.name
>> room.caption
>> room.width
>> room.height
>> room.speed
>> room.persistent
>> room.creationCode
>> room.snapX
>> room.snapY
>> room.gridEnabled
>> room.isometricGrid;
return ds;
}

View File

@ -63,6 +63,9 @@ struct Path
Type type{Type::Straight};
bool closed{true};
int precision{4};
int snapX{16};
int snapY{16};
bool gridEnabled{true};
};
struct Script
@ -127,6 +130,16 @@ struct Object
struct Room
{
QString name;
QString caption;
int width{640};
int height{480};
int speed{30};
bool persistent{};
QString creationCode;
int snapX{16};
int snapY{16};
bool gridEnabled{true};
bool isometricGrid{};
};
struct ProjectContainer