diff --git a/WORK.md b/WORK.md index 48200c0..a3c613f 100644 --- a/WORK.md +++ b/WORK.md @@ -14,6 +14,7 @@ * game panel rework * game state: config, map, entities, players * game menu pack progress +* game save * balloons: change mute, network, pause * settings: mute, pause, reset device actions * game view: toggle panel on mobile diff --git a/src/client/haxe/ru/m/tankz/Init.hx b/src/client/haxe/ru/m/tankz/Init.hx index de1102b..546643d 100644 --- a/src/client/haxe/ru/m/tankz/Init.hx +++ b/src/client/haxe/ru/m/tankz/Init.hx @@ -20,10 +20,6 @@ import ru.m.tankz.bundle.IConfigBundle; import ru.m.tankz.bundle.ILevelBundle; import ru.m.tankz.proto.pack.Request; import ru.m.tankz.proto.pack.Response; -import ru.m.tankz.storage.GameStorage; -import ru.m.tankz.storage.NetworkStorage; -import ru.m.tankz.storage.RecordStorage; -import ru.m.tankz.storage.SettingsStorage; import ru.m.update.Updater; class Init { @@ -31,10 +27,6 @@ class Init { @:provide static var theme:ITheme; @:provide static var levelBundle:ILevelBundle; @:provide static var configBundle:IConfigBundle; - @:provide static var settingsStorage:SettingsStorage; - @:provide static var multiplayerStorage:NetworkStorage; - @:provide static var gameStorage:GameStorage; - @:provide static var recordStorage:RecordStorage; @:provide static var popupManager:PopupManager; @:provide static var connection:IConnection; @:provide static var bus:IControlBus; @@ -58,10 +50,6 @@ class Init { levelBundle = new CachedLevelBundle(new ClientLevelSource(), new SharedObjectStorage()); levelBundle.load(); configBundle = new ConfigBundle(); - settingsStorage = new SettingsStorage(); - multiplayerStorage = new NetworkStorage(); - gameStorage = new GameStorage(); - recordStorage = new RecordStorage(); popupManager.showAnimateFactory = function(v) return new UnFadeAnimate(v, 100); popupManager.closeAnimateFactory = function(v) return new FadeAnimate(v, 100); diff --git a/src/client/haxe/ru/m/tankz/storage/GameStorage.hx b/src/client/haxe/ru/m/tankz/storage/GameStorage.hx index 1a6cc9d..4d282ba 100644 --- a/src/client/haxe/ru/m/tankz/storage/GameStorage.hx +++ b/src/client/haxe/ru/m/tankz/storage/GameStorage.hx @@ -4,7 +4,7 @@ import haxework.storage.SharedObjectStorage; import ru.m.tankz.game.PackProgress; import ru.m.tankz.Type; -class GameStorage extends SharedObjectStorage { +@:provide class GameStorage extends SharedObjectStorage { private static inline var VERSION = 1; diff --git a/src/client/haxe/ru/m/tankz/storage/NetworkStorage.hx b/src/client/haxe/ru/m/tankz/storage/NetworkStorage.hx index cdd2016..8c3c4e4 100644 --- a/src/client/haxe/ru/m/tankz/storage/NetworkStorage.hx +++ b/src/client/haxe/ru/m/tankz/storage/NetworkStorage.hx @@ -2,7 +2,7 @@ package ru.m.tankz.storage; import haxework.storage.SharedObjectStorage; -class NetworkStorage extends SharedObjectStorage { +@:provide class NetworkStorage extends SharedObjectStorage { public var user(get, set):User; diff --git a/src/client/haxe/ru/m/tankz/storage/RecordStorage.hx b/src/client/haxe/ru/m/tankz/storage/RecordStorage.hx index 287d3e6..7f803fb 100644 --- a/src/client/haxe/ru/m/tankz/storage/RecordStorage.hx +++ b/src/client/haxe/ru/m/tankz/storage/RecordStorage.hx @@ -4,7 +4,7 @@ import haxe.DynamicAccess; import haxework.storage.SharedObjectStorage; import ru.m.tankz.game.record.GameRecord; -class RecordStorage extends SharedObjectStorage { +@:provide class RecordStorage extends SharedObjectStorage { private static inline var VERSION = 1; diff --git a/src/client/haxe/ru/m/tankz/storage/SettingsStorage.hx b/src/client/haxe/ru/m/tankz/storage/SettingsStorage.hx index 07fadbe..8921bd6 100644 --- a/src/client/haxe/ru/m/tankz/storage/SettingsStorage.hx +++ b/src/client/haxe/ru/m/tankz/storage/SettingsStorage.hx @@ -16,7 +16,7 @@ enum Setting { ENABLE_NETWORK(value:Bool); } -class SettingsStorage extends SharedObjectStorage { +@:provide class SettingsStorage extends SharedObjectStorage { private static inline var VERSION = 4.1; diff --git a/src/client/haxe/ru/m/tankz/view/common/PackView.hx b/src/client/haxe/ru/m/tankz/view/common/PackView.hx index 744e29f..57791d7 100644 --- a/src/client/haxe/ru/m/tankz/view/common/PackView.hx +++ b/src/client/haxe/ru/m/tankz/view/common/PackView.hx @@ -2,6 +2,8 @@ package ru.m.tankz.view.common; import haxework.view.form.LabelView; import haxework.view.group.VGroupView; +import ru.m.tankz.bundle.ILevelBundle; +import ru.m.tankz.storage.GameStorage; import ru.m.tankz.Type; using ru.m.tankz.view.ViewUtil; @@ -11,11 +13,18 @@ using ru.m.tankz.view.ViewUtil; public var data(default, set):PackId; @:view var label:LabelView; + @:view var state:LabelView; + + @:provide static var gameStorage:GameStorage; + @:provide static var levelBundle:ILevelBundle; private function set_data(value:PackId):PackId { if (data != value) { data = value; label.text = data.toPackLabel("\n"); + var progress = gameStorage.get(data).progress; + var total = levelBundle.get(data).data.length; + state.text = '${progress}/${total}'; } return data; } diff --git a/src/client/haxe/ru/m/tankz/view/common/PackView.yaml b/src/client/haxe/ru/m/tankz/view/common/PackView.yaml index 91917e7..ef2bab5 100644 --- a/src/client/haxe/ru/m/tankz/view/common/PackView.yaml +++ b/src/client/haxe/ru/m/tankz/view/common/PackView.yaml @@ -11,3 +11,5 @@ views: - id: label $type: haxework.view.form.LabelView font.size: 22 + - id: state + $type: haxework.view.form.LabelView diff --git a/src/common/haxe/ru/m/tankz/game/PackProgress.hx b/src/common/haxe/ru/m/tankz/game/PackProgress.hx index 5484446..10a3167 100644 --- a/src/common/haxe/ru/m/tankz/game/PackProgress.hx +++ b/src/common/haxe/ru/m/tankz/game/PackProgress.hx @@ -17,6 +17,18 @@ class PackProgress { private var completed(default, null):Map; + public var progress(get, null):Int; + + private function get_progress():Int { + var result = -1; + for (i in completed.keys()) { + if (i > result) { + result = i; + } + } + return result + 1; + } + public function new(id:PackId) { this.id = id; this.completed = new Map(); diff --git a/src/editor/haxe/ru/m/tankz/editor/Editor.hx b/src/editor/haxe/ru/m/tankz/editor/Editor.hx index 961d6da..ce68a11 100644 --- a/src/editor/haxe/ru/m/tankz/editor/Editor.hx +++ b/src/editor/haxe/ru/m/tankz/editor/Editor.hx @@ -18,7 +18,6 @@ class Editor { @:provide static var resources:IResources; @:provide static var theme:ITheme; @:provide static var switcher:FrameSwitcher; - @:provide static var storage:EditorStorage; @:provide static var configBundle:IConfigBundle; @:provide static var levelBundle:ILevelBundle; @@ -39,7 +38,6 @@ class Editor { theme = new AppTheme(); configBundle = new ConfigBundle(); levelBundle = new CachedLevelBundle(new ClientLevelSource()); - storage = new EditorStorage(); var view = new EditorView(); Root.bind(view); diff --git a/src/editor/haxe/ru/m/tankz/editor/EditorStorage.hx b/src/editor/haxe/ru/m/tankz/editor/EditorStorage.hx index 44ee2b1..28b3f58 100644 --- a/src/editor/haxe/ru/m/tankz/editor/EditorStorage.hx +++ b/src/editor/haxe/ru/m/tankz/editor/EditorStorage.hx @@ -4,7 +4,7 @@ import haxe.DynamicAccess; import haxework.storage.SharedObjectStorage; import ru.m.tankz.config.Config; -class EditorStorage extends SharedObjectStorage { +@:provide class EditorStorage extends SharedObjectStorage { private static inline var VERSION = 2; public function new() {