blob: 2fa64721aac7b39d0424b721926cd265b95f2fd8 (
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
110
111
112
|
module Battlemap.Html exposing (view)
import Array
import Html
import Html.Events
import Battlemap
import Battlemap.Tile
import Battlemap.Direction
import Event
type alias GridBuilder =
{
row : (List (Html.Html Event.Type)),
columns : (List (Html.Html Event.Type)),
row_size : Int,
bmap : Battlemap.Type
}
view_battlemap_cell : Battlemap.Tile.Type -> (Html.Html Event.Type)
view_battlemap_cell t =
(Html.td
[
(Html.Events.onClick
(Battlemap.Tile.get_location t)
),
(Html.Attribute.class (Battlemap.Tile.get_css_class t))
]
[
case (Battlemap.Tile.get_character t) of
(Just char_id) ->
(Character.Html.get_icon
(Character.get model char_id)
)
Nothing -> (Html.text "") -- Meaning no element.
]
)
foldr_to_html : Battlemap.Tile.Type -> GridBuilder -> GridBuilder
foldr_to_html t gb =
if (gb.row_size == gb.bmap.width)
then
{gb |
row = [(view_battlemap_cell t)],
row_size = 1,
columns =
(
(Html.tr [] gb.row) :: gb.columns
)
}
else
{gb |
row = ((view_battlemap_cell t) :: gb.row),
row_size = (gb.row_size + 1)
}
grid_builder_to_html : GridBuilder -> (List (Html.Html Event.Type))
grid_builder_to_html gb =
if (gb.row_size == 0)
then
gb.columns
else
((Html.tr [] gb.row) :: gb.columns)
tiles_grid battlemap =
(Html.table
[
(Html.Attribute.class "battlemap-tiles-grid")
]
(grid_builder_to_html
(Array.foldr
(foldr_to_html)
{
row = [],
columns = [],
row_size = 0,
bmap = battlemap
}
battlemap.content
)
)
)
view : Battlemap.Type -> (Html.Html Event.Type)
view battlemap =
(Html.div
[
(Html.Attribute.class "battlemap-container")
]
[
(Html.div
[
(Html.Attribute.class "battlemap-tiles-container")
]
[ (tiles_grid battlemap) ]
),
case battlemap.navigator of
(Just navigator) ->
(Html.div
[
(Html.Attribute.class "battlemap-navigator-container")
]
[ (Battlemap.Navigator.Html.view battlemap.navigator) ]
)
Nothing -> (Html.text "") -- Meaning no element.
]
)
|