mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-18 19:39:42 +01:00
a small addition
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
// /program/ files are executable programs that do things.
|
||||
/datum/computer_file/program
|
||||
filetype = "PRG"
|
||||
filename = "UnknownProgram" // File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NTNET!
|
||||
var/required_access_run = null // List of required accesses to run the program.
|
||||
var/required_access_download = null // List of required accesses to download the program.
|
||||
var/requires_access_to_run = PROGRAM_ACCESS_ONE // Whether the program checks for required_access when run. (1 = requires single access, 2 = requires single access from list, 3 = requires all access from list)
|
||||
var/requires_access_to_download = PROGRAM_ACCESS_ONE // Whether the program checks for required_access when downloading. (1 = requires single access, 2 = requires single access from list, 3 = requires all access from list)
|
||||
var/datum/nano_module/NM = null // If the program uses NanoModule, put it here and it will be automagically opened. Otherwise implement ui_interact.
|
||||
var/nanomodule_path = null // Path to nanomodule, make sure to set this if implementing new program.
|
||||
var/program_state = PROGRAM_STATE_KILLED// PROGRAM_STATE_KILLED or PROGRAM_STATE_BACKGROUND or PROGRAM_STATE_ACTIVE - specifies whether this program is running.
|
||||
var/obj/item/modular_computer/computer // Device that runs this program.
|
||||
var/filedesc = "Unknown Program" // User-friendly name of this program.
|
||||
var/extended_desc = "N/A" // Short description of this program's function.
|
||||
var/program_icon_state = null // Program-specific screen icon state
|
||||
var/requires_ntnet = 0 // Set to 1 for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes.
|
||||
var/requires_ntnet_feature = 0 // Optional, if above is set to 1 checks for specific function of NTNet (currently NTNET_SOFTWAREDOWNLOAD, NTNET_PEERTOPEER, NTNET_SYSTEMCONTROL and NTNET_COMMUNICATION)
|
||||
var/ntnet_status = 1 // NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc.
|
||||
var/usage_flags = PROGRAM_ALL // Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_TABLET combination) or PROGRAM_ALL
|
||||
var/network_destination = null // Optional string that describes what NTNet server/system this program connects to. Used in default logging.
|
||||
var/available_on_ntnet = 1 // Whether the program can be downloaded from NTNet. Set to 0 to disable.
|
||||
var/available_on_syndinet = 0 // Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to 1 to enable.
|
||||
var/computer_emagged = 0 // Set to 1 if computer that's running us was emagged. Computer updates this every Process() tick
|
||||
var/ui_header = null // 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 /nano/images/status_icons. Be careful not to use too large images!
|
||||
var/color = "#FFFFFF" // The color of light the computer should emit when this program is open.
|
||||
filename = "UnknownProgram" // File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NTNET!
|
||||
var/required_access_run // List of required accesses to run the program.
|
||||
var/required_access_download // List of required accesses to download the program.
|
||||
var/requires_access_to_run = PROGRAM_ACCESS_ONE // Whether the program checks for required_access when run. (1 = requires single access, 2 = requires single access from list, 3 = requires all access from list)
|
||||
var/requires_access_to_download = PROGRAM_ACCESS_ONE // Whether the program checks for required_access when downloading. (1 = requires single access, 2 = requires single access from list, 3 = requires all access from list)
|
||||
var/datum/nano_module/NM // If the program uses NanoModule, put it here and it will be automagically opened. Otherwise implement ui_interact.
|
||||
var/nanomodule_path // Path to nanomodule, make sure to set this if implementing new program.
|
||||
var/program_state = PROGRAM_STATE_KILLED // PROGRAM_STATE_KILLED or PROGRAM_STATE_BACKGROUND or PROGRAM_STATE_ACTIVE - specifies whether this program is running.
|
||||
var/obj/item/modular_computer/computer // Device that runs this program.
|
||||
var/filedesc = "Unknown Program" // User-friendly name of this program.
|
||||
var/extended_desc = "N/A" // Short description of this program's function.
|
||||
var/program_icon_state // Program-specific screen icon state
|
||||
var/requires_ntnet = FALSE // Set to TRUE for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes.
|
||||
var/requires_ntnet_feature = FALSE // Optional, if above is set to TRUE checks for specific function of NTNet (currently NTNET_SOFTWAREDOWNLOAD, NTNET_PEERTOPEER, NTNET_SYSTEMCONTROL and NTNET_COMMUNICATION)
|
||||
var/ntnet_status = TRUE // NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc.
|
||||
var/usage_flags = PROGRAM_ALL // Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_TABLET combination) or PROGRAM_ALL
|
||||
var/network_destination // Optional string that describes what NTNet server/system this program connects to. Used in default logging.
|
||||
var/available_on_ntnet = TRUE // Whether the program can be downloaded from NTNet. Set to 0 to disable.
|
||||
var/available_on_syndinet = FALSE // Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to 1 to enable.
|
||||
var/computer_emagged = FALSE // Set to TRUE if computer that's running us was emagged. Computer updates this every Process() tick
|
||||
var/ui_header // 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 /nano/images/status_icons. Be careful not to use too large images!
|
||||
var/color = "#FFFFFF" // The color of light the computer should emit when this program is open.
|
||||
|
||||
/datum/computer_file/program/New(var/obj/item/modular_computer/comp = null)
|
||||
/datum/computer_file/program/New(var/obj/item/modular_computer/comp)
|
||||
..()
|
||||
if(comp && istype(comp))
|
||||
computer = comp
|
||||
@@ -57,29 +57,29 @@
|
||||
/datum/computer_file/program/proc/generate_network_log(var/text)
|
||||
if(computer)
|
||||
return computer.add_log(text)
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
/datum/computer_file/program/proc/is_supported_by_hardware(var/hardware_flag = 0, var/loud = 0, var/mob/user = null)
|
||||
/datum/computer_file/program/proc/is_supported_by_hardware(var/hardware_flag = 0, var/loud = FALSE, var/mob/user)
|
||||
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>")
|
||||
return 0
|
||||
return 1
|
||||
to_chat(user, SPAN_WARNING("\The [computer] flashes, \"Hardware Error - Incompatible software\"."))
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/datum/computer_file/program/proc/get_signal(var/specific_action = 0)
|
||||
if(computer)
|
||||
return computer.get_ntnet_status(specific_action)
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
// Called by Process() on device that runs us, once every tick.
|
||||
/datum/computer_file/program/proc/process_tick()
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
// Check if the user can run program. Only humans can operate computer. Automatically called in run_program()
|
||||
// User has to wear their ID or have it inhand for ID Scan to work.
|
||||
// Can also be called manually, with optional parameter being access_to_check to scan the user's ID
|
||||
// Check type determines how the access should be checked PROGRAM_ACCESS_ONE, PROGRAM_ACCESS_LIST_ONE, PROGRAM_ACCESS_LIST_ALL
|
||||
/datum/computer_file/program/proc/can_run(var/mob/user, var/loud = 0, var/access_to_check, var/check_type)
|
||||
/datum/computer_file/program/proc/can_run(var/mob/user, var/loud = FALSE, var/access_to_check, var/check_type)
|
||||
// Defaults to required_access_run
|
||||
if(!access_to_check)
|
||||
access_to_check = required_access_run
|
||||
@@ -90,44 +90,43 @@
|
||||
|
||||
// No required_access, allow it.
|
||||
if(!access_to_check || !requires_access_to_run)
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
if(!istype(user))
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
var/obj/item/card/id/I = user.GetIdCard()
|
||||
if(!I)
|
||||
if(loud)
|
||||
to_chat(user, "<span class='danger'>\The [computer] flashes an \"RFID Error - Unable to scan ID\" warning.</span>")
|
||||
return 0
|
||||
to_chat(user, SPAN_WARNING("\The [computer] flashes, \"RFID Error - Unable to scan ID.\"."))
|
||||
return FALSE
|
||||
|
||||
if(check_type == PROGRAM_ACCESS_ONE) //Check for single access
|
||||
if(access_to_check in I.access)
|
||||
return 1
|
||||
return TRUE
|
||||
else if(loud)
|
||||
to_chat(user, "<span class='danger'>\The [computer] flashes an \"Access Denied\" warning.</span>")
|
||||
to_chat(user, SPAN_WARNING("\The [computer] flashes, \"Access Denied.\"."))
|
||||
return FALSE
|
||||
else if(check_type == PROGRAM_ACCESS_LIST_ONE)
|
||||
for(var/check in access_to_check) //Loop through all the accesse's to check
|
||||
if(check in I.access) //Success on first match
|
||||
return 1
|
||||
return TRUE
|
||||
if(loud)
|
||||
to_chat(user, "<span class='danger'>\The [computer] flashes an \"Access Denied\" warning.</span>")
|
||||
to_chat(user, SPAN_WARNING("\The [computer] flashes, \"Access Denied.\"."))
|
||||
else if(check_type == PROGRAM_ACCESS_LIST_ALL)
|
||||
for(var/check in access_to_check) //Loop through all the accesse's to check
|
||||
if(!check in I.access) //Fail on first miss
|
||||
if(loud)
|
||||
to_chat(user, "<span class='danger'>\The [computer] flashes an \"Access Denied\" warning.</span>")
|
||||
return 0
|
||||
to_chat(user, SPAN_WARNING("\The [computer] flashes, \"Access Denied.\"."))
|
||||
return FALSE
|
||||
else // Should never happen - So fail silently
|
||||
return 0
|
||||
|
||||
|
||||
return FALSE
|
||||
|
||||
// Check if the user can run program. Only humans can operate computer. Automatically called in run_program()
|
||||
// User has to wear their ID or have it inhand for ID Scan to work.
|
||||
// Can also be called manually, with optional parameter being access_to_check to scan the user's ID
|
||||
// Check type determines how the access should be checked PROGRAM_ACCESS_ONE, PROGRAM_ACCESS_LIST_ONE, PROGRAM_ACCESS_LIST_ALL
|
||||
/datum/computer_file/program/proc/can_download(var/mob/user, var/loud = 0, var/access_to_check, var/check_type)
|
||||
/datum/computer_file/program/proc/can_download(var/mob/user, var/loud = FALSE, var/access_to_check, var/check_type)
|
||||
// Defaults to required_access_run
|
||||
if(!access_to_check)
|
||||
access_to_check = required_access_download
|
||||
@@ -138,36 +137,38 @@
|
||||
|
||||
// No required_access, allow it.
|
||||
if(!access_to_check || !requires_access_to_download)
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
if(!istype(user))
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
var/obj/item/card/id/I = user.GetIdCard()
|
||||
if(!I)
|
||||
if(loud)
|
||||
to_chat(user, "<span class='danger'>\The [computer] flashes an \"RFID Error - Unable to scan ID\" warning.</span>")
|
||||
return 0
|
||||
to_chat(user, SPAN_WARNING("\The [computer] flashes, \"RFID Error - Unable to scan ID.\"."))
|
||||
return FALSE
|
||||
|
||||
if(check_type == PROGRAM_ACCESS_ONE) //Check for single access
|
||||
if(access_to_check in I.access)
|
||||
return 1
|
||||
return TRUE
|
||||
else if(loud)
|
||||
to_chat(user, "<span class='danger'>\The [computer] flashes an \"Access Denied\" warning.</span>")
|
||||
to_chat(user, SPAN_WARNING("\The [computer] flashes, \"Access Denied.\"."))
|
||||
return FALSE
|
||||
else if(check_type == PROGRAM_ACCESS_LIST_ONE)
|
||||
for(var/check in access_to_check) //Loop through all the accesse's to check
|
||||
if(check in I.access) //Success on first match
|
||||
return 1
|
||||
return TRUE
|
||||
if(loud)
|
||||
to_chat(user, "<span class='danger'>\The [computer] flashes an \"Access Denied\" warning.</span>")
|
||||
to_chat(user, SPAN_WARNING("\The [computer] flashes, \"Access Denied.\"."))
|
||||
return FALSE
|
||||
else if(check_type == PROGRAM_ACCESS_LIST_ALL)
|
||||
for(var/check in access_to_check) //Loop through all the accesse's to check
|
||||
if(!check in I.access) //Fail on first miss
|
||||
if(loud)
|
||||
to_chat(user, "<span class='danger'>\The [computer] flashes an \"Access Denied\" warning.</span>")
|
||||
return 0
|
||||
to_chat(user, SPAN_WARNING("\The [computer] flashes, \"Access Denied.\"."))
|
||||
return FALSE
|
||||
else // Should never happen - So fail silently
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
// This attempts to retrieve header data for NanoUIs. If implementing completely new device of different type than existing ones
|
||||
// always include the device here in this proc. This proc basically relays the request to whatever is running the program.
|
||||
@@ -184,8 +185,8 @@
|
||||
if(requires_ntnet && network_destination)
|
||||
generate_network_log("Connection opened to [network_destination].")
|
||||
program_state = PROGRAM_STATE_ACTIVE
|
||||
return 1
|
||||
return 0
|
||||
return TRUE
|
||||
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(var/forced = 0)
|
||||
@@ -195,7 +196,7 @@
|
||||
if(NM)
|
||||
qdel(NM)
|
||||
NM = null
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
// This is called every tick when the program is enabled. Ensure you do parent call if you override it. If parent returns 1 continue with UI initialisation.
|
||||
// It returns 0 if it can't run or if NanoModule was used instead. I suggest using NanoModules where applicable.
|
||||
@@ -206,8 +207,8 @@
|
||||
return computer.ui_interact(user)
|
||||
if(istype(NM))
|
||||
NM.ui_interact(user, ui_key, null, force_open)
|
||||
return 0
|
||||
return 1
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
|
||||
// CONVENTIONS, READ THIS WHEN CREATING NEW PROGRAM AND OVERRIDING THIS PROC:
|
||||
@@ -217,7 +218,7 @@
|
||||
// ALWAYS INCLUDE PARENT CALL ..() OR DIE IN FIRE.
|
||||
/datum/computer_file/program/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
return TRUE
|
||||
if(computer)
|
||||
return computer.Topic(href, href_list)
|
||||
|
||||
@@ -226,4 +227,4 @@
|
||||
if(NM)
|
||||
return NM.check_eye(user)
|
||||
else
|
||||
return -1
|
||||
return -1
|
||||
Reference in New Issue
Block a user