summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-05-23 16:03:22 +0200 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-05-23 16:03:22 +0200 |
commit | f52e0f4ee19c21eb05c4f46f35178af49579f49b (patch) | |
tree | 4132d8536ef5e5fe71072136847a013b01d20b22 | |
parent | d9f9a7e1e67eb53d22488dbfb9264e2e05ec1f7a (diff) |
Centralizes Character HTML generation.
-rw-r--r-- | src/battlemap/src/View/Controlled/CharacterCard.elm | 32 | ||||
-rw-r--r-- | src/battlemap/src/View/SubMenu/Characters.elm | 33 | ||||
-rw-r--r-- | src/battlemap/src/View/SubMenu/Timeline/Attack.elm | 35 | ||||
-rw-r--r-- | src/battlemap/src/View/SubMenu/Timeline/Movement.elm | 32 | ||||
-rw-r--r-- | src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm | 32 | ||||
-rw-r--r-- | src/battlemap/www/style.css | 7 |
6 files changed, 19 insertions, 152 deletions
diff --git a/src/battlemap/src/View/Controlled/CharacterCard.elm b/src/battlemap/src/View/Controlled/CharacterCard.elm index 290db65..59431da 100644 --- a/src/battlemap/src/View/Controlled/CharacterCard.elm +++ b/src/battlemap/src/View/Controlled/CharacterCard.elm @@ -11,37 +11,11 @@ import Struct.Model import Struct.Statistics import Struct.Weapon +import View.Character + -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -get_portrait : ( - Struct.Model.Type -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_portrait model char = - (Html.div - [ - (Html.Attributes.class - ( - "asset-character-portrait-" - ++ (Struct.Character.get_portrait_id char) - ) - ), - ( - if (model.player_id == (Struct.Character.get_player_id char)) - then - (Html.Attributes.class "") - else - (Html.Attributes.class "battlemap-character-enemy") - ), - (Html.Attributes.class "battlemap-character-portrait"), - (Html.Attributes.class "battlemap-character-card-portrait") - ] - [ - ] - ) - get_name : ( Struct.Character.Type -> (Html.Html Struct.Event.Type) @@ -220,7 +194,7 @@ get_html model char weapon = (Html.Attributes.class "battlemap-character-card-top") ] [ - (get_portrait model char), + (View.Character.get_portrait_html model.player_id char), (get_name char), (get_health_bar char) ] diff --git a/src/battlemap/src/View/SubMenu/Characters.elm b/src/battlemap/src/View/SubMenu/Characters.elm index a34cf4a..d96eb2d 100644 --- a/src/battlemap/src/View/SubMenu/Characters.elm +++ b/src/battlemap/src/View/SubMenu/Characters.elm @@ -12,38 +12,11 @@ import Struct.Character import Struct.Event import Struct.Model +import View.Character + -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -get_character_portrait_html : ( - String -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_character_portrait_html viewer_id char = - (Html.div - [ - (Html.Attributes.class - ( - "asset-character-portrait-" - ++ (Struct.Character.get_portrait_id char) - ) - ), - (Html.Attributes.class - ( - if ((Struct.Character.get_player_id char) == viewer_id) - then - "battlemap-character-ally" - else - "battlemap-character-enemy" - ) - ), - (Html.Attributes.class "battlemap-character-portrait") - ] - [ - ] - ) - get_character_element_html : ( String -> Struct.Character.Type -> @@ -61,7 +34,7 @@ get_character_element_html viewer_id char = ) ] [ - (get_character_portrait_html viewer_id char), + (View.Character.get_portrait_html viewer_id char), (Html.text ( (Struct.Character.get_name char) diff --git a/src/battlemap/src/View/SubMenu/Timeline/Attack.elm b/src/battlemap/src/View/SubMenu/Timeline/Attack.elm index 6dab423..3330007 100644 --- a/src/battlemap/src/View/SubMenu/Timeline/Attack.elm +++ b/src/battlemap/src/View/SubMenu/Timeline/Attack.elm @@ -14,6 +14,8 @@ import Struct.TurnResult import Struct.Character import Struct.Model +import View.Character + -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -39,35 +41,6 @@ get_title_html attacker defender = ] ) -get_portrait_html : ( - String -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_portrait_html viewer_id char = - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-portrait"), - (Html.Attributes.class - ( - if ((Struct.Character.get_player_id char) == viewer_id) - then - "battlemap-character-ally" - else - "battlemap-character-enemy" - ) - ), - (Html.Attributes.class - ( - "asset-character-portrait-" - ++ (Struct.Character.get_portrait_id char) - ) - ) - ] - [ - ] - ) - get_effect_text : Struct.Attack.Type -> String get_effect_text attack = ( @@ -167,8 +140,8 @@ get_html model attack = ] ( [ - (get_portrait_html model.player_id atkchar), - (get_portrait_html model.player_id defchar), + (View.Character.get_portrait_html model.player_id atkchar), + (View.Character.get_portrait_html model.player_id defchar), (get_title_html atkchar defchar) ] ++ diff --git a/src/battlemap/src/View/SubMenu/Timeline/Movement.elm b/src/battlemap/src/View/SubMenu/Timeline/Movement.elm index f561d6c..bba9bc1 100644 --- a/src/battlemap/src/View/SubMenu/Timeline/Movement.elm +++ b/src/battlemap/src/View/SubMenu/Timeline/Movement.elm @@ -13,37 +13,11 @@ import Struct.TurnResult import Struct.Character import Struct.Model +import View.Character + -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -get_portrait_html : ( - String -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_portrait_html viewer_id char = - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-portrait"), - (Html.Attributes.class - ( - if ((Struct.Character.get_player_id char) == viewer_id) - then - "battlemap-character-ally" - else - "battlemap-character-enemy" - ) - ), - (Html.Attributes.class - ( - "asset-character-portrait-" - ++ (Struct.Character.get_portrait_id char) - ) - ) - ] - [ - ] - ) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- @@ -62,7 +36,7 @@ get_html model movement = (Html.Attributes.class "battlemap-timeline-movement") ] [ - (get_portrait_html model.player_id char), + (View.Character.get_portrait_html model.player_id char), (Html.text ( (Struct.Character.get_name char) diff --git a/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm b/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm index 91191c4..53122ad 100644 --- a/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm +++ b/src/battlemap/src/View/SubMenu/Timeline/WeaponSwitch.elm @@ -13,37 +13,11 @@ import Struct.TurnResult import Struct.Character import Struct.Model +import View.Character + -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -get_portrait_html : ( - String -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_portrait_html viewer_id char = - (Html.div - [ - (Html.Attributes.class "battlemap-timeline-portrait"), - (Html.Attributes.class - ( - if ((Struct.Character.get_player_id char) == viewer_id) - then - "battlemap-character-ally" - else - "battlemap-character-enemy" - ) - ), - (Html.Attributes.class - ( - "asset-character-portrait-" - ++ (Struct.Character.get_portrait_id char) - ) - ) - ] - [ - ] - ) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- @@ -62,7 +36,7 @@ get_html model weapon_switch = (Html.Attributes.class "battlemap-timeline-weapon-switch") ] [ - (get_portrait_html model.player_id char), + (View.Character.get_portrait_html model.player_id char), (Html.text ( (Struct.Character.get_name char) diff --git a/src/battlemap/www/style.css b/src/battlemap/www/style.css index 5fc6ae5..ffd32d5 100644 --- a/src/battlemap/www/style.css +++ b/src/battlemap/www/style.css @@ -145,7 +145,7 @@ justify-content: left; } -.battlemap-character-card-portrait +.battlemap-character-card .battlemap-character-portrait { grid-column: col 1; grid-row: row 1 / span 3; @@ -214,8 +214,7 @@ flex-wrap: wrap; } -.battlemap-character-portrait, -.battlemap-timeline-portrait +.battlemap-character-portrait { margin: 0.5em; box-sizing: border-box; @@ -244,7 +243,7 @@ float: left; } -.battlemap-timeline-portrait +.battlemap-timeline-element .battlemap-character-portrait { display: inline-block; vertical-align: middle; |