summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-05-28 12:28:22 +0200 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-05-28 12:28:22 +0200 |
commit | 72ffbf106d4ac051419edee91bcf8ce657fd1dc0 (patch) | |
tree | ba587de6c62036fc0fda4974a5895c4626d9b9dc /src/battle/src/View | |
parent | 65d258b1b2b9bb02e7b4dec3637c5e138e11f0e6 (diff) |
Adds "movie" controls to the timeline.
Diffstat (limited to 'src/battle/src/View')
-rw-r--r-- | src/battle/src/View/Controlled.elm | 6 | ||||
-rw-r--r-- | src/battle/src/View/SubMenu/Timeline.elm | 96 |
2 files changed, 93 insertions, 9 deletions
diff --git a/src/battle/src/View/Controlled.elm b/src/battle/src/View/Controlled.elm index 8f78fd9..aa34b48 100644 --- a/src/battle/src/View/Controlled.elm +++ b/src/battle/src/View/Controlled.elm @@ -58,7 +58,7 @@ action_or_undo_button current_action relevant_action event = (Html.Attributes.class "action-button"), (action_to_class relevant_action), (Html.Events.onClick Struct.Event.UndoActionRequest), - (Html.Attributes.class "undo") + (Html.Attributes.class "active") ] else [ @@ -147,7 +147,7 @@ path_button char_turn = (Html.Attributes.class "action-button"), (Html.Attributes.class "path-button"), (Html.Events.onClick Struct.Event.UndoActionRequest), - (Html.Attributes.class "undo") + (Html.Attributes.class "active") ] else [ @@ -158,7 +158,7 @@ path_button char_turn = ( if ((Struct.CharacterTurn.get_path char_turn) == []) then "" - else "undo" + else "active" ) ) ] diff --git a/src/battle/src/View/SubMenu/Timeline.elm b/src/battle/src/View/SubMenu/Timeline.elm index 2c1818e..0af85fe 100644 --- a/src/battle/src/View/SubMenu/Timeline.elm +++ b/src/battle/src/View/SubMenu/Timeline.elm @@ -5,6 +5,7 @@ import Array import Html import Html.Attributes +import Html.Events import Html.Lazy -- Shared ---------------------------------------------------------------------- @@ -14,8 +15,9 @@ import Shared.Util.Html import Struct.Battle import Struct.Character import Struct.Event -import Struct.TurnResult import Struct.Model +import Struct.Puppeteer +import Struct.TurnResult import View.SubMenu.Timeline.Attack import View.SubMenu.Timeline.Movement @@ -66,12 +68,11 @@ get_turn_result_html characters player_ix turn_result = (Struct.TurnResult.PlayerTurnStarted pturns) -> (View.SubMenu.Timeline.PlayerTurnStart.get_html pturns) -true_get_html : Struct.Battle.Type -> (Html.Html Struct.Event.Type) -true_get_html battle = +get_events_html : Struct.Battle.Type -> (Html.Html Struct.Event.Type) +get_events_html battle = (Html.div [ - (Html.Attributes.class "tabmenu-content"), - (Html.Attributes.class "tabmenu-timeline-tab") + (Html.Attributes.class "tabmenu-timeline-events") ] (Array.toList (Array.map @@ -84,9 +85,92 @@ true_get_html battle = ) ) +get_skip_to_button : Bool -> (Html.Html Struct.Event.Type) +get_skip_to_button skip_forward = + (Html.button + [ + (Html.Attributes.class + ( + if (skip_forward) + then "skip_forward" + else "skip_backward" + ) + ), + (Html.Events.onClick (Struct.Event.PuppeteerSkipTo skip_forward)) + ] + [ + ] + ) + +get_play_button : Bool -> Bool -> (Html.Html Struct.Event.Type) +get_play_button play_forward current_dir = + (Html.button + [ + (Html.Attributes.class + ( + if (play_forward) + then "play_forward" + else "play_backward" + ) + ), + ( + if (play_forward == current_dir) + then (Html.Attributes.class "active") + else (Html.Events.onClick (Struct.Event.PuppeteerPlay play_forward)) + ) + ] + [ + ] + ) + +get_pause_button : Bool -> (Html.Html Struct.Event.Type) +get_pause_button is_paused = + (Html.button + [ + (Html.Attributes.class "pause"), + (Html.Events.onClick Struct.Event.PuppeteerTogglePause), + (Html.Attributes.class + ( + if (is_paused) + then "active" + else "" + ) + ) + ] + [ + ] + ) + +get_controls_html : Struct.Puppeteer.Type -> (Html.Html Struct.Event.Type) +get_controls_html puppeteer = + let + is_playing_forward = (Struct.Puppeteer.get_is_playing_forward puppeteer) + is_paused = (Struct.Puppeteer.get_is_paused puppeteer) + in + (Html.div + [ + (Html.Attributes.class "tabmenu-timeline-controls") + ] + [ + (get_skip_to_button False), + (get_play_button False is_playing_forward), + (get_pause_button is_paused), + (get_play_button True is_playing_forward), + (get_skip_to_button True) + ] + ) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) get_html model = - (Html.Lazy.lazy (true_get_html) model.battle) + (Html.div + [ + (Html.Attributes.class "tabmenu-content"), + (Html.Attributes.class "tabmenu-timeline-tab") + ] + [ + (get_controls_html model.puppeteer), + (Html.Lazy.lazy (get_events_html) model.battle) + ] + ) |