Skip to content

Commit f9f0720

Browse files
Merge branch 'CodenameCrew:main' into more-scriptable-events
2 parents e7b10a3 + cda9311 commit f9f0720

12 files changed

Lines changed: 288 additions & 67 deletions

File tree

alsoft.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[general]
2+
sample-type=float32
3+
stereo-mode=speakers
4+
stereo-encoding=panpot
5+
hrtf=false
6+
cf_level=0
7+
resampler=fast_bsinc24
8+
front-stablizer=false
9+
output-limiter=false
10+
volume-adjust=0
11+
[decoder]
12+
hq-mode=false
13+
distance-comp=false
14+
nfc=false

assets/data/notes/Alt Anim Note.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
function onNoteHit(event) if (event.noteType == "Alt Anim Note") event.animSuffix = "-alt";
2-
function onPlayerMiss(event) if (event.noteType == "Alt Anim Note") event.animSuffix = "-alt";
2+
function onPlayerMiss(event) if (event.noteType == "Alt Anim Note") event.animSuffix = "miss-alt";

project.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
<assets path='mods' rename='mods' embed='false'/>
6868
<assets path='art/readme.txt' rename='do NOT readme.txt' />
6969

70+
<!-- OpenAL config -->
71+
<section if="desktop">
72+
<assets path="alsoft.txt" rename="plugins/alsoft.ini" type="text" if="windows"/>
73+
<assets path="alsoft.txt" rename="plugins/alsoft.conf" type="text" unless="windows"/>
74+
</section>
75+
7076
<!-- ______________________________ Haxedefines _____________________________ -->
7177

7278
<haxeflag name="--macro" value="funkin.backend.system.macros.NewHaxeWarning.warn()" />
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package funkin.backend.system.modules;
2+
3+
import haxe.io.Path;
4+
5+
/*
6+
* A class that simply points OpenALSoft to a custom configuration file when
7+
* the game starts up.
8+
*
9+
* The config overrides a few global OpenALSoft settings with the aim of
10+
* improving audio quality on desktop targets.
11+
*/
12+
@:keepInit class ALSoftConfig
13+
{
14+
#if desktop
15+
static function __init__():Void
16+
{
17+
var origin:String = #if hl Sys.getCwd() #else Sys.programPath() #end;
18+
19+
var configPath:String = Path.directory(Path.withoutExtension(origin));
20+
#if windows
21+
configPath += "/plugins/alsoft.ini";
22+
#elseif mac
23+
configPath = Path.directory(configPath) + "/Resources/plugins/alsoft.conf";
24+
#else
25+
configPath += "/plugins/alsoft.conf";
26+
#end
27+
28+
Sys.putEnv("ALSOFT_CONF", configPath);
29+
}
30+
#end
31+
}

