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

FlxSave: Replace FlxSaveStatus.ERROR with SAVE_ERROR #3294

Open
wants to merge 4 commits into
base: release6
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
#### Changes and improvements:
- `FlxSpritegroup`: Setting `origin` now causes members to pivot around the same point ([#2981](https://github.com/HaxeFlixel/flixel/pull/2981))
- `FlxCamera`: Smoother camera lerping, particularly with non-fixed timesteps ([#2922](https://github.com/HaxeFlixel/flixel/pull/2922))
- `FlxState`: Removed deprecated `switchTo` ([#2733](https://github.com/HaxeFlixel/flixel/pull/2733))
- `FlxG`: Added deprecation warning on `switchState` with instances ([#2733](https://github.com/HaxeFlixel/flixel/pull/2733))
- `FlxCamera`: Removed `defaultCameras`
- `FlxCamera`: Fixed `zoom` and `defaultZoom` so it works with values other than 1.0 ([#2907](https://github.com/HaxeFlixel/flixel/pull/2907))
- `FlxBasic`: Added `getDefaultCamera`, used in nearly all methods taking an optional `camera` arg ([#3072](https://github.com/HaxeFlixel/flixel/pull/3072))

#### Removals
#### Removals and Breaking Changes
We removed many features and utilities that were previously deprecated
- `flixel.util.FlxPath`: New package, `flixel.path.FlxPath`
- `FlxSwipe::angle`: Use `FlxSwipe.degrees`, instead
Expand All @@ -34,6 +32,9 @@ We removed many features and utilities that were previously deprecated
- `FlxAssets.FlxAngelCodeSource`: Use `FlxAssets.FlxAngelCodeAsset`, instead
- `FlxAssets.FlxTexturePackerSource`: Use `FlxTexturePackerJsonAsset`, instead
- `FlxUnicodeUtil`: Use `UnicodeString`, instead
- `FlxState::switchTo`: Use `startOutro`, instead ([#2733](https://github.com/HaxeFlixel/flixel/pull/2733))
- `FlxCamera.defaultCameras`: Use `FlxG.cameras.setDefaultDrawTarget`, instead
- `FlxSaveStatus.ERROR`: Use `FlxSaveStatus.SAVE_ERROR`, instead ([#3294](https://github.com/HaxeFlixel/flixel/pull/3294))

5.9.0 (TBD)
------------------------------
Expand Down
34 changes: 24 additions & 10 deletions flixel/util/FlxSave.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package flixel.util;

import flixel.util.FlxDestroyUtil.IFlxDestroyable;
import haxe.Exception;
import openfl.errors.Error;
import openfl.net.SharedObject;
import openfl.net.SharedObjectFlushStatus;

Expand Down Expand Up @@ -211,7 +210,7 @@ class FlxSave implements IFlxDestroyable
return false;
}
}
catch (e:Error)
catch (e)
{
FlxG.log.error('Error:${e.message} name:"$name", path:"$path".');
destroy();
Expand Down Expand Up @@ -308,14 +307,14 @@ class FlxSave implements IFlxDestroyable

try
{
var result = _sharedObject.flush(minFileSize);
final result = _sharedObject.flush(minFileSize);

if (result != FLUSHED)
status = ERROR("FlxSave is requesting extra storage space.");
status = SAVE_ERROR(STORAGE);
}
catch (e:Error)
catch (e)
{
status = ERROR("There was an problem flushing the save data.");
status = SAVE_ERROR(ENCODING(e));
}

checkStatus();
Expand Down Expand Up @@ -353,8 +352,10 @@ class FlxSave implements IFlxDestroyable
return true;
case EMPTY:
FlxG.log.warn("You must call save.bind() before you can read or write data.");
case ERROR(msg):
FlxG.log.error(msg);
case SAVE_ERROR(STORAGE):
FlxG.log.error("FlxSave is requesting extra storage space");
case SAVE_ERROR(ENCODING(e)):
FlxG.log.error('There was an problem encoding the save data: ${e.message}');
case LOAD_ERROR(IO(e)):
FlxG.log.error('IO ERROR: ${e.message}');
case LOAD_ERROR(INVALID_NAME(name, reason)):
Expand Down Expand Up @@ -741,6 +742,15 @@ enum LoadFailureType
PARSING(rawData:String, exception:Exception);
}

enum SaveFailureType
{
/** FlxSave is requesting extra storage space **/
STORAGE;

/** There was an problem encoding the save data */
ENCODING(e:Exception);
}

enum FlxSaveStatus
{
/**
Expand All @@ -754,12 +764,16 @@ enum FlxSaveStatus
BOUND(name:String, ?path:String);

/**
* There was an issue during `flush`
* There was an issue during `flush`. Previously known as `ERROR(msg:String)`
*/
ERROR(msg:String);
SAVE_ERROR(type:SaveFailureType);

/**
* There was an issue while loading
*/
LOAD_ERROR(type:LoadFailureType);

@:noCompletion
@:deprecated("FlxSaveStatus.ERROR is never used, it has been replaced by SAVE_ERROR")
ERROR(msg:String);
}