matrices..
This commit is contained in:
@@ -23,14 +23,12 @@
|
||||
#define WEIGHT_CLASS_GIGANTIC 6
|
||||
|
||||
/// Macro for automatically getting the volume of an item from its w_class.
|
||||
#define AUTO_SCALE_VOLUME(w_class) (w_class ** 2)
|
||||
/// Macro for automatically getting the volume of a storage item from its max_w_class and max_items.
|
||||
#define AUTO_SCALE_STORAGE_VOLUME(w_class, max_items) (AUTO_SCALE_VOLUME(w_class) * max_items)
|
||||
#define AUTO_SCALE_VOLUME(w_class) (2 ** w_class)
|
||||
/// Macro for automatically getting the volume of a storage item from its max_w_class and max_combined_w_class.
|
||||
#define AUTO_SCALE_STORAGE_VOLUME(w_class, max_combined_w_class) (AUTO_SCALE_VOLUME(w_class) * (max_combined_w_class / w_class))
|
||||
|
||||
// UI defines
|
||||
/// Minimum pixels an item must have in volumetric scaled storage UI
|
||||
#define MINIMUM_PIXELS_PER_ITEM 4
|
||||
/// The size of the volumetric scaled storage UI's volumetric boxes that's rendered behind items.
|
||||
#define VOLUMETRIC_STORAGE_BOX_SIZE 8
|
||||
#define MINIMUM_PIXELS_PER_ITEM 2
|
||||
/// Maximum number of objects that will be allowed to be displayed using the volumetric display system. Arbitrary number to prevent server lockups.
|
||||
#define MAXIMUM_VOLUMETRIC_ITEMS 256
|
||||
|
||||
@@ -42,20 +42,52 @@
|
||||
|
||||
/obj/screen/storage/left
|
||||
icon_state = "storage_start"
|
||||
insertion_click = TRUE
|
||||
|
||||
/obj/screen/storage/right
|
||||
icon_state = "storage_end"
|
||||
insertion_click = TRUE
|
||||
|
||||
/obj/screen/storage/continuous
|
||||
icon_state = "storage_continue"
|
||||
insertion_click = TRUE
|
||||
|
||||
/obj/screen/storage/volumetric_box
|
||||
icon_state = "stored_8px"
|
||||
icon_state = "stored_continue"
|
||||
var/obj/item/our_item
|
||||
var/obj/screen/storage/stored_left/left
|
||||
var/obj/screen/storage/stored_right/right
|
||||
|
||||
/obj/screen/storage/volumetric_box/Destroy()
|
||||
QDEL_NULL(left)
|
||||
QDEL_NULL(right)
|
||||
our_item = null
|
||||
return ..()
|
||||
|
||||
/obj/screen/storage/volumetric_box/Initialize(mapload, new_master, our_item)
|
||||
src.our_item = our_item
|
||||
left = new(null, src, our_item)
|
||||
right = new(null, src, our_item)
|
||||
return ..()
|
||||
|
||||
/obj/screen/storage/volumetric_box/Click(location, control, params)
|
||||
return our_item.Click(location, control, params)
|
||||
|
||||
/obj/screen/storage/volumetric_box/proc/on_screen_objects()
|
||||
return list(src, left, right)
|
||||
|
||||
/obj/screen/storage/volumetric_box/proc/set_pixel_size(pixels)
|
||||
cut_overlays()
|
||||
//our icon size is 32 pixels.
|
||||
transform = matrix(32 / pixels, 0, 0, 0, 1, 0)
|
||||
left.pixel_x = -(pixels * 0.5) - 4
|
||||
right.pixel_x = (pixels * 0.5) + 4
|
||||
add_overlay(left)
|
||||
add_overlay(right)
|
||||
pixel_x = (pixels - 32) * 0.5
|
||||
|
||||
/obj/screen/storage/stored_left
|
||||
icon_state = "stored_start"
|
||||
|
||||
/obj/screen/storage/stored_right
|
||||
icon_state = "stored_end"
|
||||
|
||||
@@ -84,8 +84,6 @@
|
||||
/datum/component/storage/Initialize(datum/component/storage/concrete/master)
|
||||
if(!isatom(parent))
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
if(isnull(max_volume))
|
||||
max_volume = AUTO_SCALE_STORAGE_VOLUME(max_w_class, max_items)
|
||||
if(master)
|
||||
change_master(master)
|
||||
|
||||
@@ -714,3 +712,9 @@
|
||||
to_chat(user, "[parent] now picks up all items in a tile at once.")
|
||||
if(COLLECT_ONE)
|
||||
to_chat(user, "[parent] now picks up one item at a time.")
|
||||
|
||||
/**
|
||||
* Gets our max volume
|
||||
*/
|
||||
/datum/component/storage/proc/get_max_volume()
|
||||
return max_volume || AUTO_SCALE_STORAGE_VOLUME(max_w_class, max_combined_w_class)
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
volume = I.get_w_volume()
|
||||
used += volume
|
||||
volume_by_item[I] = volume
|
||||
percentage_by_item[I] = volume / max_volume
|
||||
percentage_by_item[I] = volume / get_max_volume()
|
||||
to_chat(world, "DEBUG: [I] volume [volume] percent [percentage_by_item[I]]")
|
||||
var/overrun = FALSE
|
||||
if(used >= (horizontal_pixels + 4)) //2-4 pixel grace zone
|
||||
@@ -110,7 +110,7 @@
|
||||
// define outside for marginal performance boost
|
||||
var/obj/item/I
|
||||
// start at this pixel from screen_start_x.
|
||||
var/pixel = -((world.icon_size - VOLUMETRIC_STORAGE_BOX_SIZE) * 0.5)
|
||||
var/current_pixel = 0
|
||||
|
||||
LAZYINITLIST(ui_item_blocks)
|
||||
for(var/i in percentage_by_item)
|
||||
@@ -124,20 +124,12 @@
|
||||
|
||||
// now that we have pixels_to_use, place our thing and add it to the returned list.
|
||||
|
||||
// now, scale the thing
|
||||
var/multiply = pixels_to_use / VOLUMETRIC_STORAGE_BOX_SIZE
|
||||
B.transform = matrix(multiply, 0, 0, 0, 1, 0)
|
||||
|
||||
// unfortunately since scaling means expand-from-center.. ugh..
|
||||
var/px_add = (pixels_to_use - VOLUMETRIC_STORAGE_BOX_SIZE) * 0.5
|
||||
// now, screenloc the thing.
|
||||
var/xshift = FLOOR(pixel / world.icon_size, 1)
|
||||
var/px = pixel % world.icon_size
|
||||
B.screen_loc = I.screen_loc = "[screen_start_x + xshift]:[px + px_add],[screen_start_y]:[screen_pixel_y]"
|
||||
B.screen_loc = I.screen_loc = "[screen_start_x]:[current_pixel],[screen_start_y]:[screen_pixel_y]"
|
||||
// add the used pixels to pixel after we place the object
|
||||
pixel += pixels_to_use
|
||||
current_pixel += pixels_to_use
|
||||
|
||||
// set various things
|
||||
B.set_pixel_size(pixels_to_use)
|
||||
B.layer = VOLUMETRIC_STORAGE_BOX_LAYER
|
||||
B.plane = VOLUMETRIC_STORAGE_BOX_PLANE
|
||||
B.name = I.name
|
||||
@@ -148,7 +140,7 @@
|
||||
I.plane = VOLUMETRIC_STORAGE_ITEM_PLANE
|
||||
|
||||
// finally add our things.
|
||||
. += B
|
||||
. += B.on_screen_objects()
|
||||
. += I
|
||||
|
||||
// Then, continuous section.
|
||||
|
||||
Reference in New Issue
Block a user