Skip to content

Commit 528b247

Browse files
committed
fix "Issues I found while i was playtesting" (#11)
this also includes moving rearrange to the z property macro
1 parent ef0f139 commit 528b247

7 files changed

Lines changed: 40 additions & 44 deletions

File tree

Project.hxp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ class Project extends HXProject
176176
addHaxeFlag('-dce no');
177177
addHaxeFlag("--macro include('funkin')");
178178
addHaxeFlag("--macro include('flixel', true, ['flixel.addons.editors.spine.*', 'flixel.addons.nape.*', 'flixel.system.macros.*', 'flixel.addons.tile.FlxRayCastTilemap'])");
179-
addHaxeFlag("--macro addMetadata('@:build(funkin.macros.ZProperty.build())', 'flixel.FlxBasic')");
179+
addHaxeFlag("--macro addMetadata('@:build(funkin.macros.ZProperty.buildZProperty())', 'flixel.FlxBasic')");
180+
addHaxeFlag("--macro addMetadata('@:build(funkin.macros.ZProperty.buildRearrangeFunction())', 'flixel.group.FlxTypedGroup')");
180181
addHaxeFlag('--no-output', FUNKIN_DOX_GENERATION.isEnabled(this));
181182
addHaxeFlag('-xml docs/dox/' + Std.string(target).toLowerCase() + '.xml', FUNKIN_DOX_GENERATION.isEnabled(this));
182183
}

src/funkin/macros/ZProperty.hx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ZProperty
1212
* Builds the field for the `z` property.
1313
* @return New z field.
1414
*/
15-
public static macro function build():Array<Field>
15+
public static macro function buildZProperty():Array<Field>
1616
{
1717
var fields:Array<Field> = Context.getBuildFields();
1818

@@ -26,6 +26,38 @@ class ZProperty
2626

2727
return fields;
2828
}
29+
30+
/**
31+
* Builds the field for the `rearrange` function.
32+
* @return New z field.
33+
*/
34+
public static macro function buildRearrangeFunction():Array<Field>
35+
{
36+
var fields:Array<Field> = Context.getBuildFields();
37+
38+
var todo:haxe.macro.Function = {
39+
args: []
40+
};
41+
todo.expr = macro
42+
{
43+
this.sort((i:Int, basic1:flixel.FlxBasic, basic2:flixel.FlxBasic) ->
44+
{
45+
return flixel.util.FlxSort.byValues(i, basic1.z, basic2.z);
46+
}, flixel.util.FlxSort.ASCENDING);
47+
};
48+
todo.ret = macro :Void;
49+
50+
fields.push({
51+
name: "rearrange",
52+
pos: Context.currentPos(),
53+
kind: FFun(todo),
54+
access: [Access.APublic],
55+
doc: 'Rearranges all FlxBasic objects by their Z value.',
56+
meta: [],
57+
});
58+
59+
return fields;
60+
}
2961
}
3062
#end
3163
#end

src/funkin/states/FunkinState.hx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,4 @@ class FunkinState extends FlxState
8080
* This function is called after the conductor section changes.
8181
*/
8282
public function sectionHit():Void {}
83-
84-
/**
85-
* Rearranges all FlxBasic objects by their Z value.
86-
*/
87-
public function rearrange():Void
88-
{
89-
sort((i:Int, basic1:FlxBasic, basic2:FlxBasic) ->
90-
{
91-
return FlxSort.byValues(i, basic1.z, basic2.z);
92-
}, FlxSort.ASCENDING);
93-
}
9483
}

