| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2019-03-04 18:28:50 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2019-03-04 18:28:50 +0100 | 
| commit | b05eb97d89e690737418ca2aa2e49e9c9da83184 (patch) | |
| tree | 8b89d6d479b75b256b610d0a370519a96e451735 /src/map-editor | |
| parent | 85f64582db6f4cc47d04787c9d4180e57b867825 (diff) | |
Adds "focus" mode to map editor
Diffstat (limited to 'src/map-editor')
| -rw-r--r-- | src/map-editor/src/Struct/Toolbox.elm | 42 | ||||
| -rw-r--r-- | src/map-editor/src/Update/SelectTile.elm | 39 | ||||
| -rw-r--r-- | src/map-editor/src/Update/SetToolboxMode.elm | 20 | ||||
| -rw-r--r-- | src/map-editor/src/View/Toolbox.elm | 4 | 
4 files changed, 81 insertions, 24 deletions
| diff --git a/src/map-editor/src/Struct/Toolbox.elm b/src/map-editor/src/Struct/Toolbox.elm index a35ecd7..5f08761 100644 --- a/src/map-editor/src/Struct/Toolbox.elm +++ b/src/map-editor/src/Struct/Toolbox.elm @@ -44,6 +44,8 @@ type Mode =     Draw     | RemoveSelection     | AddSelection +   | Focus +   | Sample  type Shape =     Simple @@ -93,6 +95,16 @@ apply_mode_to loc (tb, map) =              ),              map           ) + +      Focus -> (tb, map) + +      Sample -> +         -- TODO: template = tile at location. +         ( +            tb, +            map +         ) +  get_filled_tiles_internals : (        (Struct.Location.Type -> Bool) ->        (List Struct.Location.Type) -> @@ -203,19 +215,25 @@ get_modes =     [        Draw,        AddSelection, -      RemoveSelection +      RemoveSelection, +      Focus, +      Sample     ]  get_shape : Type -> Shape  get_shape tb = tb.shape -get_shapes : (List Shape) -get_shapes = -   [ -      Simple, -      Fill, -      Square -   ] +get_shapes : Mode -> (List Shape) +get_shapes mode = +   case mode of +      Focus -> [Simple] +      Sample -> [Simple] +      _ -> +         [ +            Simple, +            Fill, +            Square +         ]  get_selection : Type -> (List Struct.Location.Type)  get_selection tb = tb.selection @@ -231,7 +249,13 @@ set_mode : Mode -> Type -> Type  set_mode mode tb =     {tb |        mode = mode, -      square_corner = Nothing +      square_corner = Nothing, +      shape = +         ( +            if (List.member tb.shape (get_shapes mode)) +            then tb.shape +            else Simple +         )     }  set_shape : Shape -> Type -> Type diff --git a/src/map-editor/src/Update/SelectTile.elm b/src/map-editor/src/Update/SelectTile.elm index 260c533..e7eeeb6 100644 --- a/src/map-editor/src/Update/SelectTile.elm +++ b/src/map-editor/src/Update/SelectTile.elm @@ -2,8 +2,9 @@ module Update.SelectTile exposing (apply_to)  -- Elm ------------------------------------------------------------------------- --- Battlemap ------------------------------------------------------------------- +-- Map Editor ------------------------------------------------------------------  import Struct.Event +import Struct.UI  import Struct.Location  import Struct.Model  import Struct.Toolbox @@ -21,18 +22,34 @@ apply_to : (        (Struct.Model.Type, (Cmd Struct.Event.Type))     )  apply_to model loc_ref = -   let -      (toolbox, map) = -         (Struct.Toolbox.apply_to -            (Struct.Location.from_ref loc_ref) -            model.toolbox -            model.map -         ) -   in +   if ((Struct.Toolbox.get_mode model.toolbox) == Struct.Toolbox.Focus) +   then        (           {model | -            toolbox = toolbox, -            map = map +            ui = +               (Struct.UI.set_previous_action +                  (Just (Struct.UI.SelectedLocation loc_ref)) +                  (Struct.UI.set_displayed_tab +                     Struct.UI.StatusTab +                     model.ui +                  ) +               )           },           Cmd.none        ) +   else +      let +         (toolbox, map) = +            (Struct.Toolbox.apply_to +               (Struct.Location.from_ref loc_ref) +               model.toolbox +               model.map +            ) +      in +         ( +            {model | +               toolbox = toolbox, +               map = map +            }, +            Cmd.none +         ) diff --git a/src/map-editor/src/Update/SetToolboxMode.elm b/src/map-editor/src/Update/SetToolboxMode.elm index 3444329..6104558 100644 --- a/src/map-editor/src/Update/SetToolboxMode.elm +++ b/src/map-editor/src/Update/SetToolboxMode.elm @@ -1,10 +1,11 @@  module Update.SetToolboxMode exposing (apply_to)  -- Elm ------------------------------------------------------------------------- --- Battlemap ------------------------------------------------------------------- +-- Map Editor ------------------------------------------------------------------  import Struct.Event -import Struct.Toolbox  import Struct.Model +import Struct.Toolbox +import Struct.UI  --------------------------------------------------------------------------------  -- LOCAL ----------------------------------------------------------------------- @@ -20,6 +21,19 @@ apply_to : (     )  apply_to model mode =     ( -      {model | toolbox = (Struct.Toolbox.set_mode mode model.toolbox)}, +      {model | +         toolbox = (Struct.Toolbox.set_mode mode model.toolbox), +         ui = +            ( +               case mode of +                  Struct.Toolbox.Draw -> +                     (Struct.UI.set_displayed_tab Struct.UI.TilesTab model.ui) + +                  Struct.Toolbox.Focus -> +                     (Struct.UI.set_displayed_tab Struct.UI.StatusTab model.ui) + +                  _ -> model.ui +            ) +      },        Cmd.none     ) diff --git a/src/map-editor/src/View/Toolbox.elm b/src/map-editor/src/View/Toolbox.elm index 9d934e1..a5ab910 100644 --- a/src/map-editor/src/View/Toolbox.elm +++ b/src/map-editor/src/View/Toolbox.elm @@ -51,6 +51,8 @@ get_mode_button current mode =           (Html.text              (case mode of                 Struct.Toolbox.Draw -> "Draw" +               Struct.Toolbox.Focus -> "Focus" +               Struct.Toolbox.Sample -> "Sample"                 Struct.Toolbox.AddSelection -> "Select+"                 Struct.Toolbox.RemoveSelection -> "Select-"              ) @@ -97,7 +99,7 @@ get_shapes_menu_html tb =        [(Html.Attributes.class "toolbox-shapes")]        (List.map           (get_shape_button (Struct.Toolbox.get_shape tb)) -         (Struct.Toolbox.get_shapes) +         (Struct.Toolbox.get_shapes (Struct.Toolbox.get_mode tb))        )     ) | 


