summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-07-13 18:54:20 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-07-13 18:54:20 +0200
commit356a76ce7cc9964ddb11a46b2c555ef3d3bdfb80 (patch)
tree71938491635ff0b0ea4330fdf812970a9360ae62
parent9a86bc7064fed626ecd1d3f03c7af30a5ef246c8 (diff)
Can now select a template, clear selection.
-rw-r--r--src/global/www/style.css16
-rw-r--r--src/map-editor/src/ElmModule/Update.elm8
-rw-r--r--src/map-editor/src/Struct/Event.elm2
-rw-r--r--src/map-editor/src/Struct/Tile.elm2
-rw-r--r--src/map-editor/src/Update/ClearToolboxSelection.elm24
-rw-r--r--src/map-editor/src/Update/SetToolboxTemplate.elm36
-rw-r--r--src/map-editor/src/View/SubMenu/Tiles.elm34
-rw-r--r--src/map-editor/src/View/SubMenu/Tiles.elm.m458
-rw-r--r--src/map-editor/src/View/Toolbox.elm45
-rw-r--r--src/map-editor/www/style.css14
10 files changed, 230 insertions, 9 deletions
diff --git a/src/global/www/style.css b/src/global/www/style.css
index 2baaa2a..76f1ed9 100644
--- a/src/global/www/style.css
+++ b/src/global/www/style.css
@@ -46,6 +46,22 @@ html, body, .fullscreen-module
background-color: #C8BEB7;
}
+* button:disabled
+{
+ background-color: #502D16;
+}
+
+* button:disabled:hover
+{
+ cursor: default;
+ background-color: #502D16;
+}
+
+* button:disabled:active
+{
+ background-color: #502D16;
+}
+
html, body, .fullscreen-module
{
position: absolute;
diff --git a/src/map-editor/src/ElmModule/Update.elm b/src/map-editor/src/ElmModule/Update.elm
index e7bd797..76ee2e1 100644
--- a/src/map-editor/src/ElmModule/Update.elm
+++ b/src/map-editor/src/ElmModule/Update.elm
@@ -13,6 +13,8 @@ import Update.SelectTile
import Update.SetRequestedHelp
import Update.SetToolboxMode
import Update.SetToolboxShape
+import Update.SetToolboxTemplate
+import Update.ClearToolboxSelection
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -59,3 +61,9 @@ update event model =
(Struct.Event.ModeRequested mode) ->
(Update.SetToolboxMode.apply_to new_model mode)
+
+ (Struct.Event.TemplateRequested id) ->
+ (Update.SetToolboxTemplate.apply_to new_model id)
+
+ Struct.Event.ClearSelectionRequested ->
+ (Update.ClearToolboxSelection.apply_to new_model)
diff --git a/src/map-editor/src/Struct/Event.elm b/src/map-editor/src/Struct/Event.elm
index 0f9cdae..498fbab 100644
--- a/src/map-editor/src/Struct/Event.elm
+++ b/src/map-editor/src/Struct/Event.elm
@@ -25,6 +25,8 @@ type Type =
| RequestedHelp Struct.HelpRequest.Type
| ModeRequested Struct.Toolbox.Mode
| ShapeRequested Struct.Toolbox.Shape
+ | ClearSelectionRequested
+ | TemplateRequested Int
attempted : (Result.Result err val) -> Type
attempted act =
diff --git a/src/map-editor/src/Struct/Tile.elm b/src/map-editor/src/Struct/Tile.elm
index 00cb12e..aaf6eab 100644
--- a/src/map-editor/src/Struct/Tile.elm
+++ b/src/map-editor/src/Struct/Tile.elm
@@ -159,7 +159,7 @@ get_location tile_inst = tile_inst.location
get_icon_id : Instance -> String
get_icon_id tile_inst = (toString tile_inst.icon_id)
-get_type_id: Instance -> Int
+get_type_id : Instance -> Int
get_type_id tile_inst = tile_inst.type_id
get_variant_id : Instance -> Int
diff --git a/src/map-editor/src/Update/ClearToolboxSelection.elm b/src/map-editor/src/Update/ClearToolboxSelection.elm
new file mode 100644
index 0000000..7f10b48
--- /dev/null
+++ b/src/map-editor/src/Update/ClearToolboxSelection.elm
@@ -0,0 +1,24 @@
+module Update.ClearToolboxSelection exposing (apply_to)
+-- Elm -------------------------------------------------------------------------
+
+-- Battlemap -------------------------------------------------------------------
+import Struct.Event
+import Struct.Toolbox
+import Struct.Model
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+apply_to : (
+ Struct.Model.Type ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+apply_to model =
+ (
+ {model | toolbox = (Struct.Toolbox.clear_selection model.toolbox)},
+ Cmd.none
+ )
diff --git a/src/map-editor/src/Update/SetToolboxTemplate.elm b/src/map-editor/src/Update/SetToolboxTemplate.elm
new file mode 100644
index 0000000..319bd53
--- /dev/null
+++ b/src/map-editor/src/Update/SetToolboxTemplate.elm
@@ -0,0 +1,36 @@
+module Update.SetToolboxTemplate exposing (apply_to)
+-- Elm -------------------------------------------------------------------------
+import Dict
+
+-- Battlemap -------------------------------------------------------------------
+import Struct.Event
+import Struct.Toolbox
+import Struct.Tile
+import Struct.Model
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+apply_to : (
+ Struct.Model.Type ->
+ Int ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+apply_to model id =
+ (
+ {model |
+ toolbox =
+ (Struct.Toolbox.set_template
+ (Struct.Tile.solve_tile_instance
+ (Dict.values model.tiles)
+ (Struct.Tile.error_tile_instance id 0 0)
+ )
+ model.toolbox
+ )
+ },
+ Cmd.none
+ )
diff --git a/src/map-editor/src/View/SubMenu/Tiles.elm b/src/map-editor/src/View/SubMenu/Tiles.elm
index 067339a..2255824 100644
--- a/src/map-editor/src/View/SubMenu/Tiles.elm
+++ b/src/map-editor/src/View/SubMenu/Tiles.elm
@@ -6,11 +6,39 @@ import Html.Attributes
import Html.Events
-- Battlemap -------------------------------------------------------------------
+import Constants.IO
+
import Struct.Event
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
+get_icon_html : Int -> (Html.Html Struct.Event.Type)
+get_icon_html icon_id =
+ (Html.div
+ [
+ (Html.Attributes.class "map-tile"),
+ (Html.Attributes.class "map-tiled"),
+ (Html.Attributes.class "clickable"),
+ (Html.Attributes.class "map-tile-variant-0"),
+ (Html.Attributes.style
+ [
+ (
+ "background-image",
+ (
+ "url("
+ ++ Constants.IO.tile_assets_url
+ ++ (toString icon_id)
+ ++".svg)"
+ )
+ )
+ ]
+ ),
+ (Html.Events.onClick (Struct.Event.TemplateRequested icon_id))
+ ]
+ [
+ ]
+ )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -22,6 +50,8 @@ get_html =
(Html.Attributes.class "map-tabmenu-content"),
(Html.Attributes.class "map-tabmenu-tiles-tab")
]
- [
- ]
+ (List.map
+ (get_icon_html)
+ (List.range 0 17)
+ )
)
diff --git a/src/map-editor/src/View/SubMenu/Tiles.elm.m4 b/src/map-editor/src/View/SubMenu/Tiles.elm.m4
new file mode 100644
index 0000000..bbfafd7
--- /dev/null
+++ b/src/map-editor/src/View/SubMenu/Tiles.elm.m4
@@ -0,0 +1,58 @@
+module View.SubMenu.Tiles exposing (get_html)
+
+-- Elm -------------------------------------------------------------------------
+import Html
+import Html.Attributes
+import Html.Events
+
+-- Battlemap -------------------------------------------------------------------
+import Constants.IO
+
+import Struct.Event
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_icon_html : Int -> (Html.Html Struct.Event.Type)
+get_icon_html icon_id =
+ (Html.div
+ [
+ (Html.Attributes.class "map-tile"),
+ (Html.Attributes.class "map-tiled"),
+ (Html.Attributes.class "clickable"),
+ (Html.Attributes.class "map-tile-variant-0"),
+ (Html.Attributes.style
+ [
+ (
+ "background-image",
+ (
+ "url("
+ ++ Constants.IO.tile_assets_url
+ ++ (toString icon_id)
+ ++".svg)"
+ )
+ )
+ ]
+ ),
+ (Html.Events.onClick (Struct.Event.TemplateRequested icon_id))
+ ]
+ [
+ ]
+ )
+
+m4_include(__MAKEFILE_DATA_DIR/tile/global.m4.conf)m4_dnl
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_html : (Html.Html Struct.Event.Type)
+get_html =
+ (Html.div
+ [
+ (Html.Attributes.class "map-tabmenu-content"),
+ (Html.Attributes.class "map-tabmenu-tiles-tab")
+ ]
+ (List.map
+ (get_icon_html)
+ (List.range 0 __TILE_CLASS_MAX_ID)
+ )
+ )
diff --git a/src/map-editor/src/View/Toolbox.elm b/src/map-editor/src/View/Toolbox.elm
index fe8825e..5dacb13 100644
--- a/src/map-editor/src/View/Toolbox.elm
+++ b/src/map-editor/src/View/Toolbox.elm
@@ -6,7 +6,10 @@ import Html.Attributes
import Html.Events
-- Struct.Battlemap -------------------------------------------------------------------
+import Constants.IO
+
import Struct.Event
+import Struct.Tile
import Struct.Toolbox
import Util.Html
@@ -14,12 +17,29 @@ import Util.Html
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_template_icon_html : Struct.Toolbox.Type -> (Html.Html Struct.Event.Type)
-get_template_icon_html tb =
+get_template_icon_html : Struct.Tile.Instance -> (Html.Html Struct.Event.Type)
+get_template_icon_html template =
(Html.div
- [(Html.Attributes.class "map-toolbox-template")]
[
- (Html.text "[TEMPLATE_ICON]")
+ (Html.Attributes.class "map-toolbox-template"),
+ (Html.Attributes.class "map-tiled"),
+ (Html.Attributes.class "map-tile"),
+ (Html.Attributes.class "map-tile-variant-0"),
+ (Html.Attributes.style
+ [
+ (
+ "background-image",
+ (
+ "url("
+ ++ Constants.IO.tile_assets_url
+ ++ (Struct.Tile.get_icon_id template)
+ ++".svg)"
+ )
+ )
+ ]
+ )
+ ]
+ [
]
)
@@ -89,6 +109,18 @@ get_shapes_menu_html tb =
)
)
+get_others_menu_html : (Html.Html Struct.Event.Type)
+get_others_menu_html =
+ (Html.div
+ [(Html.Attributes.class "map-toolbox-others")]
+ [
+ (Html.button
+ [(Html.Events.onClick Struct.Event.ClearSelectionRequested)]
+ [(Html.text "Clear Selection")]
+ )
+ ]
+ )
+
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -97,8 +129,9 @@ get_html tb =
(Html.div
[(Html.Attributes.class "map-toolbox")]
[
- (get_template_icon_html tb),
+ (get_template_icon_html (Struct.Toolbox.get_template tb)),
(get_modes_menu_html tb),
- (get_shapes_menu_html tb)
+ (get_shapes_menu_html tb),
+ (get_others_menu_html)
]
)
diff --git a/src/map-editor/www/style.css b/src/map-editor/www/style.css
index 836a84c..ea9b8ea 100644
--- a/src/map-editor/www/style.css
+++ b/src/map-editor/www/style.css
@@ -355,6 +355,20 @@
.map-tile-icon {z-index: 0; position: absolute; background-size: 300%;}
+.map-tile {background-size: 300%;}
+
+.map-tabmenu-tiles-tab
+{
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+}
+
+.map-tabmenu-tiles-tab .map-tile
+{
+ margin: 0.1em;
+}
+
.map-tile-selected
{
border: 1px dashed white;