1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-12-02 09:07:28 +00:00

BASE PROTOTYPE WORKING W/ HaxeUI

This commit is contained in:
Cameron Taylor 2022-08-24 05:44:22 -04:00
parent 3be4530fa5
commit 8f4855852e
6 changed files with 244 additions and 134 deletions

View file

@ -122,6 +122,8 @@
<!--In case you want to use the addons package--> <!--In case you want to use the addons package-->
<haxelib name="flixel-addons" /> <haxelib name="flixel-addons" />
<haxelib name="hscript" /> <haxelib name="hscript" />
<haxelib name="haxeui-core"/>
<haxelib name="haxeui-flixel"/>
<!--In case you want to use the ui package--> <!--In case you want to use the ui package-->
<haxelib name="flixel-ui" /> <haxelib name="flixel-ui" />
@ -196,6 +198,9 @@
<!-- HScript relies heavily on Reflection, which means we can't use DCE. --> <!-- HScript relies heavily on Reflection, which means we can't use DCE. -->
<haxeflag name="-dce no" /> <haxeflag name="-dce no" />
<haxeflag name="--macro" value="include('funkin')" /> <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. --> <!-- Necessary to provide stack traces for HScript. -->
<haxedef name="hscriptPos" /> <haxedef name="hscriptPos" />
@ -246,7 +251,7 @@
<!-- <prebuild haxe="trace('prebuilding');"/> --> <!-- <prebuild haxe="trace('prebuilding');"/> -->
<!-- <postbuild haxe="art/Postbuild.hx"/> --> <!-- <postbuild haxe="art/Postbuild.hx"/> -->
<config:ios allow-provisioning-updates="true" team-id="" /> <!-- <config:ios allow-provisioning-updates="true" team-id="" /> -->
<!-- Options for Polymod --> <!-- Options for Polymod -->
<section if="polymod"> <section if="polymod">

151
hmm.json
View file

@ -1,74 +1,81 @@
{ {
"dependencies": [ "dependencies": [{
{ "name": "discord_rpc",
"name": "discord_rpc", "type": "git",
"type": "git", "dir": null,
"dir": null, "ref": "2d83fa8",
"ref": "2d83fa8", "url": "https://github.com/Aidan63/linc_discord-rpc"
"url": "https://github.com/Aidan63/linc_discord-rpc" },
}, {
{ "name": "firetongue",
"name": "firetongue", "type": "git",
"type": "git", "dir": null,
"dir": null, "ref": "c5666c8",
"ref": "c5666c8", "url": "https://github.com/larsiusprime/firetongue"
"url": "https://github.com/larsiusprime/firetongue" },
}, {
{ "name": "flixel",
"name": "flixel", "type": "git",
"type": "git", "dir": null,
"dir": null, "ref": "93a049d6",
"ref": "93a049d6", "url": "https://github.com/haxeflixel/flixel"
"url": "https://github.com/haxeflixel/flixel" },
}, {
{ "name": "flixel-addons",
"name": "flixel-addons", "type": "haxelib",
"type": "haxelib", "version": "2.11.0"
"version": "2.11.0" },
}, {
{ "name": "flixel-ui",
"name": "flixel-ui", "type": "haxelib",
"type": "haxelib", "version": "2.4.0"
"version": "2.4.0" },
}, {
{ "name": "haxeui-core",
"name": "hscript", "type": "haxelib",
"type": "git", "version": null
"dir": null, },
"ref": "a1b7f74", {
"url": "https://github.com/mastereric/hscript" "name": "haxeui-flixel",
}, "type": "haxelib",
{ "version": null
"name": "hxcpp", },
"type": "haxelib", {
"version": "4.2.1" "name": "hscript",
}, "type": "haxelib",
{ "version": "2.5.0"
"name": "hxcpp-debug-server", },
"type": "haxelib", {
"version": "1.2.4" "name": "hxcpp",
}, "type": "haxelib",
{ "version": "4.2.1"
"name": "lime", },
"type": "haxelib", {
"version": "7.9.0" "name": "hxcpp-debug-server",
}, "type": "haxelib",
{ "version": "1.2.4"
"name": "openfl", },
"type": "haxelib", {
"version": "9.1.0" "name": "lime",
}, "type": "haxelib",
{ "version": "7.9.0"
"name": "polymod", },
"type": "git", {
"dir": null, "name": "openfl",
"ref": "c858b48", "type": "haxelib",
"url": "https://github.com/larsiusprime/polymod" "version": "9.1.0"
}, },
{ {
"name": "thx.semver", "name": "polymod",
"type": "haxelib", "type": "git",
"version": "0.2.2" "dir": null,
} "ref": "c858b48",
] "url": "https://github.com/larsiusprime/polymod"
},
{
"name": "thx.semver",
"type": "haxelib",
"version": "0.2.2"
}
]
} }

