Skip to content

Commit

Permalink
Replace nanoui weapon sprite lineart with spritesheet weapon lineart (#…
Browse files Browse the repository at this point in the history
…5631)

# About the pull request

This PR finalizes the work Stan started on but didn't finish for the
weapon examine stats panels. Now rather than individual sprites in the
nano ui weapons folder, the images are loaded from a couple
spritesheets. Additionally, when these spritesheets are loaded, they
check to ensure all gun subtypes that have a base_gun_icon match with an
icon in the sprite sheet. E.g.

![image](https://github.com/cmss13-devs/cmss13/assets/76988376/41a20922-9200-4105-a7c4-d5a4eddd55a9)

All "created" sprites are just the existing images from the nano ui
weapons folders.

# Explain why it's good for the game

More efficient resource distribution! 

# Testing Photographs and Procedure

![image](https://github.com/cmss13-devs/cmss13/assets/76988376/34c5c5a0-0bcb-4a02-b534-0a0fa6df1057)

# Changelog
:cl: Drathek
ui: Refactored backend for Weapon Stats panel to use spritesheets
instead.
/:cl:
  • Loading branch information
Drulikar committed Feb 2, 2024
1 parent 55f0768 commit 4cc11f7
Show file tree
Hide file tree
Showing 92 changed files with 42 additions and 60 deletions.
50 changes: 14 additions & 36 deletions code/modules/asset_cache/asset_list_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,9 @@
"nano/templates/",
)

/datum/asset/directory/nanoui/weapons
common_dirs = list(
"nano/images/weapons/",
)

uncommon_dirs = list()

/datum/asset/directory/nanoui/weapons/send(client)
if(!client)
log_debug("Warning! Tried to send nanoui weapon data with a null client! (asset_list_items.dm line 93)")
return
SSassets.transport.send_assets(client, common)


/datum/asset/simple/nanoui_images
keep_local_name = TRUE

assets = list(
"auto.png" = 'nano/images/weapons/auto.png',
"burst.png" = 'nano/images/weapons/burst.png',
"single.png" = 'nano/images/weapons/single.png',
"disabled_automatic.png" = 'nano/images/weapons/disabled_automatic.png',
"disabled_burst.png" = 'nano/images/weapons/disabled_burst.png',
"disabled_single.png" = 'nano/images/weapons/disabled_single.png',
"no_name.png" = 'nano/images/weapons/no_name.png',
)

var/list/common_dirs = list(
"nano/images/",
)
Expand Down Expand Up @@ -398,9 +374,22 @@
name = "gunlineart"

/datum/asset/spritesheet/gun_lineart/register()
InsertAll("", 'icons/obj/items/weapons/guns/lineart.dmi')
var/icon_file = 'icons/obj/items/weapons/guns/lineart.dmi'
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(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])")

..()

/datum/asset/spritesheet/gun_lineart_modes
name = "gunlineartmodes"

/datum/asset/spritesheet/gun_lineart_modes/register()
InsertAll("", 'icons/obj/items/weapons/guns/lineart_modes.dmi')
..()

/datum/asset/simple/orbit
assets = list(
Expand All @@ -414,17 +403,6 @@
"ntosradarpointerS.png" = 'icons/images/ui_images/ntosradar_pointer_S.png'
)

/datum/asset/simple/firemodes
assets = list(
"auto.png" = 'html/images/auto.png',
"disabled_auto.png" = 'html/images/disabled_automatic.png',
"burst.png" = 'html/images/burst.png',
"disabled_burst.png" = 'html/images/disabled_burst.png',
"single.png" = 'html/images/single.png',
"disabled_single.png" = 'html/images/disabled_single.png',
)


