mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-08-29 08:09:34 +01:00
Updates Part Three
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
var/required_access = null // List of required accesses to *run* the program.
|
||||
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/running = 0 // Set to 1 when the program is run and back to 0 when it's stopped.
|
||||
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.
|
||||
@@ -96,13 +96,13 @@
|
||||
NM.program = src // Set the program reference to separate variable, instead.
|
||||
if(requires_ntnet && network_destination)
|
||||
generate_network_log("Connection opened to [network_destination].")
|
||||
running = 1
|
||||
program_state = PROGRAM_STATE_ACTIVE
|
||||
return 1
|
||||
return 0
|
||||
|
||||
// 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)
|
||||
running = 0
|
||||
program_state = PROGRAM_STATE_KILLED
|
||||
if(network_destination)
|
||||
generate_network_log("Connection to [network_destination] closed.")
|
||||
if(NM)
|
||||
@@ -113,7 +113,7 @@
|
||||
// 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.
|
||||
/datum/computer_file/program/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(!running) // Our program was closed. Close the ui if it exists.
|
||||
if(program_state != PROGRAM_STATE_ACTIVE) // Our program was closed. Close the ui if it exists.
|
||||
if(ui)
|
||||
ui.close()
|
||||
return computer.ui_interact(user)
|
||||
@@ -129,6 +129,7 @@
|
||||
// Calls beginning with "PC_" are reserved for computer handling (by whatever runs the program)
|
||||
// ALWAYS INCLUDE PARENT CALL ..() OR DIE IN FIRE.
|
||||
/datum/computer_file/program/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
if(computer)
|
||||
computer.Topic(href, href_list)
|
||||
..()
|
||||
return computer.Topic(href, href_list)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Events are sent to the program by the computer.
|
||||
// Always include a parent call when overriding an event.
|
||||
|
||||
// Called when the ID card is removed from computer. ID is removed AFTER this proc.
|
||||
/datum/computer_file/program/proc/event_idremoved(var/background)
|
||||
return
|
||||
|
||||
// Called when the computer fails due to power loss. Override when program wants to specifically react to power loss.
|
||||
/datum/computer_file/program/proc/event_powerfailure(var/background)
|
||||
kill_program(1)
|
||||
|
||||
// Called when the network connectivity fails. Computer does necessary checks and only calls this when requires_ntnet_feature and similar variables are not met.
|
||||
/datum/computer_file/program/proc/event_networkfailure(var/background)
|
||||
kill_program(1)
|
||||
if(background)
|
||||
computer.visible_message("<span class='danger'>\The [computer]'s screen displays an \"Process [filename].[filetype] (PID [rand(100,999)]) terminated - Network Error\" error</span>")
|
||||
else
|
||||
computer.visible_message("<span class='danger'>\The [computer]'s screen briefly freezes and then shows \"NETWORK ERROR - NTNet connection lost. Please retry. If problem persists contact your system administrator.\" error.</span>")
|
||||
@@ -6,10 +6,28 @@
|
||||
nanomodule_path = /datum/nano_module/power_monitor/
|
||||
program_icon_state = "power_monitor"
|
||||
extended_desc = "This program connects to sensors around the station to provide information about electrical systems"
|
||||
ui_header = "power_norm.gif"
|
||||
required_access = access_engine
|
||||
requires_ntnet = 1
|
||||
network_destination = "power monitoring system"
|
||||
size = 9
|
||||
var/has_alert = 0
|
||||
|
||||
/datum/computer_file/program/power_monitor/process_tick()
|
||||
..()
|
||||
var/datum/nano_module/power_monitor/NMA = NM
|
||||
if(istype(NMA) && NMA.has_alarm())
|
||||
if(!has_alert)
|
||||
program_icon_state = "power_monitor_warn"
|
||||
ui_header = "power_warn.gif"
|
||||
update_computer_icon()
|
||||
has_alert = 1
|
||||
else
|
||||
if(has_alert)
|
||||
program_icon_state = "power_monitor"
|
||||
ui_header = "power_norm.gif"
|
||||
update_computer_icon()
|
||||
has_alert = 0
|
||||
|
||||
/datum/computer_file/program/alarm_monitor
|
||||
filename = "alarmmonitor"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
dos_speed = NTNETSPEED_ETHERNET * 10
|
||||
if(target && executed)
|
||||
target.dos_overload += dos_speed
|
||||
if(target.is_operational())
|
||||
if(!target.is_operational())
|
||||
target.dos_sources.Remove(src)
|
||||
target = null
|
||||
error = "Connection to destination relay lost."
|
||||
@@ -89,8 +89,9 @@
|
||||
target = R
|
||||
return
|
||||
if(href_list["PRG_reset"])
|
||||
target.dos_sources.Remove(src)
|
||||
target = null
|
||||
if(target)
|
||||
target.dos_sources.Remove(src)
|
||||
target = null
|
||||
executed = 0
|
||||
error = ""
|
||||
return
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
ui.auto_update_layout = 1
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
ui.set_auto_update(0)
|
||||
|
||||
/datum/nano_module/card_mod/proc/format_jobs(list/jobs)
|
||||
var/obj/item/weapon/card/id/id_card = program.computer.card_slot.stored_card
|
||||
|
||||
@@ -16,25 +16,17 @@
|
||||
|
||||
/datum/nano_module/computer_configurator
|
||||
name = "NTOS Computer Configuration Tool"
|
||||
var/obj/machinery/modular_computer/stationary = null
|
||||
var/obj/item/modular_computer/movable = null
|
||||
|
||||
/datum/nano_module/computer_configurator/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = default_state)
|
||||
if(program)
|
||||
stationary = program.computer
|
||||
movable = program.computer
|
||||
|
||||
if(!istype(stationary))
|
||||
stationary = null
|
||||
if(!istype(movable))
|
||||
movable = null
|
||||
|
||||
if(istype(movable, /obj/item/modular_computer/processor))
|
||||
var/obj/item/modular_computer/processor/P = movable
|
||||
stationary = P.machinery_computer
|
||||
|
||||
// No computer connection, we can't get data from that.
|
||||
if(!movable && !stationary)
|
||||
if(!movable)
|
||||
return 0
|
||||
|
||||
var/list/data = list()
|
||||
@@ -42,27 +34,15 @@
|
||||
if(program)
|
||||
data = program.get_header_data()
|
||||
|
||||
var/list/hardware = list()
|
||||
if(stationary)
|
||||
if(stationary.cpu)
|
||||
movable = stationary.cpu
|
||||
hardware.Add(stationary.tesla_link)
|
||||
else
|
||||
return
|
||||
var/list/hardware = movable.get_all_components()
|
||||
|
||||
if(movable)
|
||||
hardware.Add(movable.network_card)
|
||||
hardware.Add(movable.hard_drive)
|
||||
hardware.Add(movable.card_slot)
|
||||
hardware.Add(movable.nano_printer)
|
||||
hardware.Add(movable.battery_module)
|
||||
data["disk_size"] = movable.hard_drive.max_capacity
|
||||
data["disk_used"] = movable.hard_drive.used_capacity
|
||||
data["power_usage"] = movable.last_power_usage
|
||||
data["battery_exists"] = movable.battery_module ? 1 : 0
|
||||
if(movable.battery_module)
|
||||
data["battery_rating"] = movable.battery_module.battery.maxcharge
|
||||
data["battery_percent"] = round(movable.battery_module.battery.percent())
|
||||
data["disk_size"] = movable.hard_drive.max_capacity
|
||||
data["disk_used"] = movable.hard_drive.used_capacity
|
||||
data["power_usage"] = movable.last_power_usage
|
||||
data["battery_exists"] = movable.battery_module ? 1 : 0
|
||||
if(movable.battery_module)
|
||||
data["battery_rating"] = movable.battery_module.battery.maxcharge
|
||||
data["battery_percent"] = round(movable.battery_module.battery.percent())
|
||||
|
||||
var/list/all_entries[0]
|
||||
for(var/obj/item/weapon/computer_hardware/H in hardware)
|
||||
@@ -81,4 +61,4 @@
|
||||
ui.auto_update_layout = 1
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
ui.set_auto_update(0)
|
||||
@@ -223,5 +223,5 @@
|
||||
ui.auto_update_layout = 1
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
ui.set_auto_update(0)
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
|
||||
/datum/computer_file/program/chatclient/process_tick()
|
||||
..()
|
||||
if(running)
|
||||
if(program_state != PROGRAM_STATE_KILLED)
|
||||
ui_header = "ntnrc_idle.gif"
|
||||
if(channel)
|
||||
// Remember the last message. If there is no message in the channel remember null.
|
||||
|
||||
Reference in New Issue
Block a user