summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-08-03 22:00:44 +0200 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-08-03 22:00:44 +0200 |
commit | dd08a1e28273db632ca3b5fe4b72c57085f01429 (patch) | |
tree | 18304a77419ecc374ac42f52aa3efd88ae8be641 | |
parent | aee23306060ba664e32e6c8463fdf5fb911881a7 (diff) |
Updates to the new tile format (again).
-rw-r--r-- | src/battle/src/Comm/SetMap.elm | 48 | ||||
-rw-r--r-- | src/battle/src/Struct/Tile.elm | 67 | ||||
-rw-r--r-- | src/battle/src/View/Map/Tile.elm | 101 | ||||
-rw-r--r-- | src/battle/src/View/SubMenu/Status/TileInfo.elm | 20 | ||||
-rw-r--r-- | src/battle/www/style.css | 24 | ||||
-rw-r--r-- | src/map-editor/src/View/Map.elm | 2 | ||||
-rw-r--r-- | src/map-editor/src/View/SubMenu.elm | 3 | ||||
-rw-r--r-- | src/map-editor/src/View/SubMenu/Status.elm | 3 | ||||
-rw-r--r-- | src/map-editor/src/View/SubMenu/Status/TileInfo.elm | 1 | ||||
-rw-r--r-- | src/map-editor/src/View/SubMenu/Tiles.elm | 2 | ||||
-rw-r--r-- | src/map-editor/src/View/Toolbox.elm | 4 |
11 files changed, 184 insertions, 91 deletions
diff --git a/src/battle/src/Comm/SetMap.elm b/src/battle/src/Comm/SetMap.elm index e74471d..af930f2 100644 --- a/src/battle/src/Comm/SetMap.elm +++ b/src/battle/src/Comm/SetMap.elm @@ -23,37 +23,47 @@ type alias MapData = -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- +deserialize_tile_borders : ( + (List Int) -> + (List Struct.Tile.Border) -> + (List Struct.Tile.Border) + ) +deserialize_tile_borders rem_ints current_borders = + case rem_ints of + [] -> current_borders + (a :: (b :: c)) -> + (deserialize_tile_borders + c + ((Struct.Tile.new_border a b) :: current_borders) + ) + + _ -> [] + deserialize_tile_instance : Int -> Int -> (List Int) -> Struct.Tile.Instance deserialize_tile_instance map_width index t = case t of - [type_id] -> - (Struct.Tile.new_instance - (index % map_width) - (index // map_width) - type_id - type_id - 0 - Constants.Movement.cost_when_out_of_bounds - ) - - [type_id, border_id, variant_ix] -> + (a :: (b :: c)) -> (Struct.Tile.new_instance - (index % map_width) - (index // map_width) - type_id - border_id - variant_ix + { + x = (index % map_width), + y = (index // map_width) + } + a + b Constants.Movement.cost_when_out_of_bounds + (deserialize_tile_borders c []) ) _ -> (Struct.Tile.new_instance - (index % map_width) - (index // map_width) - 0 + { + x = (index % map_width), + y = (index // map_width) + } 0 0 Constants.Movement.cost_when_out_of_bounds + [] ) internal_decoder : MapData -> Struct.ServerReply.Type diff --git a/src/battle/src/Struct/Tile.elm b/src/battle/src/Struct/Tile.elm index 0077e7f..9783672 100644 --- a/src/battle/src/Struct/Tile.elm +++ b/src/battle/src/Struct/Tile.elm @@ -3,16 +3,21 @@ module Struct.Tile exposing Ref, Type, Instance, + Border, new, new_instance, + new_border, error_tile_instance, get_id, get_name, + get_borders, + get_border_type_id, + get_border_variant_ix, get_cost, get_instance_cost, get_location, - get_icon_id, get_type_id, + get_variant_ix, get_local_variant_ix, solve_tile_instance, decoder @@ -49,13 +54,19 @@ type alias Type = crossing_cost : Int } +type alias Border = + { + type_id : Int, + variant_ix : Int + } + type alias Instance = { location : Struct.Location.Type, + crossing_cost : Int, type_id : Int, - border_id : Int, variant_ix : Int, - crossing_cost : Int + borders : (List Border) } -------------------------------------------------------------------------------- @@ -84,14 +95,28 @@ new id name crossing_cost = crossing_cost = crossing_cost } -new_instance : Int -> Int -> Int -> Int -> Int -> Int -> Instance -new_instance x y type_id border_id variant_ix crossing_cost = +new_border : Int -> Int -> Border +new_border a b = { - location = {x = x, y = y}, + type_id = a, + variant_ix = b + } + +new_instance : ( + Struct.Location.Type -> + Int -> + Int -> + Int -> + (List Border) -> + Instance + ) +new_instance location type_id variant_ix crossing_cost borders = + { + location = location, type_id = type_id, - border_id = border_id, variant_ix = variant_ix, - crossing_cost = crossing_cost + crossing_cost = crossing_cost, + borders = borders } error_tile_instance : Int -> Int -> Instance @@ -99,9 +124,9 @@ error_tile_instance x y = { location = {x = x, y = y}, type_id = 0, - border_id = 0, variant_ix = 0, - crossing_cost = Constants.Movement.cost_when_out_of_bounds + crossing_cost = Constants.Movement.cost_when_out_of_bounds, + borders = [] } get_id : Type -> Int @@ -119,19 +144,21 @@ get_name tile = tile.name get_location : Instance -> Struct.Location.Type get_location tile_inst = tile_inst.location -get_icon_id : Instance -> String -get_icon_id tile_inst = - ( - (toString tile_inst.type_id) - ++ "-" - ++ (toString tile_inst.border_id) - ++ "-" - ++ (toString tile_inst.variant_ix) - ) - get_type_id : Instance -> Int get_type_id tile_inst = tile_inst.type_id +get_border_type_id : Border -> Int +get_border_type_id tile_border = tile_border.type_id + +get_borders : Instance -> (List Border) +get_borders tile_inst = tile_inst.borders + +get_variant_ix : Instance -> Int +get_variant_ix tile_inst = tile_inst.variant_ix + +get_border_variant_ix : Border -> Int +get_border_variant_ix tile_border = tile_border.variant_ix + get_local_variant_ix : Instance -> Int get_local_variant_ix tile_inst = ( diff --git a/src/battle/src/View/Map/Tile.elm b/src/battle/src/View/Map/Tile.elm index 844a277..36e7cb4 100644 --- a/src/battle/src/View/Map/Tile.elm +++ b/src/battle/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 @@ -16,18 +16,93 @@ import Struct.Tile -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- +get_layer_html : ( + Int -> + Struct.Tile.Border -> + (Html.Html Struct.Event.Type) + ) +get_layer_html index border = + (Html.div + [ + (Html.Attributes.class ("battle-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_html : ( - Struct.Tile.Instance -> - (Html.Html Struct.Event.Type) +get_content_html : Struct.Tile.Instance -> (List (Html.Html Struct.Event.Type)) +get_content_html tile = + ( + (Html.div + [ + (Html.Attributes.class "battle-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 "battle-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.Tile.Instance -> (Html.Html Struct.Event.Type) get_html tile = - let - tile_loc = (Struct.Tile.get_location tile) - in + let tile_loc = (Struct.Tile.get_location tile) in (Html.div [ (Html.Attributes.class "battle-tile-icon"), @@ -51,19 +126,9 @@ get_html 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/battle/src/View/SubMenu/Status/TileInfo.elm b/src/battle/src/View/SubMenu/Status/TileInfo.elm index 2cd0a6f..d08f937 100644 --- a/src/battle/src/View/SubMenu/Status/TileInfo.elm +++ b/src/battle/src/View/SubMenu/Status/TileInfo.elm @@ -7,7 +7,6 @@ import Html import Html.Attributes -- Struct.Map ------------------------------------------------------------------- -import Constants.IO import Constants.Movement import Struct.Map @@ -17,6 +16,9 @@ import Struct.Model import Struct.Tile import Util.Html + +import View.Map.Tile + -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -30,23 +32,9 @@ get_icon tile = "battle-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/battle/www/style.css b/src/battle/www/style.css index 2a2147a..c0ddc48 100644 --- a/src/battle/www/style.css +++ b/src/battle/www/style.css @@ -234,7 +234,7 @@ { box-sizing: border-box; border-radius: 5px; - background-size: 300% 300%; + background-size: 400%; width: 80px; height: 80px; } @@ -577,7 +577,7 @@ background-color: #917C6F; } -.battle-tiled +.battle-tiled, .battle-tiled * { height: 32px; width: 32px; @@ -606,12 +606,30 @@ .battle-tile-variant-14 {background-position: 200% 300%;} .battle-tile-variant-15 {background-position: 300% 300%;} -.battle-tile-icon {z-index: 0; position: absolute; background-size: 400%;} +.battle-tile-icon, .battle-tile-icon * +{ + z-index: 0; + position: absolute; + background-size: 400%; +} + .battle-path-icon-below-markers {z-index: 1;} .battle-marker-icon {z-index: 2;} .battle-path-icon-above-markers {z-index: 3;} .battle-character-icon {z-index: 4;} +.battle-tile-icon-bg { z-index: 0; } +.battle-tile-icon-dt { z-index: 9; } + +.battle-tile-icon-f-0 { z-index: 1; } +.battle-tile-icon-f-1 { z-index: 2; } +.battle-tile-icon-f-2 { z-index: 3; } +.battle-tile-icon-f-3 { z-index: 4; } +.battle-tile-icon-f-4 { z-index: 5; } +.battle-tile-icon-f-5 { z-index: 6; } +.battle-tile-icon-f-6 { z-index: 7; } +.battle-tile-icon-f-7 { z-index: 8; } + .battle-marker-icon, .battle-character-icon, .battle-path-icon diff --git a/src/map-editor/src/View/Map.elm b/src/map-editor/src/View/Map.elm index 0f75ad4..b28f5c2 100644 --- a/src/map-editor/src/View/Map.elm +++ b/src/map-editor/src/View/Map.elm @@ -18,8 +18,6 @@ import Struct.Model import Struct.Toolbox import Struct.UI -import Util.Html - import View.Map.Tile -------------------------------------------------------------------------------- diff --git a/src/map-editor/src/View/SubMenu.elm b/src/map-editor/src/View/SubMenu.elm index 75b5101..6962620 100644 --- a/src/map-editor/src/View/SubMenu.elm +++ b/src/map-editor/src/View/SubMenu.elm @@ -1,11 +1,8 @@ module View.SubMenu exposing (get_html) -- Elm ------------------------------------------------------------------------- -import Array - import Html import Html.Attributes -import Html.Lazy -- Battlemap ------------------------------------------------------------------- import Struct.Event diff --git a/src/map-editor/src/View/SubMenu/Status.elm b/src/map-editor/src/View/SubMenu/Status.elm index 5c47552..795b603 100644 --- a/src/map-editor/src/View/SubMenu/Status.elm +++ b/src/map-editor/src/View/SubMenu/Status.elm @@ -1,11 +1,8 @@ module View.SubMenu.Status exposing (get_html) -- Elm ------------------------------------------------------------------------- -import Array - import Html import Html.Attributes -import Html.Lazy -- Struct.Battlemap ------------------------------------------------------------------- import Struct.Event diff --git a/src/map-editor/src/View/SubMenu/Status/TileInfo.elm b/src/map-editor/src/View/SubMenu/Status/TileInfo.elm index 194f858..91c4b48 100644 --- a/src/map-editor/src/View/SubMenu/Status/TileInfo.elm +++ b/src/map-editor/src/View/SubMenu/Status/TileInfo.elm @@ -7,7 +7,6 @@ import Html import Html.Attributes -- Map Editor ------------------------------------------------------------------ -import Constants.IO import Constants.Movement import Struct.Map diff --git a/src/map-editor/src/View/SubMenu/Tiles.elm b/src/map-editor/src/View/SubMenu/Tiles.elm index 67a1f50..4c5c71a 100644 --- a/src/map-editor/src/View/SubMenu/Tiles.elm +++ b/src/map-editor/src/View/SubMenu/Tiles.elm @@ -6,8 +6,6 @@ import Html.Attributes import Html.Events -- Battlemap ------------------------------------------------------------------- -import Constants.IO - import Struct.Event import Struct.Tile diff --git a/src/map-editor/src/View/Toolbox.elm b/src/map-editor/src/View/Toolbox.elm index 17ca0fd..cea1192 100644 --- a/src/map-editor/src/View/Toolbox.elm +++ b/src/map-editor/src/View/Toolbox.elm @@ -6,14 +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 - import View.Map.Tile -------------------------------------------------------------------------------- |