summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/battlemap/elm-package.json3
-rw-r--r--src/battlemap/src/ElmModule/Subscriptions.elm8
-rw-r--r--src/battlemap/src/ElmModule/Update.elm8
-rw-r--r--src/battlemap/src/Struct/Event.elm4
-rw-r--r--src/battlemap/src/Struct/Model.elm10
-rw-r--r--src/battlemap/src/Update/Animate.elm36
-rw-r--r--src/battlemap/src/Update/TestAnimation.elm67
-rw-r--r--src/battlemap/src/View/Battlemap/Character.elm44
-rw-r--r--src/battlemap/src/View/SubMenu/Settings.elm6
9 files changed, 171 insertions, 15 deletions
diff --git a/src/battlemap/elm-package.json b/src/battlemap/elm-package.json
index 5f6573f..78130fd 100644
--- a/src/battlemap/elm-package.json
+++ b/src/battlemap/elm-package.json
@@ -12,7 +12,8 @@
"elm-lang/core": "5.1.1 <= v < 6.0.0",
"elm-lang/dom": "1.1.1 <= v < 2.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0",
- "elm-lang/http": "1.0.0 <= v < 2.0.0"
+ "elm-lang/http": "1.0.0 <= v < 2.0.0",
+ "mdgriffith/elm-style-animation": "3.5.5 <= v < 4.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}
diff --git a/src/battlemap/src/ElmModule/Subscriptions.elm b/src/battlemap/src/ElmModule/Subscriptions.elm
index f342b30..29a94c7 100644
--- a/src/battlemap/src/ElmModule/Subscriptions.elm
+++ b/src/battlemap/src/ElmModule/Subscriptions.elm
@@ -1,6 +1,7 @@
module ElmModule.Subscriptions exposing (..)
-- Elm -------------------------------------------------------------------------
+import Animation
-- Battlemap -------------------------------------------------------------------
import Struct.Model
@@ -14,4 +15,9 @@ import Struct.Event
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
subscriptions : Struct.Model.Type -> (Sub Struct.Event.Type)
-subscriptions model = Sub.none
+subscriptions model =
+ case model.animation of
+ (Just animation) ->
+ (Animation.subscription Struct.Event.Animate [animation])
+
+ Nothing -> Sub.none
diff --git a/src/battlemap/src/ElmModule/Update.elm b/src/battlemap/src/ElmModule/Update.elm
index da3b014..bb1d973 100644
--- a/src/battlemap/src/ElmModule/Update.elm
+++ b/src/battlemap/src/ElmModule/Update.elm
@@ -7,6 +7,7 @@ import Struct.Event
import Struct.Model
import Update.AbortTurn
+import Update.Animate
import Update.AttackWithoutMoving
import Update.ChangeScale
import Update.DisplayCharacterInfo
@@ -20,6 +21,7 @@ import Update.SelectTile
import Update.SendLoadBattlemapRequest
import Update.SwitchTeam
import Update.SwitchWeapon
+import Update.TestAnimation
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
@@ -77,6 +79,9 @@ update event model =
Struct.Event.DebugTeamSwitchRequest ->
(Update.SwitchTeam.apply_to new_model)
+ Struct.Event.DebugTestAnimation ->
+ (Update.TestAnimation.apply_to new_model)
+
(Struct.Event.DebugLoadBattlemapRequest) ->
(Update.SendLoadBattlemapRequest.apply_to new_model)
@@ -86,5 +91,8 @@ update event model =
Struct.Event.WeaponSwitchRequest ->
(Update.SwitchWeapon.apply_to new_model)
+ (Struct.Event.Animate anim_msg) ->
+ (Update.Animate.apply_to model anim_msg)
+
Struct.Event.AbortTurnRequest ->
(Update.AbortTurn.apply_to new_model)
diff --git a/src/battlemap/src/Struct/Event.elm b/src/battlemap/src/Struct/Event.elm
index a57bc2f..9eb1171 100644
--- a/src/battlemap/src/Struct/Event.elm
+++ b/src/battlemap/src/Struct/Event.elm
@@ -1,6 +1,8 @@
module Struct.Event exposing (Type(..), attempted)
-- Elm -------------------------------------------------------------------------
+import Animation
+
import Http
-- Battlemap -------------------------------------------------------------------
@@ -20,6 +22,7 @@ type Type =
| CharacterSelected Int
| DebugLoadBattlemapRequest
| DebugTeamSwitchRequest
+ | DebugTestAnimation
| DirectionRequested Struct.Direction.Type
| Failed Struct.Error.Type
| LookingForCharacter Int
@@ -29,6 +32,7 @@ type Type =
| TabSelected Struct.UI.Tab
| TileSelected Struct.Location.Ref
| TurnEnded
+ | Animate Animation.Msg
| WeaponSwitchRequest
attempted : (Result.Result err val) -> Type
diff --git a/src/battlemap/src/Struct/Model.elm b/src/battlemap/src/Struct/Model.elm
index 85b7f08..26eb7f2 100644
--- a/src/battlemap/src/Struct/Model.elm
+++ b/src/battlemap/src/Struct/Model.elm
@@ -15,15 +15,19 @@ module Struct.Model exposing
)
-- Elm -------------------------------------------------------------------------
-import Dict
+import Animation
+
import Array
+import Dict
+
-- Battlemap -------------------------------------------------------------------
import Struct.Armor
import Struct.Battlemap
import Struct.Character
import Struct.CharacterTurn
import Struct.Error
+import Struct.Event
import Struct.Tile
import Struct.TurnResult
import Struct.UI
@@ -36,6 +40,7 @@ import Util.Array
--------------------------------------------------------------------------------
type alias Type =
{
+ animation: (Maybe Animation.State),
battlemap: Struct.Battlemap.Type,
characters: (Array.Array Struct.Character.Type),
weapons: (Dict.Dict Struct.Weapon.Ref Struct.Weapon.Type),
@@ -58,6 +63,7 @@ type alias Type =
new : Type
new =
{
+ animation = Nothing,
battlemap = (Struct.Battlemap.empty),
characters = (Array.empty),
weapons = (Dict.empty),
@@ -116,6 +122,7 @@ add_tile tl model =
reset : Type -> Type
reset model =
{model |
+ animation = Nothing,
error = Nothing,
ui =
(Struct.UI.reset_displayed_nav
@@ -127,6 +134,7 @@ reset model =
full_debug_reset : Type -> Type
full_debug_reset model =
{model |
+ animation = Nothing,
battlemap = (Struct.Battlemap.empty),
characters = (Array.empty),
weapons = (Dict.empty),
diff --git a/src/battlemap/src/Update/Animate.elm b/src/battlemap/src/Update/Animate.elm
new file mode 100644
index 0000000..30c6b8e
--- /dev/null
+++ b/src/battlemap/src/Update/Animate.elm
@@ -0,0 +1,36 @@
+module Update.Animate exposing (apply_to)
+
+-- Elm -------------------------------------------------------------------------
+import Animation
+
+-- Battlemap -------------------------------------------------------------------
+import Struct.Model
+import Struct.Event
+
+type alias AnimationType = (Animation.State)
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+apply_to : (
+ Struct.Model.Type ->
+ Animation.Msg ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+apply_to model anim_msg =
+ (
+ (
+ case model.animation of
+ (Just curr_anim) ->
+ {model |
+ animation = (Just (Animation.update anim_msg curr_anim))
+ }
+
+ Nothing ->
+ model
+ ),
+ Cmd.none
+ )
diff --git a/src/battlemap/src/Update/TestAnimation.elm b/src/battlemap/src/Update/TestAnimation.elm
new file mode 100644
index 0000000..c36284f
--- /dev/null
+++ b/src/battlemap/src/Update/TestAnimation.elm
@@ -0,0 +1,67 @@
+module Update.TestAnimation exposing (apply_to)
+
+-- Elm -------------------------------------------------------------------------
+import Animation
+
+-- Battlemap -------------------------------------------------------------------
+import Struct.Model
+import Struct.Event
+
+type alias AnimationType = (Animation.State)
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+no_animation : AnimationType
+no_animation =
+ (Animation.style
+ [
+ (Animation.translate (Animation.percent 0.0) (Animation.percent 0.0))
+ ]
+ )
+
+queue_go_up : AnimationType -> AnimationType
+queue_go_up current_animation =
+ (Animation.queue
+ [
+ (Animation.to
+ [
+ (Animation.translate
+ (Animation.percent 0.0)
+ (Animation.percent 100.0)
+ )
+ ]
+ )
+ ]
+ current_animation
+ )
+
+queue_go_right : AnimationType -> AnimationType
+queue_go_right current_animation =
+ (Animation.queue
+ [
+ (Animation.to
+ [
+ (Animation.translate
+ (Animation.percent 100.0)
+ (Animation.percent 0.0)
+ )
+ ]
+ )
+ ]
+ current_animation
+ )
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+apply_to : (
+ Struct.Model.Type ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+apply_to model =
+ (
+ {model |
+ animation = (Just (queue_go_right (queue_go_up (no_animation))))
+ },
+ Cmd.none
+ )
diff --git a/src/battlemap/src/View/Battlemap/Character.elm b/src/battlemap/src/View/Battlemap/Character.elm
index a32ef5e..f53d8de 100644
--- a/src/battlemap/src/View/Battlemap/Character.elm
+++ b/src/battlemap/src/View/Battlemap/Character.elm
@@ -1,6 +1,8 @@
module View.Battlemap.Character exposing (get_html)
-- Elm -------------------------------------------------------------------------
+import Animation
+
import Html
import Html.Attributes
import Html.Events
@@ -118,20 +120,38 @@ get_actual_html : (
)
get_actual_html model char =
(Html.div
- [
- (Html.Attributes.class "battlemap-tiled"),
- (Html.Attributes.class "battlemap-character-icon"),
- (get_activation_level_class char),
- (get_alliance_class model char),
- (get_position_style char),
- (get_focus_class model char),
- (Html.Attributes.class "clickable"),
- (Html.Events.onClick
- (Struct.Event.CharacterSelected
- (Struct.Character.get_index char)
+ (
+ [
+ (Html.Attributes.class "battlemap-tiled"),
+ (Html.Attributes.class "battlemap-character-icon"),
+ (get_activation_level_class char),
+ (get_alliance_class model char),
+ (get_position_style char),
+ (get_focus_class model char),
+ (Html.Attributes.class "clickable"),
+ (Html.Events.onClick
+ (Struct.Event.CharacterSelected
+ (Struct.Character.get_index char)
+ )
+ )
+ ]
+ ++
+ (
+ if
+ (
+ (Struct.UI.get_previous_action model.ui)
+ ==
+ (Just (Struct.UI.SelectedCharacter (Struct.Character.get_index char)))
)
+ then
+ (case model.animation of
+ (Just animation) -> (Animation.render animation)
+ Nothing -> []
+ )
+ else
+ []
)
- ]
+ )
[
(get_body_html char),
(get_head_html char)
diff --git a/src/battlemap/src/View/SubMenu/Settings.elm b/src/battlemap/src/View/SubMenu/Settings.elm
index 3bd64ff..22aa99a 100644
--- a/src/battlemap/src/View/SubMenu/Settings.elm
+++ b/src/battlemap/src/View/SubMenu/Settings.elm
@@ -48,6 +48,12 @@ get_html model =
(Html.Events.onClick Struct.Event.DebugLoadBattlemapRequest)
]
[ (Html.text "[DEBUG] Load battlemap") ]
+ ),
+ (Html.button
+ [
+ (Html.Events.onClick Struct.Event.DebugTestAnimation)
+ ]
+ [ (Html.text "[DEBUG] Test animations") ]
)
]
)