-
Notifications
You must be signed in to change notification settings - Fork 57
/
project.h
93 lines (75 loc) · 2.89 KB
/
project.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* This file is part of EasyRPG Editor.
*
* EasyRPG Editor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Editor. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QDir>
#include <QList>
#include <QSettings>
#include <QString>
#include <QCoreApplication>
#include <memory>
#include "common/filefinder.h"
#include "project_data.h"
#include <lcf/rpg/database.h>
#include <lcf/rpg/map.h>
#include <lcf/rpg/treemap.h>
class Project {
Q_DECLARE_TR_FUNCTIONS(Project)
public:
using ProjectList = std::vector<std::shared_ptr<Project>>;
static ProjectList enumerate(const QDir& path);
static std::shared_ptr<Project> load(const QString& path);
static std::shared_ptr<Project> load(const QDir& path);
bool loadDatabaseAndMapTree();
std::unique_ptr<lcf::rpg::Map> loadMap(int index) const;
bool saveMap(lcf::rpg::Map& map, int index, bool incSavecount = true);
void relocate(const QDir& newDir, FileFinder::ProjectType newProjectType);
QString findFile(const QString& filename, FileFinder::FileType type = FileFinder::FileType::Default) const;
QString findFile(const QString& dir, const QString& filename, FileFinder::FileType type = FileFinder::FileType::Default) const;
/**
* Does a case-insensitive file search. When the file is not found the
* requested filename is returned.
* @param filename File to find
* @return Found file or the passed filename when not found
*/
QString findFileOrDefault(const QString& filename);
QString findDirectory(const QString& dir) const;
QString findDirectory(const QString& baseDir, const QString& dir) const;
QString detectEncoding();
QString encoding() const;
void setEncoding(const QString& encoding);
QDir projectDir() const;
void setProjectDir(const QDir& projectDir);
QString gameTitle() const;
void setGameTitle(const QString& gameTitle);
FileFinder::ProjectType projectType() const;
void setProjectType(FileFinder::ProjectType projectType);
lcf::rpg::Database& database();
const lcf::rpg::Database& database() const;
lcf::rpg::TreeMap& treeMap();
const lcf::rpg::TreeMap& treeMap() const;
ProjectData& projectData();
const ProjectData& projectData() const;
bool saveDatabase(bool incSavecount = true);
bool saveTreeMap();
private:
FileFinder::ProjectType m_projectType;
QString m_encoding;
QDir m_projectDir;
std::shared_ptr<QSettings> m_projectSettings;
QString m_gameTitle;
ProjectData m_data;
};