character editor (F1 in codename ui)
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
732
|
||||
739
|
||||
@@ -11,7 +11,7 @@ import flixel.FlxSprite;
|
||||
import flixel.FlxBasic;
|
||||
import flixel.FlxCamera;
|
||||
import flixel.math.FlxPoint;
|
||||
import funkin.desktop.editors.HelloWorld;
|
||||
import funkin.desktop.editors.*;
|
||||
import funkin.desktop.windows.*;
|
||||
import funkin.desktop.theme.Theme;
|
||||
|
||||
@@ -66,6 +66,8 @@ class DesktopMain extends MusicBeatState {
|
||||
// debug window
|
||||
if (FlxG.keys.justPressed.SPACE)
|
||||
windows.add(new Window(new HelloWorld()));
|
||||
if (FlxG.keys.justPressed.F1)
|
||||
windows.add(new Window(new CharacterEditor('dad')));
|
||||
}
|
||||
|
||||
public function updateScreenRes() {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package funkin.desktop.editors;
|
||||
|
||||
import funkin.game.Character;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxObject;
|
||||
import flixel.FlxCamera;
|
||||
import flixel.FlxG;
|
||||
|
||||
class CharacterEditor extends WindowContent {
|
||||
public function new(curCharacter:String) {
|
||||
super('Character Editor - Loading...', 0, 0, 800, 600);
|
||||
}
|
||||
|
||||
public var camHUD:FlxCamera;
|
||||
public var char:Character;
|
||||
public var curCharacter:String;
|
||||
public var camFollow:FlxObject;
|
||||
|
||||
public override function create() {
|
||||
super.create();
|
||||
|
||||
// camera stuff
|
||||
parent.windowCameras[0].resizeScroll = false;
|
||||
camHUD = new FlxCamera(800, 600, 1);
|
||||
camHUD.pixelPerfectRender = true;
|
||||
camHUD.bgColor = 0;
|
||||
parent.addCamera(camHUD);
|
||||
|
||||
// stage
|
||||
var bg = new FlxSprite(-600, -200, Paths.image('stages/default/stageback'));
|
||||
bg.scrollFactor.set(0.9, 0.9);
|
||||
var stageFront = new FlxSprite(-600, 600, Paths.image('stages/default/stagefront'));
|
||||
stageFront.scrollFactor.set(0.9, 0.9);
|
||||
var stageCurtains = new FlxSprite(-500, -300, Paths.image('stages/default/stagecurtains'));
|
||||
stageCurtains.scrollFactor.set(1.3, 1.3);
|
||||
char = new Character(100, 100, curCharacter, false);
|
||||
|
||||
for(e in [bg, stageFront, stageCurtains]) {
|
||||
e.antialiasing = true;
|
||||
}
|
||||
add(bg);
|
||||
add(stageFront);
|
||||
add(char);
|
||||
add(stageCurtains);
|
||||
|
||||
// character setup & following
|
||||
camFollow = new FlxObject(0, 0, 2, 2);
|
||||
var charMidpoint = char.getGraphicMidpoint();
|
||||
camFollow.setPosition(charMidpoint.x, charMidpoint.y);
|
||||
add(camFollow);
|
||||
windowCamera.follow(camFollow, LOCKON, 999);
|
||||
title = 'Character Editor - ${char.curCharacter}.xml';
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
if (parent.focused) {
|
||||
if (FlxG.keys.pressed.RIGHT) camFollow.x += elapsed * 200;
|
||||
if (FlxG.keys.pressed.LEFT) camFollow.x -= elapsed * 200;
|
||||
if (FlxG.keys.pressed.DOWN) camFollow.y += elapsed * 200;
|
||||
if (FlxG.keys.pressed.UP) camFollow.y -= elapsed * 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,12 @@ class HelloWorld extends WindowContent {
|
||||
t.setPosition(630 - t.width, 470 - t.height);
|
||||
t.scrollFactor.set(1, 1);
|
||||
add(t);
|
||||
|
||||
var t = new FlxUIText(0, 0, 0, "Top right text!");
|
||||
t.color = 0xFF000000;
|
||||
t.setPosition(630 - t.width, 10);
|
||||
t.scrollFactor.set(1, 0);
|
||||
add(t);
|
||||
}
|
||||
|
||||
public var time:Float = 0;
|
||||
|
||||
@@ -23,6 +23,7 @@ typedef WindowCam = {
|
||||
}
|
||||
class Window extends FlxTypedGroup<FlxBasic> {
|
||||
public var windowFrame:FlxUI9SliceSprite;
|
||||
public var windowInactiveFrame:FlxUI9SliceSprite;
|
||||
public var captionButtons:FlxTypedSpriteGroup<WindowCaptionButton>;
|
||||
|
||||
public var windowWidth:Int = 0;
|
||||
@@ -63,7 +64,16 @@ class Window extends FlxTypedGroup<FlxBasic> {
|
||||
Std.int(DesktopMain.theme.captionActive.right),
|
||||
Std.int(DesktopMain.theme.captionActive.bottom)
|
||||
]);
|
||||
windowInactiveFrame = new FlxUI9SliceSprite(0, 0,
|
||||
Paths.image(DesktopMain.theme.captionInactive.sprite),
|
||||
new Rectangle(10, 10), [
|
||||
Std.int(DesktopMain.theme.captionInactive.left),
|
||||
Std.int(DesktopMain.theme.captionInactive.top),
|
||||
Std.int(DesktopMain.theme.captionInactive.right),
|
||||
Std.int(DesktopMain.theme.captionInactive.bottom)
|
||||
]);
|
||||
add(windowFrame);
|
||||
add(windowInactiveFrame);
|
||||
|
||||
caption = new FlxUIText(24, 4, 0, content.title);
|
||||
captionButtons = new FlxTypedSpriteGroup<WindowCaptionButton>();
|
||||
@@ -176,6 +186,7 @@ class Window extends FlxTypedGroup<FlxBasic> {
|
||||
destroy();
|
||||
return;
|
||||
}
|
||||
windowInactiveFrame.visible = !(windowFrame.visible = focused);
|
||||
var i = members.length;
|
||||
|
||||
var shouldCancel = DesktopMain.instance.mouseInput.overlapsRect(this, new Rectangle(0, 0, windowCaptionCamera.width, windowCaptionCamera.height), windowCaptionCamera);
|
||||
@@ -199,7 +210,8 @@ class Window extends FlxTypedGroup<FlxBasic> {
|
||||
}
|
||||
|
||||
public function updateWindowFrame() {
|
||||
windowFrame.resize(windowWidth + Std.int(DesktopMain.theme.captionActive.left * 2), windowHeight + Std.int(DesktopMain.theme.captionActive.top) + Std.int(DesktopMain.theme.captionActive.left));
|
||||
for(frame in [windowInactiveFrame, windowFrame])
|
||||
frame.resize(windowWidth + Std.int(DesktopMain.theme.captionActive.left * 2), windowHeight + Std.int(DesktopMain.theme.captionActive.top) + Std.int(DesktopMain.theme.captionActive.left));
|
||||
windowCaptionCamera.setSize(windowWidth + Std.int(DesktopMain.theme.captionActive.left * 2), windowHeight + Std.int(DesktopMain.theme.captionActive.top) + Std.int(DesktopMain.theme.captionActive.left));
|
||||
captionButtons.setPosition(windowWidth + Std.int((DesktopMain.theme.captionActive.left * 2) - DesktopMain.theme.captionButtons.offset.x), Std.int(DesktopMain.theme.captionButtons.offset.y));
|
||||
for(e in windowCameras) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package funkin.desktop.windows;
|
||||
|
||||
import flixel.FlxBasic;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import flixel.FlxCamera;
|
||||
|
||||
class WindowContent extends FlxTypedGroup<FlxSprite> {
|
||||
class WindowContent extends FlxTypedGroup<FlxBasic> {
|
||||
public var winX(default, set):Float = 0;
|
||||
public var winY(default, set):Float = 0;
|
||||
public var title(default, set):String = "Window";
|
||||
|
||||
Reference in New Issue
Block a user