GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
SceneResourcesFinder.h
1 /*
2  * GDevelop JS Platform
3  * Copyright 2008-2023 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 
7 #pragma once
8 
9 #include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
10 #include "GDCore/String.h"
11 
12 #include <set>
13 
14 namespace gd {
15 class Project;
16 class Layout;
17 class SerializerElement;
18 } // namespace gd
19 
20 namespace gd {
21 
28 public:
34  static std::set<gd::String> FindSceneResources(gd::Project &project,
35  gd::Layout &layout);
36 
42  static std::set<gd::String> FindProjectResources(gd::Project &project);
43 
44  virtual ~SceneResourcesFinder(){};
45 
46 private:
48  : gd::ArbitraryResourceWorker(resourcesManager){};
49 
50  void AddUsedResource(gd::String &resourceName);
51 
52  void ExposeFile(gd::String &resourceFileName) override{
53  // Don't do anything: we're renaming resources, not the files they are
54  // pointing to.
55  };
56  void ExposeImage(gd::String &imageResourceName) override {
57  AddUsedResource(imageResourceName);
58  };
59  void ExposeAudio(gd::String &audioResourceName) override {
60  AddUsedResource(audioResourceName);
61  };
62  void ExposeFont(gd::String &fontResourceName) override {
63  AddUsedResource(fontResourceName);
64  };
65  void ExposeJson(gd::String &jsonResourceName) override {
66  AddUsedResource(jsonResourceName);
67  };
68  void ExposeTilemap(gd::String &tilemapResourceName) override {
69  AddUsedResource(tilemapResourceName);
70  };
71  void ExposeTileset(gd::String &tilesetResourceName) override {
72  AddUsedResource(tilesetResourceName);
73  };
74  void ExposeVideo(gd::String &videoResourceName) override {
75  AddUsedResource(videoResourceName);
76  };
77  void ExposeBitmapFont(gd::String &bitmapFontName) override {
78  AddUsedResource(bitmapFontName);
79  };
80  void ExposeModel3D(gd::String &resourceName) override {
81  AddUsedResource(resourceName);
82  };
83  void ExposeAtlas(gd::String &resourceName) override {
84  AddUsedResource(resourceName);
85  };
86  void ExposeSpine(gd::String &resourceName) override {
87  AddUsedResource(resourceName);
88  };
89 
90  std::set<gd::String> resourceNames;
91 };
92 
93 } // namespace gd
ArbitraryResourceWorker is used so as to inventory resources and sometimes update them.
Definition: ArbitraryResourceWorker.h:44
Represent a layout ( also called a scene ) of a project.
Definition: Layout.h:40
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:51
Inventory all resources used by a project.
Definition: ResourcesManager.h:556
Find resource usages in several parts of the project.
Definition: SceneResourcesFinder.h:27
static std::set< gd::String > FindProjectResources(gd::Project &project)
Find resource that are used globally in the project.
Definition: SceneResourcesFinder.cpp:15
static std::set< gd::String > FindSceneResources(gd::Project &project, gd::Layout &layout)
Find resource usages in a given scenes.
Definition: SceneResourcesFinder.cpp:22
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24