/datum/asset/simple/particle_editor
assets = list(
"motion" = 'icons/images/ui_images/particle_editor/motion.png',
Expand Down
10 changes: 3 additions & 7 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,7 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w

// weapon info

data["icon"] = SSassets.transport.get_asset_url("no_name.png")

if(SSassets.cache["[base_gun_icon].png"])
data["icon"] = SSassets.transport.get_asset_url("[base_gun_icon].png")

data["icon"] = base_gun_icon
data["name"] = name
data["desc"] = desc
data["two_handed_only"] = (flags_gun_features & GUN_WIELDED_FIRING_ONLY)
Expand Down Expand Up @@ -727,8 +723,8 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w

/obj/item/weapon/gun/ui_assets(mob/user)
. = ..() || list()
. += get_asset_datum(/datum/asset/simple/firemodes)
//. += get_asset_datum(/datum/asset/spritesheet/gun_lineart)
. += get_asset_datum(/datum/asset/spritesheet/gun_lineart_modes)
. += get_asset_datum(/datum/asset/spritesheet/gun_lineart)

// END TGUI \\
Expand Down
Binary file modified icons/obj/items/weapons/guns/lineart.dmi
Binary file not shown.
Binary file added icons/obj/items/weapons/guns/lineart_modes.dmi
Binary file not shown.
Binary file removed nano/images/weapons/88m4.png
Binary file not shown.
Binary file removed nano/images/weapons/aamateba.png
Binary file not shown.
Binary file removed nano/images/weapons/amateba.png
Binary file not shown.
Binary file removed nano/images/weapons/auto.png
Binary file not shown.
Binary file removed nano/images/weapons/auto9.png
Binary file not shown.
Binary file removed nano/images/weapons/b92fs.png
Binary file not shown.
Binary file removed nano/images/weapons/burst.png
Binary file not shown.
Binary file removed nano/images/weapons/c70.png
Binary file not shown.
Binary file removed nano/images/weapons/c_deagle.png
Binary file not shown.
Binary file removed nano/images/weapons/cmateba.png
Binary file not shown.
Binary file removed nano/images/weapons/cshotgun.png
Binary file not shown.
Binary file removed nano/images/weapons/dartgun.png
Binary file not shown.
Binary file removed nano/images/weapons/deagle.png
Binary file not shown.
Binary file removed nano/images/weapons/disabled_automatic.png
Binary file not shown.
Binary file removed nano/images/weapons/disabled_burst.png
Binary file not shown.
Binary file removed nano/images/weapons/disabled_single.png
Binary file not shown.
Binary file removed nano/images/weapons/dshotgun.png
Binary file not shown.
Binary file removed nano/images/weapons/fp9000.png
Binary file not shown.
Binary file removed nano/images/weapons/fp9000_pmc.png
Binary file not shown.
Binary file removed nano/images/weapons/g_deagle.png
Binary file not shown.
Binary file removed nano/images/weapons/hg3712.png
Binary file not shown.
Binary file removed nano/images/weapons/highpower.png
Binary file not shown.
Binary file removed nano/images/weapons/holdout.png
Binary file not shown.
Binary file removed nano/images/weapons/hunting.png
Binary file not shown.
Binary file removed nano/images/weapons/kt42.png
Binary file not shown.
Binary file removed nano/images/weapons/l42mk1.png
Diff not rendered.
Binary file removed nano/images/weapons/m16.png
Diff not rendered.
Binary file removed nano/images/weapons/m240.png
Diff not rendered.
Binary file removed nano/images/weapons/m240t.png
Diff not rendered.
Binary file removed nano/images/weapons/m37-17.png
Diff not rendered.
Binary file removed nano/images/weapons/m37.png
Diff not rendered.
Binary file removed nano/images/weapons/m39.png
Diff not rendered.
Binary file removed nano/images/weapons/m41a.png
Diff not rendered.
Binary file removed nano/images/weapons/m41a2.png
Diff not rendered.
Binary file removed nano/images/weapons/m41ae2.png
Diff not rendered.
Binary file removed nano/images/weapons/m41amk1.png
Diff not rendered.
Binary file removed nano/images/weapons/m41b.png
Diff not rendered.
Binary file removed nano/images/weapons/m42a.png
Diff not rendered.
Binary file removed nano/images/weapons/m42c.png
Diff not rendered.
Binary file removed nano/images/weapons/m44r.png
Diff not rendered.
Binary file removed nano/images/weapons/m44rc.png
Diff not rendered.
Binary file removed nano/images/weapons/m46c.png
Diff not rendered.
Binary file removed nano/images/weapons/m4a3.png
Diff not rendered.
Binary file removed nano/images/weapons/m4a345.png
Diff not rendered.
Binary file removed nano/images/weapons/m4a3c.png
Diff not rendered.
Binary file removed nano/images/weapons/m5.png
Diff not rendered.
Binary file removed nano/images/weapons/m56.png
Diff not rendered.
Binary file removed nano/images/weapons/m57a4.png
Diff not rendered.
Binary file removed nano/images/weapons/m60.png
Diff not rendered.
Binary file removed nano/images/weapons/m79.png
Diff not rendered.
Binary file removed nano/images/weapons/m81.png
Diff not rendered.
Binary file removed nano/images/weapons/m82f.png
Diff not rendered.
Binary file removed nano/images/weapons/m92.png
Diff not rendered.
Binary file removed nano/images/weapons/m93b2.png
Diff not rendered.
Binary file removed nano/images/weapons/mac15.png
Diff not rendered.
Binary file removed nano/images/weapons/mar30.png
Diff not rendered.
Binary file removed nano/images/weapons/mar40.png
Diff not rendered.
Binary file removed nano/images/weapons/mateba.png
Diff not rendered.
Binary file removed nano/images/weapons/mk221.png
Diff not rendered.
Binary file removed nano/images/weapons/mou.png
Diff not rendered.
Binary file removed nano/images/weapons/mp5.png
Diff not rendered.
Binary file removed nano/images/weapons/mp7.png
Diff not rendered.
Binary file removed nano/images/weapons/no_name.png
Diff not rendered.
Binary file removed nano/images/weapons/ny762.png
Diff not rendered.
Binary file removed nano/images/weapons/painless.png
Diff not rendered.
Binary file removed nano/images/weapons/pk9.png
Diff not rendered.
Binary file removed nano/images/weapons/pk9r.png
Diff not rendered.
Binary file removed nano/images/weapons/pk9u.png
Diff not rendered.
Binary file removed nano/images/weapons/ppsh17b.png
Diff not rendered.
Binary file removed nano/images/weapons/single.png
Diff not rendered.
Binary file removed nano/images/weapons/skorpion.png
Diff not rendered.
Binary file removed nano/images/weapons/skorpion_u.png
Diff not rendered.
Binary file removed nano/images/weapons/smartpistol.png
Diff not rendered.
Binary file removed nano/images/weapons/spearhead.png
Diff not rendered.
Binary file removed nano/images/weapons/sshotgun.png
Diff not rendered.
Binary file removed nano/images/weapons/supremo.png
Diff not rendered.
Binary file removed nano/images/weapons/svd003.png
Diff not rendered.
Binary file removed nano/images/weapons/sw357.png
Diff not rendered.
Binary file removed nano/images/weapons/sw358.png
Diff not rendered.
Binary file removed nano/images/weapons/syringegun.png
Diff not rendered.
Binary file removed nano/images/weapons/taser.png
Diff not rendered.
Binary file removed nano/images/weapons/type71.png
Diff not rendered.
Binary file removed nano/images/weapons/type71c.png
Diff not rendered.
Binary file removed nano/images/weapons/type73.png
Diff not rendered.
Binary file removed nano/images/weapons/vp78.png
Diff not rendered.
Binary file removed nano/images/weapons/xm42b.png
Diff not rendered.
Binary file removed nano/images/weapons/xm51.png
Diff not rendered.
42 changes: 25 additions & 17 deletions tgui/packages/tgui/interfaces/WeaponStats.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { map } from 'common/collections';
import { resolveAsset } from '../assets';
import { classes } from 'common/react';
import { useBackend } from '../backend';
import { ProgressBar, Section, Box, Flex, Table, Divider } from '../components';
import { Window } from '../layouts';
Expand Down Expand Up @@ -68,7 +68,7 @@ const GeneralInfo = (props) => {
<Flex.Item align="center">
<Box height="5px" />
<Box align="center">
<img src={resolveAsset(icon)} />
<span className={classes(['Icon', 'gunlineart96x96', `${icon}`])} />
</Box>
<Box height="5px" />
</Flex.Item>
Expand All @@ -78,25 +78,33 @@ const GeneralInfo = (props) => {
<Flex.Item align="center">
<Flex direction="row">
<Flex.Item>
{!auto_only ? (
<img src={resolveAsset('single.png')} />
) : (
<img src={resolveAsset('disabled_single.png')} />
)}
<span
className={classes([
'Icon',
'gunlineartmodes96x32',
`${!auto_only ? 'single' : 'disabled_single'}`,
])}
/>
</Flex.Item>
<Flex.Item>
{!auto_only && burst_amount > 1 ? (
<img src={resolveAsset('burst.png')} />
) : (
<img src={resolveAsset('disabled_burst.png')} />
)}
<span
className={classes([
'Icon',
'gunlineartmodes96x32',
`${
!auto_only && burst_amount > 1 ? 'burst' : 'disabled_burst'
}`,
])}
/>
</Flex.Item>
<Flex.Item>
{automatic ? (
<img src={resolveAsset('auto.png')} />
) : (
<img src={resolveAsset('disabled_automatic.png')} />
)}
<span
className={classes([
'Icon',
'gunlineartmodes96x32',
`${automatic ? 'auto' : 'disabled_automatic'}`,
])}
/>
</Flex.Item>
</Flex>
</Flex.Item>
Expand Down

0 comments on commit 4cc11f7

Please sign in to comment.