[client] PackView progress
This commit is contained in:
1
WORK.md
1
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
|
||||
|
||||
@@ -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<Request, Response>;
|
||||
@: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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -11,3 +11,5 @@ views:
|
||||
- id: label
|
||||
$type: haxework.view.form.LabelView
|
||||
font.size: 22
|
||||
- id: state
|
||||
$type: haxework.view.form.LabelView
|
||||
|
||||
@@ -17,6 +17,18 @@ class PackProgress {
|
||||
|
||||
private var completed(default, null):Map<Int, LevelProgress>;
|
||||
|
||||
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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user