blob: e482e2f2110be6b9c75d136dac5b0c72f52b1871 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
module Update.DisplayCharacterInfo exposing (apply_to)
-- Elm -------------------------------------------------------------------------
import Array
import Task
-- Map -------------------------------------------------------------------
import Action.Scroll
import Struct.Character
import Struct.Event
import Struct.Model
import Struct.UI
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
scroll_to_char : Struct.Model.Type -> Int -> (Cmd Struct.Event.Type)
scroll_to_char model char_ix =
case (Array.get char_ix model.characters) of
(Just char) ->
(Task.attempt
(Struct.Event.attempted)
(Action.Scroll.to
(Struct.Character.get_location char)
model.ui
)
)
Nothing ->
Cmd.none
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
apply_to : (
Struct.Model.Type ->
Int ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
apply_to model target_ref =
(
{model |
ui =
(Struct.UI.set_displayed_tab
Struct.UI.StatusTab
(Struct.UI.set_previous_action
(Just (Struct.UI.SelectedCharacter target_ref))
model.ui
)
)
},
(scroll_to_char model target_ref)
)
|