mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-05 06:14:36 +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)
|
FlxMouseEventManager.add(this, dragShit, null, function(spr:SprStage)
|
||||||
{
|
{
|
||||||
if (FlxG.keys.pressed.CONTROL)
|
if (isSelected() || StageBuilderState.curTool == SELECT)
|
||||||
alpha = 0.5;
|
alpha = 0.5;
|
||||||
}, function(spr:SprStage)
|
}, function(spr:SprStage)
|
||||||
{
|
{
|
||||||
|
@ -23,11 +23,16 @@ class SprStage extends FlxSprite
|
||||||
}, false, true, true);
|
}, false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSelected():Bool
|
||||||
|
{
|
||||||
|
return StageBuilderState.curSelectedSpr == this;
|
||||||
|
}
|
||||||
|
|
||||||
override function update(elapsed:Float)
|
override function update(elapsed:Float)
|
||||||
{
|
{
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
if (mousePressing)
|
if (mousePressing && isSelected())
|
||||||
{
|
{
|
||||||
this.x = FlxG.mouse.x - mouseOffset.x;
|
this.x = FlxG.mouse.x - mouseOffset.x;
|
||||||
this.y = FlxG.mouse.y - mouseOffset.y;
|
this.y = FlxG.mouse.y - mouseOffset.y;
|
||||||
|
@ -36,6 +41,7 @@ class SprStage extends FlxSprite
|
||||||
if (FlxG.mouse.justReleased)
|
if (FlxG.mouse.justReleased)
|
||||||
{
|
{
|
||||||
mousePressing = false;
|
mousePressing = false;
|
||||||
|
StageBuilderState.changeTool(GRAB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +51,13 @@ class SprStage extends FlxSprite
|
||||||
|
|
||||||
function dragShit(spr:SprStage)
|
function dragShit(spr:SprStage)
|
||||||
{
|
{
|
||||||
if (FlxG.keys.pressed.CONTROL)
|
if (StageBuilderState.curTool == SELECT)
|
||||||
StageBuilderState.curSelectedSpr = this;
|
StageBuilderState.curSelectedSpr = this;
|
||||||
|
|
||||||
mousePressing = true;
|
mousePressing = true;
|
||||||
|
|
||||||
|
if (isSelected())
|
||||||
|
StageBuilderState.changeTool(GRABBING);
|
||||||
mouseOffset.set(FlxG.mouse.x - this.x, FlxG.mouse.y - this.y);
|
mouseOffset.set(FlxG.mouse.x - this.x, FlxG.mouse.y - this.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,10 +142,27 @@ class StageBuilderState extends MusicBeatState
|
||||||
// trace();
|
// trace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static var curTool:TOOLS = SELECT;
|
||||||
|
|
||||||
|
var tempTool:TOOLS = SELECT;
|
||||||
|
|
||||||
override function update(elapsed:Float)
|
override function update(elapsed:Float)
|
||||||
{
|
{
|
||||||
// trace(sndChannel.position);
|
if (FlxG.keys.justPressed.CONTROL)
|
||||||
// trace(snd
|
{
|
||||||
|
tempTool = curTool;
|
||||||
|
|
||||||
|
changeTool(SELECT);
|
||||||
|
}
|
||||||
|
if (FlxG.keys.justReleased.CONTROL)
|
||||||
|
{
|
||||||
|
changeTool(tempTool);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlxG.keys.justPressed.V)
|
||||||
|
{
|
||||||
|
changeTool(SELECT);
|
||||||
|
}
|
||||||
|
|
||||||
if (FlxG.keys.justPressed.R)
|
if (FlxG.keys.justPressed.R)
|
||||||
{
|
{
|
||||||
|
@ -163,14 +180,15 @@ class StageBuilderState extends MusicBeatState
|
||||||
{
|
{
|
||||||
if (curSelectedSpr != null)
|
if (curSelectedSpr != null)
|
||||||
{
|
{
|
||||||
if (curSelectedSpr.layer != 0)
|
moveLayer(1);
|
||||||
{
|
}
|
||||||
curSelectedSpr.layer -= 1;
|
|
||||||
sprGrp.members[curSelectedSpr.layer].layer += 1;
|
|
||||||
}
|
}
|
||||||
// NOTE: fix to account if only one layer is in?
|
|
||||||
|
|
||||||
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);
|
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 isShaking:Bool = false;
|
||||||
var shakeIntensity:Float = 60;
|
var shakeIntensity:Float = 60;
|
||||||
var shakePos:FlxPoint = new FlxPoint();
|
var shakePos:FlxPoint = new FlxPoint();
|
||||||
|
@ -231,3 +296,11 @@ class StageBuilderState extends MusicBeatState
|
||||||
return FlxSort.byValues(FlxSort.ASCENDING, layer1.layer, layer2.layer);
|
return FlxSort.byValues(FlxSort.ASCENDING, layer1.layer, layer2.layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum TOOLS
|
||||||
|
{
|
||||||
|
SELECT;
|
||||||
|
MOVE;
|
||||||
|
GRAB;
|
||||||
|
GRABBING;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue