From b3fd9613c298e1af44f025d9d95021eec8c72a59 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Fri, 24 Aug 2018 17:36:33 +0200 Subject: Starting to work on the character editor. --- src/character/src/View/SubMenu/Status/TileInfo.elm | 137 +++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/character/src/View/SubMenu/Status/TileInfo.elm (limited to 'src/character/src/View/SubMenu/Status/TileInfo.elm') diff --git a/src/character/src/View/SubMenu/Status/TileInfo.elm b/src/character/src/View/SubMenu/Status/TileInfo.elm new file mode 100644 index 0000000..920b5ce --- /dev/null +++ b/src/character/src/View/SubMenu/Status/TileInfo.elm @@ -0,0 +1,137 @@ +module View.SubMenu.Status.TileInfo exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes + +-- Struct.Map ------------------------------------------------------------------- +import Constants.Movement + +import Struct.Map +import Struct.Event +import Struct.Location +import Struct.Model +import Struct.Tile + +import Util.Html + +import View.Map.Tile + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_icon : (Struct.Tile.Instance -> (Html.Html Struct.Event.Type)) +get_icon tile = + (Html.div + [ + (Html.Attributes.class "battle-tile-card-icon"), + (Html.Attributes.class "battle-info-card-picture"), + (Html.Attributes.class + ( + "battle-tile-variant-" + ++ (toString (Struct.Tile.get_local_variant_ix tile)) + ) + ) + ] + (View.Map.Tile.get_content_html tile) + ) + +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 "battle-info-card-name"), + (Html.Attributes.class "battle-info-card-text-field"), + (Html.Attributes.class "battle-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 "battle-info-card-text-field"), + (Html.Attributes.class "battle-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 "battle-info-card-text-field"), + (Html.Attributes.class "battle-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.Map.try_getting_tile_at loc model.map) of + (Just tile) -> + (Html.div + [ + (Html.Attributes.class "battle-info-card"), + (Html.Attributes.class "battle-tile-card") + ] + [ + (get_name model tile), + (Html.div + [ + (Html.Attributes.class "battle-info-card-top"), + (Html.Attributes.class "battle-tile-card-top") + ] + [ + (get_icon tile), + (get_location tile), + (get_cost tile) + ] + ) + ] + ) + + Nothing -> (Html.text "Error: Unknown tile location selected.") -- cgit v1.2.3-70-g09d2