mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-08-24 22:31:30 -04:00
44ba8a04ce
A gameplay test plays a game: it presses keys, moves the mouse, touches the screen, then checks that what should happen actually happens. For example, if the coin is collected, the score goes up, the enemy hurts the player... Tests run in a preview of the game, usually much faster than real time. [Read more about them on this page](https://wiki.gdevelop.io/gdevelop5/interface/gameplay-tests/)
75 lines
2.8 KiB
C++
75 lines
2.8 KiB
C++
/*
|
|
* GDevelop Core
|
|
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
|
* reserved. This project is released under the MIT License.
|
|
*/
|
|
#include "ProjectStripper.h"
|
|
|
|
#include "GDCore/Project/EventsFunctionsContainer.h"
|
|
#include "GDCore/Project/EventsFunctionsExtension.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/Events/BehaviorDefaultFlagClearer.h"
|
|
|
|
namespace gd {
|
|
|
|
void GD_CORE_API ProjectStripper::StripProjectForExport(gd::Project &project) {
|
|
project.GetObjects().GetObjectGroups().Clear();
|
|
while (project.GetExternalEventsCount() > 0)
|
|
project.RemoveExternalEvents(project.GetExternalEvents(0).GetName());
|
|
|
|
// Tests are editor-only: their source is sent to the game at runtime by the
|
|
// test runner, so they are never included in exported or previewed games.
|
|
project.GetTests().ClearTests();
|
|
|
|
gd::BehaviorDefaultFlagClearer behaviorDefaultFlagClearer;
|
|
gd::WholeProjectBrowser wholeProjectBrowser;
|
|
wholeProjectBrowser.ExposeObjects(project, behaviorDefaultFlagClearer);
|
|
|
|
for (unsigned int i = 0; i < project.GetLayoutsCount(); ++i) {
|
|
project.GetLayout(i).GetEvents().Clear();
|
|
}
|
|
|
|
// Keep:
|
|
// - the EventsBasedObject object list because it's useful for the Runtime
|
|
// to create the child-object.
|
|
// - the globalVariables and sceneVariables
|
|
for (unsigned int extensionIndex = 0;
|
|
extensionIndex < project.GetEventsFunctionsExtensionsCount();
|
|
++extensionIndex) {
|
|
auto &extension = project.GetEventsFunctionsExtension(extensionIndex);
|
|
extension.SetFullName("");
|
|
extension.SetShortDescription("");
|
|
extension.SetDescription("");
|
|
extension.SetHelpPath("");
|
|
extension.SetIconUrl("");
|
|
extension.SetPreviewIconUrl("");
|
|
extension.SetOrigin("", "");
|
|
extension.SetVersion("");
|
|
auto &eventsBasedObjects = extension.GetEventsBasedObjects();
|
|
if (eventsBasedObjects.size() == 0 &&
|
|
extension.GetGlobalVariables().Count() == 0 &&
|
|
extension.GetSceneVariables().Count() == 0) {
|
|
project.RemoveEventsFunctionsExtension(extension.GetName());
|
|
extensionIndex--;
|
|
continue;
|
|
}
|
|
for (unsigned int objectIndex = 0; objectIndex < eventsBasedObjects.size();
|
|
++objectIndex) {
|
|
auto &eventsBasedObject = eventsBasedObjects.at(objectIndex);
|
|
eventsBasedObject.SetFullName("");
|
|
eventsBasedObject.SetDescription("");
|
|
eventsBasedObject.GetEventsFunctions().GetInternalVector().clear();
|
|
eventsBasedObject.GetPropertyDescriptors().GetInternalVector().clear();
|
|
}
|
|
extension.GetEventsBasedBehaviors().Clear();
|
|
extension.GetEventsFunctions().ClearEventsFunctions();
|
|
extension.GetTests().ClearTests();
|
|
}
|
|
}
|
|
|
|
} // namespace gd
|