From cef46b62518b22d38f3e01cc1ec37bd2e9d4bdf4 Mon Sep 17 00:00:00 2001 From: shmyga Date: Fri, 21 Feb 2020 20:18:38 +0300 Subject: [PATCH] [update] background choiser update --- src/haxe/ru/m/puzzlez/view/BackgroundPopup.hx | 23 +++++++ .../ru/m/puzzlez/view/BackgroundPopup.yaml | 61 +++++++++++++++++++ src/haxe/ru/m/puzzlez/view/GameFrame.hx | 8 +-- src/haxe/ru/m/view/ColorPopup.hx | 13 ---- src/haxe/ru/m/view/ColorPopup.yaml | 28 --------- 5 files changed, 87 insertions(+), 46 deletions(-) create mode 100644 src/haxe/ru/m/puzzlez/view/BackgroundPopup.hx create mode 100644 src/haxe/ru/m/puzzlez/view/BackgroundPopup.yaml delete mode 100644 src/haxe/ru/m/view/ColorPopup.hx delete mode 100644 src/haxe/ru/m/view/ColorPopup.yaml diff --git a/src/haxe/ru/m/puzzlez/view/BackgroundPopup.hx b/src/haxe/ru/m/puzzlez/view/BackgroundPopup.hx new file mode 100644 index 0000000..bc81764 --- /dev/null +++ b/src/haxe/ru/m/puzzlez/view/BackgroundPopup.hx @@ -0,0 +1,23 @@ +package ru.m.puzzlez.view; + +import haxework.view.skin.ButtonColorSkin; +import haxework.view.form.ButtonView; +import haxework.color.Color; +import haxework.view.popup.PopupView; +import promhx.Promise; +import ru.m.puzzlez.render.Background; + +@:template class BackgroundPopup extends PopupView { + + private function colorButtonFactory(index:Int, color:Color):ButtonView { + var result = new ButtonView(); + result.text = " "; + result.skin = new ButtonColorSkin(color); + return result; + } + + public static function choise(message:String = null):Promise { + var result = new BackgroundPopup(); + return result.show(); + } +} diff --git a/src/haxe/ru/m/puzzlez/view/BackgroundPopup.yaml b/src/haxe/ru/m/puzzlez/view/BackgroundPopup.yaml new file mode 100644 index 0000000..14e35b9 --- /dev/null +++ b/src/haxe/ru/m/puzzlez/view/BackgroundPopup.yaml @@ -0,0 +1,61 @@ +--- +view: + $type: haxework.view.group.VGroupView + geometry.width: 400 + geometry.height: 200 + geometry.padding: 10 + geometry.hAlign: center + geometry.vAlign: middle + layout.margin: 10 + style: frame + views: + - $type: haxework.view.group.HGroupView + geometry.width: 100% + layout.margin: 10 + views: + - id: header + text: Choise background + $type: haxework.view.form.LabelView + - $type: haxework.view.group.HGroupView + geometry.width: 100% + views: + - $type: haxework.view.form.ButtonView + text: Default + +onPress: ~close(NONE) + - $type: haxework.view.data.DataView + factory: ~colorButtonFactory + geometry.width: 100% + layout: + $type: haxework.view.layout.TailLayout + margin: 5 + data: + - '#FFFFFF' + - '#001f3f' + - '#0074D9' + - '#7FDBFF' + - '#39CCCC' + - '#3D9970' + - '#2ECC40' + - '#01FF70' + - '#FFDC00' + - '#FF851B' + - '#FF4136' + - '#85144b' + - '#F012BE' + - '#B10DC9' + - '#111111' + - '#AAAAAA' + - '#DDDDDD' + +onDataSelect: ~(color) -> close(COLOR(color)) + - id: image + $type: ru.m.view.ColorView + +onSelect: ~function(color) close(COLOR(color)) + - $type: haxework.view.group.HGroupView + geometry.width: 100% + layout.hAlign: center + layout.margin: 10 + views: + - $type: haxework.view.form.ButtonView + text: OK + +onPress: ~reject('ok') + visible: false diff --git a/src/haxe/ru/m/puzzlez/view/GameFrame.hx b/src/haxe/ru/m/puzzlez/view/GameFrame.hx index 9eaa2b7..e32f6e8 100644 --- a/src/haxe/ru/m/puzzlez/view/GameFrame.hx +++ b/src/haxe/ru/m/puzzlez/view/GameFrame.hx @@ -1,7 +1,6 @@ package ru.m.puzzlez.view; import haxe.Timer; -import haxework.color.Color; import haxework.view.frame.FrameSwitcher; import haxework.view.frame.FrameView; import ru.m.puzzlez.core.Game; @@ -12,7 +11,6 @@ import ru.m.puzzlez.render.Background; import ru.m.puzzlez.render.IRender; import ru.m.puzzlez.storage.GameStorage; import ru.m.puzzlez.storage.SettingsStorage; -import ru.m.view.ColorPopup; @:template class GameFrame extends FrameView { public static var ID = "game"; @@ -75,9 +73,9 @@ import ru.m.view.ColorPopup; } private function choiseBackground():Void { - ColorPopup.choise().then((color:Null) -> { - if (color != null) { - settings.background = COLOR(color); + BackgroundPopup.choise().then((background:Null) -> { + if (background != null) { + settings.background = background; render.toRedraw(); } }); diff --git a/src/haxe/ru/m/view/ColorPopup.hx b/src/haxe/ru/m/view/ColorPopup.hx deleted file mode 100644 index 070cab4..0000000 --- a/src/haxe/ru/m/view/ColorPopup.hx +++ /dev/null @@ -1,13 +0,0 @@ -package ru.m.view; - -import promhx.Promise; -import haxework.color.Color; -import haxework.view.popup.PopupView; - -@:template class ColorPopup extends PopupView { - - public static function choise(message:String = null):Promise { - var result = new ColorPopup(); - return result.show(); - } -} diff --git a/src/haxe/ru/m/view/ColorPopup.yaml b/src/haxe/ru/m/view/ColorPopup.yaml deleted file mode 100644 index 4968396..0000000 --- a/src/haxe/ru/m/view/ColorPopup.yaml +++ /dev/null @@ -1,28 +0,0 @@ ---- -view: - $type: haxework.view.group.VGroupView - geometry.width: 400 - geometry.height: 200 - geometry.padding: 10 - geometry.hAlign: center - geometry.vAlign: middle - style: frame - views: - - $type: haxework.view.group.HGroupView - geometry.width: 100% - layout.margin: 10 - views: - - id: header - $type: haxework.view.form.LabelView - - id: image - $type: ru.m.view.ColorView - +onSelect: ~close - - $type: haxework.view.group.HGroupView - geometry.width: 100% - layout.hAlign: center - layout.margin: 10 - views: - - $type: haxework.view.form.ButtonView - text: OK - +onPress: ~close('ok') - visible: false