mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2025-04-12 06:54:41 -04:00
BASE PROTOTYPE WORKING W/ HaxeUI
This commit is contained in:
parent
3be4530fa5
commit
8f4855852e
6 changed files with 244 additions and 134 deletions
|
@ -122,6 +122,8 @@
|
|||
<!--In case you want to use the addons package-->
|
||||
<haxelib name="flixel-addons" />
|
||||
<haxelib name="hscript" />
|
||||
<haxelib name="haxeui-core"/>
|
||||
<haxelib name="haxeui-flixel"/>
|
||||
|
||||
<!--In case you want to use the ui package-->
|
||||
<haxelib name="flixel-ui" />
|
||||
|
@ -196,6 +198,9 @@
|
|||
<!-- HScript relies heavily on Reflection, which means we can't use DCE. -->
|
||||
<haxeflag name="-dce no" />
|
||||
<haxeflag name="--macro" value="include('funkin')" />
|
||||
<!-- Ensure all UI components are available at runtime. -->
|
||||
<haxeflag name="--macro" value="include('haxe.ui.components')" />
|
||||
<haxeflag name="--macro" value="include('haxe.ui.containers')" />
|
||||
|
||||
<!-- Necessary to provide stack traces for HScript. -->
|
||||
<haxedef name="hscriptPos" />
|
||||
|
@ -246,7 +251,7 @@
|
|||
<!-- <prebuild haxe="trace('prebuilding');"/> -->
|
||||
<!-- <postbuild haxe="art/Postbuild.hx"/> -->
|
||||
|
||||
<config:ios allow-provisioning-updates="true" team-id="" />
|
||||
<!-- <config:ios allow-provisioning-updates="true" team-id="" /> -->
|
||||
|
||||
<!-- Options for Polymod -->
|
||||
<section if="polymod">
|
||||
|
|
151
hmm.json
151
hmm.json
|
@ -1,74 +1,81 @@
|
|||
{
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "discord_rpc",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "2d83fa8",
|
||||
"url": "https://github.com/Aidan63/linc_discord-rpc"
|
||||
},
|
||||
{
|
||||
"name": "firetongue",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "c5666c8",
|
||||
"url": "https://github.com/larsiusprime/firetongue"
|
||||
},
|
||||
{
|
||||
"name": "flixel",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "93a049d6",
|
||||
"url": "https://github.com/haxeflixel/flixel"
|
||||
},
|
||||
{
|
||||
"name": "flixel-addons",
|
||||
"type": "haxelib",
|
||||
"version": "2.11.0"
|
||||
},
|
||||
{
|
||||
"name": "flixel-ui",
|
||||
"type": "haxelib",
|
||||
"version": "2.4.0"
|
||||
},
|
||||
{
|
||||
"name": "hscript",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "a1b7f74",
|
||||
"url": "https://github.com/mastereric/hscript"
|
||||
},
|
||||
{
|
||||
"name": "hxcpp",
|
||||
"type": "haxelib",
|
||||
"version": "4.2.1"
|
||||
},
|
||||
{
|
||||
"name": "hxcpp-debug-server",
|
||||
"type": "haxelib",
|
||||
"version": "1.2.4"
|
||||
},
|
||||
{
|
||||
"name": "lime",
|
||||
"type": "haxelib",
|
||||
"version": "7.9.0"
|
||||
},
|
||||
{
|
||||
"name": "openfl",
|
||||
"type": "haxelib",
|
||||
"version": "9.1.0"
|
||||
},
|
||||
{
|
||||
"name": "polymod",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "c858b48",
|
||||
"url": "https://github.com/larsiusprime/polymod"
|
||||
},
|
||||
{
|
||||
"name": "thx.semver",
|
||||
"type": "haxelib",
|
||||
"version": "0.2.2"
|
||||
}
|
||||
]
|
||||
"dependencies": [{
|
||||
"name": "discord_rpc",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "2d83fa8",
|
||||
"url": "https://github.com/Aidan63/linc_discord-rpc"
|
||||
},
|
||||
{
|
||||
"name": "firetongue",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "c5666c8",
|
||||
"url": "https://github.com/larsiusprime/firetongue"
|
||||
},
|
||||
{
|
||||
"name": "flixel",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "93a049d6",
|
||||
"url": "https://github.com/haxeflixel/flixel"
|
||||
},
|
||||
{
|
||||
"name": "flixel-addons",
|
||||
"type": "haxelib",
|
||||
"version": "2.11.0"
|
||||
},
|
||||
{
|
||||
"name": "flixel-ui",
|
||||
"type": "haxelib",
|
||||
"version": "2.4.0"
|
||||
},
|
||||
{
|
||||
"name": "haxeui-core",
|
||||
"type": "haxelib",
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"name": "haxeui-flixel",
|
||||
"type": "haxelib",
|
||||
"version": null
|
||||
},
|
||||
{
|
||||
"name": "hscript",
|
||||
"type": "haxelib",
|
||||
"version": "2.5.0"
|
||||
},
|
||||
{
|
||||
"name": "hxcpp",
|
||||
"type": "haxelib",
|
||||
"version": "4.2.1"
|
||||
},
|
||||
{
|
||||
"name": "hxcpp-debug-server",
|
||||
"type": "haxelib",
|
||||
"version": "1.2.4"
|
||||
},
|
||||
{
|
||||
"name": "lime",
|
||||
"type": "haxelib",
|
||||
"version": "7.9.0"
|
||||
},
|
||||
{
|
||||
"name": "openfl",
|
||||
"type": "haxelib",
|
||||
"version": "9.1.0"
|
||||
},
|
||||
{
|
||||
"name": "polymod",
|
||||
"type": "git",
|
||||
"dir": null,
|
||||
"ref": "c858b48",
|
||||
"url": "https://github.com/larsiusprime/polymod"
|
||||
},
|
||||
{
|
||||
"name": "thx.semver",
|
||||
"type": "haxelib",
|
||||
"version": "0.2.2"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -87,6 +87,7 @@ class Main extends Sprite
|
|||
initialState = TitleState;
|
||||
#end
|
||||
|
||||
haxe.ui.Toolkit.init();
|
||||
addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen));
|
||||
|
||||
#if debug
|
||||
|
|
|
@ -963,6 +963,8 @@ class PlayState extends MusicBeatState implements IHook
|
|||
|
||||
if (FlxG.keys.justPressed.U)
|
||||
{
|
||||
// hack for HaxeUI generation, doesn't work unless persistentUpdate is false at state creation!!
|
||||
persistentUpdate = false;
|
||||
openSubState(new StageOffsetSubstate());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,103 +1,184 @@
|
|||
package funkin.ui.stageBuildShit;
|
||||
|
||||
import flixel.FlxSprite;
|
||||
import flixel.input.mouse.FlxMouseEventManager;
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.ui.FlxButton;
|
||||
import funkin.play.PlayState;
|
||||
import funkin.play.character.BaseCharacter;
|
||||
import funkin.play.stage.StageData;
|
||||
import haxe.Json;
|
||||
import haxe.ui.ComponentBuilder;
|
||||
import haxe.ui.RuntimeComponentBuilder;
|
||||
import haxe.ui.Toolkit;
|
||||
import haxe.ui.components.Button;
|
||||
import haxe.ui.containers.HBox;
|
||||
import haxe.ui.containers.VBox;
|
||||
import haxe.ui.core.Component;
|
||||
import openfl.Assets;
|
||||
import openfl.events.Event;
|
||||
import openfl.events.IOErrorEvent;
|
||||
import openfl.net.FileReference;
|
||||
|
||||
class StageOffsetSubstate extends MusicBeatSubstate
|
||||
{
|
||||
public function new()
|
||||
override function create()
|
||||
{
|
||||
super();
|
||||
super.create();
|
||||
|
||||
FlxG.mouse.visible = true;
|
||||
PlayState.instance.pauseMusic();
|
||||
FlxG.camera.target = null;
|
||||
|
||||
var btn:FlxButton = new FlxButton(200, 10, "SAVE COMPILE", function()
|
||||
var str = Paths.xml('ui/stage-editor-view');
|
||||
var uiStuff:Component = RuntimeComponentBuilder.fromAsset(str);
|
||||
|
||||
uiStuff.findComponent("lol").onClick = saveCharacterCompile;
|
||||
uiStuff.findComponent('saveAs').onClick = saveStageFileRef;
|
||||
|
||||
add(uiStuff);
|
||||
|
||||
PlayState.instance.persistentUpdate = true;
|
||||
uiStuff.cameras = [PlayState.instance.camHUD];
|
||||
// btn.cameras = [PlayState.instance.camHUD];
|
||||
|
||||
for (thing in PlayState.instance.currentStage)
|
||||
{
|
||||
var stageLol:StageData = StageDataParser.parseStageData(PlayState.instance.currentStageId);
|
||||
FlxMouseEventManager.add(thing, spr ->
|
||||
{
|
||||
char = cast thing;
|
||||
trace("JUST PRESSED!");
|
||||
sprOld.x = thing.x;
|
||||
sprOld.y = thing.y;
|
||||
|
||||
var bfPos = PlayState.instance.currentStage.getBoyfriend().feetPosition;
|
||||
stageLol.characters.bf.position[0] = Std.int(bfPos.x);
|
||||
stageLol.characters.bf.position[1] = Std.int(bfPos.y);
|
||||
|
||||
var dadPos = PlayState.instance.currentStage.getDad().feetPosition;
|
||||
|
||||
stageLol.characters.dad.position[0] = Std.int(dadPos.x);
|
||||
stageLol.characters.dad.position[1] = Std.int(dadPos.y);
|
||||
|
||||
var GF_FEET_SNIIIIIIIIIIIIIFFFF = PlayState.instance.currentStage.getGirlfriend().feetPosition;
|
||||
stageLol.characters.gf.position[0] = Std.int(GF_FEET_SNIIIIIIIIIIIIIFFFF.x);
|
||||
stageLol.characters.gf.position[1] = Std.int(GF_FEET_SNIIIIIIIIIIIIIFFFF.y);
|
||||
|
||||
var outputJson = CoolUtil.jsonStringify(stageLol);
|
||||
|
||||
#if sys
|
||||
// save "local" to the current export.
|
||||
sys.io.File.saveContent('./assets/data/stages/' + PlayState.instance.currentStageId + '.json', outputJson);
|
||||
|
||||
// save to the dev version
|
||||
sys.io.File.saveContent('../../../../assets/preload/data/stages/' + PlayState.instance.currentStageId + '.json', outputJson);
|
||||
#end
|
||||
// trace(dipshitJson);
|
||||
|
||||
// put character position data to a file of some sort
|
||||
});
|
||||
btn.scrollFactor.set();
|
||||
add(btn);
|
||||
btn.cameras = [PlayState.instance.camHUD];
|
||||
mosPosOld.x = FlxG.mouse.x;
|
||||
mosPosOld.y = FlxG.mouse.y;
|
||||
}, null, spr ->
|
||||
{
|
||||
// ID tag is to see if currently overlapping hold basically!, a bit more reliable than checking transparency!
|
||||
// used for bug where you can click, and if you click on NO sprite, it snaps the thing to position! unintended!
|
||||
spr.ID = 1;
|
||||
spr.alpha = 0.5;
|
||||
}, spr ->
|
||||
{
|
||||
spr.ID = 0;
|
||||
spr.alpha = 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var mosPosOld:FlxPoint = new FlxPoint();
|
||||
var sprOld:FlxPoint = new FlxPoint();
|
||||
|
||||
var char:BaseCharacter = null;
|
||||
var char:FlxSprite = null;
|
||||
var overlappingChar:Bool = false;
|
||||
|
||||
override function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
||||
if (char != null && char.ID == 1 && FlxG.mouse.pressed)
|
||||
{
|
||||
char.x = sprOld.x - (mosPosOld.x - FlxG.mouse.x);
|
||||
char.y = sprOld.y - (mosPosOld.y - FlxG.mouse.y);
|
||||
}
|
||||
|
||||
CoolUtil.mouseCamDrag();
|
||||
|
||||
if (FlxG.keys.pressed.CONTROL)
|
||||
CoolUtil.mouseWheelZoom();
|
||||
|
||||
if (FlxG.mouse.pressed)
|
||||
{
|
||||
if (FlxG.mouse.justPressed)
|
||||
{
|
||||
for (thing in PlayState.instance.currentStage)
|
||||
{
|
||||
if (FlxG.mouse.overlaps(thing) && Std.isOfType(thing, BaseCharacter))
|
||||
char = cast thing;
|
||||
}
|
||||
|
||||
if (char != null)
|
||||
{
|
||||
sprOld.x = char.x;
|
||||
sprOld.y = char.y;
|
||||
}
|
||||
|
||||
mosPosOld.x = FlxG.mouse.x;
|
||||
mosPosOld.y = FlxG.mouse.y;
|
||||
}
|
||||
|
||||
if (char != null)
|
||||
{
|
||||
char.x = sprOld.x - (mosPosOld.x - FlxG.mouse.x);
|
||||
char.y = sprOld.y - (mosPosOld.y - FlxG.mouse.y);
|
||||
}
|
||||
}
|
||||
|
||||
if (FlxG.keys.justPressed.Y)
|
||||
{
|
||||
for (thing in PlayState.instance.currentStage)
|
||||
{
|
||||
FlxMouseEventManager.remove(thing);
|
||||
thing.alpha = 1;
|
||||
}
|
||||
|
||||
PlayState.instance.resetCamera();
|
||||
FlxG.mouse.visible = false;
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
var _file:FileReference;
|
||||
|
||||
private function saveStageFileRef(_):Void
|
||||
{
|
||||
var jsonStr = prepStageStuff();
|
||||
|
||||
_file = new FileReference();
|
||||
_file.addEventListener(Event.COMPLETE, onSaveComplete);
|
||||
_file.addEventListener(Event.CANCEL, onSaveCancel);
|
||||
_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);
|
||||
_file.save(jsonStr, PlayState.instance.currentStageId + ".json");
|
||||
}
|
||||
|
||||
function onSaveComplete(_)
|
||||
{
|
||||
fileRemoveListens();
|
||||
FlxG.log.notice("Successfully saved!");
|
||||
}
|
||||
|
||||
function onSaveCancel(_)
|
||||
{
|
||||
fileRemoveListens();
|
||||
}
|
||||
|
||||
function onSaveError(_)
|
||||
{
|
||||
fileRemoveListens();
|
||||
FlxG.log.error("Problem saving Stage file!");
|
||||
}
|
||||
|
||||
function fileRemoveListens()
|
||||
{
|
||||
_file.removeEventListener(Event.COMPLETE, onSaveComplete);
|
||||
_file.removeEventListener(Event.CANCEL, onSaveCancel);
|
||||
_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);
|
||||
_file = null;
|
||||
}
|
||||
|
||||
private function saveCharacterCompile(_):Void
|
||||
{
|
||||
var outputJson:String = prepStageStuff();
|
||||
|
||||
#if sys
|
||||
// save "local" to the current export.
|
||||
sys.io.File.saveContent('./assets/data/stages/' + PlayState.instance.currentStageId + '.json', outputJson);
|
||||
|
||||
// save to the dev version
|
||||
sys.io.File.saveContent('../../../../assets/preload/data/stages/' + PlayState.instance.currentStageId + '.json', outputJson);
|
||||
#end
|
||||
}
|
||||
|
||||
private function prepStageStuff():String
|
||||
{
|
||||
var stageLol:StageData = StageDataParser.parseStageData(PlayState.instance.currentStageId);
|
||||
|
||||
for (prop in stageLol.props)
|
||||
{
|
||||
@:privateAccess
|
||||
var posStuff = PlayState.instance.currentStage.namedProps.get(prop.name);
|
||||
|
||||
prop.position[0] = posStuff.x;
|
||||
prop.position[1] = posStuff.y;
|
||||
}
|
||||
|
||||
var bfPos = PlayState.instance.currentStage.getBoyfriend().feetPosition;
|
||||
stageLol.characters.bf.position[0] = Std.int(bfPos.x);
|
||||
stageLol.characters.bf.position[1] = Std.int(bfPos.y);
|
||||
|
||||
var dadPos = PlayState.instance.currentStage.getDad().feetPosition;
|
||||
|
||||
stageLol.characters.dad.position[0] = Std.int(dadPos.x);
|
||||
stageLol.characters.dad.position[1] = Std.int(dadPos.y);
|
||||
|
||||
var GF_FEET_SNIIIIIIIIIIIIIFFFF = PlayState.instance.currentStage.getGirlfriend().feetPosition;
|
||||
stageLol.characters.gf.position[0] = Std.int(GF_FEET_SNIIIIIIIIIIIIIFFFF.x);
|
||||
stageLol.characters.gf.position[1] = Std.int(GF_FEET_SNIIIIIIIIIIIIIFFFF.y);
|
||||
|
||||
return CoolUtil.jsonStringify(stageLol);
|
||||
}
|
||||
}
|
||||
|
|
14
source/module.xml
Normal file
14
source/module.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<module>
|
||||
<!-- A module provides additional behavior and configuration for HaxeUI. -->
|
||||
<components>
|
||||
<!--
|
||||
Ensure all components get included at compilation time.
|
||||
This needs to be done HERE and not via the `include` macro because `Toolkit.init()`
|
||||
reads this to build the component registry.
|
||||
-->
|
||||
<class package="haxe.ui.components" loadAll="true" />
|
||||
<class package="haxe.ui.containers" loadAll="true" />
|
||||
<class package="haxe.ui.core" loadAll="true" />
|
||||
</components>
|
||||
</module>
|
Loading…
Add table
Reference in a new issue