File indexing completed on 2024-05-12 05:39:49
0001 /*************************************************************************** 0002 * Copyright (C) 2021 by Renaud Guezennec * 0003 * http://www.rolisteam.org/contact * 0004 * * 0005 * This software is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #ifndef CAMPAIGNEDITOR_H 0021 #define CAMPAIGNEDITOR_H 0022 0023 #include <QObject> 0024 #include <QUndoCommand> 0025 0026 #include <memory> 0027 0028 #include "media/mediatype.h" 0029 #include <core_global.h> 0030 0031 namespace campaign 0032 { 0033 class Campaign; 0034 class Media; 0035 class CORE_EXPORT CampaignEditor : public QObject 0036 { 0037 Q_OBJECT 0038 Q_PROPERTY(Campaign* campaign READ campaign CONSTANT) 0039 public: 0040 explicit CampaignEditor(QObject* parent= nullptr); 0041 0042 Campaign* campaign() const; 0043 0044 bool open(const QString& from); 0045 0046 // media 0047 bool addMedia(const QString& id, const QString& dest, const QByteArray& array); 0048 bool removeMedia(const QString& src); 0049 bool removeFile(const QString& src); 0050 bool createDefault(const QString& src); 0051 0052 QString saveAvatar(const QString& id, const QByteArray& array); 0053 0054 QString mediaFullPathWithExtension(const QString& file, Core::ContentType type) const; 0055 QString mediaFullPath(const QString& file) const; 0056 0057 void doCommand(QUndoCommand* command); 0058 0059 QString campaignDir() const; 0060 QString currentDir() const; 0061 0062 bool mergeAudioFile(const QString& source, const QString& dest); 0063 bool copyMedia(const QString& source, const QString& dest, Core::MediaType type); 0064 bool copyTheme(const QString& source, const QString& dest); 0065 bool mergeJsonArrayFile(const QString& source, const QString& dest); 0066 0067 bool loadDiceAlias(const QString& source); // import 0068 bool loadStates(const QString& source, const QString& srcDir, const QString& dest, 0069 const QString& destDir); // import 0070 bool loadNpcData(const QString& source, const QString& srcDir, const QString& dest, 0071 const QString& destDir); // import 0072 0073 signals: 0074 void campaignLoaded(const QStringList missingFiles, const QStringList unmanagedFiles); 0075 void performCommand(QUndoCommand* command); 0076 void importedFile(campaign::Media* media); 0077 0078 private: 0079 QString m_root; 0080 std::unique_ptr<campaign::Campaign> m_campaign; 0081 }; 0082 } // namespace campaign 0083 #endif // CAMPAIGNEDITOR_H