summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/map-editor')
-rw-r--r-- | src/map-editor/src/Comm/AddTile.elm | 26 | ||||
-rw-r--r-- | src/map-editor/src/Comm/LoadMap.elm | 15 | ||||
-rw-r--r-- | src/map-editor/src/Comm/Send.elm | 28 | ||||
-rw-r--r-- | src/map-editor/src/Comm/SendMapUpdate.elm | 15 | ||||
-rw-r--r-- | src/map-editor/src/Comm/SetMap.elm | 28 | ||||
-rw-r--r-- | src/map-editor/src/Struct/Model.elm | 39 | ||||
-rw-r--r-- | src/map-editor/src/Struct/ServerReply.elm | 4 | ||||
-rw-r--r-- | src/map-editor/src/Update/HandleServerReply.elm | 29 | ||||
-rw-r--r-- | src/map-editor/src/Update/SetToolboxTemplate.elm | 10 | ||||
-rw-r--r-- | src/map-editor/src/View/SubMenu/TileStatus.elm | 97 | ||||
-rw-r--r-- | src/map-editor/src/View/SubMenu/Tiles.elm | 20 |
11 files changed, 120 insertions, 191 deletions
diff --git a/src/map-editor/src/Comm/AddTile.elm b/src/map-editor/src/Comm/AddTile.elm deleted file mode 100644 index 797731b..0000000 --- a/src/map-editor/src/Comm/AddTile.elm +++ /dev/null @@ -1,26 +0,0 @@ -module Comm.AddTile exposing (decode) - --- Elm ------------------------------------------------------------------------- -import Json.Decode - --- Battle Map ------------------------------------------------------------------ -import BattleMap.Struct.Tile - --- Local Module ---------------------------------------------------------------- -import Struct.ServerReply - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -internal_decoder : BattleMap.Struct.Tile.Type -> Struct.ServerReply.Type -internal_decoder wp = (Struct.ServerReply.AddTile wp) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -decode : (Json.Decode.Decoder Struct.ServerReply.Type) -decode = (Json.Decode.map (internal_decoder) (BattleMap.Struct.Tile.decoder)) diff --git a/src/map-editor/src/Comm/LoadMap.elm b/src/map-editor/src/Comm/LoadMap.elm index b420d26..fb6e597 100644 --- a/src/map-editor/src/Comm/LoadMap.elm +++ b/src/map-editor/src/Comm/LoadMap.elm @@ -3,6 +3,9 @@ module Comm.LoadMap exposing (try) -- Elm ------------------------------------------------------------------------- import Json.Encode +-- Shared ---------------------------------------------------------------------- +import Struct.Flags + -- Local Module ---------------------------------------------------------------- import Comm.Send @@ -23,8 +26,16 @@ try_encoding model = (Just (Json.Encode.object [ - ("stk", (Json.Encode.string model.session_token)), - ("pid", (Json.Encode.string model.player_id)), + ("stk", + (Json.Encode.string + (Struct.Flags.get_session_token model.flags) + ) + ), + ("pid", + (Json.Encode.string + (Struct.Flags.get_user_id model.flags) + ) + ), ("mid", (Json.Encode.string model.map_id)) ] ) diff --git a/src/map-editor/src/Comm/Send.elm b/src/map-editor/src/Comm/Send.elm index c7b2f39..69e977d 100644 --- a/src/map-editor/src/Comm/Send.elm +++ b/src/map-editor/src/Comm/Send.elm @@ -6,11 +6,13 @@ import Http import Json.Decode import Json.Encode +-- Battle Map ------------------------------------------------------------------ +import BattleMap.Comm.AddDataSetItem +import BattleMap.Comm.SetMap + -- Local Module ---------------------------------------------------------------- -import Comm.AddTile import Comm.AddTilePattern import Comm.Okay -import Comm.SetMap import Struct.Event import Struct.ServerReply @@ -26,19 +28,25 @@ import Struct.Model internal_decoder : String -> (Json.Decode.Decoder Struct.ServerReply.Type) internal_decoder reply_type = case reply_type of - "add_tile" -> (Comm.AddTile.decode) "add_tile_pattern" -> (Comm.AddTilePattern.decode) - "set_map" -> (Comm.SetMap.decode) + "set_map" -> (BattleMap.Comm.SetMap.decode) "okay" -> (Comm.Okay.decode) "disconnected" -> (Json.Decode.succeed Struct.ServerReply.Disconnected) other -> - (Json.Decode.fail - ( - "Unknown server command \"" - ++ other - ++ "\"" - ) + if + (String.startsWith + (BattleMap.Comm.AddDataSetItem.prefix) + reply_type ) + then (BattleMap.Comm.AddDataSetItem.get_decoder_for reply_type) + else + (Json.Decode.fail + ( + "Unknown server command \"" + ++ other + ++ "\"" + ) + ) decode : (Json.Decode.Decoder Struct.ServerReply.Type) decode = diff --git a/src/map-editor/src/Comm/SendMapUpdate.elm b/src/map-editor/src/Comm/SendMapUpdate.elm index 023f24c..d7c149d 100644 --- a/src/map-editor/src/Comm/SendMapUpdate.elm +++ b/src/map-editor/src/Comm/SendMapUpdate.elm @@ -5,6 +5,9 @@ import Array import Json.Encode +-- Shared ---------------------------------------------------------------------- +import Struct.Flags + -- Battle Map ------------------------------------------------------------------ import BattleMap.Struct.Map import BattleMap.Struct.TileInstance @@ -29,8 +32,16 @@ encode_map model = (Just (Json.Encode.object [ - ("stk", (Json.Encode.string model.session_token)), - ("pid", (Json.Encode.string model.player_id)), + ("stk", + (Json.Encode.string + (Struct.Flags.get_session_token model.flags) + ) + ), + ("pid", + (Json.Encode.string + (Struct.Flags.get_user_id model.flags) + ) + ), ("mid", (Json.Encode.string model.map_id)), ("w", (Json.Encode.int (BattleMap.Struct.Map.get_width model.map))), ( diff --git a/src/map-editor/src/Comm/SetMap.elm b/src/map-editor/src/Comm/SetMap.elm deleted file mode 100644 index 80f6db1..0000000 --- a/src/map-editor/src/Comm/SetMap.elm +++ /dev/null @@ -1,28 +0,0 @@ -module Comm.SetMap exposing (decode) - --- Elm ------------------------------------------------------------------------- -import Json.Decode - --- Battle Map ------------------------------------------------------------------ -import BattleMap.Struct.Map - --- Local Module ---------------------------------------------------------------- -import Struct.ServerReply - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -decode : (Json.Decode.Decoder Struct.ServerReply.Type) -decode = - (Json.Decode.map - (\map -> (Struct.ServerReply.SetMap map)) - (BattleMap.Struct.Map.decoder) - ) diff --git a/src/map-editor/src/Struct/Model.elm b/src/map-editor/src/Struct/Model.elm index f5fb55e..141a9c2 100644 --- a/src/map-editor/src/Struct/Model.elm +++ b/src/map-editor/src/Struct/Model.elm @@ -1,10 +1,8 @@ module Struct.Model exposing ( Type, - tile_omnimods_fun, new, invalidate, - add_tile, add_tile_pattern, reset, clear_error @@ -20,6 +18,7 @@ import Struct.Flags import Battle.Struct.Omnimods -- Battle Map ------------------------------------------------------------------ +import BattleMap.Struct.DataSet import BattleMap.Struct.Location import BattleMap.Struct.Map import BattleMap.Struct.Tile @@ -46,12 +45,11 @@ type alias Type = BattleMap.Struct.Tile.VariantID ), wild_tile_patterns : (List Struct.TilePattern.Type), - tiles : (Dict.Dict BattleMap.Struct.Tile.Ref BattleMap.Struct.Tile.Type), error : (Maybe Struct.Error.Type), - player_id : String, map_id : String, - session_token : String, - ui : Struct.UI.Type + ui : Struct.UI.Type, + + map_dataset : (BattleMap.Struct.DataSet.Type) } -------------------------------------------------------------------------------- @@ -61,13 +59,6 @@ type alias Type = -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -tile_omnimods_fun : ( - Type -> - (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) - ) -tile_omnimods_fun model = - (\loc -> (BattleMap.Struct.Map.get_omnimods_at loc model.tiles model.map)) - new : Struct.Flags.Type -> Type new flags = let @@ -78,19 +69,12 @@ new flags = toolbox = (Struct.Toolbox.default), help_request = Struct.HelpRequest.None, map = (BattleMap.Struct.Map.empty), - tiles = (Dict.empty), tile_patterns = (Dict.empty), wild_tile_patterns = [], error = Nothing, map_id = "", - player_id = - ( - if (flags.user_id == "") - then "0" - else flags.user_id - ), - session_token = flags.token, - ui = (Struct.UI.default) + ui = (Struct.UI.default), + map_dataset = (BattleMap.Struct.DataSet.new) } in case maybe_map_id of @@ -105,17 +89,6 @@ new flags = (Just id) -> {model | map_id = id} -add_tile : BattleMap.Struct.Tile.Type -> Type -> Type -add_tile tl model = - {model | - tiles = - (Dict.insert - (BattleMap.Struct.Tile.get_id tl) - tl - model.tiles - ) - } - add_tile_pattern : Struct.TilePattern.Type -> Type -> Type add_tile_pattern tp model = if (Struct.TilePattern.is_wild tp) diff --git a/src/map-editor/src/Struct/ServerReply.elm b/src/map-editor/src/Struct/ServerReply.elm index 079b472..943706f 100644 --- a/src/map-editor/src/Struct/ServerReply.elm +++ b/src/map-editor/src/Struct/ServerReply.elm @@ -2,7 +2,7 @@ module Struct.ServerReply exposing (Type(..)) -- Battle Map ------------------------------------------------------------------ import BattleMap.Struct.Map -import BattleMap.Struct.Tile +import BattleMap.Struct.DataSetItem -- Local Module ---------------------------------------------------------------- import Struct.TilePattern @@ -14,7 +14,7 @@ import Struct.TilePattern type Type = Okay | Disconnected - | AddTile BattleMap.Struct.Tile.Type + | AddMapDataSetItem BattleMap.Struct.DataSetItem.Type | AddTilePattern Struct.TilePattern.Type | SetMap BattleMap.Struct.Map.Type diff --git a/src/map-editor/src/Update/HandleServerReply.elm b/src/map-editor/src/Update/HandleServerReply.elm index 80ca116..3caf506 100644 --- a/src/map-editor/src/Update/HandleServerReply.elm +++ b/src/map-editor/src/Update/HandleServerReply.elm @@ -14,7 +14,7 @@ import Util.Http -- Battle Map ------------------------------------------------------------------ import BattleMap.Struct.Map -import BattleMap.Struct.Tile +import BattleMap.Struct.DataSetItem -- Local Module ---------------------------------------------------------------- import Constants.IO @@ -57,14 +57,20 @@ disconnected current_state = ] ) -add_tile : ( - BattleMap.Struct.Tile.Type -> +add_map_dataset_item : ( + BattleMap.Struct.DataSetItem.Type -> (Struct.Model.Type, (List (Cmd Struct.Event.Type))) -> (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ) -add_tile tl current_state = +add_map_dataset_item item current_state = let (model, cmds) = current_state in - ((Struct.Model.add_tile tl model), cmds) + ( + {model | + map_dataset = + (BattleMap.Struct.DataSetItem.add_to item model.map_dataset) + }, + cmds + ) add_tile_pattern : ( Struct.TilePattern.Type -> @@ -82,7 +88,12 @@ set_map : ( ) set_map map current_state = let (model, cmds) = current_state in - ({model | map = (BattleMap.Struct.Map.solve_tiles model.tiles map)}, cmds) + ( + {model | + map = (BattleMap.Struct.Map.solve_tiles model.map_dataset model.map) + }, + cmds + ) refresh_map : ( (Struct.Model.Type, (List (Cmd Struct.Event.Type))) -> @@ -92,7 +103,7 @@ refresh_map current_state = let (model, cmds) = current_state in ( {model | - map = (BattleMap.Struct.Map.solve_tiles model.tiles model.map) + map = (BattleMap.Struct.Map.solve_tiles model.map_dataset model.map) }, cmds ) @@ -106,8 +117,8 @@ apply_command command current_state = case command of Struct.ServerReply.Disconnected -> (disconnected current_state) - (Struct.ServerReply.AddTile tl) -> - (add_tile tl current_state) + (Struct.ServerReply.AddMapDataSetItem it) -> + (add_map_dataset_item it current_state) (Struct.ServerReply.AddTilePattern tp) -> (add_tile_pattern tp current_state) diff --git a/src/map-editor/src/Update/SetToolboxTemplate.elm b/src/map-editor/src/Update/SetToolboxTemplate.elm index 621a8fe..0ad34e6 100644 --- a/src/map-editor/src/Update/SetToolboxTemplate.elm +++ b/src/map-editor/src/Update/SetToolboxTemplate.elm @@ -4,6 +4,7 @@ module Update.SetToolboxTemplate exposing (apply_to) import Dict -- Battle Map ------------------------------------------------------------------ +import BattleMap.Struct.DataSet import BattleMap.Struct.TileInstance -- Local Module ---------------------------------------------------------------- @@ -29,10 +30,11 @@ apply_to model main_class_id variant_id = {model | toolbox = (Struct.Toolbox.set_template - ( - case (Dict.get main_class_id model.tiles) of - (Just tile) -> (BattleMap.Struct.TileInstance.default tile) - _ -> (BattleMap.Struct.TileInstance.error 0 0) + (BattleMap.Struct.TileInstance.default + (BattleMap.Struct.DataSet.get_tile + main_class_id + model.map_dataset + ) ) model.toolbox ) diff --git a/src/map-editor/src/View/SubMenu/TileStatus.elm b/src/map-editor/src/View/SubMenu/TileStatus.elm index 0ef4590..eb61a2f 100644 --- a/src/map-editor/src/View/SubMenu/TileStatus.elm +++ b/src/map-editor/src/View/SubMenu/TileStatus.elm @@ -10,9 +10,10 @@ import Html.Attributes import Util.Html -- Battle ---------------------------------------------------------------------- -import Battle.Struct.Omnimods +import Battle.View.Omnimods -- Battle Map ------------------------------------------------------------------ +import BattleMap.Struct.DataSet import BattleMap.Struct.Location import BattleMap.Struct.Map import BattleMap.Struct.Tile @@ -50,29 +51,28 @@ get_icon tile = ) get_name : ( - Struct.Model.Type -> + BattleMap.Struct.DataSet.Type -> BattleMap.Struct.TileInstance.Type -> (Html.Html Struct.Event.Type) ) -get_name model tile_inst = - case - (Dict.get - (BattleMap.Struct.TileInstance.get_class_id tile_inst) - model.tiles - ) - of - Nothing -> (Util.Html.nothing) - (Just tile) -> - (Html.div - [ - (Html.Attributes.class "info-card-name"), - (Html.Attributes.class "info-card-text-field"), - (Html.Attributes.class "tile-card-name") - ] - [ - (Html.text (BattleMap.Struct.Tile.get_name tile)) - ] +get_name dataset tile_inst = + (Html.div + [ + (Html.Attributes.class "info-card-name"), + (Html.Attributes.class "info-card-text-field"), + (Html.Attributes.class "tile-card-name") + ] + [ + (Html.text + (BattleMap.Struct.Tile.get_name + (BattleMap.Struct.DataSet.get_tile + (BattleMap.Struct.TileInstance.get_class_id tile_inst) + dataset + ) + ) ) + ] + ) get_cost : BattleMap.Struct.TileInstance.Type -> (Html.Html Struct.Event.Type) get_cost tile_inst = @@ -121,53 +121,6 @@ get_location tile_inst = ] ) -get_mod_html : (String, Int) -> (Html.Html Struct.Event.Type) -get_mod_html mod = - let - (category, value) = mod - in - (Html.div - [ - (Html.Attributes.class "info-card-mod") - ] - [ - (Html.text - (category ++ ": " ++ (String.fromInt value)) - ) - ] - ) - -get_omnimods_listing : (List (String, Int)) -> (Html.Html Struct.Event.Type) -get_omnimods_listing mod_list = - (Html.div - [ - (Html.Attributes.class "info-card-omnimods-listing") - ] - (List.map (get_mod_html) mod_list) - ) - -get_omnimods : Battle.Struct.Omnimods.Type -> (Html.Html Struct.Event.Type) -get_omnimods omnimods = - (Html.div - [ - (Html.Attributes.class "info-card-omnimods") - ] - [ - (Html.text "Attributes Modifiers"), - (get_omnimods_listing - (Battle.Struct.Omnimods.get_attribute_mods omnimods) - ), - (Html.text "Attack Modifiers"), - (get_omnimods_listing - (Battle.Struct.Omnimods.get_attack_mods omnimods) - ), - (Html.text "Defense Modifiers"), - (get_omnimods_listing - (Battle.Struct.Omnimods.get_defense_mods omnimods) - ) - ] - ) - get_tile_info_html : ( Struct.Model.Type -> BattleMap.Struct.Location.Type -> @@ -182,7 +135,7 @@ get_tile_info_html model loc = (Html.Attributes.class "tile-card") ] [ - (get_name model tile), + (get_name model.map_dataset tile), (Html.div [ (Html.Attributes.class "info-card-top"), @@ -194,7 +147,13 @@ get_tile_info_html model loc = (get_cost tile) ] ), - (get_omnimods ((Struct.Model.tile_omnimods_fun model) loc)) + (Battle.View.Omnimods.get_signed_html + (BattleMap.Struct.Map.get_omnimods_at + loc + model.map_dataset + model.map + ) + ) ] ) diff --git a/src/map-editor/src/View/SubMenu/Tiles.elm b/src/map-editor/src/View/SubMenu/Tiles.elm index 16b147e..a9136ff 100644 --- a/src/map-editor/src/View/SubMenu/Tiles.elm +++ b/src/map-editor/src/View/SubMenu/Tiles.elm @@ -4,11 +4,13 @@ module View.SubMenu.Tiles exposing (get_html) import Dict import Html +import Html.Lazy import Html.Attributes import Html.Events -- Battle Map ------------------------------------------------------------------ import BattleMap.Struct.Tile +import BattleMap.Struct.DataSet import BattleMap.Struct.TileInstance import BattleMap.View.Tile @@ -42,11 +44,8 @@ get_icon_html (ref, tile) = ) ) --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) -get_html model = +true_get_html : BattleMap.Struct.DataSet.Type -> (Html.Html Struct.Event.Type) +true_get_html dataset = (Html.div [ (Html.Attributes.class "tabmenu-content"), @@ -54,6 +53,15 @@ get_html model = ] (List.map (get_icon_html) - (Dict.toList model.tiles) + (Dict.toList (BattleMap.Struct.DataSet.get_tiles dataset)) ) ) +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) +get_html model = + (Html.Lazy.lazy + (true_get_html) + model.map_dataset + ) |