Skip to content

Commit

Permalink
adds support for arbitrary amounts of color zones on mutant overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
dwasint committed Sep 21, 2024
1 parent bd4a48e commit d7f1049
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 120 deletions.
4 changes: 4 additions & 0 deletions code/datums/bodypart_overlays/bodypart_overlay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
var/datum/color_palette/palette
///our palette key
var/palette_key
///our fallback key
var/fallback_key
///list of palette keys to colors used if the accessory says it needs multiple colors
var/list/color_keys

///Wrapper for getting the proper image, colored and everything
/datum/bodypart_overlay/proc/get_overlay(layer, obj/item/bodypart/limb)
Expand Down
31 changes: 1 addition & 30 deletions code/datums/bodypart_overlays/mutant_bodypart_overlay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
///Take on the dna/preference from whoever we're gonna be inserted in
var/imprint_on_next_insertion = TRUE

/datum/bodypart_overlay/mutant/get_overlay(layer, obj/item/bodypart/limb)
inherit_color(limb) // If draw_color is not set yet, go ahead and do that
return ..()

///Completely random image and color generation (obeys what a player can choose from)
/datum/bodypart_overlay/mutant/proc/randomize_appearance()
randomize_sprite()
Expand Down Expand Up @@ -53,27 +49,6 @@
/datum/bodypart_overlay/mutant/proc/get_base_icon_state()
return sprite_datum.icon_state

///Get the image we need to draw on the person. Called from get_overlay() which is called from _bodyparts.dm. Limb can be null
/datum/bodypart_overlay/mutant/get_image(image_layer, obj/item/bodypart/limb)
if(!sprite_datum)
CRASH("Trying to call get_image() on [type] while it didn't have a sprite_datum. This shouldn't happen, report it as soon as possible.")

var/gender = (limb?.limb_gender == FEMALE) ? "f" : "m"
var/list/icon_state_builder = list()
icon_state_builder += sprite_datum.gender_specific ? gender : "m" //Male is default because sprite accessories are so ancient they predate the concept of not hardcoding gender
icon_state_builder += feature_key
icon_state_builder += get_base_icon_state()
icon_state_builder += mutant_bodyparts_layertext(image_layer)

var/finished_icon_state = icon_state_builder.Join("_")

var/mutable_appearance/appearance = mutable_appearance(sprite_datum.icon, finished_icon_state, layer = image_layer)

if(sprite_datum.center)
center_image(appearance, sprite_datum.dimension_x, sprite_datum.dimension_y)

return appearance

///Get the image we need to draw on the person. Called from get_overlay() which is called from _bodyparts.dm. Limb can be null
/datum/bodypart_overlay/mutant/get_image_inner(image_layer, obj/item/bodypart/limb)
if(!sprite_datum)
Expand All @@ -98,10 +73,6 @@

return appearance

/datum/bodypart_overlay/mutant/color_image(image/overlay, layer, obj/item/bodypart/limb)

overlay.color = sprite_datum.color_src ? draw_color : null

/datum/bodypart_overlay/mutant/added_to_limb(obj/item/bodypart/limb)
inherit_color(limb)

Expand Down Expand Up @@ -138,7 +109,7 @@

if(palette)
var/datum/color_palette/located = ownerlimb.owner.dna.color_palettes[palette]
draw_color = located.return_color(palette_key)
draw_color = located.return_color(palette_key, fallback_key)
else
switch(color_source)
if(ORGAN_COLOR_OVERRIDE)
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/dead/new_player/sprite_accessories.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
var/datum/color_palette/palette
var/palette_key
var/fallback_key
var/list/layers

/datum/sprite_accessory/blank
name = "None"
Expand Down Expand Up @@ -1897,7 +1898,7 @@ MONKESTATION EDIT
icon_state = "cat"
hasinner = TRUE
palette = /datum/color_palette/generic_colors
palette_key = "hair_color"
palette_key = HAIR_COLOR

/datum/sprite_accessory/ears/fox
icon = 'icons/mob/species/human/fox_features.dmi'
Expand Down
Binary file modified monkestation/code/modules/the_bird_inside_of_me/icons/armwings.dmi
Binary file not shown.
7 changes: 2 additions & 5 deletions monkestation/code/modules/the_bird_inside_of_me/plummage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@
layers = EXTERNAL_FRONT
color_source = ORGAN_COLOR_OVERRIDE
palette = /datum/color_palette/ornithids

/datum/bodypart_overlay/mutant/plumage/inherit_color(obj/item/bodypart/ownerlimb, force)
var/datum/color_palette/located = ownerlimb?.owner?.dna?.color_palettes[palette]
draw_color = located?.return_color("feather_main") || "#FFFFFF"
return TRUE
palette_key = "plummage"
fallback_key = "feather_main"

