forgot to push :trollface:

This commit is contained in:
Yoshman29
2022-12-03 00:50:36 +01:00
parent e438774935
commit 1fc8ce3df2
7 changed files with 76 additions and 52 deletions
+3
View File
@@ -164,4 +164,7 @@
<!-- Comment this out to disable global scripts !-->
<haxedef name="GLOBAL_SCRIPT" />
<!-- Comment this out to disable softcoded states and state scripting !-->
<haxedef name="SOFTCODED_STATES" />
</project>
+1 -1
View File
@@ -1 +1 @@
1327
1333
+37
View File
@@ -0,0 +1,37 @@
package funkin.editors;
import funkin.desktop.DesktopMain;
import flixel.FlxG;
import flixel.FlxState;
import funkin.game.*;
class CharacterEditor extends MusicBeatState {
public var character:Character;
public var characterName:String;
private var oldState:Class<FlxState> = null;
public function new(char:String) {
super();
this.characterName = char;
if (!(FlxG.state is DesktopMain))
oldState = Type.getClass(FlxG.state);
}
public override function create() {
super.create();
add(new Stage("default"));
character = new Character(770, 100, characterName, true);
characterName = character.curCharacter;
add(character);
trace(members);
}
public override function update(elapsed:Float) {
super.update(elapsed);
if (controls.BACK && oldState != null)
FlxG.switchState(Type.createInstance(oldState, []));
}
}
+5 -3
View File
@@ -1,5 +1,6 @@
package funkin.game;
import funkin.editors.CharacterEditor;
import funkin.scripting.DummyScript;
import funkin.menus.StoryMenuState.WeekData;
import funkin.ui.FunkinText;
@@ -128,7 +129,6 @@ class PlayState extends MusicBeatState
public var iconP2:HealthIcon;
public var camHUD:HudCamera;
public var camGame:FlxCamera;
public var songScore:Int = 0;
public var misses:Int = 0;
@@ -278,7 +278,7 @@ class PlayState extends MusicBeatState
if (SONG.stage == null || SONG.stage.trim() == "") SONG.stage = "stage";
add(new Stage(SONG.stage));
add(stage = new Stage(SONG.stage));
switch(SONG.song) {
@@ -937,7 +937,9 @@ class PlayState extends MusicBeatState
FlxG.switchState(new Charting()); */
if (FlxG.keys.justPressed.EIGHT)
FlxG.switchState(new AnimationDebug(SONG.player2));
FlxG.switchState(new CharacterEditor(SONG.player2));
if (FlxG.keys.justPressed.NINE)
FlxG.switchState(new CharacterEditor(SONG.player1));
if (startingSong)
{
+29 -13
View File
@@ -1,5 +1,7 @@
package funkin.game;
import flixel.FlxG;
import flixel.FlxState;
import funkin.system.XMLUtil;
import flixel.FlxSprite;
import openfl.utils.Assets;
@@ -22,9 +24,12 @@ class Stage extends FlxBasic implements IBeatReceiver {
return stageSprites[name];
}
public function new(stage:String) {
public function new(stage:String, ?state:FlxState) {
super();
if (PlayState.instance == null) return;
if (state == null) state = PlayState.instance;
if (state == null) state = FlxG.state;
stagePath = Paths.xml('stages/$stage');
try {
if (Assets.exists(stagePath)) stageXML = new Access(Xml.parse(Assets.getText(stagePath)).firstElement());
@@ -35,24 +40,26 @@ class Stage extends FlxBasic implements IBeatReceiver {
if (stageXML != null) {
var spritesParentFolder = "";
if (stageXML.has.zoom) {
var parsed:Null<Float> = Std.parseFloat(stageXML.att.zoom);
if (parsed != null) PlayState.instance.defaultCamZoom = parsed;
if (PlayState.instance != null) {
if (stageXML.has.zoom) {
var parsed:Null<Float> = Std.parseFloat(stageXML.att.zoom);
if (parsed != null && PlayState.instance != null) PlayState.instance.defaultCamZoom = parsed;
}
PlayState.instance.curStage = stageXML.has.name ? stageXML.att.name : stage;
}
if (stageXML.has.folder) {
spritesParentFolder = stageXML.att.folder;
if (spritesParentFolder.charAt(spritesParentFolder.length-1) != "/") spritesParentFolder = spritesParentFolder + "/";
}
if (stageXML.has.name) PlayState.instance.curStage = stageXML.att.name;
for(node in stageXML.elements) {
var sprite:Dynamic = switch(node.name) {
case "sprite" | "spr" | "sparrow":
var spr = new StageSprite();
spr.antialiasing = true;
if (!node.has.sprite || !node.has.name || !node.has.x || !node.has.y) continue;
var spr = new StageSprite(node.att.name);
spr.antialiasing = true;
spr.loadAnimatedGraphic(Paths.image('$spritesParentFolder${node.att.sprite}', null, true));
var x:Null<Float> = Std.parseFloat(node.att.x);
@@ -92,17 +99,20 @@ class Stage extends FlxBasic implements IBeatReceiver {
}
stageSprites.set(node.att.name, spr);
PlayState.instance.add(spr);
state.add(spr);
spr;
case "boyfriend" | "bf":
if (PlayState.instance == null) continue;
doCharNodeShit(PlayState.instance.boyfriend, node);
PlayState.instance.add(PlayState.instance.boyfriend);
PlayState.instance.boyfriend;
case "girlfriend" | "gf":
if (PlayState.instance == null) continue;
doCharNodeShit(PlayState.instance.gf, node);
PlayState.instance.add(PlayState.instance.gf);
PlayState.instance.gf;
case "ratings" | "combo":
if (PlayState.instance == null) continue;
PlayState.instance.comboGroup.setPosition(
Std.parseFloat(node.getAtt("x")).getDefault(PlayState.instance.comboGroup.x),
Std.parseFloat(node.getAtt("y")).getDefault(PlayState.instance.comboGroup.y)
@@ -110,19 +120,20 @@ class Stage extends FlxBasic implements IBeatReceiver {
PlayState.instance.add(PlayState.instance.comboGroup);
PlayState.instance.comboGroup;
case "dad" | "opponent":
if (PlayState.instance.dad == null || PlayState.instance.dad.isGF) continue;
if (PlayState.instance == null || PlayState.instance.dad == null || PlayState.instance.dad.isGF) continue;
doCharNodeShit(PlayState.instance.dad, node);
PlayState.instance.add(PlayState.instance.dad);
PlayState.instance.dad;
default: null;
}
if (sprite != null) {
for(e in node.nodes.property) {
for(e in node.nodes.property)
XMLUtil.applyXMLProperty(sprite, e);
}
}
}
}
if (PlayState.instance == null) return;
stageScript = Script.create(Paths.script('data/stages/$stage'));
for(k=>e in stageSprites) {
stageScript.set(k, e);
@@ -157,7 +168,12 @@ class Stage extends FlxBasic implements IBeatReceiver {
class StageSprite extends FlxSprite implements IBeatReceiver {
public var beatAnims:Array<String> = [];
public var name:String;
public function new(name:String) {
super();
this.name = name;
}
public override function update(elapsed:Float) {
super.update(elapsed);
}
-34
View File
@@ -1,34 +0,0 @@
package funkin.scripting;
class ScriptedState extends MusicBeatState {
var script:Script;
public override function new(scriptName:String) {
super();
script = Script.create(Paths.script('data/states/${scriptName}'));
script.setParent(this);
script.load();
}
public override function create() {
super.create();
script.call("create");
}
public override function update(elapsed:Float) {
script.call("preUpdate", [elapsed]);
super.update(elapsed);
script.call("update", [elapsed]);
}
public override function beatHit(curBeat:Int) {
super.beatHit(curBeat);
script.call("beatHit", [curBeat]);
}
public override function stepHit(curStep:Int) {
super.stepHit(curStep);
script.call("stepHit", [curStep]);
}
}
+1 -1
View File
@@ -77,7 +77,7 @@ class MusicBeatState extends FlxUIState implements IBeatReceiver
public function new(scriptsAllowed:Bool = true, ?scriptName:String) {
super();
this.scriptsAllowed = scriptsAllowed;
this.scriptsAllowed = #if SOFTCODED_STATES scriptsAllowed #else false #end;
this.scriptName = scriptName;
loadScript();
}