mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-07-19 20:23:07 +01:00
TGUI Research
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
var/upgraded = FALSE // When hit with an upgrade disk, will turn true, allowing it to print the higher tier circuits.
|
||||
var/can_clone = FALSE // Same for above, but will allow the printer to duplicate a specific assembly. (Not implemented)
|
||||
// var/static/list/recipe_list = list()
|
||||
var/current_category = null
|
||||
var/obj/item/device/electronic_assembly/assembly_to_clone = null
|
||||
var/obj/item/device/electronic_assembly/assembly_to_clone = null // Not implemented x3
|
||||
var/dirty_items = FALSE
|
||||
|
||||
/obj/item/device/integrated_circuit_printer/upgraded
|
||||
upgraded = TRUE
|
||||
@@ -47,7 +47,7 @@
|
||||
if(stack.use(max(1, round(num)))) // We don't want to create stacks that aren't whole numbers
|
||||
to_chat(user, span("notice", "You add [num] sheet\s to \the [src]."))
|
||||
metal += num * metal_per_sheet
|
||||
interact(user)
|
||||
attack_self(user)
|
||||
return TRUE
|
||||
|
||||
if(istype(O,/obj/item/integrated_circuit))
|
||||
@@ -55,7 +55,7 @@
|
||||
user.unEquip(O)
|
||||
metal = min(metal + O.w_class, max_metal)
|
||||
qdel(O)
|
||||
interact(user)
|
||||
attack_self(user)
|
||||
return TRUE
|
||||
|
||||
if(istype(O,/obj/item/weapon/disk/integrated_circuit/upgrade/advanced))
|
||||
@@ -64,7 +64,8 @@
|
||||
return TRUE
|
||||
to_chat(user, span("notice", "You install \the [O] into \the [src]."))
|
||||
upgraded = TRUE
|
||||
interact(user)
|
||||
dirty_items = TRUE
|
||||
attack_self(user)
|
||||
return TRUE
|
||||
|
||||
if(istype(O,/obj/item/weapon/disk/integrated_circuit/upgrade/clone))
|
||||
@@ -73,98 +74,126 @@
|
||||
return TRUE
|
||||
to_chat(user, span("notice", "You install \the [O] into \the [src]."))
|
||||
can_clone = TRUE
|
||||
interact(user)
|
||||
attack_self(user)
|
||||
return TRUE
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/item/device/integrated_circuit_printer/vv_edit_var(var_name, var_value)
|
||||
// Gotta update the static data in case an admin VV's the upgraded var for some reason..!
|
||||
if(var_name == "upgraded")
|
||||
dirty_items = TRUE
|
||||
return ..()
|
||||
|
||||
/obj/item/device/integrated_circuit_printer/attack_self(var/mob/user)
|
||||
interact(user)
|
||||
tgui_interact(user)
|
||||
|
||||
/obj/item/device/integrated_circuit_printer/interact(mob/user)
|
||||
var/window_height = 600
|
||||
var/window_width = 500
|
||||
/obj/item/device/integrated_circuit_printer/tgui_state(mob/user)
|
||||
return GLOB.tgui_inventory_state
|
||||
|
||||
if(isnull(current_category))
|
||||
current_category = SScircuit.circuit_fabricator_recipe_list[1]
|
||||
/obj/item/device/integrated_circuit_printer/tgui_interact(mob/user, datum/tgui/ui)
|
||||
if(dirty_items)
|
||||
update_tgui_static_data(user, ui)
|
||||
dirty_items = FALSE
|
||||
|
||||
var/HTML = "<center><h2>Integrated Circuit Printer</h2></center><br>"
|
||||
if(!debug)
|
||||
HTML += "Metal: [metal/metal_per_sheet]/[max_metal/metal_per_sheet] sheets.<br>"
|
||||
else
|
||||
HTML += "Metal: INFINITY.<br>"
|
||||
HTML += "Circuits available: [upgraded ? "Advanced":"Regular"].<br>"
|
||||
HTML += "Assembly Cloning: [can_clone ? "Available": "Unavailable"].<br>"
|
||||
if(assembly_to_clone)
|
||||
HTML += "Assembly '[assembly_to_clone.name]' loaded.<br>"
|
||||
HTML += "Crossed out circuits mean that the printer is not sufficentally upgraded to create that circuit.<br>"
|
||||
HTML += "<hr>"
|
||||
HTML += "Categories:"
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "ICPrinter", name) // 500, 600
|
||||
ui.open()
|
||||
|
||||
/obj/item/device/integrated_circuit_printer/tgui_static_data(mob/user)
|
||||
var/list/data = ..()
|
||||
|
||||
var/list/categories = list()
|
||||
for(var/category in SScircuit.circuit_fabricator_recipe_list)
|
||||
if(category != current_category)
|
||||
HTML += " <a href='?src=\ref[src];category=[category]'>\[[category]\]</a> "
|
||||
else // Bold the button if it's already selected.
|
||||
HTML += " <b>\[[category]\]</b> "
|
||||
HTML += "<hr>"
|
||||
HTML += "<center><h4>[current_category]</h4></center>"
|
||||
var/list/cat_obj = list(
|
||||
"name" = category,
|
||||
"items" = list()
|
||||
)
|
||||
var/list/circuit_list = SScircuit.circuit_fabricator_recipe_list[category]
|
||||
for(var/path in circuit_list)
|
||||
var/obj/O = path
|
||||
var/can_build = TRUE
|
||||
if(ispath(path, /obj/item/integrated_circuit))
|
||||
var/obj/item/integrated_circuit/IC = path
|
||||
if((initial(IC.spawn_flags) & IC_SPAWN_RESEARCH) && (!(initial(IC.spawn_flags) & IC_SPAWN_DEFAULT)) && !upgraded)
|
||||
can_build = FALSE
|
||||
|
||||
var/list/current_list = SScircuit.circuit_fabricator_recipe_list[current_category]
|
||||
for(var/path in current_list)
|
||||
var/obj/O = path
|
||||
var/can_build = TRUE
|
||||
if(ispath(path, /obj/item/integrated_circuit))
|
||||
var/obj/item/integrated_circuit/IC = path
|
||||
if((initial(IC.spawn_flags) & IC_SPAWN_RESEARCH) && (!(initial(IC.spawn_flags) & IC_SPAWN_DEFAULT)) && !upgraded)
|
||||
can_build = FALSE
|
||||
if(can_build)
|
||||
HTML += "<A href='?src=\ref[src];build=[path]'>\[[initial(O.name)]\]</A>: [initial(O.desc)]<br>"
|
||||
else
|
||||
HTML += "<s>\[[initial(O.name)]\]</s>: [initial(O.desc)]<br>"
|
||||
var/cost = 1
|
||||
if(ispath(path, /obj/item/device/electronic_assembly))
|
||||
var/obj/item/device/electronic_assembly/E = path
|
||||
cost = round((initial(E.max_complexity) + initial(E.max_components)) / 4)
|
||||
else
|
||||
var/obj/item/I = path
|
||||
cost = initial(I.w_class)
|
||||
|
||||
user << browse(jointext(HTML, null), "window=integrated_printer;size=[window_width]x[window_height];border=1;can_resize=1;can_close=1;can_minimize=1")
|
||||
cat_obj["items"].Add(list(list(
|
||||
"name" = initial(O.name),
|
||||
"desc" = initial(O.desc),
|
||||
"can_build" = can_build,
|
||||
"cost" = cost,
|
||||
"path" = path,
|
||||
)))
|
||||
categories.Add(list(cat_obj))
|
||||
data["categories"] = categories
|
||||
|
||||
return data
|
||||
|
||||
/obj/item/device/integrated_circuit_printer/Topic(href, href_list)
|
||||
/obj/item/device/integrated_circuit_printer/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
|
||||
var/list/data = ..()
|
||||
|
||||
data["metal"] = metal
|
||||
data["max_metal"] = max_metal
|
||||
data["metal_per_sheet"] = metal_per_sheet
|
||||
data["debug"] = debug
|
||||
data["upgraded"] = upgraded
|
||||
data["can_clone"] = can_clone
|
||||
data["assembly_to_clone"] = assembly_to_clone
|
||||
|
||||
return data
|
||||
|
||||
/obj/item/device/integrated_circuit_printer/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
|
||||
if(..())
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
add_fingerprint(usr)
|
||||
|
||||
if(href_list["category"])
|
||||
current_category = href_list["category"]
|
||||
|
||||
if(href_list["build"])
|
||||
var/build_type = text2path(href_list["build"])
|
||||
if(!build_type || !ispath(build_type))
|
||||
return 1
|
||||
|
||||
var/cost = 1
|
||||
|
||||
if(isnull(current_category))
|
||||
current_category = SScircuit.circuit_fabricator_recipe_list[1]
|
||||
if(ispath(build_type, /obj/item/device/electronic_assembly))
|
||||
var/obj/item/device/electronic_assembly/E = build_type
|
||||
cost = round( (initial(E.max_complexity) + initial(E.max_components) ) / 4)
|
||||
else
|
||||
var/obj/item/I = build_type
|
||||
cost = initial(I.w_class)
|
||||
if(!(build_type in SScircuit.circuit_fabricator_recipe_list[current_category]))
|
||||
return
|
||||
|
||||
if(!debug)
|
||||
if(!Adjacent(usr))
|
||||
to_chat(usr, "<span class='notice'>You are too far away from \the [src].</span>")
|
||||
if(metal - cost < 0)
|
||||
to_chat(usr, "<span class='warning'>You need [cost] metal to build that!.</span>")
|
||||
switch(action)
|
||||
if("build")
|
||||
var/build_type = text2path(params["build"])
|
||||
if(!build_type || !ispath(build_type))
|
||||
return 1
|
||||
metal -= cost
|
||||
var/obj/item/built = new build_type(get_turf(loc))
|
||||
usr.put_in_hands(built)
|
||||
to_chat(usr, "<span class='notice'>[capitalize(built.name)] printed.</span>")
|
||||
playsound(src, 'sound/items/jaws_pry.ogg', 50, TRUE)
|
||||
|
||||
interact(usr)
|
||||
var/cost = 1
|
||||
|
||||
if(ispath(build_type, /obj/item/device/electronic_assembly))
|
||||
var/obj/item/device/electronic_assembly/E = build_type
|
||||
cost = round( (initial(E.max_complexity) + initial(E.max_components) ) / 4)
|
||||
else
|
||||
var/obj/item/I = build_type
|
||||
cost = initial(I.w_class)
|
||||
|
||||
var/in_some_category = FALSE
|
||||
for(var/category in SScircuit.circuit_fabricator_recipe_list)
|
||||
if(build_type in SScircuit.circuit_fabricator_recipe_list[category])
|
||||
in_some_category = TRUE
|
||||
break
|
||||
if(!in_some_category)
|
||||
return
|
||||
|
||||
if(!debug)
|
||||
if(!Adjacent(usr))
|
||||
to_chat(usr, "<span class='notice'>You are too far away from \the [src].</span>")
|
||||
if(metal - cost < 0)
|
||||
to_chat(usr, "<span class='warning'>You need [cost] metal to build that!.</span>")
|
||||
return 1
|
||||
metal -= cost
|
||||
var/obj/item/built = new build_type(get_turf(loc))
|
||||
usr.put_in_hands(built)
|
||||
to_chat(usr, "<span class='notice'>[capitalize(built.name)] printed.</span>")
|
||||
playsound(src, 'sound/items/jaws_pry.ogg', 50, TRUE)
|
||||
return TRUE
|
||||
|
||||
// FUKKEN UPGRADE DISKS
|
||||
/obj/item/weapon/disk/integrated_circuit/upgrade
|
||||
|
||||
Reference in New Issue
Block a user