summaryrefslogtreecommitdiff
blob: b5f6b77bb86157b306ed81efcdd335752680d2c2 (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
99
100
101
102
103
104
105
106
107
108
109
module View.SubMenu.Markers exposing (get_html)

-- Elm -------------------------------------------------------------------------
import Dict

import Html
import Html.Attributes
import Html.Events

-- Battle Map ------------------------------------------------------------------
import BattleMap.Struct.Map
import BattleMap.Struct.Marker

-- Local Module ----------------------------------------------------------------
import Struct.Event
import Struct.Model
import Struct.UI

--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_marker_html : (
      String ->
      (String, BattleMap.Struct.Marker.Type)
      -> (Html.Html Struct.Event.Type)
   )
get_marker_html current_selection (ref, marker) =
   (Html.option
      [
         (Html.Attributes.value ref),
         (Html.Attributes.selected (ref == current_selection))
      ]
      [ (Html.text ref) ]
   )

get_selector_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
get_selector_html model =
   (Html.div
      [
      ]
      [
         (Html.select
            [
               (Html.Events.onInput Struct.Event.SetMarkerName)
            ]
            (List.map
               (get_marker_html (Struct.UI.get_marker_name model.ui))
               (Dict.toList (BattleMap.Struct.Map.get_markers model.map))
            )
         ),
         (Html.button
            [
               (Html.Events.onClick  Struct.Event.LoadMarker)
            ]
            [(Html.text "Load")]
         ),
         (Html.button
            [
               (Html.Events.onClick Struct.Event.SaveMarker)
            ]
            [(Html.text "Save")]
         ),
         (Html.button
            [
               (Html.Events.onClick Struct.Event.RemoveMarker)
            ]
            [(Html.text "Remove")]
         )
      ]
   )

new_marker_menu : (Html.Html Struct.Event.Type)
new_marker_menu =
   (Html.div
      []
      [
         (Html.input
            [
               (Html.Events.onInput Struct.Event.SetMarkerName)
            ]
            [
            ]
         ),
         (Html.button
            [
               (Html.Events.onClick Struct.Event.NewMarker)
            ]
            [
               (Html.text "Add")
            ]
         )
      ]
   )

--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
get_html model =
   (Html.div
      [
         (Html.Attributes.class "tabmenu-content"),
         (Html.Attributes.class "tabmenu-markers-tab")
      ]
      [
         (new_marker_menu),
         (get_selector_html model)
      ]
   )