mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Allow any Event to dependencies to source files (only used by CppCodeEvent for now)
This is to avoid casting events to CppCodeEvent (and so relying explicitly on them) when doing dependencies analysis.
This commit is contained in:
@@ -14,6 +14,8 @@ namespace gd
|
||||
{
|
||||
|
||||
EventsList BaseEvent::badSubEvents;
|
||||
std::vector< gd::String > BaseEvent::emptyDependencies;
|
||||
gd::String BaseEvent::emptySourceFile;
|
||||
|
||||
BaseEvent::BaseEvent() :
|
||||
eventHeightNeedUpdate(true),
|
||||
|
@@ -111,6 +111,19 @@ public:
|
||||
virtual std::vector < gd::Expression* > GetAllExpressions() { std::vector < gd::Expression* > noExpr; return noExpr;};
|
||||
virtual std::vector < const gd::Expression* > GetAllExpressions() const { std::vector < const gd::Expression* > noExpr; return noExpr;};
|
||||
|
||||
/**
|
||||
* \brief Returns the dependencies on source files of the project.
|
||||
* \note Default implementation returns an empty list of dependencies. This is fine for most events that
|
||||
* are not related to adding custom user source code.
|
||||
*/
|
||||
virtual const std::vector<gd::String> & GetSourceFileDependencies() const { return emptyDependencies; };
|
||||
|
||||
/**
|
||||
* \brief Returns the name of the source file associated with the event
|
||||
* \note Default implementation returns an empty string. This is fine for most events that
|
||||
* are not related to adding custom user source code.
|
||||
*/
|
||||
virtual const gd::String & GetAssociatedGDManagedSourceFile(gd::Project & project) const { return emptySourceFile; };
|
||||
///@}
|
||||
|
||||
/** \name Code generation
|
||||
@@ -263,11 +276,13 @@ protected:
|
||||
mutable unsigned int renderedHeight;
|
||||
|
||||
private:
|
||||
bool folded; ///< True if the subevents should be hidden in the events editor
|
||||
bool folded; ///< True if the subevents should be hidden in the events editor
|
||||
bool disabled; ///<True if the event is disabled and must not be executed
|
||||
gd::String type; ///<Type of the event. Must be assigned at the creation. Used for saving the event for instance.
|
||||
|
||||
static gd::EventsList badSubEvents;
|
||||
static std::vector< gd::String > emptyDependencies;
|
||||
static gd::String emptySourceFile;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
void SetLastChangeTimeStamp(time_t lastChangeTimeStamp_) { lastChangeTimeStamp = lastChangeTimeStamp_; }
|
||||
|
||||
const std::vector<gd::String> & GetDependencies() const { return dependencies; };
|
||||
const std::vector<gd::String> & GetSourceFileDependencies() const { return dependencies; };
|
||||
void SetDependencies(const std::vector<gd::String> & dependencies_) { dependencies = dependencies_; };
|
||||
|
||||
bool GetPassSceneAsParameter() const { return passSceneAsParameter; };
|
||||
|
@@ -98,13 +98,11 @@ bool DependenciesAnalyzer::Analyze(gd::EventsList & events, bool isOnTopLevel)
|
||||
}
|
||||
} catch(...) {}
|
||||
|
||||
try {
|
||||
CppCodeEvent & cppCodeEvent = dynamic_cast<CppCodeEvent &>(events[i]);
|
||||
std::vector<gd::String> dependencies = events[i].GetSourceFileDependencies();
|
||||
sourceFilesDependencies.insert(dependencies.begin(), dependencies.end());
|
||||
|
||||
const std::vector<gd::String> & dependencies = cppCodeEvent.GetDependencies();
|
||||
sourceFilesDependencies.insert(dependencies.begin(), dependencies.end());
|
||||
sourceFilesDependencies.insert(cppCodeEvent.GetAssociatedGDManagedSourceFile(project));
|
||||
} catch(...) {}
|
||||
const gd::String & associatedSourceFile = events[i].GetAssociatedGDManagedSourceFile(project);
|
||||
if (!associatedSourceFile.empty()) sourceFilesDependencies.insert(associatedSourceFile);
|
||||
|
||||
if ( events[i].CanHaveSubEvents() )
|
||||
{
|
||||
|
@@ -256,8 +256,14 @@ EditCppCodeEvent::EditCppCodeEvent(wxWindow* parent, CppCodeEvent & event_, gd::
|
||||
|
||||
dependenciesList->Append(allFiles[i]->GetFileName());
|
||||
|
||||
if ( std::find(editedEvent.GetDependencies().begin(), editedEvent.GetDependencies().end(), allFiles[i]->GetFileName() ) != editedEvent.GetDependencies().end() )
|
||||
if (std::find(
|
||||
editedEvent.GetSourceFileDependencies().begin(),
|
||||
editedEvent.GetSourceFileDependencies().end(),
|
||||
allFiles[i]->GetFileName() ) != editedEvent.GetSourceFileDependencies().end()
|
||||
)
|
||||
{
|
||||
dependenciesList->Check(dependenciesList->GetCount()-1, true);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateFunctionPrototype();
|
||||
|
Reference in New Issue
Block a user