the magic code (experimental)

This commit is contained in:
Yoshman29
2023-03-26 22:39:53 +02:00
parent ae01d8ae83
commit 6ecfb6d7d4
4 changed files with 908 additions and 6 deletions
+1
View File
@@ -515,6 +515,7 @@ class PlayState extends MusicBeatState
// CHARACTER INITIALISATION
#if REGION
comboGroup = new FlxSpriteGroup(FlxG.width * 0.55, (FlxG.height * 0.5) - 60);
comboGroup.maxSize = 20;
#end
// SCRIPTS & STAGE INITIALISATION
+11 -6
View File
@@ -1,5 +1,6 @@
package funkin.game;
import funkin.system.MusicBeatGroup;
import flixel.FlxState;
import haxe.xml.Access;
import funkin.interfaces.IBeatReceiver;
@@ -156,15 +157,19 @@ class Stage extends FlxBasic implements IBeatReceiver {
PlayState.instance.scripts.add(stageScript);
}
public function getCharGroup(name:String) {
if (characterPoses[name] == null) return null;
return characterPoses[name].group;
}
public function addCharPos(name:String, node:Access, ?nonXMLInfo:StageCharPosInfo) {
var dummyBasic:FlxBasic = new FlxBasic();
dummyBasic.active = false;
state.add(dummyBasic);
var group:MusicBeatGroup = new MusicBeatGroup();
state.add(group);
characterPoses[name] = {
node: node,
nonXMLInfo: nonXMLInfo,
dummy: dummyBasic
group: group
};
}
@@ -189,7 +194,7 @@ class Stage extends FlxBasic implements IBeatReceiver {
char.setPosition(charPos.nonXMLInfo.x, charPos.nonXMLInfo.y);
if (charPos.node != null)
doCharNodeShit(char, charPos.node);
state.insert(state.members.indexOf(charPos.dummy), char);
charPos.group.add(char);
}
}
private static function doCharNodeShit(char:Character, node:Access) {
@@ -224,7 +229,7 @@ class Stage extends FlxBasic implements IBeatReceiver {
typedef StageCharPos = {
var node:Access;
var dummy:FlxBasic;
var group:MusicBeatGroup;
var ?nonXMLInfo:StageCharPosInfo;
}
@@ -0,0 +1,56 @@
package funkin.system;
import lime.graphics.Image;
import openfl.geom.Rectangle;
import openfl.display.BitmapData;
import lime.graphics.cairo.CairoImageSurface;
class OptimizedBitmapData extends BitmapData {
@SuppressWarnings("checkstyle:Dynamic")
@:noCompletion private override function __fromImage(image:#if lime Image #else Dynamic #end):Void
{
#if lime
if (image != null && image.buffer != null)
{
this.image = image;
width = image.width;
height = image.height;
rect = new Rectangle(0, 0, image.width, image.height);
__textureWidth = width;
__textureHeight = height;
#if sys
image.format = BGRA32;
image.premultiplied = true;
#end
__isValid = true;
readable = true;
lock();
getTexture(FlxG.stage.context3D);
getSurface();
readable = true;
this.image = null;
}
#end
}
@SuppressWarnings("checkstyle:Dynamic")
@:dox(hide) public override function getSurface():#if lime CairoImageSurface #else Dynamic #end
{
#if lime
if (__surface == null)
{
__surface = CairoImageSurface.fromImage(image);
}
return __surface;
#else
return null;
#end
}
}