[refactoring] restore GameStorage
This commit is contained in:
@@ -9,6 +9,7 @@ import ru.m.puzzlez.settings.Settings;
|
|||||||
import ru.m.puzzlez.source.AssetImageSource;
|
import ru.m.puzzlez.source.AssetImageSource;
|
||||||
import ru.m.puzzlez.source.FileImageSource;
|
import ru.m.puzzlez.source.FileImageSource;
|
||||||
import ru.m.puzzlez.source.PixabayImageSource;
|
import ru.m.puzzlez.source.PixabayImageSource;
|
||||||
|
import ru.m.puzzlez.storage.GameStorage;
|
||||||
import ru.m.puzzlez.view.PuzzlezAppView;
|
import ru.m.puzzlez.view.PuzzlezAppView;
|
||||||
import ru.m.update.Updater;
|
import ru.m.update.Updater;
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ class PuzzlezApp {
|
|||||||
// ToDo: fix @:provide macro
|
// ToDo: fix @:provide macro
|
||||||
Settings;
|
Settings;
|
||||||
IPartBuilder;
|
IPartBuilder;
|
||||||
|
GameStorage;
|
||||||
sourceBundle.register(new AssetImageSource());
|
sourceBundle.register(new AssetImageSource());
|
||||||
sourceBundle.register(new FileImageSource());
|
sourceBundle.register(new FileImageSource());
|
||||||
sourceBundle.register(new PixabayImageSource());
|
sourceBundle.register(new PixabayImageSource());
|
||||||
|
|||||||
@@ -160,12 +160,12 @@ class Render extends SpriteView implements IRender {
|
|||||||
content.graphics.drawRect(0, 0, width, height);
|
content.graphics.drawRect(0, 0, width, height);
|
||||||
content.graphics.endFill();
|
content.graphics.endFill();
|
||||||
case Background.IMAGE(id):
|
case Background.IMAGE(id):
|
||||||
/*imageStorage.resolve(id).then(result -> {
|
ImageData.fromImageId(id).resolve().then(result -> {
|
||||||
content.graphics.clear();
|
content.graphics.clear();
|
||||||
content.graphics.beginBitmapFill(result);
|
content.graphics.beginBitmapFill(result);
|
||||||
content.graphics.drawRect(0, 0, width, height);
|
content.graphics.drawRect(0, 0, width, height);
|
||||||
content.graphics.endFill();
|
content.graphics.endFill();
|
||||||
});*/
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import hw.view.popup.ConfirmView;
|
|||||||
import promhx.Promise;
|
import promhx.Promise;
|
||||||
import ru.m.puzzlez.image.Game;
|
import ru.m.puzzlez.image.Game;
|
||||||
import ru.m.puzzlez.image.IGame;
|
import ru.m.puzzlez.image.IGame;
|
||||||
//import ru.m.puzzlez.net.NetworkGame;
|
|
||||||
import ru.m.puzzlez.proto.event.GameEvent;
|
import ru.m.puzzlez.proto.event.GameEvent;
|
||||||
import ru.m.puzzlez.proto.game.GameState;
|
import ru.m.puzzlez.proto.game.GameState;
|
||||||
import ru.m.puzzlez.proto.game.GameStatus;
|
import ru.m.puzzlez.proto.game.GameStatus;
|
||||||
import ru.m.puzzlez.render.IRender;
|
import ru.m.puzzlez.render.IRender;
|
||||||
import ru.m.puzzlez.settings.Settings;
|
import ru.m.puzzlez.settings.Settings;
|
||||||
|
import ru.m.puzzlez.storage.GameStorage;
|
||||||
import ru.m.puzzlez.view.popup.BackgroundPopup;
|
import ru.m.puzzlez.view.popup.BackgroundPopup;
|
||||||
import ru.m.puzzlez.view.popup.PreviewPopup;
|
import ru.m.puzzlez.view.popup.PreviewPopup;
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ import ru.m.puzzlez.view.popup.PreviewPopup;
|
|||||||
@:view private var render:IRender;
|
@:view private var render:IRender;
|
||||||
private var game:IGame;
|
private var game:IGame;
|
||||||
@:provide var switcher:FrameSwitcher;
|
@:provide var switcher:FrameSwitcher;
|
||||||
// @:provide var storage:GameStorage;
|
@:provide var storage:GameStorage;
|
||||||
@:provide var settings:Settings;
|
@:provide var settings:Settings;
|
||||||
|
|
||||||
private var saveTimer:Timer;
|
private var saveTimer:Timer;
|
||||||
@@ -68,7 +68,7 @@ import ru.m.puzzlez.view.popup.PreviewPopup;
|
|||||||
saveTimer = null;
|
saveTimer = null;
|
||||||
}
|
}
|
||||||
if (game != null) {
|
if (game != null) {
|
||||||
// storage.save(game.state);
|
storage.save(game.state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,6 @@ import ru.m.puzzlez.view.popup.PreviewPopup;
|
|||||||
.then(result -> {
|
.then(result -> {
|
||||||
if (result) {
|
if (result) {
|
||||||
switcher.change(StartFrame.ID);
|
switcher.change(StartFrame.ID);
|
||||||
// switcher.change(ImageListFrame.ID, storage.statusSource(game.state.status));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package ru.m.puzzlez.view;
|
package ru.m.puzzlez.view;
|
||||||
|
|
||||||
|
import ru.m.puzzlez.storage.GameStorage;
|
||||||
import hw.view.form.LabelView;
|
import hw.view.form.LabelView;
|
||||||
import hw.view.frame.FrameSwitcher;
|
import hw.view.frame.FrameSwitcher;
|
||||||
import hw.view.frame.FrameView;
|
import hw.view.frame.FrameView;
|
||||||
@@ -21,6 +22,7 @@ typedef ImageSourceConfig = {
|
|||||||
@:view var images:ImageDataList;
|
@:view var images:ImageDataList;
|
||||||
@:provide var switcher:FrameSwitcher;
|
@:provide var switcher:FrameSwitcher;
|
||||||
@:provide var sourceBundle:ImageSourceBundle;
|
@:provide var sourceBundle:ImageSourceBundle;
|
||||||
|
@:provide var gameStorage:GameStorage;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super(ID);
|
super(ID);
|
||||||
@@ -37,7 +39,13 @@ typedef ImageSourceConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function start(imageId:ImageId):Void {
|
private function start(imageId:ImageId):Void {
|
||||||
switcher.change(PresetFrame.ID, imageId);
|
gameStorage.get(imageId).then(state -> {
|
||||||
|
if (state != null) {
|
||||||
|
switcher.change(GameFrame.ID, state);
|
||||||
|
} else {
|
||||||
|
switcher.change(PresetFrame.ID, imageId);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function back():Void {
|
private function back():Void {
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
package ru.m.puzzlez.view.common;
|
package ru.m.puzzlez.view.common;
|
||||||
|
|
||||||
import hw.view.utils.DrawUtil;
|
import hw.view.group.GroupView;
|
||||||
import hw.view.ImageView;
|
import hw.view.ImageView;
|
||||||
import ru.m.puzzlez.image.ImageData;
|
import ru.m.puzzlez.image.ImageData;
|
||||||
import ru.m.puzzlez.proto.game.ImageId;
|
import ru.m.puzzlez.proto.game.ImageId;
|
||||||
|
|
||||||
class ImageIdView extends ImageView {
|
@:template class ImageIdView extends GroupView {
|
||||||
public var imageId(default, set):ImageId;
|
public var imageId(default, set):ImageId;
|
||||||
|
|
||||||
private function set_imageId(value:ImageId):ImageId {
|
private function set_imageId(value:ImageId):ImageId {
|
||||||
imageId = value;
|
imageId = value;
|
||||||
ImageData.fromImageId(imageId).resolve().then(data -> this.image = data);
|
loading.promise = ImageData.fromImageId(imageId).resolve().then(data -> this.imageView.image = data);
|
||||||
return imageId;
|
return imageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@:view("image") var imageView:ImageView;
|
||||||
|
private var loading:LoadingWrapper;
|
||||||
|
|
||||||
public function new(imageId:ImageId = null) {
|
public function new(imageId:ImageId = null) {
|
||||||
super();
|
super();
|
||||||
style = "view";
|
loading = new LoadingWrapper(this);
|
||||||
stretch = false;
|
|
||||||
fillType = FillType.COVER;
|
|
||||||
if (imageId != null) {
|
if (imageId != null) {
|
||||||
this.imageId = imageId;
|
this.imageId = imageId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class DefaultHelper implements DataHelper<Bytes, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function dataMeta(data:Bytes):DataMeta {
|
public function dataMeta(data:Bytes):DataMeta {
|
||||||
return ["date" => Date.now().toString()];
|
return ["date" => Date.now()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user