mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-08-20 15:35:13 +00:00
cursor shit and tool shit i duno lol!
This commit is contained in:
parent
6c47686ee8
commit
65d187f511
|
@ -15,7 +15,7 @@ class SprStage extends FlxSprite
|
|||
|
||||
FlxMouseEventManager.add(this, dragShit, null, function(spr:SprStage)
|
||||
{
|
||||
if (FlxG.keys.pressed.CONTROL)
|
||||
if (isSelected() || StageBuilderState.curTool == SELECT)
|
||||
alpha = 0.5;
|
||||
}, function(spr:SprStage)
|
||||
{
|
||||
|
@ -23,11 +23,16 @@ class SprStage extends FlxSprite
|
|||
}, false, true, true);
|
||||
}
|
||||
|
||||
function isSelected():Bool
|
||||
{
|
||||
return StageBuilderState.curSelectedSpr == this;
|
||||
}
|
||||
|
||||
override function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
||||
if (mousePressing)
|
||||
if (mousePressing && isSelected())
|
||||
{
|
||||
this.x = FlxG.mouse.x - mouseOffset.x;
|
||||
this.y = FlxG.mouse.y - mouseOffset.y;
|
||||
|
@ -36,6 +41,7 @@ class SprStage extends FlxSprite
|
|||
if (FlxG.mouse.justReleased)
|
||||
{
|
||||
mousePressing = false;
|
||||
StageBuilderState.changeTool(GRAB);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,11 +51,13 @@ class SprStage extends FlxSprite
|
|||
|
||||
function dragShit(spr:SprStage)
|
||||
{
|
||||
if (FlxG.keys.pressed.CONTROL)
|
||||
if (StageBuilderState.curTool == SELECT)
|
||||
StageBuilderState.curSelectedSpr = this;
|
||||
|
||||
mousePressing = true;
|
||||
|
||||
if (isSelected())
|
||||
StageBuilderState.changeTool(GRABBING);
|
||||
mouseOffset.set(FlxG.mouse.x - this.x, FlxG.mouse.y - this.y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,10 +142,27 @@ class StageBuilderState extends MusicBeatState
|
|||
// trace();
|
||||
}
|
||||
|
||||
public static var curTool:TOOLS = SELECT;
|
||||
|
||||
var tempTool:TOOLS = SELECT;
|
||||
|
||||
override function update(elapsed:Float)
|
||||
{
|
||||
// trace(sndChannel.position);
|
||||
// trace(snd
|
||||
if (FlxG.keys.justPressed.CONTROL)
|
||||
{
|
||||
tempTool = curTool;
|
||||
|
||||
changeTool(SELECT);
|
||||
}
|
||||
if (FlxG.keys.justReleased.CONTROL)
|
||||
{
|
||||
changeTool(tempTool);
|
||||
}
|
||||
|
||||
if (FlxG.keys.justPressed.V)
|
||||
{
|
||||
changeTool(SELECT);
|
||||
}
|
||||
|
||||
if (FlxG.keys.justPressed.R)
|
||||
{
|
||||
|
@ -163,14 +180,15 @@ class StageBuilderState extends MusicBeatState
|
|||
{
|
||||
if (curSelectedSpr != null)
|
||||
{
|
||||
if (curSelectedSpr.layer != 0)
|
||||
{
|
||||
curSelectedSpr.layer -= 1;
|
||||
sprGrp.members[curSelectedSpr.layer].layer += 1;
|
||||
}
|
||||
// NOTE: fix to account if only one layer is in?
|
||||
moveLayer(1);
|
||||
}
|
||||
}
|
||||
|
||||
sortSprGrp();
|
||||
if (FlxG.keys.justPressed.DOWN)
|
||||
{
|
||||
if (curSelectedSpr != null)
|
||||
{
|
||||
moveLayer(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,9 +221,56 @@ class StageBuilderState extends MusicBeatState
|
|||
}
|
||||
}
|
||||
|
||||
if (FlxG.keys.justPressed.Z && actionQueue.length > 0)
|
||||
{
|
||||
isUndoRedo = true;
|
||||
actionQueue.pop()(posQueue.pop());
|
||||
}
|
||||
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
static public function changeTool(newTool:TOOLS)
|
||||
{
|
||||
curTool = newTool;
|
||||
|
||||
switch (curTool)
|
||||
{
|
||||
case SELECT:
|
||||
FlxG.mouse.load(new FlxSprite().loadGraphic(Paths.image('stageBuild/cursorSelect')).pixels);
|
||||
case GRABBING:
|
||||
FlxG.mouse.load(new FlxSprite().loadGraphic(Paths.image('stageBuild/cursorGrabbing')).pixels);
|
||||
case GRAB:
|
||||
FlxG.mouse.load(new FlxSprite().loadGraphic(Paths.image('stageBuild/cursorGrab')).pixels);
|
||||
default:
|
||||
trace('swag');
|
||||
}
|
||||
}
|
||||
|
||||
var isUndoRedo:Bool = false;
|
||||
var actionQueue:Array<Dynamic->Void> = [];
|
||||
var posQueue:Array<Dynamic> = [];
|
||||
|
||||
function moveLayer(layerMovement:Int = 0):Void
|
||||
{
|
||||
if (curSelectedSpr.layer == 0 && layerMovement > 0)
|
||||
return;
|
||||
|
||||
curSelectedSpr.layer -= layerMovement;
|
||||
sprGrp.members[curSelectedSpr.layer].layer += layerMovement;
|
||||
// NOTE: fix to account if only one layer is in?
|
||||
|
||||
sortSprGrp();
|
||||
|
||||
if (!isUndoRedo)
|
||||
{
|
||||
actionQueue.push(moveLayer);
|
||||
posQueue.push(layerMovement * -1);
|
||||
}
|
||||
else
|
||||
isUndoRedo = false;
|
||||
}
|
||||
|
||||
var isShaking:Bool = false;
|
||||
var shakeIntensity:Float = 60;
|
||||
var shakePos:FlxPoint = new FlxPoint();
|
||||
|
@ -231,3 +296,11 @@ class StageBuilderState extends MusicBeatState
|
|||
return FlxSort.byValues(FlxSort.ASCENDING, layer1.layer, layer2.layer);
|
||||
}
|
||||
}
|
||||
|
||||
enum TOOLS
|
||||
{
|
||||
SELECT;
|
||||
MOVE;
|
||||
GRAB;
|
||||
GRABBING;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue