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

Save overhaul #2584

Merged
merged 22 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
- `WatchFrontEnd`: added `FlxG.watch.addFunction` ([#2500](https://github.com/HaxeFlixel/flixel/pull/2500))
- `FlxPoint`: added binary operators `+`, `-`, `+=`, `-=`, `*`, and `*=` ([#2557](https://github.com/HaxeFlixel/flixel/pull/2557))
- `FlxColor`: added `rgb` getter and setter ([#2555](https://github.com/HaxeFlixel/flixel/pull/2555))
- `FlxSave`: added `migrateDataFrom`, `status` and `isBound` ([#2566](https://github.com/HaxeFlixel/flixel/pull/2566))
- `FlxSave`: added `mergeDataFrom`, `mergeData` `status`, `isBound` and `isEmpty`
([#2566](https://github.com/HaxeFlixel/flixel/pull/2566))
([#2584](https://github.com/HaxeFlixel/flixel/pull/2584))

#### Bugfixes:

Expand Down
28 changes: 5 additions & 23 deletions flixel/FlxG.hx
Original file line number Diff line number Diff line change
Expand Up @@ -668,30 +668,12 @@ class FlxG
if (save.isBound)
return;

// Use Project.xml data to determine save id
var meta = stage.application.meta;
var name = meta["file"];
var path:String = null;

// replace invalid characters with hyphens
var invalidChars = ~/[ ~%&\\;:"',<>?#]/;
name = invalidChars.split(name).join("-");

#if !flash
// On most browsers using the full URL path often causes a new save path to be created
// every time a new version of the game is updated. Especially on portals like Newgrounds.
// just set the path to your company name, to ensure a unique storage id.
path = meta["company"];
if (path == null || path == "")
path = "HaxeFlixel";
else
path = invalidChars.split(path).join("-");
#end

// Create a save based on project metadata (since 5.0.0).
// Use Project.xml data to determine save id (since 5.0.0).
final name = stage.application.meta["file"];
save.bind(FlxSave.validate(name));
// look for the pre 5.0 save and convert it if it exists.
save.bind(name, path);
save.migrateDataFrom("flixel");
if (save.isEmpty())
save.mergeDataFrom("flixel", null, false, false);
}

/**
Expand Down
Loading