| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2017-11-30 16:05:43 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2017-11-30 16:05:43 +0100 | 
| commit | 2d030cbc89e4bf14fc584a83417d59fc86640202 (patch) | |
| tree | f3ae7159a0eb5c15516aee18ffff7aaeb1d06770 /src/battlemap | |
| parent | 68e6ad689deabed93ebfb41abea90d9fe4911179 (diff) | |
Fixes 'battlemap-actual' div having 0x0 size.
Diffstat (limited to 'src/battlemap')
| -rw-r--r-- | src/battlemap/src/Battlemap.elm | 8 | ||||
| -rw-r--r-- | src/battlemap/src/View/Battlemap.elm | 71 | ||||
| -rw-r--r-- | src/battlemap/src/View/Battlemap/Tile.elm | 25 | ||||
| -rw-r--r-- | src/battlemap/www/style.css | 23 | 
4 files changed, 103 insertions, 24 deletions
| diff --git a/src/battlemap/src/Battlemap.elm b/src/battlemap/src/Battlemap.elm index 9d0c3d5..5b289d0 100644 --- a/src/battlemap/src/Battlemap.elm +++ b/src/battlemap/src/Battlemap.elm @@ -4,6 +4,8 @@ module Battlemap exposing        empty,        new,        reset, +      get_width, +      get_height,        get_navigator_remaining_points,        get_tiles,        set_navigator, @@ -94,6 +96,12 @@ tile_cost_function bmap start_loc char_list loc =  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- +get_width : Type -> Int +get_width bmap = bmap.width + +get_height : Type -> Int +get_height bmap = bmap.height +  get_tiles : Type -> (Array.Array Battlemap.Tile.Type)  get_tiles bmap = bmap.content diff --git a/src/battlemap/src/View/Battlemap.elm b/src/battlemap/src/View/Battlemap.elm index c05644f..35f8237 100644 --- a/src/battlemap/src/View/Battlemap.elm +++ b/src/battlemap/src/View/Battlemap.elm @@ -74,20 +74,71 @@ char_on_map char =           ]        ) -get_tiles_html : ( -      (Array.Array Battlemap.Tile.Type) -> -      (Html.Html Event.Type) -   ) -get_tiles_html tiles_array = +get_tiles_line_html : (List (Html.Html Event.Type)) -> (Html.Html Event.Type) +get_tiles_line_html tiles_list =     (Html.div        [ -         (Html.Attributes.class "battlemap-tiles-layer") +         (Html.Attributes.class "battlemap-tiles-layer-row")        ] -      (List.map -         (View.Battlemap.Tile.get_html) -         (Array.toList tiles_array) +      tiles_list +   ) + +get_tiles_lines_html : ( +      Int -> +      Battlemap.Tile.Type -> +      ( +         Int, +         (List (Html.Html Event.Type)), +         (List (Html.Html Event.Type)) +      ) -> +      ( +         Int, +         (List (Html.Html Event.Type)), +         (List (Html.Html Event.Type)) +      ) +   ) +get_tiles_lines_html max_index tile (curr_index, curr_line, result) = +   if (curr_index == 0) +   then +      ( +         max_index, +         [], +         ( +            (get_tiles_line_html +               ((View.Battlemap.Tile.get_html tile) :: curr_line) +            ) +            :: +            result +         )        ) +   else +      ( +         (curr_index - 1), +         ((View.Battlemap.Tile.get_html tile) :: curr_line), +         result +      ) + +get_tiles_html : ( +      Int -> +      (Array.Array Battlemap.Tile.Type) -> +      (Html.Html Event.Type)     ) +get_tiles_html bmap_width tiles_array = +   let +      max_index = (bmap_width - 1) +      (_, last_line, other_lines) = +         (Array.foldr +            (get_tiles_lines_html max_index) +            (max_index, [], []) +            tiles_array +         ) +   in +      (Html.div +         [ +            (Html.Attributes.class "battlemap-tiles-layer") +         ] +         ((get_tiles_line_html last_line) :: other_lines) +      )  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- @@ -112,7 +163,7 @@ get_html battlemap scale characters =        ]        (           (Html.Lazy.lazy -            (get_tiles_html) +            (get_tiles_html (Battlemap.get_width battlemap))              (Battlemap.get_tiles battlemap)           )           :: diff --git a/src/battlemap/src/View/Battlemap/Tile.elm b/src/battlemap/src/View/Battlemap/Tile.elm index 6b37d84..3577e00 100644 --- a/src/battlemap/src/View/Battlemap/Tile.elm +++ b/src/battlemap/src/View/Battlemap/Tile.elm @@ -28,19 +28,20 @@ get_html tile =              ),              (Html.Events.onClick                 (Event.TileSelected (Battlemap.Location.get_ref tile_loc)) -            ), -            (Html.Attributes.style -               [ -                  ( -                     "top", -                     ((toString (tile_loc.y * Constants.UI.tile_size)) ++ "px") -                  ), -                  ( -                     "left", -                     ((toString (tile_loc.x * Constants.UI.tile_size)) ++ "px") -                  ) -               ]              ) +--            ), +--            (Html.Attributes.style +--               [ +--                  ( +--                     "top", +--                     ((toString (tile_loc.y * Constants.UI.tile_size)) ++ "px") +--                  ), +--                  ( +--                     "left", +--                     ((toString (tile_loc.x * Constants.UI.tile_size)) ++ "px") +--                  ) +--               ] +--            )           ]           [           ] diff --git a/src/battlemap/www/style.css b/src/battlemap/www/style.css index e208b27..b8f60ff 100644 --- a/src/battlemap/www/style.css +++ b/src/battlemap/www/style.css @@ -20,16 +20,34 @@  /** Inside the container ******************************************************/  .battlemap-tiled  { -   position: absolute;     height: 32px;     width: 32px; +   /** Fixes odd behavior of table cell being resized. **/ +   min-width: 32px; +   max-width: 32px;  } -.battlemap-tile-icon       {z-index: 0;} +.battlemap-tile-icon       {z-index: 0; display: table-cell;}  .battlemap-marker-icon     {z-index: 1;}  .battlemap-character-icon  {z-index: 2;}  .battlemap-path-icon       {z-index: 3; color: white;} +.battlemap-marker-icon, +.battlemap-character-icon, +.battlemap-path-icon +{ +   position: absolute; +} +.battlemap-tiles-layer +{ +   display: table; +} + +.battlemap-tiles-layer-row +{ +   display: table-row; +} +  .battlemap-character-icon  {     box-sizing: border-box; @@ -52,6 +70,7 @@     filter: grayscale(50%);     border: 2px dotted rgba(0,0,0,0.7);  } +  /**** Path Icons **************************************************************/  .battlemap-path-icon-NR:before,  .battlemap-path-icon-LR:before, | 


