Added functionality to manage time lines, objects and rooms too
This commit is contained in:
@ -11,8 +11,11 @@ HEADERS += \
|
||||
dialogs/fontpropertiesdialog.h \
|
||||
dialogs/imageeditordialog.h \
|
||||
dialogs/objectinformationdialog.h \
|
||||
dialogs/objectpropertiesdialog.h \
|
||||
dialogs/pathpropertiesdialog.h \
|
||||
dialogs/roompropertiesdialog.h \
|
||||
dialogs/scriptpropertiesdialog.h \
|
||||
dialogs/timelinepropertiesdialog.h \
|
||||
futurecpp.h \
|
||||
jshighlighter.h \
|
||||
mainwindow.h \
|
||||
@ -34,8 +37,11 @@ SOURCES += main.cpp \
|
||||
dialogs/fontpropertiesdialog.cpp \
|
||||
dialogs/imageeditordialog.cpp \
|
||||
dialogs/objectinformationdialog.cpp \
|
||||
dialogs/objectpropertiesdialog.cpp \
|
||||
dialogs/pathpropertiesdialog.cpp \
|
||||
dialogs/roompropertiesdialog.cpp \
|
||||
dialogs/scriptpropertiesdialog.cpp \
|
||||
dialogs/timelinepropertiesdialog.cpp \
|
||||
jshighlighter.cpp \
|
||||
mainwindow.cpp \
|
||||
projectcontainer.cpp \
|
||||
@ -55,8 +61,11 @@ FORMS += \
|
||||
dialogs/fontpropertiesdialog.ui \
|
||||
dialogs/imageeditordialog.ui \
|
||||
dialogs/objectinformationdialog.ui \
|
||||
dialogs/objectpropertiesdialog.ui \
|
||||
dialogs/pathpropertiesdialog.ui \
|
||||
dialogs/roompropertiesdialog.ui \
|
||||
dialogs/scriptpropertiesdialog.ui \
|
||||
dialogs/timelinepropertiesdialog.ui \
|
||||
mainwindow.ui \
|
||||
dialogs/backgroundpropertiesdialog.ui \
|
||||
dialogs/editspritedialog.ui \
|
||||
|
@ -51,7 +51,7 @@ void BackgroundPropertiesDialog::accept()
|
||||
{
|
||||
if (m_background.name != m_ui->lineEditName->text())
|
||||
{
|
||||
if (!m_projectModel.renameBackground(m_background, m_ui->lineEditName->text()))
|
||||
if (!m_projectModel.rename<Background>(m_background, m_ui->lineEditName->text()))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Renaming Background failed!"), tr("Renaming Background failed!"));
|
||||
return;
|
||||
|
@ -66,7 +66,7 @@ void FontPropertiesDialog::accept()
|
||||
{
|
||||
if (m_font.name != m_ui->lineEditName->text())
|
||||
{
|
||||
if (!m_projectModel.renameFont(m_font, m_ui->lineEditName->text()))
|
||||
if (!m_projectModel.rename<Font>(m_font, m_ui->lineEditName->text()))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Renaming Font failed!"), tr("Renaming Font failed!"));
|
||||
return;
|
||||
|
11
dialogs/objectpropertiesdialog.cpp
Normal file
11
dialogs/objectpropertiesdialog.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "objectpropertiesdialog.h"
|
||||
#include "ui_objectpropertiesdialog.h"
|
||||
|
||||
ObjectPropertiesDialog::ObjectPropertiesDialog(Object &object, ProjectTreeModel &projectModel, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::ObjectPropertiesDialog>()}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
ObjectPropertiesDialog::~ObjectPropertiesDialog() = default;
|
21
dialogs/objectpropertiesdialog.h
Normal file
21
dialogs/objectpropertiesdialog.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class ObjectPropertiesDialog; }
|
||||
struct Object;
|
||||
class ProjectTreeModel;
|
||||
|
||||
class ObjectPropertiesDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ObjectPropertiesDialog(Object &object, ProjectTreeModel &projectModel, QWidget *parent = nullptr);
|
||||
~ObjectPropertiesDialog();
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::ObjectPropertiesDialog> m_ui;
|
||||
};
|
25
dialogs/objectpropertiesdialog.ui
Normal file
25
dialogs/objectpropertiesdialog.ui
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ObjectPropertiesDialog</class>
|
||||
<widget class="QDialog" name="ObjectPropertiesDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Object Properties</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/qtgameengine/icons/object-file.png</normaloff>:/qtgameengine/icons/object-file.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -55,7 +55,7 @@ void PathPropertiesDialog::accept()
|
||||
{
|
||||
if (m_path.name != m_ui->lineEditName->text())
|
||||
{
|
||||
if (!m_projectModel.renamePath(m_path, m_ui->lineEditName->text()))
|
||||
if (!m_projectModel.rename<Path>(m_path, m_ui->lineEditName->text()))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Renaming Path failed!"), tr("Renaming Path failed!"));
|
||||
return;
|
||||
|
11
dialogs/roompropertiesdialog.cpp
Normal file
11
dialogs/roompropertiesdialog.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "roompropertiesdialog.h"
|
||||
#include "ui_roompropertiesdialog.h"
|
||||
|
||||
RoomPropertiesDialog::RoomPropertiesDialog(Room &room, ProjectTreeModel &projectModel, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::RoomPropertiesDialog>()}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
RoomPropertiesDialog::~RoomPropertiesDialog() = default;
|
21
dialogs/roompropertiesdialog.h
Normal file
21
dialogs/roompropertiesdialog.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class RoomPropertiesDialog; }
|
||||
struct Room;
|
||||
class ProjectTreeModel;
|
||||
|
||||
class RoomPropertiesDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RoomPropertiesDialog(Room &room, ProjectTreeModel &projectModel, QWidget *parent = nullptr);
|
||||
~RoomPropertiesDialog();
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::RoomPropertiesDialog> m_ui;
|
||||
};
|
25
dialogs/roompropertiesdialog.ui
Normal file
25
dialogs/roompropertiesdialog.ui
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RoomPropertiesDialog</class>
|
||||
<widget class="QDialog" name="RoomPropertiesDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Room Properties</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/qtgameengine/icons/room-file.png</normaloff>:/qtgameengine/icons/room-file.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -76,7 +76,7 @@ void ScriptPropertiesDialog::accept()
|
||||
{
|
||||
if (m_script.name != m_lineEditName->text())
|
||||
{
|
||||
if (!m_projectModel.renameScript(m_script, m_lineEditName->text()))
|
||||
if (!m_projectModel.rename<Script>(m_script, m_lineEditName->text()))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Renaming Script failed!"), tr("Renaming Script failed!"));
|
||||
return;
|
||||
|
@ -90,7 +90,7 @@ void SoundPropertiesDialog::accept()
|
||||
{
|
||||
if (m_sound.name != m_ui->lineEditName->text())
|
||||
{
|
||||
if (!m_projectModel.renameSound(m_sound, m_ui->lineEditName->text()))
|
||||
if (!m_projectModel.rename<Sound>(m_sound, m_ui->lineEditName->text()))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Renaming Sound failed!"), tr("Renaming Sound failed!"));
|
||||
return;
|
||||
|
@ -63,7 +63,7 @@ void SpritePropertiesDialog::accept()
|
||||
{
|
||||
if (m_sprite.name != m_ui->lineEditName->text())
|
||||
{
|
||||
if (!m_projectModel.renameSprite(m_sprite, m_ui->lineEditName->text()))
|
||||
if (!m_projectModel.rename<Sprite>(m_sprite, m_ui->lineEditName->text()))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Renaming Sprite failed!"), tr("Renaming Sprite failed!"));
|
||||
return;
|
||||
|
11
dialogs/timelinepropertiesdialog.cpp
Normal file
11
dialogs/timelinepropertiesdialog.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "timelinepropertiesdialog.h"
|
||||
#include "ui_timelinepropertiesdialog.h"
|
||||
|
||||
TimeLinePropertiesDialog::TimeLinePropertiesDialog(TimeLine &timeLine, ProjectTreeModel &projectModel, QWidget *parent) :
|
||||
QDialog{parent},
|
||||
m_ui{std::make_unique<Ui::TimeLinePropertiesDialog>()}
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
TimeLinePropertiesDialog::~TimeLinePropertiesDialog() = default;
|
21
dialogs/timelinepropertiesdialog.h
Normal file
21
dialogs/timelinepropertiesdialog.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui { class TimeLinePropertiesDialog; }
|
||||
struct TimeLine;
|
||||
class ProjectTreeModel;
|
||||
|
||||
class TimeLinePropertiesDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TimeLinePropertiesDialog(TimeLine &timeLine, ProjectTreeModel &projectModel, QWidget *parent = nullptr);
|
||||
~TimeLinePropertiesDialog();
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::TimeLinePropertiesDialog> m_ui;
|
||||
};
|
25
dialogs/timelinepropertiesdialog.ui
Normal file
25
dialogs/timelinepropertiesdialog.ui
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TimeLinePropertiesDialog</class>
|
||||
<widget class="QDialog" name="TimeLinePropertiesDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Time Line Properties</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/qtgameengine/icons/timeline-file.png</normaloff>:/qtgameengine/icons/timeline-file.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
BIN
icons/room-file.png
Normal file
BIN
icons/room-file.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
icons/timeline-file.png
Normal file
BIN
icons/timeline-file.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
684
mainwindow.cpp
684
mainwindow.cpp
@ -14,12 +14,29 @@
|
||||
#include "dialogs/pathpropertiesdialog.h"
|
||||
#include "dialogs/scriptpropertiesdialog.h"
|
||||
#include "dialogs/fontpropertiesdialog.h"
|
||||
#include "dialogs/timelinepropertiesdialog.h"
|
||||
#include "dialogs/objectpropertiesdialog.h"
|
||||
#include "dialogs/roompropertiesdialog.h"
|
||||
#include "dialogs/preferencesdialog.h"
|
||||
#include "dialogs/gameinformationdialog.h"
|
||||
#include "dialogs/globalgamesettingsdialog.h"
|
||||
#include "dialogs/extensionpackagesdialog.h"
|
||||
#include "dialogs/objectinformationdialog.h"
|
||||
|
||||
namespace {
|
||||
template<typename T> struct PropertiesDialogForDetail;
|
||||
template<> struct PropertiesDialogForDetail<Sprite> { using Type = SpritePropertiesDialog; };
|
||||
template<> struct PropertiesDialogForDetail<Sound> { using Type = SoundPropertiesDialog; };
|
||||
template<> struct PropertiesDialogForDetail<Background> { using Type = BackgroundPropertiesDialog; };
|
||||
template<> struct PropertiesDialogForDetail<Path> { using Type = PathPropertiesDialog; };
|
||||
template<> struct PropertiesDialogForDetail<Script> { using Type = ScriptPropertiesDialog; };
|
||||
template<> struct PropertiesDialogForDetail<Font> { using Type = FontPropertiesDialog; };
|
||||
template<> struct PropertiesDialogForDetail<TimeLine> { using Type = TimeLinePropertiesDialog; };
|
||||
template<> struct PropertiesDialogForDetail<Object> { using Type = ObjectPropertiesDialog; };
|
||||
template<> struct PropertiesDialogForDetail<Room> { using Type = RoomPropertiesDialog; };
|
||||
template<typename T> using PropertiesDialogFor = typename PropertiesDialogForDetail<T>::Type;
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow{parent},
|
||||
m_ui{std::make_unique<Ui::MainWindow>()},
|
||||
@ -78,12 +95,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(m_ui->actionProperties, &QAction::triggered, this, &MainWindow::showProperties);
|
||||
connect(m_ui->actionFindResource, &QAction::triggered, this, &MainWindow::findResource);
|
||||
connect(m_ui->actionShowObjectInformation, &QAction::triggered, this, &MainWindow::showObjectInformation);
|
||||
connect(m_ui->actionCreateSprite, &QAction::triggered, this, &MainWindow::createSprite);
|
||||
connect(m_ui->actionCreateSound, &QAction::triggered, this, &MainWindow::createSound);
|
||||
connect(m_ui->actionCreateBackground, &QAction::triggered, this, &MainWindow::createBackground);
|
||||
connect(m_ui->actionCreatePath, &QAction::triggered, this, &MainWindow::createPath);
|
||||
connect(m_ui->actionCreateScript, &QAction::triggered, this, &MainWindow::createScript);
|
||||
connect(m_ui->actionCreateFont, &QAction::triggered, this, &MainWindow::createFont);
|
||||
connect(m_ui->actionCreateSprite, &QAction::triggered, this, &MainWindow::createFor<Sprite>);
|
||||
connect(m_ui->actionCreateSound, &QAction::triggered, this, &MainWindow::createFor<Sound>);
|
||||
connect(m_ui->actionCreateBackground, &QAction::triggered, this, &MainWindow::createFor<Background>);
|
||||
connect(m_ui->actionCreatePath, &QAction::triggered, this, &MainWindow::createFor<Path>);
|
||||
connect(m_ui->actionCreateScript, &QAction::triggered, this, &MainWindow::createFor<Script>);
|
||||
connect(m_ui->actionCreateFont, &QAction::triggered, this, &MainWindow::createFor<Font>);
|
||||
connect(m_ui->actionCreateTimeLine, &QAction::triggered, this, &MainWindow::createFor<TimeLine>);
|
||||
connect(m_ui->actionCreateObject, &QAction::triggered, this, &MainWindow::createFor<Object>);
|
||||
connect(m_ui->actionCreateRoom, &QAction::triggered, this, &MainWindow::createFor<Room>);
|
||||
connect(m_ui->actionGameInformation, &QAction::triggered, this, &MainWindow::showGameInformation);
|
||||
connect(m_ui->actionGlobalGameSettings, &QAction::triggered, this, &MainWindow::showGlobalGameSettings);
|
||||
connect(m_ui->actionExtensionPackages, &QAction::triggered, this, &MainWindow::showExtensionPackages);
|
||||
@ -180,287 +200,25 @@ void MainWindow::contextMenuRequested(const QPoint &pos)
|
||||
|
||||
void MainWindow::doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
switch (m_projectTreeModel->nodeType(index))
|
||||
if (m_projectTreeModel->nodeType(index) == ProjectTreeModel::NodeType::Root)
|
||||
{
|
||||
case ProjectTreeModel::NodeType::Root:
|
||||
if (index == m_projectTreeModel->gameInformationRoot())
|
||||
showGameInformation();
|
||||
else if (index == m_projectTreeModel->globalGameSettingsRoot())
|
||||
showGlobalGameSettings();
|
||||
else if (index == m_projectTreeModel->extensionPackagesRoot())
|
||||
showExtensionPackages();
|
||||
break;
|
||||
case ProjectTreeModel::NodeType::Sprite:
|
||||
{
|
||||
auto sprite = m_projectTreeModel->getSprite(index);
|
||||
if (!sprite)
|
||||
break;
|
||||
|
||||
if (const auto iter = m_spritePropertiesWindows.find(sprite); iter != std::cend(m_spritePropertiesWindows))
|
||||
{
|
||||
m_ui->mdiArea->setActiveSubWindow(iter->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dialog = new SpritePropertiesDialog{*sprite, *m_projectTreeModel};
|
||||
auto subwindow = m_ui->mdiArea->addSubWindow(dialog);
|
||||
auto action = m_ui->menuWindow->addAction(dialog->windowTitle());
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered,
|
||||
m_ui->mdiArea, [mdiArea=m_ui->mdiArea,subwindow,action](){
|
||||
mdiArea->setActiveSubWindow(subwindow);
|
||||
action->setChecked(subwindow->windowState().testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(subwindow, &QMdiSubWindow::windowStateChanged,
|
||||
action, [action](Qt::WindowStates oldState, Qt::WindowStates newState){
|
||||
action->setChecked(newState.testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(dialog, &QWidget::windowTitleChanged, action, &QAction::setText);
|
||||
connect(dialog, &QDialog::finished,
|
||||
this, [&spritePropertiesDialogs=m_spritePropertiesWindows,subwindow](){
|
||||
for (auto iter = std::begin(spritePropertiesDialogs); iter != std::end(spritePropertiesDialogs); )
|
||||
{
|
||||
if (iter->second == subwindow)
|
||||
iter = spritePropertiesDialogs.erase(iter);
|
||||
else
|
||||
iter++;
|
||||
}
|
||||
});
|
||||
connect(dialog, &QDialog::finished,
|
||||
subwindow, &QObject::deleteLater);
|
||||
connect(dialog, &QDialog::finished,
|
||||
action, &QObject::deleteLater);
|
||||
m_spritePropertiesWindows[sprite] = subwindow;
|
||||
dialog->show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectTreeModel::NodeType::Sound:
|
||||
{
|
||||
auto sound = m_projectTreeModel->getSound(index);
|
||||
if (!sound)
|
||||
break;
|
||||
|
||||
if (const auto iter = m_soundPropertiesWindows.find(sound); iter != std::cend(m_soundPropertiesWindows))
|
||||
{
|
||||
m_ui->mdiArea->setActiveSubWindow(iter->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dialog = new SoundPropertiesDialog{*sound, *m_projectTreeModel};
|
||||
auto subwindow = m_ui->mdiArea->addSubWindow(dialog);
|
||||
auto action = m_ui->menuWindow->addAction(dialog->windowTitle());
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered,
|
||||
m_ui->mdiArea, [mdiArea=m_ui->mdiArea,subwindow,action](){
|
||||
mdiArea->setActiveSubWindow(subwindow);
|
||||
action->setChecked(subwindow->windowState().testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(subwindow, &QMdiSubWindow::windowStateChanged,
|
||||
action, [action](Qt::WindowStates oldState, Qt::WindowStates newState){
|
||||
action->setChecked(newState.testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(dialog, &QWidget::windowTitleChanged, action, &QAction::setText);
|
||||
connect(dialog, &QDialog::finished,
|
||||
this, [&soundPropertiesDialogs=m_soundPropertiesWindows,subwindow](){
|
||||
for (auto iter = std::begin(soundPropertiesDialogs); iter != std::end(soundPropertiesDialogs); )
|
||||
{
|
||||
if (iter->second == subwindow)
|
||||
iter = soundPropertiesDialogs.erase(iter);
|
||||
else
|
||||
iter++;
|
||||
}
|
||||
});
|
||||
connect(dialog, &QDialog::finished,
|
||||
subwindow, &QObject::deleteLater);
|
||||
connect(dialog, &QDialog::finished,
|
||||
action, &QObject::deleteLater);
|
||||
m_soundPropertiesWindows[sound] = subwindow;
|
||||
dialog->show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectTreeModel::NodeType::Background:
|
||||
{
|
||||
auto background = m_projectTreeModel->getBackground(index);
|
||||
if (!background)
|
||||
break;
|
||||
|
||||
if (const auto iter = m_backgroundPropertiesWindows.find(background); iter != std::cend(m_backgroundPropertiesWindows))
|
||||
{
|
||||
m_ui->mdiArea->setActiveSubWindow(iter->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dialog = new BackgroundPropertiesDialog{*background, *m_projectTreeModel};
|
||||
auto subwindow = m_ui->mdiArea->addSubWindow(dialog);
|
||||
auto action = m_ui->menuWindow->addAction(dialog->windowTitle());
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered,
|
||||
m_ui->mdiArea, [mdiArea=m_ui->mdiArea,subwindow,action](){
|
||||
mdiArea->setActiveSubWindow(subwindow);
|
||||
action->setChecked(subwindow->windowState().testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(subwindow, &QMdiSubWindow::windowStateChanged,
|
||||
action, [action](Qt::WindowStates oldState, Qt::WindowStates newState){
|
||||
action->setChecked(newState.testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(dialog, &QWidget::windowTitleChanged, action, &QAction::setText);
|
||||
connect(dialog, &QDialog::finished,
|
||||
this, [&backgroundPropertiesDialogs=m_backgroundPropertiesWindows,subwindow](){
|
||||
for (auto iter = std::begin(backgroundPropertiesDialogs); iter != std::end(backgroundPropertiesDialogs); )
|
||||
{
|
||||
if (iter->second == subwindow)
|
||||
iter = backgroundPropertiesDialogs.erase(iter);
|
||||
else
|
||||
iter++;
|
||||
}
|
||||
});
|
||||
connect(dialog, &QDialog::finished,
|
||||
subwindow, &QObject::deleteLater);
|
||||
connect(dialog, &QDialog::finished,
|
||||
action, &QObject::deleteLater);
|
||||
m_backgroundPropertiesWindows[background] = subwindow;
|
||||
dialog->show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectTreeModel::NodeType::Path:
|
||||
{
|
||||
auto path = m_projectTreeModel->getPath(index);
|
||||
if (!path)
|
||||
break;
|
||||
|
||||
if (const auto iter = m_pathPropertiesWindows.find(path); iter != std::cend(m_pathPropertiesWindows))
|
||||
{
|
||||
m_ui->mdiArea->setActiveSubWindow(iter->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dialog = new PathPropertiesDialog{*path, *m_projectTreeModel};
|
||||
auto subwindow = m_ui->mdiArea->addSubWindow(dialog);
|
||||
auto action = m_ui->menuWindow->addAction(dialog->windowTitle());
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered,
|
||||
m_ui->mdiArea, [mdiArea=m_ui->mdiArea,subwindow,action](){
|
||||
mdiArea->setActiveSubWindow(subwindow);
|
||||
action->setChecked(subwindow->windowState().testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(subwindow, &QMdiSubWindow::windowStateChanged,
|
||||
action, [action](Qt::WindowStates oldState, Qt::WindowStates newState){
|
||||
action->setChecked(newState.testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(dialog, &QWidget::windowTitleChanged, action, &QAction::setText);
|
||||
connect(dialog, &QDialog::finished,
|
||||
this, [&pathPropertiesDialogs=m_pathPropertiesWindows,subwindow](){
|
||||
for (auto iter = std::begin(pathPropertiesDialogs); iter != std::end(pathPropertiesDialogs); )
|
||||
{
|
||||
if (iter->second == subwindow)
|
||||
iter = pathPropertiesDialogs.erase(iter);
|
||||
else
|
||||
iter++;
|
||||
}
|
||||
});
|
||||
connect(dialog, &QDialog::finished,
|
||||
subwindow, &QObject::deleteLater);
|
||||
connect(dialog, &QDialog::finished,
|
||||
action, &QObject::deleteLater);
|
||||
m_pathPropertiesWindows[path] = subwindow;
|
||||
dialog->show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectTreeModel::NodeType::Script:
|
||||
{
|
||||
auto script = m_projectTreeModel->getScript(index);
|
||||
if (!script)
|
||||
break;
|
||||
|
||||
if (const auto iter = m_scriptPropertiesWindows.find(script); iter != std::cend(m_scriptPropertiesWindows))
|
||||
{
|
||||
m_ui->mdiArea->setActiveSubWindow(iter->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dialog = new ScriptPropertiesDialog{*script, *m_projectTreeModel};
|
||||
auto subwindow = m_ui->mdiArea->addSubWindow(dialog);
|
||||
auto action = m_ui->menuWindow->addAction(dialog->windowTitle());
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered,
|
||||
m_ui->mdiArea, [mdiArea=m_ui->mdiArea,subwindow,action](){
|
||||
mdiArea->setActiveSubWindow(subwindow);
|
||||
action->setChecked(subwindow->windowState().testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(subwindow, &QMdiSubWindow::windowStateChanged,
|
||||
action, [action](Qt::WindowStates oldState, Qt::WindowStates newState){
|
||||
action->setChecked(newState.testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(dialog, &QWidget::windowTitleChanged, action, &QAction::setText);
|
||||
connect(dialog, &QDialog::finished,
|
||||
this, [&scriptPropertiesDialogs=m_scriptPropertiesWindows,subwindow](){
|
||||
for (auto iter = std::begin(scriptPropertiesDialogs); iter != std::end(scriptPropertiesDialogs); )
|
||||
{
|
||||
if (iter->second == subwindow)
|
||||
iter = scriptPropertiesDialogs.erase(iter);
|
||||
else
|
||||
iter++;
|
||||
}
|
||||
});
|
||||
connect(dialog, &QDialog::finished,
|
||||
subwindow, &QObject::deleteLater);
|
||||
connect(dialog, &QDialog::finished,
|
||||
action, &QObject::deleteLater);
|
||||
m_scriptPropertiesWindows[script] = subwindow;
|
||||
dialog->show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProjectTreeModel::NodeType::Font:
|
||||
{
|
||||
auto font = m_projectTreeModel->getFont(index);
|
||||
if (!font)
|
||||
break;
|
||||
|
||||
if (const auto iter = m_fontPropertiesWindows.find(font); iter != std::cend(m_fontPropertiesWindows))
|
||||
{
|
||||
m_ui->mdiArea->setActiveSubWindow(iter->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dialog = new FontPropertiesDialog{*font, *m_projectTreeModel};
|
||||
auto subwindow = m_ui->mdiArea->addSubWindow(dialog);
|
||||
auto action = m_ui->menuWindow->addAction(dialog->windowTitle());
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered,
|
||||
m_ui->mdiArea, [mdiArea=m_ui->mdiArea,subwindow,action](){
|
||||
mdiArea->setActiveSubWindow(subwindow);
|
||||
action->setChecked(subwindow->windowState().testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(subwindow, &QMdiSubWindow::windowStateChanged,
|
||||
action, [action](Qt::WindowStates oldState, Qt::WindowStates newState){
|
||||
action->setChecked(newState.testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(dialog, &QWidget::windowTitleChanged, action, &QAction::setText);
|
||||
connect(dialog, &QDialog::finished,
|
||||
this, [&fontPropertiesDialogs=m_fontPropertiesWindows,subwindow](){
|
||||
for (auto iter = std::begin(fontPropertiesDialogs); iter != std::end(fontPropertiesDialogs); )
|
||||
{
|
||||
if (iter->second == subwindow)
|
||||
iter = fontPropertiesDialogs.erase(iter);
|
||||
else
|
||||
iter++;
|
||||
}
|
||||
});
|
||||
connect(dialog, &QDialog::finished,
|
||||
subwindow, &QObject::deleteLater);
|
||||
connect(dialog, &QDialog::finished,
|
||||
action, &QObject::deleteLater);
|
||||
m_fontPropertiesWindows[font] = subwindow;
|
||||
dialog->show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (doubleClickedFor<Sprite>(index)) return;
|
||||
if (doubleClickedFor<Sound>(index)) return;
|
||||
if (doubleClickedFor<Background>(index)) return;
|
||||
if (doubleClickedFor<Path>(index)) return;
|
||||
if (doubleClickedFor<Script>(index)) return;
|
||||
if (doubleClickedFor<Font>(index)) return;
|
||||
if (doubleClickedFor<TimeLine>(index)) return;
|
||||
if (doubleClickedFor<Object>(index)) return;
|
||||
if (doubleClickedFor<Room>(index)) return;
|
||||
}
|
||||
|
||||
void MainWindow::selectionChanged(const QModelIndex &index)
|
||||
@ -468,30 +226,30 @@ void MainWindow::selectionChanged(const QModelIndex &index)
|
||||
switch (const auto nodeType = m_projectTreeModel->nodeType(index))
|
||||
{
|
||||
case ProjectTreeModel::NodeType::Root:
|
||||
if (index == m_projectTreeModel->spritesRoot() ||
|
||||
index == m_projectTreeModel->soundsRoot() ||
|
||||
index == m_projectTreeModel->backgroundsRoot() ||
|
||||
index == m_projectTreeModel->pathsRoot() ||
|
||||
index == m_projectTreeModel->scriptsRoot() ||
|
||||
index == m_projectTreeModel->fontsRoot())
|
||||
if (index == m_projectTreeModel->rootFor<Sprite>() ||
|
||||
index == m_projectTreeModel->rootFor<Sound>() ||
|
||||
index == m_projectTreeModel->rootFor<Background>() ||
|
||||
index == m_projectTreeModel->rootFor<Path>() ||
|
||||
index == m_projectTreeModel->rootFor<Script>() ||
|
||||
index == m_projectTreeModel->rootFor<Font>() ||
|
||||
index == m_projectTreeModel->rootFor<TimeLine>() ||
|
||||
index == m_projectTreeModel->rootFor<Object>() ||
|
||||
index == m_projectTreeModel->rootFor<Room>())
|
||||
{
|
||||
m_ui->actionCreate->setEnabled(true);
|
||||
m_ui->actionCreateGroup->setText(tr("Cr&eate Group"));
|
||||
m_ui->actionCreateGroup->setEnabled(true);
|
||||
m_ui->actionSortByName->setEnabled(true);
|
||||
|
||||
if (index == m_projectTreeModel->spritesRoot())
|
||||
m_ui->actionCreate->setText(tr("&Create Sprite"));
|
||||
else if (index == m_projectTreeModel->soundsRoot())
|
||||
m_ui->actionCreate->setText(tr("&Create Sound"));
|
||||
else if (index == m_projectTreeModel->backgroundsRoot())
|
||||
m_ui->actionCreate->setText(tr("&Create Background"));
|
||||
else if (index == m_projectTreeModel->pathsRoot())
|
||||
m_ui->actionCreate->setText(tr("&Create Path"));
|
||||
else if (index == m_projectTreeModel->scriptsRoot())
|
||||
m_ui->actionCreate->setText(tr("&Create Script"));
|
||||
else if (index == m_projectTreeModel->fontsRoot())
|
||||
m_ui->actionCreate->setText(tr("&Create Font"));
|
||||
if (index == m_projectTreeModel->rootFor<Sprite>()) m_ui->actionCreate->setText(tr("&Create Sprite"));
|
||||
else if (index == m_projectTreeModel->rootFor<Sound>()) m_ui->actionCreate->setText(tr("&Create Sound"));
|
||||
else if (index == m_projectTreeModel->rootFor<Background>()) m_ui->actionCreate->setText(tr("&Create Background"));
|
||||
else if (index == m_projectTreeModel->rootFor<Path>()) m_ui->actionCreate->setText(tr("&Create Path"));
|
||||
else if (index == m_projectTreeModel->rootFor<Script>()) m_ui->actionCreate->setText(tr("&Create Script"));
|
||||
else if (index == m_projectTreeModel->rootFor<Font>()) m_ui->actionCreate->setText(tr("&Create Font"));
|
||||
else if (index == m_projectTreeModel->rootFor<TimeLine>()) m_ui->actionCreate->setText(tr("&Create Time Line"));
|
||||
else if (index == m_projectTreeModel->rootFor<Object>()) m_ui->actionCreate->setText(tr("&Create Object"));
|
||||
else if (index == m_projectTreeModel->rootFor<Room>()) m_ui->actionCreate->setText(tr("&Create Room"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -516,6 +274,9 @@ void MainWindow::selectionChanged(const QModelIndex &index)
|
||||
case ProjectTreeModel::NodeType::Path:
|
||||
case ProjectTreeModel::NodeType::Script:
|
||||
case ProjectTreeModel::NodeType::Font:
|
||||
case ProjectTreeModel::NodeType::TimeLine:
|
||||
case ProjectTreeModel::NodeType::Object:
|
||||
case ProjectTreeModel::NodeType::Room:
|
||||
m_ui->actionCreate->setEnabled(true);
|
||||
switch (nodeType)
|
||||
{
|
||||
@ -525,6 +286,9 @@ void MainWindow::selectionChanged(const QModelIndex &index)
|
||||
case ProjectTreeModel::NodeType::Path: m_ui->actionCreate->setText(tr("&Insert Path")); break;
|
||||
case ProjectTreeModel::NodeType::Script: m_ui->actionCreate->setText(tr("&Insert Script")); break;
|
||||
case ProjectTreeModel::NodeType::Font: m_ui->actionCreate->setText(tr("&Insert Font")); break;
|
||||
case ProjectTreeModel::NodeType::TimeLine: m_ui->actionCreate->setText(tr("&Insert Time Line")); break;
|
||||
case ProjectTreeModel::NodeType::Object: m_ui->actionCreate->setText(tr("&Insert Object")); break;
|
||||
case ProjectTreeModel::NodeType::Room: m_ui->actionCreate->setText(tr("&Insert Room")); break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
}
|
||||
@ -737,18 +501,15 @@ void MainWindow::create()
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
if (index == m_projectTreeModel->spritesRoot())
|
||||
createSprite();
|
||||
else if (index == m_projectTreeModel->soundsRoot())
|
||||
createSound();
|
||||
else if (index == m_projectTreeModel->backgroundsRoot())
|
||||
createBackground();
|
||||
else if (index == m_projectTreeModel->pathsRoot())
|
||||
createPath();
|
||||
else if (index == m_projectTreeModel->scriptsRoot())
|
||||
createScript();
|
||||
else if (index == m_projectTreeModel->fontsRoot())
|
||||
createFont();
|
||||
if (index == m_projectTreeModel->rootFor<Sprite>()) createFor<Sprite>();
|
||||
else if (index == m_projectTreeModel->rootFor<Sound>()) createFor<Sound>();
|
||||
else if (index == m_projectTreeModel->rootFor<Background>()) createFor<Background>();
|
||||
else if (index == m_projectTreeModel->rootFor<Path>()) createFor<Path>();
|
||||
else if (index == m_projectTreeModel->rootFor<Script>()) createFor<Script>();
|
||||
else if (index == m_projectTreeModel->rootFor<Font>()) createFor<Font>();
|
||||
else if (index == m_projectTreeModel->rootFor<TimeLine>()) createFor<TimeLine>();
|
||||
else if (index == m_projectTreeModel->rootFor<Object>()) createFor<Object>();
|
||||
else if (index == m_projectTreeModel->rootFor<Room>()) createFor<Room>();
|
||||
else
|
||||
{
|
||||
switch (m_projectTreeModel->nodeType(index))
|
||||
@ -759,6 +520,9 @@ void MainWindow::create()
|
||||
case ProjectTreeModel::NodeType::Path:
|
||||
case ProjectTreeModel::NodeType::Script:
|
||||
case ProjectTreeModel::NodeType::Font:
|
||||
case ProjectTreeModel::NodeType::TimeLine:
|
||||
case ProjectTreeModel::NodeType::Object:
|
||||
case ProjectTreeModel::NodeType::Room:
|
||||
if (!m_projectTreeModel->insertRows(index.row(), 1, index.parent()))
|
||||
QMessageBox::warning(this, tr("Inserting failed!"), tr("Inserting failed!"));
|
||||
break;
|
||||
@ -850,41 +614,22 @@ void MainWindow::showObjectInformation()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::createSprite()
|
||||
template<typename T>
|
||||
void MainWindow::createFor()
|
||||
{
|
||||
if (!m_projectTreeModel->insertRows(m_project.sprites.size(), 1, m_projectTreeModel->spritesRoot()))
|
||||
QMessageBox::warning(this, tr("Creating Sprite failed!"), tr("Creating Sprite failed!"));
|
||||
if (!m_projectTreeModel->insertRows(m_project.containerFor<T>().size(), 1, m_projectTreeModel->rootFor<T>()))
|
||||
QMessageBox::warning(this, tr("Creating failed!"), tr("Creating failed!"));
|
||||
}
|
||||
|
||||
void MainWindow::createSound()
|
||||
{
|
||||
if (!m_projectTreeModel->insertRows(m_project.sounds.size(), 1, m_projectTreeModel->soundsRoot()))
|
||||
QMessageBox::warning(this, tr("Creating Sound failed!"), tr("Creating Sound failed!"));
|
||||
}
|
||||
|
||||
void MainWindow::createBackground()
|
||||
{
|
||||
if (!m_projectTreeModel->insertRows(m_project.backgrounds.size(), 1, m_projectTreeModel->backgroundsRoot()))
|
||||
QMessageBox::warning(this, tr("Creating Background failed!"), tr("Creating Background failed!"));
|
||||
}
|
||||
|
||||
void MainWindow::createPath()
|
||||
{
|
||||
if (!m_projectTreeModel->insertRows(m_project.paths.size(), 1, m_projectTreeModel->pathsRoot()))
|
||||
QMessageBox::warning(this, tr("Creating Path failed!"), tr("Creating Path failed!"));
|
||||
}
|
||||
|
||||
void MainWindow::createScript()
|
||||
{
|
||||
if (!m_projectTreeModel->insertRows(m_project.scripts.size(), 1, m_projectTreeModel->scriptsRoot()))
|
||||
QMessageBox::warning(this, tr("Creating Script failed!"), tr("Creating Script failed!"));
|
||||
}
|
||||
|
||||
void MainWindow::createFont()
|
||||
{
|
||||
if (!m_projectTreeModel->insertRows(m_project.fonts.size(), 1, m_projectTreeModel->fontsRoot()))
|
||||
QMessageBox::warning(this, tr("Creating Font failed!"), tr("Creating Font failed!"));
|
||||
}
|
||||
template void MainWindow::createFor<Sprite>();
|
||||
template void MainWindow::createFor<Sound>();
|
||||
template void MainWindow::createFor<Background>();
|
||||
template void MainWindow::createFor<Path>();
|
||||
template void MainWindow::createFor<Script>();
|
||||
template void MainWindow::createFor<Font>();
|
||||
template void MainWindow::createFor<TimeLine>();
|
||||
template void MainWindow::createFor<Object>();
|
||||
template void MainWindow::createFor<Room>();
|
||||
|
||||
void MainWindow::showGameInformation()
|
||||
{
|
||||
@ -917,112 +662,28 @@ void MainWindow::rowsInserted(const QModelIndex &parent, int first, int last)
|
||||
|
||||
void MainWindow::rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
|
||||
{
|
||||
if (parent == m_projectTreeModel->spritesRoot())
|
||||
{
|
||||
for (int row = first; row <= last; row++)
|
||||
{
|
||||
if (const auto sprite = m_projectTreeModel->getSprite(m_projectTreeModel->index(row, 0, parent)))
|
||||
{
|
||||
if (const auto iter = m_spritePropertiesWindows.find(sprite); iter != std::end(m_spritePropertiesWindows))
|
||||
{
|
||||
delete iter->second;
|
||||
m_spritePropertiesWindows.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent == m_projectTreeModel->soundsRoot())
|
||||
{
|
||||
for (int row = first; row <= last; row++)
|
||||
{
|
||||
if (const auto sound = m_projectTreeModel->getSound(m_projectTreeModel->index(row, 0, parent)))
|
||||
{
|
||||
if (const auto iter = m_soundPropertiesWindows.find(sound); iter != std::end(m_soundPropertiesWindows))
|
||||
{
|
||||
delete iter->second;
|
||||
m_soundPropertiesWindows.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent == m_projectTreeModel->backgroundsRoot())
|
||||
{
|
||||
for (int row = first; row <= last; row++)
|
||||
{
|
||||
if (const auto background = m_projectTreeModel->getBackground(m_projectTreeModel->index(row, 0, parent)))
|
||||
{
|
||||
if (const auto iter = m_backgroundPropertiesWindows.find(background); iter != std::end(m_backgroundPropertiesWindows))
|
||||
{
|
||||
delete iter->second;
|
||||
m_backgroundPropertiesWindows.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent == m_projectTreeModel->pathsRoot())
|
||||
{
|
||||
for (int row = first; row <= last; row++)
|
||||
{
|
||||
if (const auto path = m_projectTreeModel->getPath(m_projectTreeModel->index(row, 0, parent)))
|
||||
{
|
||||
if (const auto iter = m_pathPropertiesWindows.find(path); iter != std::end(m_pathPropertiesWindows))
|
||||
{
|
||||
delete iter->second;
|
||||
m_pathPropertiesWindows.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent == m_projectTreeModel->scriptsRoot())
|
||||
{
|
||||
for (int row = first; row <= last; row++)
|
||||
{
|
||||
if (const auto script = m_projectTreeModel->getScript(m_projectTreeModel->index(row, 0, parent)))
|
||||
{
|
||||
if (const auto iter = m_scriptPropertiesWindows.find(script); iter != std::end(m_scriptPropertiesWindows))
|
||||
{
|
||||
delete iter->second;
|
||||
m_scriptPropertiesWindows.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent == m_projectTreeModel->fontsRoot())
|
||||
{
|
||||
for (int row = first; row <= last; row++)
|
||||
{
|
||||
if (const auto font = m_projectTreeModel->getFont(m_projectTreeModel->index(row, 0, parent)))
|
||||
{
|
||||
if (const auto iter = m_fontPropertiesWindows.find(font); iter != std::end(m_fontPropertiesWindows))
|
||||
{
|
||||
delete iter->second;
|
||||
m_fontPropertiesWindows.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rowsAboutToBeRemovedFor<Sprite>(parent, first, last)) return;
|
||||
if (rowsAboutToBeRemovedFor<Sound>(parent, first, last)) return;
|
||||
if (rowsAboutToBeRemovedFor<Background>(parent, first, last)) return;
|
||||
if (rowsAboutToBeRemovedFor<Path>(parent, first, last)) return;
|
||||
if (rowsAboutToBeRemovedFor<Script>(parent, first, last)) return;
|
||||
if (rowsAboutToBeRemovedFor<Font>(parent, first, last)) return;
|
||||
if (rowsAboutToBeRemovedFor<TimeLine>(parent, first, last)) return;
|
||||
if (rowsAboutToBeRemovedFor<Object>(parent, first, last)) return;
|
||||
if (rowsAboutToBeRemovedFor<Room>(parent, first, last)) return;
|
||||
}
|
||||
|
||||
void MainWindow::modelAboutToBeReset()
|
||||
{
|
||||
for (const auto &pair : m_spritePropertiesWindows)
|
||||
delete pair.second;
|
||||
m_spritePropertiesWindows.clear();
|
||||
for (const auto &pair : m_soundPropertiesWindows)
|
||||
delete pair.second;
|
||||
m_soundPropertiesWindows.clear();
|
||||
for (const auto &pair : m_backgroundPropertiesWindows)
|
||||
delete pair.second;
|
||||
m_backgroundPropertiesWindows.clear();
|
||||
for (const auto &pair : m_pathPropertiesWindows)
|
||||
delete pair.second;
|
||||
m_pathPropertiesWindows.clear();
|
||||
for (const auto &pair : m_scriptPropertiesWindows)
|
||||
delete pair.second;
|
||||
m_scriptPropertiesWindows.clear();
|
||||
for (const auto &pair : m_fontPropertiesWindows)
|
||||
delete pair.second;
|
||||
m_fontPropertiesWindows.clear();
|
||||
modelAboutToBeResetFor<Sprite>();
|
||||
modelAboutToBeResetFor<Sound>();
|
||||
modelAboutToBeResetFor<Background>();
|
||||
modelAboutToBeResetFor<Path>();
|
||||
modelAboutToBeResetFor<Script>();
|
||||
modelAboutToBeResetFor<Font>();
|
||||
modelAboutToBeResetFor<TimeLine>();
|
||||
modelAboutToBeResetFor<Object>();
|
||||
modelAboutToBeResetFor<Room>();
|
||||
}
|
||||
|
||||
void MainWindow::updateTitle()
|
||||
@ -1031,3 +692,140 @@ void MainWindow::updateTitle()
|
||||
.arg(m_filePath.isEmpty() ? "<new-game>" : QFileInfo{m_filePath}.fileName())
|
||||
.arg(m_unsavedChanges ? tr("*") : QString{}));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool MainWindow::doubleClickedFor(const QModelIndex &index)
|
||||
{
|
||||
if (m_projectTreeModel->nodeType(index) != ProjectTreeModel::nodeTypeFor<T>())
|
||||
return false;
|
||||
|
||||
auto entry = m_projectTreeModel->get<T>(index);
|
||||
if (!entry)
|
||||
return true;
|
||||
|
||||
auto &propertyWindows = propertyWindowsFor<T>();
|
||||
if (const auto iter = propertyWindows.find(entry); iter != std::cend(propertyWindows))
|
||||
{
|
||||
m_ui->mdiArea->setActiveSubWindow(iter->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dialog = new PropertiesDialogFor<T>{*entry, *m_projectTreeModel};
|
||||
auto subwindow = m_ui->mdiArea->addSubWindow(dialog);
|
||||
auto action = m_ui->menuWindow->addAction(dialog->windowTitle());
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered,
|
||||
m_ui->mdiArea, [mdiArea=m_ui->mdiArea,subwindow,action](){
|
||||
mdiArea->setActiveSubWindow(subwindow);
|
||||
action->setChecked(subwindow->windowState().testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(subwindow, &QMdiSubWindow::windowStateChanged,
|
||||
action, [action](Qt::WindowStates oldState, Qt::WindowStates newState){
|
||||
action->setChecked(newState.testFlag(Qt::WindowActive));
|
||||
});
|
||||
connect(dialog, &QWidget::windowTitleChanged, action, &QAction::setText);
|
||||
connect(dialog, &QDialog::finished,
|
||||
this, [&propertyWindows,subwindow](){
|
||||
for (auto iter = std::begin(propertyWindows); iter != std::end(propertyWindows); )
|
||||
{
|
||||
if (iter->second == subwindow)
|
||||
iter = propertyWindows.erase(iter);
|
||||
else
|
||||
iter++;
|
||||
}
|
||||
});
|
||||
connect(dialog, &QDialog::finished,
|
||||
subwindow, &QObject::deleteLater);
|
||||
connect(dialog, &QDialog::finished,
|
||||
action, &QObject::deleteLater);
|
||||
propertyWindows[entry] = subwindow;
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool MainWindow::rowsAboutToBeRemovedFor(const QModelIndex &parent, int first, int last)
|
||||
{
|
||||
if (parent != m_projectTreeModel->rootFor<T>())
|
||||
return false;
|
||||
|
||||
for (int row = first; row <= last; row++)
|
||||
{
|
||||
if (const auto entry = m_projectTreeModel->get<T>(m_projectTreeModel->index(row, 0, parent)))
|
||||
{
|
||||
auto &propertyWindows = propertyWindowsFor<T>();
|
||||
if (const auto iter = propertyWindows.find(entry); iter != std::end(propertyWindows))
|
||||
{
|
||||
delete iter->second;
|
||||
propertyWindows.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void MainWindow::modelAboutToBeResetFor()
|
||||
{
|
||||
auto &propertyWindows = propertyWindowsFor<T>();
|
||||
for (const auto &pair : propertyWindows)
|
||||
delete pair.second;
|
||||
propertyWindows.clear();
|
||||
}
|
||||
|
||||
template<>
|
||||
std::map<Sprite*, QMdiSubWindow*> &MainWindow::propertyWindowsFor<Sprite>()
|
||||
{
|
||||
return m_spritePropertiesWindows;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::map<Sound*, QMdiSubWindow*> &MainWindow::propertyWindowsFor<Sound>()
|
||||
{
|
||||
return m_soundPropertiesWindows;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::map<Background*, QMdiSubWindow*> &MainWindow::propertyWindowsFor<Background>()
|
||||
{
|
||||
return m_backgroundPropertiesWindows;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::map<Path*, QMdiSubWindow*> &MainWindow::propertyWindowsFor<Path>()
|
||||
{
|
||||
return m_pathPropertiesWindows;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::map<Script*, QMdiSubWindow*> &MainWindow::propertyWindowsFor<Script>()
|
||||
{
|
||||
return m_scriptPropertiesWindows;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::map<Font*, QMdiSubWindow*> &MainWindow::propertyWindowsFor<Font>()
|
||||
{
|
||||
return m_fontPropertiesWindows;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::map<TimeLine*, QMdiSubWindow*> &MainWindow::propertyWindowsFor<TimeLine>()
|
||||
{
|
||||
return m_timeLinePropertiesWindows;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::map<Object*, QMdiSubWindow*> &MainWindow::propertyWindowsFor<Object>()
|
||||
{
|
||||
return m_objectPropertiesWindows;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::map<Room*, QMdiSubWindow*> &MainWindow::propertyWindowsFor<Room>()
|
||||
{
|
||||
return m_roomPropertiesWindows;
|
||||
}
|
||||
|
34
mainwindow.h
34
mainwindow.h
@ -46,12 +46,19 @@ private slots:
|
||||
void showProperties();
|
||||
void findResource();
|
||||
void showObjectInformation();
|
||||
void createSprite();
|
||||
void createSound();
|
||||
void createBackground();
|
||||
void createPath();
|
||||
void createScript();
|
||||
void createFont();
|
||||
private:
|
||||
template<typename T>
|
||||
void createFor();
|
||||
private slots:
|
||||
// void createSprite();
|
||||
// void createSound();
|
||||
// void createBackground();
|
||||
// void createPath();
|
||||
// void createScript();
|
||||
// void createFont();
|
||||
// void createTimeLine();
|
||||
// void createObject();
|
||||
// void createRoom();
|
||||
void showGameInformation();
|
||||
void showGlobalGameSettings();
|
||||
void showExtensionPackages();
|
||||
@ -64,6 +71,18 @@ private slots:
|
||||
private:
|
||||
void updateTitle();
|
||||
|
||||
template<typename T>
|
||||
std::map<T*, QMdiSubWindow*> &propertyWindowsFor();
|
||||
|
||||
template<typename T>
|
||||
bool doubleClickedFor(const QModelIndex &index);
|
||||
|
||||
template<typename T>
|
||||
bool rowsAboutToBeRemovedFor(const QModelIndex &parent, int first, int last);
|
||||
|
||||
template<typename T>
|
||||
void modelAboutToBeResetFor();
|
||||
|
||||
const std::unique_ptr<Ui::MainWindow> m_ui;
|
||||
|
||||
ProjectContainer m_project;
|
||||
@ -79,6 +98,9 @@ private:
|
||||
std::map<Path*, QMdiSubWindow*> m_pathPropertiesWindows;
|
||||
std::map<Script*, QMdiSubWindow*> m_scriptPropertiesWindows;
|
||||
std::map<Font*, QMdiSubWindow*> m_fontPropertiesWindows;
|
||||
std::map<TimeLine*, QMdiSubWindow*> m_timeLinePropertiesWindows;
|
||||
std::map<Object*, QMdiSubWindow*> m_objectPropertiesWindows;
|
||||
std::map<Room*, QMdiSubWindow*> m_roomPropertiesWindows;
|
||||
|
||||
QMdiSubWindow *m_objectInformationWindow{};
|
||||
};
|
||||
|
@ -1,14 +1,82 @@
|
||||
#include "projectcontainer.h"
|
||||
|
||||
template<> std::list<Sprite> &ProjectContainer::containerFor() { return sprites; }
|
||||
template<> const std::list<Sprite> &ProjectContainer::containerFor() const { return sprites; }
|
||||
template<> std::list<Sound> &ProjectContainer::containerFor() { return sounds; }
|
||||
template<> const std::list<Sound> &ProjectContainer::containerFor() const { return sounds; }
|
||||
template<> std::list<Background> &ProjectContainer::containerFor() { return backgrounds; }
|
||||
template<> const std::list<Background> &ProjectContainer::containerFor() const { return backgrounds; }
|
||||
template<> std::list<Path> &ProjectContainer::containerFor() { return paths; }
|
||||
template<> const std::list<Path> &ProjectContainer::containerFor() const { return paths; }
|
||||
template<> std::list<Script> &ProjectContainer::containerFor() { return scripts; }
|
||||
template<> const std::list<Script> &ProjectContainer::containerFor() const { return scripts; }
|
||||
template<> std::list<Font> &ProjectContainer::containerFor() { return fonts; }
|
||||
template<> const std::list<Font> &ProjectContainer::containerFor() const { return fonts; }
|
||||
template<> std::list<TimeLine> &ProjectContainer::containerFor() { return timeLines; }
|
||||
template<> const std::list<TimeLine> &ProjectContainer::containerFor() const { return timeLines; }
|
||||
template<> std::list<Object> &ProjectContainer::containerFor() { return objects; }
|
||||
template<> const std::list<Object> &ProjectContainer::containerFor() const { return objects; }
|
||||
template<> std::list<Room> &ProjectContainer::containerFor() { return rooms; }
|
||||
template<> const std::list<Room> &ProjectContainer::containerFor() const { return rooms; }
|
||||
|
||||
template<typename T>
|
||||
QDataStream &operator<<(QDataStream &ds, const std::list<T> &list)
|
||||
{
|
||||
{
|
||||
int entries = list.size();
|
||||
ds << entries;
|
||||
}
|
||||
for (const auto &entry : list)
|
||||
ds << entry;
|
||||
return ds;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
QDataStream &operator>>(QDataStream &ds, std::list<T> &list)
|
||||
{
|
||||
int entries;
|
||||
ds >> entries;
|
||||
|
||||
for (int i = 0; i < entries; i++)
|
||||
{
|
||||
T entry;
|
||||
ds >> entry;
|
||||
list.emplace_back(std::move(entry));
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
QDataStream &operator<<(QDataStream &ds, const std::vector<T> &list)
|
||||
{
|
||||
{
|
||||
int entries = list.size();
|
||||
ds << entries;
|
||||
}
|
||||
for (const auto &entry : list)
|
||||
ds << entry;
|
||||
return ds;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
QDataStream &operator>>(QDataStream &ds, std::vector<T> &list)
|
||||
{
|
||||
int entries;
|
||||
ds >> entries;
|
||||
|
||||
for (int i = 0; i < entries; i++)
|
||||
{
|
||||
T entry;
|
||||
ds >> entry;
|
||||
list.emplace_back(std::move(entry));
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Sprite &sprite)
|
||||
{
|
||||
ds << sprite.name;
|
||||
{
|
||||
int pixmaps = sprite.pixmaps.size();
|
||||
ds << pixmaps;
|
||||
}
|
||||
for (const auto &pixmap : sprite.pixmaps)
|
||||
ds << pixmap;
|
||||
ds << sprite.pixmaps;
|
||||
ds << sprite.origin.x;
|
||||
ds << sprite.origin.y;
|
||||
ds << sprite.preciseCollisionChecking;
|
||||
@ -19,17 +87,7 @@ QDataStream &operator<<(QDataStream &ds, const Sprite &sprite)
|
||||
QDataStream &operator>>(QDataStream &ds, Sprite &sprite)
|
||||
{
|
||||
ds >> sprite.name;
|
||||
{
|
||||
int pixmaps;
|
||||
ds >> pixmaps;
|
||||
|
||||
for (int i = 0; i < pixmaps; i++)
|
||||
{
|
||||
QPixmap pixmap;
|
||||
ds >> pixmap;
|
||||
sprite.pixmaps.emplace_back(std::move(pixmap));
|
||||
}
|
||||
}
|
||||
ds >> sprite.pixmaps;
|
||||
ds >> sprite.origin.x;
|
||||
ds >> sprite.origin.y;
|
||||
ds >> sprite.preciseCollisionChecking;
|
||||
@ -125,115 +183,67 @@ QDataStream &operator>>(QDataStream &ds, Font &font)
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const TimeLine &timeLine)
|
||||
{
|
||||
ds << timeLine.name;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, TimeLine &timeLine)
|
||||
{
|
||||
ds >> timeLine.name;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Object &object)
|
||||
{
|
||||
ds << object.name;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Object &object)
|
||||
{
|
||||
ds >> object.name;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Room &room)
|
||||
{
|
||||
ds << room.name;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Room &room)
|
||||
{
|
||||
ds >> room.name;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const ProjectContainer &project)
|
||||
{
|
||||
{
|
||||
int sprites = project.sprites.size();
|
||||
ds << sprites;
|
||||
for (const auto &sprite : project.sprites)
|
||||
ds << sprite;
|
||||
}
|
||||
{
|
||||
int sounds = project.sounds.size();
|
||||
ds << sounds;
|
||||
for (const auto &sound : project.sounds)
|
||||
ds << sound;
|
||||
}
|
||||
{
|
||||
int backgrounds = project.backgrounds.size();
|
||||
ds << backgrounds;
|
||||
for (const auto &background : project.backgrounds)
|
||||
ds << background;
|
||||
}
|
||||
{
|
||||
int paths = project.paths.size();
|
||||
ds << paths;
|
||||
for (const auto &path : project.paths)
|
||||
ds << path;
|
||||
}
|
||||
{
|
||||
int scripts = project.scripts.size();
|
||||
ds << scripts;
|
||||
for (const auto &script : project.scripts)
|
||||
ds << script;
|
||||
}
|
||||
{
|
||||
int fonts = project.fonts.size();
|
||||
ds << fonts;
|
||||
for (const auto &font : project.fonts)
|
||||
ds << font;
|
||||
}
|
||||
ds << project.sprites;
|
||||
ds << project.sounds;
|
||||
ds << project.backgrounds;
|
||||
ds << project.paths;
|
||||
ds << project.scripts;
|
||||
ds << project.fonts;
|
||||
ds << project.timeLines;
|
||||
ds << project.objects;
|
||||
ds << project.rooms;
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, ProjectContainer &project)
|
||||
{
|
||||
{
|
||||
int sprites;
|
||||
ds >> sprites;
|
||||
|
||||
for (int i = 0; i < sprites; i++)
|
||||
{
|
||||
Sprite sprite;
|
||||
ds >> sprite;
|
||||
project.sprites.emplace_back(std::move(sprite));
|
||||
}
|
||||
}
|
||||
{
|
||||
int sounds;
|
||||
ds >> sounds;
|
||||
|
||||
for (int i = 0; i < sounds; i++)
|
||||
{
|
||||
Sound sound;
|
||||
ds >> sound;
|
||||
project.sounds.emplace_back(std::move(sound));
|
||||
}
|
||||
}
|
||||
{
|
||||
int backgrounds;
|
||||
ds >> backgrounds;
|
||||
|
||||
for (int i = 0; i < backgrounds; i++)
|
||||
{
|
||||
Background background;
|
||||
ds >> background;
|
||||
project.backgrounds.emplace_back(std::move(background));
|
||||
}
|
||||
}
|
||||
{
|
||||
int paths;
|
||||
ds >> paths;
|
||||
|
||||
for (int i = 0; i < paths; i++)
|
||||
{
|
||||
Path path;
|
||||
ds >> path;
|
||||
project.paths.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
{
|
||||
int scripts;
|
||||
ds >> scripts;
|
||||
|
||||
for (int i = 0; i < scripts; i++)
|
||||
{
|
||||
Script script;
|
||||
ds >> script;
|
||||
project.scripts.emplace_back(std::move(script));
|
||||
}
|
||||
}
|
||||
{
|
||||
int fonts;
|
||||
ds >> fonts;
|
||||
|
||||
for (int i = 0; i < fonts; i++)
|
||||
{
|
||||
Font font;
|
||||
ds >> font;
|
||||
project.fonts.emplace_back(std::move(font));
|
||||
}
|
||||
}
|
||||
ds >> project.sprites;
|
||||
ds >> project.sounds;
|
||||
ds >> project.backgrounds;
|
||||
ds >> project.paths;
|
||||
ds >> project.scripts;
|
||||
ds >> project.fonts;
|
||||
ds >> project.timeLines;
|
||||
ds >> project.objects;
|
||||
ds >> project.rooms;
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ struct Sound
|
||||
{
|
||||
QString name;
|
||||
enum class Type { Sound, Music };
|
||||
Type type;
|
||||
Type type{Type::Sound};
|
||||
QString path;
|
||||
struct {
|
||||
bool chorus{};
|
||||
@ -67,14 +67,35 @@ struct Font
|
||||
} range;
|
||||
};
|
||||
|
||||
struct TimeLine
|
||||
{
|
||||
QString name;
|
||||
};
|
||||
|
||||
struct Object
|
||||
{
|
||||
QString name;
|
||||
};
|
||||
|
||||
struct Room
|
||||
{
|
||||
QString name;
|
||||
};
|
||||
|
||||
struct ProjectContainer
|
||||
{
|
||||
std::list<Sprite> sprites;
|
||||
std::list<Sound> sounds;
|
||||
std::list<Sound> sounds;
|
||||
std::list<Background> backgrounds;
|
||||
std::list<Path> paths;
|
||||
std::list<Script> scripts;
|
||||
std::list<Font> fonts;
|
||||
std::list<TimeLine> timeLines;
|
||||
std::list<Object> objects;
|
||||
std::list<Room> rooms;
|
||||
|
||||
template<typename T> std::list<T> &containerFor();
|
||||
template<typename T> const std::list<T> &containerFor() const;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Sprite &sprite);
|
||||
@ -89,5 +110,11 @@ QDataStream &operator<<(QDataStream &ds, const Script &script);
|
||||
QDataStream &operator>>(QDataStream &ds, Script &script);
|
||||
QDataStream &operator<<(QDataStream &ds, const Font &font);
|
||||
QDataStream &operator>>(QDataStream &ds, Font &font);
|
||||
QDataStream &operator<<(QDataStream &ds, const TimeLine &timeLine);
|
||||
QDataStream &operator>>(QDataStream &ds, TimeLine &timeLine);
|
||||
QDataStream &operator<<(QDataStream &ds, const Object &object);
|
||||
QDataStream &operator>>(QDataStream &ds, Object &object);
|
||||
QDataStream &operator<<(QDataStream &ds, const Room &room);
|
||||
QDataStream &operator>>(QDataStream &ds, Room &room);
|
||||
QDataStream &operator<<(QDataStream &ds, const ProjectContainer &project);
|
||||
QDataStream &operator>>(QDataStream &ds, ProjectContainer &project);
|
||||
|
1682
projecttreemodel.cpp
1682
projecttreemodel.cpp
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,8 @@
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
#include <optional>
|
||||
|
||||
struct ProjectContainer;
|
||||
struct Sprite;
|
||||
struct Sound;
|
||||
@ -9,6 +11,9 @@ struct Background;
|
||||
struct Path;
|
||||
struct Script;
|
||||
struct Font;
|
||||
struct TimeLine;
|
||||
struct Object;
|
||||
struct Room;
|
||||
|
||||
class ProjectTreeModel : public QAbstractItemModel
|
||||
{
|
||||
@ -23,6 +28,9 @@ public:
|
||||
Path,
|
||||
Script,
|
||||
Font,
|
||||
TimeLine,
|
||||
Object,
|
||||
Room,
|
||||
};
|
||||
|
||||
explicit ProjectTreeModel(QObject *parent = nullptr);
|
||||
@ -44,43 +52,18 @@ public:
|
||||
void setProject(ProjectContainer *project);
|
||||
NodeType nodeType(const QModelIndex &index) const;
|
||||
|
||||
QModelIndex spritesRoot() const;
|
||||
QModelIndex soundsRoot() const;
|
||||
QModelIndex backgroundsRoot() const;
|
||||
QModelIndex pathsRoot() const;
|
||||
QModelIndex scriptsRoot() const;
|
||||
QModelIndex fontsRoot() const;
|
||||
QModelIndex timeLinesRoot() const;
|
||||
QModelIndex objectsRoot() const;
|
||||
QModelIndex roomsRoot() const;
|
||||
template<typename T> QModelIndex rootFor() const;
|
||||
|
||||
QModelIndex gameInformationRoot() const;
|
||||
QModelIndex globalGameSettingsRoot() const;
|
||||
QModelIndex extensionPackagesRoot() const;
|
||||
|
||||
Sprite *getSprite(const QModelIndex &index);
|
||||
const Sprite *getSprite(const QModelIndex &index) const;
|
||||
template<typename T> T *get(const QModelIndex &index);
|
||||
template<typename T> const T *get(const QModelIndex &index) const;
|
||||
|
||||
Sound *getSound(const QModelIndex &index);
|
||||
const Sound *getSound(const QModelIndex &index) const;
|
||||
template<typename T> bool rename(const T &sprite, const QString &newName);
|
||||
|
||||
Background *getBackground(const QModelIndex &index);
|
||||
const Background *getBackground(const QModelIndex &index) const;
|
||||
|
||||
Path *getPath(const QModelIndex &index);
|
||||
const Path *getPath(const QModelIndex &index) const;
|
||||
|
||||
Script *getScript(const QModelIndex &index);
|
||||
const Script *getScript(const QModelIndex &index) const;
|
||||
|
||||
Font *getFont(const QModelIndex &index);
|
||||
const Font *getFont(const QModelIndex &index) const;
|
||||
|
||||
bool renameSprite(const Sprite &sprite, const QString &newName);
|
||||
bool renameSound(const Sound &sound, const QString &newName);
|
||||
bool renameBackground(const Background &background, const QString &newName);
|
||||
bool renamePath(const Path &path, const QString &newName);
|
||||
bool renameScript(const Script &script, const QString &newName);
|
||||
bool renameFont(const Font &font, const QString &newName);
|
||||
template<typename T> static constexpr ProjectTreeModel::NodeType nodeTypeFor() = delete;
|
||||
|
||||
signals:
|
||||
void errorOccured(const QString &message);
|
||||
@ -91,7 +74,67 @@ signals:
|
||||
void pathNameChanged(const Path &path);
|
||||
void scriptNameChanged(const Script &script);
|
||||
void fontNameChanged(const Font &font);
|
||||
void timeLineNameChanged(const TimeLine &font);
|
||||
void objectNameChanged(const Object &font);
|
||||
void roomNameChanged(const Room &font);
|
||||
|
||||
private:
|
||||
template<typename T> QVariant dataFor(const QModelIndex &index, int role) const;
|
||||
template<typename T> QVariant iconFor(const T &entry) const;
|
||||
template<typename T> bool setDataFor(const QModelIndex &index, const QVariant &value, int role);
|
||||
template<typename T> std::optional<bool> insertRowsFor(int row, int count, const QModelIndex &parent);
|
||||
template<typename T> std::optional<bool> removeRowsFor(int row, int count, const QModelIndex &parent);
|
||||
template<typename T> void emitNameChanged(const T &entry);
|
||||
template<typename T> static QString nameTempateFor();
|
||||
|
||||
ProjectContainer *m_project{};
|
||||
};
|
||||
|
||||
template<> constexpr ProjectTreeModel::NodeType ProjectTreeModel::nodeTypeFor<Sprite>() { return ProjectTreeModel::NodeType::Sprite; }
|
||||
template<> constexpr ProjectTreeModel::NodeType ProjectTreeModel::nodeTypeFor<Sound>() { return ProjectTreeModel::NodeType::Sound; }
|
||||
template<> constexpr ProjectTreeModel::NodeType ProjectTreeModel::nodeTypeFor<Background>() { return ProjectTreeModel::NodeType::Background; }
|
||||
template<> constexpr ProjectTreeModel::NodeType ProjectTreeModel::nodeTypeFor<Path>() { return ProjectTreeModel::NodeType::Path; }
|
||||
template<> constexpr ProjectTreeModel::NodeType ProjectTreeModel::nodeTypeFor<Script>() { return ProjectTreeModel::NodeType::Script; }
|
||||
template<> constexpr ProjectTreeModel::NodeType ProjectTreeModel::nodeTypeFor<Font>() { return ProjectTreeModel::NodeType::Font; }
|
||||
template<> constexpr ProjectTreeModel::NodeType ProjectTreeModel::nodeTypeFor<TimeLine>() { return ProjectTreeModel::NodeType::TimeLine; }
|
||||
template<> constexpr ProjectTreeModel::NodeType ProjectTreeModel::nodeTypeFor<Object>() { return ProjectTreeModel::NodeType::Object; }
|
||||
template<> constexpr ProjectTreeModel::NodeType ProjectTreeModel::nodeTypeFor<Room>() { return ProjectTreeModel::NodeType::Room; }
|
||||
|
||||
template<> QModelIndex ProjectTreeModel::rootFor<Sprite>() const;
|
||||
template<> QModelIndex ProjectTreeModel::rootFor<Sound>() const;
|
||||
template<> QModelIndex ProjectTreeModel::rootFor<Background>() const;
|
||||
template<> QModelIndex ProjectTreeModel::rootFor<Path>() const;
|
||||
template<> QModelIndex ProjectTreeModel::rootFor<Script>() const;
|
||||
template<> QModelIndex ProjectTreeModel::rootFor<Font>() const;
|
||||
template<> QModelIndex ProjectTreeModel::rootFor<TimeLine>() const;
|
||||
template<> QModelIndex ProjectTreeModel::rootFor<Object>() const;
|
||||
template<> QModelIndex ProjectTreeModel::rootFor<Room>() const;
|
||||
|
||||
//template<> Sprite *ProjectTreeModel::get<Sprite>(const QModelIndex &index);
|
||||
//template<> const Sprite *ProjectTreeModel::get<Sprite>(const QModelIndex &index) const;
|
||||
//template<> Sound *ProjectTreeModel::get<Sound>(const QModelIndex &index);
|
||||
//template<> const Sound *ProjectTreeModel::get<Sound>(const QModelIndex &index) const;
|
||||
//template<> Background *ProjectTreeModel::get<Background>(const QModelIndex &index);
|
||||
//template<> const Background *ProjectTreeModel::get<Background>(const QModelIndex &index) const;
|
||||
//template<> Path *ProjectTreeModel::get<Path>(const QModelIndex &index);
|
||||
//template<> const Path *ProjectTreeModel::get<Path>(const QModelIndex &index) const;
|
||||
//template<> Script *ProjectTreeModel::get<Script>(const QModelIndex &index);
|
||||
//template<> const Script *ProjectTreeModel::get<Script>(const QModelIndex &index) const;
|
||||
//template<> Font *ProjectTreeModel::get<Font>(const QModelIndex &index);
|
||||
//template<> const Font *ProjectTreeModel::get<Font>(const QModelIndex &index) const;
|
||||
//template<> TimeLine *ProjectTreeModel::get<TimeLine>(const QModelIndex &index);
|
||||
//template<> const TimeLine *ProjectTreeModel::get<TimeLine>(const QModelIndex &index) const;
|
||||
//template<> Object *ProjectTreeModel::get<Object>(const QModelIndex &index);
|
||||
//template<> const Object *ProjectTreeModel::get<Object>(const QModelIndex &index) const;
|
||||
//template<> Room *ProjectTreeModel::get<Room>(const QModelIndex &index);
|
||||
//template<> const Room *ProjectTreeModel::get<Room>(const QModelIndex &index) const;
|
||||
|
||||
//template<> bool ProjectTreeModel::rename<Sprite>(const Sprite &sprite, const QString &newName);
|
||||
//template<> bool ProjectTreeModel::rename<Sound>(const Sound &sound, const QString &newName);
|
||||
//template<> bool ProjectTreeModel::rename<Background>(const Background &background, const QString &newName);
|
||||
//template<> bool ProjectTreeModel::rename<Path>(const Path &path, const QString &newName);
|
||||
//template<> bool ProjectTreeModel::rename<Script>(const Script &script, const QString &newName);
|
||||
//template<> bool ProjectTreeModel::rename<Font>(const Font &font, const QString &newName);
|
||||
//template<> bool ProjectTreeModel::rename<TimeLine>(const TimeLine &timeLine, const QString &newName);
|
||||
//template<> bool ProjectTreeModel::rename<Object>(const Object &object, const QString &newName);
|
||||
//template<> bool ProjectTreeModel::rename<Room>(const Room &room, const QString &newName);
|
||||
|
@ -63,5 +63,7 @@
|
||||
<file>icons/timeline.png</file>
|
||||
<file>icons/undo.png</file>
|
||||
<file>icons/object-file.png</file>
|
||||
<file>icons/room-file.png</file>
|
||||
<file>icons/timeline-file.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Reference in New Issue
Block a user