/datum/bodypart_overlay/mutant/plumage/get_global_feature_list()
return GLOB.avian_ears_list
Expand Down
29 changes: 25 additions & 4 deletions monkestation/code/modules/the_bird_inside_of_me/prefs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

/datum/preference/choiced/ornithid_wings/compile_constant_data()
var/list/data = ..()
data[SUPPLEMENTAL_FEATURE_KEY] = "feather_color"
data[SUPPLEMENTAL_FEATURE_KEY] = list("feather_color", "feather_color_secondary", "feather_color_tri")
return data

/datum/preference/color/feather_color
Expand All @@ -78,9 +78,6 @@
category = PREFERENCE_CATEGORY_SUPPLEMENTAL_FEATURES
relevant_inherent_trait = TRAIT_FEATHERED

/datum/preference/color/feather_color/apply_to_human(mob/living/carbon/human/target, value)
target.dna.features["feathers"] = value

/datum/preference/color/feather_color_secondary
savefile_key = "feather_color_secondary"
savefile_identifier = PREFERENCE_CHARACTER
Expand All @@ -89,6 +86,30 @@
allows_nulls = TRUE
default_null = TRUE

/datum/preference/color/feather_color_tri
savefile_key = "feather_color_tri"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_SUPPLEMENTAL_FEATURES
relevant_inherent_trait = TRAIT_FEATHERED
allows_nulls = TRUE
default_null = TRUE

/datum/preference/color/plummage_color
savefile_key = "plummage_color"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_SUPPLEMENTAL_FEATURES
relevant_inherent_trait = TRAIT_FEATHERED
allows_nulls = TRUE
default_null = TRUE

/datum/preference/color/feather_tail_color
savefile_key = "feather_tail_color"
savefile_identifier = PREFERENCE_CHARACTER
category = PREFERENCE_CATEGORY_SUPPLEMENTAL_FEATURES
relevant_inherent_trait = TRAIT_FEATHERED
allows_nulls = TRUE
default_null = TRUE

#define X_TAIL_CROP 16
#define Y_TAIL_CROP 5

Expand Down
8 changes: 2 additions & 6 deletions monkestation/code/modules/the_bird_inside_of_me/tails.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@
layers = EXTERNAL_BEHIND | EXTERNAL_FRONT
color_source = ORGAN_COLOR_OVERRIDE
palette = /datum/color_palette/ornithids
palette_key = "tail"
fallback_key = "feather_main"

/datum/bodypart_overlay/mutant/tail/avian/get_global_feature_list()
return GLOB.tails_list_avian

/datum/bodypart_overlay/mutant/tail/avian/inherit_color(obj/item/bodypart/ownerlimb, force)
var/datum/color_palette/located = ownerlimb?.owner?.dna?.color_palettes[palette]
draw_color = located?.return_color("feather_secondary", "feather_main") || "#FFFFFF"
return TRUE


/datum/sprite_accessory/tails/avian
icon = 'monkestation/code/modules/the_bird_inside_of_me/icons/ornithidfeatures.dmi'

Expand Down
16 changes: 11 additions & 5 deletions monkestation/code/modules/the_bird_inside_of_me/wings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
name = "Fluffy"
icon_state = "fluffy"

/datum/sprite_accessory/arm_wings/tri_colored
name = "Tri-Colored Wings"
icon_state = "triple"
//layers = list("first" = "feather_main", "second" = "feather_secondary", "third" = "feather_tri")

/datum/sprite_accessory/arm_wings/pursuant
name = "Pursuant"
icon_state = "pursuant"
Expand All @@ -69,6 +74,11 @@
name = "Fluffy"
icon_state = "fluffy"

/datum/sprite_accessory/arm_wingsopen/tri_colored
name = "Tri-Colored Wings"
icon_state = "triple"
layers = list("first" = "feather_main", "second" = "feather_secondary", "third" = "feather_tri")

/datum/bodypart_overlay/mutant/wings/functional/arm_wings
feature_key = "arm_wings"
layers = EXTERNAL_BEHIND | EXTERNAL_ADJACENT | EXTERNAL_FRONT
Expand All @@ -77,11 +87,7 @@
///Feature render key for opened arm wings
open_feature_key = "arm_wingsopen"
palette = /datum/color_palette/ornithids

/datum/bodypart_overlay/mutant/wings/functional/arm_wings/inherit_color(obj/item/bodypart/ownerlimb, force) // overriding inherit_color directly because "override_color" for some unspeakable reason gets passed fuck all
var/datum/color_palette/located = ownerlimb?.owner?.dna?.color_palettes[palette]
draw_color = located?.return_color("feather_main") || "#FFFFFF"
return TRUE
palette_key = "feather_main"

