Files
GDevelop/Core/GDCore/IDE/DependenciesAnalyzer.h
D8H 1f852648ef Make games launch faster by loading resources in the background (#5572)
* Only the first scene and global objects resources (images, sounds, 3D models etc...) will be downloaded during launch of the game. This usually allows for a very fast loading time.
* Other scenes resources will continue to load in the background. It has no impact on the game performance as this is done on other threads by the browser or the engine running the game.
* Scenes are loaded in the order they are listed in the project manager.
* You can also use actions and expressions to prioritize a scene (if it's known that a level will be needed soon for example) or read the current loading progress. This allows to create lightweight scenes that can act as custom loading screens. Otherwise, the launch loading screen will be shown if a scene is still loading when launched.
* Read more about this on https://wiki.gdevelop.io/gdevelop5/all-features/resources-loading/.
2023-11-22 22:51:24 +01:00

108 lines
3.0 KiB
C++

/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#if defined(GD_IDE_ONLY)
#ifndef DEPENDENCIESANALYZER_H
#define DEPENDENCIESANALYZER_H
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "GDCore/String.h"
namespace gd {
class EventsList;
}
namespace gd {
class BaseEvent;
}
namespace gd {
class Project;
}
namespace gd {
class Layout;
}
namespace gd {
class ExternalEvents;
}
/**
* \brief Compute the dependencies of a scene or external events.
*/
class GD_CORE_API DependenciesAnalyzer {
public:
/**
* \brief Constructor for analyzing the dependencies of a layout
*/
DependenciesAnalyzer(const gd::Project& project_, const gd::Layout& layout_);
/**
* \brief Constructor for analyzing the dependencies of external events.
*/
DependenciesAnalyzer(const gd::Project& project_,
const gd::ExternalEvents& externalEvents);
virtual ~DependenciesAnalyzer();
/**
* \brief Search the dependencies and return true if there are no circular
* dependencies in the events of the layout or external events passed in the
* constructor.
*
* \return true if there are no circular dependencies, false otherwise (in
* this case, no events code generation must done).
*/
bool Analyze();
/**
* \brief Return the scenes being dependencies of the scene or external events
* passed in the constructor.
*/
const std::set<gd::String>& GetScenesDependencies() const {
return scenesDependencies;
};
/**
* \brief Return the external events being dependencies of the scene or
* external events passed in the constructor.
*/
const std::set<gd::String>& GetExternalEventsDependencies() const {
return externalEventsDependencies;
};
/**
* \brief Return the source files being dependencies of the scene or external
* events passed in the constructor.
*/
const std::set<gd::String>& GetSourceFilesDependencies() const {
return sourceFilesDependencies;
};
private:
/**
* \brief Analyze the dependencies of the events.
*
* \param events The events to be analyzed
* \param isOnTopLevel If true, assumes that the events are on the top level
* (they have no parents). \return false if a circular dependency exists, true
* otherwise.
*/
bool Analyze(const gd::EventsList& events);
std::set<gd::String> scenesDependencies;
std::set<gd::String> externalEventsDependencies;
std::set<gd::String> sourceFilesDependencies;
std::vector<gd::String>
parentScenes; ///< Used to check for circular dependencies.
std::vector<gd::String>
parentExternalEvents; ///< Used to check for circular dependencies.
const gd::Project& project;
const gd::Layout* layout;
const gd::ExternalEvents* externalEvents;
};
#endif // DEPENDENCIESANALYZER_H
#endif