character propties window finished (besides isPlayer)
This commit is contained in:
@@ -3,6 +3,8 @@ package funkin.editors.character;
|
||||
import funkin.game.Character;
|
||||
|
||||
class CharacterPropertiesWindow extends UISliceSprite {
|
||||
public var character:Character;
|
||||
|
||||
public var positionXStepper:UINumericStepper;
|
||||
public var positionYStepper:UINumericStepper;
|
||||
public var scaleStepper:UINumericStepper;
|
||||
@@ -14,39 +16,61 @@ class CharacterPropertiesWindow extends UISliceSprite {
|
||||
public var testAsDropDown:UIDropDown;
|
||||
public var designedAsDropDown:UIDropDown;
|
||||
|
||||
public function new(x:Float, y:Float, character:Character) {
|
||||
public function new(x:Float, y:Float, character:Character) @:privateAccess {
|
||||
super(x, y, Std.int(500-16), 204+20, "editors/ui/inputbox");
|
||||
|
||||
function addLabelOn(ui:UISprite, text:String)
|
||||
members.push(new UIText(ui.x, ui.y - 24, 0, text));
|
||||
|
||||
positionXStepper = new UINumericStepper(x+16, y+36, character.globalOffset.x, 0.001, 2, null, null, 104);
|
||||
positionXStepper.onChange = (text:String) -> {
|
||||
@:privateAccess positionXStepper.__onChange(text);
|
||||
this.changePosition(positionXStepper.value, null);
|
||||
};
|
||||
members.push(positionXStepper);
|
||||
addLabelOn(positionXStepper, "Position (X,Y)");
|
||||
|
||||
members.push(new UIText(positionXStepper.x+104-32+0, positionXStepper.y + 9, 0, ",", 22));
|
||||
|
||||
positionYStepper = new UINumericStepper(positionXStepper.x+104-32+26, positionXStepper.y, character.globalOffset.y, 0.001, 2, null, null, 104);
|
||||
positionYStepper.onChange = (text:String) -> {
|
||||
@:privateAccess positionYStepper.__onChange(text);
|
||||
this.changePosition(null, positionYStepper.value);
|
||||
};
|
||||
members.push(positionYStepper);
|
||||
|
||||
scaleStepper = new UINumericStepper(positionYStepper.x+104-32+32, positionYStepper.y, character.scale.x, 0.001, 2, null, null, 104);
|
||||
scaleStepper = new UINumericStepper(positionYStepper.x+104-32+32, positionYStepper.y, character.scale.x, 0.001, 2, 0, null, 104);
|
||||
scaleStepper.onChange = (text:String) -> {
|
||||
@:privateAccess scaleStepper.__onChange(text);
|
||||
this.changeScale(scaleStepper.value);
|
||||
};
|
||||
members.push(scaleStepper);
|
||||
addLabelOn(scaleStepper, "Scale");
|
||||
|
||||
flipXCheckbox = new UICheckbox(scaleStepper.x+104-32+24, scaleStepper.y, "Flipped?", character.flipX);
|
||||
flipXCheckbox = new UICheckbox(scaleStepper.x+104-32+24, scaleStepper.y, "Flipped?", character.isPlayer ? !character.__baseFlipped : character.__baseFlipped);
|
||||
flipXCheckbox.onChecked = (checked:Bool) -> {this.changeFlipX(checked);};
|
||||
members.push(flipXCheckbox);
|
||||
addLabelOn(flipXCheckbox, "Flipped X");
|
||||
|
||||
cameraXStepper = new UINumericStepper(positionXStepper.x, positionXStepper.y+32+32+4, character.cameraOffset.x, 0.001, 2, null, null, 104);
|
||||
cameraXStepper.onChange = (text:String) -> {
|
||||
@:privateAccess cameraXStepper.__onChange(text);
|
||||
this.changeCamPosition(cameraXStepper.value, null);
|
||||
};
|
||||
members.push(cameraXStepper);
|
||||
addLabelOn(cameraXStepper, "Camera Position (X,Y)");
|
||||
|
||||
members.push(new UIText(cameraXStepper.x + 104-32+0, cameraXStepper.y+9, 0, ",", 22));
|
||||
|
||||
cameraYStepper = new UINumericStepper(cameraXStepper.x+104-32+26, cameraXStepper.y, character.cameraOffset.y, 0.001, 2, null, null, 104);
|
||||
cameraYStepper.onChange = (text:String) -> {
|
||||
@:privateAccess cameraYStepper.__onChange(text);
|
||||
this.changeCamPosition(null, cameraYStepper.value);
|
||||
};
|
||||
members.push(cameraYStepper);
|
||||
|
||||
antialiasingCheckbox = new UICheckbox(cameraYStepper.x+104-32+32+24, cameraYStepper.y, "Antialiased?", character.antialiasing);
|
||||
antialiasingCheckbox.onChecked = (checked:Bool) -> {this.changeAntialiasing(checked);};
|
||||
members.push(antialiasingCheckbox);
|
||||
addLabelOn(antialiasingCheckbox, "Antialiasing");
|
||||
|
||||
@@ -61,5 +85,56 @@ class CharacterPropertiesWindow extends UISliceSprite {
|
||||
antialiasingCheckbox.x+=14;
|
||||
for (checkbox in [flipXCheckbox, antialiasingCheckbox])
|
||||
{checkbox.y += 3; checkbox.x += 12;}
|
||||
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
public function changePosition(newPosX:Null<Float>, newPosY:Null<Float>) {
|
||||
if (newPosX != null && newPosY != null && newPosX == character.globalOffset.x && newPosY == character.globalOffset.y)
|
||||
return;
|
||||
else {
|
||||
if (newPosX != null && newPosX == character.globalOffset.x) return;
|
||||
if (newPosY != null && newPosY == character.globalOffset.y) return;
|
||||
}
|
||||
|
||||
if (newPosX != null) character.globalOffset.x = newPosX;
|
||||
if (newPosY != null) character.globalOffset.y = newPosY;
|
||||
|
||||
CharacterEditor.instance.playAnimation(character.getAnimName());
|
||||
}
|
||||
|
||||
public function changeScale(newScale:Float) {
|
||||
if (character.scale.x == newScale) return;
|
||||
|
||||
character.scale.set(newScale, newScale);
|
||||
character.updateHitbox();
|
||||
|
||||
CharacterEditor.instance.playAnimation(character.getAnimName());
|
||||
}
|
||||
|
||||
public function changeFlipX(newFlipX:Bool) @:privateAccess {
|
||||
if (character.isPlayer ? !character.__baseFlipped : character.__baseFlipped == newFlipX) return;
|
||||
|
||||
character.flipX = character.isPlayer ? !newFlipX : newFlipX;
|
||||
character.__baseFlipped = character.flipX;
|
||||
|
||||
CharacterEditor.instance.playAnimation(character.getAnimName());
|
||||
}
|
||||
|
||||
public function changeCamPosition(newPosX:Null<Float>, newPosY:Null<Float>) {
|
||||
if (newPosX != null && newPosY != null && newPosX == character.cameraOffset.x && newPosY == character.cameraOffset.y)
|
||||
return;
|
||||
else {
|
||||
if (newPosX != null && newPosX == character.cameraOffset.x) return;
|
||||
if (newPosY != null && newPosY == character.cameraOffset.y) return;
|
||||
}
|
||||
|
||||
if (newPosX != null) character.cameraOffset.x = newPosX;
|
||||
if (newPosY != null) character.cameraOffset.y = newPosY;
|
||||
}
|
||||
|
||||
public function changeAntialiasing(newAntialiasing:Bool) {
|
||||
if (character.antialiasing == newAntialiasing) return;
|
||||
character.antialiasing = newAntialiasing;
|
||||
}
|
||||
}
|
||||
@@ -87,8 +87,8 @@ class UISliceSprite extends UISprite {
|
||||
}
|
||||
|
||||
public override function draw() @:privateAccess {
|
||||
var lastPixelPerfect:Bool = cameras[0].pixelPerfectRender;
|
||||
cameras[0].pixelPerfectRender = false;
|
||||
var lastPixelPerfect:Bool = cameras[0] != null ? cameras[0].pixelPerfectRender : false;
|
||||
if (cameras[0] != null) cameras[0].pixelPerfectRender = false;
|
||||
|
||||
var x:Float = this.x;
|
||||
var y:Float = this.y;
|
||||
@@ -187,7 +187,7 @@ class UISliceSprite extends UISprite {
|
||||
}
|
||||
alpha = oldAlpha;
|
||||
}
|
||||
cameras[0].pixelPerfectRender = true;
|
||||
if (cameras[0] != null) cameras[0].pixelPerfectRender = lastPixelPerfect;
|
||||
|
||||
setPosition(x, y);
|
||||
super.drawMembers();
|
||||
|
||||
@@ -80,24 +80,33 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
|
||||
script.call("postCreate");
|
||||
}
|
||||
|
||||
@:noCompletion var __swappedLeftRightAnims:Bool = false;
|
||||
@:noCompletion var __autoInterval:Bool = false;
|
||||
|
||||
public function fixChar(switchAnims:Bool = false, autoInterval:Bool = false) {
|
||||
if ((isDanceLeftDanceRight = hasAnimation("danceLeft") && hasAnimation("danceRight")) && autoInterval)
|
||||
beatInterval = 1;
|
||||
__autoInterval = autoInterval;
|
||||
|
||||
if (isPlayer != playerOffsets && switchAnims) {
|
||||
// character is flipped
|
||||
CoolUtil.switchAnimFrames(animation.getByName('singRIGHT'), animation.getByName('singLEFT'));
|
||||
CoolUtil.switchAnimFrames(animation.getByName('singRIGHTmiss'), animation.getByName('singLEFTmiss'));
|
||||
|
||||
switchOffset('singLEFT', 'singRIGHT');
|
||||
switchOffset('singLEFTmiss', 'singRIGHTmiss');
|
||||
}
|
||||
// character is flipped
|
||||
if (isPlayer != playerOffsets && switchAnims)
|
||||
swapLeftRightAnimations();
|
||||
|
||||
frameOffset.set(getAnimOffset(getAnimName()).x, getAnimOffset(getAnimName()).y);
|
||||
if (isPlayer)
|
||||
flipX = !flipX;
|
||||
if (isPlayer) flipX = !flipX;
|
||||
__baseFlipped = flipX;
|
||||
}
|
||||
|
||||
public function swapLeftRightAnimations() {
|
||||
CoolUtil.switchAnimFrames(animation.getByName('singRIGHT'), animation.getByName('singLEFT'));
|
||||
CoolUtil.switchAnimFrames(animation.getByName('singRIGHTmiss'), animation.getByName('singLEFTmiss'));
|
||||
|
||||
switchOffset('singLEFT', 'singRIGHT');
|
||||
switchOffset('singLEFTmiss', 'singRIGHTmiss');
|
||||
|
||||
__swappedLeftRightAnims = true;
|
||||
}
|
||||
|
||||
@:noCompletion var __baseFlipped:Bool = false;
|
||||
@:noCompletion var isDanceLeftDanceRight:Bool = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user