Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is FlxSave.validate private? #3058

Open
DetectiveBaldi opened this issue Mar 4, 2024 · 4 comments
Open

Why is FlxSave.validate private? #3058

DetectiveBaldi opened this issue Mar 4, 2024 · 4 comments

Comments

@DetectiveBaldi
Copy link
Contributor

DetectiveBaldi commented Mar 4, 2024

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.

@Geokureli
Copy link
Member

Geokureli commented Mar 5, 2024

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
Copy link
Member

Geokureli commented Mar 5, 2024

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?

@DetectiveBaldi
Copy link
Contributor Author

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

@Geokureli
Copy link
Member

Geokureli commented Mar 5, 2024

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();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants