This commit is contained in:
Yoshman29
2022-12-28 03:30:57 +01:00
parent ae2c32d1a4
commit 4019ebfe98
11 changed files with 216 additions and 24 deletions
+3
View File
@@ -25,6 +25,9 @@
<contextBackground path="context" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />
<contextOption path="contextOption" textColor="255,255,255" height="20" />
<!-- MENU BAR -->
<menuBar path="menuBar" height="20" />
<!-- TEXTBOX -->
<textbox path="textbox" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />
<textboxHover path="textboxHover" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />

Before

Width:  |  Height:  |  Size: 116 B

After

Width:  |  Height:  |  Size: 116 B

+1 -1
View File
@@ -1 +1 @@
1834
1847
@@ -25,6 +25,8 @@ class CharacterEditor extends WindowContent {
public var curAnim:AnimData;
public var menuBar:MenuBar;
/**
* ANIMATION TAB
*/
@@ -36,6 +38,20 @@ class CharacterEditor extends WindowContent {
public var animOffsetX:NumericStepper;
public var animOffsetY:NumericStepper;
/**
* CHARACTER SETTINGS TAB
*/
public var charSpriteInput:InputBox;
public var charIconInput:InputBox;
public var charIsPlayerCheckbox:Checkbox;
public var charIsGFCheckbox:Checkbox;
public var charOffsetXStepper:NumericStepper;
public var charOffsetYStepper:NumericStepper;
public var charHoldTimeStepper:NumericStepper;
public var charFlipXCheckbox:Checkbox;
public var charScaleStepper:NumericStepper;
public var charAntialiasingCheckbox:Checkbox;
public override function create() {
super.create();
@@ -77,6 +93,78 @@ class CharacterEditor extends WindowContent {
// interface setup
setupTabView();
// todo: menu bar handlers
menuBar = new MenuBar([
{
name: "File",
options: [
{
name: "New"
},
{
name: "Open"
},
{
name: "Save"
},
{
name: "Save As..."
},
{
name: "Exit"
}
]
},
{
name: "Edit",
options: [
{
name: "Add Animation..."
},
{
name: "Delete Animation"
}
]
},
{
name: "View",
options: [
{
name: "Lock Camera on Character"
},
{
name: "Reset Camera Position",
callback: resetCamPos
},
{
name: "Reset Camera Zoom"
},
{
name: "Show a Boyfriend Silouhette"
},
{
name: "Show a Dad Silouhette"
},
{
name: "Show a Girlfriend Silouhette"
}
]
},
{
name: "Help",
options: [
{
name: "Open Editor Documentation"
},
{
name: "Open Engine Documentation"
}
]
}
]);
menuBar.cameras = [camHUD];
add(menuBar);
}
public function setupTabView() {
@@ -84,6 +172,14 @@ class CharacterEditor extends WindowContent {
tabView.updateAnchor(1, 0, [camHUD]);
add(tabView);
addAnimTab();
addCharTab();
refreshAnims();
changeAnim(0);
}
public function addAnimTab() {
var content:Array<FlxBasic> = [];
var label:WindowText = null;
@@ -101,17 +197,42 @@ class CharacterEditor extends WindowContent {
content.push(animLoopCheckbox = new Checkbox(10, animPrefixInput.y + animPrefixInput.height + 10, 380, "Loop"));
content.push(label = new WindowText(10, animLoopCheckbox.y + animLoopCheckbox.height + 10, 0, "Animation FPS (Frames per second)"));
content.push(animFpsStepper = new NumericStepper(10, label.y + label.height + 10, 380, 0));
content.push(animFpsStepper = new NumericStepper(10, label.y + label.height, 380, 0));
content.push(label = new WindowText(10, animFpsStepper.y + animFpsStepper.height + 10, 0, "Animation Offset (Relative to scale)"));
content.push(animOffsetX = new NumericStepper(10, label.y + label.height + 10, 180, 0));
content.push(animOffsetY = new NumericStepper(200, label.y + label.height + 10, 180, 0));
content.push(animOffsetX = new NumericStepper(10, label.y + label.height, 180, 0));
content.push(animOffsetY = new NumericStepper(200, label.y + label.height, 180, 0));
for(e in [animOffsetX, animOffsetY])
e.increment = 10;
for(spr in content)
tabView.tabs[0].add(spr);
}
refreshAnims();
changeAnim(0);
public function addCharTab() {
var content:Array<FlxObject> = [];
var label:WindowText = null;
content.push(label = new WindowText(10, 10, 0, "Sprite Name (images/characters/)"));
content.push(charSpriteInput = new InputBox(10, label.y + label.height, 380, char.xml.has.sprite ? char.xml.att.sprite : ""));
content.push(label = new WindowText(10, content.last().y + content.last().height, 0, "Icon Name (images/icons/)"));
content.push(charIconInput = new InputBox(10, label.y + label.height, 380, char.icon.getDefault("")));
content.push(charIsPlayerCheckbox = new Checkbox(10, content.last().y + content.last().height + 10, 380, "Playable character"));
content.push(label = new WindowText(10, content.last().y + content.last().height, 380, "(Offsets are automatically fixed when playing as a non-playable character and vice versa)"));
charIsPlayerCheckbox.checked = char.xml.getAtt("isPlayer") == "true";
content.push(charIsGFCheckbox = new Checkbox(10, content.last().y + content.last().height + 10, 380, "Is Girlfriend"));
content.push(label = new WindowText(10, content.last().y + content.last().height, 380, "(Characters marked as Girlfriend will replace GF when used as opponent)"));
charIsGFCheckbox.checked = char.isGF;
content.push(charFlipXCheckbox = new Checkbox(10, content.last().y + content.last().height + 10, 380, "Flip Horizontally"));
charFlipXCheckbox.checked = char.__baseFlipped != char.isPlayer;
for(spr in content)
tabView.tabs[1].add(spr);
}
public function changeAnim(id:Int) {
@@ -157,6 +278,11 @@ class CharacterEditor extends WindowContent {
if (shouldUpdate)
updateCurAnim(oldName, updateListAsWell);
}
char.isPlayer = char.playerOffsets = charIsPlayerCheckbox.checked;
char.isGF = charIsPlayerCheckbox.checked;
char.flipX = char.__baseFlipped = (charFlipXCheckbox.checked != char.isPlayer);
char.x = charIsPlayerCheckbox.checked ? 770 : 100;
}
public function updateCurAnim(?oldName:String, updateListAsWell:Bool = false) {
@@ -164,6 +290,7 @@ class CharacterEditor extends WindowContent {
oldName = char.animation.curAnim != null ? char.animation.curAnim.name : curAnim.name;
char.animation.remove(oldName);
char.animation.curAnim = null;
XMLUtil.addAnimToSprite(char, curAnim);
@@ -173,4 +300,19 @@ class CharacterEditor extends WindowContent {
public override function onWindowResize(width:Int, height:Int) {
tabView.resize(400, height - 20);
}
/**
* =========== CONTEXT MENU OPTIONS ===========
*/
/**
* View
*/
public function resetCamPos() {
var pos = char.getCameraPosition();
camFollow.setPosition(pos.x, pos.y);
}
public function resetCamZoom() {
windowCamera.zoom = 1;
}
}
+3
View File
@@ -117,8 +117,11 @@ class Button extends FlxObject implements IDesktopFocusableObject {
spr.draw();
label.y += (height - label.height) / 2;
label.draw();
additionalDraw();
}
public function additionalDraw() {}
public function onFocus() {}
public function onFocusLost() {}
+1 -1
View File
@@ -51,7 +51,7 @@ class InputBox extends Button implements IDesktopInputObject {
onTextInput("");
case Keyboard.BACKSPACE:
text = text.substr(0, index <= 0 ? 0 : index - 1) + text.substring(index, text.length);
index--;
changeIndex(-1);
onTextInput("");
case Keyboard.ENTER | Keyboard.NUMPAD_ENTER:
if (onChange != null)
+53
View File
@@ -0,0 +1,53 @@
package funkin.desktop.sprites;
import flixel.FlxG;
import flixel.math.FlxPoint;
import flixel.FlxSprite;
import flixel.FlxBasic;
import funkin.desktop.windows.WindowGroup;
class MenuBar extends WindowGroup<FlxBasic> {
public var spr:FlxSprite;
public var buttons:Array<Button> = [];
public function new(trees:Array<TopMenuTree>) {
super();
spr = new FlxSprite(0, 0);
spr.loadGraphic(Paths.image(DesktopMain.theme.menuBar.sprite));
add(spr);
var lastX:Float = 0;
for(t in trees) {
var b:Button = null;
b = new Button(lastX, 0, t.name, function() {
var pos:FlxPoint = b.getScreenPosition(null, camera);
pos.y += b.height;
var camPos = camera != null ? FlxPoint.get(camera.x, camera.y) : FlxPoint.get();
ContextMenu.open(pos.x + camPos.x, pos.y + camPos.y, t.options, function(i) {});
});
b.label.fieldWidth = 0;
@:privateAccess b.label._regen = true;
b.resize(b.label.width + 20, 20);
lastX = b.x + b.width;
b.normalSprite.visible = false;
buttons.push(b);
add(b);
}
}
public override function update(elapsed:Float) {
super.update(elapsed);
spr.setGraphicSize(FlxG.width, 20);
spr.updateHitbox();
}
}
typedef TopMenuTree = {
var name:String;
var options:Array<ContextOption>;
}
@@ -2,6 +2,7 @@ package funkin.desktop.sprites;
import flixel.math.FlxMath;
// TODO: FIX MEMORY GOING BRRRRRRRRRRRRRRRRRRRRR
class NumericStepper extends InputBox {
public var decimals:Int = 0;
public var increment:Float = 1;
@@ -34,13 +35,12 @@ class NumericStepper extends InputBox {
super.update(elapsed);
}
public override function draw() {
public override function additionalDraw() {
addButton.copyProperties(this);
subButton.copyProperties(this);
addButton.x += width;
subButton.x += width + height;
super.draw();
addButton.draw();
subButton.draw();
}
-15
View File
@@ -1,15 +0,0 @@
package funkin.desktop.sprites;
import flixel.FlxBasic;
import funkin.desktop.windows.WindowGroup;
class TopMenu extends WindowGroup<FlxBasic> {
public function new(trees:Array<TopMenuTree>) {
super();
}
}
typedef TopMenuTree = {
var name:String;
var options:Array<ContextOption>;
}
+5
View File
@@ -59,6 +59,11 @@ class Theme {
public var contextBackground:ThemeData = new ThemeData();
public var contextOption:ThemeData = new ThemeData();
/**
* MENU BAR
*/
public var menuBar:ThemeData = new ThemeData();
/**
* THEME
*/
+1
View File
@@ -27,6 +27,7 @@ import funkin.scripting.events.*;
import funkin.scripting.events.PlayAnimEvent.PlayAnimContext;
using StringTools;
@:allow(funkin.desktop.editors.CharacterEditor)
class Character extends FlxSprite implements IBeatReceiver implements IOffsetCompatible
{
private var __stunnedTime:Float = 0;