From 6a07935216a4d8a8889711221bf870a7f16d2b0e Mon Sep 17 00:00:00 2001 From: nsensfel Date: Mon, 12 Nov 2018 16:00:21 +0100 Subject: Adds glyph board selection. --- src/roster-editor/src/Struct/GlyphBoard.elm | 6 ++ src/roster-editor/src/Struct/UI.elm | 1 + src/roster-editor/src/View/CharacterCard.elm | 38 +++++++++ src/roster-editor/src/View/CurrentTab.elm | 8 +- src/roster-editor/src/View/GlyphBoardSelection.elm | 92 ++++++++++++++++++++++ 5 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 src/roster-editor/src/View/GlyphBoardSelection.elm (limited to 'src/roster-editor') diff --git a/src/roster-editor/src/Struct/GlyphBoard.elm b/src/roster-editor/src/Struct/GlyphBoard.elm index 3221a4e..a7fa503 100644 --- a/src/roster-editor/src/Struct/GlyphBoard.elm +++ b/src/roster-editor/src/Struct/GlyphBoard.elm @@ -28,6 +28,7 @@ type alias Type = { id : String, name : String, + slots : (List Int), omnimods : Struct.Omnimods.Type } @@ -62,6 +63,10 @@ decoder = Type |> (Json.Decode.Pipeline.required "id" Json.Decode.string) |> (Json.Decode.Pipeline.required "nam" Json.Decode.string) + |> (Json.Decode.Pipeline.required + "slot" + (Json.Decode.list (Json.Decode.int)) + ) |> (Json.Decode.Pipeline.required "omni" Struct.Omnimods.decoder) ) @@ -70,6 +75,7 @@ none = { id = "", name = "None", + slots = [], omnimods = (Struct.Omnimods.none) } diff --git a/src/roster-editor/src/Struct/UI.elm b/src/roster-editor/src/Struct/UI.elm index f3ed05d..10b04c6 100644 --- a/src/roster-editor/src/Struct/UI.elm +++ b/src/roster-editor/src/Struct/UI.elm @@ -25,6 +25,7 @@ type Tab = -- | AccessorySelectionTab | WeaponSelectionTab | ArmorSelectionTab + | GlyphBoardSelectionTab | GlyphManagementTab type alias Type = diff --git a/src/roster-editor/src/View/CharacterCard.elm b/src/roster-editor/src/View/CharacterCard.elm index aa3e922..7430165 100644 --- a/src/roster-editor/src/View/CharacterCard.elm +++ b/src/roster-editor/src/View/CharacterCard.elm @@ -15,6 +15,7 @@ import Html.Events import Struct.Armor import Struct.Character import Struct.Event +import Struct.GlyphBoard import Struct.Omnimods import Struct.Statistics import Struct.UI @@ -260,6 +261,42 @@ get_armor_details omnimods armor = ] ) +get_glyph_board_details : ( + Struct.GlyphBoard.Type -> + (Html.Html Struct.Event.Type) + ) +get_glyph_board_details board = + (Html.div + [ + (Html.Attributes.class "character-card-glyph-board"), + (Html.Attributes.class "clickable"), + (Html.Events.onClick + (Struct.Event.TabSelected Struct.UI.GlyphBoardSelectionTab) + ) + ] + [ + (Html.div + [ + (Html.Attributes.class "character-card-glyph-board-name") + ] + [ + (Html.text (Struct.GlyphBoard.get_name board)) + ] + ), + (Html.div + [ + (Html.Attributes.class "info-card-omnimods-listing") + ] + (List.map + (get_mod_html) + (Struct.Omnimods.get_all_mods + (Struct.GlyphBoard.get_omnimods board) + ) + ) + ) + ] + ) + stat_name : String -> (Html.Html Struct.Event.Type) stat_name name = (Html.div @@ -407,6 +444,7 @@ get_full_html char = ), (get_weapon_details omnimods damage_modifier main_weapon), (get_armor_details omnimods armor), + (get_glyph_board_details (Struct.Character.get_glyph_board char)), (get_relevant_stats char_statistics), (get_weapon_summary damage_modifier secondary_weapon) ] diff --git a/src/roster-editor/src/View/CurrentTab.elm b/src/roster-editor/src/View/CurrentTab.elm index 8a062a9..995a5d2 100644 --- a/src/roster-editor/src/View/CurrentTab.elm +++ b/src/roster-editor/src/View/CurrentTab.elm @@ -8,11 +8,12 @@ import Struct.Event import Struct.Model import Struct.UI +import View.ArmorSelection import View.CharacterSelection +import View.GlyphManagement +import View.GlyphBoardSelection import View.PortraitSelection import View.WeaponSelection -import View.ArmorSelection -import View.GlyphManagement -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- @@ -36,5 +37,8 @@ get_html model = Struct.UI.ArmorSelectionTab -> (View.ArmorSelection.get_html model) + Struct.UI.GlyphBoardSelectionTab -> + (View.GlyphBoardSelection.get_html model) + Struct.UI.GlyphManagementTab -> (View.GlyphManagement.get_html model) diff --git a/src/roster-editor/src/View/GlyphBoardSelection.elm b/src/roster-editor/src/View/GlyphBoardSelection.elm new file mode 100644 index 0000000..756edbf --- /dev/null +++ b/src/roster-editor/src/View/GlyphBoardSelection.elm @@ -0,0 +1,92 @@ +module View.GlyphBoardSelection exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes +import Html.Events + +-- Roster Editor --------------------------------------------------------------- +import Struct.GlyphBoard +import Struct.Event +import Struct.Model +import Struct.Omnimods + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +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 ++ ": " ++ (toString value)) + ) + ] + ) + +get_glyph_board_html : ( + Struct.GlyphBoard.Type -> + (Html.Html Struct.Event.Type) + ) +get_glyph_board_html glyph_board = + (Html.div + [ + (Html.Attributes.class "character-card-glyph-board"), + (Html.Attributes.class "clickable"), + (Html.Events.onClick + (Struct.Event.SelectedGlyphBoard + (Struct.GlyphBoard.get_id glyph_board) + ) + ) + ] + [ + (Html.div + [ + (Html.Attributes.class "character-card-glyph-board-name") + ] + [ + (Html.text (Struct.GlyphBoard.get_name glyph_board)) + ] + ), + (Html.div + [ + (Html.Attributes.class "info-card-omnimods-listing") + ] + (List.map + (get_mod_html) + (Struct.Omnimods.get_all_mods + (Struct.GlyphBoard.get_omnimods glyph_board) + ) + ) + ) + ] + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) +get_html model = + (Html.div + [ + (Html.Attributes.class "selection-window"), + (Html.Attributes.class "glyph-board-selection") + ] + [ + (Html.text "Glyph Board Selection"), + (Html.div + [ + (Html.Attributes.class "selection-window-listing") + ] + (List.map (get_glyph_board_html) (Dict.values model.glyph_boards)) + ) + ] + ) -- cgit v1.2.3-70-g09d2