Skip to content

Commit a6dd5f6

Browse files
committed
2 parents b2be619 + 0275798 commit a6dd5f6

27 files changed

Lines changed: 153 additions & 191 deletions

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838

3939
- name: Install Libraries
4040
run: |
41+
haxelib --global update haxelib
42+
haxelib fixrepo
4143
haxelib install hmm
4244
haxelib run hmm install
4345
@@ -118,6 +120,8 @@ jobs:
118120

119121
# - name: Install Libraries
120122
# run: |
123+
# haxelib --global update haxelib
124+
# haxelib fixrepo
121125
# haxelib install hmm
122126
# haxelib run hmm install
123127

@@ -201,6 +205,8 @@ jobs:
201205

202206
# - name: Install Libraries
203207
# run: |
208+
# haxelib --global update haxelib
209+
# haxelib fixrepo
204210
# haxelib install hmm
205211
# haxelib run hmm install
206212

Preloader.hx

Lines changed: 0 additions & 57 deletions
This file was deleted.

Project.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
<!--In case you want to use nape with flixel-->
7575
<!--<haxelib name="nape-haxe4" />-->
7676

77+
<haxeflag name="--macro" value="kitty.Macro.init()" />
78+
7779
<!-- ______________________________ Haxedefines _____________________________ -->
7880

7981
<!--Enable the Flixel core recording system-->

hmm.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@
4343
},
4444
{
4545
"name": "moonchart",
46-
"type": "haxelib",
47-
"version": null
46+
"type": "git",
47+
"dir": null,
48+
"ref": "main",
49+
"url": "https://github.com/MaybeMaru/moonchart"
4850
}
4951
]
5052
}

source/import.hx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if !macro
12
import flixel.FlxG;
23
import flixel.FlxSprite;
34
import flixel.tweens.FlxEase;
@@ -15,4 +16,5 @@ import kitty.backend.modding.*;
1516

1617
import kitty.states.menus.options.KadeEngineData;
1718

18-
using StringTools;
19+
using StringTools;
20+
#end

