summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/css/src/login.scss | 42 | ||||
-rw-r--r-- | src/css/src/main-menu.scss | 25 | ||||
-rw-r--r-- | src/css/src/shared/general-header.scss | 44 | ||||
-rw-r--r-- | src/main-menu/src/ElmModule/Update.elm | 49 | ||||
-rw-r--r-- | src/main-menu/src/ElmModule/View.elm | 42 | ||||
-rw-r--r-- | src/main-menu/src/Struct/BattleSummary.elm | 65 | ||||
-rw-r--r-- | src/main-menu/src/Struct/MapSummary.elm | 51 | ||||
-rw-r--r-- | src/main-menu/src/Struct/Model.elm | 2 | ||||
-rw-r--r-- | src/main-menu/src/Struct/Player.elm | 107 | ||||
-rw-r--r-- | src/main-menu/src/Update/HandleServerReply.elm | 44 | ||||
-rw-r--r-- | src/main-menu/src/Update/SendRecovery.elm | 29 | ||||
-rw-r--r-- | src/main-menu/src/Update/SendSignIn.elm | 29 | ||||
-rw-r--r-- | src/main-menu/src/Update/SendSignUp.elm | 29 | ||||
-rw-r--r-- | src/main-menu/src/View/BattleListing.elm | 52 | ||||
-rw-r--r-- | src/main-menu/src/View/Header.elm.m4 | 2 |
15 files changed, 301 insertions, 311 deletions
diff --git a/src/css/src/login.scss b/src/css/src/login.scss index afc9e60..e25f40a 100644 --- a/src/css/src/login.scss +++ b/src/css/src/login.scss @@ -22,47 +22,7 @@ body, padding-bottom: 1em; } -.fullscreen-module > header -{ - display: flex; - flex-direction: row; -} - -.fullscreen-module > header nav -{ - display: flex; - flex-direction: row; - flex-wrap: wrap; - flex: 1; - align-items: center; - justify-content: space-around; -} - -.fullscreen-module > header nav a -{ - color: $GOLD-0; - transition: background-color 0.3s ease-out; - font-size: 1.5em; - font-variant: small-caps; - font-weight: bold; - text-decoration: none; - margin: 0.5em; -} - -.main-server-logo -{ - z-index: 1; - margin: 0.5em; -} - -.main-server-version -{ - z-index: 0; - position: absolute; - font-size: 0.7em; - top: 0; - right: 0; -} +@import 'shared/general-header'; main { diff --git a/src/css/src/main-menu.scss b/src/css/src/main-menu.scss new file mode 100644 index 0000000..e3b209f --- /dev/null +++ b/src/css/src/main-menu.scss @@ -0,0 +1,25 @@ +@import 'shared/colors'; +@import 'shared/shadows'; + +* +{ + color: $GOLD-0; + @include text-shadow(1px, $BROWN-0, 0.5); +} + +body, +.fullscreen-module +{ + display: flex; + flex-direction: column; + background-color: $BROWN-2; + + align-items: center; +} + +.fullscreen-module +{ + padding-bottom: 1em; +} + +@import 'shared/general-header'; diff --git a/src/css/src/shared/general-header.scss b/src/css/src/shared/general-header.scss new file mode 100644 index 0000000..701a6bc --- /dev/null +++ b/src/css/src/shared/general-header.scss @@ -0,0 +1,44 @@ +@import 'colors'; +@import 'shadows'; + +.fullscreen-module > header +{ + display: flex; + flex-direction: row; +} + +.fullscreen-module > header nav +{ + display: flex; + flex-direction: row; + flex-wrap: wrap; + flex: 1; + align-items: center; + justify-content: space-around; +} + +.fullscreen-module > header nav a +{ + color: $GOLD-0; + transition: background-color 0.3s ease-out; + font-size: 1.5em; + font-variant: small-caps; + font-weight: bold; + text-decoration: none; + margin: 0.5em; +} + +.main-server-logo +{ + z-index: 1; + margin: 0.5em; +} + +.main-server-version +{ + z-index: 0; + position: absolute; + font-size: 0.7em; + top: 0; + right: 0; +} diff --git a/src/main-menu/src/ElmModule/Update.elm b/src/main-menu/src/ElmModule/Update.elm index babb5b5..425d95f 100644 --- a/src/main-menu/src/ElmModule/Update.elm +++ b/src/main-menu/src/ElmModule/Update.elm @@ -2,14 +2,11 @@ module ElmModule.Update exposing (update) -- Elm ------------------------------------------------------------------------- --- Map ------------------------------------------------------------------- +-- Main Menu ------------------------------------------------------------------- import Struct.Event import Struct.Model import Update.HandleServerReply -import Update.SendSignIn -import Update.SendSignUp -import Update.SendRecovery import Update.SelectTab -------------------------------------------------------------------------------- @@ -41,49 +38,5 @@ update event model = (Struct.Event.ServerReplied result) -> (Update.HandleServerReply.apply_to model result) - Struct.Event.SignInRequested -> - (Update.SendSignIn.apply_to new_model) - - Struct.Event.SignUpRequested -> - (Update.SendSignUp.apply_to model) - - Struct.Event.RecoveryRequested -> - (Update.SendRecovery.apply_to model) - (Struct.Event.TabSelected tab) -> (Update.SelectTab.apply_to new_model tab) - - (Struct.Event.RequestedHelp _) -> - -- TODO - (model, Cmd.none) - - (Struct.Event.SetUsername str) -> - ( - {model | username = str}, - Cmd.none - ) - - (Struct.Event.SetPassword1 str) -> - ( - {model | password1 = str}, - Cmd.none - ) - - (Struct.Event.SetPassword2 str) -> - ( - {model | password2 = str}, - Cmd.none - ) - - (Struct.Event.SetEmail1 str) -> - ( - {model | email1 = str}, - Cmd.none - ) - - (Struct.Event.SetEmail2 str) -> - ( - {model | email2 = str}, - Cmd.none - ) - diff --git a/src/main-menu/src/ElmModule/View.elm b/src/main-menu/src/ElmModule/View.elm index 657e063..b37116c 100644 --- a/src/main-menu/src/ElmModule/View.elm +++ b/src/main-menu/src/ElmModule/View.elm @@ -5,19 +5,17 @@ import Html import Html.Lazy import Html.Attributes --- Map ------------------------------------------------------------------- +-- Main Menu ------------------------------------------------------------------- import Struct.Error import Struct.Event import Struct.Model +import Struct.Player import Struct.UI import Util.Html -import View.AccountRecovery +import View.BattleListing import View.Header -import View.MainMenu -import View.SignIn -import View.SignUp -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- @@ -38,30 +36,20 @@ view model = [ ] [ - (View.MainMenu.get_html - (Struct.UI.try_getting_displayed_tab model.ui) + (View.BattleListing.get_html + "Campaigns" + "main-menu-campaigns" + (Struct.Player.get_campaigns model.player) ), - ( - case (Struct.UI.try_getting_displayed_tab model.ui) of - (Just Struct.UI.SignInTab) -> (View.SignIn.get_html model) - (Just Struct.UI.SignUpTab) -> (View.SignUp.get_html model) - (Just Struct.UI.RecoveryTab) -> - (View.AccountRecovery.get_html model) - - _ -> (View.SignIn.get_html model) + (View.BattleListing.get_html + "Invasions" + "main-menu-invasions" + (Struct.Player.get_invasions model.player) ), - ( - case model.error of - Nothing -> (Util.Html.nothing) - (Just err) -> - (Html.div - [ - (Html.Attributes.class "error-msg") - ] - [ - (Html.text (Struct.Error.to_string err)) - ] - ) + (View.BattleListing.get_html + "Events" + "main-menu-events" + (Struct.Player.get_events model.player) ) ] ) diff --git a/src/main-menu/src/Struct/BattleSummary.elm b/src/main-menu/src/Struct/BattleSummary.elm new file mode 100644 index 0000000..adab965 --- /dev/null +++ b/src/main-menu/src/Struct/BattleSummary.elm @@ -0,0 +1,65 @@ +module Struct.BattleSummary exposing + ( + Type, + get_id, + get_name, + get_last_edit, + is_players_turn, + decoder, + none + ) + +-- Elm ------------------------------------------------------------------------- +import Json.Decode +import Json.Decode.Pipeline + +-- Main Menu ------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type alias Type = + { + id : String, + name : String, + last_edit : String, + is_players_turn : Bool + } + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_id : Type -> String +get_id t = t.id + +get_name : Type -> String +get_name t = t.name + +get_last_edit : Type -> String +get_last_edit t = t.last_edit + +is_players_turn : Type -> Bool +is_players_turn t = t.is_players_turn + +decoder : (Json.Decode.Decoder Type) +decoder = + (Json.Decode.Pipeline.decode + Type + |> (Json.Decode.Pipeline.required "id" Json.Decode.string) + |> (Json.Decode.Pipeline.required "nme" Json.Decode.string) + |> (Json.Decode.Pipeline.required "ldt" Json.Decode.string) + |> (Json.Decode.Pipeline.required "ipt" Json.Decode.bool) + ) + +none : Type +none = + { + id = "", + name = "Unknown", + last_edit = "Never", + is_players_turn = False + } diff --git a/src/main-menu/src/Struct/MapSummary.elm b/src/main-menu/src/Struct/MapSummary.elm new file mode 100644 index 0000000..7ad0e53 --- /dev/null +++ b/src/main-menu/src/Struct/MapSummary.elm @@ -0,0 +1,51 @@ +module Struct.MapSummary exposing + ( + Type, + get_id, + get_name, + decoder, + none + ) + +-- Elm ------------------------------------------------------------------------- +import Json.Decode +import Json.Decode.Pipeline + +-- Main Menu ------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type alias Type = + { + id : String, + name : String + } + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_id : Type -> String +get_id t = t.id + +get_name : Type -> String +get_name t = t.name + +decoder : (Json.Decode.Decoder Type) +decoder = + (Json.Decode.Pipeline.decode + Type + |> (Json.Decode.Pipeline.required "id" Json.Decode.string) + |> (Json.Decode.Pipeline.required "nme" Json.Decode.string) + ) + +none : Type +none = + { + id = "", + name = "Unknown" + } diff --git a/src/main-menu/src/Struct/Model.elm b/src/main-menu/src/Struct/Model.elm index 85c8344..69a7529 100644 --- a/src/main-menu/src/Struct/Model.elm +++ b/src/main-menu/src/Struct/Model.elm @@ -22,7 +22,6 @@ import Util.Array -------------------------------------------------------------------------------- type alias Type = { - help_request: Struct.HelpRequest.Type, error: (Maybe Struct.Error.Type), player_id: String, session_token: String, @@ -40,7 +39,6 @@ type alias Type = new : Struct.Flags.Type -> Type new flags = { - help_request = Struct.HelpRequest.None, error = Nothing, player_id = flags.user_id, session_token = flags.token, diff --git a/src/main-menu/src/Struct/Player.elm b/src/main-menu/src/Struct/Player.elm index 8a70023..2a56395 100644 --- a/src/main-menu/src/Struct/Player.elm +++ b/src/main-menu/src/Struct/Player.elm @@ -16,33 +16,24 @@ module Struct.Player exposing import Json.Decode import Json.Decode.Pipeline --- Map ------------------------------------------------------------------- -import Struct.Omnimods +-- Main Menu ------------------------------------------------------------------- +import Struct.BattleSummary +import Struct.MapSummary -------------------------------------------------------------------------------- -- TYPES ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -type alias PartiallyDecoded = - { - id : Int, - nam : String, - rmi : Int, - rma : Int, - omni : String - } - type alias Type = { - id : Int, name : String, - def_range : Int, - atk_range : Int, - omnimods : Struct.Omnimods.Type, - damage_sum : Int + maps : (List Struct.MapSummary.Type), + campaigns : (List Struct.BattleSummary.Type), + invasions : (List Struct.BattleSummary.Type), + events : (List Struct.BattleSummary.Type), + roster_id : String, + inventory_id : String } -type alias Ref = Int - -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -50,50 +41,60 @@ type alias Ref = Int -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -new : Int -> String -> Int -> Int -> Struct.Omnimods.Type -> Type -new id name range_min range_max omnimods = - { - id = id, - name = name, - def_range = range_min, - atk_range = range_max, - omnimods = omnimods, - damage_sum = (Struct.Omnimods.get_damage_sum omnimods) - } +get_username : Type -> String +get_username t = t.name -get_id : Type -> Int -get_id wp = wp.id +get_maps : Type -> (List Struct.MapSummary.Type) +get_maps t = t.maps -get_name : Type -> String -get_name wp = wp.name +get_campaigns : Type -> (List Struct.BattleSummary.Type) +get_campaigns t = t.campaigns -get_attack_range : Type -> Int -get_attack_range wp = wp.atk_range +get_invasions : Type -> (List Struct.BattleSummary.Type) +get_invasions t = t.invasions -get_defense_range : Type -> Int -get_defense_range wp = wp.def_range +get_events : Type -> (List Struct.BattleSummary.Type) +get_events t = t.events -get_omnimods : Type -> Struct.Omnimods.Type -get_omnimods wp = wp.omnimods +get_roster_id : Type -> String +get_roster_id t = t.roster_id -get_damage_sum : Type -> Int -get_damage_sum wp = wp.damage_sum +get_inventory_id : Type -> String +get_inventory_id t = t.inventory_id decoder : (Json.Decode.Decoder Type) decoder = - (Json.Decode.map - (\e -> {e | damage_sum = (Struct.Omnimods.get_damage_sum e.omnimods)}) - (Json.Decode.Pipeline.decode - Type - |> (Json.Decode.Pipeline.required "usr" Json.Decode.string) - |> (Json.Decode.Pipeline.required "maps" Json.Decode.list) - |> (Json.Decode.Pipeline.required "cmps" Json.Decode.list) - |> (Json.Decode.Pipeline.required "invs" Json.Decode.list) - |> (Json.Decode.Pipeline.required "evts" Json.Decode.list) - |> (Json.Decode.Pipeline.required "rtid" Json.Decode.list) - |> (Json.Decode.Pipeline.required "ivid" Json.Decode.list) - ) + (Json.Decode.Pipeline.decode + Type + |> (Json.Decode.Pipeline.required "nme" Json.Decode.string) + |> (Json.Decode.Pipeline.required + "maps" + (Json.Decode.list Struct.MapSummary.decoder) + ) + |> (Json.Decode.Pipeline.required + "cmps" + (Json.Decode.list Struct.BattleSummary.decoder) + ) + |> (Json.Decode.Pipeline.required + "invs" + (Json.Decode.list Struct.BattleSummary.decoder) + ) + |> (Json.Decode.Pipeline.required + "evts" + (Json.Decode.list Struct.BattleSummary.decoder) + ) + |> (Json.Decode.Pipeline.required "rtid" Json.Decode.string) + |> (Json.Decode.Pipeline.required "ivid" Json.Decode.string) ) none : Type -none = (new 0 "None" 0 0 (Struct.Omnimods.new [] [] [] [])) +none = + { + name = "Unknown", + maps = [], + campaigns = [], + invasions = [], + events = [], + roster_id = "", + inventory_id = "" + } diff --git a/src/main-menu/src/Update/HandleServerReply.elm b/src/main-menu/src/Update/HandleServerReply.elm index 8720457..18cfdd8 100644 --- a/src/main-menu/src/Update/HandleServerReply.elm +++ b/src/main-menu/src/Update/HandleServerReply.elm @@ -1,20 +1,13 @@ module Update.HandleServerReply exposing (apply_to) -- Elm ------------------------------------------------------------------------- -import Array - -import Dict - import Http --- Map ------------------------------------------------------------------- -import Action.Session - +-- Main Menu ------------------------------------------------------------------- import Struct.Error import Struct.Event import Struct.Model import Struct.ServerReply -import Struct.UI -------------------------------------------------------------------------------- -- TYPES ----------------------------------------------------------------------- @@ -23,37 +16,6 @@ import Struct.UI -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -set_session : ( - String -> - String -> - ( - Struct.Model.Type, - (Maybe Struct.Error.Type), - (List (Cmd Struct.Event.Type)) - ) -> - ( - Struct.Model.Type, - (Maybe Struct.Error.Type), - (List (Cmd Struct.Event.Type)) - ) - ) -set_session pid stk current_state = - case current_state of - (_, (Just _), _) -> current_state - - (model, _, cmd_list) -> - ( - {model | - player_id = pid, - session_token = stk - }, - Nothing, - ( - (Action.Session.store_new_session (pid, stk)) - :: cmd_list - ) - ) - apply_command : ( Struct.ServerReply.Type -> ( @@ -69,9 +31,7 @@ apply_command : ( ) apply_command command current_state = case command of - (Struct.ServerReply.SetSession (pid, stk)) -> - (set_session pid stk current_state) - + (Struct.ServerReply.SetPlayer _) -> current_state Struct.ServerReply.Okay -> current_state -------------------------------------------------------------------------------- diff --git a/src/main-menu/src/Update/SendRecovery.elm b/src/main-menu/src/Update/SendRecovery.elm deleted file mode 100644 index 313477b..0000000 --- a/src/main-menu/src/Update/SendRecovery.elm +++ /dev/null @@ -1,29 +0,0 @@ -module Update.SendRecovery exposing (apply_to) --- Elm ------------------------------------------------------------------------- - --- Map ------------------------------------------------------------------- -import Comm.SendRecovery - -import Struct.Event -import Struct.Model - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -apply_to : ( - Struct.Model.Type -> - (Struct.Model.Type, (Cmd Struct.Event.Type)) - ) -apply_to model = - ( - model, - (case (Comm.SendRecovery.try model) of - (Just cmd) -> cmd - Nothing -> Cmd.none - ) - ) - diff --git a/src/main-menu/src/Update/SendSignIn.elm b/src/main-menu/src/Update/SendSignIn.elm deleted file mode 100644 index 9e28c95..0000000 --- a/src/main-menu/src/Update/SendSignIn.elm +++ /dev/null @@ -1,29 +0,0 @@ -module Update.SendSignIn exposing (apply_to) --- Elm ------------------------------------------------------------------------- - --- Map ------------------------------------------------------------------- -import Comm.SendSignIn - -import Struct.Event -import Struct.Model - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -apply_to : ( - Struct.Model.Type -> - (Struct.Model.Type, (Cmd Struct.Event.Type)) - ) -apply_to model = - ( - model, - (case (Comm.SendSignIn.try model) of - (Just cmd) -> cmd - Nothing -> Cmd.none - ) - ) - diff --git a/src/main-menu/src/Update/SendSignUp.elm b/src/main-menu/src/Update/SendSignUp.elm deleted file mode 100644 index b4b2605..0000000 --- a/src/main-menu/src/Update/SendSignUp.elm +++ /dev/null @@ -1,29 +0,0 @@ -module Update.SendSignUp exposing (apply_to) --- Elm ------------------------------------------------------------------------- - --- Map ------------------------------------------------------------------- -import Comm.SendSignUp - -import Struct.Event -import Struct.Model - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -apply_to : ( - Struct.Model.Type -> - (Struct.Model.Type, (Cmd Struct.Event.Type)) - ) -apply_to model = - ( - model, - (case (Comm.SendSignUp.try model) of - (Just cmd) -> cmd - Nothing -> Cmd.none - ) - ) - diff --git a/src/main-menu/src/View/BattleListing.elm b/src/main-menu/src/View/BattleListing.elm index d3df261..9b667ac 100644 --- a/src/main-menu/src/View/BattleListing.elm +++ b/src/main-menu/src/View/BattleListing.elm @@ -3,15 +3,52 @@ module View.BattleListing exposing (get_html) -- Elm ------------------------------------------------------------------------- import Html import Html.Attributes -import Html.Events +-- import Html.Events -- Map ------------------------------------------------------------------- +import Struct.BattleSummary import Struct.Event -import Struct.UI -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- +get_item_html : Struct.BattleSummary.Type -> (Html.Html Struct.Event.Type) +get_item_html item = + (Html.a + [ + (Html.Attributes.href + ( + "/battle/?id=" + ++ (Struct.BattleSummary.get_id item) + ) + ), + ( + if (Struct.BattleSummary.is_players_turn item) + then + (Html.Attributes.class "main-menu-battle-summary-is-active") + else + (Html.Attributes.class "main-menu-battle-summary-is-inactive") + ) + ] + [ + (Html.div + [ + (Html.Attributes.class "main-menu-battle-summary-name") + ] + [ + (Html.text (Struct.BattleSummary.get_name item)) + ] + ), + (Html.div + [ + (Html.Attributes.class "main-menu-battle-summary-date") + ] + [ + (Html.text (Struct.BattleSummary.get_last_edit item)) + ] + ) + ] + ) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- @@ -19,13 +56,13 @@ import Struct.UI get_html : ( String -> String -> - (List Struct.BattleRef) -> + (List Struct.BattleSummary.Type) -> (Html.Html Struct.Event.Type) ) -get_html name class battle_refs = +get_html name class battle_summaries = (Html.div [ - (Html.Attributes.class class) + (Html.Attributes.class class), (Html.Attributes.class "main-menu-battle-listing") ] [ @@ -41,10 +78,7 @@ get_html name class battle_refs = [ (Html.Attributes.class "main-menu-battle-listing-body") ] - (List.map - (get_battle_ref_html) - battle_refs - ) + (List.map (get_item_html) battle_summaries) ), (Html.div [ diff --git a/src/main-menu/src/View/Header.elm.m4 b/src/main-menu/src/View/Header.elm.m4 index 49e9965..57cb6d1 100644 --- a/src/main-menu/src/View/Header.elm.m4 +++ b/src/main-menu/src/View/Header.elm.m4 @@ -3,11 +3,9 @@ module View.Header exposing (get_html) -- Elm ------------------------------------------------------------------------- import Html import Html.Attributes -import Html.Events -- Map ------------------------------------------------------------------- import Struct.Event -import Struct.UI -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- |