summaryrefslogtreecommitdiff
blob: aa83bd6a5757fc6cb080c5e449c8b4849a17bf67 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
module Struct.UI exposing
   (
      Type,
      Tab(..),
      Action(..),
      default,
      -- Zoom
      get_zoom_level,
      reset_zoom_level,
      mod_zoom_level,
      -- Tab
      try_getting_displayed_tab,
      set_displayed_tab,
      reset_displayed_tab,
      to_string,
      get_all_tabs,
      -- Navigator
      try_getting_displayed_nav,
      set_displayed_nav,
      reset_displayed_nav,
      -- Previous Action
      get_previous_action,
      set_previous_action
   )

-- Battlemap -------------------------------------------------------------------
import Struct.Location

--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
type Tab =
   StatusTab
   | TilesTab
   | SettingsTab

type Action =
   SelectedLocation Struct.Location.Ref

type alias Type =
   {
      zoom_level : Float,
      displayed_tab : (Maybe Tab),
      previous_action : (Maybe Action)
   }

--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
default : Type
default =
   {
      zoom_level = 1.0,
      displayed_tab = Nothing,
      previous_action = Nothing
   }

-- Zoom ------------------------------------------------------------------------
get_zoom_level : Type -> Float
get_zoom_level ui = ui.zoom_level

reset_zoom_level : Type -> Type
reset_zoom_level ui = {ui | zoom_level = 1.0}

mod_zoom_level : Float -> Type -> Type
mod_zoom_level mod ui = {ui | zoom_level = (mod * ui.zoom_level)}

-- Tab -------------------------------------------------------------------------
try_getting_displayed_tab : Type -> (Maybe Tab)
try_getting_displayed_tab ui = ui.displayed_tab

set_displayed_tab : Tab -> Type -> Type
set_displayed_tab tab ui = {ui | displayed_tab = (Just tab)}

reset_displayed_tab : Type -> Type
reset_displayed_tab ui = {ui | displayed_tab = Nothing}

to_string : Tab -> String
to_string tab =
   case tab of
      StatusTab -> "Status"
      TilesTab -> "Tiles"
      SettingsTab -> "Settings"

get_all_tabs : (List Tab)
get_all_tabs =
   [StatusTab, TilesTab, SettingsTab]

-- Previous Action -------------------------------------------------------------
set_previous_action : (Maybe Action) -> Type -> Type
set_previous_action act ui = {ui | previous_action = act}

get_previous_action : Type -> (Maybe Action)
get_previous_action ui = ui.previous_action