summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-02-14 17:47:05 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-02-14 17:47:05 +0100
commit9fa3c1475d4da27766a6718a5bb35610b148ca79 (patch)
treec4f8d89f015afe5064fa3ce51ed8ecf8c583c17a
parent8ff327c656ccc0253be9c8db3bc8e4f3d8f39bc0 (diff)
Removes hardcoded number of tile types.
-rw-r--r--src/asset/www/data/tiles.json.m42
-rw-r--r--src/map-editor/src/Struct/Tile.elm12
-rw-r--r--src/map-editor/src/View/SubMenu.elm2
-rw-r--r--src/map-editor/src/View/SubMenu/Tiles.elm50
4 files changed, 37 insertions, 29 deletions
diff --git a/src/asset/www/data/tiles.json.m4 b/src/asset/www/data/tiles.json.m4
index 7eb6a4b..99dc7c4 100644
--- a/src/asset/www/data/tiles.json.m4
+++ b/src/asset/www/data/tiles.json.m4
@@ -1,6 +1,6 @@
[
m4_include(__MAKEFILE_DATA_DIR/tile/global.m4.conf)m4_dnl
-m4_include(__MAKEFILE_DATA_DIR/tile/error.m4d)m4_dnl
+m4_include(__MAKEFILE_DATA_DIR/tile/special.m4d)m4_dnl
m4_include(__MAKEFILE_DATA_DIR/tile/grassland.m4d)m4_dnl
m4_include(__MAKEFILE_DATA_DIR/tile/mud.m4d)m4_dnl
m4_include(__MAKEFILE_DATA_DIR/tile/water.m4d)m4_dnl
diff --git a/src/map-editor/src/Struct/Tile.elm b/src/map-editor/src/Struct/Tile.elm
index 8a3677c..d2c75fc 100644
--- a/src/map-editor/src/Struct/Tile.elm
+++ b/src/map-editor/src/Struct/Tile.elm
@@ -9,6 +9,7 @@ module Struct.Tile exposing
new,
clone_instance,
new_instance,
+ default_instance,
new_border,
error_tile_instance,
get_id,
@@ -136,6 +137,17 @@ new_border type_id variant_id =
variant_id = variant_id
}
+default_instance : Type -> Instance
+default_instance tile =
+ (new_instance
+ {x = 0, y = 0}
+ tile.id
+ "0"
+ tile.crossing_cost
+ tile.family
+ []
+ )
+
new_instance : (
Struct.Location.Type ->
Ref ->
diff --git a/src/map-editor/src/View/SubMenu.elm b/src/map-editor/src/View/SubMenu.elm
index 89ea92f..0b1fbea 100644
--- a/src/map-editor/src/View/SubMenu.elm
+++ b/src/map-editor/src/View/SubMenu.elm
@@ -29,7 +29,7 @@ get_inner_html model tab =
(View.SubMenu.Status.get_html model)
Struct.UI.TilesTab ->
- (View.SubMenu.Tiles.get_html)
+ (View.SubMenu.Tiles.get_html model)
Struct.UI.SettingsTab ->
(View.SubMenu.Settings.get_html model)
diff --git a/src/map-editor/src/View/SubMenu/Tiles.elm b/src/map-editor/src/View/SubMenu/Tiles.elm
index d2c4c5b..8d97269 100644
--- a/src/map-editor/src/View/SubMenu/Tiles.elm
+++ b/src/map-editor/src/View/SubMenu/Tiles.elm
@@ -1,12 +1,15 @@
module View.SubMenu.Tiles exposing (get_html)
-- Elm -------------------------------------------------------------------------
+import Dict
+
import Html
import Html.Attributes
import Html.Events
--- Battlemap -------------------------------------------------------------------
+-- Map Editor ------------------------------------------------------------------
import Struct.Event
+import Struct.Model
import Struct.Tile
import View.Map.Tile
@@ -14,36 +17,29 @@ import View.Map.Tile
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_icon_html : Int -> (Html.Html Struct.Event.Type)
-get_icon_html index =
- let tile_id = (String.fromInt index) in
- (Html.div
- [
- (Html.Attributes.class "map-tile"),
- (Html.Attributes.class "map-tiled"),
- (Html.Attributes.class "clickable"),
- (Html.Attributes.class "map-tile-variant-0"),
- (Html.Events.onClick
- (Struct.Event.TemplateRequested (tile_id, "0"))
- )
- ]
- (View.Map.Tile.get_content_html
- (Struct.Tile.new_instance
- {x = 0, y = 0}
- tile_id
- "0"
- 0
- "0"
- []
- )
+get_icon_html : (
+ (Struct.Tile.Ref, Struct.Tile.Type) ->
+ (Html.Html Struct.Event.Type)
+ )
+get_icon_html (ref, tile) =
+ (Html.div
+ [
+ (Html.Attributes.class "map-tile"),
+ (Html.Attributes.class "map-tiled"),
+ (Html.Attributes.class "clickable"),
+ (Html.Attributes.class "map-tile-variant-0"),
+ (Html.Events.onClick
+ (Struct.Event.TemplateRequested ((Struct.Tile.get_id tile), "0"))
)
- )
+ ]
+ (View.Map.Tile.get_content_html (Struct.Tile.default_instance tile))
+ )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-get_html : (Html.Html Struct.Event.Type)
-get_html =
+get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type)
+get_html model =
(Html.div
[
(Html.Attributes.class "tabmenu-content"),
@@ -51,6 +47,6 @@ get_html =
]
(List.map
(get_icon_html)
- (List.range 0 5)
+ (Dict.toList model.tiles)
)
)