| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2017-12-12 13:04:04 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2017-12-12 13:04:04 +0100 | 
| commit | 7e38eda602e083a4f9d978fcc5ad93a3b17c6a1b (patch) | |
| tree | 3340d523cb07b0b39fbbc87bb95870f99aad61cf /src/battlemap | |
| parent | eb33b4f122074659c04786d9e6fa57c6a06f3e8d (diff) | |
AttackMarkers not interactive, removes Model.State.
Diffstat (limited to 'src/battlemap')
| -rw-r--r-- | src/battlemap/src/Shim/Model.elm | 1 | ||||
| -rw-r--r-- | src/battlemap/src/Struct/Model.elm | 12 | ||||
| -rw-r--r-- | src/battlemap/src/Update/SelectCharacter.elm | 1 | ||||
| -rw-r--r-- | src/battlemap/src/Update/SelectTile.elm | 12 | ||||
| -rw-r--r-- | src/battlemap/src/View/Battlemap.elm | 1 | ||||
| -rw-r--r-- | src/battlemap/src/View/Battlemap/Navigator.elm | 46 | ||||
| -rw-r--r-- | src/battlemap/src/View/SideBar/TabMenu/Status.elm | 61 | 
7 files changed, 54 insertions, 80 deletions
| diff --git a/src/battlemap/src/Shim/Model.elm b/src/battlemap/src/Shim/Model.elm index a03be3c..01ee8c8 100644 --- a/src/battlemap/src/Shim/Model.elm +++ b/src/battlemap/src/Shim/Model.elm @@ -19,7 +19,6 @@ import Struct.UI  --generate : Struct.Model.Type  generate =     { -      state = Struct.Model.Default,        battlemap = (Struct.Battlemap.empty),        characters = (Dict.empty),        error = Nothing, diff --git a/src/battlemap/src/Struct/Model.elm b/src/battlemap/src/Struct/Model.elm index fb8a72a..faef50b 100644 --- a/src/battlemap/src/Struct/Model.elm +++ b/src/battlemap/src/Struct/Model.elm @@ -1,9 +1,7 @@  module Struct.Model exposing     (        Type, -      State(..),        add_character, -      get_state,        invalidate,        reset,        clear_error @@ -23,14 +21,8 @@ import Struct.UI  --------------------------------------------------------------------------------  -- TYPES -----------------------------------------------------------------------  -------------------------------------------------------------------------------- -type State = -   Default -   | InspectingTile Struct.Location.Ref -   | InspectingCharacter Struct.Character.Ref -  type alias Type =     { -      state: State,        battlemap: Struct.Battlemap.Type,        characters: (Dict.Dict Struct.Character.Ref Struct.Character.Type),        error: (Maybe Struct.Error.Type), @@ -58,13 +50,9 @@ add_character model char =           )     } -get_state : Type -> State -get_state model = model.state -  reset : Type -> (Dict.Dict Struct.Character.Ref Struct.Character.Type) -> Type  reset model characters =     {model | -      state = Default,        characters = characters,        error = Nothing,        ui = (Struct.UI.set_previous_action model.ui Nothing), diff --git a/src/battlemap/src/Update/SelectCharacter.elm b/src/battlemap/src/Update/SelectCharacter.elm index 42c53d6..e8dd734 100644 --- a/src/battlemap/src/Update/SelectCharacter.elm +++ b/src/battlemap/src/Update/SelectCharacter.elm @@ -44,7 +44,6 @@ select_character model target_char_id target_char =     if (Struct.Character.is_enabled target_char)     then        {model | -         state = Struct.Model.Default,           char_turn =              (Struct.CharacterTurn.set_navigator                 (Struct.CharacterTurn.set_controlled_character diff --git a/src/battlemap/src/Update/SelectTile.elm b/src/battlemap/src/Update/SelectTile.elm index b44e139..817b511 100644 --- a/src/battlemap/src/Update/SelectTile.elm +++ b/src/battlemap/src/Update/SelectTile.elm @@ -137,4 +137,14 @@ apply_to model loc_ref =        (Just navigator) ->           (go_to_tile model navigator loc_ref) -      _ -> ({model | state = (Struct.Model.InspectingTile loc_ref)}, Cmd.none) +      _ -> +         ( +            {model | +               ui = +                  (Struct.UI.set_previous_action +                     model.ui +                     (Just (Struct.UI.SelectedLocation loc_ref)) +                  ) +            }, +            Cmd.none +         ) diff --git a/src/battlemap/src/View/Battlemap.elm b/src/battlemap/src/View/Battlemap.elm index f52ed4e..e5e9d36 100644 --- a/src/battlemap/src/View/Battlemap.elm +++ b/src/battlemap/src/View/Battlemap.elm @@ -132,6 +132,7 @@ get_html model =              (Just navigator) ->                 (View.Battlemap.Navigator.get_html                    (Struct.Navigator.get_summary navigator) +                  True                 )              Nothing -> diff --git a/src/battlemap/src/View/Battlemap/Navigator.elm b/src/battlemap/src/View/Battlemap/Navigator.elm index 1b99d47..fc32cc0 100644 --- a/src/battlemap/src/View/Battlemap/Navigator.elm +++ b/src/battlemap/src/View/Battlemap/Navigator.elm @@ -20,10 +20,11 @@ import Struct.Navigator  -- LOCAL -----------------------------------------------------------------------  --------------------------------------------------------------------------------  marker_get_html : ( +      Bool ->        (Struct.Location.Ref, Struct.Marker.Type) ->        (Html.Html Struct.Event.Type)     ) -marker_get_html (loc_ref, marker) = +marker_get_html is_interactive (loc_ref, marker) =     (Html.div        [           (Html.Attributes.class "battlemap-marker-icon"), @@ -43,8 +44,14 @@ marker_get_html (loc_ref, marker) =                 "-marker"              )           ), -         (Html.Events.onClick -            (Struct.Event.TileSelected loc_ref) +         ( +            if (is_interactive && (marker == Struct.Marker.CanGoTo)) +            then +               (Html.Events.onClick +                  (Struct.Event.TileSelected loc_ref) +               ) +            else +               (Html.Attributes.class "")           ),           (Html.Attributes.style              ( @@ -178,21 +185,26 @@ mark_the_spot loc origin_dir =  --------------------------------------------------------------------------------  get_html : (        Struct.Navigator.Summary -> +      Bool ->        (List (Html.Html Struct.Event.Type))     ) -get_html nav_summary = -   ( -      (List.map (marker_get_html) nav_summary.markers) -      ++ +get_html nav_summary is_interactive = +   if (is_interactive) +   then        ( -         let -            (final_loc, final_dir, path_node_htmls) = -               (List.foldr -                  (path_node_get_html) -                  (nav_summary.starting_location, Struct.Direction.None, []) -                  nav_summary.path -               ) -         in -            ((mark_the_spot final_loc final_dir) :: path_node_htmls) +         (List.map (marker_get_html True) nav_summary.markers) +         ++ +         ( +            let +               (final_loc, final_dir, path_node_htmls) = +                  (List.foldr +                     (path_node_get_html) +                     (nav_summary.starting_location, Struct.Direction.None, []) +                     nav_summary.path +                  ) +            in +               ((mark_the_spot final_loc final_dir) :: path_node_htmls) +         )        ) -   ) +   else +      (List.map (marker_get_html False) nav_summary.markers) diff --git a/src/battlemap/src/View/SideBar/TabMenu/Status.elm b/src/battlemap/src/View/SideBar/TabMenu/Status.elm index 7309b01..61c0540 100644 --- a/src/battlemap/src/View/SideBar/TabMenu/Status.elm +++ b/src/battlemap/src/View/SideBar/TabMenu/Status.elm @@ -48,32 +48,6 @@ get_char_info_html model char_ref =              )           ) -get_char_attack_info_html : ( -      Struct.Model.Type -> -      Struct.Character.Ref -> -      (Html.Html Struct.Event.Type) -   ) -get_char_attack_info_html model char_ref = -   case (Dict.get char_ref model.characters) of -      Nothing -> (Html.text "Error: Unknown character selected.") -      (Just char) -> -         (Html.text -            ( -               "Attacking " -               ++ char.name -               ++ " (Team " -               ++ (toString (Struct.Character.get_team char)) -               ++ "): " -               ++ (toString (Struct.Character.get_movement_points char)) -               ++ " movement points; " -               ++ (toString (Struct.Character.get_attack_range char)) -               ++ " attack range. Health: " -               ++ (toString (Struct.Character.get_current_health char)) -               ++ "/" -               ++ (toString (Struct.Character.get_max_health char)) -            ) -         ) -  get_error_html : Struct.Error.Type -> (Html.Html Struct.Event.Type)  get_error_html err =     (Html.div @@ -149,28 +123,19 @@ get_html model =           (Html.Attributes.class "battlemap-footer-tabmenu-content"),           (Html.Attributes.class "battlemap-footer-tabmenu-content-status")        ] -      (case model.state of -         (Struct.Model.InspectingTile tile_loc) -> -            [(get_tile_info_html model (Struct.Location.from_ref tile_loc))] - -         (Struct.Model.InspectingCharacter char_ref) -> -            [(get_char_info_html model char_ref)] - -         _ -> -            [ -               (case (Struct.UI.get_previous_action model.ui) of -                  (Just (Struct.UI.SelectedLocation loc)) -> -                     (get_tile_info_html -                        model -                        (Struct.Location.from_ref loc) -                     ) +      [ +         (case (Struct.UI.get_previous_action model.ui) of +            (Just (Struct.UI.SelectedLocation loc)) -> +               (get_tile_info_html +                  model +                  (Struct.Location.from_ref loc) +               ) -                  (Just (Struct.UI.SelectedCharacter target_char)) -> -                     (get_char_info_html model target_char) +            (Just (Struct.UI.SelectedCharacter target_char)) -> +               (get_char_info_html model target_char) -                  _ -> -                     (Html.text "Double-click on a character to control it.") -               ) -            ] -      ) +            _ -> +               (Html.text "Double-click on a character to control it.") +         ) +      ]     ) | 


