mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-10 08:44:47 +00:00
49 lines
799 B
Haxe
49 lines
799 B
Haxe
|
package funkin.ui.haxeui;
|
||
|
|
||
|
import haxe.ui.RuntimeComponentBuilder;
|
||
|
import haxe.ui.core.Component;
|
||
|
|
||
|
class HaxeUIState extends MusicBeatState
|
||
|
{
|
||
|
public var component:Component;
|
||
|
|
||
|
var _componentKey:String;
|
||
|
|
||
|
public function new(key:String)
|
||
|
{
|
||
|
super();
|
||
|
_componentKey = key;
|
||
|
}
|
||
|
|
||
|
override function create()
|
||
|
{
|
||
|
super.create();
|
||
|
|
||
|
if (component == null)
|
||
|
component = buildComponent(_componentKey);
|
||
|
if (component != null)
|
||
|
add(component);
|
||
|
}
|
||
|
|
||
|
public function buildComponent(assetPath:String)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return RuntimeComponentBuilder.fromAsset(assetPath);
|
||
|
}
|
||
|
catch (e)
|
||
|
{
|
||
|
trace('[ERROR] Failed to build component from asset: ' + assetPath);
|
||
|
trace(e);
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
override function destroy()
|
||
|
{
|
||
|
if (component != null)
|
||
|
remove(component);
|
||
|
component = null;
|
||
|
}
|
||
|
}
|