1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-01-01 09:48:14 +00:00

stage edit funny moments

This commit is contained in:
Cameron Taylor 2023-02-03 18:10:06 -05:00
parent ac3e1c1899
commit ca443411be
6 changed files with 101 additions and 17 deletions

View file

@ -144,6 +144,7 @@ class BaseCharacter extends Bopper
else
{
this.characterName = _data.name;
this.name = _data.name;
this.singTimeCrochet = _data.singTime;
this.globalOffsets = _data.offsets;
this.flipX = _data.flipX;

View file

@ -5,6 +5,7 @@ import flixel.math.FlxPoint;
import flixel.util.FlxTimer;
import funkin.modding.IScriptedClass.IPlayStateScriptedClass;
import funkin.modding.events.ScriptEvent;
import funkin.play.stage.StageProp;
typedef AnimationFrameCallback = String->Int->Int->Void;
typedef AnimationFinishedCallback = String->Void;
@ -13,7 +14,7 @@ typedef AnimationFinishedCallback = String->Void;
* A Bopper is a stage prop which plays a dance animation.
* Y'know, a thingie that bops. A bopper.
*/
class Bopper extends FlxSprite implements IPlayStateScriptedClass
class Bopper extends StageProp implements IPlayStateScriptedClass
{
/**
* The bopper plays the dance animation once every `danceEvery` beats.
@ -281,8 +282,7 @@ class Bopper extends FlxSprite implements IPlayStateScriptedClass
applyAnimationOffsets(correctName);
canPlayOtherAnims = false;
forceAnimationTimer.start(duration, (timer) ->
{
forceAnimationTimer.start(duration, (timer) -> {
canPlayOtherAnims = true;
}, 1);
}

View file

@ -11,9 +11,12 @@ import funkin.modding.events.ScriptEventDispatcher;
import funkin.play.character.BaseCharacter;
import funkin.play.stage.StageData.StageDataCharacter;
import funkin.play.stage.StageData.StageDataParser;
import funkin.play.stage.StageProp;
import funkin.util.SortUtil;
import funkin.util.assets.FlxAnimationUtil;
typedef StagePropGroup = FlxTypedSpriteGroup<StageProp>;
/**
* A Stage is a group of objects rendered in the PlayState.
*
@ -28,7 +31,7 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass
public var camZoom:Float = 1.0;
var namedProps:Map<String, FlxSprite> = new Map<String, FlxSprite>();
var namedProps:Map<String, StageProp> = new Map<String, StageProp>();
var characters:Map<String, BaseCharacter> = new Map<String, BaseCharacter>();
var boppers:Array<Bopper> = new Array<Bopper>();
@ -66,7 +69,7 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass
debugIconGroup = new FlxSpriteGroup();
debugIconGroup.visible = false;
debugIconGroup.zIndex = 1000000;
add(debugIconGroup);
// add(debugIconGroup);
}
public function resetStage():Void
@ -93,7 +96,7 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass
for (dataProp in _data.props)
{
// Fetch the prop.
var prop:FlxSprite = getNamedProp(dataProp.name);
var prop:StageProp = getNamedProp(dataProp.name);
if (prop != null)
{
@ -125,14 +128,14 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass
var isAnimated = dataProp.animations.length > 0;
var propSprite:FlxSprite;
var propSprite:StageProp;
if (dataProp.danceEvery != 0)
{
propSprite = new Bopper(dataProp.danceEvery);
}
else
{
propSprite = new FlxSprite();
propSprite = new StageProp();
}
if (isAnimated)
@ -239,11 +242,12 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass
* @param name (Optional) A unique name for the sprite.
* You can call `getNamedProp(name)` to retrieve it later.
*/
public function addProp(prop:FlxSprite, ?name:String = null)
public function addProp(prop:StageProp, ?name:String = null)
{
if (name != null)
{
namedProps.set(name, prop);
prop.name = name;
}
this.add(prop);
}
@ -255,6 +259,7 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass
{
boppers.push(bopper);
this.addProp(bopper, name);
bopper.name = name;
}
/**
@ -268,8 +273,7 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass
public function setShader(shader:FlxShader)
{
forEachAlive(function(prop:FlxSprite)
{
forEachAlive(function(prop:FlxSprite) {
prop.shader = shader;
});
}
@ -439,7 +443,7 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass
* @param name The name of the prop to retrieve.
* @return The corresponding FlxSprite.
*/
public function getNamedProp(name:String):FlxSprite
public function getNamedProp(name:String):StageProp
{
return this.namedProps.get(name);
}

View file

@ -0,0 +1,13 @@
package funkin.play.stage;
import flixel.FlxSprite;
class StageProp extends FlxSprite
{
public var name:String = "";
public function new()
{
super();
}
}

View file

@ -1,6 +1,8 @@
package funkin.ui.haxeui;
import haxe.ui.RuntimeComponentBuilder;
import haxe.ui.components.CheckBox;
import haxe.ui.containers.menus.MenuCheckBox;
import haxe.ui.core.Component;
import haxe.ui.events.MouseEvent;
@ -101,6 +103,49 @@ class HaxeUISubState extends MusicBeatSubstate
}
}
/**
* Set the value of a HaxeUI component.
* Usually modifies the text of a label or value of a text field.
*/
function setUIValue<T>(key:String, value:T):T
{
var target:Component = findComponent(key);
if (target == null)
{
// Gracefully handle the case where the item can't be located.
trace('WARN: Could not locate menu item: $key');
return value;
}
else
{
return target.value = value;
}
}
/**
* Set the value of a HaxeUI checkbox,
* since that's on 'selected' instead of 'value'.
*/
public function setUICheckboxSelected<T>(key:String, value:Bool):Bool
{
var targetA:CheckBox = findComponent(key, CheckBox);
if (targetA != null)
{
return targetA.selected = value;
}
var targetB:MenuCheckBox = findComponent(key, MenuCheckBox);
if (targetB != null)
{
return targetB.selected = value;
}
// Gracefully handle the case where the item can't be located.
trace('WARN: Could not locate check box: $key');
return value;
}
public function findComponent<T:Component>(criteria:String = null, type:Class<T> = null, recursive:Null<Bool> = null, searchType:String = "id"):Null<T>
{
if (component == null) return null;

View file

@ -4,9 +4,12 @@ import flixel.FlxSprite;
import flixel.input.mouse.FlxMouseEvent;
import flixel.math.FlxPoint;
import funkin.play.PlayState;
import funkin.play.character.BaseCharacter;
import funkin.play.stage.StageData;
import funkin.play.stage.StageProp;
import funkin.ui.haxeui.HaxeUISubState;
import haxe.ui.RuntimeComponentBuilder;
import haxe.ui.containers.ListView;
import haxe.ui.core.Component;
import openfl.events.Event;
import openfl.events.IOErrorEvent;
@ -46,10 +49,33 @@ class StageOffsetSubstate extends HaxeUISubState
// uiStuff.cameras = [PlayState.instance.camHUD];
// btn.cameras = [PlayState.instance.camHUD];
var layerList:ListView = findComponent("prop-layers");
for (thing in PlayState.instance.currentStage)
{
var prop:StageProp = cast thing;
if (prop != null && prop.name != null)
{
layerList.dataSource.add(
{
item: prop.name,
complete: true
});
}
//
//
//
//
//
FlxMouseEvent.add(thing, spr -> {
var dyn:StageProp = cast spr;
if (dyn != null && dyn.name != null) trace(dyn.name);
char = cast thing;
// trace(thing);
// trace(spr);
trace("JUST PRESSED!");
sprOld.x = thing.x;
sprOld.y = thing.y;
@ -115,11 +141,6 @@ class StageOffsetSubstate extends HaxeUISubState
if (FlxG.keys.pressed.CONTROL) CoolUtil.mouseWheelZoom();
if (FlxG.mouse.wheel != 0)
{
FlxG.camera.zoom += FlxG.mouse.wheel * 0.1;
}
if (FlxG.keys.justPressed.Y)
{
for (thing in PlayState.instance.currentStage)