source/funkin/backend/system/net/Socket.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Socket implements IFlxDestroyable {
1818

1919
public function read():String {
2020
try {
21-
return this.socket.input.readUntil(('\n').charCodeAt(0)).replace("\\n", "\n");
21+
return this.socket.input.readUntil('\n'.code).replace("\\n", "\n");
2222
} catch(e) {
2323

2424
}

source/funkin/backend/utils/CoolUtil.hx

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,124 @@ class CoolUtil
865865

866866
return result.join(seperator);
867867
}
868+
869+
public inline static function parsePropertyString(fieldPath:String):Array<OneOfTwo<String, Int>> {
870+
return FlxTween.parseFieldString(fieldPath);
871+
}
872+
873+
public static function stringifyFieldsPath(fields:Array<OneOfTwo<String, Int>>):String {
874+
var str = new StringBuf();
875+
var first = true;
876+
for (field in fields) {
877+
if (Type.typeof(field) == TInt) {
878+
str.add('[${field}]');
879+
} else {
880+
if (!first)
881+
str.add('.');
882+
str.add(field);
883+
}
884+
first = false;
885+
}
886+
return str.toString();
887+
}
888+
889+
public static function parseProperty(target:Dynamic, fields:OneOfTwo<String, Array<OneOfTwo<String, Int>>>):Dynamic {
890+
var fields:Array<OneOfTwo<String, Int>> = {
891+
if((fields is String)) CoolUtil.parsePropertyString(fields);
892+
else fields;
893+
}
894+
895+
var field = CoolUtil.last(fields);
896+
for (i in 0...fields.length - 1) {
897+
var component = fields[i];
898+
if (Type.typeof(component) == TInt) {
899+
if ((target is Array)) {
900+
var index:Int = cast component;
901+
var arr:Array<Dynamic> = cast target;
902+
target = arr[index];
903+
}
904+
} else { // TClass(String)
905+
target = Reflect.getProperty(target, component);
906+
}
907+
if (!Reflect.isObject(target) && !(target is Array))
908+
throw 'The object does not have the property "$component" in "${stringifyFieldsPath(fields)}"';
909+
}
910+
return new PropertyInfo(target, field);
911+
}
912+
913+
public static function cloneProperty(toTarget:Dynamic, fields:OneOfTwo<String, Array<OneOfTwo<String, Int>>>, fromTarget:Dynamic):Dynamic {
914+
var fields:Array<OneOfTwo<String, Int>> = {
915+
if((fields is String)) CoolUtil.parsePropertyString(fields);
916+
else fields;
917+
}
918+
919+
var toProperty = CoolUtil.parseProperty(toTarget, fields);
920+
var fromProperty = CoolUtil.parseProperty(fromTarget, fields);
921+
922+
return toProperty.setValue(fromProperty.getValue());
923+
}
924+
}
925+
926+
class PropertyInfo {
927+
public var object:Dynamic;
928+
public var field:OneOfTwo<String, Int>;
929+
public var typeOfField:Type.ValueType;
930+
#if hscript_improved
931+
public var isCustom:Bool = false;
932+
public var custom:hscript.IHScriptCustomBehaviour;
933+
#end
934+
935+
public function new(object:Dynamic, field:OneOfTwo<String, Int>) {
936+
this.object = object;
937+
this.field = field;
938+
#if hscript_improved
939+
if (object is hscript.IHScriptCustomBehaviour)
940+
{
941+
isCustom = true;
942+
custom = cast object;
943+
}
944+
#end
945+
946+
typeOfField = Type.typeof(field);
947+
}
948+
949+
public function getValue():Dynamic
950+
{
951+
if (typeOfField == TInt)
952+
{
953+
var index:Int = cast field;
954+
var arr:Array<Dynamic> = cast object;
955+
return arr[index];
956+
}
957+
else
958+
{
959+
#if hscript_improved
960+
if (isCustom)
961+
return custom.hget(field);
962+
else
963+
#end
964+
return Reflect.getProperty(object, field);
965+
}
966+
}
967+
968+
public function setValue(value:Dynamic):Void
969+
{
970+
if (typeOfField == TInt)
971+
{
972+
var index:Int = cast field;
973+
var arr:Array<Dynamic> = cast object;
974+
arr[index] = value;
975+
}
976+
else
977+
{
978+
#if hscript_improved
979+
if (isCustom)
980+
custom.hset(field, value);
981+
else
982+
#end
983+
Reflect.setProperty(object, field, value);
984+
}
985+
}
868986
}
869987

870988
/**

source/funkin/backend/utils/ZipUtil.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ class ZipUtil {
135135
if (prog == null) prog = new ZipProgress();
136136

137137
try {
138-
var curPath:Array<String> = ['$path'];
138+
var curPath:Array<String> = [path];
139139
var destPath:Array<String> = [];
140140
if (prefix != "") {
141141
prefix = prefix.replace("\\", "/");
142-
while(prefix.charAt(0) == "/") prefix = prefix.substr(1);
143-
while(prefix.charAt(prefix.length-1) == "/") prefix = prefix.substr(0, prefix.length-1);
142+
while(prefix.charCodeAt(0) == "/".code) prefix = prefix.substr(1);
143+
while(prefix.charCodeAt(prefix.length-1) == "/".code) prefix = prefix.substr(0, prefix.length-1);
144144
destPath.push(prefix);
145145
}
146146

@@ -160,7 +160,7 @@ class ZipUtil {
160160
} else {
161161
// is file, put it in the list
162162
var zipPath = '$zipPath/$e';
163-
while(zipPath.charAt(0) == "/") zipPath = zipPath.substr(1);
163+
while(zipPath.charCodeAt(0) == "/".code) zipPath = zipPath.substr(1);
164164
files.push(new StrNameLabel('$path/$e', zipPath));
165165
}
166166
}

source/funkin/game/GameOverSubstate.hx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,8 @@ class GameOverSubstate extends MusicBeatSubstate
100100
if (__cancelDefault)
101101
return;
102102

103-
if (controls.ACCEPT)
104-
{
105-
endBullshit();
106-
}
107-
108-
if (controls.BACK)
109-
{
110-
if (PlayState.chartingMode && Charter.undos.unsaved)
111-
game.saveWarn(false);
112-
else {
113-
PlayState.resetSongInfos();
114-
if (Charter.instance != null) Charter.instance.__clearStatics();
115-
116-
if (FlxG.sound.music != null)
117-
FlxG.sound.music.stop();
118-
FlxG.sound.music = null;
119-
120-
if (PlayState.isStoryMode)
121-
FlxG.switchState(new StoryMenuState());
122-
else
123-
FlxG.switchState(new FreeplayState());
124-
}
125-
126-
}
103+
if (controls.ACCEPT) endBullshit();
104+
if (controls.BACK) exit();
127105

128106
if (!isEnding && ((!lossSFX.playing) || (character.getAnimName() == "firstDeath" && character.isAnimFinished())) && (FlxG.sound.music == null || !FlxG.sound.music.playing))
129107
{
@@ -192,6 +170,26 @@ class GameOverSubstate extends MusicBeatSubstate
192170
});
193171
}
194172

173+
function exit()
174+
{
175+
var event = new CancellableEvent();
176+
gameoverScript.call('onReturnToMenu', [event]);
177+
178+
if (event.cancelled)
179+
return;
180+
181+
if (PlayState.chartingMode && Charter.undos.unsaved) game.saveWarn(false);
182+
else {
183+
PlayState.resetSongInfos();
184+
if (Charter.instance != null) Charter.instance.__clearStatics();
185+
186+
if (FlxG.sound.music != null) FlxG.sound.music.stop();
187+
FlxG.sound.music = null;
188+
189+
FlxG.switchState(PlayState.isStoryMode ? new StoryMenuState() : new FreeplayState());
190+
}
191+
}
192+
195193
override function destroy()
196194
{
197195
gameoverScript.call("destroy");

source/funkin/game/Note.hx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ class Note extends FlxSprite
7575
public var scrollSpeed:Null<Float> = null;
7676
public var noteAngle:Null<Float> = null;
7777

78+
public var copyStrumAngle:Bool = true;
79+
public var updateNotesPosX:Bool = true;
80+
public var updateNotesPosY:Bool = true;
81+
public var updateFlipY:Bool = true;
82+
7883
public var noteType(get, null):String;
7984

8085
@:dox(hide) public var __strumCameras:Array<FlxCamera> = null;
@@ -215,7 +220,7 @@ class Note extends FlxSprite
215220

216221
override function drawComplex(camera:FlxCamera) {
217222
var downscrollCam = (camera is HudCamera ? cast(camera, HudCamera).downscroll : false);
218-
flipY = (isSustainNote && flipSustain) && (downscrollCam != (__strum != null && __strum.getScrollSpeed(this) < 0));
223+
if (updateFlipY) flipY = (isSustainNote && flipSustain) && (downscrollCam != (__strum != null && __strum.getScrollSpeed(this) < 0));
219224
if (downscrollCam) {
220225
frameOffset.y += __notePosFrameOffset.y * 2;
221226
super.drawComplex(camera);

source/funkin/game/PlayState.hx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,27 @@ class PlayState extends MusicBeatState
13681368

13691369
switch(event.name) {
13701370
case "HScript Call":
1371-
scripts.call(event.params[0], event.params[1].split(','));
1371+
var scriptPacks:Array<ScriptPack> = [scripts, stateScripts];
1372+
for (strLine in strumLines.members) for (char in strLine.characters) scriptPacks.push(char.scripts);
1373+
var args:Array<String> = event.params[1].split(',');
1374+
1375+
for (pack in scriptPacks) {
1376+
pack.call(event.params[0], args);
1377+
//public functions
1378+
if (pack.publicVariables.exists(event.params[0])) {
1379+
var func = pack.publicVariables.get(event.params[0]);
1380+
if (func != null && Reflect.isFunction(func))
1381+
Reflect.callMethod(null, func, args);
1382+
}
1383+
}
1384+
1385+
//static functions
1386+
if (Script.staticVariables.exists(event.params[0])) {
1387+
var func = Script.staticVariables.get(event.params[0]);
1388+
if (func != null && Reflect.isFunction(func))
1389+
Reflect.callMethod(null, func, args);
1390+
}
1391+
13721392
case "Camera Movement":
13731393
curCameraTarget = event.params[0];
13741394
case "Add Camera Zoom":

0 commit comments

Comments
 (0)