Configuration Utility + Fixes

- Adds a computer configuration utility program, that is pre-installed on each computer. This program shows detailed component information and offers component toggling possibility.
- Bandaid fix for NanoUI runtimes which seem to be caused by nanoUIs sometimes being somehow opened on null object. Such UI is force-deleted if this happens.
- Programs now have properly defined usage_flags (Note to self: AND is not OR!)
- Minor visual adjustment to buttons in UIs.
This commit is contained in:
Atlantis
2015-08-25 05:26:27 +02:00
parent e6cbd7866d
commit 01c5de790f
13 changed files with 237 additions and 12 deletions
@@ -10,7 +10,7 @@
var/open = 1 // Whether the computer is active/opened/it's screen is on.
var/datum/computer_file/program/active_program = null // A currently active program running on the computer.
var/hardware_flag = 0 // A flag that describes this device type
var/last_power_usage = 0
// Modular computers can run on various devices. Each DEVICE (Laptop, Console, Tablet,..)
// must have it's own DMI file. Icon states must be called exactly the same in all files, but may look differently
// If you create a program which is limited to Laptops and Consoles you don't have to add it's icon_state overlay for Tablets too, for example.
@@ -148,6 +148,7 @@
// Process currently calls handle_power(), may be expanded in future if more things are added.
/obj/item/modular_computer/process()
if(!enabled) // The computer is turned off
last_power_usage = 0
return 0
if(active_program && active_program.requires_ntnet && !get_ntnet_status(active_program.requires_ntnet_feature)) // Active program requires NTNet to run but we've just lost connection. Crash.
@@ -188,6 +189,8 @@
data["PC_ntneticon"] = "sig_low.gif"
if(2)
data["PC_ntneticon"] = "sig_high.gif"
if(3)
data["PC_ntneticon"] = "sig_lan.gif"
data["PC_stationtime"] = worldtime2text()
data["PC_hasheader"] = 1
@@ -197,6 +200,9 @@
// Installs programs necessary for computer function.
// TODO: Implement program for downloading of other programs, and replace hardcoded program addition here
/obj/item/modular_computer/proc/install_default_programs()
hard_drive.store_file(new/datum/computer_file/program/computerconfig(src)) // Computer configuration utility, allows hardware control and displays more info than status bar
//TODO: Remove once downloading is implemented
hard_drive.store_file(new/datum/computer_file/program/alarm_monitor(src))
hard_drive.store_file(new/datum/computer_file/program/power_monitor(src))
hard_drive.store_file(new/datum/computer_file/program/atmos_control(src))
@@ -227,6 +233,16 @@
if( href_list["PC_exit"] )
kill_program()
return
if( href_list["PC_enable_component"] )
var/datum/computer_hardware/H = find_hardware_by_name(href_list["PC_enable_component"])
if(H && istype(H) && !H.enabled)
H.enabled = 1
return
if( href_list["PC_disable_component"] )
var/datum/computer_hardware/H = find_hardware_by_name(href_list["PC_disable_component"])
if(H && istype(H) && H.enabled)
H.enabled = 0
return
if( href_list["PC_shutdown"] )
kill_program(1)
visible_message("\The [src] shuts down.")
@@ -278,6 +294,7 @@
if(battery)
battery.use(power_usage * CELLRATE)
last_power_usage = power_usage
/obj/item/modular_computer/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if(istype(W, /obj/item/weapon/card/id)) // ID Card, try to insert it.
@@ -295,4 +312,16 @@
user << "You insert \the [I] into \the [src]."
return
..()
..()
// Checks all hardware pieces to determine if name matches, if yes, returns the hardware piece, otherwise returns null
/obj/item/modular_computer/proc/find_hardware_by_name(var/name)
if(hard_drive && (hard_drive.name == name))
return hard_drive
if(network_card && (network_card.name == name))
return network_card
if(nano_printer && (nano_printer.name == name))
return nano_printer
if(card_slot && (card_slot.name == name))
return card_slot
return null
@@ -10,6 +10,7 @@
var/battery_powered = 0 // Whether computer should be battery powered. It is set automatically
use_power = 0
var/hardware_flag = 0 // A flag that describes this device type
var/last_power_usage = 0 // Power usage during last tick
// Modular computers can run on various devices. Each DEVICE (Laptop, Console, Tablet,..)
// must have it's own DMI file. Icon states must be called exactly the same in all files, but may look differently
@@ -76,9 +77,16 @@
card_slot.stored_card = null
user << "You remove the card from \the [src]"
/obj/machinery/modular_computer/New()
..()
install_default_programs()
// Installs programs necessary for computer function.
// TODO: Implement program for downloading of other programs, and replace hardcoded program addition here
/obj/machinery/modular_computer/proc/install_default_programs()
hard_drive.store_file(new/datum/computer_file/program/computerconfig(src)) // Computer configuration utility, allows hardware control and displays more info than status bar
//TODO: Remove once downloading is implemented
hard_drive.store_file(new/datum/computer_file/program/alarm_monitor(src))
hard_drive.store_file(new/datum/computer_file/program/power_monitor(src))
hard_drive.store_file(new/datum/computer_file/program/atmos_control(src))
@@ -143,6 +151,7 @@
/obj/machinery/modular_computer/process()
if(!enabled) // The computer is turned off
use_power = 0
last_power_usage = 0
return 0
if(active_program && active_program.requires_ntnet && !get_ntnet_status(active_program.requires_ntnet_feature)) // Active program requires NTNet to run but we've just lost connection. Crash.
@@ -185,6 +194,8 @@
data["PC_ntneticon"] = "sig_low.gif"
if(2)
data["PC_ntneticon"] = "sig_high.gif"
if(3)
data["PC_ntneticon"] = "sig_lan.gif"
if(tesla_link && tesla_link.enabled && powered())
data["PC_apclinkicon"] = "charging.gif"
@@ -212,6 +223,20 @@
else
return 0
// Checks all hardware pieces to determine if name matches, if yes, returns the hardware piece, otherwise returns null
/obj/machinery/modular_computer/proc/find_hardware_by_name(var/name)
if(hard_drive && (hard_drive.name == name))
return hard_drive
if(network_card && (network_card.name == name))
return network_card
if(tesla_link && (tesla_link.name == name))
return tesla_link
if(nano_printer && (nano_printer.name == name))
return nano_printer
if(card_slot && (card_slot.name == name))
return card_slot
return null
// Handles user's GUI input
/obj/machinery/modular_computer/Topic(href, href_list)
if(..())
@@ -219,6 +244,16 @@
if( href_list["PC_exit"] )
kill_program()
return
if( href_list["PC_enable_component"] )
var/datum/computer_hardware/H = find_hardware_by_name(href_list["PC_enable_component"])
if(H && istype(H) && !H.enabled)
H.enabled = 1
return
if( href_list["PC_disable_component"] )
var/datum/computer_hardware/H = find_hardware_by_name(href_list["PC_disable_component"])
if(H && istype(H) && H.enabled)
H.enabled = 0
return
if( href_list["PC_shutdown"] )
kill_program(1)
visible_message("\The [src] shuts down.")
@@ -291,6 +326,7 @@
use_power = 0
if (battery)
battery.use(power_usage * CELLRATE)
last_power_usage = power_usage
// Modular computers can have battery in them, we handle power in previous proc, so prevent this from messing it up for us.
/obj/machinery/modular_computer/power_change()
@@ -8,14 +8,16 @@
icon_state_unpowered = "console"
screen_icon_state_menu = "menu"
keyboard_icon_state_menu = "kb_menu"
hardware_flag = PROGRAM_CONSOLE
anchored = 1
density = 1
/obj/machinery/modular_computer/console/New()
..()
battery = null
network_card = new/datum/computer_hardware/network_card/wired(src)
tesla_link = new/datum/computer_hardware/tesla_link(src)
tesla_link.enabled = 1
tesla_link.critical = 1 // Consoles don't usually come with cells, and this prevents people from disabling their only power source, as they wouldn't be able to enable it again.
hard_drive = new/datum/computer_hardware/hard_drive/super(src) // Consoles generally have better HDDs due to lower space limitations
install_default_programs() // Consoles come with set of department-specific programs when constructed.
..()
update_icon()
@@ -52,7 +52,7 @@
name = "laptop computer"
desc = "A portable computer"
var/obj/item/laptop/portable = null // Portable version of this computer, dropped on alt-click to allow transport. Used by laptops.
battery_powered = 1 // Laptops have integrated battery
hardware_flag = PROGRAM_LAPTOP
icon_state_unpowered = "laptop-open" // Icon state when the computer is turned off
icon = 'icons/obj/modular_laptop.dmi'
icon_state = "laptop-open"