mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 15:17:01 +01:00
Refactor card scaling into an element for general item scaling (#56102)
The current TCG code had some code for scaling its cards down when they're on the ground and then scaling them back in hand/inventory. This element aims to preserve this functionality and to allow it work for other items. While the TCG makes the cards smaller on the ground, this element allows for items to be scaled up OR down when on the floor or in inventory. While this particular element has to do with scaling, I am looking at ways to expand this sort of icon change functionality to icon_state as well, but there are additional issues with blood decals needing to be redrawn and possibly vis_contents.
This commit is contained in:
@@ -26,9 +26,7 @@ GLOBAL_LIST_EMPTY(cached_cards)
|
||||
|
||||
/obj/item/tcgcard/Initialize(mapload, datum_series, datum_id)
|
||||
. = ..()
|
||||
zoom_out()
|
||||
RegisterSignal(src, COMSIG_STORAGE_ENTERED, .proc/zoom_in)
|
||||
RegisterSignal(src, COMSIG_STORAGE_EXITED, .proc/zoom_out)
|
||||
AddElement(/datum/element/item_scaling, 0.3, 1)
|
||||
//If they are passed as null let's replace them with the vars on the card. this also means we can allow for map loaded ccards
|
||||
if(!datum_series)
|
||||
datum_series = series
|
||||
@@ -102,14 +100,6 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
. = ..()
|
||||
flip_card(user)
|
||||
|
||||
/obj/item/tcgcard/equipped(mob/user, slot, initial)
|
||||
. = ..()
|
||||
zoom_in()
|
||||
|
||||
/obj/item/tcgcard/dropped(mob/user, silent)
|
||||
. = ..()
|
||||
zoom_out()
|
||||
|
||||
/obj/item/tcgcard/update_icon_state()
|
||||
. = ..()
|
||||
if(!flipped)
|
||||
@@ -129,9 +119,7 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
var/obj/item/tcgcard_deck/new_deck = new /obj/item/tcgcard_deck(drop_location())
|
||||
new_deck.flipped = flipped
|
||||
user.transferItemToLoc(second_card, new_deck)//Start a new pile with both cards, in the order of card placement.
|
||||
second_card.zoom_in()
|
||||
user.transferItemToLoc(src, new_deck)
|
||||
zoom_in()
|
||||
new_deck.update_icon_state()
|
||||
user.put_in_hands(new_deck)
|
||||
if(istype(I, /obj/item/tcgcard_deck))
|
||||
@@ -141,7 +129,6 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
return
|
||||
user.transferItemToLoc(src, old_deck)
|
||||
flipped = old_deck.flipped
|
||||
zoom_in()
|
||||
old_deck.update_icon()
|
||||
update_icon()
|
||||
return ..()
|
||||
@@ -162,18 +149,6 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
tapped = !tapped
|
||||
animate(src, transform = ntransform, time = 2, easing = (EASE_IN|EASE_OUT))
|
||||
|
||||
/**
|
||||
* Transforms the card's sprite to look like a small, paper card. Use when outside of inventory
|
||||
*/
|
||||
/obj/item/tcgcard/proc/zoom_in()
|
||||
transform = matrix()
|
||||
|
||||
/**
|
||||
* Transforms the card's sprite to look like a large, detailed, illustrated paper card. Use when inside of inventory/storage.
|
||||
*/
|
||||
/obj/item/tcgcard/proc/zoom_out()
|
||||
transform = matrix(0.3,0,0,0,0.3,0)
|
||||
|
||||
/obj/item/tcgcard/proc/flip_card(mob/user)
|
||||
to_chat(user, "<span_class='notice'>You turn the card over.</span>")
|
||||
if(!flipped)
|
||||
@@ -249,7 +224,6 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
for(var/card in 1 to contents.len)
|
||||
var/obj/item/tcgcard/stored_card = contents[card]
|
||||
stored_card.forceMove(drop_location())
|
||||
stored_card.zoom_out()
|
||||
. = ..()
|
||||
|
||||
/obj/item/tcgcard_deck/proc/check_menu(mob/living/user)
|
||||
@@ -268,7 +242,6 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
var/obj/item/tcgcard/new_card = I
|
||||
new_card.flipped = flipped
|
||||
new_card.forceMove(src)
|
||||
new_card.zoom_in()
|
||||
|
||||
|
||||
/obj/item/tcgcard_deck/attack_self(mob/living/carbon/user)
|
||||
@@ -290,7 +263,6 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
if(contents.len <= 1)
|
||||
var/obj/item/tcgcard/final_card = contents[1]
|
||||
user.transferItemToLoc(final_card, drop_location())
|
||||
final_card.zoom_out()
|
||||
qdel(src)
|
||||
|
||||
|
||||
@@ -320,7 +292,6 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
//Now flip the cards to their opposite positions.
|
||||
for(var/a in 1 to contents.len)
|
||||
var/obj/item/tcgcard/nu_card = contents[a]
|
||||
nu_card.zoom_in()
|
||||
nu_card.flipped = flipped
|
||||
nu_card.update_icon_state()
|
||||
update_icon_state()
|
||||
@@ -377,9 +348,7 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
|
||||
/obj/item/cardpack/Initialize()
|
||||
. = ..()
|
||||
zoom_out()
|
||||
RegisterSignal(src, COMSIG_STORAGE_ENTERED, .proc/zoom_in)
|
||||
RegisterSignal(src, COMSIG_STORAGE_EXITED, .proc/zoom_out)
|
||||
AddElement(/datum/element/item_scaling, 0.4, 1)
|
||||
//Pass by refrance moment
|
||||
//This lets us only have one rarity table per pack, badmins beware
|
||||
if(GLOB.cached_rarity_table[type])
|
||||
@@ -391,20 +360,6 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
else
|
||||
GLOB.cached_guar_rarity[type] = guar_rarity
|
||||
|
||||
/obj/item/cardpack/equipped(mob/user, slot, initial)
|
||||
. = ..()
|
||||
zoom_in()
|
||||
|
||||
/obj/item/cardpack/dropped(mob/user, silent)
|
||||
. = ..()
|
||||
zoom_out()
|
||||
|
||||
/obj/item/cardpack/proc/zoom_in()
|
||||
transform = matrix()
|
||||
|
||||
/obj/item/cardpack/proc/zoom_out()
|
||||
transform = matrix(0.4,0,0,0,0.4,0)
|
||||
|
||||
/obj/item/cardpack/attack_self(mob/user)
|
||||
. = ..()
|
||||
var/list/cards = buildCardListWithRarity(card_count, guaranteed_count)
|
||||
@@ -430,15 +385,7 @@ GLOBAL_LIST_EMPTY(tcgcard_radial_choices)
|
||||
|
||||
/obj/item/coin/thunderdome/Initialize()
|
||||
. = ..()
|
||||
transform = matrix(0.4,0,0,0,0.4,0)
|
||||
|
||||
/obj/item/coin/thunderdome/equipped(mob/user, slot, initial)
|
||||
. = ..()
|
||||
transform = matrix()
|
||||
|
||||
/obj/item/coin/thunderdome/dropped(mob/user, silent)
|
||||
. = ..()
|
||||
transform = matrix(0.4,0,0,0,0.4,0)
|
||||
AddElement(/datum/element/item_scaling, 0.4, 1)
|
||||
|
||||
/obj/item/storage/card_binder
|
||||
name = "card binder"
|
||||
|
||||
Reference in New Issue
Block a user