From 96d7905f7faef941f5454fd2c8b0b50a294fd26c Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Wed, 18 Oct 2017 20:59:41 +0200 Subject: Borked mouse controls for the navigator, it seems. --- elm/battlemap/src/View/Battlemap.elm | 88 ++++++++++++++++++++------ elm/battlemap/src/View/Battlemap/Navigator.elm | 17 +++++ elm/battlemap/src/View/Battlemap/Tile.elm | 39 ++++++++++++ 3 files changed, 126 insertions(+), 18 deletions(-) create mode 100644 elm/battlemap/src/View/Battlemap/Navigator.elm create mode 100644 elm/battlemap/src/View/Battlemap/Tile.elm (limited to 'elm/battlemap/src/View') diff --git a/elm/battlemap/src/View/Battlemap.elm b/elm/battlemap/src/View/Battlemap.elm index 1e10a2a..efe4d1e 100644 --- a/elm/battlemap/src/View/Battlemap.elm +++ b/elm/battlemap/src/View/Battlemap.elm @@ -1,26 +1,78 @@ -module View.Battlemap exposing (view) +module View.Battlemap exposing (get_html) + +import Array + +import List + +import Html +import Html.Attributes +import Html.Events + +import Battlemap + +import Character import View.Battlemap.Tile import View.Battlemap.Navigator -view : Battlemap.Type -> (Html.Html Event.Type) -view battlemap = +import Event +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +char_on_map : Int -> Character.Type -> (Html.Html Event.Type) +char_on_map tile_size char = + let + char_loc = (Character.get_location char) + in + (Html.div + [ + (Html.Attributes.class "battlemap-character-icon"), + (Html.Attributes.class + ("asset-character-icon-" ++ (Character.get_icon_id char)) + ), + (Html.Events.onClick + (Event.CharacterSelected (Character.get_ref char)) + ), + (Html.Attributes.style + [ + ("top", ((toString (char_loc.y * tile_size)) ++ "px")), + ("left", ((toString (char_loc.x * tile_size)) ++ "px")) + ] + ) + ] + [ + ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : ( + Battlemap.Type -> + Int -> + (List Character.Type) -> + (Html.Html Event.Type) + ) +get_html battlemap tile_size characters = (Html.div [ - (Html.Attribute.class "battlemap-container") - ] - [ - ( - , - case battlemap.navigator of - (Just navigator) -> - (Html.div - [ - (Html.Attribute.class "battlemap-navigator-container") - ] - [ (Battlemap.Navigator.Html.view battlemap.navigator) ] - ) - - Nothing -> (Html.text "") -- Meaning no element. + (Html.Attributes.class "battlemap-container") ] + ( + (List.map + (View.Battlemap.Tile.get_html tile_size) + (Array.toList (Battlemap.get_tiles battlemap)) + ) + ++ + (List.map + (char_on_map tile_size) + characters + ) + ++ + case (Battlemap.try_getting_navigator_summary battlemap) of + (Just nav_summary) -> + (View.Battlemap.Navigator.get_html tile_size nav_summary) + + Nothing -> [(Html.text "")] + ) ) diff --git a/elm/battlemap/src/View/Battlemap/Navigator.elm b/elm/battlemap/src/View/Battlemap/Navigator.elm new file mode 100644 index 0000000..4180e6d --- /dev/null +++ b/elm/battlemap/src/View/Battlemap/Navigator.elm @@ -0,0 +1,17 @@ +module View.Battlemap.Navigator exposing (get_html) + +import Html +--import Html.Attributes +--import Html.Events + +--import Battlemap.Location +import Battlemap.Navigator + +import Event + +get_html : ( + Int -> + Battlemap.Navigator.Summary -> + (List (Html.Html Event.Type)) + ) +get_html tile_size nav_summary = [] diff --git a/elm/battlemap/src/View/Battlemap/Tile.elm b/elm/battlemap/src/View/Battlemap/Tile.elm new file mode 100644 index 0000000..d38d84e --- /dev/null +++ b/elm/battlemap/src/View/Battlemap/Tile.elm @@ -0,0 +1,39 @@ +module View.Battlemap.Tile exposing (get_html) + +import Html +import Html.Attributes +import Html.Events + +import Battlemap.Tile +import Battlemap.Location + +import Event + +get_html : ( + Int -> + Battlemap.Tile.Type -> + (Html.Html Event.Type) + ) +get_html tile_size tile = + let + tile_loc = (Battlemap.Tile.get_location tile) + in + (Html.div + [ + (Html.Attributes.class "battlemap-tile-icon"), + (Html.Attributes.class + ("asset-tile-" ++ (toString (Battlemap.Tile.get_icon_id tile))) + ), + (Html.Events.onClick + (Event.TileSelected (Battlemap.Location.get_ref tile_loc)) + ), + (Html.Attributes.style + [ + ("top", ((toString (tile_loc.y * tile_size)) ++ "px")), + ("left", ((toString (tile_loc.x * tile_size)) ++ "px")) + ] + ) + ] + [ + ] + ) -- cgit v1.2.3-70-g09d2