summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-07-12 21:09:37 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-07-12 21:09:37 +0200
commiteb7c4865b5311ca559b12fe649ea3f865d1f66b5 (patch)
tree8165f1c587e7e8843a4712febf8136a05d105f60
parent559f46102c656ace81a262f0edff28b617a7ec88 (diff)
The map editor now displays it correctly.
-rw-r--r--Makefile1
-rw-r--r--mk/preprocessor.mk5
-rw-r--r--src/asset/www/data/tiles.json38
-rw-r--r--src/asset/www/data/tiles.json.m48
-rw-r--r--src/map-editor/src/Comm/LoadTiles.elm31
-rw-r--r--src/map-editor/src/Comm/Send.elm16
-rw-r--r--src/map-editor/src/Constants/IO.elm.m46
-rw-r--r--src/map-editor/src/ElmModule/Init.elm15
8 files changed, 115 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 68fd02c..f47634c 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ MODULES ?= battle global asset map-editor
SRC_DIR = ${CURDIR}/src
WWW_DIR = ${CURDIR}/www
+DATA_DIR ?= /my/src/tacticians-server/data/
################################################################################
## MAKEFILE MAGIC ##############################################################
################################################################################
diff --git a/mk/preprocessor.mk b/mk/preprocessor.mk
index 285c9fa..9046fb0 100644
--- a/mk/preprocessor.mk
+++ b/mk/preprocessor.mk
@@ -9,6 +9,9 @@ CONFIG_FILE ?= ${CURDIR}/conf/constants.conf
PREPROCESSOR_FILES = $(shell find ${CURDIR} -name "*.m4")
PREPROCESSED_FILES = $(patsubst %.m4,%,$(PREPROCESSOR_FILES))
+MAKEFILE_TO_M4 = \
+ --define=__MAKEFILE_DATA_DIR=$(DATA_DIR)
+
################################################################################
## SANITY CHECKS ###############################################################
################################################################################
@@ -25,7 +28,7 @@ PREPROCESSOR_RESULT = $(PREPROCESSED_FILES)
## INTERNAL RULES ##############################################################
################################################################################
$(PREPROCESSED_FILES): %: %.m4 .PHONY
- m4 -P $(CONFIG_FILE) $< > $@
+ m4 -P $(MAKEFILE_TO_M4) $(CONFIG_FILE) $< > $@
.PHONY:
diff --git a/src/asset/www/data/tiles.json b/src/asset/www/data/tiles.json
new file mode 100644
index 0000000..0c8f9fc
--- /dev/null
+++ b/src/asset/www/data/tiles.json
@@ -0,0 +1,38 @@
+[
+
+ {
+ "msg": "add_tile",
+ "id": 0,
+ "nam": "[Grassland] Grass",
+ "ct": 6,
+ "rmi": 0,
+ "rma": 0
+ },
+ {
+ "msg": "add_tile",
+ "id": 1,
+ "nam": "[Grassland] Mushroom Infestation",
+ "ct": 12,
+ "rmi": 1,
+ "rma": 1
+ },
+ {
+ "msg": "add_tile",
+ "id": 2,
+ "nam": "[Grassland] Tree Remains",
+ "ct": 24,
+ "rmi": 2,
+ "rma": 2
+ },
+ {
+ "msg": "add_tile",
+ "id": 3,
+ "nam": "[Grassland] Clear Water",
+ "ct": 201,
+ "rmi": 3,
+ "rma": 17
+ },
+ {
+ "msg": "okay"
+ }
+]
diff --git a/src/asset/www/data/tiles.json.m4 b/src/asset/www/data/tiles.json.m4
new file mode 100644
index 0000000..fcbbd39
--- /dev/null
+++ b/src/asset/www/data/tiles.json.m4
@@ -0,0 +1,8 @@
+[
+m4_include(__MAKEFILE_DATA_DIR/tile/global.m4.conf)m4_dnl
+__TILE_CLASS_USE_JSON_STYLE
+m4_include(__MAKEFILE_DATA_DIR/tile/grassland.m4d)m4_dnl
+ {
+ "msg": "okay"
+ }
+]
diff --git a/src/map-editor/src/Comm/LoadTiles.elm b/src/map-editor/src/Comm/LoadTiles.elm
new file mode 100644
index 0000000..6175e7a
--- /dev/null
+++ b/src/map-editor/src/Comm/LoadTiles.elm
@@ -0,0 +1,31 @@
+module Comm.LoadTiles exposing (try)
+
+-- Elm -------------------------------------------------------------------------
+
+-- Battlemap -------------------------------------------------------------------
+import Comm.Send
+
+import Constants.IO
+
+import Struct.Event
+import Struct.Model
+
+--------------------------------------------------------------------------------
+-- TYPES ------------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+try : Struct.Model.Type -> (Maybe (Cmd Struct.Event.Type))
+try model =
+ (Just
+ (Comm.Send.empty_request
+ model
+ Constants.IO.tiles_data_url
+ )
+ )
diff --git a/src/map-editor/src/Comm/Send.elm b/src/map-editor/src/Comm/Send.elm
index 2b9c4aa..f620f68 100644
--- a/src/map-editor/src/Comm/Send.elm
+++ b/src/map-editor/src/Comm/Send.elm
@@ -1,4 +1,4 @@
-module Comm.Send exposing (try_sending)
+module Comm.Send exposing (try_sending, empty_request)
-- Elm -------------------------------------------------------------------------
import Http
@@ -66,3 +66,17 @@ try_sending model recipient try_encoding_fun =
)
Nothing -> Nothing
+
+empty_request : (
+ Struct.Model.Type ->
+ String ->
+ (Cmd Struct.Event.Type)
+ )
+empty_request model recipient =
+ (Http.send
+ Struct.Event.ServerReplied
+ (Http.get
+ recipient
+ (Json.Decode.list (decode))
+ )
+ )
diff --git a/src/map-editor/src/Constants/IO.elm.m4 b/src/map-editor/src/Constants/IO.elm.m4
index ed66c79..397efaa 100644
--- a/src/map-editor/src/Constants/IO.elm.m4
+++ b/src/map-editor/src/Constants/IO.elm.m4
@@ -3,6 +3,12 @@ module Constants.IO exposing (..)
base_url : String
base_url = "__CONF_SERVER_URL"
+data_url : String
+data_url = (base_url ++ "/asset/data/")
+
+tiles_data_url : String
+tiles_data_url = (base_url ++ "/asset/data/tiles.json")
+
map_editor_handler_url : String
map_editor_handler_url = (base_url ++ "/handler/map-editor")
diff --git a/src/map-editor/src/ElmModule/Init.elm b/src/map-editor/src/ElmModule/Init.elm
index 73230a3..09034dc 100644
--- a/src/map-editor/src/ElmModule/Init.elm
+++ b/src/map-editor/src/ElmModule/Init.elm
@@ -3,6 +3,7 @@ module ElmModule.Init exposing (init)
-- Elm -------------------------------------------------------------------------
-- Battlemap -------------------------------------------------------------------
+import Comm.LoadTiles
import Comm.LoadMap
import Struct.Event
@@ -21,8 +22,16 @@ init flags =
let model = (Struct.Model.new flags) in
(
model,
- (case (Comm.LoadMap.try model) of
- (Just cmd) -> cmd
- Nothing -> Cmd.none
+ (Cmd.batch
+ [
+ (case (Comm.LoadTiles.try model) of
+ (Just cmd) -> cmd
+ Nothing -> Cmd.none
+ ),
+ (case (Comm.LoadMap.try model) of
+ (Just cmd) -> cmd
+ Nothing -> Cmd.none
+ )
+ ]
)
)