Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 13 additions & 46 deletions builder/builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <minizip/zip.h>

#include <QCoreApplication>
#include <QDir>

Builder::Builder() {
connect(AssetManager::instance(), &AssetManager::importFinished, this, &Builder::onImportFinished, Qt::QueuedConnection);
Expand Down Expand Up @@ -88,61 +87,29 @@ void Builder::package(const TString &target) {
zipClose(zf, nullptr);
}

bool copyRecursively(QString sourceFolder, QString destFolder) {
QDir sourceDir(sourceFolder);
if(!sourceDir.exists()) {
return false;
}

QDir destDir(destFolder);
if(!destDir.exists()) {
destDir.mkdir(destFolder);
}

QStringList files = sourceDir.entryList(QDir::Files);
for(int i = 0; i< files.count(); i++) {
QString srcName = sourceFolder + "/" + files[i];
QString destName = destFolder + "/" + files[i];
if(!QFile::copy(srcName, destName)) {
return false;
}
}

files.clear();
files = sourceDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
for(int i = 0; i< files.count(); i++) {
QString srcName = sourceFolder + "/" + files[i];
QString destName = destFolder + "/" + files[i];
if(!copyRecursively(srcName, destName)) {
return false;
}
}
return true;
}

void Builder::onImportFinished() {
ProjectSettings *project = ProjectSettings::instance();
TString platform = project->currentPlatformName();
TString path = project->artifact();
Url info(path);
TString targetPath = project->targetPath() + "/" + platform + "/";
TString targetPath = project->targetPath() + "/" + platform;

QDir dir;
dir.mkpath(targetPath.data());
TString target(targetPath + info.name());
if(!File::exists(targetPath) && !File::mkPath(targetPath)) {
aDebug() << "Unable to create build directory at:" << targetPath;
}

bool isDir = File::isDir(target);
if((isDir && QDir(target.data()).removeRecursively()) || File::remove(target)) {
aInfo() << "Previous build removed.";
for(auto &it : File::list(targetPath)) {
File::remove(it);
}

if(isDir && copyRecursively(path.data(), target.data())) {
File::copy(path, target);
bool result = true;
for(const TString &it : project->artifacts()) {
result &= File::copy(it, targetPath + "/" + Url(it).name());
}

aInfo() << "New build copied to:" << target;
if(result) {
aInfo() << "New build copied to:" << targetPath;

if(!project->currentBuilder()->isBundle(platform)) {
package(target);
package(targetPath + "/" + project->projectName());

aInfo() << "Packaging Done.";
}
Expand Down
8 changes: 4 additions & 4 deletions builder/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);

QCoreApplication::setOrganizationName(COMPANY_NAME);
QCoreApplication::setApplicationName(BUILDER_NAME);
QCoreApplication::setApplicationName(EDITOR_NAME); // Special for settings sharing
QCoreApplication::setApplicationVersion(SDK_VERSION);

QCommandLineParser parser;
Expand All @@ -55,17 +55,17 @@ int main(int argc, char *argv[]) {
parser.addVersionOption();

QCommandLineOption sourceFileOption(QStringList() << "s" << "source",
QCoreApplication::translate("main", "Project file <.forge>."),
QCoreApplication::translate("main", "Project file <.forge>"),
QCoreApplication::translate("main", "project"));
parser.addOption(sourceFileOption);

QCommandLineOption targetDirectoryOption(QStringList() << "t" << "target",
QCoreApplication::translate("main", "Build Project into <directory>."),
QCoreApplication::translate("main", "Build Project into <directory>"),
QCoreApplication::translate("main", "directory"));
parser.addOption(targetDirectoryOption);

QCommandLineOption platformOption(QStringList() << "p" << "platform",
QCoreApplication::translate("main", "Specify the target <platform>."),
QCoreApplication::translate("main", "Specify the target <platform>"),
QCoreApplication::translate("main", "platform"));
parser.addOption(platformOption);

Expand Down
7 changes: 3 additions & 4 deletions engine/includes/editor/projectsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class ENGINE_EXPORT ProjectSettings : public Object {

void reportTypes(const std::set<TString> &types);

TString artifact() const;
void setArtifact(const TString &value);
StringList artifacts() const;
void setArtifacts(const StringList &value);

void loadSettings();
void saveSettings();
Expand All @@ -99,6 +99,7 @@ class ENGINE_EXPORT ProjectSettings : public Object {

private:
StringList m_platforms;
StringList m_artifacts;

std::map<TString, bool> m_plugins;
std::map<TString, CodeBuilder *> m_supportedPlatforms;
Expand All @@ -114,8 +115,6 @@ class ENGINE_EXPORT ProjectSettings : public Object {

TString m_currentPlatform;

TString m_artifact;

TString m_projectPath;
TString m_targetPath;
TString m_contentPath;
Expand Down
14 changes: 6 additions & 8 deletions engine/src/editor/codebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "editor/assetmanager.h"

#include <QFile>
#include <QDir>
#include <QRegularExpression>

namespace {
Expand Down Expand Up @@ -80,7 +79,7 @@ void CodeBuilder::renameAsset(AssetConverterSettings *settings, const TString &o
"(%1"
};

for(auto it : templates) {
for(auto &it : templates) {
data.replace(it.arg(oldName.data()).toStdString(), it.arg(newName.data()).toStdString());
}

Expand Down Expand Up @@ -140,8 +139,7 @@ void CodeBuilder::updateTemplate(const TString &src, const TString &dst) {
}
file.close();

QDir dir;
dir.mkpath(Url(dst).dir().data());
File::mkPath(Url(dst).dir());

file.setFileName(dst.data());
if(file.open(QFile::WriteOnly | QFile::Text | QFile::Truncate)) {
Expand All @@ -154,7 +152,7 @@ void CodeBuilder::updateTemplate(const TString &src, const TString &dst) {
void CodeBuilder::generateLoader(const TString &dst, const StringList &modules) {
std::map<TString, TString> classes;
// Generate plugin loader
for(TString it : m_sources) {
for(const TString &it : m_sources) {
QFile file(it.data());
if(file.open(QFile::ReadOnly | QFile::Text)) {
QString data = file.readLine();
Expand Down Expand Up @@ -226,7 +224,7 @@ void CodeBuilder::generateLoader(const TString &dst, const StringList &modules)

TString name = ProjectSettings::instance()->projectName() + "-editor";
for(auto &it : PluginManager::instance()->plugins()) {
Url info(it.toStdString());
Url info(it);
if(name != info.baseName()) {
m_values[gEditorLibrariesList].append(TString(12, ' ') + "\"" + info.baseName() + "\",\n");
}
Expand Down Expand Up @@ -255,7 +253,7 @@ TString CodeBuilder::project() const {

StringList CodeBuilder::sources() const {
StringList list;
for(auto it : m_sources) {
for(auto &it : m_sources) {
list.push_back(it);
}
return list;
Expand All @@ -266,7 +264,7 @@ void CodeBuilder::rescanSources(const TString &path) {

for(auto &filePath : File::list(path)) {
TString suff = Url(filePath).completeSuffix().toLower();
for(auto it : suffixes()) {
for(auto &it : suffixes()) {
if(it == suff) {
m_sources.insert(filePath);
break;
Expand Down
50 changes: 4 additions & 46 deletions engine/src/editor/editorsettings.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#include "editorsettings.h"

#include <QVariant>

#include <QSettings>
#include <QColor>
#include <QCoreApplication>
#include <QTranslator>

#include <log.h>

namespace {
const char *gSettings(".Settings");
const char *gEditorSettings("EditorSettings");
}

Expand Down Expand Up @@ -61,47 +58,8 @@ void EditorSettings::loadSettings() {
setProperty(name.data(), it->second);
}
}
} else { /// \todo To be removed in mid 2025
QSettings settings(COMPANY_NAME, EDITOR_NAME);
QVariantMap data = settings.value(gSettings).toMap();

for(const TString &it : dynamicPropertyNames()) {
TString info = propertyTag(dynamicPropertyInfo(it.data()), "editor=");
Variant originValue = property(it.data());
QVariant newValue = data.value(it.data());

if(newValue.isValid()) {
switch(originValue.userType()) {
case MetaType::BOOLEAN: {
bool value = newValue.toBool();
setProperty(it.data(), value);
} break;
case MetaType::INTEGER: {
int value = newValue.toInt();
setProperty(it.data(), value);
} break;
case MetaType::FLOAT: {
float value = newValue.toFloat();
setProperty(it.data(), value);
} break;
case MetaType::STRING: {
TString value(newValue.toString().toStdString());
setProperty(it.data(), value);
} break;
case MetaType::VECTOR4: {
if(info == "Color") {
QString str(newValue.toString());
if(!str.isEmpty()) {
QColor color(str);
Vector4 value(color.redF(), color.greenF(), color.blueF(), color.alphaF());
setProperty(it.data(), value);
}
}
} break;
default: break;
}
}
}
} else {
aError() << "Unable to load settings";
}

blockSignals(false);
Expand Down
25 changes: 14 additions & 11 deletions engine/src/editor/pluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

#include "config.h"

const char *gComponents("components");
namespace {
const char *gComponents("components");
const char *gLabel("[PluginManager]");
}

PluginManager *PluginManager::m_instance = nullptr;

Expand Down Expand Up @@ -257,13 +260,13 @@ bool PluginManager::loadPlugin(const TString &path, bool reload) {
}
return true;
} else {
aError() << "[PluginManager] Can't create plugin:" << qPrintable(lib->fileName());
aError() << gLabel << "Can't create plugin:" << qPrintable(lib->fileName());
}
} else {
aError() << "[PluginManager] Bad plugin:" << qPrintable(lib->fileName());
aError() << gLabel << "Bad plugin:" << qPrintable(lib->fileName());
}
} else {
aError() << "[PluginManager] Can't load plugin:" << qPrintable(lib->fileName()) << "With error:" << qPrintable(lib->errorString());
aError() << gLabel << "Can't load plugin:" << qPrintable(lib->fileName()) << "With error:" << qPrintable(lib->errorString());
}
delete lib;
return false;
Expand Down Expand Up @@ -308,26 +311,26 @@ void PluginManager::reloadPlugin(const TString &path) {
deserializeComponents(result);
// Remove old plugin
if(File::remove(temp)) {
aInfo() << "Plugin:" << path << "reloaded";
aInfo() << gLabel << "Plugin:" << path << "reloaded";
return;
}
}
delete plugin->library;
} else {
aError() << "Plugin unload:" << path << "failed";
aError() << gLabel << "Plugin unload:" << path << "failed";
}
} else { // Just copy and load plugin
if(File::copy(path, dest) && loadPlugin(dest)) {
aInfo() << "Plugin:" << dest << "simply loaded";
aInfo() << gLabel << "Plugin:" << dest << "loaded";
return;
}
}
// Rename it back
if(File::remove(dest) && File::rename(temp, dest)) {
if(loadPlugin(dest)) {
aInfo() << "Old version of plugin:" << path << "is loaded";
aInfo() << gLabel << "Old version of plugin:" << path << "is loaded";
} else {
aError() << "Load of old version of plugin:" << path << "is failed";
aError() << gLabel << "Load of old version of plugin:" << path << "is failed";
}
}
}
Expand Down Expand Up @@ -355,7 +358,7 @@ bool PluginManager::registerSystem(Module *plugin, const char *name) {
}

void PluginManager::initSystems() {
for(auto it : m_systems) {
for(auto &it : m_systems) {
it.second->init();
}
}
Expand Down Expand Up @@ -390,7 +393,7 @@ void PluginManager::syncWhiteList() {
StringList toRemove;

auto &plugins = ProjectSettings::instance()->plugins();
for(auto it : plugins) {
for(auto &it : plugins) {
if(it.second) {
if(std::find(m_initialWhiteList.begin(), m_initialWhiteList.end(), it.first) != m_initialWhiteList.end()) {
toRemove.push_back(it.first);
Expand Down
8 changes: 4 additions & 4 deletions engine/src/editor/projectsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ void ProjectSettings::saveSettings() {
}
}

TString ProjectSettings::artifact() const {
return m_artifact;
StringList ProjectSettings::artifacts() const {
return m_artifacts;
}

void ProjectSettings::setArtifact(const TString &value) {
m_artifact = value;
void ProjectSettings::setArtifacts(const StringList &value) {
m_artifacts = value;
}

TString ProjectSettings::projectName() const {
Expand Down
3 changes: 0 additions & 3 deletions engine/src/systems/rendersystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#include "components/camera.h"
#include "components/actor.h"

#include "resources/material.h"
#include "resources/rendertarget.h"

#include "pipelinetasks/ambientocclusion.h"
#include "pipelinetasks/antialiasing.h"
#include "pipelinetasks/bloom.h"
Expand Down
Loading
Loading