From 01c87c98b84a974c4e9c8835f5c0daed706de53d Mon Sep 17 00:00:00 2001 From: George FunBook Date: Mon, 25 Nov 2024 11:04:10 -0600 Subject: [PATCH 1/4] replace `FlxSaveStatus.ERROR` with SAVE_ERROR --- flixel/util/FlxSave.hx | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/flixel/util/FlxSave.hx b/flixel/util/FlxSave.hx index 629e9f3e2e..e40073ca7a 100644 --- a/flixel/util/FlxSave.hx +++ b/flixel/util/FlxSave.hx @@ -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; @@ -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(); @@ -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(); @@ -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)): @@ -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 { /** @@ -756,7 +766,7 @@ enum FlxSaveStatus /** * There was an issue during `flush` */ - ERROR(msg:String); + SAVE_ERROR(type:SaveFailureType); /** * There was an issue while loading From ab76af634a4142f450e6b1cbd8270934346cedac Mon Sep 17 00:00:00 2001 From: George FunBook Date: Mon, 25 Nov 2024 11:13:56 -0600 Subject: [PATCH 2/4] update changelog --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f45ed1bd13..af1f5b562e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 5.9.0 (TBD) ------------------------------ From 28433e9b794ffcae449e15328d4199b8ce0ca25b Mon Sep 17 00:00:00 2001 From: George FunBook Date: Mon, 25 Nov 2024 11:14:58 -0600 Subject: [PATCH 3/4] add link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af1f5b562e..d122b752fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ We removed many features and utilities that were previously deprecated - `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 +- `FlxSaveStatus.ERROR`: Use `FlxSaveStatus.SAVE_ERROR`, instead ([#3294](https://github.com/HaxeFlixel/flixel/pull/3294)) 5.9.0 (TBD) ------------------------------ From 6b91451010a2ffbb94b84f499deb79e5fb739603 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Tue, 26 Nov 2024 11:57:55 -0600 Subject: [PATCH 4/4] Add deprecated ERROR back --- flixel/util/FlxSave.hx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flixel/util/FlxSave.hx b/flixel/util/FlxSave.hx index e40073ca7a..e364f26e08 100644 --- a/flixel/util/FlxSave.hx +++ b/flixel/util/FlxSave.hx @@ -764,7 +764,7 @@ 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)` */ SAVE_ERROR(type:SaveFailureType); @@ -772,4 +772,8 @@ enum FlxSaveStatus * 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); }