use a context menu for adding
i got school but ill fix some of the suadhnasidj when back home
This commit is contained in:
@@ -52,6 +52,10 @@
|
||||
<stepper name="angleStepper" label="Angle" value="charPos.angle" x="last.x + last.bWidth + XOFFSET - 20" y="curY" precision="2" step="0.01" width="100" />
|
||||
|
||||
<stepper name="zoomFactorStepper" label="Zoom Factor" value="charPos.zoomFactor" x="col(1)" y="curY" precision="2" step="0.01" width="100" />
|
||||
|
||||
<section if="charPos.extra.exists('extraPos')">
|
||||
<textbox name="charName" label="Position Name" value="charPos.name" x="col(2)" y="curY" width="100"/>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
||||
@@ -305,27 +305,32 @@ class StageEditor extends UIState {
|
||||
members.insert(newID, sprite);
|
||||
}
|
||||
stageSpritesWindow.addButton.callback = () -> {
|
||||
var node:Access = new Access(Xml.createElement("sprite"));
|
||||
stage.stageXML.x.addChild(node.x);
|
||||
node.att.name = "sprite_" + stageSpritesWindow.buttons.length;
|
||||
|
||||
var sprite:FunkinSprite = new FunkinSprite();
|
||||
add(sprite);
|
||||
sprite.extra.set(exID("node"), node);
|
||||
sprite.extra.set(exID("type"), node.name);
|
||||
sprite.extra.set(exID("imageFile"), '');
|
||||
sprite.extra.set(exID("parentNode"), new Access(node.x.parent));
|
||||
sprite.extra.set(exID("highMemory"), false);
|
||||
sprite.extra.set(exID("lowMemory"), false);
|
||||
xmlMap.set(sprite, node);
|
||||
|
||||
var button:StageSpriteButton = new StageSpriteButton(0, 0, sprite, node);
|
||||
sprite.extra.set(exID("button"), button);
|
||||
stageSpritesWindow.add(button);
|
||||
|
||||
var substate = new StageSpriteEditScreen(button);
|
||||
substate.newSprite = true;
|
||||
openSubState(substate);
|
||||
var lastDrawCam = stageSpritesWindow.addButton.__lastDrawCameras[0];
|
||||
var screenPos = stageSpritesWindow.addButton.getScreenPosition(null, lastDrawCam == null ? FlxG.camera : lastDrawCam);
|
||||
openContextMenu([
|
||||
{
|
||||
label: "Sprite",
|
||||
onSelect: _sprite_new,
|
||||
color: 0xFF00FF00,
|
||||
icon: 2
|
||||
},
|
||||
{
|
||||
label: "Box",
|
||||
onSelect: function(_) {
|
||||
UIState.state.displayNotification(new UIBaseNotification("Creating a box isnt implemented yet!", 2, BOTTOM_LEFT));
|
||||
CoolUtil.playMenuSFX(WARNING, 0.45);
|
||||
},
|
||||
color: 0xFF00FF00,
|
||||
icon: 2
|
||||
},
|
||||
{
|
||||
label: "Character",
|
||||
onSelect: _character_new,
|
||||
color: 0xFF00FF00,
|
||||
icon: 2
|
||||
}
|
||||
], null, lastDrawCam.x + screenPos.x, lastDrawCam.y + screenPos.y + stageSpritesWindow.addButton.bHeight, stageSpritesWindow.addButton.bWidth);
|
||||
screenPos.put();
|
||||
}
|
||||
for (i=>sprite in order) {
|
||||
var xml = (sprite != null) ? xmlMap.get(sprite) : orderNodes[i];
|
||||
@@ -478,6 +483,78 @@ class StageEditor extends UIState {
|
||||
undos.save();
|
||||
}
|
||||
|
||||
function _sprite_new(_) {
|
||||
var node:Access = new Access(Xml.createElement("sprite"));
|
||||
stage.stageXML.x.addChild(node.x);
|
||||
node.att.name = "sprite_" + stageSpritesWindow.buttons.length;
|
||||
|
||||
var sprite:FunkinSprite = new FunkinSprite();
|
||||
insert(members.indexOf(stage), sprite);
|
||||
sprite.extra.set(exID("node"), node);
|
||||
sprite.extra.set(exID("type"), node.name);
|
||||
sprite.extra.set(exID("imageFile"), '');
|
||||
sprite.extra.set(exID("parentNode"), stage.stageXML.x);
|
||||
sprite.extra.set(exID("highMemory"), false);
|
||||
sprite.extra.set(exID("lowMemory"), false);
|
||||
xmlMap.set(sprite, node);
|
||||
|
||||
var button:StageSpriteButton = new StageSpriteButton(0, 0, sprite, node);
|
||||
sprite.extra.set(exID("button"), button);
|
||||
stageSpritesWindow.add(button);
|
||||
|
||||
var substate = new StageSpriteEditScreen(button);
|
||||
substate.newSprite = true;
|
||||
openSubState(substate);
|
||||
}
|
||||
|
||||
function _character_new(_) {
|
||||
var node:Access = new Access(Xml.createElement("char"));
|
||||
stage.stageXML.x.addChild(node.x);
|
||||
node.att.name = "character_" + stageSpritesWindow.buttons.length;
|
||||
|
||||
var charPos = new StageCharPos();
|
||||
charPos.visible = charPos.active = false;
|
||||
charPos.name = "character_" + stageSpritesWindow.buttons.length;
|
||||
charPos.extra.set(exID("extraChar"), true);
|
||||
stage.characterPoses[charPos.name] = charPos;
|
||||
|
||||
var char = new Character(0,0, "bf", stage.isCharFlipped(charPos.name, true), true);
|
||||
char.name = "bf";
|
||||
char.debugMode = true;
|
||||
// Play first anim, and make it the last frame
|
||||
var animToPlay = char.getAnimOrder()[0];
|
||||
char.playAnim(animToPlay, true, NONE);
|
||||
var lastIndx = (char.animateAtlas != null) ?
|
||||
char.animateAtlas.anim.length - 1 :
|
||||
char.animation.curAnim.numFrames - 1;
|
||||
char.playAnim(animToPlay, true, NONE, false, lastIndx);
|
||||
char.stopAnimation();
|
||||
|
||||
// Add it to the stage
|
||||
char.visible = true;
|
||||
char.alpha = 0.5;
|
||||
function setEx(name:String, value:Dynamic) {
|
||||
char.extra.set(exID(name), value);
|
||||
charPos.extra.set(exID(name), value);
|
||||
}
|
||||
setEx("node", node);
|
||||
setEx("pos", charPos);
|
||||
setEx("char", char);
|
||||
|
||||
setEx("parentNode", stage.stageXML);
|
||||
setEx("highMemory", false);
|
||||
setEx("lowMemory", false);
|
||||
chars.push(char);
|
||||
|
||||
stage.applyCharStuff(char, charPos.name, 0);
|
||||
charMap[charPos.name] = char;
|
||||
|
||||
var button = new StageCharacterButton(0,0, charPos, node);
|
||||
char.extra.set(exID("button"), button);
|
||||
charPos.extra.set(exID("button"), button);
|
||||
stageSpritesWindow.add(button);
|
||||
}
|
||||
|
||||
function saveToXml(xml:Xml, name:String, value:Dynamic, ?defaultValue:Dynamic) {
|
||||
if(value == null || value == defaultValue) return xml;
|
||||
xml.set(name, Std.string(value));
|
||||
|
||||
@@ -7,6 +7,7 @@ class UIContextMenu extends MusicBeatSubstate {
|
||||
public var options:Array<UIContextMenuOption>;
|
||||
var x:Float;
|
||||
var y:Float;
|
||||
var w:Int = 100;
|
||||
var contextCam:FlxCamera;
|
||||
|
||||
var bg:UISliceSprite;
|
||||
@@ -21,11 +22,12 @@ class UIContextMenu extends MusicBeatSubstate {
|
||||
__oobDeletion = false;
|
||||
}
|
||||
|
||||
public function new(options:Array<UIContextMenuOption>, callback:UIContextMenuCallback, x:Float, y:Float) {
|
||||
public function new(options:Array<UIContextMenuOption>, callback:UIContextMenuCallback, x:Float, y:Float, ?w:Int = 100) {
|
||||
super();
|
||||
this.options = options.getDefault([]);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@@ -37,7 +39,7 @@ class UIContextMenu extends MusicBeatSubstate {
|
||||
contextCam.scroll.set(0, 7.5);
|
||||
FlxG.cameras.add(contextCam, false);
|
||||
|
||||
bg = new UISliceSprite(x, y, 100, 100, 'editors/ui/context-bg');
|
||||
bg = new UISliceSprite(x, y, w, 100, 'editors/ui/context-bg');
|
||||
bg.cameras = [contextCam];
|
||||
add(bg);
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class UIState extends MusicBeatState {
|
||||
}
|
||||
}
|
||||
|
||||
public function openContextMenu(options:Array<UIContextMenuOption>, ?callback:UIContextMenuCallback, ?x:Float, ?y:Float) {
|
||||
public function openContextMenu(options:Array<UIContextMenuOption>, ?callback:UIContextMenuCallback, ?x:Float, ?y:Float, ?w:Int) {
|
||||
var state = FlxG.state;
|
||||
while(state.subState != null && !(state._requestSubStateReset && state._requestedSubState == null))
|
||||
state = state.subState;
|
||||
@@ -144,7 +144,7 @@ class UIState extends MusicBeatState {
|
||||
state.persistentDraw = true;
|
||||
state.persistentUpdate = true;
|
||||
|
||||
state.openSubState(curContextMenu = new UIContextMenu(options, callback, x.getDefault(__mousePos.x), y.getDefault(__mousePos.y)));
|
||||
state.openSubState(curContextMenu = new UIContextMenu(options, callback, x.getDefault(__mousePos.x), y.getDefault(__mousePos.y), w));
|
||||
return curContextMenu;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user