mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-26 01:52:15 +00:00
Major update
- Renames some files, tidies up some of the code - Adds forceMove() and Topic() sanity checks from github suggestions - Properly implements tablets, usage flags and portable devices in general. For now, adds codersprites (final release will have actual sprites) - Fixes some bugs - Assigns file sizes to programs
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
// This is mostly modified copypaste of modular_computer.dm. It is necessary as
|
||||
// modular_computer MUST stay as machinery subtype, while this must be an item subtype
|
||||
// as it's portable.
|
||||
|
||||
/obj/item/modular_computer
|
||||
name = "Modular Microcomputer"
|
||||
desc = "A small portable microcomputer"
|
||||
@@ -10,6 +9,7 @@
|
||||
var/enabled = 1 // Whether the computer is turned on.
|
||||
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
|
||||
|
||||
// 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
|
||||
@@ -56,26 +56,41 @@
|
||||
user << "There is no card in \the [src]"
|
||||
return
|
||||
|
||||
card_slot.stored_card.loc = src.loc
|
||||
card_slot.stored_card.forceMove(get_turf(src))
|
||||
card_slot.stored_card = null
|
||||
user << "You remove the card from \the [src]"
|
||||
|
||||
// TODO: Convert hardware creation specific stuff to vending machine that handles laptops.
|
||||
/obj/item/modular_computer/New()
|
||||
network_card = new(src)
|
||||
hard_drive = new(src)
|
||||
battery = new(src)
|
||||
battery.maxcharge = 1000
|
||||
battery.charge = 1000
|
||||
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/alarm_monitor(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/power_monitor(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/atmos_control(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/rcon_console(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/suit_sensors(src))
|
||||
processing_objects.Add(src)
|
||||
update_icon()
|
||||
..()
|
||||
|
||||
/obj/item/modular_computer/Destroy()
|
||||
processing_objects.Remove(src)
|
||||
if(network_card)
|
||||
qdel(network_card)
|
||||
if(hard_drive)
|
||||
qdel(hard_drive)
|
||||
if(battery)
|
||||
qdel(battery)
|
||||
if(nano_printer)
|
||||
qdel(nano_printer)
|
||||
if(card_slot)
|
||||
qdel(card_slot)
|
||||
..()
|
||||
|
||||
/obj/item/modular_computer/update_icon()
|
||||
icon_state = icon_state_unpowered
|
||||
|
||||
overlays.Cut()
|
||||
if(!enabled)
|
||||
return
|
||||
if(active_program)
|
||||
overlays.Add(active_program.program_icon_state ? active_program.program_icon_state : icon_state_menu)
|
||||
else
|
||||
overlays.Add(icon_state_menu)
|
||||
|
||||
// Operates NanoUI
|
||||
/obj/item/modular_computer/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(!open || !enabled)
|
||||
@@ -119,7 +134,7 @@
|
||||
ui.set_auto_update(1)
|
||||
|
||||
// On-click handling. Turns on the computer if it's off and opens the GUI.
|
||||
/obj/item/modular_computer/attack_hand(mob/user)
|
||||
/obj/item/modular_computer/attack_self(mob/user)
|
||||
if(enabled)
|
||||
ui_interact(user)
|
||||
else if(battery && battery.charge) // Battery-run and charged or non-battery but powered by APC.
|
||||
@@ -179,6 +194,14 @@
|
||||
data["PC_showexitprogram"] = active_program ? 1 : 0 // Hides "Exit Program" button on mainscreen
|
||||
return data
|
||||
|
||||
// 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/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))
|
||||
hard_drive.store_file(new/datum/computer_file/program/rcon_console(src))
|
||||
hard_drive.store_file(new/datum/computer_file/program/suit_sensors(src))
|
||||
|
||||
// Relays kill program request to currently active program. Use this to quit current program.
|
||||
/obj/item/modular_computer/proc/kill_program(var/forced = 0)
|
||||
@@ -199,6 +222,8 @@
|
||||
|
||||
// Handles user's GUI input
|
||||
/obj/item/modular_computer/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
if( href_list["PC_exit"] )
|
||||
kill_program()
|
||||
return
|
||||
@@ -219,6 +244,9 @@
|
||||
user << "<span class='danger'>\The [src]'s screen shows \"I/O ERROR - Unable to run program\" warning.</span>"
|
||||
return
|
||||
|
||||
if(!P.is_supported_by_hardware(hardware_flag, 1, user))
|
||||
return
|
||||
|
||||
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature)) // The program requires NTNet connection, but we are not connected to NTNet.
|
||||
user << "<span class='danger'>\The [src]'s screen shows \"NETWORK ERROR - Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning.</span>"
|
||||
return
|
||||
@@ -249,7 +277,7 @@
|
||||
power_usage += hard_drive.power_usage
|
||||
|
||||
if(battery)
|
||||
battery.use(power_usage)
|
||||
battery.use(power_usage * CELLRATE)
|
||||
|
||||
/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.
|
||||
@@ -263,7 +291,7 @@
|
||||
return
|
||||
|
||||
card_slot.stored_card = I
|
||||
I.loc = src
|
||||
I.forceMove(src)
|
||||
user << "You insert \the [I] into \the [src]."
|
||||
return
|
||||
|
||||
7
code/modules/modular_computers/computers/item/tablet.dm
Normal file
7
code/modules/modular_computers/computers/item/tablet.dm
Normal file
@@ -0,0 +1,7 @@
|
||||
/obj/item/modular_computer/tablet
|
||||
name = "tablet computer"
|
||||
icon = 'icons/obj/modular_tablet.dmi'
|
||||
icon_state = "tablet"
|
||||
icon_state_unpowered = "tablet"
|
||||
icon_state_menu = "menu"
|
||||
hardware_flag = PROGRAM_TABLET
|
||||
@@ -9,15 +9,17 @@
|
||||
var/datum/computer_file/program/active_program = null // A currently active program running on the computer.
|
||||
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
|
||||
|
||||
// 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.
|
||||
|
||||
icon = 'icons/obj/computer.dmi'
|
||||
icon_state = "laptop-open"
|
||||
icon = null
|
||||
icon_state = null
|
||||
var/icon_state_unpowered = null // Icon state when the computer is turned off
|
||||
var/icon_state_menu = "menu" // Icon state overlay when the computer is turned on, but no program is loaded that would override the screen.
|
||||
var/screen_icon_state_menu = "menu" // Icon state overlay when the computer is turned on, but no program is loaded that would override the screen.
|
||||
var/keyboard_icon_state_menu = "keyboard1" // Keyboard's icon state overlay when the computer is turned on and no program is loaded
|
||||
|
||||
// Important hardware (must be installed for computer to work)
|
||||
var/datum/computer_hardware/network_card/network_card // Network Card component of this computer. Allows connection to NTNet
|
||||
@@ -29,6 +31,18 @@
|
||||
var/datum/computer_hardware/nano_printer/nano_printer // Nano Printer component of this computer, for your everyday paperwork needs.
|
||||
|
||||
|
||||
/obj/machinery/modular_computer/update_icon()
|
||||
icon_state = icon_state_unpowered
|
||||
|
||||
overlays.Cut()
|
||||
if(!enabled)
|
||||
return
|
||||
if(active_program)
|
||||
overlays.Add(active_program.program_icon_state ? active_program.program_icon_state : screen_icon_state_menu)
|
||||
overlays.Add(active_program.keyboard_icon_state ? active_program.keyboard_icon_state : keyboard_icon_state_menu)
|
||||
else
|
||||
overlays.Add(screen_icon_state_menu)
|
||||
overlays.Add(keyboard_icon_state_menu)
|
||||
|
||||
// Eject ID card from computer, if it has ID slot with card inside.
|
||||
/obj/machinery/modular_computer/verb/eject_id()
|
||||
@@ -58,27 +72,18 @@
|
||||
user << "There is no card in \the [src]"
|
||||
return
|
||||
|
||||
card_slot.stored_card.loc = src.loc
|
||||
card_slot.stored_card.forceMove(src.loc)
|
||||
card_slot.stored_card = null
|
||||
user << "You remove the card from \the [src]"
|
||||
|
||||
|
||||
// TODO: Convert hardware creation specific stuff to vending machine that handles laptops.
|
||||
/obj/machinery/modular_computer/New()
|
||||
network_card = new(src)
|
||||
hard_drive = new(src)
|
||||
tesla_link = new(src)
|
||||
battery = new(src)
|
||||
battery.maxcharge = 500
|
||||
battery.charge = 500
|
||||
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/alarm_monitor(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/power_monitor(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/atmos_control(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/rcon_console(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/suit_sensors(src))
|
||||
update_icon()
|
||||
..()
|
||||
// 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/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))
|
||||
hard_drive.store_file(new/datum/computer_file/program/rcon_console(src))
|
||||
hard_drive.store_file(new/datum/computer_file/program/suit_sensors(src))
|
||||
|
||||
// Operates NanoUI
|
||||
/obj/machinery/modular_computer/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
@@ -209,6 +214,8 @@
|
||||
|
||||
// Handles user's GUI input
|
||||
/obj/machinery/modular_computer/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
if( href_list["PC_exit"] )
|
||||
kill_program()
|
||||
return
|
||||
@@ -229,6 +236,9 @@
|
||||
user << "<span class='danger'>\The [src]'s screen shows \"I/O ERROR - Unable to run program\" warning.</span>"
|
||||
return
|
||||
|
||||
if(!P.is_supported_by_hardware(hardware_flag, 1, user))
|
||||
return
|
||||
|
||||
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature)) // The program requires NTNet connection, but we are not connected to NTNet.
|
||||
user << "<span class='danger'>\The [src]'s screen shows \"NETWORK ERROR - Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning.</span>"
|
||||
return
|
||||
@@ -301,7 +311,7 @@
|
||||
return
|
||||
|
||||
card_slot.stored_card = I
|
||||
I.loc = src
|
||||
I.forceMove(src)
|
||||
user << "You insert \the [I] into \the [src]."
|
||||
return
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/obj/machinery/modular_computer/console/
|
||||
name = "console"
|
||||
desc = "A stationary computer."
|
||||
enabled = 1
|
||||
|
||||
icon = 'icons/obj/modular_console.dmi'
|
||||
icon_state = "console"
|
||||
icon_state_unpowered = "console"
|
||||
screen_icon_state_menu = "menu"
|
||||
keyboard_icon_state_menu = "kb_menu"
|
||||
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
|
||||
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.
|
||||
@@ -29,13 +29,13 @@
|
||||
if(!stored_computer)
|
||||
if(contents.len)
|
||||
for(var/obj/O in contents)
|
||||
O.loc = loc
|
||||
O.forceMove(src.loc)
|
||||
usr << "\The [src] crumbles to pieces."
|
||||
spawn(5)
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
stored_computer.loc = loc
|
||||
stored_computer.forceMove(src.loc)
|
||||
stored_computer.stat &= ~MAINT
|
||||
stored_computer.update_icon()
|
||||
stored_computer.open = 1
|
||||
@@ -57,17 +57,6 @@
|
||||
icon = 'icons/obj/modular_laptop.dmi'
|
||||
icon_state = "laptop-open"
|
||||
|
||||
/obj/machinery/modular_computer/laptop/update_icon()
|
||||
icon_state = icon_state_unpowered
|
||||
|
||||
overlays.Cut()
|
||||
if(!enabled)
|
||||
return
|
||||
if(active_program)
|
||||
overlays.Add(active_program.program_icon_state ? active_program.program_icon_state : icon_state_menu)
|
||||
else
|
||||
overlays.Add(icon_state_menu)
|
||||
|
||||
// Close the computer. collapsing it into movable item that can't be used.
|
||||
/obj/machinery/modular_computer/laptop/verb/close_computer()
|
||||
set name = "Close Laptop"
|
||||
@@ -94,8 +83,8 @@
|
||||
portable=new
|
||||
portable.stored_computer = src
|
||||
|
||||
portable.loc = loc
|
||||
loc = portable
|
||||
portable.forceMove(src.loc)
|
||||
src.forceMove(portable)
|
||||
stat |= MAINT
|
||||
if(user)
|
||||
user << "You close \the [src]."
|
||||
@@ -1,33 +0,0 @@
|
||||
/obj/machinery/modular_computer/console/
|
||||
name = "console"
|
||||
desc = "A stationary computer."
|
||||
enabled = 1
|
||||
icon = 'icons/obj/modular_console.dmi'
|
||||
icon_state = "console"
|
||||
icon_state_unpowered = "console"
|
||||
icon_state_menu = "menu"
|
||||
var/keyboard_icon_state_menu = "keyboard13"
|
||||
battery_powered = 0
|
||||
anchored = 1
|
||||
density = 1
|
||||
|
||||
/obj/machinery/modular_computer/console/New()
|
||||
..()
|
||||
battery = null
|
||||
tesla_link = new/datum/computer_hardware/tesla_link(src)
|
||||
tesla_link.enabled = 1
|
||||
hard_drive = new/datum/computer_hardware/hard_drive/super(src) // Consoles generally have better HDDs due to lower space limitations
|
||||
|
||||
|
||||
/obj/machinery/modular_computer/console/update_icon()
|
||||
icon_state = icon_state_unpowered
|
||||
|
||||
overlays.Cut()
|
||||
if(!enabled)
|
||||
return
|
||||
if(active_program)
|
||||
overlays.Add(active_program.program_icon_state ? active_program.program_icon_state : icon_state_menu)
|
||||
overlays.Add(active_program.keyboard_icon_state ? active_program.keyboard_icon_state : keyboard_icon_state_menu)
|
||||
else
|
||||
overlays.Add(icon_state_menu)
|
||||
overlays.Add(keyboard_icon_state_menu)
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 682 B After Width: | Height: | Size: 818 B |
Reference in New Issue
Block a user