summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/map-editor/src/View')
-rw-r--r-- | src/map-editor/src/View/Map/Tile.elm | 95 | ||||
-rw-r--r-- | src/map-editor/src/View/SubMenu/Status/TileInfo.elm | 19 | ||||
-rw-r--r-- | src/map-editor/src/View/SubMenu/Tiles.elm | 39 | ||||
-rw-r--r-- | src/map-editor/src/View/Toolbox.elm | 20 |
4 files changed, 106 insertions, 67 deletions
diff --git a/src/map-editor/src/View/Map/Tile.elm b/src/map-editor/src/View/Map/Tile.elm index 798896e..89b6300 100644 --- a/src/map-editor/src/View/Map/Tile.elm +++ b/src/map-editor/src/View/Map/Tile.elm @@ -1,4 +1,4 @@ -module View.Map.Tile exposing (get_html) +module View.Map.Tile exposing (get_html, get_content_html) -- Elm ------------------------------------------------------------------------- import Html @@ -18,9 +18,90 @@ import Struct.Toolbox -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- +get_layer_html : ( + Int -> + Struct.Tile.Border -> + (Html.Html Struct.Event.Type) + ) +get_layer_html index border = + (Html.div + [ + (Html.Attributes.class ("map-tile-icon-f-" ++ (toString index))), + (Html.Attributes.style + [ + ( + "background-image", + ( + "url(" + ++ Constants.IO.tile_assets_url + ++ (toString (Struct.Tile.get_border_type_id border)) + ++ "-f-" + ++ (toString (Struct.Tile.get_border_variant_ix border)) + ++ ".svg)" + ) + ) + ] + ) + ] + [] + ) + -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- +get_content_html : Struct.Tile.Instance -> (List (Html.Html Struct.Event.Type)) +get_content_html tile = + ( + (Html.div + [ + (Html.Attributes.class "map-tile-icon-bg"), + (Html.Attributes.style + [ + ( + "background-image", + ( + "url(" + ++ Constants.IO.tile_assets_url + ++ (toString (Struct.Tile.get_type_id tile)) + ++ "-bg.svg)" + ) + ) + ] + ) + ] + [] + ) + :: + ( + (Html.div + [ + (Html.Attributes.class "map-tile-icon-dt"), + (Html.Attributes.style + [ + ( + "background-image", + ( + "url(" + ++ Constants.IO.tile_assets_url + ++ (toString (Struct.Tile.get_type_id tile)) + ++ "-v-" + ++ (toString (Struct.Tile.get_variant_ix tile)) + ++ ".svg)" + ) + ) + ] + ) + ] + [] + ) + :: + (List.indexedMap + (get_layer_html) + (Struct.Tile.get_borders tile) + ) + ) + ) + get_html : ( Struct.Toolbox.Type -> Struct.Tile.Instance -> @@ -63,19 +144,9 @@ get_html tb tile = ( "left", ((toString (tile_loc.x * Constants.UI.tile_size)) ++ "px") - ), - ( - "background-image", - ( - "url(" - ++ Constants.IO.tile_assets_url - ++ (Struct.Tile.get_icon_id tile) - ++".svg)" - ) ) ] ) ] - [ - ] + (get_content_html tile) ) diff --git a/src/map-editor/src/View/SubMenu/Status/TileInfo.elm b/src/map-editor/src/View/SubMenu/Status/TileInfo.elm index 1e5acac..194f858 100644 --- a/src/map-editor/src/View/SubMenu/Status/TileInfo.elm +++ b/src/map-editor/src/View/SubMenu/Status/TileInfo.elm @@ -17,6 +17,9 @@ import Struct.Model import Struct.Tile import Util.Html + +import View.Map.Tile + -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -30,23 +33,9 @@ get_icon tile = "map-tile-variant-" ++ (toString (Struct.Tile.get_local_variant_ix tile)) ) - ), - (Html.Attributes.style - [ - ( - "background-image", - ( - "url(" - ++ Constants.IO.tile_assets_url - ++ (Struct.Tile.get_icon_id tile) - ++".svg)" - ) - ) - ] ) ] - [ - ] + (View.Map.Tile.get_content_html tile) ) get_name : ( diff --git a/src/map-editor/src/View/SubMenu/Tiles.elm b/src/map-editor/src/View/SubMenu/Tiles.elm index 64cd633..67a1f50 100644 --- a/src/map-editor/src/View/SubMenu/Tiles.elm +++ b/src/map-editor/src/View/SubMenu/Tiles.elm @@ -9,6 +9,9 @@ import Html.Events import Constants.IO import Struct.Event +import Struct.Tile + +import View.Map.Tile -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- @@ -22,32 +25,20 @@ get_icon_html icon_id = (Html.Attributes.class "map-tiled"), (Html.Attributes.class "clickable"), (Html.Attributes.class "map-tile-variant-0"), - (Html.Attributes.style - [ - ( - "background-image", - ( - let - icon_id_str = (toString icon_id) - in - ( - "url(" - ++ Constants.IO.tile_assets_url - ++ icon_id_str - ++ "-" - ++ icon_id_str - ++"-0.svg)" - ) - ) - ) - ] - ), (Html.Events.onClick - (Struct.Event.TemplateRequested (icon_id, icon_id, 0)) + (Struct.Event.TemplateRequested (icon_id, 0)) ) ] - [ - ] + (View.Map.Tile.get_content_html + (Struct.Tile.new_instance + {x = 0, y = 0} + icon_id + 0 + 0 + 0 + [] + ) + ) ) -------------------------------------------------------------------------------- @@ -62,6 +53,6 @@ get_html = ] (List.map (get_icon_html) - (List.range 0 3) + (List.range 0 5) ) ) diff --git a/src/map-editor/src/View/Toolbox.elm b/src/map-editor/src/View/Toolbox.elm index 4054c4d..17ca0fd 100644 --- a/src/map-editor/src/View/Toolbox.elm +++ b/src/map-editor/src/View/Toolbox.elm @@ -14,6 +14,8 @@ import Struct.Toolbox import Util.Html +import View.Map.Tile + -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -24,23 +26,9 @@ get_template_icon_html template = (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)" - ) - ) - ] - ) - ] - [ + (Html.Attributes.class "map-tile-variant-0") ] + (View.Map.Tile.get_content_html template) ) get_mode_button : ( |