/datum/bodypart_overlay/mutant/wings/functional/arm_wings/get_global_feature_list()
if(wings_open)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/datum/bodypart_overlay/mutant/get_overlay(layer, obj/item/bodypart/limb)
inherit_color(limb)
layer = bitflag_to_layer(layer)
if(sprite_datum.layers)
var/mutable_appearance/MA = mutable_appearance(layer = layer)
for(var/state in sprite_datum.layers)
var/mutable_appearance/returned = get_image(layer, limb, state)
color_image(returned, layer, limb, sprite_datum.layers[state])
MA.overlays += returned
return MA
else
. = get_image(layer, limb)
color_image(., layer, limb)

///Get the image we need to draw on the person. Called from get_overlay() which is called from _bodyparts.dm. Limb can be null
/datum/bodypart_overlay/mutant/get_image(image_layer, obj/item/bodypart/limb, layer_name)
if(!sprite_datum)
CRASH("Trying to call get_image() on [type] while it didn't have a sprite_datum. This shouldn't happen, report it as soon as possible.")

var/gender = (limb?.limb_gender == FEMALE) ? "f" : "m"
var/list/icon_state_builder = list()
icon_state_builder += sprite_datum.gender_specific ? gender : "m" //Male is default because sprite accessories are so ancient they predate the concept of not hardcoding gender
if(layer_name)
icon_state_builder += layer_name
icon_state_builder += feature_key
icon_state_builder += get_base_icon_state()
icon_state_builder += mutant_bodyparts_layertext(image_layer)

var/finished_icon_state = icon_state_builder.Join("_")

var/mutable_appearance/appearance = mutable_appearance(sprite_datum.icon, finished_icon_state, layer = image_layer)

if(sprite_datum.center)
center_image(appearance, sprite_datum.dimension_x, sprite_datum.dimension_y)

return appearance

/datum/bodypart_overlay/mutant/color_image(image/overlay, layer, obj/item/bodypart/limb, key_name)
if(!key_name)
overlay.color = sprite_datum.color_src ? draw_color : null
else
var/datum/color_palette/located = limb?.owner?.dna?.color_palettes[palette]
overlay.color = located.return_color(key_name, fallback_key)
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
/datum/color_palette/generic_colors
var/hair_color
var/facial_hair_color

var/hair_gradient_color
var/facial_hair_gradient_color

//this is temporary until we move everything over to per species coloring
var/mutant_color
var/mutant_color_secondary
var/fur_color

/datum/color_palette/generic_colors/apply_prefs(datum/preferences/incoming)
hair_color = incoming.read_preference(/datum/preference/color/hair_color)
facial_hair_color = incoming.read_preference(/datum/preference/color/facial_hair_color)

facial_hair_gradient_color = incoming.read_preference(/datum/preference/color/facial_hair_gradient)
hair_gradient_color = incoming.read_preference(/datum/preference/color/hair_gradient)

mutant_color = incoming.read_preference(/datum/preference/color/mutant_color)
mutant_color_secondary = incoming.read_preference(/datum/preference/color/mutant_color_secondary)

fur_color = incoming.read_preference(/datum/preference/color/fur_color)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
var/feather_secondary
var/feather_tri

var/tail
var/plummage

/datum/color_palette/ornithids/apply_prefs(datum/preferences/incoming)
feather_main = incoming.read_preference(/datum/preference/color/feather_color)
feather_secondary = incoming.read_preference(/datum/preference/color/feather_color_secondary)
feather_tri = incoming.read_preference(/datum/preferences/color/feather_color_tri)

Check failure on line 14 in monkestation/code/modules/the_fabled_dna_changes/species_color_pallettes/ornithids.dm

View workflow job for this annotation

GitHub Actions / Run Linters

failed to resolve path /datum/preferences/color/feather_color_tri

Check failure on line 14 in monkestation/code/modules/the_fabled_dna_changes/species_color_pallettes/ornithids.dm

View workflow job for this annotation

GitHub Actions / Run Linters

OD0404: Type /datum/preferences/color/feather_color_tri does not exist
plummage = incoming.read_preference(/datum/preference/color/plummage_color)
tail = incoming.read_preference(/datum/preference/color/feather_tail_color)

1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -7922,6 +7922,7 @@
#include "monkestation\code\modules\the_bird_inside_of_me\tails.dm"
#include "monkestation\code\modules\the_bird_inside_of_me\wings.dm"
#include "monkestation\code\modules\the_fabled_dna_changes\dna.dm"
#include "monkestation\code\modules\the_fabled_dna_changes\multi_colored_bodyoverlay.dm"
#include "monkestation\code\modules\the_fabled_dna_changes\species_color_pallettes\_color_pallette.dm"
#include "monkestation\code\modules\the_fabled_dna_changes\species_color_pallettes\generic_palette.dm"
#include "monkestation\code\modules\the_fabled_dna_changes\species_color_pallettes\ornithids.dm"
Expand Down
Loading

0 comments on commit d7f1049

Please sign in to comment.