View file

@ -87,6 +87,7 @@ class Main extends Sprite
initialState = TitleState; initialState = TitleState;
#end #end
haxe.ui.Toolkit.init();
addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen)); addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen));
#if debug #if debug

View file

@ -963,6 +963,8 @@ class PlayState extends MusicBeatState implements IHook
if (FlxG.keys.justPressed.U) if (FlxG.keys.justPressed.U)
{ {
// hack for HaxeUI generation, doesn't work unless persistentUpdate is false at state creation!!
persistentUpdate = false;
openSubState(new StageOffsetSubstate()); openSubState(new StageOffsetSubstate());
} }

View file

@ -1,103 +1,184 @@
package funkin.ui.stageBuildShit; package funkin.ui.stageBuildShit;
import flixel.FlxSprite;
import flixel.input.mouse.FlxMouseEventManager;
import flixel.math.FlxPoint; import flixel.math.FlxPoint;
import flixel.ui.FlxButton; import flixel.ui.FlxButton;
import funkin.play.PlayState; import funkin.play.PlayState;
import funkin.play.character.BaseCharacter; import funkin.play.character.BaseCharacter;
import funkin.play.stage.StageData; import funkin.play.stage.StageData;
import haxe.Json; 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.Assets;
import openfl.events.Event;
import openfl.events.IOErrorEvent;
import openfl.net.FileReference;
class StageOffsetSubstate extends MusicBeatSubstate class StageOffsetSubstate extends MusicBeatSubstate
{ {
public function new() override function create()
{ {
super(); super.create();
FlxG.mouse.visible = true; FlxG.mouse.visible = true;
PlayState.instance.pauseMusic(); PlayState.instance.pauseMusic();
FlxG.camera.target = null; 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; mosPosOld.x = FlxG.mouse.x;
stageLol.characters.bf.position[0] = Std.int(bfPos.x); mosPosOld.y = FlxG.mouse.y;
stageLol.characters.bf.position[1] = Std.int(bfPos.y); }, null, spr ->
{
var dadPos = PlayState.instance.currentStage.getDad().feetPosition; // 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!
stageLol.characters.dad.position[0] = Std.int(dadPos.x); spr.ID = 1;
stageLol.characters.dad.position[1] = Std.int(dadPos.y); spr.alpha = 0.5;
}, spr ->
var GF_FEET_SNIIIIIIIIIIIIIFFFF = PlayState.instance.currentStage.getGirlfriend().feetPosition; {
stageLol.characters.gf.position[0] = Std.int(GF_FEET_SNIIIIIIIIIIIIIFFFF.x); spr.ID = 0;
stageLol.characters.gf.position[1] = Std.int(GF_FEET_SNIIIIIIIIIIIIIFFFF.y); spr.alpha = 1;
});
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];
} }
var mosPosOld:FlxPoint = new FlxPoint(); var mosPosOld:FlxPoint = new FlxPoint();
var sprOld: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) override function update(elapsed:Float)
{ {
super.update(elapsed); 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(); CoolUtil.mouseCamDrag();
if (FlxG.keys.pressed.CONTROL) if (FlxG.keys.pressed.CONTROL)
CoolUtil.mouseWheelZoom(); 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) if (FlxG.keys.justPressed.Y)
{ {
for (thing in PlayState.instance.currentStage)
{
FlxMouseEventManager.remove(thing);
thing.alpha = 1;
}
PlayState.instance.resetCamera(); PlayState.instance.resetCamera();
FlxG.mouse.visible = false; FlxG.mouse.visible = false;
close(); 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
View 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>