Bug 15: Refactor, improve and finish the Local Storage (Preferences) implementation of Storage api

This commit is contained in:
Robert Vokac 2024-09-14 11:08:58 +02:00
parent 57a17492c3
commit bf2cf7c046
No known key found for this signature in database
GPG Key ID: C459E1E4B4A986BB
2 changed files with 7 additions and 7 deletions

View File

@ -28,21 +28,21 @@ import com.pixelgamelibrary.api.storage.map.MapStorage;
*
* @author robertvokac
*/
public class WebGLStorage extends MapStorage {
public class PreferencesStorage extends MapStorage {
public Platform getPlatform() {
return Platform.WEB;
}
public WebGLStorage() {
public PreferencesStorage() {
this("pixel.libgdx.webGL.Local-Storage");
}
public WebGLStorage(String preferencesName) {
public PreferencesStorage(String preferencesName) {
this(Gdx.app.getPreferences(preferencesName));
}
public WebGLStorage(Preferences preferences) {
public PreferencesStorage(Preferences preferences) {
super(new SimpleLocalStorageMap(preferences));
}

View File

@ -39,8 +39,8 @@ public class StorageFactory {
public static Storage getStorage() {
final Platform platform = Pixel.app().getPlatform();
if (storage == null) {
storage = new MemoryStorage();
}
storage = new PreferencesStorage();
}//todo fixme
if (storage == null) {
if (platform.isDesktop()) {
@ -50,7 +50,7 @@ public class StorageFactory {
storage = new AndroidStorage();
}
if (platform.isWeb()) {
storage = new WebGLStorage();
storage = new PreferencesStorage();
}
}
if (storage == null) {