Skip to content

Commit

Permalink
Update Guns Lineart and Autowiki Handling of Base Types (#5729)
Browse files Browse the repository at this point in the history
# About the pull request

This PR is a follow up to #5631 and does several things related to gun
icons:
- Autowiki now skips mags and guns with no icon_staste set (I did the
same for attachments, but none are in this scenario)
- Gun lineart now has the no_name sprite as the first sprite so it is
used again as the default sprite when no lineart exists
- Various gun linearts have been duplicated for sub types that are
basically the same icon.
- The testing for missing linearts has been fixed to check icon_state
instead of base_gun_icon because only a couple guns even assigned
base_gun_icon before Initialize
- The testing for missing linearts now skips `GUN_UNUSUAL_DESIGN` since
they can't be inspected
- The unit_test for spritesheets now enforces css requirements. See
https://www.w3.org/TR/CSS2/syndata.html#value-def-identifier
- The 88m4 has been renamed to _88m4 to comply with css requirements.
- Removed the two cases where a base_gun_icon was set in the definition
(that would just get reset in Initialize)
- Since many guns are now missing sprites in the missing lineart test,
the testing error is downgraded to only a debug log until they can all
have an exception set or the icons set. Currently all the missing
sprites are below:

<details>
<summary>Missing Sprites in
icons/obj/items/weapons/guns/lineart.dmi</summary>

- /obj/item/weapon/gun/pistol/np92, icon_state="np92"
- /obj/item/weapon/gun/pistol/np92/suppressed, icon_state="npz92"
- /obj/item/weapon/gun/pistol/np92/suppressed/tranq, icon_state="npz92"
- /obj/item/weapon/gun/pistol/t73, icon_state="tt"
- /obj/item/weapon/gun/pistol/t73/leader, icon_state="ttb"
- /obj/item/weapon/gun/pistol/clfpistol, icon_state="m43"
- /obj/item/weapon/gun/pistol/es4, icon_state="es4"
- /obj/item/weapon/gun/energy/rxfm5_eva, icon_state="rxfm5_eva"
- /obj/item/weapon/gun/launcher/rocket/anti_tank, icon_state="m83a2"
- /obj/item/weapon/gun/launcher/rocket/anti_tank/disposable,
icon_state="m83a2"
- /obj/item/weapon/gun/launcher/rocket/upp, icon_state="hjra12"
- /obj/item/weapon/gun/rifle/m41a/elite/xm40, icon_state="m40sd"
- /obj/item/weapon/gun/rifle/m41a/elite/xm40/ap, icon_state="m40sd"
- /obj/item/weapon/gun/rifle/nsg23, icon_state="nsg23"
- /obj/item/weapon/gun/rifle/nsg23/stripped, icon_state="nsg23"
- /obj/item/weapon/gun/rifle/nsg23/no_lock, icon_state="nsg23"
- /obj/item/weapon/gun/rifle/nsg23/no_lock/stripped, icon_state="nsg23"
- /obj/item/weapon/gun/rifle/mar40/lmg, icon_state="mar50"
- /obj/item/weapon/gun/rifle/mar40/lmg/tactical, icon_state="mar50"
- /obj/item/weapon/gun/rifle/xm177, icon_state="xm177"
- /obj/item/weapon/gun/rifle/xm177/dutch, icon_state="xm177"
- /obj/item/weapon/gun/rifle/ar10, icon_state="ar10"
- /obj/item/weapon/gun/rifle/m4ra, icon_state="m4ra"
- /obj/item/weapon/gun/rifle/m4ra/training, icon_state="m4ra"
- /obj/item/weapon/gun/rifle/l42a/abr40, icon_state="abr40"
- /obj/item/weapon/gun/rifle/l42a/abr40/tactical, icon_state="abr40_tac"
- /obj/item/weapon/gun/rifle/rmc_f90, icon_state="aug"
- /obj/item/weapon/gun/rifle/rmc_f90/a_grip, icon_state="aug_com"
- /obj/item/weapon/gun/rifle/rmc_f90/scope, icon_state="aug_dmr"
- /obj/item/weapon/gun/rifle/rmc_f90/shotgun, icon_state="aug_mkey"
- /obj/item/weapon/gun/rifle/m4ra_custom, icon_state="m4ra_custom"
- /obj/item/weapon/gun/rifle/sniper/XM43E1, icon_state="xm43e1"
- /obj/item/weapon/gun/rifle/sniper/svd, icon_state="type88"
- /obj/item/weapon/gun/boltaction, icon_state="boltaction"
- /obj/item/weapon/gun/boltaction/vulture, icon_state="vulture"
- /obj/item/weapon/gun/boltaction/vulture/skillless,
icon_state="vulture"
- /obj/item/weapon/gun/lever_action, icon_state="r4t-placeholder"
- /obj/item/weapon/gun/lever_action/r4t, icon_state="r4t"
- /obj/item/weapon/gun/lever_action/xm88, icon_state="boomslang"
- /obj/item/weapon/gun/pkp, icon_state="qjy72"
- /obj/item/weapon/gun/revolver/m44/custom/pkd_special,
icon_state="lapd_2019"
- /obj/item/weapon/gun/revolver/m44/custom/pkd_special/k2049,
icon_state="lapd_2049"
- /obj/item/weapon/gun/revolver/m44/custom/pkd_special/l_series,
icon_state="pkd_double"
- /obj/item/weapon/gun/revolver/m44/custom/webley, icon_state="webley"
- /obj/item/weapon/gun/revolver/upp, icon_state="zhnk72"
- /obj/item/weapon/gun/revolver/upp/shrapnel, icon_state="zhnk72"
- /obj/item/weapon/gun/shotgun/combat/riot, icon_state="mp220"
- /obj/item/weapon/gun/shotgun/combat/guard, icon_state="mp221"
- /obj/item/weapon/gun/shotgun/combat/marsoc, icon_state="mk210"
- /obj/item/weapon/gun/shotgun/type23, icon_state="type23"
- /obj/item/weapon/gun/shotgun/type23/breacher, icon_state="type23"
- /obj/item/weapon/gun/shotgun/type23/breacher/slug, icon_state="type23"
- /obj/item/weapon/gun/shotgun/type23/breacher/flechette,
icon_state="type23"
- /obj/item/weapon/gun/shotgun/type23/dual, icon_state="type23"
- /obj/item/weapon/gun/shotgun/type23/dragon, icon_state="type23"
- /obj/item/weapon/gun/shotgun/type23/riot_control, icon_state="type23"
- /obj/item/weapon/gun/shotgun/double/twobore, icon_state="twobore"
- /obj/item/weapon/gun/smartgun/rmc, icon_state="magsg"
- /obj/item/weapon/gun/smg/pps43, icon_state="insasu"
- /obj/item/weapon/gun/smg/pps43/extended_mag, icon_state="insasu"
- /obj/item/weapon/gun/smg/bizon, icon_state="type64"
- /obj/item/weapon/gun/smg/bizon/upp, icon_state="type64_u"
- /obj/item/weapon/gun/smg/uzi, icon_state="uzi"
- /obj/item/weapon/gun/smg/nailgun, icon_state="nailgun"
- /obj/item/weapon/gun/smg/nailgun/compact, icon_state="cnailgun"

</details>

# Explain why it's good for the game

Now the 88m4 pistol doesn't show up as the default icon, and instead is
the no_name icon:

![image](https://github.com/cmss13-devs/cmss13/assets/76988376/6d02f72b-4a29-48d6-900a-8b7109cd5057)

Now spritesheet states that can't be displayed (such as the 88m4 because
it starts with a digit) will fail unit tests:

![image](https://github.com/cmss13-devs/cmss13/assets/76988376/180d5834-d873-46b4-9cb8-e4c0ac03d033)
but I ensured the rename to _88m4 still works correctly even with the
empty state:

![image](https://github.com/cmss13-devs/cmss13/assets/76988376/0b788b37-e993-4c25-af3a-f4f7778034ac)


# Testing Photographs and Procedure
See above.

All "new" sprites are duplicates of existing.


# Changelog
:cl: Drathek
code: Autowiki now skips guns and mags without icon_states
code: Unit testing for spritesheets now enforces css requirements for
class names
imageadd: Gun stats lineart now uses the no_name sprite again for guns
without lineart
/:cl:
  • Loading branch information
Drulikar committed Feb 19, 2024
1 parent a3babc1 commit efc4e0a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
11 changes: 9 additions & 2 deletions code/modules/asset_cache/asset_list_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,16 @@
InsertAll("", icon_file)

for(var/obj/item/weapon/gun/current_gun as anything in subtypesof(/obj/item/weapon/gun))
var/icon_state = initial(current_gun.base_gun_icon)
if(isnull(initial(current_gun.icon_state)))
continue
if(initial(current_gun.flags_gun_features) & GUN_UNUSUAL_DESIGN)
continue // These don't have a way to inspect weapon stats
var/obj/item/weapon/gun/temp_gun = new current_gun
var/icon_state = temp_gun.base_gun_icon // base_gun_icon is set in Initialize generally
qdel(temp_gun)
if(icon_state && isnull(sprites[icon_state]))
stack_trace("[current_gun] does not have a valid lineart icon state, icon=[icon_file], icon_state=[json_encode(icon_state)](\ref[icon_state])")
// upgrade this to a stack_trace once all guns have a lineart and we want to lint against that
log_debug("[current_gun] does not have a valid lineart icon state, icon=[icon_file], icon_state=[json_encode(icon_state)]")

..()

Expand Down
12 changes: 9 additions & 3 deletions code/modules/autowiki/pages/guns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

var/list/gun_to_ammo = list()

for(var/obj/item/ammo_magazine/typepath as anything in subtypesof(/obj/item/ammo_magazine) - subtypesof(/obj/item/ammo_magazine/internal))
for(var/obj/item/ammo_magazine/typepath as anything in subtypesof(/obj/item/ammo_magazine) - typesof(/obj/item/ammo_magazine/internal))
if(isnull(initial(typepath.icon_state)))
continue // Skip mags with no icon_state (e.g. base types)
LAZYADD(gun_to_ammo[initial(typepath.gun_type)], typepath)

for(var/typepath in sort_list(subtypesof(/obj/item/weapon/gun), GLOBAL_PROC_REF(cmp_typepaths_asc)))
var/obj/item/weapon/gun/generating_gun = new typepath()
var/obj/item/weapon/gun/generating_gun = typepath
if(isnull(initial(generating_gun.icon_state)))
continue // Skip guns with no icon_state (e.g. base types)

generating_gun = new typepath()
var/filename = SANITIZE_FILENAME(escape_value(format_text(generating_gun.name)))

var/list/gun_data = generating_gun.ui_data()

var/list/valid_mag_types = list()
Expand Down Expand Up @@ -70,6 +74,8 @@

var/list/attachments_by_slot = list()
for(var/obj/item/attachable/attachment_typepath as anything in generating_gun.attachable_allowed)
if(isnull(initial(attachment_typepath.icon_state)))
continue // Skip attachments with no icon_state (e.g. base types)
LAZYADD(attachments_by_slot[capitalize(initial(attachment_typepath.slot))], attachment_typepath)

var/attachments = ""
Expand Down
4 changes: 1 addition & 3 deletions code/modules/projectiles/guns/pistols.dm
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@
icon = 'icons/obj/items/weapons/guns/guns_by_faction/colony.dmi'
icon_state = "c_deagle"
item_state = "c_deagle"
base_gun_icon = "c_deagle"
current_mag = /obj/item/ammo_magazine/pistol/heavy/super/highimpact
black_market_value = 100

Expand All @@ -257,7 +256,6 @@
desc = "A Desert Eagle anodized in gold and adorned with rosewood grips. The living definition of ostentatious, it's flashy, unwieldy, tremendously heavy, and kicks like a mule. But as a symbol of power, there's nothing like it."
icon_state = "g_deagle"
item_state = "g_deagle"
base_gun_icon = "g_deagle"

//-------------------------------------------------------
//NP92 pistol
Expand Down Expand Up @@ -588,7 +586,7 @@
name = "\improper 88 Mod 4 combat pistol"
desc = "Standard issue USCM firearm. Also found in the hands of Weyland-Yutani PMC teams. Fires 9mm armor shredding rounds and is capable of 3-round burst."
icon = 'icons/obj/items/weapons/guns/guns_by_faction/uscm.dmi'
icon_state = "88m4"
icon_state = "_88m4" // to comply with css standards
item_state = "88m4"
fire_sound = "88m4"
firesound_volume = 20
Expand Down
4 changes: 4 additions & 0 deletions code/modules/unit_tests/spritesheets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
/datum/unit_test/spritesheets

/datum/unit_test/spritesheets/Run()
var/regex/valid_css_class = new(@"^([\l_][\w\-]|[\l_\-][\l_])")
for(var/datum/asset/spritesheet/sheet as anything in subtypesof(/datum/asset/spritesheet))
if(!initial(sheet.name)) //Ignore abstract types
continue
sheet = get_asset_datum(sheet)
for(var/sprite_name in sheet.sprites)
if(!sprite_name)
TEST_FAIL("Spritesheet [sheet.type] has a nameless icon state.")
if(!valid_css_class.Find(sprite_name))
// https://www.w3.org/TR/CSS2/syndata.html#value-def-identifier
TEST_FAIL("Spritesheet [sheet.type] has a icon state that doesn't comply with css standards: '[sprite_name]'.")
Binary file modified icons/obj/items/weapons/guns/guns_by_faction/uscm.dmi
Binary file not shown.
Binary file modified icons/obj/items/weapons/guns/lineart.dmi
Binary file not shown.

0 comments on commit efc4e0a

Please sign in to comment.