Skip to content
Closed
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
8 changes: 8 additions & 0 deletions Core/GDCore/IDE/Dialogs/LayoutEditorCanvas/EditorSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ class GD_CORE_API EditorSettings {
* \brief Unserialize the settings.
*/
void UnserializeFrom(const SerializerElement& element);

/**
* \brief Return true if the settings contain no serialized data.
*/
bool IsEmpty() const {
gd::SerializerElement contentCopy(content);
return contentCopy.IsEmpty() && contentCopy.IsValueUndefined();
}
///@}

private:
Expand Down
26 changes: 25 additions & 1 deletion Core/GDCore/IDE/ProjectStripper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@

#include "GDCore/Project/EventsFunctionsContainer.h"
#include "GDCore/Project/EventsFunctionsExtension.h"
#include "GDCore/Project/EventsBasedObject.h"
#include "GDCore/Project/ExternalEvents.h"
#include "GDCore/Project/ExternalLayout.h"
#include "GDCore/Project/Layout.h"
#include "GDCore/Project/Project.h"
#include "GDCore/IDE/WholeProjectBrowser.h"
#include "GDCore/IDE/Dialogs/LayoutEditorCanvas/EditorSettings.h"
#include "GDCore/IDE/Events/BehaviorDefaultFlagClearer.h"
#include "GDCore/Serialization/SerializerElement.h"

namespace gd {

namespace {
void ClearEditorSettings(gd::EditorSettings &editorSettings) {
gd::SerializerElement emptyEditorSettings;
editorSettings.UnserializeFrom(emptyEditorSettings);
}
} // namespace

void GD_CORE_API ProjectStripper::StripProjectForExport(gd::Project &project) {
project.GetObjects().GetObjectGroups().Clear();
while (project.GetExternalEventsCount() > 0)
Expand All @@ -26,7 +36,14 @@ void GD_CORE_API ProjectStripper::StripProjectForExport(gd::Project &project) {
wholeProjectBrowser.ExposeObjects(project, behaviorDefaultFlagClearer);

for (unsigned int i = 0; i < project.GetLayoutsCount(); ++i) {
project.GetLayout(i).GetEvents().Clear();
auto &layout = project.GetLayout(i);
layout.GetEvents().Clear();
ClearEditorSettings(layout.GetAssociatedEditorSettings());
}

for (unsigned int i = 0; i < project.GetExternalLayoutsCount(); ++i) {
ClearEditorSettings(
project.GetExternalLayout(i).GetAssociatedEditorSettings());
}

// Keep:
Expand Down Expand Up @@ -58,6 +75,13 @@ void GD_CORE_API ProjectStripper::StripProjectForExport(gd::Project &project) {
auto &eventsBasedObject = eventsBasedObjects.at(objectIndex);
eventsBasedObject.SetFullName("");
eventsBasedObject.SetDescription("");
ClearEditorSettings(
eventsBasedObject.GetDefaultVariant().GetAssociatedEditorSettings());
for (auto &&eventsBasedObjectVariant :
eventsBasedObject.GetVariants().GetInternalVector()) {
ClearEditorSettings(
eventsBasedObjectVariant->GetAssociatedEditorSettings());
}
eventsBasedObject.GetEventsFunctions().GetInternalVector().clear();
eventsBasedObject.GetPropertyDescriptors().GetInternalVector().clear();
}
Expand Down
4 changes: 3 additions & 1 deletion Core/GDCore/Project/EventsBasedObjectVariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ void EventsBasedObjectVariant::SerializeTo(SerializerElement &element) const {

layers.SerializeLayersTo(element.AddChild("layers"));
initialInstances.SerializeTo(element.AddChild("instances"));
editorSettings.SerializeTo(element.AddChild("editionSettings"));
if (!editorSettings.IsEmpty()) {
editorSettings.SerializeTo(element.AddChild("editionSettings"));
}
}

void EventsBasedObjectVariant::UnserializeFrom(
Expand Down
6 changes: 4 additions & 2 deletions Core/GDCore/Project/ExternalLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ void ExternalLayout::UnserializeFrom(gd::Project &project,

void ExternalLayout::SerializeTo(SerializerElement& element) const {
element.SetAttribute("name", name);
instances.SerializeTo(element.AddChild("instances"));
editorSettings.SerializeTo(element.AddChild("editionSettings"));
instances.SerializeTo(element.AddChild("instances"));
if (!editorSettings.IsEmpty()) {
editorSettings.SerializeTo(element.AddChild("editionSettings"));
}
element.SetAttribute("associatedLayout", associatedLayout);
}

Expand Down
6 changes: 4 additions & 2 deletions Core/GDCore/Project/Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ void Layout::SerializeTo(SerializerElement& element) const {
element.SetAttribute("resourcesUnloading", resourcesUnloading);
element.SetAttribute("disableInputWhenNotFocused",
disableInputWhenNotFocused);

editorSettings.SerializeTo(element.AddChild("uiSettings"));

if (!editorSettings.IsEmpty()) {
editorSettings.SerializeTo(element.AddChild("uiSettings"));
}

objectsContainer.GetObjectGroups().SerializeTo(
element.AddChild("objectsGroups"));
Expand Down
6 changes: 5 additions & 1 deletion newIDE/app/scripts/import-libGD.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ if (shell.test('-f', path.join(sourceDirectory, 'libGD.js'))) {
let branch = (branchShellString.stdout || '').trim();
if (branch === 'HEAD') {
// We're in detached HEAD. Try to read the branch from the CI environment variables.
if (process.env.APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) {
if (process.env.SEMAPHORE_GIT_PR_BRANCH) {
branch = process.env.SEMAPHORE_GIT_PR_BRANCH;
} else if (process.env.SEMAPHORE_GIT_BRANCH) {
branch = process.env.SEMAPHORE_GIT_BRANCH;
} else if (process.env.APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) {
branch = process.env.APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH;
} else if (process.env.APPVEYOR_REPO_BRANCH) {
branch = process.env.APPVEYOR_REPO_BRANCH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import optionalRequire from '../../Utils/OptionalRequire';
import { type FileMetadata } from '../index';
import { unsplit } from '../../Utils/ObjectSplitter';
import { openFilePicker, readJSONFile } from '../../Utils/FileSystem';
import {
applyLocalProjectUiSettings,
getLocalProjectUiSettingsFilePath,
} from './LocalProjectUiSettings';
const fs = optionalRequire('fs');
const path = optionalRequire('path');

Expand All @@ -24,6 +28,10 @@ export const onOpen = (
|}> => {
const filePath = fileMetadata.fileIdentifier;
const projectPath = path.dirname(filePath);
const localProjectUiSettingsPath = getLocalProjectUiSettingsFilePath(
filePath,
path
);
return readJSONFile(filePath).then(object => {
return unsplit(object, {
getReferencePartialObject: referencePath => {
Expand All @@ -34,9 +42,19 @@ export const onOpen = (
// to be un-splitted, but not the content of these properties), to avoid very slow processing
// of large game files.
maxUnsplitDepth: 3,
}).then(() => {
return { content: object };
});
})
.then(() => {
if (!fs.existsSync(localProjectUiSettingsPath)) return;

return readJSONFile(localProjectUiSettingsPath).then(
localProjectUiSettings => {
applyLocalProjectUiSettings(object, localProjectUiSettings);
}
);
})
.then(() => {
return { content: object };
});
});
};

Expand Down
Loading