-
Notifications
You must be signed in to change notification settings - Fork 932
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reload resources in the editor when the resource changes (#5631)
GDevelop now refreshes resources (images, videos, 3D models, fonts, etc.) when a change is detected on the filesystem so that you can immediately see the changes. This allows to efficiently use GDevelop alongside other tools (Tiled or LDtk for instance). Notes: - This logically only affects the desktop version for projects saved on the filesystem; - You can deactivate it in the preferences.
- Loading branch information
1 parent
740485b
commit 91db750
Showing
55 changed files
with
768 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "ObjectsUsingResourceCollector.h" | ||
|
||
#include "GDCore/Project/Object.h" | ||
#include "GDCore/Project/Project.h" | ||
|
||
namespace gd { | ||
|
||
void ObjectsUsingResourceCollector::DoVisitObject(gd::Object& object) { | ||
gd::ResourceNameMatcher resourceNameMatcher(resourceName); | ||
|
||
object.GetConfiguration().ExposeResources(resourceNameMatcher); | ||
if (resourceNameMatcher.AnyResourceMatches()) { | ||
objectNames.push_back(object.GetName()); | ||
} | ||
}; | ||
|
||
ObjectsUsingResourceCollector::~ObjectsUsingResourceCollector() {} | ||
|
||
} // namespace gd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* GDevelop Core | ||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights | ||
* reserved. This project is released under the MIT License. | ||
*/ | ||
|
||
#ifndef ProjectObjectsUsingResourceCollector_H | ||
#define ProjectObjectsUsingResourceCollector_H | ||
|
||
#include <vector> | ||
|
||
#include "GDCore/IDE/Project/ArbitraryObjectsWorker.h" | ||
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h" | ||
#include "GDCore/String.h" | ||
|
||
namespace gd { | ||
class Object; | ||
} // namespace gd | ||
|
||
namespace gd { | ||
|
||
class GD_CORE_API ObjectsUsingResourceCollector | ||
: public ArbitraryObjectsWorker { | ||
public: | ||
ObjectsUsingResourceCollector(const gd::String& resourceName_) | ||
: resourceName(resourceName_){}; | ||
virtual ~ObjectsUsingResourceCollector(); | ||
|
||
std::vector<gd::String>& GetObjectNames() { return objectNames; } | ||
|
||
private: | ||
void DoVisitObject(gd::Object& object) override; | ||
|
||
std::vector<gd::String> objectNames; | ||
gd::String resourceName; | ||
}; | ||
|
||
class GD_CORE_API ResourceNameMatcher : public ArbitraryResourceWorker { | ||
public: | ||
ResourceNameMatcher(const gd::String& resourceName_) | ||
: resourceName(resourceName_), matchesResourceName(false){}; | ||
virtual ~ResourceNameMatcher(){}; | ||
|
||
bool AnyResourceMatches() { return matchesResourceName; } | ||
void Reset() { matchesResourceName = false; } | ||
|
||
private: | ||
virtual void ExposeFile(gd::String& resource) override{ | ||
/*Don't care, we just read resource names*/ | ||
}; | ||
virtual void ExposeImage(gd::String& otherResourceName) override { | ||
MatchResourceName(otherResourceName); | ||
}; | ||
virtual void ExposeAudio(gd::String& otherResourceName) override { | ||
MatchResourceName(otherResourceName); | ||
}; | ||
virtual void ExposeFont(gd::String& otherResourceName) override { | ||
MatchResourceName(otherResourceName); | ||
}; | ||
virtual void ExposeJson(gd::String& otherResourceName) override { | ||
MatchResourceName(otherResourceName); | ||
}; | ||
virtual void ExposeTilemap(gd::String& otherResourceName) override { | ||
MatchResourceName(otherResourceName); | ||
}; | ||
virtual void ExposeTileset(gd::String& otherResourceName) override { | ||
MatchResourceName(otherResourceName); | ||
}; | ||
virtual void ExposeVideo(gd::String& otherResourceName) override { | ||
MatchResourceName(otherResourceName); | ||
}; | ||
virtual void ExposeBitmapFont(gd::String& otherResourceName) override { | ||
MatchResourceName(otherResourceName); | ||
}; | ||
virtual void ExposeModel3D(gd::String& otherResourceName) override { | ||
MatchResourceName(otherResourceName); | ||
}; | ||
|
||
void MatchResourceName(gd::String& otherResourceName) { | ||
if (otherResourceName == resourceName) matchesResourceName = true; | ||
} | ||
|
||
gd::String resourceName; | ||
bool matchesResourceName; | ||
}; | ||
|
||
}; // namespace gd | ||
|
||
#endif // ProjectObjectsUsingResourceCollector_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.