summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battlemap/src/Model.elm6
-rw-r--r--src/battlemap/src/Model/EndTurn.elm12
-rw-r--r--src/battlemap/src/Model/RequestDirection.elm17
-rw-r--r--src/battlemap/src/Model/SelectCharacter.elm10
-rw-r--r--src/battlemap/src/Model/SelectTile.elm32
-rw-r--r--src/battlemap/src/UI.elm13
-rw-r--r--src/battlemap/src/View/Footer/TabMenu/Status.elm8
7 files changed, 70 insertions, 28 deletions
diff --git a/src/battlemap/src/Model.elm b/src/battlemap/src/Model.elm
index 8f932aa..d770711 100644
--- a/src/battlemap/src/Model.elm
+++ b/src/battlemap/src/Model.elm
@@ -21,9 +21,9 @@ import Character
type State =
Default
- | MovingCharacterWithButtons Character.Ref
- | MovingCharacterWithClick Character.Ref
- | FocusingTile Battlemap.Location.Ref
+ | ControllingCharacter Character.Ref
+ | InspectingTile Battlemap.Location.Ref
+ | InspectingCharacter Character.Ref
type alias Type =
{
diff --git a/src/battlemap/src/Model/EndTurn.elm b/src/battlemap/src/Model/EndTurn.elm
index 9ec76fb..e7fbe3c 100644
--- a/src/battlemap/src/Model/EndTurn.elm
+++ b/src/battlemap/src/Model/EndTurn.elm
@@ -1,7 +1,10 @@
module Model.EndTurn exposing (apply_to)
+-- Elm -------------------------------------------------------------------------
import Dict
+-- Battlemap -------------------------------------------------------------------
+
import Battlemap
import Character
@@ -10,6 +13,9 @@ import Error
import Model
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
make_it_so : Model.Type -> Character.Ref -> Model.Type
make_it_so model char_ref =
case (Battlemap.try_getting_navigator_location model.battlemap) of
@@ -39,11 +45,13 @@ make_it_so model char_ref =
)
)
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
apply_to : Model.Type -> Model.Type
apply_to model =
case (Model.get_state model) of
- (Model.MovingCharacterWithButtons char_ref) -> (make_it_so model char_ref)
- (Model.MovingCharacterWithClick char_ref) -> (make_it_so model char_ref)
+ (Model.ControllingCharacter char_ref) -> (make_it_so model char_ref)
_ ->
(Model.invalidate
model
diff --git a/src/battlemap/src/Model/RequestDirection.elm b/src/battlemap/src/Model/RequestDirection.elm
index f39b4f8..3c48c93 100644
--- a/src/battlemap/src/Model/RequestDirection.elm
+++ b/src/battlemap/src/Model/RequestDirection.elm
@@ -1,15 +1,22 @@
module Model.RequestDirection exposing (apply_to)
+-- Elm -------------------------------------------------------------------------
import Dict
+-- Battlemap -------------------------------------------------------------------
import Battlemap
import Battlemap.Direction
import Character
+import UI
+
import Model
import Error
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
make_it_so : (
Model.Type ->
Character.Ref ->
@@ -28,7 +35,7 @@ make_it_so model char_ref dir =
case new_bmap of
(Just bmap) ->
{model |
- state = (Model.MovingCharacterWithButtons char_ref),
+ ui = (UI.set_has_just_used_manual_controls model.ui True),
battlemap = bmap
}
@@ -41,13 +48,13 @@ make_it_so model char_ref dir =
)
)
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
apply_to : Model.Type -> Battlemap.Direction.Type -> Model.Type
apply_to model dir =
case (Model.get_state model) of
- (Model.MovingCharacterWithButtons char_ref) ->
- (make_it_so model char_ref dir)
-
- (Model.MovingCharacterWithClick char_ref) ->
+ (Model.ControllingCharacter char_ref) ->
(make_it_so model char_ref dir)
_ ->
diff --git a/src/battlemap/src/Model/SelectCharacter.elm b/src/battlemap/src/Model/SelectCharacter.elm
index b624ef9..a6b4a6b 100644
--- a/src/battlemap/src/Model/SelectCharacter.elm
+++ b/src/battlemap/src/Model/SelectCharacter.elm
@@ -1,7 +1,9 @@
module Model.SelectCharacter exposing (apply_to)
+-- Elm -------------------------------------------------------------------------
import Dict
+-- Battlemap -------------------------------------------------------------------
import Character
import Battlemap
@@ -9,6 +11,9 @@ import Battlemap
import Model
import Error
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
make_it_so : Model.Type -> Character.Ref -> Model.Type
make_it_so model char_id =
case (Dict.get char_id model.characters) of
@@ -16,7 +21,7 @@ make_it_so model char_id =
if ((Character.get_team char) == model.controlled_team)
then
{model |
- state = (Model.MovingCharacterWithClick char_id),
+ state = (Model.ControllingCharacter char_id),
battlemap =
(Battlemap.set_navigator
(Character.get_location char)
@@ -44,6 +49,9 @@ make_it_so model char_id =
)
)
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
apply_to : Model.Type -> Character.Ref -> Model.Type
apply_to model char_id =
case (Model.get_state model) of
diff --git a/src/battlemap/src/Model/SelectTile.elm b/src/battlemap/src/Model/SelectTile.elm
index 4a9032f..9ad9cdd 100644
--- a/src/battlemap/src/Model/SelectTile.elm
+++ b/src/battlemap/src/Model/SelectTile.elm
@@ -1,5 +1,6 @@
module Model.SelectTile exposing (apply_to)
+-- Battlemap -------------------------------------------------------------------
import Battlemap
import Battlemap.Direction
import Battlemap.Location
@@ -9,9 +10,12 @@ import Character
import Model.RequestDirection
import Model.EndTurn
+import UI
import Model
-import Error
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
autopilot : Battlemap.Direction.Type -> Model.Type -> Model.Type
autopilot dir model =
(Model.RequestDirection.apply_to model dir)
@@ -23,13 +27,15 @@ go_to_tile model char_ref loc_ref =
if (loc_ref == (Battlemap.Location.get_ref nav_loc))
then
-- We are already there.
- if (model.state == (Model.MovingCharacterWithClick char_ref))
+ if (UI.has_just_used_manual_controls model.ui)
then
+ -- And we didn't just click on that tile.
+ {model |
+ ui = (UI.set_has_just_used_manual_controls model.ui False)
+ }
+ else
-- And we just clicked on that tile.
(Model.EndTurn.apply_to model)
- else
- -- And we didn't just click on that tile.
- {model | state = (Model.MovingCharacterWithClick char_ref)}
else
-- We have to try getting there.
case
@@ -53,7 +59,11 @@ go_to_tile model char_ref loc_ref =
)
in
{new_model |
- state = (Model.MovingCharacterWithClick char_ref)
+ ui =
+ (UI.set_has_just_used_manual_controls
+ new_model.ui
+ False
+ )
}
Nothing -> -- Clicked outside of the range indicator
@@ -61,13 +71,13 @@ go_to_tile model char_ref loc_ref =
Nothing -> -- Clicked outside of the range indicator
(Model.reset model model.characters)
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
apply_to : Model.Type -> Battlemap.Location.Ref -> Model.Type
apply_to model loc_ref =
case (Model.get_state model) of
- (Model.MovingCharacterWithButtons char_ref) ->
- (go_to_tile model char_ref loc_ref)
-
- (Model.MovingCharacterWithClick char_ref) ->
+ (Model.ControllingCharacter char_ref) ->
(go_to_tile model char_ref loc_ref)
- _ -> {model | state = (Model.FocusingTile loc_ref)}
+ _ -> {model | state = (Model.InspectingTile loc_ref)}
diff --git a/src/battlemap/src/UI.elm b/src/battlemap/src/UI.elm
index b0cea8f..99d4c5e 100644
--- a/src/battlemap/src/UI.elm
+++ b/src/battlemap/src/UI.elm
@@ -14,7 +14,9 @@ module UI exposing
to_string,
get_all_tabs,
-- Manual Controls
- has_manual_controls_enabled
+ has_manual_controls_enabled,
+ has_just_used_manual_controls,
+ set_has_just_used_manual_controls
)
--------------------------------------------------------------------------------
@@ -29,6 +31,7 @@ type alias Type =
{
zoom_level : Float,
show_manual_controls : Bool,
+ just_used_manual_controls : Bool,
displayed_tab : (Maybe Tab)
}
@@ -44,6 +47,7 @@ default =
{
zoom_level = 1.0,
show_manual_controls = True,
+ just_used_manual_controls = False,
displayed_tab = (Just StatusTab)
}
@@ -81,6 +85,13 @@ get_all_tabs =
has_manual_controls_enabled : Type -> Bool
has_manual_controls_enabled ui = ui.show_manual_controls
+has_just_used_manual_controls : Type -> Bool
+has_just_used_manual_controls ui = ui.just_used_manual_controls
+
+set_has_just_used_manual_controls : Type -> Bool -> Type
+set_has_just_used_manual_controls ui val =
+ {ui | just_used_manual_controls = val}
+
toggle_manual_controls : Type -> Type
toggle_manual_controls ui =
if (ui.show_manual_controls)
diff --git a/src/battlemap/src/View/Footer/TabMenu/Status.elm b/src/battlemap/src/View/Footer/TabMenu/Status.elm
index 814aaee..a908521 100644
--- a/src/battlemap/src/View/Footer/TabMenu/Status.elm
+++ b/src/battlemap/src/View/Footer/TabMenu/Status.elm
@@ -113,13 +113,11 @@ get_html model =
[
(case model.state of
Model.Default -> (Html.text "Click on a character to control it.")
- (Model.FocusingTile tile_loc) ->
+ (Model.InspectingTile tile_loc) ->
(get_tile_info_html model (Battlemap.Location.from_ref tile_loc))
-
- (Model.MovingCharacterWithButtons char_ref) ->
+ (Model.InspectingCharacter char_ref) ->
(get_char_info_html model char_ref)
-
- (Model.MovingCharacterWithClick char_ref) ->
+ (Model.ControllingCharacter char_ref) ->
(get_char_info_html model char_ref)
)
]