Skip to content

Commit dc61d68

Browse files
committed
Merge branch 'main' into internal-merge
# Conflicts: # source/funkin/backend/system/Flags.hx
2 parents bf3c45d + d113fc4 commit dc61d68

10 files changed

Lines changed: 1127 additions & 83 deletions

File tree

assets/data/scripts/pixel.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function onCountdown(event) {
7575
};
7676
}
7777

78-
function onPlayerHit(event:NoteHitEvent) {
78+
function onRatingsShown(event:RatingsShowEvent) {
7979
if (!enablePixelUI) return;
8080
event.ratingPrefix = "stages/school/ui/";
8181
event.ratingScale = daPixelZoom * 0.7;
Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,98 @@
11
package funkin.backend;
22

3+
import flixel.FlxCamera;
4+
import flixel.FlxG;
5+
import flixel.math.FlxMath;
36
import flixel.text.FlxText;
47
import flixel.util.FlxColor;
58
import funkin.backend.system.Flags;
69

7-
class FunkinText extends FlxText {
8-
public function new(X:Float = 0, Y:Float = 0, FieldWidth:Float = 0, ?Text:String, ?Size:Int, Border:Bool = true) {
9-
if (Size == null) Size = Flags.DEFAULT_FONT_SIZE;
10+
class FunkinText extends FlxText
11+
{
12+
public var zoomFactor:Float = 1;
13+
public var zoomFactorEnabled:Bool = true;
14+
15+
public function new(X:Float = 0, Y:Float = 0, FieldWidth:Float = 0, ?Text:String, ?Size:Int, Border:Bool = true)
16+
{
17+
if (Size == null)
18+
Size = Flags.DEFAULT_FONT_SIZE;
1019

1120
super(X, Y, FieldWidth, Text, Size);
21+
1222
setFormat(Paths.font(Flags.DEFAULT_FONT), Size, FlxColor.WHITE);
13-
if (Border) {
23+
24+
if (Border)
25+
{
1426
borderStyle = OUTLINE;
1527
borderSize = 1;
1628
borderColor = 0xFF000000;
1729
}
1830
}
31+
32+
private inline function __shouldDoZoomFactor():Bool
33+
{
34+
return zoomFactorEnabled && zoomFactor != 1;
35+
}
36+
37+
private inline function __getZoomScaleX(camera:FlxCamera):Float
38+
{
39+
return (camera.scaleX > 0 ? Math.max : Math.min)(0, FlxMath.lerp(1 / camera.scaleX, 1, zoomFactor));
40+
}
41+
42+
private inline function __getZoomScaleY(camera:FlxCamera):Float
43+
{
44+
return (camera.scaleY > 0 ? Math.max : Math.min)(0, FlxMath.lerp(1 / camera.scaleY, 1, zoomFactor));
45+
}
46+
47+
private inline function __getZoomAnchorX(camera:FlxCamera):Float
48+
{
49+
if (Flags.USE_LEGACY_ZOOM_FACTOR)
50+
return camera.width * 0.5;
51+
52+
return camera.width * 0.5 + camera.scroll.x * scrollFactor.x;
53+
}
54+
55+
private inline function __getZoomAnchorY(camera:FlxCamera):Float
56+
{
57+
if (Flags.USE_LEGACY_ZOOM_FACTOR)
58+
return camera.height * 0.5;
59+
60+
return camera.height * 0.5 + camera.scroll.y * scrollFactor.y;
61+
}
62+
63+
override public function draw():Void
64+
{
65+
if (!__shouldDoZoomFactor())
66+
{
67+
super.draw();
68+
return;
69+
}
70+
71+
var camera:FlxCamera = this.camera;
72+
73+
if (camera == null)
74+
camera = FlxG.camera;
75+
76+
var oldX:Float = x;
77+
var oldY:Float = y;
78+
var oldScaleX:Float = scale.x;
79+
var oldScaleY:Float = scale.y;
80+
81+
var zoomScaleX:Float = __getZoomScaleX(camera);
82+
var zoomScaleY:Float = __getZoomScaleY(camera);
83+
84+
var anchorX:Float = __getZoomAnchorX(camera);
85+
var anchorY:Float = __getZoomAnchorY(camera);
86+
87+
x = (x - anchorX) * zoomScaleX + anchorX;
88+
y = (y - anchorY) * zoomScaleY + anchorY;
89+
90+
scale.set(scale.x * zoomScaleX, scale.y * zoomScaleY);
91+
92+
super.draw();
93+
94+
x = oldX;
95+
y = oldY;
96+
scale.set(oldScaleX, oldScaleY);
97+
}
1998
}

source/funkin/backend/chart/EventsData.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class EventsData {
7575
defValue: "In"
7676
},
7777
{name: "Mode", type: TDropDown(['direct', 'stage']), defValue: "direct"},
78-
{name: "Multiplicative?", type: TBool, defValue: true}
78+
{name: "Multiplicative?", type: TBool, defValue: false}
7979
],
8080
"Camera Modulo Change" => [
8181
{name: "Modulo Interval", type: TInt(1, 9999999, 1), defValue: 4},
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package funkin.backend.scripting.events.gameplay;
2+
3+
import flixel.math.FlxPoint;
4+
import flixel.tweens.FlxTween;
5+
6+
final class RatingsShowEvent extends CancellableEvent
7+
{
8+
/**
9+
* Rating sprite (may be null)
10+
*/
11+
public var ratingSprite:Null<FlxSprite>;
12+
/**
13+
* Number sprite (may be null)
14+
*/
15+
public var numberSprite:Null<FlxSprite>;
16+
/**
17+
* Combo sprite (may be null)
18+
*/
19+
public var comboSprite:Null<FlxSprite>;
20+
/**
21+
* Scale of combo numbers. (may be null)
22+
*/
23+
public var numScale:Null<Float> = 0.5;
24+
/**
25+
* Whenever antialiasing should be enabled on combo numbers. (may be null)
26+
*/
27+
public var numAntialiasing:Null<Bool> = true;
28+
/**
29+
* Scale of the rating sprites. (may be null)
30+
*/
31+
public var ratingScale:Null<Float> = 0.7;
32+
/**
33+
* Whenever antialiasing should be enabled on ratings. (may be null)
34+
*/
35+
public var ratingAntialiasing:Null<Bool> = true;
36+
/**
37+
* Prefix of the rating sprite path. Defaults to "game/score/"
38+
*/
39+
public var ratingPrefix:String;
40+
/**
41+
* Suffix of the rating sprite path.
42+
*/
43+
public var ratingSuffix:String;
44+
/**
45+
* The sprite's acceleration.
46+
*/
47+
public var acceleration:Float;
48+
/**
49+
* A FlxPoint which x or y properties preposition the sprites current velocity.
50+
*/
51+
public var velocity:FlxPoint;
52+
/**
53+
* The duration of the sprite's alpha tween.
54+
*/
55+
public var tweenDuration:Float;
56+
/**
57+
* The start delay of the sprite's alpha tween.
58+
*/
59+
public var startDelay:Float;
60+
/**
61+
* Whenever the Rating sprites should be shown or not.
62+
*/
63+
public var displayRating:Bool;
64+
/**
65+
* Whenever the Rating sprites should be shown or not.
66+
*/
67+
public var displayNumbers:Bool;
68+
/**
69+
* Whenever the Combo sprite should be shown or not (like old Week 7 patches).
70+
*/
71+
public var displayCombo:Bool;
72+
/**
73+
* Whether the sprite should be tweened or not.
74+
*/
75+
public var playTween:Bool;
76+
/**
77+
* The amount of spacing for the combo numbers. (may be null)
78+
*/
79+
public var numSpacing:Null<Float>;
80+
/**
81+
* The position of the sprite.
82+
*/
83+
public var position:FlxPoint;
84+
/**
85+
* Whether to reset the sprite or not.
86+
*/
87+
public var resetSprite:Bool;
88+
/**
89+
* The rating name of the rating sprite. (may be null)
90+
*/
91+
public var rating:Null<String>;
92+
/**
93+
* The FlxTween instance. (null before "onPostRatingsShown")
94+
*/
95+
public var tween:Null<FlxTween>;
96+
}

source/funkin/backend/scripting/events/note/NoteHitEvent.hx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ final class NoteHitEvent extends CancellableEvent {
3434
/**
3535
* Whenever the Rating sprites should be shown or not.
3636
*/
37-
public var displayRating:Bool;
37+
public var displayRating:Null<Bool>;
3838
/**
3939
* Whenever the Combo sprite should be shown or not (like old Week 7 patches).
4040
*/
41-
public var displayCombo:Bool;
41+
public var displayCombo:Null<Bool>;
4242
/**
4343
* Note that has been pressed
4444
*/
@@ -66,11 +66,11 @@ final class NoteHitEvent extends CancellableEvent {
6666
/**
6767
* Prefix of the rating sprite path. Defaults to "game/score/"
6868
*/
69-
public var ratingPrefix:String;
69+
public var ratingPrefix:Null<String>;
7070
/**
7171
* Suffix of the rating sprite path.
7272
*/
73-
public var ratingSuffix:String;
73+
public var ratingSuffix:Null<String>;
7474
/**
7575
* Direction of the press (0 = Left, 1 = Down, 2 = Up, 3 = Right)
7676
*/
@@ -98,19 +98,19 @@ final class NoteHitEvent extends CancellableEvent {
9898
/**
9999
* Scale of combo numbers.
100100
*/
101-
public var numScale:Float = 0.5;
101+
public var numScale:Null<Float>;
102102
/**
103103
* Whenever antialiasing should be enabled on combo number.
104104
*/
105-
public var numAntialiasing:Bool = true;
105+
public var numAntialiasing:Null<Bool>;
106106
/**
107107
* Scale of ratings.
108108
*/
109-
public var ratingScale:Float = 0.7;
109+
public var ratingScale:Null<Float>;
110110
/**
111111
* Whenever antialiasing should be enabled on ratings.
112112
*/
113-
public var ratingAntialiasing:Bool = true;
113+
public var ratingAntialiasing:Null<Bool>;
114114
/**
115115
* Whenever the animation should be forced to play (if it's null it will be forced based on the sprite's data xml, if it has one).
116116
*/

0 commit comments

Comments
 (0)