Files
Bubberstation/code/game/objects/structures/ore_containers.dm
Lucy f4a077c6fe Refactors some more UIs to use DmIcon (#87886)
## About The Pull Request

Upstream port of
https://github.com/Monkestation/Monkestation2.0/pull/4215

This changes some tgui UIs that used icon2base64/getFlatIcon to display
items to instead use DmIcon, just passing the icon/icon_state instead.

To be specific: the ORM, the "ore container", and the order console
(produce, mining, and bitrunning vendors)

<details>
<summary><h3>UI screenshots / proof of testing</h3></summary>

![2024-11-12 (1731458275) ~
dreamseeker](https://github.com/user-attachments/assets/b1c60677-b117-4c23-8076-8b5072130d55)
![2024-11-12 (1731458281) ~
dreamseeker](https://github.com/user-attachments/assets/b64d3c2f-4754-4e5d-991a-2df69d86eb2a)
![2024-11-12 (1731458286) ~
dreamseeker](https://github.com/user-attachments/assets/287d8db1-8acb-4c4c-a2f0-66227a477d19)
![2024-11-12 (1731458388) ~
dreamseeker](https://github.com/user-attachments/assets/f69f5d51-5cdc-442c-971d-a4abedd4a3d2)
![2024-11-12 (1731458391) ~
dreamseeker](https://github.com/user-attachments/assets/53a95e88-ac41-4f97-a409-10b19d130376)


</details>

## Why It's Good For The Game

gfi bad, especially in ui(_static)_data, dmicon good.

## Changelog
🆑
refactor: The ORM, "ore container", and order console UIs (produce,
mining, bitrunner vendors) now load icons in a more efficient manner.
/🆑
2024-11-14 19:10:22 +01:00

54 lines
1.4 KiB
Plaintext

///structure to contain ores
/obj/structure/ore_container
/obj/structure/ore_container/attackby(obj/item/ore, mob/living/carbon/human/user, list/modifiers)
if(istype(ore, /obj/item/stack/ore) && !user.combat_mode)
ore.forceMove(src)
return
return ..()
/obj/structure/ore_container/Entered(atom/movable/mover)
. = ..()
update_appearance(UPDATE_OVERLAYS)
/obj/structure/ore_container/Exited(atom/movable/mover)
. = ..()
update_appearance(UPDATE_OVERLAYS)
/obj/structure/ore_container/ui_interact(mob/user, datum/tgui/ui)
. = ..()
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "OreContainer")
ui.open()
/obj/structure/ore_container/ui_data(mob/user)
var/list/ores = list()
for(var/obj/item/stack/ore/ore_item in contents)
ores += list(list(
"id" = REF(ore_item),
"name" = ore_item.name,
"amount" = ore_item.amount,
"icon" = ore_item::icon,
"icon_state" = ore_item::icon_state,
))
return list("ores" = ores)
/obj/structure/ore_container/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(. || !isliving(ui.user))
return TRUE
var/mob/living/customer = ui.user
var/obj/item/stack_to_move
switch(action)
if("withdraw")
if(isnull(params["reference"]))
return TRUE
stack_to_move = locate(params["reference"]) in contents
if(isnull(stack_to_move))
return TRUE
stack_to_move.forceMove(get_turf(customer))
return TRUE