Restore catch quality inventory styling
This commit is contained in:
parent
8b13ba1d7d
commit
4dc87235ec
4 changed files with 141 additions and 11 deletions
|
|
@ -11,6 +11,12 @@ const LockedContentPresentationType = preload(
|
|||
"res://ui/components/locked_content_presentation.gd"
|
||||
)
|
||||
|
||||
enum QualityEmphasis {
|
||||
NORMAL,
|
||||
HOVER,
|
||||
SELECTED,
|
||||
}
|
||||
|
||||
var slot_index: int = -1
|
||||
var container: int = -1
|
||||
var entry_kind: int = -1
|
||||
|
|
@ -29,6 +35,7 @@ var _context_text: String = ""
|
|||
var _context_hovered: bool = false
|
||||
var _context_focused: bool = false
|
||||
var _staged: bool = false
|
||||
var _quality_tier: int = -1
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -101,10 +108,12 @@ func refresh() -> void:
|
|||
entry_kind = -1
|
||||
entry_identity = StringName()
|
||||
_context_text = ""
|
||||
_quality_tier = -1
|
||||
_icon.texture = null
|
||||
_quantity.text = ""
|
||||
disabled = _locked
|
||||
_apply_icon_geometry()
|
||||
_apply_style()
|
||||
if _locked:
|
||||
_icon.texture = LockedContentPresentationType.ICON
|
||||
_icon.modulate = LockedContentPresentationType.icon_modulate()
|
||||
|
|
@ -152,12 +161,14 @@ func refresh() -> void:
|
|||
)
|
||||
if fish_catch == null:
|
||||
return
|
||||
_quality_tier = fish_catch.quality
|
||||
_icon.texture = fish_catch.fish.display_texture
|
||||
_context_text = _catch_context_text(fish_catch)
|
||||
var catch_name: String = FishQuality.qualified_name(
|
||||
fish_catch.fish.display_name, fish_catch.quality
|
||||
)
|
||||
accessibility_name = "%s, slot %d" % [catch_name, slot_index + 1]
|
||||
_apply_style()
|
||||
|
||||
|
||||
func _on_pressed() -> void:
|
||||
|
|
@ -306,27 +317,62 @@ func _drop_data(_at_position: Vector2, data: Variant) -> void:
|
|||
|
||||
func _apply_style() -> void:
|
||||
var radius: int = roundi(minf(_presentation_size.x, _presentation_size.y) * 0.5)
|
||||
var normal_color: Color = quality_background_color(
|
||||
_quality_tier,
|
||||
QualityEmphasis.SELECTED if _staged else QualityEmphasis.NORMAL,
|
||||
)
|
||||
var normal := UtilityPageStyle.rounded_style(
|
||||
Color(
|
||||
UtilityPageStyle.OCEAN_SELECTED
|
||||
if _staged else UtilityPageStyle.OCEAN_FIELD,
|
||||
0.92 if _staged else 0.88,
|
||||
),
|
||||
normal_color,
|
||||
radius,
|
||||
)
|
||||
var hover := UtilityPageStyle.rounded_style(
|
||||
Color(UtilityPageStyle.OCEAN_SELECTED, 0.92), radius
|
||||
quality_background_color(_quality_tier, QualityEmphasis.HOVER),
|
||||
radius,
|
||||
)
|
||||
var selected := UtilityPageStyle.rounded_style(
|
||||
quality_background_color(_quality_tier, QualityEmphasis.SELECTED),
|
||||
radius,
|
||||
)
|
||||
var locked := UtilityPageStyle.rounded_style(
|
||||
LockedContentPresentationType.disabled_background_color(), radius
|
||||
)
|
||||
for state: StringName in [&"normal", &"pressed"]:
|
||||
add_theme_stylebox_override(state, normal)
|
||||
add_theme_stylebox_override("normal", normal)
|
||||
add_theme_stylebox_override(
|
||||
"pressed", selected if FishQuality.is_valid(_quality_tier) else normal
|
||||
)
|
||||
add_theme_stylebox_override("disabled", locked)
|
||||
for state: StringName in [&"hover", &"focus"]:
|
||||
add_theme_stylebox_override(state, hover)
|
||||
|
||||
|
||||
static func quality_background_color(
|
||||
quality: int,
|
||||
emphasis: QualityEmphasis,
|
||||
) -> Color:
|
||||
var base_color: Color
|
||||
var alpha: float
|
||||
var quality_mix: float
|
||||
match emphasis:
|
||||
QualityEmphasis.HOVER:
|
||||
base_color = UtilityPageStyle.OCEAN_SELECTED
|
||||
alpha = 0.92
|
||||
quality_mix = 0.64
|
||||
QualityEmphasis.SELECTED:
|
||||
base_color = UtilityPageStyle.OCEAN_SELECTED
|
||||
alpha = 0.92
|
||||
quality_mix = 0.82
|
||||
_:
|
||||
base_color = UtilityPageStyle.OCEAN_FIELD
|
||||
alpha = 0.88
|
||||
quality_mix = 0.46
|
||||
if not FishQuality.is_valid(quality):
|
||||
return Color(base_color, alpha)
|
||||
return Color(
|
||||
base_color.lerp(UIPalette.get_quality_color(quality), quality_mix),
|
||||
alpha,
|
||||
)
|
||||
|
||||
|
||||
func _apply_presentation() -> void:
|
||||
_apply_icon_geometry()
|
||||
var is_large: bool = _presentation_size.x >= 70.0
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ signal drop_requested(payload: Dictionary)
|
|||
var entry_key: String = ""
|
||||
var _icon: TextureRect
|
||||
var _quantity: Label
|
||||
var _quality_tier: int = -1
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -32,11 +33,29 @@ func _ready() -> void:
|
|||
_quantity.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
_quantity.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
add_child(_quantity)
|
||||
_apply_style()
|
||||
|
||||
|
||||
func _apply_style() -> void:
|
||||
var normal_color := GeneralInventorySlot.quality_background_color(
|
||||
_quality_tier,
|
||||
GeneralInventorySlot.QualityEmphasis.NORMAL,
|
||||
)
|
||||
var hover_color := GeneralInventorySlot.quality_background_color(
|
||||
_quality_tier,
|
||||
GeneralInventorySlot.QualityEmphasis.SELECTED,
|
||||
)
|
||||
# Preserve the tray's established opacity while sharing the inventory's
|
||||
# quality colors. Ordinary items and the empty drop target stay unchanged.
|
||||
normal_color.a = 0.96
|
||||
hover_color.a = 0.96
|
||||
var normal := UtilityPageStyle.rounded_style(
|
||||
Color(UtilityPageStyle.OCEAN_FIELD, 0.96), 26
|
||||
normal_color,
|
||||
26,
|
||||
)
|
||||
var hover := UtilityPageStyle.rounded_style(
|
||||
Color(UtilityPageStyle.OCEAN_SELECTED, 0.96), 26
|
||||
hover_color,
|
||||
26,
|
||||
)
|
||||
for state: StringName in [&"normal", &"pressed", &"disabled"]:
|
||||
add_theme_stylebox_override(state, normal)
|
||||
|
|
@ -49,12 +68,15 @@ func configure(
|
|||
icon: Texture2D,
|
||||
label: String,
|
||||
quantity: int = 1,
|
||||
quality: int = -1,
|
||||
) -> void:
|
||||
entry_key = key
|
||||
_quality_tier = quality
|
||||
_icon.texture = icon
|
||||
_quantity.text = "×%d" % quantity if quantity > 1 else ""
|
||||
tooltip_text = "%s · select to remove" % label
|
||||
accessibility_name = tooltip_text
|
||||
_apply_style()
|
||||
|
||||
|
||||
func _can_drop_data(_at_position: Vector2, data: Variant) -> bool:
|
||||
|
|
|
|||
|
|
@ -205,12 +205,14 @@ func _refresh_tray() -> void:
|
|||
var identity := StringName(str(record["identity"]))
|
||||
var icon: Texture2D
|
||||
var label: String
|
||||
var quality: int = -1
|
||||
if int(record["kind"]) == PlayerInventoryLayout.EntryKind.CATCH:
|
||||
var fish_catch := _fish_inventory.get_catch_by_id(identity)
|
||||
if fish_catch == null:
|
||||
continue
|
||||
icon = fish_catch.fish.display_texture
|
||||
label = fish_catch.fish.display_name
|
||||
quality = fish_catch.quality
|
||||
else:
|
||||
var item := _item_catalog.get_item_by_id(identity)
|
||||
if item == null:
|
||||
|
|
@ -219,7 +221,13 @@ func _refresh_tray() -> void:
|
|||
label = item.display_name
|
||||
var slot := ShopSaleTraySlot.new()
|
||||
_tray_grid.add_child(slot)
|
||||
slot.configure(key, icon, label, int(record.get("quantity", 1)))
|
||||
slot.configure(
|
||||
key,
|
||||
icon,
|
||||
label,
|
||||
int(record.get("quantity", 1)),
|
||||
quality,
|
||||
)
|
||||
slot.remove_requested.connect(_on_remove_requested)
|
||||
slot.drop_requested.connect(_on_drop_payload)
|
||||
var drop_slot := ShopSaleTraySlot.new()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue