Skip to content

Commit

Permalink
implement sprite editor, fix inconsistent model changes error
Browse files Browse the repository at this point in the history
  • Loading branch information
fundies committed Jan 13, 2020
1 parent 52dd2f1 commit 92a07d1
Show file tree
Hide file tree
Showing 32 changed files with 1,095 additions and 450 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ set(RGM_SOURCES
Editors/SpriteEditor.cpp
Editors/SettingsEditor.cpp
Models/TreeModel.cpp
Models/SpriteModel.cpp
Models/RepeatedStringModel.cpp
Models/SpriteSubimageModel.cpp
Models/ProtoModel.cpp
Models/ModelMapper.cpp
Models/ImmediateMapper.cpp
Expand All @@ -63,6 +64,8 @@ set(RGM_SOURCES
Widgets/PathView.cpp
Widgets/RoomView.cpp
Widgets/AssetView.cpp
Widgets/SpriteView.cpp
Widgets/SpriteSubimageListView.cpp
Plugins/RGMPlugin.cpp
Plugins/ServerPlugin.cpp
)
Expand Down Expand Up @@ -94,7 +97,8 @@ set(RGM_HEADERS
Models/ProtoModel.h
Models/ModelMapper.h
Models/ImmediateMapper.h
Models/SpriteModel.h
Models/RepeatedStringModel.h
Models/SpriteSubimageModel.h
Models/ResourceModelMap.h
Models/RepeatedProtoModel.h
Models/TreeSortFilterProxyModel.h
Expand All @@ -112,6 +116,8 @@ set(RGM_HEADERS
Widgets/PathView.h
Widgets/RoomView.h
Widgets/AssetView.h
Widgets/SpriteView.h
Widgets/SpriteSubimageListView.h
Plugins/RGMPlugin.h
Plugins/ServerPlugin.h
)
Expand Down
73 changes: 34 additions & 39 deletions Components/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <QImage>
#include <QImageReader>
#include <QImageWriter>
#include <QMimeDatabase>
#include <QMap>
#include <QMimeDatabase>

struct MimeType {
MimeType() {}
Expand All @@ -14,11 +14,12 @@ struct MimeType {
};

class MimeTypeList {
public:
public:
MimeTypeList() {}
MimeTypeList(const QList<QByteArray>& mimeTypes, const QList<MimeType> additionalMimeTypes) {
QStringList temp;
foreach(const QByteArray& mime, mimeTypes) temp.append(mime);
foreach (const QByteArray& mime, mimeTypes)
temp.append(mime);

QMimeDatabase mimeDB;
for (const QString& mimeTypeFilter : temp) {
Expand All @@ -33,13 +34,13 @@ class MimeTypeList {
filters.append(mime.fileFilter);
}

for (const MimeType& mime : additionalMimeTypes) {
nameFilters.append(mime.description);
}
for (const MimeType& mime : additionalMimeTypes) {
nameFilters.append(mime.description);
}

filters.prepend(QString("(%1)").arg(filters.join(' ')));
nameFilters.prepend("All Supported " + filters[0]);
nameFilters.append("All Files (*)");
filters.prepend(QString("(%1)").arg(filters.join(' ')));
nameFilters.prepend("All Supported " + filters[0]);
nameFilters.append("All Files (*)");
}

QStringList nameFilters;
Expand All @@ -48,41 +49,35 @@ class MimeTypeList {
};

static const QMap<FileDialog_t, MimeTypeList> derp = {

{FileDialog_t::SpriteLoad,
MimeTypeList(QImageReader::supportedMimeTypes(), {MimeType("*.Sprite.gmx", "GMX Background (*.Background.gmx)"),
MimeType("*.spr", "EGM Background (*.bkg)")})},

{FileDialog_t::SpriteSave,
MimeTypeList(QImageWriter::supportedMimeTypes(), {MimeType("*.spr", "EGM Background (*.bkg)")})},

{FileDialog_t::BackgroundLoad, MimeTypeList(QImageReader::supportedMimeTypes(),
{
MimeType("*.Background.gmx", "GMX Background (*.Background.gmx)"),
MimeType("*.bkg", "EGM Background (*.bkg)")
})
},

{FileDialog_t::BackgroundSave, MimeTypeList(QImageWriter::supportedMimeTypes(),
{
MimeType("*.bkg", "EGM Background (*.bkg)")
})
},
{MimeType("*.Background.gmx", "GMX Background (*.Background.gmx)"),
MimeType("*.bkg", "EGM Background (*.bkg)")})},

{FileDialog_t::BackgroundSave,
MimeTypeList(QImageWriter::supportedMimeTypes(), {MimeType("*.bkg", "EGM Background (*.bkg)")})},

{FileDialog_t::SoundLoad, MimeTypeList({},
{
MimeType("*.Sound.gmx", "GMX Sound (*.Sound.gmx)"),
MimeType("*.snd", "EGM Sound (*.snd)"),
MimeType("*.ogg", "OGG (*.ogg)"),
MimeType("*.flac", "FLAC (*.flac)"),
MimeType("*.mp3", "MP3 (*.mp3)"),
MimeType("*.mod", "MOD (*.mod)"),
MimeType("*.wav", "Wav (*.wav)"),
})
},

{FileDialog_t::SoundSave, MimeTypeList({},
{
MimeType("*.snd", "EGM Sound (*.snd)")
})
}
};
{
MimeType("*.Sound.gmx", "GMX Sound (*.Sound.gmx)"),
MimeType("*.snd", "EGM Sound (*.snd)"),
MimeType("*.ogg", "OGG (*.ogg)"),
MimeType("*.flac", "FLAC (*.flac)"),
MimeType("*.mp3", "MP3 (*.mp3)"),
MimeType("*.mod", "MOD (*.mod)"),
MimeType("*.wav", "Wav (*.wav)"),
})},

FileDialog::FileDialog(QWidget* parent, FileDialog_t type, bool writer) :
QFileDialog(parent, "Select ") {
{FileDialog_t::SoundSave, MimeTypeList({}, {MimeType("*.snd", "EGM Sound (*.snd)")})}};

FileDialog::FileDialog(QWidget* parent, FileDialog_t type, bool writer) : QFileDialog(parent, "Select ") {
if (writer)
setAcceptMode(QFileDialog::AcceptSave);
else {
Expand Down
9 changes: 2 additions & 7 deletions Components/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@

#include <QFileDialog>

enum FileDialog_t {
BackgroundLoad,
BackgroundSave,
SoundSave,
SoundLoad
};
enum FileDialog_t { BackgroundLoad, BackgroundSave, SpriteLoad, SpriteSave, SoundSave, SoundLoad };

class FileDialog : public QFileDialog {
public:
FileDialog(QWidget* parent, FileDialog_t type, bool writer);
FileDialog(QWidget* parent, FileDialog_t type, bool writer);
};
22 changes: 11 additions & 11 deletions Editors/RoomEditor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1471,17 +1471,6 @@
</action>
</widget>
<customwidgets>
<customwidget>
<class>ColorPicker</class>
<extends>QWidget</extends>
<header>Widgets/ColorPicker.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>RoomView</class>
<extends>QWidget</extends>
<header>Widgets/RoomView.h</header>
</customwidget>
<customwidget>
<class>AssetScrollArea</class>
<extends>QScrollArea</extends>
Expand All @@ -1494,6 +1483,17 @@
<header>Widgets/AssetScrollAreaBackground.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ColorPicker</class>
<extends>QWidget</extends>
<header>Widgets/ColorPicker.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>RoomView</class>
<extends>QWidget</extends>
<header>Widgets/RoomView.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
Expand Down
Loading

0 comments on commit 92a07d1

Please sign in to comment.