src/funkin/states/ui/FreeplayState.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ class FreeplayState extends FunkinState
247247
{
248248
backingCard.confirm();
249249
dj.confirm();
250+
blockInputs = true;
250251

251252
new FlxTimer().start(2, (_) ->
252253
{

src/funkin/states/ui/OptionsState.hx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@ class OptionsState extends FunkinState
248248

249249
var lerpXPosArrow:Float = 0;
250250

251-
var justExitedTimeout:Int = -1;
252-
253251
override public function update(elapsed:Float):Void
254252
{
255253
switch (currentStatus)
@@ -283,7 +281,7 @@ class OptionsState extends FunkinState
283281
}
284282
#end
285283

286-
if (controls.justPressed.BACK && justExitedTimeout == -1)
284+
if (controls.justPressed.BACK)
287285
{
288286
#if FLX_MOUSE
289287
FlxG.mouse.visible = false;
@@ -305,7 +303,6 @@ class OptionsState extends FunkinState
305303
if (controls.justPressed.BACK)
306304
{
307305
FlxG.sound.play(Paths.content.audio('ui/menu/cancelMenu'));
308-
justExitedTimeout = 2;
309306

310307
playCategoryTweens(false);
311308
currentStatus = CATEGORY;
@@ -314,15 +311,6 @@ class OptionsState extends FunkinState
314311
}
315312

316313
super.update(elapsed);
317-
318-
// fixes stupid bug that exists for some odd reason (ill fix it as soon as im integrating flxcontrols)
319-
if (justExitedTimeout > 0)
320-
{
321-
justExitedTimeout -= 1;
322-
323-
if (justExitedTimeout == 0)
324-
justExitedTimeout = -1;
325-
}
326314
}
327315

328316
function changeCategory(?indexHop:Int = 0):Void
@@ -371,6 +359,8 @@ class OptionsState extends FunkinState
371359

372360
FlxTween.cancelTweensOf(categoryCamera);
373361
FlxTween.tween(categoryCamera, {y: cameraY, zoom: cameraZoom}, 0.4, {ease: FlxEase.expoInOut});
362+
363+
categoryArrow.x = lerpXPosArrow; // just in case
374364
}
375365

376366
function generateCategoryOptions():Void

src/funkin/states/ui/StoryState.hx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class StoryState extends FunkinState
4141
#end
4242

4343
grpWeekItems = new FlxTypedGroup<WeekItem>();
44-
grpWeekItems.z = 10;
4544
add(grpWeekItems);
4645

4746
txtTracklist = new FlxText(FlxG.width * 0.05, 500, 0, "", 32);
@@ -50,26 +49,21 @@ class StoryState extends FunkinState
5049
add(txtTracklist);
5150

5251
var topBlackBar:FunkinSprite = new FunkinSprite().loadTexture('#000000', FlxG.width, 56);
53-
topBlackBar.z = 20;
5452
add(topBlackBar);
5553

5654
scoreText = new FlxText(10, 10, 0, "SCORE: 0", 36);
5755
scoreText.setFormat("VCR OSD Mono", 32);
58-
scoreText.z = 30;
5956
add(scoreText);
6057

6158
weekMotto = new FlxText(FlxG.width, 10, 0, "", 32);
6259
weekMotto.setFormat("VCR OSD Mono", 32, FlxColor.WHITE, RIGHT);
6360
weekMotto.alpha = 0.7;
64-
weekMotto.z = 40;
6561
add(weekMotto);
6662

6763
colorBG = new FunkinSprite(0, 56).loadTexture('#FFFFFF', FlxG.width, 400);
68-
colorBG.z = 50;
6964
add(colorBG);
7065

7166
grpOfWeekSprGrps = new FlxTypedSpriteGroup<FunkinSpriteGroup>(0, 56);
72-
grpOfWeekSprGrps.z = 100;
7367
add(grpOfWeekSprGrps);
7468

7569
for (i => week in loadedWeeks)
@@ -82,6 +76,7 @@ class StoryState extends FunkinState
8276
weekSpr.screenCenter(X);
8377

8478
var weekSprGrp:FunkinSpriteGroup = week.buildSprites();
79+
weekSprGrp.group.rearrange();
8580
grpOfWeekSprGrps.add(weekSprGrp);
8681

8782
// TODO: ADD LOCK SPRITE
@@ -111,7 +106,6 @@ class StoryState extends FunkinState
111106

112107
super.create();
113108

114-
rearrange();
115109
changeItem();
116110
}
117111

src/funkin/substates/FunkinSubState.hx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,4 @@ class FunkinSubState extends FlxSubState
6464
* This function is called after the conductor section changes.
6565
*/
6666
public function sectionHit():Void {}
67-
68-
/**
69-
* Rearranges all FlxBasic objects by their Z value.
70-
*/
71-
public function rearrange():Void
72-
{
73-
sort((i:Int, basic1:FlxBasic, basic2:FlxBasic) ->
74-
{
75-
return FlxSort.byValues(i, basic1.z, basic2.z);
76-
}, FlxSort.ASCENDING);
77-
}
7867
}

0 commit comments

Comments
 (0)