[client] add PausePopup

This commit is contained in:
2019-10-30 22:16:06 +03:00
parent fffb6a3214
commit 70e6565e1f
9 changed files with 6077 additions and 7304 deletions

1
.gitignore vendored
View File

@@ -13,3 +13,4 @@ config.json
/node_modules
/log
/ansible/*.retry
.npmrc

13294
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -152,6 +152,7 @@ class AppTheme extends Theme {
registerButton("start", "play-circle-solid.svg");
registerButton("login", "sign-in-solid.svg");
registerButton("logout", "sign-out-solid.svg");
registerButton("bars", "bars-solid.svg");
registerButton("keyboard", "keyboard-light.svg", true);
registerButton("backspace", "backspace-light.svg", true);

View File

@@ -1,5 +1,6 @@
package ru.m.tankz.view;
import ru.m.tankz.view.popup.PausePopup;
import flash.ui.Keyboard;
import ru.m.control.DeviceAction;
import haxework.view.frame.FrameSwitcher;
@@ -112,6 +113,19 @@ import ru.m.tankz.view.gamepad.GamepadView;
var tankConfig = game.config.getTank(info.type);
gamepad.weapons = tankConfig.weapons;
}
case PAUSE(paused):
if (paused) {
PausePopup.instance.show().then(function(action) {
switch action {
case EXIT:
switcher.change(LevelFrame.ID, game.level.packId);
case RESUME | null:
game.pause = false;
}
});
} else {
PausePopup.instance.close(null);
}
case COMPLETE(result):
stop();
switcher.change(ResultFrame.ID, result);
@@ -127,8 +141,4 @@ import ru.m.tankz.view.gamepad.GamepadView;
gameView = null;
}
}
public function close():Void {
switcher.change(LevelFrame.ID, game.level.packId);
}
}

View File

@@ -13,9 +13,9 @@ views:
geometry.stretch: true
visible: false
- $type: haxework.view.form.ButtonView
style: button.close
style: button.bars
geometry.position: absolute
geometry.hAlign: left
geometry.vAlign: top
geometry.margin: 10
+onPress: ~close()
+onPress: ~function(_) game.pause = true

View File

@@ -6,7 +6,7 @@ import haxework.view.popup.PopupView;
import haxework.view.text.TextView;
import ru.m.tankz.network.NetworkManager;
@:template class LoginPopup extends PopupView<User> {
@:singleton @:template class LoginPopup extends PopupView<User> {
@:view var username:InputView;
@:view var password:InputView;
@@ -35,13 +35,4 @@ import ru.m.tankz.network.NetworkManager;
private function submit():Void {
network.login(username.text);
}
public static var instance(get, null):LoginPopup;
private static function get_instance():LoginPopup {
if (instance == null) {
instance = new LoginPopup();
}
return instance;
}
}

View File

@@ -0,0 +1,12 @@
package ru.m.tankz.view.popup;
import haxework.view.popup.PopupView;
enum Action {
RESUME;
EXIT;
}
@:singleton @:template class PausePopup extends PopupView<Action> {
}

View File

@@ -0,0 +1,39 @@
---
layout.hAlign: center
layout.vAlign: middle
view:
$type: haxework.view.group.VGroupView
layout.hAlign: center
geometry.width: 400
# geometry.height: 400
style: window
views:
- $type: haxework.view.group.HGroupView
geometry.width: 100%
geometry.padding: 10
layout.vAlign: middle
views:
- id: name
$type: haxework.view.form.LabelView
geometry.width: 100%
geometry.margin.left: 10
layout.hAlign: left
style: text
text: Pause
- $type: haxework.view.form.ButtonView
style: window.close
+onPress: ~reject('close')
- $type: haxework.view.group.VGroupView
geometry.width: 100%
# geometry.stretch: true
geometry.padding: 20
layout.margin: 5
views:
- $type: haxework.view.form.ButtonView
geometry.width: 100%
text: Resume
+onPress: ~close(RESUME)
- $type: haxework.view.form.ButtonView
geometry.width: 100%
text: Exit
+onPress: ~close(EXIT)

View File

@@ -0,0 +1 @@
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="bars" class="svg-inline--fa fa-bars fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"></path></svg>

After

Width:  |  Height:  |  Size: 569 B