Skip to content

Commit

Permalink
Auto-generated digi sprites (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMelbert authored Aug 12, 2024
1 parent 0882b6c commit 7313cf2
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 35 deletions.
6 changes: 4 additions & 2 deletions code/__DEFINES/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ DEFINE_BITFIELD(no_equip_flags, list(
#define CLOTHING_DIGITIGRADE_VARIATION_NO_NEW_ICON (1<<2)
/// When worn by a mob with digitigrade, apply a filter
#define CLOTHING_DIGITIGRADE_FILTER (1<<3)
/// Auto-generates the leg portion of the sprite with GAGS
#define CLOTHING_DIGITIGRADE_MASK (1<<4)

/// Any flag which has a variation for digi
#define DIGITIGRADE_VARIATIONS (CLOTHING_DIGITIGRADE_VARIATION|CLOTHING_DIGITIGRADE_VARIATION_NO_NEW_ICON|CLOTHING_DIGITIGRADE_FILTER)
/// All variation flags which render correctly on a digitigrade leg setup
#define DIGITIGRADE_VARIATIONS (CLOTHING_DIGITIGRADE_VARIATION|CLOTHING_DIGITIGRADE_VARIATION_NO_NEW_ICON|CLOTHING_DIGITIGRADE_FILTER|CLOTHING_DIGITIGRADE_MASK)

//flags for covering body parts
#define GLASSESCOVERSEYES (1<<0)
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ DEFINE_BITFIELD(supports_variations_flags, list(
"CLOTHING_DIGITIGRADE_VARIATION" = CLOTHING_DIGITIGRADE_VARIATION,
"CLOTHING_DIGITIGRADE_VARIATION_NO_NEW_ICON" = CLOTHING_DIGITIGRADE_VARIATION_NO_NEW_ICON,
"CLOTHING_DIGITIGRADE_FILTER" = CLOTHING_DIGITIGRADE_FILTER,
"CLOTHING_DIGITIGRADE_MASK" = CLOTHING_DIGITIGRADE_MASK,
))

DEFINE_BITFIELD(flora_flags, list(
Expand Down
10 changes: 10 additions & 0 deletions code/datums/greyscale/json_configs/_jumpsuit_worn_digi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"": [
{
"type": "icon_state",
"icon_state": "jumpsuit",
"blend_mode": "overlay",
"color_ids": [ 1 ]
}
]
}
8 changes: 4 additions & 4 deletions code/game/objects/structures/mannequin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@
var/datum/sprite_accessory/underwear/underwear = GLOB.underwear_list[underwear_name]
if(underwear)
if(body_type == FEMALE && underwear.gender == MALE)
. += wear_female_version(underwear.icon_state, underwear.icon, BODY_LAYER, FEMALE_UNIFORM_FULL)
. += mutable_appearance(wear_female_version(underwear.icon_state, underwear.icon, FEMALE_UNIFORM_FULL), layer = -BODY_LAYER)
else
. += mutable_appearance(underwear.icon, underwear.icon_state, -BODY_LAYER)
. += mutable_appearance(underwear.icon, underwear.icon_state, layer = -BODY_LAYER)
var/datum/sprite_accessory/undershirt/undershirt = GLOB.undershirt_list[undershirt_name]
if(undershirt)
if(body_type == FEMALE)
. += wear_female_version(undershirt.icon_state, undershirt.icon, BODY_LAYER)
. += mutable_appearance(wear_female_version(undershirt.icon_state, undershirt.icon), layer = -BODY_LAYER)
else
. += mutable_appearance(undershirt.icon, undershirt.icon_state, -BODY_LAYER)
. += mutable_appearance(undershirt.icon, undershirt.icon_state, layer = -BODY_LAYER)
var/datum/sprite_accessory/socks/socks = GLOB.socks_list[socks_name]
if(socks)
. += mutable_appearance(socks.icon, socks.icon_state, -BODY_LAYER)
Expand Down
1 change: 0 additions & 1 deletion code/modules/clothing/under/_under.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
drop_sound = 'sound/items/handling/cloth_drop.ogg'
pickup_sound = 'sound/items/handling/cloth_pickup.ogg'
limb_integrity = 30
supports_variations_flags = CLOTHING_DIGITIGRADE_FILTER
blood_overlay_type = "uniform" // NON-MODULE CHANGE reworking clothing blood overlays

/// Has this undersuit been freshly laundered and, as such, imparts a mood bonus for wearing
Expand Down
6 changes: 3 additions & 3 deletions code/modules/mob/living/carbon/human/_species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ GLOBAL_LIST_EMPTY(features_by_species)
var/mutable_appearance/underwear_overlay
if(underwear)
if(species_human.dna.species.sexes && species_human.physique == FEMALE && (underwear.gender == MALE))
underwear_overlay = wear_female_version(underwear.icon_state, underwear.icon, BODY_LAYER, FEMALE_UNIFORM_FULL)
underwear_overlay = mutable_appearance(wear_female_version(underwear.icon_state, underwear.icon, FEMALE_UNIFORM_FULL), layer = -BODY_LAYER)
else
underwear_overlay = mutable_appearance(underwear.icon, underwear.icon_state, -BODY_LAYER)
if(!underwear.use_static)
Expand All @@ -648,9 +648,9 @@ GLOBAL_LIST_EMPTY(features_by_species)
if(undershirt)
var/mutable_appearance/working_shirt
if(species_human.dna.species.sexes && species_human.physique == FEMALE)
working_shirt = wear_female_version(undershirt.icon_state, undershirt.icon, BODY_LAYER)
working_shirt = mutable_appearance(wear_female_version(undershirt.icon_state, undershirt.icon), layer = -BODY_LAYER)
else
working_shirt = mutable_appearance(undershirt.icon, undershirt.icon_state, -BODY_LAYER)
working_shirt = mutable_appearance(undershirt.icon, undershirt.icon_state, layer = -BODY_LAYER)
standing += working_shirt

if(species_human.socks && species_human.num_legs >= 2 && !(species_human.bodytype & BODYTYPE_DIGITIGRADE))
Expand Down
103 changes: 90 additions & 13 deletions code/modules/mob/living/carbon/human/human_update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,72 @@ There are several things that need to be remembered:
hands += hand_overlay
return hands

/proc/wear_female_version(t_color, icon, layer, type, greyscale_colors)
var/index = "[t_color]-[greyscale_colors]"
var/icon/female_clothing_icon = GLOB.female_clothing_icons[index]
if(!female_clothing_icon) //Create standing/laying icons if they don't exist
generate_female_clothing(index, t_color, icon, type)
return mutable_appearance(GLOB.female_clothing_icons[index], layer = -layer)
/// Modifies a sprite slightly to conform to female body shapes
/proc/wear_female_version(icon_state, icon, type, greyscale_colors)
var/index = "[icon_state]-[greyscale_colors]"
var/static/list/female_clothing_icons = list()
var/icon/female_clothing_icon = female_clothing_icons[index]
if(!female_clothing_icon) //Create standing/laying icons if they don't exist
var/female_icon_state = "female[type == FEMALE_UNIFORM_FULL ? "_full" : ((!type || type & FEMALE_UNIFORM_TOP_ONLY) ? "_top" : "")][type & FEMALE_UNIFORM_NO_BREASTS ? "_no_breasts" : ""]"
var/icon/female_cropping_mask = icon('icons/mob/clothing/under/masking_helpers.dmi', female_icon_state)
female_clothing_icon = icon(icon, icon_state)
female_clothing_icon.Blend(female_cropping_mask, ICON_MULTIPLY)
female_clothing_icon = fcopy_rsc(female_clothing_icon)
female_clothing_icons[index] = female_clothing_icon

return icon(female_clothing_icon)

// These coordonates point to roughly somewhere in the middle of the left leg
// Used in approximating what color the pants of clothing should be
#define LEG_SAMPLE_X_LOWER 13
#define LEG_SAMPLE_X_UPPER 14

#define LEG_SAMPLE_Y_LOWER 8
#define LEG_SAMPLE_Y_UPPER 9

/// Modifies a sprite to conform to digitigrade body shapes
/proc/wear_digi_version(icon/base_icon, key, greyscale_config = /datum/greyscale_config/jumpsuit_worn_digi, greyscale_colors)
ASSERT(key, "wear_digi_version: no key passed")
ASSERT(ispath(greyscale_config, /datum/greyscale_config), "wear_digi_version: greyscale_config is not a valid path (got: [greyscale_config])")
// items with greyscale colors containing multiple colors are invalid
if(isnull(greyscale_colors) || length(SSgreyscale.ParseColorString(greyscale_colors)) > 1)
var/pant_color
// approximates the color of the pants by sampling a few pixels in the middle of the left leg
for(var/x in LEG_SAMPLE_X_LOWER to LEG_SAMPLE_X_UPPER)
for(var/y in LEG_SAMPLE_Y_LOWER to LEG_SAMPLE_Y_UPPER)
var/xy_color = base_icon.GetPixel(x, y)
pant_color = pant_color ? BlendRGB(pant_color, xy_color, 0.5) : xy_color

greyscale_colors = pant_color || "#1d1d1d" // black pants always look good

var/index = "[key]-[greyscale_config]-[greyscale_colors]"
var/static/list/digitigrade_clothing_icons = list()
var/icon/digitigrade_clothing_icon = digitigrade_clothing_icons[index]
if(!digitigrade_clothing_icon)
var/static/icon/torso_mask
if(!torso_mask)
torso_mask = icon('maplestation_modules/icons/mob/clothing/under/digi_mask.dmi', "torso_mask")
var/static/icon/leg_mask
if(!leg_mask)
leg_mask = icon('maplestation_modules/icons/mob/clothing/under/digi_mask.dmi', "leg_mask")

base_icon.Blend(leg_mask, ICON_SUBTRACT) // cuts the legs off

var/icon/leg_icon = SSgreyscale.GetColoredIconByType(greyscale_config, greyscale_colors)
leg_icon.Blend(torso_mask, ICON_SUBTRACT) // cuts the torso off

base_icon.Blend(leg_icon, ICON_OVERLAY) // puts the new legs on

digitigrade_clothing_icon = fcopy_rsc(base_icon)
digitigrade_clothing_icons[index] = digitigrade_clothing_icon

return icon(digitigrade_clothing_icon)

#undef LEG_SAMPLE_X_LOWER
#undef LEG_SAMPLE_X_UPPER

#undef LEG_SAMPLE_Y_LOWER
#undef LEG_SAMPLE_Y_UPPER

/mob/living/carbon/human/proc/get_overlays_copy(list/unwantedLayers)
var/list/out = new
Expand Down Expand Up @@ -658,20 +718,37 @@ generate/load female uniform sprites matching all previously decided variables
override_file = null,
)

// NON-MODULE CHANGE // UPSTREAM ME
//Find a valid icon_state from variables+arguments
var/t_state = override_state || (isinhands ? inhand_icon_state : worn_icon_state) || icon_state
//Find a valid icon file from variables+arguments
var/file2use = override_file || (isinhands ? null : worn_icon) || default_icon_file
//Find a valid layer from variables+arguments
var/layer2use = alternate_worn_layer || default_layer
// NON-MODULE CHANGE END

var/mutable_appearance/standing
var/mob/living/carbon/wearer = loc
var/is_digi = istype(wearer) && (wearer.bodytype & BODYTYPE_DIGITIGRADE) && !wearer.is_digitigrade_squished()

var/mutable_appearance/standing // this is the actual resulting MA
var/icon/building_icon // used to construct an icon across multiple procs before converting it to MA
if(female_uniform)
standing = wear_female_version(t_state, file2use, layer2use, female_uniform, greyscale_colors) //should layer2use be in sync with the adjusted value below? needs testing - shiz
if(!standing)
standing = mutable_appearance(file2use, t_state, -layer2use)
building_icon = wear_female_version(
icon_state = t_state,
icon = file2use,
type = female_uniform,
greyscale_colors = greyscale_colors,
)
if(!isinhands && is_digi && (supports_variations_flags & CLOTHING_DIGITIGRADE_MASK))
building_icon = wear_digi_version(
base_icon = building_icon || icon(file2use, t_state),
key = "[t_state]-[file2use]-[female_uniform]",
greyscale_config = digitigrade_greyscale_config_worn || greyscale_config_worn,
greyscale_colors = digitigrade_greyscale_colors || greyscale_colors || color,
)
if(building_icon)
standing = mutable_appearance(building_icon, layer = -layer2use)

// no special handling done, default it
standing ||= mutable_appearance(file2use, t_state, layer = -layer2use)

//Get the overlays for this item when it's being worn
//eg: ammo counters, primed grenade flashes, etc.
Expand All @@ -681,7 +758,7 @@ generate/load female uniform sprites matching all previously decided variables

standing = center_image(standing, isinhands ? inhand_x_dimension : worn_x_dimension, isinhands ? inhand_y_dimension : worn_y_dimension)

if(!isinhands && (supports_variations_flags & CLOTHING_DIGITIGRADE_FILTER))
if(!isinhands && is_digi && (supports_variations_flags & CLOTHING_DIGITIGRADE_FILTER))
apply_digitigrade_filters(standing)

//Worn offsets
Expand Down
16 changes: 14 additions & 2 deletions code/modules/surgery/bodyparts/species_parts/lizard_bodyparts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@

/obj/item/bodypart/leg/left/digitigrade/update_limb(dropping_limb = FALSE, is_creating = FALSE)
. = ..()
limb_id = owner.is_digitigrade_squished() ? SPECIES_LIZARD : BODYPART_ID_DIGITIGRADE
var/old_id = limb_id
limb_id = owner?.is_digitigrade_squished() ? SPECIES_LIZARD : BODYPART_ID_DIGITIGRADE
if(old_id != limb_id)
// Something unsquished / squished us so we need to go through and update everything that is affected
for(var/obj/item/thing as anything in owner?.get_equipped_items())
if(thing.supports_variations_flags & DIGITIGRADE_VARIATIONS)
thing.update_slot_icon()

/obj/item/bodypart/leg/right/digitigrade
icon_greyscale = 'icons/mob/human/species/lizard/bodyparts.dmi'
Expand All @@ -80,4 +86,10 @@

/obj/item/bodypart/leg/right/digitigrade/update_limb(dropping_limb = FALSE, is_creating = FALSE)
. = ..()
limb_id = owner.is_digitigrade_squished() ? SPECIES_LIZARD : BODYPART_ID_DIGITIGRADE
var/old_id = limb_id
limb_id = owner?.is_digitigrade_squished() ? SPECIES_LIZARD : BODYPART_ID_DIGITIGRADE
if(old_id != limb_id)
// Something unsquished / squished us so we need to go through and update everything that is affected
for(var/obj/item/thing as anything in owner?.get_equipped_items())
if(thing.supports_variations_flags & DIGITIGRADE_VARIATIONS)
thing.update_slot_icon()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 5 additions & 10 deletions maplestation_modules/code/datums/greyscale/_greyscale_config.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@
/datum/greyscale_config/tablet/stripe_two_color
json_config = 'code/datums/greyscale/json_configs/_pda_stripe_two_color.json'

// /datum/greyscale_config/jumpsuit_worn_digi
// name = "Digitigrate Jumpsuit Worn"
// icon_file = 'maplestation_modules/icons/mob/clothing/under/digi_under.dmi'
// json_config = 'code/datums/greyscale/json_configs/jumpsuit_worn.json'

// /datum/greyscale_config/jumpsuit_prison_worn_digi
// name = "Digitigrade Prison Jumpsuit Worn"
// icon_file = 'maplestation_modules/icons/mob/clothing/under/digi_under.dmi'
// json_config = 'code/datums/greyscale/json_configs/jumpsuit_prison_worn.json'
/datum/greyscale_config/jumpsuit_worn_digi
name = "Digitigrate Jumpsuit Worn"
icon_file = 'maplestation_modules/icons/mob/clothing/under/digi_gags.dmi'
json_config = 'code/datums/greyscale/json_configs/_jumpsuit_worn_digi.json'

/datum/greyscale_config/heels
name = "Heels"
Expand All @@ -47,7 +42,7 @@

/datum/greyscale_config/spacer_turtleneck
name = "Spacer's Turtleneck"
icon_file = 'maplestation_modules/icons/mob/clothing/under/spacer_turtleneck.dmi'
icon_file = 'maplestation_modules/icons/obj/clothing/under/spacer_turtleneck.dmi'
json_config = 'code/datums/greyscale/json_configs/spacer_turtleneck.json'

/datum/greyscale_config/spacer_turtleneck_worn
Expand Down
2 changes: 2 additions & 0 deletions maplestation_modules/code/modules/clothing/digi_clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
var/digitigrade_file
/// Greyscale config for this worn on digi lizards
var/digitigrade_greyscale_config_worn
/// Greyscale colors for this worn on digi lizards
var/digitigrade_greyscale_colors
16 changes: 16 additions & 0 deletions maplestation_modules/code/modules/clothing/under/digi_under.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
// Don't ask my why I tested these
/obj/item/clothing/under
supports_variations_flags = CLOTHING_DIGITIGRADE_MASK
digitigrade_greyscale_config_worn = /datum/greyscale_config/jumpsuit_worn_digi

/obj/item/clothing/under/rank/civilian/janitor/maid
supports_variations_flags = CLOTHING_DIGITIGRADE_VARIATION_NO_NEW_ICON

/obj/item/clothing/under/costume/maid
supports_variations_flags = CLOTHING_DIGITIGRADE_FILTER

/obj/item/clothing/under/rank/engineering/engineer
digitigrade_greyscale_colors = "#DEB63E"

/obj/item/clothing/under/misc/psyche
digitigrade_greyscale_colors = "#3f3f3f"

/obj/item/clothing/under/color/rainbow
digitigrade_greyscale_colors = "#3f3f3f"

/obj/item/clothing/under/spacer_turtleneck
digitigrade_greyscale_colors = "#5e483c"
Binary file not shown.
Binary file not shown.

0 comments on commit 7313cf2

Please sign in to comment.