yet another batch. MAJOR: APC

This commit is contained in:
Letter N
2020-07-30 12:54:53 +08:00
parent 5d4bb48628
commit 0805265412
20 changed files with 298 additions and 365 deletions
@@ -3,7 +3,7 @@
ui_interact(user)
// Operates TGUI
/obj/item/modular_computer/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
/obj/item/modular_computer/ui_interact(mob/user, datum/tgui/ui)
if(!enabled)
if(ui)
ui.close()
@@ -14,7 +14,7 @@
return 0
// Robots don't really need to see the screen, their wireless connection works as long as computer is on.
if(!screen_on && !hasSiliconAccessInArea(user))
if(!screen_on && !issilicon(user))
if(ui)
ui.close()
return 0
@@ -33,19 +33,17 @@
to_chat(user, "<span class='danger'>\The [src] beeps three times, it's screen displaying a \"DISK ERROR\" warning.</span>")
return // No HDD, No HDD files list or no stored files. Something is very broken.
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
ui = SStgui.try_update_ui(user, src, ui)
if (!ui)
var/datum/asset/assets = get_asset_datum(/datum/asset/simple/headers)
assets.send(user)
assets = get_asset_datum(/datum/asset/simple/arcade)
assets.send(user)
ui = new(user, src, ui_key, "NtosMain", "NtOS Main menu", 400, 500, master_ui, state)
ui = new(user, src, "NtosMain")
ui.set_autoupdate(TRUE)
ui.open()
ui.set_autoupdate(state = 1)
ui.send_asset(get_asset_datum(/datum/asset/simple/headers))
/obj/item/modular_computer/ui_data(mob/user)
var/list/data = get_header_data()
data["device_theme"] = device_theme
data["programs"] = list()
var/obj/item/computer_hardware/hard_drive/hard_drive = all_components[MC_HDD]
for(var/datum/computer_file/program/P in hard_drive.stored_files)
@@ -143,6 +141,7 @@
set_light(comp_light_luminosity, 1, comp_light_color)
else
set_light(0)
return TRUE
if("PC_light_color")
var/mob/user = usr
@@ -31,15 +31,10 @@
var/available_on_ntnet = 1
/// Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to 1 to enable.
var/available_on_syndinet = 0
/// ID of TGUI interface
/// Name of the tgui interface
var/tgui_id
/// Default size of TGUI window, in pixels
var/ui_x = 575
var/ui_y = 700
/// Example: "something.gif" - a header image that will be rendered in computer's UI when this program is running at background. Images are taken from /icons/program_icons. Be careful not to use too large images!
var/ui_header = null
///Assets specific to programs
var/list/special_assets = list()
/datum/computer_file/program/New(obj/item/modular_computer/comp = null)
..()
@@ -69,12 +64,12 @@
/datum/computer_file/program/proc/generate_network_log(text)
if(computer)
return computer.add_log(text)
return FALSE
return 0
/datum/computer_file/program/proc/is_supported_by_hardware(hardware_flag = 0, loud = 0, mob/user = null)
if(!(hardware_flag & usage_flags))
if(loud && computer && user)
to_chat(user, "<span class='danger'>\The [computer] flashes an \"Hardware Error - Incompatible software\" warning.</span>")
to_chat(user, "<span class='danger'>\The [computer] flashes a \"Hardware Error - Incompatible software\" warning.</span>")
return FALSE
return TRUE
@@ -143,13 +138,27 @@
// This is performed on program startup. May be overridden to add extra logic. Remember to include ..() call. Return 1 on success, 0 on failure.
// When implementing new program based device, use this to run the program.
/datum/computer_file/program/proc/run_program(mob/living/user)
if(can_run(user, TRUE))
if(can_run(user, 1))
if(requires_ntnet && network_destination)
generate_network_log("Connection opened to [network_destination].")
program_state = PROGRAM_STATE_ACTIVE
return TRUE
return FALSE
/**
*
*Called by the device when it is emagged.
*
*Emagging the device allows certain programs to unlock new functions. However, the program will
*need to be downloaded first, and then handle the unlock on their own in their run_emag() proc.
*The device will allow an emag to be run multiple times, so the user can re-emag to run the
*override again, should they download something new. The run_emag() proc should return TRUE if
*the emagging affected anything, and FALSE if no change was made (already emagged, or has no
*emag functions).
**/
/datum/computer_file/program/proc/run_emag()
return FALSE
// Use this proc to kill the program. Designed to be implemented by each program if it requires on-quit logic, such as the NTNRC client.
/datum/computer_file/program/proc/kill_program(forced = FALSE)
program_state = PROGRAM_STATE_KILLED
@@ -157,18 +166,12 @@
generate_network_log("Connection to [network_destination] closed.")
return TRUE
/datum/computer_file/program/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
/datum/computer_file/program/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui && tgui_id)
var/datum/asset/assets = get_asset_datum(/datum/asset/simple/headers)
assets.send(user)
for(var/i in special_assets)
assets = get_asset_datum(i)
assets.send(user)
ui = new(user, src, ui_key, tgui_id, filedesc, ui_x, ui_y, state = state)
ui = new(user, src, tgui_id, filedesc)
ui.open()
ui.send_asset(get_asset_datum(/datum/asset/simple/headers))
// CONVENTIONS, READ THIS WHEN CREATING NEW PROGRAM AND OVERRIDING THIS PROC:
// Topic calls are automagically forwarded from NanoModule this program contains.
@@ -27,9 +27,6 @@
var/dev_printer = 0 // 0: None, 1: Standard
var/dev_card = 0 // 0: None, 1: Standard
ui_x = 500
ui_y = 400
// Removes all traces of old order and allows you to begin configuration from scratch.
/obj/machinery/lapvend/proc/reset_order()
state = 0
@@ -224,15 +221,15 @@
return TRUE
return FALSE
/obj/machinery/lapvend/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
/obj/machinery/lapvend/ui_interact(mob/user, datum/tgui/ui)
if(stat & (BROKEN | NOPOWER | MAINT))
if(ui)
ui.close()
return FALSE
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
ui = SStgui.try_update_ui(user, src, ui)
if (!ui)
ui = new(user, src, ui_key, "ComputerFabricator", "Personal Computer Vendor", ui_x, ui_y, state = state)
ui = new(user, src, "ComputerFabricator")
ui.open()
/obj/machinery/lapvend/attackby(obj/item/I, mob/user)
@@ -241,7 +238,7 @@
if(!user.temporarilyRemoveItemFromInventory(c))
return
credits += c.value
visible_message("<span class='info'><span class='name'>[user]</span> inserts [c.value] credits into [src].</span>")
visible_message("<span class='info'><span class='name'>[user]</span> inserts [c.value] cr into [src].</span>")
qdel(c)
return
else if(istype(I, /obj/item/holochip))
@@ -257,10 +254,10 @@
var/datum/bank_account/account = ID.registered_account
var/target_credits = total_price - credits
if(!account.adjust_money(-target_credits))
say("Insufficient money on card to purchase!")
say("Insufficient credits on card to purchase!")
return
credits += target_credits
say("[target_credits] cr has been desposited from your account.")
say("[target_credits] cr has been deposited from your account.")
return
return ..()
@@ -308,4 +305,4 @@
state = 3
addtimer(CALLBACK(src, .proc/reset_order), 100)
return TRUE
return FALSE
return FALSE