diff --git a/package.json b/package.json index 19338a5..9c18fe8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "puzzlez", - "version": "0.3.4", + "version": "0.3.5", "private": true, "devDependencies": { "dateformat": "^3.0.3", diff --git a/src/haxe/ru/m/puzzlez/PuzzlezTheme.hx b/src/haxe/ru/m/puzzlez/PuzzlezTheme.hx index bfa72ab..40340b9 100644 --- a/src/haxe/ru/m/puzzlez/PuzzlezTheme.hx +++ b/src/haxe/ru/m/puzzlez/PuzzlezTheme.hx @@ -33,10 +33,14 @@ class PuzzlezTheme extends Theme { "geometry.width" => SizeValue.fromInt(size), "geometry.height" => SizeValue.fromInt(size), "skin" => function() return new ButtonSVGSkin(), + "skin.color" => colors.light, ])); register(new Style("icon.close", [ "skin.svg" => Assets.getText("resources/image/icon/times-circle-solid.svg"), ])); + register(new Style("icon.setting", [ + "skin.svg" => Assets.getText("resources/image/icon/cog-solid.svg"), + ])); register(new Style("icon.small", [ "geometry.width" => SizeValue.fromInt(smallSize), "geometry.height" => SizeValue.fromInt(smallSize), diff --git a/src/haxe/ru/m/puzzlez/render/Render.hx b/src/haxe/ru/m/puzzlez/render/Render.hx index 12ec3e4..8d3cdc9 100644 --- a/src/haxe/ru/m/puzzlez/render/Render.hx +++ b/src/haxe/ru/m/puzzlez/render/Render.hx @@ -100,7 +100,7 @@ class Render extends SpriteView implements IRender { imageView.y = state.preset.imageRect.y; imageView.graphics.clear(); imageView.graphics.lineStyle(2, 0xCCCCCC); - imageView.graphics.beginFill(0x555555, 0.6); + imageView.graphics.beginFill(0x555555, 0.4); imageView.graphics.drawRect(0, 0, state.preset.imageRect.width, state.preset.imageRect.height); imageView.graphics.endFill(); imageView.graphics.lineStyle(); @@ -145,6 +145,12 @@ class Render extends SpriteView implements IRender { content.graphics.drawRect(0, 0, width, height); content.graphics.endFill(); case Background.IMAGE(id): + imageStorage.resolve(id).then(result -> { + content.graphics.clear(); + content.graphics.beginBitmapFill(result); + content.graphics.drawRect(0, 0, width, height); + content.graphics.endFill(); + }); } } diff --git a/src/haxe/ru/m/puzzlez/view/BackgroundPopup.hx b/src/haxe/ru/m/puzzlez/view/BackgroundPopup.hx index bc81764..854579f 100644 --- a/src/haxe/ru/m/puzzlez/view/BackgroundPopup.hx +++ b/src/haxe/ru/m/puzzlez/view/BackgroundPopup.hx @@ -1,23 +1,95 @@ package ru.m.puzzlez.view; -import haxework.view.skin.ButtonColorSkin; -import haxework.view.form.ButtonView; import haxework.color.Color; +import haxework.view.data.DataView; +import haxework.view.form.ButtonView; import haxework.view.popup.PopupView; +import haxework.view.skin.Skin; +import haxework.view.SpriteView; +import haxework.view.utils.DrawUtil; +import openfl.Assets; +import openfl.utils.AssetType; import promhx.Promise; +import ru.m.puzzlez.core.Id.ImageId; import ru.m.puzzlez.render.Background; +import ru.m.puzzlez.storage.ImageStorage; @:template class BackgroundPopup extends PopupView { + private static var colorsList:Array = [ + '#FFFFFF', + '#001f3f', + '#0074D9', + '#7FDBFF', + '#39CCCC', + '#3D9970', + '#2ECC40', + '#01FF70', + '#FFDC00', + '#FF851B', + '#FF4136', + '#85144b', + '#F012BE', + '#B10DC9', + '#111111', + '#AAAAAA', + '#DDDDDD', + ]; + + @:view("selected") var selectedView:SpriteView; + @:view("colors") var colorsView:DataView; + @:view("textures") var texturesView:DataView; + + public var selected(default, set):Background; + + @:provide var imageStorage:ImageStorage; + + public function new() { + super(); + colorsView.data = colorsList; + var textures = []; + for (name in Assets.list(AssetType.IMAGE)) { + if (StringTools.startsWith(name, 'resources/texture')) { + textures.push(new ImageId('asset', name)); + } + } + texturesView.data = textures; + } + + private function set_selected(value:Background):Background { + selected = value; + switch selected { + case NONE: + selectedView.skin = null; + case COLOR(color): + selectedView.skin = Skin.color(color); + case IMAGE(id): + imageStorage.resolve(id).then(result -> { + selectedView.skin = Skin.bitmap(result, REPEAT); + selectedView.toRedraw(); + }); + } + selectedView.toRedraw(); + return selected; + } + private function colorButtonFactory(index:Int, color:Color):ButtonView { var result = new ButtonView(); - result.text = " "; - result.skin = new ButtonColorSkin(color); + result.text = " "; + result.skin = Skin.buttonColor(color); return result; } - public static function choise(message:String = null):Promise { + private function textureButtonFactory(index:Int, imageId:ImageId):ButtonView { + var result = new ButtonView(); + result.text = " "; + result.skin = Skin.buttonBitmap(Assets.getBitmapData(imageId.id), REPEAT); + return result; + } + + public static function choise(current:Background):Promise { var result = new BackgroundPopup(); + result.selected = current; return result.show(); } } diff --git a/src/haxe/ru/m/puzzlez/view/BackgroundPopup.yaml b/src/haxe/ru/m/puzzlez/view/BackgroundPopup.yaml index 14e35b9..48af784 100644 --- a/src/haxe/ru/m/puzzlez/view/BackgroundPopup.yaml +++ b/src/haxe/ru/m/puzzlez/view/BackgroundPopup.yaml @@ -1,7 +1,7 @@ --- view: $type: haxework.view.group.VGroupView - geometry.width: 400 + geometry.width: 640 geometry.height: 200 geometry.padding: 10 geometry.hAlign: center @@ -16,46 +16,38 @@ view: - id: header text: Choise background $type: haxework.view.form.LabelView - - $type: haxework.view.group.HGroupView + - id: selected + $type: haxework.view.SpriteView 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)) + geometry.height: 100 + - id: colors + $type: haxework.view.data.DataView + factory: ~colorButtonFactory + geometry.width: 100% + layout: + $type: haxework.view.layout.TailLayout + margin: 5 + +onDataSelect: ~(color) -> selected = COLOR(color) + - id: textures + $type: haxework.view.data.DataView + factory: ~textureButtonFactory + geometry.width: 100% + layout: + $type: haxework.view.layout.TailLayout + margin: 5 + +onDataSelect: ~(imageId) -> selected = IMAGE(imageId) - id: image $type: ru.m.view.ColorView - +onSelect: ~function(color) close(COLOR(color)) + geometry.hAlign: center + +onSelect: ~(color) -> selected = COLOR(color) - $type: haxework.view.group.HGroupView geometry.width: 100% layout.hAlign: center layout.margin: 10 views: + - $type: haxework.view.form.ButtonView + text: Default + +onPress: ~close(NONE) - $type: haxework.view.form.ButtonView text: OK - +onPress: ~reject('ok') - visible: false + +onPress: ~close(selected) diff --git a/src/haxe/ru/m/puzzlez/view/GameFrame.hx b/src/haxe/ru/m/puzzlez/view/GameFrame.hx index e32f6e8..764437a 100644 --- a/src/haxe/ru/m/puzzlez/view/GameFrame.hx +++ b/src/haxe/ru/m/puzzlez/view/GameFrame.hx @@ -1,5 +1,7 @@ package ru.m.puzzlez.view; +import promhx.Promise; +import haxework.view.popup.ConfirmView; import haxe.Timer; import haxework.view.frame.FrameSwitcher; import haxework.view.frame.FrameView; @@ -73,7 +75,7 @@ import ru.m.puzzlez.storage.SettingsStorage; } private function choiseBackground():Void { - BackgroundPopup.choise().then((background:Null) -> { + BackgroundPopup.choise(settings.background).then(background -> { if (background != null) { settings.background = background; render.toRedraw(); @@ -82,6 +84,14 @@ import ru.m.puzzlez.storage.SettingsStorage; } private function back():Void { - switcher.back(); + (if (game != null && game.state.status == COMPLETE) { + Promise.promise(true); + } else { + ConfirmView.confirm("Exit?"); + }).then(result -> { + if (result) { + switcher.change(StartFrame.ID); + } + }); } } diff --git a/src/haxe/ru/m/puzzlez/view/GameFrame.yaml b/src/haxe/ru/m/puzzlez/view/GameFrame.yaml index 767dec4..0317401 100644 --- a/src/haxe/ru/m/puzzlez/view/GameFrame.yaml +++ b/src/haxe/ru/m/puzzlez/view/GameFrame.yaml @@ -10,14 +10,16 @@ views: geometry.width: 100% geometry.height: 100% - $type: haxework.view.form.ButtonView - text: Background + style: icon.setting geometry.position: absolute geometry.hAlign: left geometry.vAlign: top + geometry.margin: [5, 0, 5, 0] +onPress: ~choiseBackground() - $type: haxework.view.form.ButtonView - text: Back + style: icon.close geometry.position: absolute geometry.hAlign: right geometry.vAlign: top + geometry.margin: [0, 5, 5, 0] +onPress: ~back() diff --git a/src/resources/image/icon/keyboard-light.svg b/src/resources/image/icon/keyboard-light.svg deleted file mode 100644 index 8dc7ee9..0000000 --- a/src/resources/image/icon/keyboard-light.svg +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/src/resources/image/icon/play-circle-solid.svg b/src/resources/image/icon/play-circle-solid.svg deleted file mode 100644 index cc067c5..0000000 --- a/src/resources/image/icon/play-circle-solid.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/resources/image/icon/sign-in-solid.svg b/src/resources/image/icon/sign-in-solid.svg deleted file mode 100644 index a6b7b3d..0000000 --- a/src/resources/image/icon/sign-in-solid.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/resources/image/icon/sign-out-solid.svg b/src/resources/image/icon/sign-out-solid.svg deleted file mode 100644 index efbfbbb..0000000 --- a/src/resources/image/icon/sign-out-solid.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/resources/image/icon/tablet-android-alt-light.svg b/src/resources/image/icon/tablet-android-alt-light.svg deleted file mode 100644 index 35ef4c5..0000000 --- a/src/resources/image/icon/tablet-android-alt-light.svg +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/src/resources/texture/45-degree-fabric-light.png b/src/resources/texture/45-degree-fabric-light.png new file mode 100644 index 0000000..edd5c01 Binary files /dev/null and b/src/resources/texture/45-degree-fabric-light.png differ diff --git a/src/resources/texture/beige-paper.png b/src/resources/texture/beige-paper.png new file mode 100644 index 0000000..5da8c67 Binary files /dev/null and b/src/resources/texture/beige-paper.png differ diff --git a/src/resources/texture/brick-wall.png b/src/resources/texture/brick-wall.png new file mode 100644 index 0000000..af45c0a Binary files /dev/null and b/src/resources/texture/brick-wall.png differ diff --git a/src/resources/texture/pool-table.png b/src/resources/texture/pool-table.png new file mode 100644 index 0000000..ea8d8f7 Binary files /dev/null and b/src/resources/texture/pool-table.png differ diff --git a/work.md b/work.md index 0efa0f8..42eb1dd 100644 --- a/work.md +++ b/work.md @@ -2,3 +2,4 @@ * parts groups * navigation * render: table scale/move +* images paginator