flixel icon indicating copy to clipboard operation
flixel copied to clipboard

Why is `FlxSave.validate` private?

Open DetectiveBaldi opened this issue 1 year ago • 4 comments

FlxSave.validate and FlxSave.validateAndWarn are not public functions. Is there a reason for this? The requirement of needing a @:privateAccess call seems unnecessary.

Fields such as invalidChars are also private, this could be avoided by making the setter null.

DetectiveBaldi avatar Mar 04 '24 23:03 DetectiveBaldi

if we make validate public, it should be renamed to something less vague like validateSavePath (keep and deprecate the old private func too in case anyone was using @:privateAccess, and rather than making invalidChars read only, lets add a public isValidSavePath().

Geokureli avatar Mar 05 '24 15:03 Geokureli

Also if you're calling save.bind() with a custom path, there's a good chance you're doing something wrong. The preferred way of using a custom save path is to change the title and company fields in your project.xml's app node. Can you talk about why you need this?

Geokureli avatar Mar 05 '24 15:03 Geokureli

Also if you're calling save.bind() with a custom path, there's a good chance you're doing something wrong. The preferred way of using a custom save path is to change the title and company fields in your project.xml's app node. Can you talk about why you need this?

I'm making a syetem where the player can select multiple saves, or have the ability to create new ones while also being able to change their name, I want to validate the name inputted to make sure it's valid

DetectiveBaldi avatar Mar 05 '24 18:03 DetectiveBaldi

what about having multiple save slots under one actual save? pretty sure you can use a Maps in FlxSave or if not, can use DynamicAccess, example:

final data:DynamicAccess<{score:Int, levelsCompleted:Int}> = cast FlxG.save.data;
if (data.exists(saveSlotName))
{
    final slotData = data.get(saveSlotName);
    trace('score: ${slotData.score}, levels completed: ${slotData.levelsCompleted}');
}
else
{
    data.set(saveSlotName, { score: 0, levelsCompleted:0 });
    trace('No existing slot named "$saveSlotName", creating new one');
    FlxG.save.data.flush();
}

Geokureli avatar Mar 05 '24 18:03 Geokureli