Polish interface artwork and controller behavior

This commit is contained in:
Alexander Sellite 2026-08-19 10:02:28 -04:00
parent c6b897718c
commit f8e02e3844
41 changed files with 1119 additions and 171 deletions

View file

@ -7,7 +7,9 @@ signal context_requested(slot: GeneralInventorySlot)
signal context_changed(slot: GeneralInventorySlot, text: String, active: bool)
const ItemDataType = preload("res://items/item_data.gd")
const LOCK_ICON: Texture2D = preload("res://ui/icons/pictograms/lock_light.png")
const LockedContentPresentationType = preload(
"res://ui/components/locked_content_presentation.gd"
)
var slot_index: int = -1
var container: int = -1
@ -104,8 +106,8 @@ func refresh() -> void:
disabled = _locked
_apply_icon_geometry()
if _locked:
_icon.texture = LOCK_ICON
_icon.modulate = Color(UtilityPageStyle.OCEAN_DISABLED, 0.18)
_icon.texture = LockedContentPresentationType.ICON
_icon.modulate = LockedContentPresentationType.icon_modulate()
var storage_slot := (
container == PlayerInventoryLayout.InventoryContainer.STORAGE
)
@ -305,7 +307,7 @@ func _apply_style() -> void:
Color(UtilityPageStyle.OCEAN_SELECTED, 0.92), radius
)
var locked := UtilityPageStyle.rounded_style(
Color(UtilityPageStyle.OCEAN_FIELD, 0.38), radius
LockedContentPresentationType.disabled_background_color(), radius
)
for state: StringName in [&"normal", &"pressed"]:
add_theme_stylebox_override(state, normal)
@ -332,7 +334,9 @@ func _apply_icon_geometry() -> void:
var is_large: bool = _presentation_size.x >= 70.0
var margin: float
if _locked:
var lock_size: float = 24.0 if is_large else 18.0
var lock_size: float = LockedContentPresentationType.icon_size_for(
_presentation_size
).x
margin = maxf(
(_presentation_size.x - lock_size) * 0.5,
0.0,

View file

@ -0,0 +1,67 @@
class_name LockedContentPresentation
extends RefCounted
const UtilityPageStyleType = preload("res://ui/utility_page_style.gd")
const ICON: Texture2D = preload("res://ui/icons/pictograms/lock_light.png")
const LARGE_ICON_SIZE: float = 24.0
const COMPACT_ICON_SIZE: float = 18.0
const LARGE_PRESENTATION_THRESHOLD: float = 70.0
const ICON_ALPHA: float = 0.18
const BACKGROUND_ALPHA: float = 0.38
static func icon_size_for(presentation_size: Vector2) -> Vector2:
var edge: float = (
LARGE_ICON_SIZE
if minf(presentation_size.x, presentation_size.y)
>= LARGE_PRESENTATION_THRESHOLD
else COMPACT_ICON_SIZE
)
return Vector2(edge, edge)
static func icon_modulate(alpha: float = ICON_ALPHA) -> Color:
return Color(UtilityPageStyleType.OCEAN_DISABLED, alpha)
static func disabled_background_color() -> Color:
return Color(UtilityPageStyleType.OCEAN_FIELD, BACKGROUND_ALPHA)
static func make_icon_texture(
icon_size: int = int(COMPACT_ICON_SIZE),
canvas_size: int = icon_size,
) -> Texture2D:
var source_image: Image = ICON.get_image()
if source_image == null or source_image.is_empty():
return ICON
var image := source_image.duplicate() as Image
if image.is_compressed() and image.decompress() != OK:
return ICON
image.convert(Image.FORMAT_RGBA8)
image.resize(
icon_size,
icon_size,
Image.INTERPOLATE_NEAREST,
)
if canvas_size > icon_size:
var canvas := Image.create(
canvas_size,
canvas_size,
false,
Image.FORMAT_RGBA8,
)
canvas.fill(Color.TRANSPARENT)
var inset := Vector2i.ONE * ((canvas_size - icon_size) / 2)
canvas.blend_rect(
image,
Rect2i(Vector2i.ZERO, Vector2i(icon_size, icon_size)),
inset,
)
image = canvas
var texture := ImageTexture.create_from_image(image)
texture.set_meta(&"locked_content_icon", true)
texture.set_meta(&"locked_content_icon_size", icon_size)
texture.set_meta(&"locked_content_canvas_size", canvas_size)
return texture

View file

@ -0,0 +1 @@
uid://c0188g32tfjk3