Merge remote-tracking branch 'upstream/main' into pr/397

This commit is contained in:
Ralty
2025-07-05 18:23:41 +07:00
30 changed files with 310 additions and 221 deletions
-3
View File
@@ -1,3 +0,0 @@
//
function update(elapsed:Float)
if (FlxG.keys.justPressed.F5) FlxG.resetState();
+26 -35
View File
@@ -18,9 +18,7 @@ static var daPixelZoom = 6;
* UI
*/
function onNoteCreation(event) {
if (event.note.strumLine == playerStrums && !pixelNotesForBF) return;
if (event.note.strumLine == cpuStrums && !pixelNotesForDad) return;
if ((event.note.strumLine == playerStrums && !pixelNotesForBF) || (event.note.strumLine == cpuStrums && !pixelNotesForDad)) return;
event.cancel();
var note = event.note;
@@ -34,18 +32,14 @@ function onNoteCreation(event) {
}
note.scale.set(daPixelZoom, daPixelZoom);
note.updateHitbox();
note.antialiasing = false;
}
function onPostNoteCreation(event) {
var splashes = event.note;
if (pixelSplashes)
splashes.splash = "pixel-default";
}
function onPostNoteCreation(event) if (pixelSplashes)
event.note.splash = "pixel-default";
function onStrumCreation(event) {
if (event.player == 1 && !pixelNotesForBF) return;
if (event.player == 0 && !pixelNotesForDad) return;
if ((event.player == 1 && !pixelNotesForBF) || (event.player == 0 && !pixelNotesForDad)) return;
event.cancel();
var strum = event.strum;
@@ -56,6 +50,7 @@ function onStrumCreation(event) {
strum.scale.set(daPixelZoom, daPixelZoom);
strum.updateHitbox();
strum.antialiasing = false;
}
function onCountdown(event) {
@@ -86,9 +81,9 @@ function onPlayerHit(event:NoteHitEvent) {
* CAMERA HACKS!!
*/
function postCreate() {
if (enablePauseMenu) {
if (enablePauseMenu)
PauseSubState.script = 'data/scripts/week6-pause';
}
if (enableCameraHacks) {
camGame.pixelPerfectRender = true;
camGame.antialiasing = false;
@@ -104,8 +99,8 @@ function postCreate() {
}
}
function onStartCountdown() {
/*var newNoteCamera = new HudCamera();
/*function onStartCountdown() {
var newNoteCamera = new HudCamera();
newNoteCamera.bgColor = 0; // transparent
FlxG.cameras.add(newNoteCamera, false);
@@ -119,8 +114,8 @@ function onStartCountdown() {
i++;
}
}
makeCameraPixely(newNoteCamera);*/
}
makeCameraPixely(newNoteCamera);
}*/
/**
* Use this to make any camera pixelly (you wont be able to zoom with it anymore!)
@@ -145,33 +140,29 @@ function destroy() {
FlxG.game.stage.quality = oldStageQuality;
}
function pixelCam(cam) {
function pixelCam(cam)
makeCameraPixely(cam);
}
var pixellyCameras = [];
var pixellyShaders = [];
function postUpdate(elapsed) {
for(e in pixellyCameras) {
if (Std.isOfType(e, HudCamera))
e.downscroll = camHUD.downscroll;
}
if (enableCameraHacks) {
for(p in strumLines)
p.notes.forEach(function(n) {
if(n.isSustainNote) return; // hacky fix for hold
n.y -= n.y % daPixelZoom;
n.x -= n.x % daPixelZoom;
});
function postUpdate() {
for (e in pixellyCameras) if (Std.isOfType(e, HudCamera))
e.downscroll = camHUD.downscroll;
if (enableCameraHacks) for (p in strumLines) {
p.notes.forEach(function(n) {
if(n.isSustainNote) return; // hacky fix for hold
n.y -= n.y % daPixelZoom;
n.x -= n.x % daPixelZoom;
});
}
var zoom = 1 / daPixelZoom / Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y);
for(e in pixellyCameras) {
for (e in pixellyCameras) {
if (!e.exists) continue;
e.zoom = zoom;
}
for(e in pixellyShaders) {
for (e in pixellyShaders)
e.pixelZoom = zoom;
}
}
}
+36 -48
View File
@@ -3,7 +3,7 @@ import flixel.text.FlxText;
import flixel.text.FlxTextBorderStyle;
import flixel.util.FlxAxes;
var pixelScript:Script;
var pixelScript:Script = game.scripts.getByName("pixel.hx");
var pauseCam = new FlxCamera();
var bg:FlxSprite;
@@ -19,47 +19,40 @@ function create(event) {
event.music = isThorns ? "pixel/LunchboxScary" : "pixel/Lunchbox";
cameras = [];
pixelScript = game.scripts.getByName("pixel.hx");
pixelScript.call("pixelCam", [pauseCam]);
// allowing this pause script even if the pixel script is not loaded - Nex
pixelScript?.call("pixelCam", [pauseCam]);
FlxG.cameras.add(pauseCam, false);
cameras = [pauseCam];
pauseCam.bgColor = isThorns ? 0x88000000 : 0x88FF99CC;
pauseCam.alpha = 0;
bg = new FlxSprite(44 * 6, 14 * 6);
bg.loadGraphic(Paths.image('stages/school/pause/bg'));
if (isThorns)
bg.color = 0xFF000000;
bg = new FlxSprite(44 * 6, 14 * 6, Paths.image('stages/school/pause/bg'));
bg.antialiasing = false;
if (isThorns) bg.color = 0xFF000000;
bg.scale.set(6, 6);
bg.updateHitbox();
bg.scale.y = 4;
bg.cameras = [pauseCam];
add(bg);
songText = new FlxText(0, 22 * 6, 0, "Pause", 8, false);
confText(songText);
add(songText);
var i = 2;
for(e in menuItems) {
text = new FlxText(0, (22 * 6) + (i * 9 * 6), 0, e, 8, false);
for (i=>e in menuItems) {
text = new FlxText(0, (22 * 6) + ((i+2) * 9 * 6), 0, e, 8, false);
confText(text);
add(text);
texts.push(text);
i++;
}
hand = new FlxSprite().loadGraphic(Paths.image('stages/school/ui/hand_textbox'));
hand.antialiasing = false;
hand.scale.set(6, 6);
hand.updateHitbox();
add(hand);
FlxTween.tween(bg, {"scale.y": 6}, 0.75, {ease: FlxEase.elasticOut});
FlxTween.tween(bg.scale, {y: 6}, 0.75, {ease: FlxEase.elasticOut});
cameras = [pauseCam];
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/ANGRY' : 'pixel/clickText'));
}
@@ -70,55 +63,50 @@ function confText(text) {
text.screenCenter(FlxAxes.X);
text.borderStyle = FlxTextBorderStyle.OUTLINE;
if (!isThorns) text.borderColor = 0xFF953E3E;
text.antialiasing = false;
texts.push(text);
add(text);
}
function destroy() {
if(FlxG.cameras.list.contains(pauseCam))
FlxG.cameras.remove(pauseCam);
}
function destroy() if (FlxG.cameras.list.contains(pauseCam))
FlxG.cameras.remove(pauseCam);
var canDoShit = true;
var time:Float = 0;
function update(elapsed) {
pixelScript.call("postUpdate", [elapsed]);
pixelScript?.call("postUpdate", [elapsed]);
pauseCam.alpha = lerp(pauseCam.alpha, 1, 0.25);
time += elapsed;
var curText = texts[curSelected];
var curText = texts[curSelected + 1];
hand.setPosition(curText.x - hand.width - 18 + (Math.sin(time * Math.PI * 2) * 12), curText.y + (text.height - hand.height) - 6);
hand.x -= hand.x % 6;
hand.y -= hand.y % 6;
if (!canDoShit) return;
var oldSec = curSelected;
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel);
if (oldSec != curSelected)
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/type' : 'pixel/pixelText'));
if (controls.ACCEPT) enterOption();
}
if (controls.ACCEPT) {
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/ANGRY' : 'pixel/clickText'));
var option = menuItems[curSelected];
if (option == "Resume" || option == "Exit to menu") {
var scrollSFX = FlxG.sound.load(Paths.sound(isThorns ? 'pixel/type' : 'pixel/pixelText'));
function changeSelection(change) if (canDoShit) { // this overrides the function inside of the normal pause btw, so no event gets called - Nex
curSelected = FlxMath.wrap(curSelected + change, 0, menuItems.length - 1);
if (change != 0) scrollSFX.play();
}
var enterSFX = FlxG.sound.load(Paths.sound(isThorns ? 'pixel/ANGRY' : 'pixel/clickText'));
function enterOption() if (canDoShit) {
var option = menuItems[curSelected];
enterSFX.play();
switch(option) {
case "Resume", "Exit to menu":
canDoShit = false;
for(t in texts) t.visible = false;
hand.visible = songText.visible = false;
FlxTween.tween(bg, {"scale.y": 0}, 0.125, {ease: FlxEase.cubeOut, onComplete: function() {
selectOption();
}});
} else {
selectOption();
}
FlxTween.tween(bg.scale, {y: 0}, 0.125, {ease: FlxEase.cubeOut, onComplete: selectOption});
default: selectOption();
}
}
function changeSelection(change) { // this overrides the function inside of the normal pause btw, so no event gets called - Nex
curSelected += change;
if (curSelected < 0)
curSelected = menuItems.length - 1;
if (curSelected >= menuItems.length)
curSelected = 0;
}
+2 -8
View File
@@ -3,13 +3,7 @@ var sound:Sound;
function create()
sound = Paths.sound('jeffGameover/jeffGameover-' + FlxG.random.int(1, 25, !Options.naughtyness ? [1, 3, 8, 13, 17, 21] : null));
function beatHit(cur:Int) {
if(cur != 0) return;
function beatHit(cur:Int) if (cur == 0) {
FlxG.sound.play(sound, 1, false, null, true, () -> if (!isEnding) FlxG.sound.music.fadeIn(4, 0.2, 1));
FlxG.sound.music.volume = 0.2;
FlxG.sound.play(sound, 1, false, null, true, function()
{
if (!isEnding)
FlxG.sound.music.fadeIn(4, 0.2, 1);
});
}
+2 -2
View File
@@ -1,7 +1,7 @@
var tankAngle:Float = FlxG.random.int(-90, 45);
var tankSpeed:Float = FlxG.random.float(5, 7);
function postCreate() if(PlayState.isStoryMode)
function postCreate() if (PlayState.isStoryMode)
GameOverSubstate.script = 'data/scripts/week7-balledLines';
function update(elapsed:Float) {
@@ -12,7 +12,7 @@ function update(elapsed:Float) {
}
function onPostCountdown(event) {
if(!playCutscenes || event.sprite == null) return;
if (!playCutscenes || event.sprite == null) return;
var lastIndex:Int = members.indexOf(event.sprite);
remove(event.sprite);
insert(lastIndex + 4, event.sprite);
-2
View File
@@ -59,8 +59,6 @@ function create() {
}
function update(elapsed) {
if (FlxG.keys.justPressed.F5)
FlxG.resetState();
switch(step) {
case 0:
lipSync(tankman, 0, 16750);
+4 -1
View File
@@ -17,7 +17,10 @@ class Compiler {
private static function __build(args:Array<String>, arg:Array<String>) {
for(a in args)
arg.push(a);
Sys.command("lime", arg);
arg = ['run', 'lime'].concat(arg);
Sys.command("haxelib", arg);
}
public static function getBuildTarget() {
+11 -9
View File
@@ -101,6 +101,8 @@ class MusicBeatState extends FlxState implements IBeatReceiver
public static var skipTransOut:Bool = false;
public static var skipTransIn:Bool = false;
public static var ALLOW_DEBUG_RELOAD:Bool = true;
inline function get_controls():Controls
return PlayerSettings.solo.controls;
inline function get_controlsP1():Controls
@@ -147,16 +149,20 @@ class MusicBeatState extends FlxState implements IBeatReceiver
call("postUpdate", [elapsed]);
}
if (_requestSubStateReset)
{
if (_requestSubStateReset) {
_requestSubStateReset = false;
resetSubState();
}
if (subState != null)
{
subState.tryUpdate(elapsed);
if (/*subState == null && */(ALLOW_DEBUG_RELOAD && controls.DEBUG_RELOAD)) {
Logs.trace("Reloading Current State...", INFO, YELLOW);
FlxG.resetState();
}
if (subState != null)
subState.tryUpdate(elapsed);
}
override function create()
{
loadScript();
@@ -189,10 +195,6 @@ class MusicBeatState extends FlxState implements IBeatReceiver
override function update(elapsed:Float)
{
// TODO: DEBUG MODE!!
if (FlxG.keys.justPressed.F5) {
loadScript();
}
call("update", [elapsed]);
super.update(elapsed);
+8 -8
View File
@@ -126,15 +126,19 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver
call("postUpdate", [elapsed]);
}
if (_requestSubStateReset)
{
// if (subState == null && (MusicBeatState.ALLOW_DEBUG_RELOAD && controls.DEBUG_RELOAD)) {
// Logs.trace("Reloading Current SubState...", INFO, YELLOW);
// var test = Type.createInstance(Type.getClass(this), [this.scriptsAllowed, this.scriptName]);
// parent.openSubState(test);
// }
if (_requestSubStateReset) {
_requestSubStateReset = false;
resetSubState();
}
if (subState != null)
{
subState.tryUpdate(elapsed);
}
}
override function close() {
@@ -171,10 +175,6 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver
override function update(elapsed:Float)
{
// TODO: DEBUG MODE!!
if (FlxG.keys.justPressed.F5) {
loadScript();
}
call("update", [elapsed]);
super.update(elapsed);
}
+5 -5
View File
@@ -274,13 +274,13 @@ class Paths
}
return content;
}
static public function getFolderContent(key:String, addPath:Bool = false, source:AssetsLibraryList.AssetSource = BOTH):Array<String> {
static public function getFolderContent(key:String, addPath:Bool = false, source:AssetsLibraryList.AssetSource = BOTH, noExtension:Bool = false):Array<String> {
// designed to work both on windows and web
if (!key.endsWith("/")) key += "/";
var content = assetsTree.getFiles('assets/$key', source);
if (addPath) {
for(k=>e in content)
content[k] = '$key$e';
for (k => e in content) {
if (noExtension) e = Path.withoutExtension(e);
content[k] = addPath ? '$key$e' : e;
}
return content;
/*
@@ -363,4 +363,4 @@ class ScriptPathInfo {
this.file = file;
this.library = library;
}
}
}
+14 -12
View File
@@ -96,8 +96,11 @@ class Chart {
var fromMods:Bool = fromMods;
for (path in [metaDiffPath, metaPath]) if (Assets.exists(path)) {
fromMods = Paths.assetsTree.existsSpecific(path, "TEXT", MODS);
try data = Json.parse(Assets.getText(path))
catch(e) Logs.trace('Failed to load song metadata for ${songName} ($path): ${Std.string(e)}', ERROR);
try {
var tempData = Json.parse(Assets.getText(path));
tempData.color = CoolUtil.getColorFromDynamic(tempData.color).getDefault(defaultColor);
data = tempData;
} catch(e) Logs.trace('Failed to load song metadata for ${songName} ($path): ${Std.string(e)}', ERROR);
if (data != null) break;
}
@@ -115,7 +118,6 @@ class Chart {
data.setFieldDefault("coopAllowed", false);
data.setFieldDefault("opponentModeAllowed", false);
data.setFieldDefault("displayName", data.name);
data.setFieldDefault("parsedColor", data.color.getColorFromDynamic().getDefault(defaultColor));
if (data.difficulties.length <= 0) {
data.difficulties = [for(f in Paths.getFolderContent('songs/${songNameLower}/charts/', false, !fromMods)) if (Path.extension(f = f.toUpperCase()) == "JSON") Path.withoutExtension(f)];
@@ -257,33 +259,33 @@ class Chart {
CoolUtil.safeSaveFile(chartPath, Json.stringify(filteredChart, null, saveSettings.prettyPrint == true ? "\t" : null));
// idk how null reacts to it so better be sure
if (saveSettings.overrideExistingMeta == true || !FileSystem.exists(metaPath))
CoolUtil.safeSaveFile(metaPath, Json.stringify(meta, null, saveSettings.prettyPrint == true ? "\t" : null));
CoolUtil.safeSaveFile(metaPath, makeMetaSaveable(meta));
#end
return filteredChart;
}
public static function filterChartForSaving(chart:ChartData, ?saveMetaInChart:Null<Bool>, ?saveEventsInChart:Null<Bool>):ChartData {
var data = Reflect.copy(chart); // make a copy of the chart to leave the OG intact
if (saveMetaInChart != true) {
data.meta = null;
} else {
data.meta = Reflect.copy(chart.meta); // also make a copy of the metadata to leave the OG intact.
if(data.meta != null && Reflect.hasField(data.meta, "parsedColor")) Reflect.deleteField(data.meta, "parsedColor");
}
data.meta = saveMetaInChart != true ? null : data.meta = Reflect.copy(chart.meta); // also make a copy of the metadata to leave the OG intact.
data.events = saveEventsInChart != true ? null : Reflect.copy(chart.events); // same here once again
data.fromMods = null;
var sortedData:Dynamic = {};
for(f in Reflect.fields(data)) {
for (f in Reflect.fields(data)) {
var v = Reflect.field(data, f);
if (v != null)
Reflect.setField(sortedData, f, v);
}
return sortedData;
}
public static inline function makeMetaSaveable(meta:ChartMetaData, prettyPrint:Bool = true):String {
var data:Dynamic = Reflect.copy(meta);
if (data.color != null) data.color = new FlxColor(data.color).toWebString(); // dont even ask me - Nex
return Json.stringify(data, null, prettyPrint ? "\t" : null);
}
}
typedef ChartSaveSettings = {
+1 -4
View File
@@ -22,14 +22,11 @@ typedef ChartMetaData = {
public var ?stepsPerBeat:Int;
public var ?needsVoices:Bool;
public var ?icon:String;
public var ?color:Dynamic;
public var ?color:FlxColor;
public var ?difficulties:Array<String>;
public var ?coopAllowed:Bool;
public var ?opponentModeAllowed:Bool;
public var ?customValues:Dynamic;
// NOT TO BE EXPORTED
public var ?parsedColor:FlxColor;
}
typedef ChartStrumLine = {
+28 -11
View File
@@ -11,6 +11,9 @@ import funkin.backend.assets.ModsFolder;
class GlobalScript {
public static var scripts:ScriptPack;
private static var reloading:Bool = false;
private static var _lastAllow_Reload:Bool = false;
public static function init() {
#if MOD_SUPPORT
ModsFolder.onModSwitch.add(onModSwitch);
@@ -42,16 +45,12 @@ class GlobalScript {
});
FlxG.signals.postUpdate.add(function() {
call("postUpdate", [FlxG.elapsed]);
if (FlxG.keys.justPressed.F5) {
if (scripts.scripts.length > 0) {
Logs.trace('Reloading global script...', WARNING, YELLOW);
scripts.reload();
Logs.trace('Global script successfully reloaded.', WARNING, GREEN);
} else {
Logs.trace('Loading global script...', WARNING, YELLOW);
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
}
if (reloading) {
reloading = false;
MusicBeatState.ALLOW_DEBUG_RELOAD = _lastAllow_Reload;
}
if (FlxG.keys.justPressed.F2)
NativeAPI.allocConsole();
});
@@ -70,12 +69,29 @@ class GlobalScript {
FlxG.signals.preStateSwitch.add(function() {
call("preStateSwitch", []);
});
FlxG.signals.preUpdate.add(function() {
call("preUpdate", [FlxG.elapsed]);
call("update", [FlxG.elapsed]);
});
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
if (FlxG.keys.pressed.SHIFT) {
var resetKey = FlxG.keys.justPressed.F5; // we default the key to F5, but really this shouldn't matter, as every state will be at minimum a MusicBeatState.
if ((FlxG.state is MusicBeatState)) resetKey = cast(FlxG.state, MusicBeatState).controls.DEBUG_RELOAD;
// If we want, we could just make reseting GlobalScript it's own keybind, but for now this works.
if (resetKey) {
reloading = true;
Logs.trace("Reloading Global Scripts...", INFO, YELLOW);
// yeah its a bit messy, sorry. This just prevents actually reloading the actual state.
_lastAllow_Reload = MusicBeatState.ALLOW_DEBUG_RELOAD;
MusicBeatState.ALLOW_DEBUG_RELOAD = false;
// Would be better to just re-initalize GlobalScript so there aren't any lose ends.
onModSwitch(#if MOD_SUPPORT ModsFolder.currentModFolder #else null #end);
}
}
});
}
public static function event<T:CancellableEvent>(name:String, event:T):T {
@@ -88,6 +104,7 @@ class GlobalScript {
if (scripts != null)
scripts.call(name, args);
}
public static function onModSwitch(newMod:String) {
call("destroy");
scripts = FlxDestroyUtil.destroy(scripts);
@@ -53,7 +53,7 @@ class ScriptPack extends Script {
public override function call(func:String, ?parameters:Array<Dynamic>):Dynamic {
for(e in scripts)
if(e.active)
if (e.active)
e.call(func, parameters);
return null;
}
+23
View File
@@ -44,6 +44,9 @@ enum abstract Action(String) to String from String {
var RESET = "reset";
var CHEAT = "cheat";
var SWITCHMOD = "switchmod";
// Debugs
var DEBUG_RELOAD = "debug-reload";
}
enum Device
@@ -73,6 +76,9 @@ enum Control
PAUSE;
CHEAT;
SWITCHMOD;
// Debugs
DEBUG_RELOAD;
}
enum KeyboardScheme
@@ -122,6 +128,8 @@ class Controls extends FlxActionSet
var _reset = new FlxActionDigital(Action.RESET);
var _cheat = new FlxActionDigital(Action.CHEAT);
var _switchMod = new FlxActionDigital(Action.SWITCHMOD);
var debug_reload = new FlxActionDigital(Action.DEBUG_RELOAD);
#if (haxe >= "4.0.0")
var byName:Map<String, FlxActionDigital> = [];
@@ -372,6 +380,14 @@ class Controls extends FlxActionSet
inline function set_SWITCHMOD(val)
return @:privateAccess _switchMod._checked = val;
public var DEBUG_RELOAD(get, set):Bool;
inline function get_DEBUG_RELOAD()
return debug_reload.check();
inline function set_DEBUG_RELOAD(val)
return @:privateAccess debug_reload._checked = val;
public function new(name, scheme = None)
{
super(name);
@@ -408,6 +424,7 @@ class Controls extends FlxActionSet
add(_reset);
add(_cheat);
add(_switchMod);
add(debug_reload);
for (action in digitalActions)
byName[action.name] = action;
@@ -469,6 +486,7 @@ class Controls extends FlxActionSet
case RESET: _reset;
case CHEAT: _cheat;
case SWITCHMOD: _switchMod;
case DEBUG_RELOAD: debug_reload;
}
}
@@ -532,6 +550,8 @@ class Controls extends FlxActionSet
func(_cheat, JUST_PRESSED);
case SWITCHMOD:
func(_switchMod, JUST_PRESSED);
case DEBUG_RELOAD:
func(debug_reload, JUST_PRESSED);
}
}
@@ -687,6 +707,7 @@ class Controls extends FlxActionSet
inline bindKeys(Control.PAUSE, Options.SOLO_PAUSE);
inline bindKeys(Control.RESET, Options.SOLO_RESET);
inline bindKeys(Control.SWITCHMOD, Options.SOLO_SWITCHMOD);
inline bindKeys(Control.DEBUG_RELOAD, Options.SOLO_DEBUG_RELOAD);
case Duo(true):
inline bindKeys(Control.UP, Options.P1_UP);
inline bindKeys(Control.DOWN, Options.P1_DOWN);
@@ -701,6 +722,7 @@ class Controls extends FlxActionSet
inline bindKeys(Control.PAUSE, Options.P1_PAUSE);
inline bindKeys(Control.RESET, Options.P1_RESET);
inline bindKeys(Control.SWITCHMOD, Options.P1_SWITCHMOD);
inline bindKeys(Control.DEBUG_RELOAD, Options.P1_DEBUG_RELOAD);
case Duo(false):
inline bindKeys(Control.UP, Options.P2_UP);
inline bindKeys(Control.DOWN, Options.P2_DOWN);
@@ -715,6 +737,7 @@ class Controls extends FlxActionSet
inline bindKeys(Control.PAUSE, Options.P2_PAUSE);
inline bindKeys(Control.RESET, Options.P2_RESET);
inline bindKeys(Control.SWITCHMOD, Options.P2_SWITCHMOD);
inline bindKeys(Control.DEBUG_RELOAD, Options.P2_DEBUG_RELOAD);
case None: // nothing
case Custom: // nothing
}
+2 -1
View File
@@ -89,7 +89,7 @@ class Main extends Sprite
public static var audioDisconnected:Bool = false;
public static var changeID:Int = 0;
public static var pathBack = #if windows
public static var pathBack = #if (windows || linux)
"../../../../"
#elseif mac
"../../../../../../../"
@@ -183,6 +183,7 @@ class Main extends Sprite
public static function refreshAssets() {
WindowUtils.resetTitle();
FunkinCache.instance.clearSecondLayer();
FlxSoundTray.volumeChangeSFX = Paths.sound('menu/volume');
FlxSoundTray.volumeUpChangeSFX = null;
+6 -1
View File
@@ -389,9 +389,14 @@ class CoolUtil
if (Assets.exists(infoPath)) {
var musicInfo = IniUtil.parseAsset(infoPath, [
"BPM" => null,
"TimeSignature" => "4/4"
"TimeSignature" => "4/4",
"LoopTime" => "0.0"
]);
if (FlxG.sound.music != null) {
FlxG.sound.music.loopTime = Std.parseFloat(musicInfo["LoopTime"]) * 1000;
}
var timeSignParsed:Array<Null<Float>> = musicInfo["TimeSignature"] == null ? [] : [for(s in musicInfo["TimeSignature"].split("/")) Std.parseFloat(s)];
var beatsPerMeasure:Float = 4;
var stepsPerBeat:Int = 4;
+5 -4
View File
@@ -70,12 +70,13 @@ class XMLUtil {
/**
* Overrides a sprite based on a XML node.
*/
public static function loadSpriteFromXML(spr:FunkinSprite, node:Access, parentFolder:String = "", defaultAnimType:XMLAnimType = BEAT):FunkinSprite {
public static function loadSpriteFromXML(spr:FunkinSprite, node:Access, parentFolder:String = "", defaultAnimType:XMLAnimType = BEAT, loadGraphic:Bool = true):FunkinSprite {
if (parentFolder == null) parentFolder = "";
spr.name = node.getAtt("name");
spr.antialiasing = true;
spr.loadSprite(Paths.image('$parentFolder${node.getAtt("sprite").getDefault(spr.name)}', null, true));
if (loadGraphic)
spr.loadSprite(Paths.image('$parentFolder${node.getAtt("sprite").getDefault(spr.name)}', null, true));
spr.spriteAnimType = defaultAnimType;
if (node.has.type) {
@@ -185,10 +186,10 @@ class XMLUtil {
/**
* Creates a new sprite based on a XML node.
*/
public static inline function createSpriteFromXML(node:Access, parentFolder:String = "", defaultAnimType:XMLAnimType = BEAT, ?cl:Class<FunkinSprite>, ?args:Array<Dynamic>):FunkinSprite {
public static inline function createSpriteFromXML(node:Access, parentFolder:String = "", defaultAnimType:XMLAnimType = BEAT, ?cl:Class<FunkinSprite>, ?args:Array<Dynamic>, loadGraphic:Bool = true):FunkinSprite {
if(cl == null) cl = FunkinSprite;
if(args == null) args = [];
return loadSpriteFromXML(Type.createInstance(cl, args), node, parentFolder, defaultAnimType);
return loadSpriteFromXML(Type.createInstance(cl, args), node, parentFolder, defaultAnimType, loadGraphic);
}
public static function extractAnimFromXML(anim:Access, animType:XMLAnimType = NONE, loop:Bool = false):AnimData {
+7 -4
View File
@@ -610,7 +610,7 @@ class Charter extends UIState {
// Just for now until i add event stacking -lunar
try {__relinkUndos();}
catch (e) {Logs.trace('Failed to relink undos: ${Std.string(e)}', ERROR);}
__applyPlaytestInfo();
}
@@ -1279,8 +1279,11 @@ class Charter extends UIState {
for(id=>str in strumLines.members)
if (str != null) str.y = strumlineInfoBG.y;
strumlineAddButton.x = 0;
strumlineAddButton.y = strumlineInfoBG.y;
strumlineLockButton.y = strumlineInfoBG.y;
strumlineLockButton.text.visible = strumlineLockButton.button.selectable = strumlineLockButton.button.visible = strumLines.members.length > 0;
}
var zoom(default, set):Float = 0;
@@ -1335,7 +1338,7 @@ class Charter extends UIState {
#if sys
CoolUtil.safeSaveFile(
'${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/meta.json',
Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t")
PlayState.SONG.meta == null ? null : Chart.makeMetaSaveable(PlayState.SONG.meta)
);
#else
_file_meta_saveas(_);
@@ -1343,7 +1346,7 @@ class Charter extends UIState {
}
function _file_meta_saveas(_) {
openSubState(new SaveSubstate(Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t"), { // always pretty print meta
openSubState(new SaveSubstate(PlayState.SONG.meta == null ? null : Chart.makeMetaSaveable(PlayState.SONG.meta), { // always pretty print meta
defaultSaveFile: 'meta.json'
}));
}
@@ -1640,7 +1643,7 @@ class Charter extends UIState {
t.icon = (Options.charterLowDetailWaveforms = !Options.charterLowDetailWaveforms) ? 1 : 0;
for (shader in waveformHandler.waveShaders) shader.data.lowDetail.value = [Options.charterLowDetailWaveforms];
}
inline function _snap_increasesnap(_) changequant(1);
inline function _snap_decreasesnap(_) changequant(-1);
inline function _snap_resetsnap(_) setquant(16);
@@ -91,7 +91,7 @@ class CharterMetaDataScreen extends UISubstateWindow {
coopAllowedCheckbox = new UICheckbox(opponentModeCheckbox.x + 150 + 26, opponentModeCheckbox.y, "Co-op Mode", metadata.coopAllowed);
add(coopAllowedCheckbox);
colorWheel = new UIColorwheel(iconTextBox.x, coopAllowedCheckbox.y, metadata.parsedColor);
colorWheel = new UIColorwheel(iconTextBox.x, coopAllowedCheckbox.y, metadata.color);
add(colorWheel);
addLabelOn(colorWheel, "Color");
@@ -158,8 +158,7 @@ class CharterMetaDataScreen extends UISubstateWindow {
needsVoices: needsVoicesCheckbox.checked,
displayName: displayNameTextBox.label.text,
icon: iconTextBox.label.text,
color: colorWheel.curColorString,
parsedColor: colorWheel.curColor,
color: colorWheel.curColor,
opponentModeAllowed: opponentModeCheckbox.checked,
coopAllowed: coopAllowedCheckbox.checked,
difficulties: [for (diff in difficulitesTextBox.label.text.split(",")) diff.trim()],
@@ -1,15 +1,16 @@
package funkin.editors.charter;
import funkin.backend.chart.ChartData;
import funkin.backend.chart.Chart;
import funkin.backend.chart.ChartData.ChartMetaData;
import haxe.Json;
import funkin.editors.charter.SongCreationScreen.SongCreationData;
import funkin.options.type.NewOption;
import funkin.backend.chart.ChartData;
import funkin.backend.system.framerate.Framerate;
import funkin.menus.FreeplayState.FreeplaySonglist;
import funkin.editors.EditorTreeMenu;
import funkin.editors.charter.SongCreationScreen.SongCreationData;
import funkin.menus.FreeplayState.FreeplaySonglist;
import funkin.options.*;
import funkin.options.type.*;
import funkin.options.type.NewOption;
import haxe.Json;
using StringTools;
@@ -38,7 +39,7 @@ class CharterSelection extends EditorTreeMenu {
FlxG.state.openSubState(new ChartCreationScreen(saveChart));
}));
optionsTree.add(new OptionsScreen(s.name, "Select a difficulty to continue.", list));
}, s.parsedColor.getDefault(0xFFFFFFFF))
}, s.color.getDefault(0xFFFFFFFF))
];
list.insert(0, new NewOption("New Song", "New Song", function() {
@@ -109,7 +110,7 @@ class CharterSelection extends EditorTreeMenu {
sys.FileSystem.createDirectory('$songFolder/charts');
// Save Files
CoolUtil.safeSaveFile('$songFolder/meta.json', Json.stringify(creation.meta, "\t"));
CoolUtil.safeSaveFile('$songFolder/meta.json', Chart.makeMetaSaveable(creation.meta));
if (creation.instBytes != null) sys.io.File.saveBytes('$songFolder/song/Inst.${Paths.SOUND_EXT}', creation.instBytes);
if (creation.voicesBytes != null) sys.io.File.saveBytes('$songFolder/song/Voices.${Paths.SOUND_EXT}', creation.voicesBytes);
#end
@@ -126,7 +127,7 @@ class CharterSelection extends EditorTreeMenu {
FlxG.state.openSubState(new ChartCreationScreen(saveChart));
}));
optionsTree.insert(1, new OptionsScreen(creation.meta.name, "Select a difficulty to continue.", list));
}, creation.meta.parsedColor.getDefault(0xFFFFFFFF));
}, creation.meta.color.getDefault(0xFFFFFFFF));
// Add to List
freeplayList.songs.insert(0, creation.meta);
@@ -160,7 +161,7 @@ class CharterSelection extends EditorTreeMenu {
var meta = Json.parse(sys.io.File.getContent('$songFolder/meta.json'));
if (meta.difficulties != null && !meta.difficulties.contains(name)) {
meta.difficulties.push(name);
CoolUtil.safeSaveFile('$songFolder/meta.json', Json.stringify(meta));
CoolUtil.safeSaveFile('$songFolder/meta.json', Chart.makeMetaSaveable(meta));
}
}
}
@@ -58,8 +58,8 @@ class CharterStrumlineButton extends UISprite {
super.update(elapsed);
UIState.state.updateSpriteRect(button);
if(UIState.state.curContextMenu == null && UIState.state.isOverlapping(button, button.__rect)) {
if (UIState.state.curContextMenu == null && UIState.state.isOverlapping(button, button.__rect) && button.visible) {
UIState.state.updateSpriteRect(button);
buttonScale.set(0.95, 0.95);
if (FlxG.mouse.justPressed && onClick != null) {
onClick();
@@ -254,8 +254,7 @@ class SongCreationScreen extends UISubstateWindow {
needsVoices: needsVoicesCheckbox.checked,
displayName: displayNameTextBox.label.text,
icon: iconTextBox.label.text,
color: colorWheel.curColorString,
parsedColor: colorWheel.curColor,
color: colorWheel.curColor,
opponentModeAllowed: opponentModeCheckbox.checked,
coopAllowed: coopAllowedCheckbox.checked,
difficulties: [for (diff in difficulitesTextBox.label.text.split(",")) diff.trim()],
+16 -22
View File
@@ -154,9 +154,9 @@ class Note extends FlxSprite
case 0:
animation.addByPrefix('scroll', 'purple0');
animation.addByPrefix('hold', 'purple hold piece');
animation.addByPrefix('holdend', 'purple hold end');
if (frames.getByName("pruple end hold") != null)
animation.addByPrefix("holdend", "pruple end hold");
animation.addByPrefix("holdend", "pruple end hold");
if (animation.exists("holdend") != true) // null or false
animation.addByPrefix('holdend', 'purple hold end');
case 1:
animation.addByPrefix('scroll', 'blue0');
animation.addByPrefix('hold', 'blue hold piece');
@@ -278,30 +278,22 @@ class Note extends FlxSprite
public function updateSustain(strum:Strum) {
var scrollSpeed = strum.getScrollSpeed(this);
var len = 0.45 * CoolUtil.quantize(scrollSpeed, 100);
if (nextSustain != null && lastScrollSpeed != scrollSpeed) {
// is long sustain
if (lastScrollSpeed != scrollSpeed) {
lastScrollSpeed = scrollSpeed;
scale.y = (sustainLength * len) / frameHeight;
updateHitbox();
scale.y += gapFix / frameHeight;
if (nextSustain != null) {
scale.y = (sustainLength * 0.45 * scrollSpeed) / frameHeight;
updateHitbox();
scale.y += gapFix / frameHeight;
}
}
if (!wasGoodHit) return;
var t = FlxMath.bound((Conductor.songPosition - strumTime) / (height) * len, 0, 1);
var swagRect = this.clipRect == null ? new FlxRect() : this.clipRect;
swagRect.x = 0;
swagRect.y = t * frameHeight;
swagRect.width = frameWidth;
swagRect.height = frameHeight;
setClipRect(swagRect);
updateSustainClip();
}
public inline function setClipRect(rect:FlxRect) {
this.clipRect = rect;
public function updateSustainClip() if (wasGoodHit) {
var t = FlxMath.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1);
var rect = clipRect == null ? FlxRect.get() : clipRect;
clipRect = rect.set(0, frameHeight * t, frameWidth, frameHeight * (1 - t));
}
@:noCompletion
@@ -317,5 +309,7 @@ class Note extends FlxSprite
public override function destroy() {
super.destroy();
clipRect = FlxDestroyUtil.put(clipRect);
}
}
+2 -10
View File
@@ -1292,16 +1292,8 @@ class PlayState extends MusicBeatState
if (updateRatingStuff != null)
updateRatingStuff();
if (canAccessDebugMenus) {
if (chartingMode && FlxG.keys.justPressed.SEVEN) {
FlxG.switchState(new funkin.editors.charter.Charter(SONG.meta.name, difficulty, false));
}
if (FlxG.keys.justPressed.F5) {
Logs.trace('Reloading scripts...', WARNING, YELLOW);
scripts.reload();
Logs.trace('Song scripts successfully reloaded.', WARNING, GREEN);
}
}
if (canAccessDebugMenus && chartingMode && FlxG.keys.justPressed.SEVEN)
FlxG.switchState(new funkin.editors.charter.Charter(SONG.meta.name, difficulty, false));
if (Options.camZoomOnBeat && camZooming && FlxG.camera.zoom < maxCamZoom) {
var beat = Conductor.getBeats(camZoomingEvery, camZoomingInterval, camZoomingOffset);
+15 -4
View File
@@ -32,7 +32,7 @@ class Stage extends FlxBasic implements IBeatReceiver {
for (k=>e in stageSprites) script.set(k, e);
public function prepareInfos(node:Access)
return XMLImportedScriptInfo.prepareInfos(node, PlayState.instance.scripts, (infos) -> xmlImportedScripts.push(infos));
return XMLImportedScriptInfo.prepareInfos(node, PlayState.instance != null ? PlayState.instance.scripts : null, (infos) -> xmlImportedScripts.push(infos));
public function new(stage:String, ?state:FlxState) {
super();
@@ -93,17 +93,28 @@ class Stage extends FlxBasic implements IBeatReceiver {
case "box" | "solid":
if (!node.has.name || !node.has.width || !node.has.height) continue;
var spr = new FlxSprite(
var spr = new FunkinSprite(
(node.has.x) ? Std.parseFloat(node.att.x).getDefault(0) : 0,
(node.has.y) ? Std.parseFloat(node.att.y).getDefault(0) : 0
);
(node.name == "solid" ? spr.makeSolid : spr.makeGraphic)(
// just to make sure, its better to apply these before it gets inside of xmlUtil (because of mainly updateHitbox i guess), so im removing them before it gets passed - Nex
var toRemove = ["x", "y", "width", "height", "color"];
var isSolid = node.name == "solid";
(isSolid ? spr.makeSolid : spr.makeGraphic)(
Std.parseInt(node.att.width),
Std.parseInt(node.att.height),
(node.has.color) ? CoolUtil.getColorFromDynamic(node.att.color) : -1
);
if (isSolid) toRemove.push("updateHitbox"); // makesolid already calls updateHitbox - Nex
for (a in toRemove) node.x.remove(a);
XMLUtil.loadSpriteFromXML(spr, node, "", NONE, false);
if (!node.has.zoomfactor && PlayState.instance != null)
spr.initialZoom = PlayState.instance.defaultCamZoom;
stageSprites.set(node.getAtt("name"), spr);
state.add(spr);
spr;
@@ -318,4 +329,4 @@ typedef StageCharPosInfo = {
var y:Float;
var flip:Bool;
var scroll:Float;
}
}
+3 -2
View File
@@ -189,7 +189,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
if (cpu && __updateNote_event.__autoCPUHit && !daNote.avoid && !daNote.wasGoodHit && daNote.strumTime < __updateNote_songPos) PlayState.instance.goodNoteHit(this, daNote);
if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + (daNote.sustainLength) < __updateNote_songPos) {
if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + daNote.sustainLength < __updateNote_songPos) {
deleteNote(daNote);
return;
}
@@ -215,8 +215,9 @@ class StrumLine extends FlxTypedGroup<Strum> {
var __notePerStrum:Array<Note> = [];
function __inputProcessPressed(note:Note) {
if (__pressed[note.strumID] && note.isSustainNote && note.canBeHit && !note.wasGoodHit) {
if (__pressed[note.strumID] && note.isSustainNote && note.strumTime < __updateNote_songPos && !note.wasGoodHit) {
PlayState.instance.goodNoteHit(this, note);
note.updateSustainClip();
}
}
function __inputProcessJustPressed(note:Note) {
+2 -2
View File
@@ -234,7 +234,7 @@ class FreeplayState extends MusicBeatState
scoreText.x = coopText.x = scoreBG.x + 4;
diffText.x = Std.int(scoreBG.x + ((scoreBG.width - diffText.width) / 2));
interpColor.fpsLerpTo(songs[curSelected].parsedColor, 0.0625);
interpColor.fpsLerpTo(songs[curSelected].color, 0.0625);
bg.color = interpColor.color;
#if PRELOAD_ALL
@@ -456,4 +456,4 @@ class FreeplaySonglist {
return songList;
}
}
}
+46 -6
View File
@@ -69,12 +69,16 @@ class Options
public static var charterAutoSavesSeperateFolder:Bool = false;
/**
* PLAYER 1 CONTROLS
*/
* PLAYER 1 CONTROLS
*/
// Notes
public static var P1_NOTE_LEFT:Array<FlxKey> = [A];
public static var P1_NOTE_DOWN:Array<FlxKey> = [S];
public static var P1_NOTE_UP:Array<FlxKey> = [W];
public static var P1_NOTE_RIGHT:Array<FlxKey> = [D];
// Menus
public static var P1_LEFT:Array<FlxKey> = [A];
public static var P1_DOWN:Array<FlxKey> = [S];
public static var P1_UP:Array<FlxKey> = [W];
@@ -82,16 +86,28 @@ class Options
public static var P1_ACCEPT:Array<FlxKey> = [ENTER];
public static var P1_BACK:Array<FlxKey> = [BACKSPACE];
public static var P1_PAUSE:Array<FlxKey> = [ENTER];
// Misc
public static var P1_RESET:Array<FlxKey> = [R];
public static var P1_SWITCHMOD:Array<FlxKey> = [TAB];
public static var P1_VOLUME_UP:Array<FlxKey> = [];
public static var P1_VOLUME_DOWN:Array<FlxKey> = [];
public static var P1_VOLUME_MUTE:Array<FlxKey> = [];
// Debugs
public static var P1_DEBUG_RELOAD:Array<FlxKey> = [F5];
/**
* PLAYER 2 CONTROLS (ALT)
*/
* PLAYER 2 CONTROLS (ALT)
*/
// Notes
public static var P2_NOTE_LEFT:Array<FlxKey> = [LEFT];
public static var P2_NOTE_DOWN:Array<FlxKey> = [DOWN];
public static var P2_NOTE_UP:Array<FlxKey> = [UP];
public static var P2_NOTE_RIGHT:Array<FlxKey> = [RIGHT];
// Menus
public static var P2_LEFT:Array<FlxKey> = [LEFT];
public static var P2_DOWN:Array<FlxKey> = [DOWN];
public static var P2_UP:Array<FlxKey> = [UP];
@@ -99,16 +115,28 @@ class Options
public static var P2_ACCEPT:Array<FlxKey> = [SPACE];
public static var P2_BACK:Array<FlxKey> = [ESCAPE];
public static var P2_PAUSE:Array<FlxKey> = [ESCAPE];
// Misc
public static var P2_RESET:Array<FlxKey> = [];
public static var P2_SWITCHMOD:Array<FlxKey> = [];
public static var P2_VOLUME_UP:Array<FlxKey> = [NUMPADPLUS];
public static var P2_VOLUME_DOWN:Array<FlxKey> = [NUMPADMINUS];
public static var P2_VOLUME_MUTE:Array<FlxKey> = [NUMPADZERO];
// Debugs
public static var P2_DEBUG_RELOAD:Array<FlxKey> = [];
/**
* SOLO GETTERS
*/
* SOLO GETTERS
*/
// Notes
public static var SOLO_NOTE_LEFT(get, null):Array<FlxKey>;
public static var SOLO_NOTE_DOWN(get, null):Array<FlxKey>;
public static var SOLO_NOTE_UP(get, null):Array<FlxKey>;
public static var SOLO_NOTE_RIGHT(get, null):Array<FlxKey>;
// Menus
public static var SOLO_LEFT(get, null):Array<FlxKey>;
public static var SOLO_DOWN(get, null):Array<FlxKey>;
public static var SOLO_UP(get, null):Array<FlxKey>;
@@ -116,8 +144,16 @@ class Options
public static var SOLO_ACCEPT(get, null):Array<FlxKey>;
public static var SOLO_BACK(get, null):Array<FlxKey>;
public static var SOLO_PAUSE(get, null):Array<FlxKey>;
// Misc
public static var SOLO_RESET(get, null):Array<FlxKey>;
public static var SOLO_SWITCHMOD(get, null):Array<FlxKey>;
public static var SOLO_VOLUME_UP(get, null):Array<FlxKey>;
public static var SOLO_VOLUME_DOWN(get, null):Array<FlxKey>;
public static var SOLO_VOLUME_MUTE(get, null):Array<FlxKey>;
// Debugs
public static var SOLO_DEBUG_RELOAD(get, null):Array<FlxKey>;
public static function load() {
if (__save == null) __save = new FlxSave();
@@ -146,6 +182,10 @@ class Options
PlayerSettings.solo.setKeyboardScheme(Solo);
PlayerSettings.player1.setKeyboardScheme(Duo(true));
PlayerSettings.player2.setKeyboardScheme(Duo(false));
FlxG.sound.volumeUpKeys = SOLO_VOLUME_UP;
FlxG.sound.volumeDownKeys = SOLO_VOLUME_DOWN;
FlxG.sound.muteKeys = SOLO_VOLUME_MUTE;
}
public static function save() {
@@ -66,6 +66,23 @@ class KeybindsOptions extends MusicBeatSubstate {
},
]
},
{
name: 'Volume',
settings: [
{
name: 'Up',
control: 'VOLUME_UP'
},
{
name: 'Down',
control: 'VOLUME_DOWN'
},
{
name: 'Mute',
control: 'VOLUME_MUTE'
},
]
},
{
name: 'Engine',
settings: [
@@ -74,6 +91,15 @@ class KeybindsOptions extends MusicBeatSubstate {
control: 'SWITCHMOD'
},
]
},
{
name: 'DEBUG',
settings: [
{
name: 'Reload',
control: 'DEBUG_RELOAD'
},
]
}
];
@@ -162,6 +188,10 @@ class KeybindsOptions extends MusicBeatSubstate {
}
add(alphabets);
add(camFollow);
FlxG.sound.volumeUpKeys = [];
FlxG.sound.volumeDownKeys = [];
FlxG.sound.muteKeys = [];
}
public override function destroy() {