more updates!

This commit is contained in:
Letter N
2021-02-12 17:52:59 +08:00
parent 6286d40082
commit 5db87b9065
9 changed files with 402 additions and 277 deletions
+56 -49
View File
@@ -7,7 +7,9 @@
desc = "Controls a stacking machine... in theory."
density = FALSE
circuit = /obj/item/circuitboard/machine/stacking_unit_console
/// Connected stacking machine
var/obj/machinery/mineral/stacking_machine/machine
/// Direction for which console looks for stacking machine to connect to
var/machinedir = SOUTHEAST
/obj/machinery/mineral/stacking_unit_console/Initialize()
@@ -16,50 +18,53 @@
if (machine)
machine.CONSOLE = src
/obj/machinery/mineral/stacking_unit_console/ui_interact(mob/user)
. = ..()
if(!machine)
to_chat(user, "<span class='notice'>[src] is not linked to a machine!</span>")
return
var/obj/item/stack/sheet/s
var/dat
dat += text("<b>Stacking unit console</b><br><br>")
for(var/O in machine.stack_list)
s = machine.stack_list[O]
if(s.amount > 0)
dat += text("[capitalize(s.name)]: [s.amount] <A href='?src=[REF(src)];release=[s.type]'>Release</A><br>")
dat += text("<br>Stacking: [machine.stack_amt]<br><br>")
user << browse(dat, "window=console_stacking_machine")
/obj/machinery/mineral/stacking_unit_console/multitool_act(mob/living/user, obj/item/I)
if(istype(I, /obj/item/multitool))
var/obj/item/multitool/M = I
M.buffer = src
to_chat(user, "<span class='notice'>You store linkage information in [I]'s buffer.</span>")
return TRUE
/obj/machinery/mineral/stacking_unit_console/Topic(href, href_list)
if(..())
if(!multitool_check_buffer(user, I))
return
usr.set_machine(src)
src.add_fingerprint(usr)
if(href_list["release"])
if(!(text2path(href_list["release"]) in machine.stack_list))
return //someone tried to spawn materials by spoofing hrefs
var/obj/item/stack/sheet/inp = machine.stack_list[text2path(href_list["release"])]
var/obj/item/stack/sheet/out = new inp.type(null, inp.amount)
inp.amount = 0
machine.unload_mineral(out)
var/obj/item/multitool/M = I
M.buffer = src
to_chat(user, "<span class='notice'>You store linkage information in [I]'s buffer.</span>")
return TRUE
src.updateUsrDialog()
return
/obj/machinery/mineral/stacking_unit_console/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "StackingConsole", name)
ui.open()
/obj/machinery/mineral/stacking_unit_console/ui_data(mob/user)
var/list/data = list()
data["machine"] = machine ? TRUE : FALSE
data["stacking_amount"] = null
data["contents"] = list()
if(machine)
data["stacking_amount"] = machine.stack_amt
for(var/stack_type in machine.stack_list)
var/obj/item/stack/sheet/stored_sheet = machine.stack_list[stack_type]
if(stored_sheet.amount <= 0)
continue
data["contents"] += list(list(
"type" = stored_sheet.type,
"name" = capitalize(stored_sheet.name),
"amount" = stored_sheet.amount,
))
return data
/obj/machinery/mineral/stacking_unit_console/ui_act(action, list/params)
. = ..()
if(.)
return
switch(action)
if("release")
var/obj/item/stack/sheet/released_type = text2path(params["type"])
if(!released_type || !(initial(released_type.merge_type) in machine.stack_list))
return //someone tried to spawn materials by spoofing hrefs
var/obj/item/stack/sheet/inp = machine.stack_list[initial(released_type.merge_type)]
var/obj/item/stack/sheet/out = new inp.type(null, inp.amount)
inp.amount = 0
machine.unload_mineral(out)
return TRUE
/**********************Mineral stacking unit**************************/
@@ -108,6 +113,17 @@
/obj/machinery/mineral/stacking_machine/proc/process_sheet(obj/item/stack/sheet/inp)
if(QDELETED(inp))
return
// Dump the sheets to the silo if attached
if(materials.silo && !materials.on_hold())
var/matlist = inp.custom_materials & materials.mat_container.materials
if (length(matlist))
var/inserted = materials.mat_container.insert_item(inp)
materials.silo_log(src, "collected", inserted, "sheets", matlist)
qdel(inp)
return
// No silo attached process to internal storage
var/key = inp.merge_type
var/obj/item/stack/sheet/storage = stack_list[key]
if(!storage) //It's the first of this sheet added
@@ -115,15 +131,6 @@
storage.amount += inp.amount //Stack the sheets
qdel(inp)
if(materials.silo && !materials.on_hold()) //Dump the sheets to the silo
var/matlist = storage.custom_materials & materials.mat_container.materials
if (length(matlist))
var/inserted = materials.mat_container.insert_item(storage)
materials.silo_log(src, "collected", inserted, "sheets", matlist)
if (QDELETED(storage))
stack_list -= key
return
while(storage.amount >= stack_amt) //Get rid of excessive stackage
var/obj/item/stack/sheet/out = new inp.type(null, stack_amt)
unload_mineral(out)
@@ -0,0 +1,78 @@
//Portrait picker! It's a tgui window that lets you look through all the portraits, and choose one as your AI.
//very similar to centcom_podlauncher in terms of how this is coded, so i kept a lot of comments from it
//^ wow! it's the second time i've said this! i'm a real coder now, copying my statement of copying other people's stuff.
#define TAB_LIBRARY 1
#define TAB_SECURE 2
#define TAB_PRIVATE 3
/datum/portrait_picker
var/client/holder //client of whoever is using this datum
/datum/portrait_picker/New(user)//user can either be a client or a mob due to byondcode(tm)
if (istype(user, /client))
var/client/user_client = user
holder = user_client //if its a client, assign it to holder
else
var/mob/user_mob = user
holder = user_mob.client //if its a mob, assign the mob's client to holder
/datum/portrait_picker/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "PortraitPicker")
ui.open()
/datum/portrait_picker/ui_close()
qdel(src)
/datum/portrait_picker/ui_state(mob/user)
return GLOB.conscious_state
/datum/portrait_picker/ui_assets(mob/user)
return list(
get_asset_datum(/datum/asset/simple/portraits/library),
get_asset_datum(/datum/asset/simple/portraits/library_secure),
get_asset_datum(/datum/asset/simple/portraits/library_private)
)
/datum/portrait_picker/ui_data(mob/user)
var/list/data = list()
data["library"] = SSpersistence.paintings["library"] ? SSpersistence.paintings["library"] : 0
data["library_secure"] = SSpersistence.paintings["library_secure"] ? SSpersistence.paintings["library_secure"] : 0
data["library_private"] = SSpersistence.paintings["library_private"] ? SSpersistence.paintings["library_private"] : 0 //i'm gonna regret this, won't i?
return data
/datum/portrait_picker/ui_act(action, params)
. = ..()
if(.)
return
switch(action)
if("select")
var/list/tab2key = list(TAB_LIBRARY = "library", TAB_SECURE = "library_secure", TAB_PRIVATE = "library_private")
var/folder = tab2key[params["tab"]]
var/list/current_list = SSpersistence.paintings[folder]
var/list/chosen_portrait = current_list[params["selected"]]
var/png = "data/paintings/[folder]/[chosen_portrait["md5"]].png"
var/icon/portrait_icon = new(png)
var/mob/living/ai = holder.mob
var/w = portrait_icon.Width()
var/h = portrait_icon.Height()
var/mutable_appearance/MA = mutable_appearance(portrait_icon)
if(w == 23 || h == 23)
to_chat(ai, "<span class='notice'>Small note: 23x23 Portraits are accepted, but they do not fit perfectly inside the display frame.</span>")
MA.pixel_x = 5
MA.pixel_y = 5
else if(w == 24 || h == 24)
to_chat(ai, "<span class='notice'>Portrait Accepted. Enjoy!</span>")
MA.pixel_x = 4
MA.pixel_y = 4
else
to_chat(ai, "<span class='warning'>Sorry, only 23x23 and 24x24 Portraits are accepted.</span>")
return
ai.cut_overlays() //so people can't keep repeatedly select portraits to add stacking overlays
ai.icon_state = "ai-portrait-active"//background
ai.add_overlay(MA)
+8 -15
View File
@@ -11,7 +11,6 @@
#define MODE_WRITING 1
#define MODE_STAMPING 2
/**
* Paper is now using markdown (like in github pull notes) for ALL rendering
* so we do loose a bit of functionality but we gain in easy of use of
@@ -23,9 +22,6 @@
icon = 'icons/obj/bureaucracy.dmi'
icon_state = "paper"
item_state = "paper"
// inhand_icon_state = "paper"
// worn_icon_state = "paper"
// custom_fire_overlay = "paper_onfire_overlay"
throwforce = 0
w_class = WEIGHT_CLASS_TINY
throw_range = 1
@@ -102,8 +98,8 @@
/obj/item/paper/Initialize()
. = ..()
pixel_y = rand(-8, 8)
pixel_x = rand(-9, 9)
pixel_x = base_pixel_x + rand(-9, 9)
pixel_y = base_pixel_y + rand(-8, 8)
update_icon()
/obj/item/paper/update_icon_state()
@@ -193,13 +189,6 @@
user.visible_message(ignition_message)
add_fingerprint(user)
fire_act(I.get_temperature())
//I would have it become a paper plane before the throw, but that would risk runtimes
/obj/item/paper/DoRevenantThrowEffects(atom/target)
sleep(10)
if(HAS_TRAIT(src, TRAIT_SPOOKY_THROW))
return
new /obj/item/paperplane(get_turf(src))
qdel(src)
/obj/item/paper/attackby(obj/item/P, mob/living/user, params)
if(burn_paper_product_attackby_check(P, user))
@@ -253,6 +242,8 @@
/obj/item/paper/ui_data(mob/user)
var/list/data = list()
data["edit_usr"] = "[user]"
var/obj/O = user.get_active_held_item()
if(istype(O, /obj/item/toy/crayon))
var/obj/item/toy/crayon/PEN = O
@@ -291,7 +282,8 @@
return data
/obj/item/paper/ui_act(action, params,datum/tgui/ui)
if(..())
. = ..()
if(.)
return
switch(action)
if("stamp")
@@ -317,7 +309,8 @@
LAZYADD(stamped, stamp_icon_state)
update_static_data(usr,ui)
ui.user.visible_message("<span class='notice'>[ui.user] stamps [src] with [stamp_class]!</span>", "<span class='notice'>You stamp [src] with [stamp_class]!</span>")
var/obj/O = ui.user.get_active_held_item()
ui.user.visible_message("<span class='notice'>[ui.user] stamps [src] with \the [O.name]!</span>", "<span class='notice'>You stamp [src] with \the [O.name]!</span>")
else
to_chat(usr, pick("You try to stamp but you miss!", "There is no where else you can stamp!"))
. = TRUE