mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
1 Commits
allow-bump
...
hot-reload
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b06ff9fd4e |
@@ -69,6 +69,11 @@ namespace gdjs {
|
||||
return resourceKinds;
|
||||
}
|
||||
|
||||
clearCache(): void {
|
||||
this._loadedThreeModels.clear();
|
||||
this._downloadedArrayBuffers.clear();
|
||||
}
|
||||
|
||||
async processResource(resourceName: string): Promise<void> {
|
||||
const resource = this._resourceLoader.getResource(resourceName);
|
||||
if (!resource) {
|
||||
@@ -114,6 +119,9 @@ namespace gdjs {
|
||||
if (!loader) {
|
||||
return;
|
||||
}
|
||||
if (this._loadedThreeModels.get(resource)) {
|
||||
return;
|
||||
}
|
||||
const url = this._resourceLoader.getFullUrl(resource.file);
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
|
@@ -50,5 +50,9 @@ namespace gdjs {
|
||||
this._nameToContent.clear();
|
||||
this._fileToContent.clear();
|
||||
}
|
||||
|
||||
getAllValues(): IterableIterator<C> {
|
||||
return this._fileToContent.values();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -146,12 +146,6 @@ namespace gdjs {
|
||||
this._resources = new Map<string, ResourceData>();
|
||||
this._globalResources = globalResources;
|
||||
|
||||
// These 3 attributes are filled by `setResources`.
|
||||
this._sceneResources = new Map<string, Array<string>>();
|
||||
this._sceneNamesToLoad = new Set<string>();
|
||||
this._sceneNamesToMakeReady = new Set<string>();
|
||||
this.setResources(resourceDataArray, globalResources, layoutDataArray);
|
||||
|
||||
this._imageManager = new gdjs.ImageManager(this);
|
||||
this._soundManager = new gdjs.SoundManager(this);
|
||||
this._fontManager = new gdjs.FontManager(this);
|
||||
@@ -176,6 +170,12 @@ namespace gdjs {
|
||||
this._resourceManagersMap.set(resourceKind, resourceManager);
|
||||
}
|
||||
}
|
||||
|
||||
// These 3 attributes are filled by `setResources`.
|
||||
this._sceneResources = new Map<string, Array<string>>();
|
||||
this._sceneNamesToLoad = new Set<string>();
|
||||
this._sceneNamesToMakeReady = new Set<string>();
|
||||
this.setResources(resourceDataArray, globalResources, layoutDataArray);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,6 +212,9 @@ namespace gdjs {
|
||||
for (const resourceData of resourceDataArray) {
|
||||
this._resources.set(resourceData.name, resourceData);
|
||||
}
|
||||
for (const resourceManager of this._resourceManagersMap.values()) {
|
||||
resourceManager.clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
async loadAllResources(
|
||||
|
@@ -29,5 +29,10 @@ namespace gdjs {
|
||||
* Return the kind of resources handled by this manager.
|
||||
*/
|
||||
getResourceKinds(): Array<ResourceKind>;
|
||||
|
||||
/**
|
||||
* Clear any resource in cache.
|
||||
*/
|
||||
clearCache():void;
|
||||
}
|
||||
}
|
||||
|
@@ -1237,6 +1237,8 @@ namespace gdjs {
|
||||
): void {
|
||||
let somethingChanged = false;
|
||||
|
||||
// TODO Refresh resources here.
|
||||
|
||||
// Check if default properties changed
|
||||
if (oldInstance.x !== newInstance.x) {
|
||||
runtimeObject.setX(newInstance.x);
|
||||
|
@@ -31,6 +31,10 @@ namespace gdjs {
|
||||
return resourceKinds;
|
||||
}
|
||||
|
||||
clearCache(): void {
|
||||
// Hot-reload of font is not handled as fonts are unlikely to be edited.
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the font family associated to the specified font resource name.
|
||||
* The font resource must have been loaded before. If that's not the case,
|
||||
|
@@ -365,7 +365,7 @@ namespace gdjs {
|
||||
* It is basically a container to associate channels to sounds and keep a list
|
||||
* of all sounds being played.
|
||||
*/
|
||||
export class HowlerSoundManager {
|
||||
export class HowlerSoundManager implements gdjs.ResourceManager {
|
||||
_loadedMusics = new gdjs.ResourceCache<Howl>();
|
||||
_loadedSounds = new gdjs.ResourceCache<Howl>();
|
||||
_availableResources: Record<string, ResourceData> = {};
|
||||
@@ -437,6 +437,10 @@ namespace gdjs {
|
||||
return resourceKinds;
|
||||
}
|
||||
|
||||
clearCache(): void {
|
||||
// TODO Handle hot-reload of sounds.
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure rate is in a range valid for Howler.js
|
||||
* @return The clamped rate
|
||||
|
@@ -39,6 +39,11 @@ namespace gdjs {
|
||||
return resourceKinds;
|
||||
}
|
||||
|
||||
clearCache(): void {
|
||||
this._loadedJsons.clear();
|
||||
this._callbacks.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request all the json resources to be preloaded (unless they are marked as not preloaded).
|
||||
*
|
||||
|
@@ -76,6 +76,10 @@ namespace gdjs {
|
||||
return resourceKinds;
|
||||
}
|
||||
|
||||
clearCache(): void {
|
||||
this._loadedFontsData.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the instance of the default `Pixi.BitmapFont`, always available.
|
||||
*/
|
||||
|
@@ -76,6 +76,24 @@ namespace gdjs {
|
||||
return resourceKinds;
|
||||
}
|
||||
|
||||
clearCache(): void {
|
||||
for (const texture of this._loadedTextures.getAllValues()) {
|
||||
texture.destroy(true);
|
||||
}
|
||||
for (const name in this._loadedThreeTextures.items) {
|
||||
const texture = this._loadedThreeTextures.items[name];
|
||||
texture.dispose();
|
||||
}
|
||||
for (const name in this._loadedThreeMaterials.items) {
|
||||
const texture = this._loadedThreeMaterials.items[name];
|
||||
texture.dispose();
|
||||
}
|
||||
this._loadedTextures.clear();
|
||||
this._loadedThreeTextures.clear();
|
||||
this._loadedThreeMaterials.clear();
|
||||
PIXI.Assets.cache.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the PIXI texture associated to the specified resource name.
|
||||
* Returns a placeholder texture if not found.
|
||||
|
Reference in New Issue
Block a user