Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprites #85

Merged
merged 18 commits into from
Feb 1, 2020
140 changes: 77 additions & 63 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,114 +22,128 @@ set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/Dialogs")

# Include ENIGMA things
set(ENIGMA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Submodules/enigma-dev)
include_directories("${ENIGMA_DIR}/shared/protos/codegen" "${ENIGMA_DIR}/CommandLine/libEGM")
include_directories("${ENIGMA_DIR}/shared/protos/.eobjs/" "${ENIGMA_DIR}/CommandLine/libEGM")

# Populate a CMake variable with the sources
set(RGM_SOURCES
Plugins/RGMPlugin.cpp
Plugins/ServerPlugin.cpp
main.cpp
MainWindow.cpp
Dialogs/PreferencesDialog.cpp
Dialogs/TimelineChangeMoment.cpp
Editors/BaseEditor.cpp
Editors/CodeEditor.cpp
Editors/BackgroundEditor.cpp
Components/ArtManager.cpp
Components/Utility.cpp
Components/QMenuView.cpp
Components/RecentFiles.cpp
Models/TreeSortFilterProxyModel.cpp
Models/MessageModel.cpp
Models/RepeatedImageModel.cpp
Models/RepeatedStringModel.cpp
Models/ModelMapper.cpp
Models/ProtoModel.cpp
Models/RepeatedMessageModel.cpp
Models/ImmediateMapper.cpp
Models/ResourceModelMap.cpp
Models/TreeModel.cpp
Editors/ObjectEditor.cpp
Editors/PathEditor.cpp
Editors/CodeEditor.cpp
Editors/SoundEditor.cpp
Editors/ScriptEditor.cpp
Editors/ShaderEditor.cpp
Editors/FontEditor.cpp
Editors/PathEditor.cpp
Editors/BackgroundEditor.cpp
Editors/TimelineEditor.cpp
Editors/RoomEditor.cpp
Editors/SpriteEditor.cpp
Editors/ShaderEditor.cpp
Editors/ScriptEditor.cpp
Editors/SettingsEditor.cpp
Models/TreeModel.cpp
Models/SpriteModel.cpp
Models/ProtoModel.cpp
Models/ModelMapper.cpp
Models/ImmediateMapper.cpp
Models/ResourceModelMap.cpp
Models/RepeatedProtoModel.cpp
Models/TreeSortFilterProxyModel.cpp
Components/ArtManager.cpp
Components/Utility.cpp
Components/RecentFiles.cpp
Components/QMenuView.cpp
Widgets/AssetScrollAreaBackground.cpp
Widgets/BackgroundView.cpp
Editors/SpriteEditor.cpp
Editors/BaseEditor.cpp
Editors/RoomEditor.cpp
Widgets/CodeWidgetPlain.cpp
Widgets/AssetView.cpp
Widgets/CodeWidget.cpp
Widgets/BackgroundView.cpp
Widgets/StackedCodeWidget.cpp
Widgets/ColorPicker.cpp
Widgets/PathView.cpp
Widgets/RoomView.cpp
Widgets/AssetView.cpp
Plugins/RGMPlugin.cpp
Plugins/ServerPlugin.cpp
Widgets/PathView.cpp
Widgets/AssetScrollAreaBackground.cpp
Widgets/SpriteSubimageListView.cpp
Widgets/ColorPicker.cpp
Widgets/SpriteView.cpp
)

if (MSVC)
set(RGM_SOURCES ${RGM_SOURCES} qtplugins.cpp)
endif()

set(RGM_HEADERS
main.h
Plugins/ServerPlugin.h
Plugins/RGMPlugin.h
MainWindow.h
main.h
Dialogs/PreferencesDialog.h
Dialogs/PreferencesKeys.h
Dialogs/TimelineChangeMoment.h
Editors/CodeEditor.h
Editors/BaseEditor.h
Editors/BackgroundEditor.h
Editors/ObjectEditor.h
Editors/SoundEditor.h
Editors/ScriptEditor.h
Editors/ShaderEditor.h
Components/Logger.h
Components/RecentFiles.h
Components/QMenuView.h
Components/ArtManager.h
Components/QMenuView_p.h
Components/Utility.h
Models/TreeModel.h
Models/RepeatedStringModel.h
Models/ResourceModelMap.h
Models/ModelMapper.h
Models/TreeSortFilterProxyModel.h
Models/RepeatedImageModel.h
Models/MessageModel.h
Models/ImmediateMapper.h
Models/RepeatedMessageModel.h
Models/ProtoModel.h
Models/RepeatedModel.h
Editors/FontEditor.h
Editors/PathEditor.h
Editors/TimelineEditor.h
Editors/RoomEditor.h
Editors/SpriteEditor.h
Editors/SettingsEditor.h
Models/TreeModel.h
Models/ProtoModel.h
Models/ModelMapper.h
Models/ImmediateMapper.h
Models/SpriteModel.h
Models/ResourceModelMap.h
Models/RepeatedProtoModel.h
Models/TreeSortFilterProxyModel.h
Components/ArtManager.h
Components/RecentFiles.h
Components/Utility.h
Components/QMenuView.h
Components/Logger.h
Editors/SoundEditor.h
Editors/TimelineEditor.h
Editors/BackgroundEditor.h
Editors/ObjectEditor.h
Editors/RoomEditor.h
Editors/BaseEditor.h
Editors/ScriptEditor.h
Editors/CodeEditor.h
Editors/ShaderEditor.h
Widgets/AssetScrollArea.h
Widgets/AssetScrollAreaBackground.h
Widgets/BackgroundView.h
Widgets/CodeWidget.h
Widgets/StackedCodeWidget.h
Widgets/ColorPicker.h
Widgets/AssetScrollAreaBackground.h
Widgets/PathView.h
Widgets/ResourceSelector.h
Widgets/RoomView.h
Widgets/AssetView.h
Plugins/RGMPlugin.h
Plugins/ServerPlugin.h
Widgets/ColorPicker.h
Widgets/SpriteSubimageListView.h
Widgets/CodeWidget.h
Widgets/SpriteView.h
Widgets/BackgroundView.h

)

set(RGM_UI
MainWindow.ui
Dialogs/TimelineChangeMoment.ui
Dialogs/PreferencesDialog.ui
Dialogs/AddImageDialog.ui
Dialogs/TimelineChangeMoment.ui
Editors/CodeEditor.ui
Editors/SoundEditor.ui
Editors/BackgroundEditor.ui
Editors/ObjectEditor.ui
Editors/FontEditor.ui
Editors/PathEditor.ui
Editors/TimelineEditor.ui
Editors/RoomEditor.ui
Editors/SpriteEditor.ui
Editors/PathEditor.ui
Editors/SettingsEditor.ui
Editors/RoomEditor.ui
Editors/FontEditor.ui
Editors/TimelineEditor.ui
Editors/ObjectEditor.ui
)

set(RGM_RC
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)")
})
}
};
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my god did clang do this?

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);
};
Loading