| summaryrefslogtreecommitdiff |
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-09-27 16:25:14 +0200 |
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-09-27 16:25:14 +0200 |
| commit | 55f01ce3978f12eafe7e726ee52133169c84b2bc (patch) | |
| tree | 0f3b440690ae0254dc23c07eadb0d8a98cbd03ca | |
| parent | 287049d6d1f06269fa48e2dba460e8dde9867bda (diff) | |
...
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | src/background/Makefile | 9 | ||||
| -rw-r--r-- | src/background/elm-package.json | 3 | ||||
| -rw-r--r-- | src/background/src/ElmModule/View.elm | 1 | ||||
| -rw-r--r-- | src/popup/Makefile | 9 | ||||
| -rw-r--r-- | src/popup/elm-package.json | 3 | ||||
| -rw-r--r-- | src/popup/src/Action/Ports.elm | 4 | ||||
| -rw-r--r-- | src/popup/src/Comm/GetBattles.elm | 45 | ||||
| -rw-r--r-- | src/popup/src/Comm/Send.elm | 2 | ||||
| -rw-r--r-- | src/popup/src/Comm/SetBattles.elm | 51 | ||||
| -rw-r--r-- | src/popup/src/Struct/ServerReply.elm | 6 | ||||
| -rw-r--r-- | src/popup/src/Update/HandleServerReply.elm | 57 | ||||
| -rw-r--r-- | src/popup/src/Update/RefreshBattles.elm | 8 | ||||
| -rw-r--r-- | src/shared/Action/Ports.elm (renamed from src/background/src/Action/Ports.elm) | 1 | ||||
| -rw-r--r-- | www/script/init_background.js | 3 | ||||
| -rw-r--r-- | www/script/init_popup.js | 3 |
16 files changed, 22 insertions, 189 deletions
@@ -22,18 +22,18 @@ all: build build: for module in $(MODULES_SRC) ; do \ - $(MAKE) -C $$module build ; \ + $(MAKE) -C $$module build WWW_DIR="$(WWW_DIR)"; \ done clean: for module in $(MODULES_SRC) ; do \ - $(MAKE) -C $$module clean ; \ + $(MAKE) -C $$module clean WWW_DIR="$(WWW_DIR)"; \ done reset: $(MAKE) clean for module in $(MODULES_SRC) ; do \ - $(MAKE) -C $$module reset; \ + $(MAKE) -C $$module reset WWW_DIR="$(WWW_DIR)"; \ done ################################################################################ diff --git a/src/background/Makefile b/src/background/Makefile index 3b58a08..0bd7c27 100644 --- a/src/background/Makefile +++ b/src/background/Makefile @@ -2,8 +2,7 @@ ## CONFIG ###################################################################### ################################################################################ SRC_DIR ?= src -WWW_DIR ?= www -WWW_SCRIPT_DIR ?= $(WWW_DIR)/script +TARGET_FILE ?= $(WWW_DIR)/script/main_background.js ELM_CC ?= elm-make --warn @@ -21,10 +20,10 @@ SUB_MODULES = $(shell find $(SRC_DIR) -type f | grep "elm$$") ################################################################################ ## TARGET RULES ################################################################ ################################################################################ -build: $(WWW_SCRIPT_DIR)/main.js +build: $(TARGET_FILE) clean: - rm -f $(WWW_SCRIPT_DIR)/main.js + rm -f $(TARGET_FILE) reset: rm -rf elm-stuff @@ -32,5 +31,5 @@ reset: ################################################################################ ## INTERNAL RULES ############################################################## ################################################################################ -$(WWW_SCRIPT_DIR)/main.js: $(MAIN_MODULE) $(SUB_MODULES) +$(TARGET_FILE): $(MAIN_MODULE) $(SUB_MODULES) $(ELM_CC) $(MAIN_MODULE) --output $@ diff --git a/src/background/elm-package.json b/src/background/elm-package.json index a8b8580..14dedf1 100644 --- a/src/background/elm-package.json +++ b/src/background/elm-package.json @@ -4,7 +4,8 @@ "repository": "https://github.com/nsensfel/tacticians-extension.git", "license": "Apache 2.0", "source-directories": [ - "src" + "src", + "../shared" ], "exposed-modules": [], "dependencies": { diff --git a/src/background/src/ElmModule/View.elm b/src/background/src/ElmModule/View.elm index 32a139f..64f7188 100644 --- a/src/background/src/ElmModule/View.elm +++ b/src/background/src/ElmModule/View.elm @@ -1,6 +1,7 @@ module ElmModule.View exposing (view) -- Elm ------------------------------------------------------------------------- +import Html -- Extension ------------------------------------------------------------------- import Util.Html diff --git a/src/popup/Makefile b/src/popup/Makefile index 3b58a08..7fdd89b 100644 --- a/src/popup/Makefile +++ b/src/popup/Makefile @@ -2,8 +2,7 @@ ## CONFIG ###################################################################### ################################################################################ SRC_DIR ?= src -WWW_DIR ?= www -WWW_SCRIPT_DIR ?= $(WWW_DIR)/script +TARGET_FILE ?= $(WWW_DIR)/script/main_popup.js ELM_CC ?= elm-make --warn @@ -21,10 +20,10 @@ SUB_MODULES = $(shell find $(SRC_DIR) -type f | grep "elm$$") ################################################################################ ## TARGET RULES ################################################################ ################################################################################ -build: $(WWW_SCRIPT_DIR)/main.js +build: $(TARGET_FILE) clean: - rm -f $(WWW_SCRIPT_DIR)/main.js + rm -f $(TARGET_FILE) reset: rm -rf elm-stuff @@ -32,5 +31,5 @@ reset: ################################################################################ ## INTERNAL RULES ############################################################## ################################################################################ -$(WWW_SCRIPT_DIR)/main.js: $(MAIN_MODULE) $(SUB_MODULES) +$(TARGET_FILE): $(MAIN_MODULE) $(SUB_MODULES) $(ELM_CC) $(MAIN_MODULE) --output $@ diff --git a/src/popup/elm-package.json b/src/popup/elm-package.json index a8b8580..14dedf1 100644 --- a/src/popup/elm-package.json +++ b/src/popup/elm-package.json @@ -4,7 +4,8 @@ "repository": "https://github.com/nsensfel/tacticians-extension.git", "license": "Apache 2.0", "source-directories": [ - "src" + "src", + "../shared" ], "exposed-modules": [], "dependencies": { diff --git a/src/popup/src/Action/Ports.elm b/src/popup/src/Action/Ports.elm deleted file mode 100644 index 4d83077..0000000 --- a/src/popup/src/Action/Ports.elm +++ /dev/null @@ -1,4 +0,0 @@ -port module Action.Ports exposing (..) - -port store_params : (Int, String) -> (Cmd msg) -port reset_params : () -> (Cmd msg) diff --git a/src/popup/src/Comm/GetBattles.elm b/src/popup/src/Comm/GetBattles.elm deleted file mode 100644 index 0956972..0000000 --- a/src/popup/src/Comm/GetBattles.elm +++ /dev/null @@ -1,45 +0,0 @@ -module Comm.GetBattles exposing (try) - --- Elm ------------------------------------------------------------------------- -import Json.Encode - --- Extension ------------------------------------------------------------------- -import Comm.Send - -import Struct.Event -import Struct.Model -import Struct.Player - --------------------------------------------------------------------------------- --- TYPES ------------------------------------------------------------------------ --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -try_encoding : String -> Struct.Model.Type -> (Maybe Json.Encode.Value) -try_encoding player_id model = - let - encoded_player_id = (Json.Encode.string player_id) - in - (Just - (Json.Encode.object - [ - ("id", encoded_player_id) - ] - ) - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -try : Struct.Model.Type -> Struct.Player.Type -> (Maybe (Cmd Struct.Event.Type)) -try model player = - (Comm.Send.try_sending - model - ( - (Struct.Player.get_query_url player) - ++ "/handler/player/plr_get_battles" - ) - (try_encoding (Struct.Player.get_id player)) - ) diff --git a/src/popup/src/Comm/Send.elm b/src/popup/src/Comm/Send.elm index 3fc30ae..cda4cf2 100644 --- a/src/popup/src/Comm/Send.elm +++ b/src/popup/src/Comm/Send.elm @@ -8,7 +8,6 @@ import Json.Encode -- Extension ------------------------------------------------------------------- import Comm.Okay -import Comm.SetBattles import Struct.Event import Struct.ServerReply @@ -25,7 +24,6 @@ internal_decoder : String -> (Json.Decode.Decoder Struct.ServerReply.Type) internal_decoder reply_type = case reply_type of "okay" -> (Comm.Okay.decoder) - "set_battles" -> (Comm.SetBattles.decoder) other -> (Json.Decode.fail ( diff --git a/src/popup/src/Comm/SetBattles.elm b/src/popup/src/Comm/SetBattles.elm deleted file mode 100644 index 0add112..0000000 --- a/src/popup/src/Comm/SetBattles.elm +++ /dev/null @@ -1,51 +0,0 @@ -module Comm.SetBattles exposing (decoder) - --- Elm ------------------------------------------------------------------------- -import Json.Decode - --- Extension ------------------------------------------------------------------- -import Struct.BattleSummary -import Struct.Player -import Struct.ServerReply - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -type alias Battles = - { - campaigns : (List Struct.BattleSummary.Type), - invasions : (List Struct.BattleSummary.Type), - events : (List Struct.BattleSummary.Type) - } - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -internal_decoder : (Json.Decode.Decoder Battles) -internal_decoder = - (Json.Decode.map3 - Battles - (Json.Decode.field - "cmps" - (Json.Decode.list (Struct.BattleSummary.decoder)) - ) - (Json.Decode.field - "invs" - (Json.Decode.list (Struct.BattleSummary.decoder)) - ) - (Json.Decode.field - "evts" - (Json.Decode.list (Struct.BattleSummary.decoder)) - ) - ) - -to_server_reply : Battles -> Struct.ServerReply.Type -to_server_reply t = - (Struct.ServerReply.SetBattles (t.campaigns, t.invasions, t.events)) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -decoder : (Json.Decode.Decoder Struct.ServerReply.Type) -decoder = - (Json.Decode.map (to_server_reply) (internal_decoder)) diff --git a/src/popup/src/Struct/ServerReply.elm b/src/popup/src/Struct/ServerReply.elm index f0530d8..e995f63 100644 --- a/src/popup/src/Struct/ServerReply.elm +++ b/src/popup/src/Struct/ServerReply.elm @@ -13,12 +13,6 @@ type Type = Okay | SetID String | SetUsername String - | SetBattles - ( - (List Struct.BattleSummary.Type), - (List Struct.BattleSummary.Type), - (List Struct.BattleSummary.Type) - ) -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- diff --git a/src/popup/src/Update/HandleServerReply.elm b/src/popup/src/Update/HandleServerReply.elm index b80c7b4..eec6b02 100644 --- a/src/popup/src/Update/HandleServerReply.elm +++ b/src/popup/src/Update/HandleServerReply.elm @@ -1,18 +1,12 @@ module Update.HandleServerReply exposing (apply_to) -- Elm ------------------------------------------------------------------------- -import Array - import Http -- Extension ------------------------------------------------------------------- -import Comm.GetBattles - -import Struct.BattleSummary import Struct.Error import Struct.Event import Struct.Model -import Struct.Player import Struct.ServerReply -------------------------------------------------------------------------------- @@ -22,55 +16,6 @@ import Struct.ServerReply -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -handle_set_battles : ( - ( - (List Struct.BattleSummary.Type), - (List Struct.BattleSummary.Type), - (List Struct.BattleSummary.Type) - ) -> - (Struct.Model.Type, (List (Cmd Struct.Event.Type))) -> - (Struct.Model.Type, (List (Cmd Struct.Event.Type))) - ) -handle_set_battles battles current_state = - let - (model, cmds) = current_state - (campaigns, invasions, events) = battles - in - case (Array.get model.query_index model.players) of - Nothing -> current_state -- TODO: error - (Just player) -> - let - updated_player = - (Struct.Player.set_battles - campaigns - invasions - events - player - ) - updated_model = - {model | - players = - (Array.set - model.query_index - updated_player - model.players - ), - query_index = (model.query_index + 1), - notify = - ( - model.notify - || (Struct.Player.has_active_battles updated_player) - ) - } - in - case (Array.get updated_model.query_index model.players) of - Nothing -> ({updated_model| query_index = -1}, cmds) - - (Just next_player) -> - case (Comm.GetBattles.try updated_model next_player) of - Nothing -> ({updated_model| query_index = -1}, cmds) - (Just query) -> (updated_model, (query :: cmds)) - apply_command : ( Struct.ServerReply.Type -> (Struct.Model.Type, (List (Cmd Struct.Event.Type))) -> @@ -81,8 +26,6 @@ apply_command command current_state = Struct.ServerReply.Okay -> current_state (Struct.ServerReply.SetID str) -> current_state -- TODO (Struct.ServerReply.SetUsername str) -> current_state -- TODO - (Struct.ServerReply.SetBattles battles) -> - (handle_set_battles battles current_state) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- diff --git a/src/popup/src/Update/RefreshBattles.elm b/src/popup/src/Update/RefreshBattles.elm index 2ff739f..e82fb08 100644 --- a/src/popup/src/Update/RefreshBattles.elm +++ b/src/popup/src/Update/RefreshBattles.elm @@ -4,8 +4,6 @@ module Update.RefreshBattles exposing (apply_to) import Array -- Extension ------------------------------------------------------------------- -import Comm.GetBattles - import Struct.Event import Struct.Flags import Struct.Model @@ -21,8 +19,4 @@ apply_to : Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type)) apply_to model = case (Array.get 0 model.players) of Nothing -> (model, Cmd.none) - (Just player) -> - case (Comm.GetBattles.try model player) of - -- TODO: Invalidate only this player, refresh the others. - Nothing -> (model, Cmd.none) - (Just cmd) -> ({model | query_index = 0}, cmd) + (Just player) -> (model, Cmd.none) diff --git a/src/background/src/Action/Ports.elm b/src/shared/Action/Ports.elm index 9222b08..460defc 100644 --- a/src/background/src/Action/Ports.elm +++ b/src/shared/Action/Ports.elm @@ -1,4 +1,5 @@ port module Action.Ports exposing (..) port read_params : () -> (Cmd msg) +port store_params : (Int, String) -> (Cmd msg) port store_results : (String) -> (Cmd msg) diff --git a/www/script/init_background.js b/www/script/init_background.js index 09fa501..362ec43 100644 --- a/www/script/init_background.js +++ b/www/script/init_background.js @@ -1,5 +1,6 @@ tacticians_online.params.load(); -tacticians_online.app = Elm.Main.fullscreen(); +tacticians_online.app = Elm.Main.fullscreen(tacticians_online.params.get_params()); tacticians_online.params.attach_to(tacticians_online.app); +tacticians_online.battles.attach_to(tacticians_online.app); diff --git a/www/script/init_popup.js b/www/script/init_popup.js index 09fa501..362ec43 100644 --- a/www/script/init_popup.js +++ b/www/script/init_popup.js @@ -1,5 +1,6 @@ tacticians_online.params.load(); -tacticians_online.app = Elm.Main.fullscreen(); +tacticians_online.app = Elm.Main.fullscreen(tacticians_online.params.get_params()); tacticians_online.params.attach_to(tacticians_online.app); +tacticians_online.battles.attach_to(tacticians_online.app); |


