-
-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request Ports world icons from Mojave 13. This is an element that allows for tiny, size-accurate versions of object sprites in a roundabout way. ~~Drafted since spritainers want more coverage before merging~~ UNDRAFTED by request of a spritainer. God weeps ### //MAKING A SUPER BASIC WORLD ICON IMPLEMENTATION GUIDE: FOR REAL. NO VIRUS. 100% ORGANIC// - Place the Element in an Init below The Item In Question `/obj/item/Initialize()` ` . = ..()` ` AddElement(/datum/element/world_icon, null, icon, 'icon')` - Fill in info. Put the ORIGINAL ICON in the addelement's `'icon'` slot (yeah, this element layers the "original" sprite on top of the worldicon one, using it as the default. It just be like that sometimes) `/obj/item/kitchen/knife/combat/Initialize()` ` . = ..()` ` AddElement(/datum/element/world_icon, null, icon, 'icons/obj/kitchen.dmi')` - Put the directory to your NEW, WORLD ICON in the item's normal icon var `icon = 'icons/obj/world/melee.dmi'` The world icon and icon adjustment vars on obj/item should allow for implementation in places where an object's Icon has to frequently change. <!-- Describe The Pull Request. Please be sure every change is documented or this can delay review and even discourage maintainers from merging your PR! --> ## Why It's Good For The Game Just a little guy <!-- Please add a short description of why you think these changes would benefit the game. If you can't justify it in words, it might not be worth adding. --> ## Changelog :cl: add: World icon element. add: World icons for combat knives. /:cl: <!-- Both :cl:'s are required for the changelog to work! You can put your name to the right of the first :cl: if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. --> --------- Signed-off-by: Sun-Soaked <[email protected]> Co-authored-by: Sun-Soaked <[email protected]> Co-authored-by: FalloutFalcon <[email protected]>
- Loading branch information
1 parent
8fa9d08
commit 084eae0
Showing
7 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
///////////////////////////////////////////////////////////// | ||
////////// WORLD ICON ELEMENT DIRECTORY ////////// | ||
///////////////////////////////////////////////////////////// | ||
//PORTED FROM MOJAVE SUN// | ||
|
||
// Slap onto something to give it a world icon that differs from the inventory one (allows for realistically sized objects and all that) // | ||
// To fix 25/06/2021 : Blood Decals, Mutable Overlays and other baked in bitch ass overlays that need to be remade when the icon changes // | ||
// Fixed 07/05/2022: Now you can deal with the above by handling everything with attached_proc instead | ||
// Fixed 12/04/2023: Icon states, Needs major tuning up by someone who can properly make it work | ||
|
||
/datum/element/world_icon | ||
id_arg_index = 2 | ||
element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH | ||
//If we want COMPLEX world icon behavior, this proc will handle icon updating when the item is NOT in the inventory. | ||
//I just assumed that the default update_icon is for inventory sprites because ss13 basically focuses on how the sprites | ||
//look on your hand, not how they realistically look in the world. | ||
var/attached_proc | ||
/// Only used if attached_proc doesn't exist, simply changes the icon of target to this when it's in the inventory | ||
var/inventory_icon | ||
/// Only used if attached_proc doesn't exist, simply changes the icon of target to this when it's NOT in the inventory | ||
var/world_icon | ||
/// Only used when inventory state icon is different from original | ||
var/inventory_icon_state | ||
/// Only used when world state icon is different from original, pretty much just the original "icon_state" but if you for some reason need to flip the standard icon states for this element around you can use this | ||
var/world_icon_state | ||
|
||
/datum/element/world_icon/Attach(obj/item/target, attached_proc, world_icon, inventory_icon, world_icon_state, inventory_icon_state) | ||
. = ..() | ||
if(!istype(target)) | ||
return ELEMENT_INCOMPATIBLE | ||
|
||
src.attached_proc = attached_proc | ||
src.world_icon = world_icon | ||
src.world_icon_state = world_icon_state | ||
src.inventory_icon = inventory_icon | ||
src.inventory_icon_state = inventory_icon_state | ||
RegisterSignal(target, COMSIG_ATOM_UPDATE_ICON, PROC_REF(update_icon)) | ||
RegisterSignal(target, COMSIG_ATOM_UPDATE_ICON_STATE, PROC_REF(update_icon_state)) | ||
RegisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_STORAGE_ENTERED, COMSIG_ITEM_DROPPED, COMSIG_STORAGE_EXITED), PROC_REF(inventory_updated)) | ||
target.update_appearance(UPDATE_ICON) | ||
target.update_appearance(UPDATE_ICON_STATE) | ||
|
||
/datum/element/world_icon/Detach(obj/item/source) | ||
. = ..() | ||
UnregisterSignal(source, COMSIG_ATOM_UPDATE_ICON) | ||
UnregisterSignal(source, COMSIG_ATOM_UPDATE_ICON_STATE, PROC_REF(update_icon_state)) | ||
UnregisterSignal(source, list(COMSIG_ITEM_EQUIPPED, COMSIG_STORAGE_ENTERED, COMSIG_ITEM_DROPPED, COMSIG_STORAGE_EXITED)) | ||
source.update_appearance(UPDATE_ICON) | ||
source.update_appearance(UPDATE_ICON_STATE) | ||
|
||
/datum/element/world_icon/proc/update_icon(obj/item/source, updates) | ||
SIGNAL_HANDLER | ||
|
||
if((source.item_flags & IN_INVENTORY) || (source.loc && SEND_SIGNAL(source.loc, COMSIG_CONTAINS_STORAGE))) | ||
if(attached_proc) | ||
return | ||
return default_inventory_icon(source) | ||
|
||
if(attached_proc) | ||
return call(source, attached_proc)(updates) | ||
else | ||
return default_world_icon(source) | ||
|
||
/datum/element/world_icon/proc/update_icon_state(obj/item/source, updates) | ||
SIGNAL_HANDLER | ||
|
||
if((source.item_flags & IN_INVENTORY) || (source.loc && SEND_SIGNAL(source.loc, COMSIG_CONTAINS_STORAGE))) | ||
if(attached_proc) | ||
return | ||
return default_inventory_icon_state(source) | ||
|
||
if(attached_proc) | ||
return call(source, attached_proc)(updates) | ||
else | ||
return default_world_icon_state(source) | ||
|
||
/datum/element/world_icon/proc/inventory_updated(obj/item/source) | ||
SIGNAL_HANDLER | ||
|
||
source.update_appearance(UPDATE_ICON) | ||
source.update_appearance(UPDATE_ICON_STATE) | ||
|
||
/datum/element/world_icon/proc/default_inventory_icon(obj/item/source) | ||
SIGNAL_HANDLER | ||
|
||
source.icon = inventory_icon | ||
|
||
/datum/element/world_icon/proc/default_world_icon(obj/item/source) | ||
SIGNAL_HANDLER | ||
|
||
source.icon = world_icon | ||
|
||
/datum/element/world_icon/proc/default_inventory_icon_state(obj/item/source) | ||
SIGNAL_HANDLER | ||
|
||
if(!inventory_icon_state) | ||
source.icon_state = source.icon_state | ||
return | ||
|
||
INVOKE_ASYNC(src, PROC_REF(check_inventory_state), source) | ||
|
||
/datum/element/world_icon/proc/default_world_icon_state(obj/item/source) | ||
SIGNAL_HANDLER | ||
|
||
if(!world_icon_state) | ||
source.icon_state = source.icon_state | ||
return | ||
|
||
INVOKE_ASYNC(src, PROC_REF(check_world_icon_state), source) | ||
|
||
/datum/element/world_icon/proc/check_inventory_state(obj/item/source) | ||
SIGNAL_HANDLER | ||
|
||
inventory_icon_state = source.inventory_state | ||
source.icon_state = inventory_icon_state | ||
|
||
/datum/element/world_icon/proc/check_world_icon_state(obj/item/source) | ||
SIGNAL_HANDLER | ||
|
||
world_icon_state = source.world_state | ||
source.icon_state = world_icon_state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters