Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ addons/*
addons/*
!addons/readme.txt
dev-libs/
.vs/
1 change: 1 addition & 0 deletions assets/languages/en/Editors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@
<str id="icon">Icon</str>
<str id="iconColor">Icon Color</str>
<str id="singDuration">Sing Duration</str>
<str id="defaultFPS">Default FPS</str>
<str id="useSingDuration">Use Sing Duration?</str>
<str id="customValues">Custom Values (Advanced)</str>
</group>
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/editors/character/CharacterAnimsWindow.hx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class CharacterAnimsWindow extends UIButtonList<CharacterAnimButton> {
var animData:AnimData = {
name: animName,
anim: __autoCompleteAnims[0],
fps: 24, loop: false,
fps: character.defaultAimFPS, loop: false,
x: 0, y: 0,
indices: [],
animType: NONE,
Expand Down
26 changes: 26 additions & 0 deletions source/funkin/editors/character/CharacterInfoScreen.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import openfl.geom.Point;
import openfl.geom.Rectangle;
import openfl.display.BitmapData;
import funkin.game.Character;
import funkin.backend.utils.XMLUtil.AnimData;
import funkin.editors.character.CharacterEditor;

using funkin.backend.utils.BitmapUtil;

typedef CharacterExtraInfo = {
var icon:String;
var iconColor:Null<FlxColor>;
var holdTime:Float;
var defaultAimFPS:Float;
var customProperties:Map<String, Dynamic>;
}

Expand All @@ -26,12 +29,15 @@ class CharacterInfoScreen extends UISubstateWindow {

public var useDurationCheckbox:UICheckbox;
public var durationStepper:UINumericStepper;
public var defaultAimFPS:UINumericStepper;

public var customPropertiesButtonList:UIButtonList<PropertyButton>;

public var saveButton:UIButton;
public var closeButton:UIButton;

var oldDefFPS:Float;

public var onSave:(info:CharacterExtraInfo) -> Void = null;

public function new(character:Character, onSave:(info:CharacterExtraInfo) -> Void) {
Expand Down Expand Up @@ -77,6 +83,11 @@ class CharacterInfoScreen extends UISubstateWindow {

durationStepper.selectable = useDurationCheckbox.checked;

defaultAimFPS = new UINumericStepper(iconColorPicker.x, durationStepper.y + durationStepper.height + 40, character.defaultAimFPS, 0.001, 2, 0, 9999999, 74);
add(defaultAimFPS);
addLabelOn(defaultAimFPS, translate("defaultFPS"));
oldDefFPS = character.defaultAimFPS;

customPropertiesButtonList = new UIButtonList<PropertyButton>(iconColorWheel.x+iconColorWheel.bWidth+22, iconColorWheel.y, 290, 200, '', FlxPoint.get(280, 35), null, 5);
customPropertiesButtonList.frames = Paths.getFrames('editors/ui/inputbox');
customPropertiesButtonList.cameraSpacing = 0;
Expand Down Expand Up @@ -107,10 +118,25 @@ class CharacterInfoScreen extends UISubstateWindow {
public function saveCharacterInfo() {
UIUtil.confirmUISelections(this);

if (defaultAimFPS.value != oldDefFPS){
var daIDForButton:Int = 0;
for (anim in character.getAnimOrder()){
var animName = character.animDatas.get(anim);
if (animName.fps == oldDefFPS){
var poop:CharacterAnimButton = CharacterEditor.instance.characterAnimsWindow.buttons.members[daIDForButton];
trace(poop);
poop.changeFPS(defaultAimFPS.value);
}
daIDForButton++;
}
}


if (onSave != null) onSave({
icon: iconColorPicker.iconTextBox.label.text,
iconColor: iconColorWheel.curColor,
holdTime: useDurationCheckbox.checked ? durationStepper.value : -1,
defaultAimFPS: defaultAimFPS.value,
customProperties: [
for (val in customPropertiesButtonList.buttons.members)
val.propertyText.label.text => val.valueText.label.text
Expand Down
2 changes: 2 additions & 0 deletions source/funkin/editors/character/CharacterPropertiesWindow.hx
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,14 @@ class CharacterPropertiesWindow extends UISliceSprite {
icon: character.icon,
iconColor: character.iconColor,
holdTime: character.holdTime,
defaultAimFPS: character.defaultAimFPS,
customProperties: character.extra.copy()
};

character.icon = info.icon;
character.iconColor = info.iconColor;
character.holdTime = info.holdTime;
character.defaultAimFPS = info.defaultAimFPS;
character.extra = info.customProperties.copy();

if (addToUndo) CharacterEditor.undos.addToUndo(CCharEditInfo(oldInfo, info));
Expand Down
17 changes: 14 additions & 3 deletions source/funkin/game/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
public var icon:String = null;
public var iconColor:Null<FlxColor> = null;
public var gameOverCharacter:String = Character.FALLBACK_DEAD_CHARACTER;
public var defaultAimFPS:Float = 24;


public var cameraOffset:FlxPoint = FlxPoint.get(0, 0);
public var globalOffset:FlxPoint = FlxPoint.get(0, 0);
Expand Down Expand Up @@ -373,6 +375,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
if (xml.x.exists("x")) globalOffset.x = Std.parseFloat(xml.x.get("x"));
if (xml.x.exists("y")) globalOffset.y = Std.parseFloat(xml.x.get("y"));
if (xml.x.exists("gameOverChar")) gameOverCharacter = xml.x.get("gameOverChar");
if (xml.x.exists("defFps")) defaultAimFPS = Std.parseFloat(xml.x.get("defFps"));
if (xml.x.exists("camx")) cameraOffset.x = Std.parseFloat(xml.x.get("camx"));
if (xml.x.exists("camy")) cameraOffset.y = Std.parseFloat(xml.x.get("camy"));
if (xml.x.exists("holdTime")) holdTime = Std.parseFloat(xml.x.get("holdTime")).getDefaultFloat(4);
Expand Down Expand Up @@ -408,7 +411,13 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
loadSprite(Paths.image('characters/$sprite'));
for(node in xml.elements) {
switch(node.name) {
case "anim":
case "anim":
if (defaultAimFPS != 24){
if (!node.x.exists("fps")) {
node.x.set('fps', Std.string(defaultAimFPS));
}
}

XMLUtil.addXMLAnimation(this, node);
case "use-extension" | "extension" | "ext":
if (XMLImportedScriptInfo.shouldLoadBefore(node)) continue;
Expand Down Expand Up @@ -439,7 +448,8 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
public static var characterProperties:Array<String> = [
"x", "y", "sprite", "scale", "antialiasing",
"flipX", "camx", "camy", "isPlayer", "icon",
"color", "gameOverChar", "holdTime", "applyStageMatrix"
"color", "gameOverChar", "holdTime", "applyStageMatrix",
"defFps"
];
public static var characterAnimProperties:Array<String> = [
"name", "anim", "label", "x", "y", "fps", "loop", "indices"
Expand All @@ -463,6 +473,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset

if (gameOverCharacter != Character.FALLBACK_DEAD_CHARACTER) xml.set("gameOverChar", gameOverCharacter);
if (iconColor != null) xml.set("color", iconColor.toWebString());
if (defaultAimFPS != 24) xml.set("defFps", Std.string(defaultAimFPS));

if (sprite != curCharacter) xml.set("sprite", sprite);
if (scale.x != 1) xml.set("scale", Std.string(FlxMath.roundDecimal(scale.x, 4)));
Expand All @@ -485,7 +496,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
animXml.set("name", anim.name);
animXml.set("anim", anim.anim);
if (anim.loop) animXml.set("loop", Std.string(anim.loop));
if (FlxMath.roundDecimal(anim.fps, 2) != 24) animXml.set("fps", Std.string(FlxMath.roundDecimal(anim.fps, 2)));
if (FlxMath.roundDecimal(anim.fps, 2) != defaultAimFPS) animXml.set("fps", Std.string(FlxMath.roundDecimal(anim.fps, 2)));

var offset:FlxPoint = getAnimOffset(anim.name);
if (FlxMath.roundDecimal(offset.x, 2) != 0) animXml.set("x", Std.string(FlxMath.roundDecimal(offset.x, 2)));
Expand Down