aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-09-09 23:20:48 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-09-09 23:20:48 +0200
commitbbcef7854f999ae8fd77b6bcf8addd594cae08b9 (patch)
tree922464bb27711fe332188c8fbae6bc0db5d81714
parent89bc3e662c166ba96097c35f1665409a6ed54a6d (diff)
downloadtacticians-client-bbcef7854f999ae8fd77b6bcf8addd594cae08b9.zip
tacticians-client-bbcef7854f999ae8fd77b6bcf8addd594cae08b9.tar.bz2
Makes glyph selection more user-friendly.
-rw-r--r--src/css/src/roster-editor/selection-window.scss8
-rw-r--r--src/roster-editor/src/ElmModule/Update.elm8
-rw-r--r--src/roster-editor/src/Struct/Character.elm98
-rw-r--r--src/roster-editor/src/Struct/UI.elm25
-rw-r--r--src/roster-editor/src/Update/SetGlyph.elm6
-rw-r--r--src/roster-editor/src/Update/SetGlyphBoard.elm2
-rw-r--r--src/roster-editor/src/Update/SetGlyphSlot.elm70
-rw-r--r--src/roster-editor/src/View/GlyphSelection.elm71
8 files changed, 216 insertions, 72 deletions
diff --git a/src/css/src/roster-editor/selection-window.scss b/src/css/src/roster-editor/selection-window.scss
index f3a63a0..98e5168 100644
--- a/src/css/src/roster-editor/selection-window.scss
+++ b/src/css/src/roster-editor/selection-window.scss
@@ -38,3 +38,11 @@
width: 16em;
display: block;
}
+.roster-editor-forbidden-glyph
+{
+ background-color: $RED-5;
+ border-radius: 6px;
+ border: solid 1px $RED-0;
+ padding: 2px;
+}
+
diff --git a/src/roster-editor/src/ElmModule/Update.elm b/src/roster-editor/src/ElmModule/Update.elm
index cf1c396..03881b7 100644
--- a/src/roster-editor/src/ElmModule/Update.elm
+++ b/src/roster-editor/src/ElmModule/Update.elm
@@ -14,6 +14,7 @@ import Update.SendRoster
import Update.SetArmor
import Update.SetGlyph
import Update.SetGlyphBoard
+import Update.SetGlyphSlot
import Update.SetName
import Update.SetPortrait
import Update.SetRequestedHelp
@@ -104,12 +105,7 @@ update event model =
(Update.SetGlyph.apply_to new_model ref)
(Struct.Event.ClickedOnGlyph index) ->
- (Update.SelectTab.apply_to
- {model |
- ui = (Struct.UI.set_glyph_slot index model.ui)
- }
- Struct.UI.GlyphSelectionTab
- )
+ (Update.SetGlyphSlot.apply_to index model)
(Struct.Event.SelectedGlyphBoard ref) ->
(Update.SetGlyphBoard.apply_to new_model ref)
diff --git a/src/roster-editor/src/Struct/Character.elm b/src/roster-editor/src/Struct/Character.elm
index c927c05..6c01993 100644
--- a/src/roster-editor/src/Struct/Character.elm
+++ b/src/roster-editor/src/Struct/Character.elm
@@ -11,8 +11,9 @@ module Struct.Character exposing
get_was_edited,
set_is_valid,
get_is_valid,
- set_invalid_glyph_family_indices,
+ update_glyph_family_index_collections,
get_invalid_glyph_family_indices,
+ get_all_glyph_family_indices,
resolve,
to_unresolved,
decoder,
@@ -51,6 +52,7 @@ type alias Type =
was_edited : Bool,
is_valid : Bool,
invalid_glyph_family_ids : (Set.Set BattleCharacters.Struct.Glyph.Ref),
+ all_glyph_family_ids : (Set.Set BattleCharacters.Struct.Glyph.Ref),
base : BattleCharacters.Struct.Character.Type
}
@@ -61,30 +63,46 @@ type alias Unresolved =
was_edited : Bool,
is_valid : Bool,
invalid_glyph_family_ids : (Set.Set BattleCharacters.Struct.Glyph.Ref),
+ all_glyph_family_ids : (Set.Set BattleCharacters.Struct.Glyph.Ref),
base : BattleCharacters.Struct.Character.Unresolved
}
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-compute_invalid_glyph_family_ids : (
+compute_glyph_family_id_collections : (
BattleCharacters.Struct.Equipment.Type ->
- (Set.Set BattleCharacters.Struct.Glyph.Ref)
- )
-compute_invalid_glyph_family_ids equipment =
- (Set.remove
- (BattleCharacters.Struct.Glyph.get_family_id
- (BattleCharacters.Struct.Glyph.none)
+ (
+ (Set.Set BattleCharacters.Struct.Glyph.Ref),
+ (Set.Set BattleCharacters.Struct.Glyph.Ref)
)
- (Util.List.duplicates
+ )
+compute_glyph_family_id_collections equipment =
+ let
+ family_ids_list =
(List.map
(BattleCharacters.Struct.Glyph.get_family_id)
(Array.toList
(BattleCharacters.Struct.Equipment.get_glyphs equipment)
)
)
+ no_glyph_family_id =
+ (BattleCharacters.Struct.Glyph.get_family_id
+ (BattleCharacters.Struct.Glyph.none)
+ )
+ in
+ (
+ (Set.remove
+ no_glyph_family_id
+ (Set.fromList family_ids_list)
+ ),
+ (Set.remove
+ no_glyph_family_id
+ (Util.List.duplicates
+ family_ids_list
+ )
+ )
)
- )
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -142,16 +160,26 @@ get_invalid_glyph_family_indices : (
)
get_invalid_glyph_family_indices char = char.invalid_glyph_family_ids
-set_invalid_glyph_family_indices : (
+get_all_glyph_family_indices : (
+ Type ->
+ (Set.Set BattleCharacters.Struct.Glyph.Ref)
+ )
+get_all_glyph_family_indices char = char.all_glyph_family_ids
+
+update_glyph_family_index_collections : (
BattleCharacters.Struct.Equipment.Type ->
Type ->
Type
)
-set_invalid_glyph_family_indices equipment char =
- let ids = (compute_invalid_glyph_family_ids equipment) in
+update_glyph_family_index_collections equipment char =
+ let
+ (used_ids, overused_ids) =
+ (compute_glyph_family_id_collections equipment)
+ in
{char |
- invalid_glyph_family_ids = ids,
- is_valid = (char.is_valid && (Set.isEmpty ids))
+ all_glyph_family_ids = used_ids,
+ invalid_glyph_family_ids = overused_ids,
+ is_valid = (char.is_valid && (Set.isEmpty overused_ids))
}
resolve : (
@@ -163,21 +191,29 @@ resolve : (
Type
)
resolve equipment_resolver ref =
- (set_is_valid
- {
- ix = ref.ix,
- battle_ix = ref.battle_ix,
- was_edited = ref.was_edited,
- is_valid = False,
- invalid_glyph_family_ids = ref.invalid_glyph_family_ids,
- base =
- (BattleCharacters.Struct.Character.resolve
- (equipment_resolver)
- (Battle.Struct.Omnimods.none)
- ref.base
- )
- }
- )
+ let
+ base_character =
+ (BattleCharacters.Struct.Character.resolve
+ (equipment_resolver)
+ (Battle.Struct.Omnimods.none)
+ ref.base
+ )
+ (all_glyph_family_ids, invalid_glyph_family_ids) =
+ (compute_glyph_family_id_collections
+ (BattleCharacters.Struct.Character.get_equipment base_character)
+ )
+ in
+ (set_is_valid
+ {
+ ix = ref.ix,
+ battle_ix = ref.battle_ix,
+ was_edited = ref.was_edited,
+ is_valid = False,
+ invalid_glyph_family_ids = invalid_glyph_family_ids,
+ all_glyph_family_ids = all_glyph_family_ids,
+ base = base_character
+ }
+ )
to_unresolved : Type -> Unresolved
to_unresolved char =
@@ -187,6 +223,7 @@ to_unresolved char =
was_edited = char.was_edited,
is_valid = char.is_valid,
invalid_glyph_family_ids = char.invalid_glyph_family_ids,
+ all_glyph_family_ids = char.all_glyph_family_ids,
base = (BattleCharacters.Struct.Character.to_unresolved char.base)
}
@@ -199,6 +236,7 @@ decoder =
|> (Json.Decode.Pipeline.hardcoded False)
|> (Json.Decode.Pipeline.hardcoded True)
|> (Json.Decode.Pipeline.hardcoded (Set.empty))
+ |> (Json.Decode.Pipeline.hardcoded (Set.empty))
|>
(Json.Decode.Pipeline.required
"bas"
diff --git a/src/roster-editor/src/Struct/UI.elm b/src/roster-editor/src/Struct/UI.elm
index 59244d2..33e1181 100644
--- a/src/roster-editor/src/Struct/UI.elm
+++ b/src/roster-editor/src/Struct/UI.elm
@@ -9,10 +9,7 @@ module Struct.UI exposing
reset_displayed_tab,
-- Which glyph slot is being edited?
set_glyph_slot,
- get_glyph_slot,
- -- Display Tile Costs
- get_display_tile_cost,
- toggle_display_tile_cost
+ get_glyph_slot
)
--------------------------------------------------------------------------------
@@ -31,8 +28,7 @@ type Tab =
type alias Type =
{
displayed_tab : Tab,
- glyph_slot : Int,
- display_tile_cost : Bool
+ glyph_slot : (Int, Int)
}
--------------------------------------------------------------------------------
@@ -46,8 +42,7 @@ default : Type
default =
{
displayed_tab = CharacterSelectionTab,
- glyph_slot = -1,
- display_tile_cost = False
+ glyph_slot = (-1, 0)
}
-- Tab -------------------------------------------------------------------------
@@ -60,16 +55,8 @@ set_displayed_tab tab ui = {ui | displayed_tab = tab}
reset_displayed_tab : Type -> Type
reset_displayed_tab ui = {ui | displayed_tab = CharacterSelectionTab}
-get_glyph_slot : Type -> Int
+get_glyph_slot : Type -> (Int, Int)
get_glyph_slot ui = ui.glyph_slot
-set_glyph_slot : Int -> Type -> Type
-set_glyph_slot tab ui = {ui | glyph_slot = tab}
-
--- Tile Cost -------------------------------------------------------------------
-toggle_display_tile_cost : Type -> Type
-toggle_display_tile_cost ui =
- {ui | display_tile_cost = (not ui.display_tile_cost)}
-
-get_display_tile_cost : Type -> Bool
-get_display_tile_cost ui = ui.display_tile_cost
+set_glyph_slot : (Int, Int) -> Type -> Type
+set_glyph_slot slot_and_factor ui = {ui | glyph_slot = slot_and_factor}
diff --git a/src/roster-editor/src/Update/SetGlyph.elm b/src/roster-editor/src/Update/SetGlyph.elm
index 7007d47..067cf7c 100644
--- a/src/roster-editor/src/Update/SetGlyph.elm
+++ b/src/roster-editor/src/Update/SetGlyph.elm
@@ -33,9 +33,11 @@ apply_to model ref =
((Just char), (Just glyph)) ->
let
base_char = (Struct.Character.get_base_character char)
+ (glyph_slot, glyph_modifier) =
+ (Struct.UI.get_glyph_slot model.ui)
updated_equipment =
(BattleCharacters.Struct.Equipment.set_glyph
- (Struct.UI.get_glyph_slot model.ui)
+ glyph_slot
glyph
(BattleCharacters.Struct.Character.get_equipment
base_char
@@ -45,7 +47,7 @@ apply_to model ref =
{model |
edited_char =
(Just
- (Struct.Character.set_invalid_glyph_family_indices
+ (Struct.Character.update_glyph_family_index_collections
updated_equipment
(Struct.Character.set_base_character
(BattleCharacters.Struct.Character.set_equipment
diff --git a/src/roster-editor/src/Update/SetGlyphBoard.elm b/src/roster-editor/src/Update/SetGlyphBoard.elm
index 70a7fd6..9f0f452 100644
--- a/src/roster-editor/src/Update/SetGlyphBoard.elm
+++ b/src/roster-editor/src/Update/SetGlyphBoard.elm
@@ -43,7 +43,7 @@ apply_to model ref =
{model |
edited_char =
(Just
- (Struct.Character.set_invalid_glyph_family_indices
+ (Struct.Character.update_glyph_family_index_collections
updated_equipment
(Struct.Character.set_base_character
(BattleCharacters.Struct.Character.set_equipment
diff --git a/src/roster-editor/src/Update/SetGlyphSlot.elm b/src/roster-editor/src/Update/SetGlyphSlot.elm
new file mode 100644
index 0000000..6c8f6dd
--- /dev/null
+++ b/src/roster-editor/src/Update/SetGlyphSlot.elm
@@ -0,0 +1,70 @@
+module Update.SetGlyphSlot exposing (apply_to)
+
+-- Elm -------------------------------------------------------------------------
+import Array
+
+-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.Glyph
+import BattleCharacters.Struct.GlyphBoard
+import BattleCharacters.Struct.Equipment
+import BattleCharacters.Struct.Character
+
+-- Local Module ----------------------------------------------------------------
+import Struct.Character
+import Struct.Event
+import Struct.Model
+import Struct.UI
+
+import Update.SelectTab
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_glyph_board_slot_factor : (
+ Int ->
+ Struct.Character.Type ->
+ Int
+ )
+get_glyph_board_slot_factor index char =
+ case
+ (Array.get
+ index
+ (Array.fromList
+ (BattleCharacters.Struct.GlyphBoard.get_slots
+ (BattleCharacters.Struct.Equipment.get_glyph_board
+ (BattleCharacters.Struct.Character.get_equipment
+ (Struct.Character.get_base_character char)
+ )
+ )
+ )
+ )
+ )
+ of
+ Nothing -> 0
+ (Just factor) -> factor
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+apply_to : (
+ Int ->
+ Struct.Model.Type ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+apply_to index model =
+ case model.edited_char of
+ Nothing -> (model, Cmd.none)
+ (Just char) ->
+ (Update.SelectTab.apply_to
+ {model|
+ ui =
+ (Struct.UI.set_glyph_slot
+ (
+ index,
+ (get_glyph_board_slot_factor index char)
+ )
+ model.ui
+ )
+ }
+ Struct.UI.GlyphSelectionTab
+ )
diff --git a/src/roster-editor/src/View/GlyphSelection.elm b/src/roster-editor/src/View/GlyphSelection.elm
index d1125f6..67faf59 100644
--- a/src/roster-editor/src/View/GlyphSelection.elm
+++ b/src/roster-editor/src/View/GlyphSelection.elm
@@ -1,6 +1,10 @@
module View.GlyphSelection exposing (get_html)
-- Elm -------------------------------------------------------------------------
+import Array
+
+import Set
+
import Dict
import Html
@@ -8,14 +12,21 @@ import Html.Attributes
import Html.Events
-- Battle ----------------------------------------------------------------------
+import Battle.Struct.Omnimods
+
import Battle.View.Omnimods
-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.Character
+import BattleCharacters.Struct.Equipment
import BattleCharacters.Struct.Glyph
+import BattleCharacters.Struct.GlyphBoard
-- Local Module ----------------------------------------------------------------
+import Struct.Character
import Struct.Event
import Struct.Model
+import Struct.UI
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
@@ -35,14 +46,27 @@ get_mod_html mod =
)
get_glyph_html : (
+ (Set.Set BattleCharacters.Struct.Glyph.Ref) ->
+ Float ->
BattleCharacters.Struct.Glyph.Type ->
(Html.Html Struct.Event.Type)
)
-get_glyph_html glyph =
+get_glyph_html invalid_family_ids factor glyph =
(Html.div
[
(Html.Attributes.class "character-card-glyph"),
(Html.Attributes.class "clickable"),
+ (Html.Attributes.class
+ (
+ if
+ (Set.member
+ (BattleCharacters.Struct.Glyph.get_family_id glyph)
+ invalid_family_ids
+ )
+ then "roster-editor-forbidden-glyph"
+ else "roster-editor-allowed-glyph"
+ )
+ ),
(Html.Events.onClick
(Struct.Event.SelectedGlyph
(BattleCharacters.Struct.Glyph.get_id glyph)
@@ -52,7 +76,10 @@ get_glyph_html glyph =
[
(Html.text (BattleCharacters.Struct.Glyph.get_name glyph)),
(Battle.View.Omnimods.get_html
- (BattleCharacters.Struct.Glyph.get_omnimods glyph)
+ (Battle.Struct.Omnimods.scale
+ factor
+ (BattleCharacters.Struct.Glyph.get_omnimods glyph)
+ )
)
]
)
@@ -67,16 +94,32 @@ get_html model =
(Html.Attributes.class "selection-window"),
(Html.Attributes.class "glyph-management")
]
- [
- (Html.text "Glyph Selection"),
- (Html.div
- [
- (Html.Attributes.class "selection-window-listing")
- ]
- (List.map
- (get_glyph_html)
- (Dict.values model.glyphs)
- )
- )
- ]
+ (
+ case model.edited_char of
+ Nothing -> [ (Html.text "Choose a character first.") ]
+ (Just char) ->
+ let
+ (slot_index, glyph_modifier) =
+ (Struct.UI.get_glyph_slot model.ui)
+ glyph_multiplier =
+ ((toFloat glyph_modifier) / 100.0)
+ used_glyph_family_indices =
+ (Struct.Character.get_all_glyph_family_indices char)
+ in
+ [
+ (Html.text "Glyph Selection"),
+ (Html.div
+ [
+ (Html.Attributes.class "selection-window-listing")
+ ]
+ (List.map
+ (get_glyph_html
+ used_glyph_family_indices
+ glyph_multiplier
+ )
+ (Dict.values model.glyphs)
+ )
+ )
+ ]
+ )
)