adding anims works now (+editing ui)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package funkin.backend;
|
||||
|
||||
import funkin.backend.utils.XMLUtil.AnimData;
|
||||
import funkin.backend.utils.XMLUtil.IXMLEvents;
|
||||
import flixel.system.FlxAssets.FlxGraphicAsset;
|
||||
import flixel.addons.effects.FlxSkewedSprite;
|
||||
@@ -37,6 +38,8 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
|
||||
public var name:String;
|
||||
public var zoomFactor:Float = 1;
|
||||
public var initialZoom:Float = 1;
|
||||
public var debugMode:Bool = false;
|
||||
public var animDatas:Map<String, AnimData> = [];
|
||||
|
||||
public var animateAtlas:FlxAnimate;
|
||||
@:noCompletion public var atlasPlayingAnim:String;
|
||||
@@ -286,7 +289,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!animation.exists(AnimName))
|
||||
if (!animation.exists(AnimName) && !debugMode)
|
||||
return;
|
||||
animation.play(AnimName, Force, Reversed, Frame);
|
||||
}
|
||||
|
||||
@@ -164,25 +164,6 @@ class XMLUtil {
|
||||
return addAnimToSprite(sprite, extractAnimFromXML(anim, animType, loop));
|
||||
}
|
||||
|
||||
public static function getAnimationData(sprite:FlxSprite, name:String):AnimData {
|
||||
var flxanim:FlxAnimation = sprite.animation.getByName(name);
|
||||
var animData:AnimData = {
|
||||
name: name,
|
||||
anim: flxanim.prefix,
|
||||
fps: flxanim.frameRate,
|
||||
loop: flxanim.looped,
|
||||
x: 0,
|
||||
y: 0,
|
||||
indices: flxanim.usesIndicies ? flxanim.frames : [],
|
||||
animType: NONE
|
||||
};
|
||||
if (sprite is FunkinSprite) {
|
||||
var animOffset = cast(sprite, FunkinSprite).getAnimOffset(name);
|
||||
animData.x = animOffset.x; animData.y = animOffset.y;
|
||||
}
|
||||
return animData;
|
||||
}
|
||||
|
||||
public static function addAnimToSprite(sprite:FlxSprite, animData:AnimData):ErrorCode {
|
||||
if (animData.name != null && animData.anim != null) {
|
||||
if (animData.fps <= 0 #if web || animData.fps == null #end) animData.fps = 24;
|
||||
@@ -194,7 +175,6 @@ class XMLUtil {
|
||||
else
|
||||
animateAnim.addBySymbol(animData.name, animData.anim, animData.fps, animData.loop);
|
||||
} else {
|
||||
trace("ge");
|
||||
if (animData.indices.length > 0)
|
||||
sprite.animation.addByIndices(animData.name, animData.anim, animData.indices, "", animData.fps, animData.loop);
|
||||
else
|
||||
@@ -214,6 +194,7 @@ class XMLUtil {
|
||||
default:
|
||||
// nothing
|
||||
}
|
||||
xmlSpr.animDatas.set(animData.name, animData);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -108,8 +108,15 @@ class CharacterAnimScreen extends UISubstateWindow {
|
||||
animType: NONE,
|
||||
x: offsetXStepper.value,
|
||||
y: offsetYStepper.value,
|
||||
indices: [for (indice in indicesTextBox.label.text.split(",")) Std.parseInt(indice.trim())]
|
||||
indices: []
|
||||
};
|
||||
var indicesSplit = indicesTextBox.label.text.split(",");
|
||||
for(indice in indicesSplit) {
|
||||
var i = Std.parseInt(indice.trim());
|
||||
if (i != null)
|
||||
animData.indices.push(i);
|
||||
}
|
||||
|
||||
if (onSave != null) onSave(animData);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class CharacterAnimsWindow extends UIWindow {
|
||||
for (i => button in buttons.members)
|
||||
cast(button, CharacterAnimButtons).updatePos(23,16+((32+16)*i));
|
||||
|
||||
addButton.y = 16+((32+16)*(character.animation.getNameList().length));
|
||||
addButton.y = 16+((32+16)*(buttons.members.length));
|
||||
addIcon.x = addButton.x + (440/2) - 8; addIcon.y = addButton.y + (32/2) - 8;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,9 @@ class CharacterAnimButtons extends UIButton {
|
||||
ghostIcon.updateHitbox();
|
||||
members.push(ghostIcon);
|
||||
|
||||
editButton = new UIButton(ghostButton.x+32+17, y, "", null, 32);
|
||||
editButton = new UIButton(ghostButton.x+32+17, y, "", function () {
|
||||
CharacterEditor.instance.editAnimWithUI(this.anim);
|
||||
}, 32);
|
||||
members.push(editButton);
|
||||
|
||||
editIcon = new FlxSprite(editButton.x + 8, editButton.y + 8).loadGraphic(Paths.image('editors/character/edit-button'));
|
||||
|
||||
@@ -97,7 +97,7 @@ class CharacterEditor extends UIState {
|
||||
},
|
||||
{
|
||||
label: "Edit Animation",
|
||||
onSelect: _char_update_anim,
|
||||
onSelect: _char_edit_anim,
|
||||
},
|
||||
{
|
||||
label: "Delete Animation",
|
||||
@@ -341,7 +341,8 @@ class CharacterEditor extends UIState {
|
||||
createAnimWithUI();
|
||||
}
|
||||
|
||||
function _char_update_anim(_) {
|
||||
function _char_edit_anim(_) {
|
||||
editAnimWithUI(character.animation.name);
|
||||
}
|
||||
|
||||
function _char_remove_anim(_) {
|
||||
@@ -358,13 +359,14 @@ class CharacterEditor extends UIState {
|
||||
}));
|
||||
}
|
||||
|
||||
public function editAnimWithUI() {
|
||||
|
||||
public function editAnimWithUI(name:String) {
|
||||
FlxG.state.openSubState(new CharacterAnimScreen(character.animDatas.get(name), (_) -> {
|
||||
trace("this dont work yet looooll");
|
||||
}));
|
||||
}
|
||||
|
||||
public function createAnim(animData:AnimData, animID:Int = -1, addtoUndo:Bool = true) {
|
||||
XMLUtil.addAnimToSprite(character, animData);
|
||||
trace(character.animation.getNameList());
|
||||
characterAnimsWindow.createNewButton(animData.name, FlxPoint.get(animData.x,animData.y), false, animID);
|
||||
|
||||
playAnimation(animData.name);
|
||||
@@ -378,10 +380,12 @@ class CharacterEditor extends UIState {
|
||||
|
||||
// undo shit blah blah
|
||||
var oldID:Int = character.animation.getNameList().indexOf(name);
|
||||
var oldAnimData:AnimData = XMLUtil.getAnimationData(character, name);
|
||||
var oldAnimData:AnimData = character.animDatas.get(name);
|
||||
|
||||
character.animation.remove(name);
|
||||
character.animOffsets.remove(name);
|
||||
if (character.animation.exists(name)) {
|
||||
character.animation.remove(name);
|
||||
character.animOffsets.remove(name);
|
||||
}
|
||||
characterAnimsWindow.removeButton(name);
|
||||
|
||||
if (addtoUndo)
|
||||
|
||||
@@ -40,8 +40,6 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
|
||||
return stunned = b;
|
||||
}
|
||||
|
||||
public var debugMode:Bool = false;
|
||||
|
||||
public var isPlayer:Bool = false;
|
||||
public var isGF:Bool = false;
|
||||
public var curCharacter:String = 'bf';
|
||||
|
||||
Reference in New Issue
Block a user