Add modular character customization
This commit is contained in:
parent
70d6205ec1
commit
2bcb4a3c93
34 changed files with 761 additions and 76 deletions
|
|
@ -12,8 +12,8 @@ const CATEGORY_IDS: PackedStringArray = [
|
|||
]
|
||||
|
||||
const CATEGORY_LABELS: Dictionary = {
|
||||
"species": "species",
|
||||
"fur_pattern": "fur pattern",
|
||||
"species": "head",
|
||||
"fur_pattern": "fur color",
|
||||
"ears": "ears",
|
||||
"eyes": "eyes",
|
||||
"nose": "nose",
|
||||
|
|
@ -22,24 +22,59 @@ const CATEGORY_LABELS: Dictionary = {
|
|||
}
|
||||
|
||||
const OPTIONS: Dictionary = {
|
||||
"species": [{"id": "default", "label": "default"}],
|
||||
"fur_pattern": [{"id": "solid", "label": "solid"}],
|
||||
"ears": [{"id": "default", "label": "default"}],
|
||||
"eyes": [{"id": "default", "label": "default"}],
|
||||
"nose": [{"id": "default", "label": "default"}],
|
||||
"mouth": [{"id": "default", "label": "default"}],
|
||||
"species": [
|
||||
{"id": "round", "label": "round"},
|
||||
{"id": "pointy", "label": "pointy"},
|
||||
],
|
||||
# The serialized field remains `fur_pattern` for save and network
|
||||
# compatibility. It holds the initial solid fur-color selection until the
|
||||
# authored pattern layer is ready.
|
||||
"fur_pattern": [
|
||||
{"id": "white", "label": "white", "color": Color("f2f0e8")},
|
||||
{"id": "gray", "label": "gray", "color": Color("819398")},
|
||||
{"id": "charcoal", "label": "charcoal", "color": Color("34444a")},
|
||||
{"id": "brown", "label": "brown", "color": Color("7b4a32")},
|
||||
{"id": "orange", "label": "orange", "color": Color("c86c36")},
|
||||
{"id": "yellow", "label": "yellow", "color": Color("d8c545")},
|
||||
{"id": "green", "label": "green", "color": Color("6f913c")},
|
||||
{"id": "teal", "label": "teal", "color": Color("3a8790")},
|
||||
],
|
||||
"ears": [
|
||||
{"id": "none", "label": "none"},
|
||||
{"id": "pointy_long", "label": "long"},
|
||||
{"id": "pointy_short", "label": "short"},
|
||||
{"id": "pointy_wide", "label": "wide"},
|
||||
],
|
||||
"eyes": [
|
||||
{"id": "simple_shine", "label": "simple shine"},
|
||||
{
|
||||
"id": "simple_shine_eyebrows",
|
||||
"label": "simple shine + eyebrows",
|
||||
},
|
||||
],
|
||||
"nose": [{"id": "dog_round", "label": "round"}],
|
||||
"mouth": [{"id": "three", "label": "three"}],
|
||||
"tail": [{"id": "none", "label": "none"}],
|
||||
}
|
||||
|
||||
const LEGACY_OPTION_ALIASES: Dictionary = {
|
||||
"species": {"default": "round"},
|
||||
"fur_pattern": {"solid": "white"},
|
||||
"ears": {"default": "none"},
|
||||
"eyes": {"default": "simple_shine"},
|
||||
"nose": {"default": "dog_round"},
|
||||
"mouth": {"default": "three"},
|
||||
}
|
||||
|
||||
|
||||
static func default_snapshot() -> Dictionary:
|
||||
return {
|
||||
"species": "default",
|
||||
"fur_pattern": "solid",
|
||||
"ears": "default",
|
||||
"eyes": "default",
|
||||
"nose": "default",
|
||||
"mouth": "default",
|
||||
"species": "round",
|
||||
"fur_pattern": "white",
|
||||
"ears": "none",
|
||||
"eyes": "simple_shine",
|
||||
"nose": "dog_round",
|
||||
"mouth": "three",
|
||||
"tail": "none",
|
||||
}
|
||||
|
||||
|
|
@ -53,12 +88,26 @@ static func category_label(category_id: String) -> String:
|
|||
|
||||
|
||||
static func is_valid_option(category_id: String, option_id: String) -> bool:
|
||||
option_id = canonical_option_id(category_id, option_id)
|
||||
for option: Dictionary in options_for(category_id):
|
||||
if str(option.get("id", "")) == option_id:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
static func canonical_option_id(category_id: String, option_id: String) -> String:
|
||||
var aliases: Dictionary = LEGACY_OPTION_ALIASES.get(category_id, {})
|
||||
return str(aliases.get(option_id, option_id))
|
||||
|
||||
|
||||
static func option_color(category_id: String, option_id: String) -> Color:
|
||||
var canonical_id: String = canonical_option_id(category_id, option_id)
|
||||
for option: Dictionary in options_for(category_id):
|
||||
if str(option.get("id", "")) == canonical_id:
|
||||
return option.get("color", Color.WHITE) as Color
|
||||
return Color.WHITE
|
||||
|
||||
|
||||
static func validate_snapshot(value: Variant) -> bool:
|
||||
if typeof(value) != TYPE_DICTIONARY:
|
||||
return false
|
||||
|
|
@ -80,7 +129,9 @@ static func sanitized_snapshot(value: Variant) -> Dictionary:
|
|||
return result
|
||||
var snapshot: Dictionary = value
|
||||
for category_id: String in CATEGORY_IDS:
|
||||
var option_id := str(snapshot.get(category_id, ""))
|
||||
var option_id: String = canonical_option_id(
|
||||
category_id, str(snapshot.get(category_id, ""))
|
||||
)
|
||||
if is_valid_option(category_id, option_id):
|
||||
result[category_id] = option_id
|
||||
return result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue