summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/map-editor/src/View/SubMenu/Status/TileInfo.elm')
-rw-r--r-- | src/map-editor/src/View/SubMenu/Status/TileInfo.elm | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/src/map-editor/src/View/SubMenu/Status/TileInfo.elm b/src/map-editor/src/View/SubMenu/Status/TileInfo.elm new file mode 100644 index 0000000..a009bc3 --- /dev/null +++ b/src/map-editor/src/View/SubMenu/Status/TileInfo.elm @@ -0,0 +1,142 @@ +module View.SubMenu.Status.TileInfo exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes + +-- Struct.Battlemap ------------------------------------------------------------------- +import Constants.IO +import Constants.Movement + +import Struct.Battlemap +import Struct.Event +import Struct.Location +import Struct.Model +import Struct.Tile + +import Util.Html +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_icon : (Struct.Tile.Instance -> (Html.Html Struct.Event.Type)) +get_icon tile = + (Html.div + [ + (Html.Attributes.class "battlemap-tile-card-icon"), + (Html.Attributes.class + ( + "battlemap-tile-variant-" + ++ (toString (Struct.Tile.get_variant_id tile)) + ) + ), + (Html.Attributes.style + [ + ( + "background-image", + ( + "url(" + ++ Constants.IO.tile_assets_url + ++ (Struct.Tile.get_icon_id tile) + ++".svg)" + ) + ) + ] + ) + ] + [ + ] + ) + +get_name : ( + Struct.Model.Type -> + Struct.Tile.Instance -> + (Html.Html Struct.Event.Type) + ) +get_name model tile = + case (Dict.get (Struct.Tile.get_type_id tile) model.tiles) of + Nothing -> (Util.Html.nothing) + (Just tile_type) -> + (Html.div + [ + (Html.Attributes.class "battlemap-tile-card-name") + ] + [ + (Html.text (Struct.Tile.get_name tile_type)) + ] + ) + +get_cost : (Struct.Tile.Instance -> (Html.Html Struct.Event.Type)) +get_cost tile = + let + cost = (Struct.Tile.get_instance_cost tile) + text = + if (cost > Constants.Movement.max_points) + then + "Obstructed" + else + ("Cost: " ++ (toString cost)) + in + (Html.div + [ + (Html.Attributes.class "battlemap-tile-card-cost") + ] + [ + (Html.text text) + ] + ) + +get_location : (Struct.Tile.Instance -> (Html.Html Struct.Event.Type)) +get_location tile = + let + tile_location = (Struct.Tile.get_location tile) + in + (Html.div + [ + (Html.Attributes.class "battlemap-tile-card-location") + ] + [ + (Html.text + ( + "{x: " + ++ (toString tile_location.x) + ++ "; y: " + ++ (toString tile_location.y) + ++ "}" + ) + ) + ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : ( + Struct.Model.Type -> + Struct.Location.Type -> + (Html.Html Struct.Event.Type) + ) +get_html model loc = + case (Struct.Battlemap.try_getting_tile_at loc model.battlemap) of + (Just tile) -> + (Html.div + [ + (Html.Attributes.class "battlemap-tile-card") + ] + [ + (get_name model tile), + (Html.div + [ + (Html.Attributes.class "battlemap-tile-card-top") + ] + [ + (get_icon tile), + (get_location tile), + (get_cost tile) + ] + ) + ] + ) + + Nothing -> (Html.text "Error: Unknown tile location selected.") |