Skip to content

Commit

Permalink
FlxSave: Replace FlxSaveStatus.ERROR with SAVE_ERROR (#3294)
Browse files Browse the repository at this point in the history
* replace `FlxSaveStatus.ERROR` with SAVE_ERROR

* update changelog

* add link

* Add deprecated  ERROR back
  • Loading branch information
Geokureli authored Jan 30, 2025
1 parent 27a756b commit 2f5d24a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
6.0.0 (TBD)

#### 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 @@ -25,6 +25,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
- `FlxSave`: Deprecate and remove all uses of `FlxSaveStatus.ERROR` for `FlxSaveStatus.SAVE_ERROR` ([#3294](https://github.com/HaxeFlixel/flixel/pull/3294))

#### Changes and improvements:
- `FlxSpritegroup`: Setting `origin` now causes members to pivot around the same point ([#2981](https://github.com/HaxeFlixel/flixel/pull/2981))
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);
}

0 comments on commit 2f5d24a

Please sign in to comment.