source/kitty/Macro.hx

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package kitty;
2+
3+
#if macro
4+
import haxe.macro.Compiler;
5+
import haxe.macro.Context;
6+
import haxe.macro.Expr;
7+
8+
using StringTools;
9+
using haxe.macro.ExprTools;
10+
11+
class Macro {
12+
public static function init():Void {
13+
var classPath:String = Std.string(Macro).replace('Class<', '').replace('>', '');
14+
Compiler.addMetadata('@:build($classPath.rebuildFlxText())', 'flixel.text.FlxText');
15+
Compiler.addMetadata('@:build($classPath.rebuildBitmapData())', 'openfl.display.BitmapData');
16+
Compiler.include('kitty', true, ['*Macro']);
17+
Compiler.include('haxe', true, ['haxe.atomic.*', 'haxe.macro.*']);
18+
Compiler.include('flixel', true, ['flixel.addons.editors.spine.*', 'flixel.addons.nape.*', 'flixel.system.macros.*', 'flixel.addons.tile.FlxRayCastTilemap', 'flixel.addons.weapon.*']);
19+
Compiler.include('moonchart', true, ['moonchart.backend.*']);
20+
}
21+
22+
// fix for pixel font related shenanigans
23+
public static macro function rebuildFlxText():Array<Field> {
24+
var classFields = Context.getBuildFields();
25+
var tempClass = macro class TempClass {
26+
/**
27+
* If true, the text will be rendered with pixel-perfect sharpness.
28+
*/
29+
public var pixelFont(default, set):Bool;
30+
function set_pixelFont(value:Bool):Bool {
31+
if (value) {
32+
textField.antiAliasType = ADVANCED;
33+
textField.sharpness = 400;
34+
} else {
35+
textField.antiAliasType = NORMAL;
36+
textField.sharpness = 100;
37+
}
38+
return pixelFont = value;
39+
}
40+
}
41+
42+
var newConstructor = classFields.filter(field -> return field.name == 'new')[0];
43+
switch (newConstructor.kind) {
44+
case FFun(f):
45+
var initExpr:Expr = f.expr;
46+
f.expr = macro {
47+
$initExpr;
48+
set_pixelFont(false);
49+
}
50+
newConstructor.kind = FFun(f);
51+
default:
52+
}
53+
classFields.remove(classFields.filter(field -> return field.name == 'set_antialiasing')[0]);
54+
55+
return classFields.concat(tempClass.fields);
56+
}
57+
58+
// fix for GPU rendering related shenanigans
59+
public static macro function rebuildBitmapData():Array<Field> {
60+
var classFields = Context.getBuildFields();
61+
var tempClass = macro class TempClass {
62+
/**
63+
* If true, the bitmap data will render to your GPU.
64+
* NOTE: ISN'T WORKING RIGHT FOR SOME REASON, ALSO DON'T SET IT TO TRUE HERE, IT CRASHES
65+
*/
66+
public var renderToGPU:Bool = false;
67+
}
68+
69+
var fromImageFunc = classFields.filter(field -> return field.name == '__fromImage')[0];
70+
switch (fromImageFunc.kind) {
71+
case FFun(f):
72+
var initExpr:Expr = f.expr;
73+
f.expr = macro {
74+
if (!renderToGPU) {
75+
$initExpr;
76+
return;
77+
}
78+
if (image != null && image.buffer != null) {
79+
this.image = image;
80+
81+
width = image.width;
82+
height = image.height;
83+
rect = new Rectangle(0, 0, image.width, image.height);
84+
85+
__textureWidth = width;
86+
__textureHeight = height;
87+
88+
#if sys
89+
image.format = BGRA32;
90+
image.premultiplied = true;
91+
#end
92+
93+
readable = true;
94+
__isValid = true;
95+
96+
// https://github.com/CodenameCrew/CodenameEngine/blob/main/source/funkin/backend/system/OptimizedBitmapData.hx#L9L46
97+
if (flixel.FlxG.stage.context3D != null) {
98+
lock();
99+
getTexture(flixel.FlxG.stage.context3D);
100+
getSurface();
101+
readable = true;
102+
this.image = null;
103+
}
104+
}
105+
}
106+
fromImageFunc.kind = FFun(f);
107+
default:
108+
}
109+
var getSurfaceFunc = classFields.filter(field -> return field.name == 'getSurface')[0];
110+
switch (getSurfaceFunc.kind) {
111+
case FFun(f):
112+
var initExpr:Expr = f.expr;
113+
f.expr = macro {
114+
// https://github.com/CodenameCrew/CodenameEngine/blob/main/source/funkin/backend/system/OptimizedBitmapData.hx#L48L61
115+
if (renderToGPU)
116+
return __surface ??= CairoImageSurface.fromImage(image);
117+
$initExpr;
118+
}
119+
getSurfaceFunc.kind = FFun(f);
120+
default:
121+
}
122+
123+
return classFields.concat(tempClass.fields);
124+
}
125+
}
126+
#end

source/kitty/backend/ChartParser.hx

Lines changed: 0 additions & 80 deletions
This file was deleted.

source/kitty/backend/Controls.hx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package kitty.backend;
22

33
import flixel.input.gamepad.FlxGamepad;
4-
import flixel.FlxG;
54
import flixel.input.FlxInput;
65
import flixel.input.actions.FlxAction;
76
import flixel.input.actions.FlxActionInput;

source/kitty/backend/CoolUtil.hx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package kitty.backend;
22

3-
import flixel.FlxG;
43
import flixel.math.FlxMath;
54
import lime.utils.Assets;
65

7-
using StringTools;
8-
96
class CoolUtil
107
{
118
public static function coolTextFile(path:String):Array<String>

source/kitty/backend/Highscore.hx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package kitty.backend;
22

3-
import flixel.FlxG;
4-
5-
using StringTools;
63
class Highscore
74
{
85
#if (haxe >= "4.0.0")

0 commit comments

Comments
 (0)