Add reusable UI components for Phase 7 UI Polish
- Introduced `EmojiQuickGrid`, `FontPresetPicker`, and `PresetSizeToggle` classes for emoji selection, font presets, and size toggles respectively. - Implemented configuration methods for each component to handle dynamic content and theming. - Created tests for the new components to ensure functionality and integration with the existing UI. - Added a comprehensive architecture specification for Phase 7 UI Polish detailing scope, implementation, and validation strategies. - Updated existing theme handling to support new UI elements and ensure consistent styling across the application.
This commit is contained in:
@@ -4,6 +4,27 @@ extends RefCounted
|
||||
const STICKMEN_DIR := "user://thumbnails/stickmen"
|
||||
const PROP_DIR := "user://thumbnails/props"
|
||||
const PROP_VERSION := 1
|
||||
var _memory: Dictionary = {}
|
||||
|
||||
func get_texture(cache_path: String) -> Texture2D:
|
||||
if _memory.has(cache_path):
|
||||
return _memory[cache_path] as Texture2D
|
||||
var texture: Texture2D = load_png(cache_path)
|
||||
if texture != null:
|
||||
_memory[cache_path] = texture
|
||||
return texture
|
||||
|
||||
func store_texture(cache_path: String, texture: Texture2D) -> Error:
|
||||
if texture == null:
|
||||
return ERR_INVALID_PARAMETER
|
||||
_memory[cache_path] = texture
|
||||
return save_png(texture, cache_path)
|
||||
|
||||
func forget_memory(cache_path: String) -> void:
|
||||
_memory.erase(cache_path)
|
||||
|
||||
func clear_memory() -> void:
|
||||
_memory.clear()
|
||||
|
||||
|
||||
func stickman_key(path: String) -> String:
|
||||
@@ -19,12 +40,16 @@ func prop_png(id: String) -> String:
|
||||
|
||||
|
||||
func load_png(png_path: String) -> Texture2D:
|
||||
if _memory.has(png_path):
|
||||
return _memory[png_path] as Texture2D
|
||||
if not FileAccess.file_exists(png_path):
|
||||
return null
|
||||
var img := Image.load_from_file(png_path)
|
||||
if img == null:
|
||||
return null
|
||||
return ImageTexture.create_from_image(img)
|
||||
var texture: Texture2D = ImageTexture.create_from_image(img)
|
||||
_memory[png_path] = texture
|
||||
return texture
|
||||
|
||||
|
||||
func save_png(tex: Texture2D, png_path: String) -> Error:
|
||||
@@ -34,6 +59,7 @@ func save_png(tex: Texture2D, png_path: String) -> Error:
|
||||
if img == null:
|
||||
return ERR_CANT_CREATE
|
||||
ensure_dir(png_path.get_base_dir())
|
||||
_memory[png_path] = tex
|
||||
return img.save_png(png_path)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user