Extensions can really load data in ResourcesManager
This commit is contained in:
Binary file not shown.
Submodule h2d-libgdx-spine-extension updated: dc01b4d6f5...789840b01a
Submodule h2d-libgdx-talos-extension updated: 0cc2a1e491...f78568f6c8
Submodule h2d-libgdx-typinglabel-extension updated: 867d770366...a0567ceeda
Submodule hyperlap2d-runtime-libgdx updated: 73936b29f8...71c6cfe6ee
+3
-5
@@ -8,13 +8,12 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.esotericsoftware.spine.Skeleton;
|
||||
import com.esotericsoftware.spine.SkeletonData;
|
||||
import com.esotericsoftware.spine.SkeletonJson;
|
||||
import com.esotericsoftware.spine.SkeletonRenderer;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import games.rednblack.editor.plugin.tiled.TiledPlugin;
|
||||
import games.rednblack.editor.plugin.tiled.view.SpineDrawable;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
import games.rednblack.h2d.extension.spine.ResourceRetrieverAttachmentLoader;
|
||||
import games.rednblack.h2d.extension.spine.SpineDataObject;
|
||||
import games.rednblack.h2d.extension.spine.SpineItemType;
|
||||
|
||||
import java.io.File;
|
||||
@@ -97,9 +96,8 @@ public class ResourcesManager {
|
||||
|
||||
public SpineDrawable getSpineDrawable(String name) {
|
||||
if (spineDrawableCache.get(name) == null) {
|
||||
ResourceRetrieverAttachmentLoader atlasAttachmentLoader = new ResourceRetrieverAttachmentLoader(name, tiledPlugin.getAPI().getSceneLoader().getRm());
|
||||
SkeletonJson skeletonJson = new SkeletonJson(atlasAttachmentLoader);
|
||||
SkeletonData skeletonData = skeletonJson.readSkeletonData(tiledPlugin.getAPI().getSceneLoader().getRm().getExternalItemType(SpineItemType.SPINE_TYPE, name));
|
||||
SpineDataObject spineDataObject = (SpineDataObject) tiledPlugin.getAPI().getSceneLoader().getRm().getExternalItemType(SpineItemType.SPINE_TYPE, name);
|
||||
SkeletonData skeletonData = spineDataObject.skeletonData;
|
||||
Skeleton skeleton = new Skeleton(skeletonData);
|
||||
|
||||
spineDrawableCache.put(name, new SpineDrawable(skeleton, skeletonRenderer));
|
||||
|
||||
+4
-6
@@ -2,13 +2,12 @@ package games.rednblack.editor.plugin.tiled.tools.drawStrategy;
|
||||
|
||||
import com.esotericsoftware.spine.Skeleton;
|
||||
import com.esotericsoftware.spine.SkeletonData;
|
||||
import com.esotericsoftware.spine.SkeletonJson;
|
||||
import games.rednblack.editor.plugin.tiled.TiledPlugin;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.h2d.common.command.ReplaceSpineCommandBuilder;
|
||||
import games.rednblack.h2d.common.factory.IFactory;
|
||||
import games.rednblack.h2d.extension.spine.ResourceRetrieverAttachmentLoader;
|
||||
import games.rednblack.h2d.extension.spine.SpineComponent;
|
||||
import games.rednblack.h2d.extension.spine.SpineDataObject;
|
||||
import games.rednblack.h2d.extension.spine.SpineItemType;
|
||||
|
||||
public class SpineDrawStrategy extends BasicDrawStrategy {
|
||||
@@ -45,10 +44,9 @@ public class SpineDrawStrategy extends BasicDrawStrategy {
|
||||
replaceSpineCommandBuilder.begin(entity);
|
||||
String animName = tiledPlugin.getSelectedTileName();
|
||||
replaceSpineCommandBuilder.setAnimationName(animName);
|
||||
ResourceRetrieverAttachmentLoader atlasAttachmentLoader = new ResourceRetrieverAttachmentLoader(animName, tiledPlugin.getAPI().getSceneLoader().getRm());
|
||||
SkeletonJson skeletonJson = new SkeletonJson(atlasAttachmentLoader);
|
||||
replaceSpineCommandBuilder.setSkeletonJson(skeletonJson);
|
||||
SkeletonData skeletonData = skeletonJson.readSkeletonData((tiledPlugin.getAPI().getSceneLoader().getRm().getExternalItemType(SpineItemType.SPINE_TYPE, animName)));
|
||||
SpineDataObject spineDataObject = (SpineDataObject) tiledPlugin.getAPI().getSceneLoader().getRm().getExternalItemType(SpineItemType.SPINE_TYPE, animName);
|
||||
replaceSpineCommandBuilder.setSkeletonJson(spineDataObject.skeletonJson);
|
||||
SkeletonData skeletonData = spineDataObject.skeletonData;
|
||||
replaceSpineCommandBuilder.setSkeleton(new Skeleton(skeletonData));
|
||||
replaceSpineCommandBuilder.execute(tiledPlugin.facade);
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* * Copyright 2015 See AUTHORS file.
|
||||
* *
|
||||
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* * you may not use this file except in compliance with the License.
|
||||
* * You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package games.rednblack.editor.data;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
|
||||
/**
|
||||
* Created by azakhary on 7/3/2014.
|
||||
*/
|
||||
public class SpineAnimData {
|
||||
public FileHandle jsonFile;
|
||||
public String animName;
|
||||
}
|
||||
@@ -12,19 +12,23 @@ import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.utils.*;
|
||||
import com.esotericsoftware.spine.SkeletonJson;
|
||||
import com.kotcrab.vis.ui.VisUI;
|
||||
import com.talosvfx.talos.runtime.ParticleEffectDescriptor;
|
||||
import com.talosvfx.talos.runtime.utils.ShaderDescriptor;
|
||||
import com.talosvfx.talos.runtime.utils.VectorField;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.data.SpineAnimData;
|
||||
import games.rednblack.editor.renderer.data.*;
|
||||
import games.rednblack.editor.renderer.resources.FontSizePair;
|
||||
import games.rednblack.editor.renderer.resources.IResourceRetriever;
|
||||
import games.rednblack.editor.renderer.utils.H2DSkinLoader;
|
||||
import games.rednblack.editor.renderer.utils.HyperJson;
|
||||
import games.rednblack.editor.renderer.utils.ShadedDistanceFieldFont;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.editor.view.ui.widget.actors.basic.WhitePixel;
|
||||
import games.rednblack.h2d.extension.spine.ResourceRetrieverAttachmentLoader;
|
||||
import games.rednblack.h2d.extension.spine.SpineDataObject;
|
||||
import games.rednblack.h2d.extension.spine.SpineDrawableLogic;
|
||||
import games.rednblack.h2d.extension.spine.SpineItemType;
|
||||
import games.rednblack.h2d.extension.talos.ResourceRetrieverAssetProvider;
|
||||
import games.rednblack.h2d.extension.talos.TalosItemType;
|
||||
@@ -50,10 +54,9 @@ public class ResourceManager extends Proxy implements IResourceRetriever {
|
||||
|
||||
private final HashMap<String, ParticleEffect> particleEffects = new HashMap<>(1);
|
||||
private final HashMap<String, ParticleEffectDescriptor> talosVFXs = new HashMap<>(1);
|
||||
private final HashMap<String, FileHandle> talosVFXsFiles = new HashMap<>(1);
|
||||
private HashMap<String, TextureAtlas> currentProjectAtlas = new HashMap<>(1);
|
||||
|
||||
private final HashMap<String, SpineAnimData> spineAnimAtlases = new HashMap<>();
|
||||
private final HashMap<String, SpineDataObject> spineAnimAtlases = new HashMap<>();
|
||||
private final HashMap<String, Array<TextureAtlas.AtlasRegion>> spriteAnimAtlases = new HashMap<>();
|
||||
private final HashMap<FontSizePair, BitmapFont> bitmapFonts = new HashMap<>();
|
||||
private final HashMap<String, ShaderProgram> shaderPrograms = new HashMap<>(1);
|
||||
@@ -164,13 +167,12 @@ public class ResourceManager extends Proxy implements IResourceRetriever {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileHandle getExternalItemType(int itemType, String name) {
|
||||
public Object getExternalItemType(int itemType, String name) {
|
||||
switch (itemType) {
|
||||
case SpineItemType.SPINE_TYPE:
|
||||
SpineAnimData animData = spineAnimAtlases.get(name);
|
||||
return animData.jsonFile;
|
||||
return spineAnimAtlases.get(name);
|
||||
case TalosItemType.TALOS_TYPE:
|
||||
return talosVFXsFiles.get(name);
|
||||
return talosVFXs.get(name);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -261,7 +263,6 @@ public class ResourceManager extends Proxy implements IResourceRetriever {
|
||||
assetProvider.setAssetHandler(VectorField.class, this::findVectorFieldDescriptorOnLoad);
|
||||
ParticleEffectDescriptor effectDescriptor = new ParticleEffectDescriptor();
|
||||
effectDescriptor.setAssetProvider(assetProvider);
|
||||
talosVFXsFiles.put(filename, Gdx.files.internal(file.getAbsolutePath()));
|
||||
effectDescriptor.load(Gdx.files.internal(file.getAbsolutePath()));
|
||||
talosVFXs.put(filename, effectDescriptor);
|
||||
}
|
||||
@@ -301,14 +302,17 @@ public class ResourceManager extends Proxy implements IResourceRetriever {
|
||||
private void loadCurrentProjectSpineAnimations(String path, String curResolution) {
|
||||
spineAnimAtlases.clear();
|
||||
FileHandle sourceDir = new FileHandle(path + "orig/spine-animations");
|
||||
SpineDrawableLogic spineDrawableLogic = (SpineDrawableLogic) Sandbox.getInstance().sceneControl.sceneLoader.getExternalItemType(SpineItemType.SPINE_TYPE).getDrawable();
|
||||
for (FileHandle entry : sourceDir.list()) {
|
||||
if (entry.file().isDirectory()) {
|
||||
String animName = FilenameUtils.removeExtension(entry.file().getName());
|
||||
FileHandle animJsonFile = Gdx.files.internal(entry.file().getAbsolutePath() + File.separator + animName + ".json");
|
||||
SpineAnimData data = new SpineAnimData();
|
||||
data.jsonFile = animJsonFile;
|
||||
data.animName = animName;
|
||||
spineAnimAtlases.put(animName, data);
|
||||
|
||||
SpineDataObject spineDataObject = new SpineDataObject();
|
||||
spineDataObject.skeletonJson = new SkeletonJson(new ResourceRetrieverAttachmentLoader(animName, this, spineDrawableLogic));
|
||||
spineDataObject.skeletonData = spineDataObject.skeletonJson.readSkeletonData(animJsonFile);
|
||||
|
||||
spineAnimAtlases.put(animName, spineDataObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,7 +496,7 @@ public class ResourceManager extends Proxy implements IResourceRetriever {
|
||||
addBitmapFont(fontfamily, parameter.size, font, mono);
|
||||
}
|
||||
|
||||
public HashMap<String, SpineAnimData> getProjectSpineAnimationsList() {
|
||||
public HashMap<String, SpineDataObject> getProjectSpineAnimationsList() {
|
||||
return spineAnimAtlases;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.esotericsoftware.spine.attachments.Attachment;
|
||||
import com.esotericsoftware.spine.attachments.MeshAttachment;
|
||||
import com.esotericsoftware.spine.attachments.RegionAttachment;
|
||||
import games.rednblack.editor.renderer.resources.IResourceRetriever;
|
||||
import games.rednblack.h2d.extension.spine.ResourceRetrieverAttachmentLoader;
|
||||
import games.rednblack.h2d.extension.spine.SpineDataObject;
|
||||
import games.rednblack.h2d.extension.spine.SpineItemType;
|
||||
|
||||
public class SpineActor extends Actor {
|
||||
@@ -75,8 +75,9 @@ public class SpineActor extends Actor {
|
||||
}
|
||||
|
||||
private void initSkeletonData() {
|
||||
skeletonJson = new SkeletonJson(new ResourceRetrieverAttachmentLoader(animationName, irr));
|
||||
skeletonData = skeletonJson.readSkeletonData((irr.getExternalItemType(SpineItemType.SPINE_TYPE, animationName)));
|
||||
SpineDataObject spineDataObject = (SpineDataObject) irr.getExternalItemType(SpineItemType.SPINE_TYPE, animationName);
|
||||
skeletonJson = spineDataObject.skeletonJson;
|
||||
skeletonData = spineDataObject.skeletonData;
|
||||
}
|
||||
|
||||
private void initSpine() {
|
||||
|
||||
Reference in New Issue
Block a user