Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacement of station's consoles with ModPC's apps #2809

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/modules/modular_computers/computers/item/computer_ui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
var/datum/computer_file/program/ai_restorer/airestore_app = locate() in stored_files
if(airestore_app?.stored_card)
data["removable_media"] += "intelliCard"
data["removable_media"] += handle_ui_removable_media_insert(user) // FLUFFY FRONTIER ADD

data["programs"] = list()
for(var/datum/computer_file/program/program in stored_files)
Expand Down Expand Up @@ -207,6 +208,7 @@
if(RemoveID(user))
playsound(src, 'sound/machines/card_slide.ogg', 50)
return TRUE
return handle_ui_removable_media_eject(param, user) // FLUFFFY FRONTIER ADD

if("PC_Imprint_ID")
imprint_id()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
. = ..()
if(!CONFIG_GET(flag/no_default_techweb_link) && !stored_research)
CONNECT_TO_RND_SERVER_ROUNDSTART(stored_research, computer)
handle_rnd_control_install() // FLUFFY FRONTIER ADD

/datum/computer_file/program/science/application_attackby(obj/item/attacking_item, mob/living/user)
if (istype(attacking_item, /obj/item/disk/tech_disk) || istype(attacking_item, /obj/item/disk/design_disk)) return handle_disks_insertion(attacking_item, user) // FLUFFY FRONTTIER ADD
if(!istype(attacking_item, /obj/item/multitool))
return FALSE
var/obj/item/multitool/attacking_tool = attacking_item
if(!QDELETED(attacking_tool.buffer) && istype(attacking_tool.buffer, /datum/techweb))
handle_rnd_control_remove() // FLUFFY FRONTIER ADD
stored_research = attacking_tool.buffer
handle_rnd_control_install() // FLUFFY FRONTIER ADD
return TRUE

/datum/computer_file/program/science/ui_assets(mob/user)
Expand All @@ -57,6 +61,7 @@
"d_disk" = null, //See above.
"locked" = locked,
)
data = handle_disks_ui_data(data) // FLUFFY FRONTIER ADD

// Serialize all nodes to display
for(var/tier in stored_research.tiers)
Expand Down Expand Up @@ -94,6 +99,7 @@
if (locked && action != "toggleLock")
computer.say("Console is locked, cannot perform further actions.")
return TRUE
if (action in list("ejectDisk", "uploadDisk", "loadTech")) return handle_disks_ui_act(action, params) // FLUFFY FRONTIER ADD

switch (action)
if ("toggleLock")
Expand Down
53 changes: 53 additions & 0 deletions tff_modular/modules/all_computers_to_modular_consoles/_helper.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
// May I be cursed, but I am to lazy to copypast atom/allowed() code now
/datum/computer_file/program/proc/allowed(mob/accessor)
var/list/tmp_req_access = computer.req_access
var/list/tmp_req_one_access = computer.req_one_access
computer.req_access = null
computer.req_one_access = run_access
. = computer.allowed(accessor)
computer.req_access = tmp_req_access
computer.req_one_access = tmp_req_one_access
*/
/datum/techweb
// We wanna track not only consoles but NT apps that connected to us too
var/list/datum/computer_file/program/science/apps_accessing = list()

/datum/computer_file/program/proc/can_run_Adjacent(mob/accessor, loud, access_to_check, downloading, list/access)
// TODO: atom/allowed() handles syndie borgs. We - not.
if (can_run(accessor, loud, access_to_check, downloading, access))
return TRUE

// atom/allowed() copycode
var/obj/item/active_item = accessor.get_active_held_item()
var/obj/item/inactive_item = accessor.get_inactive_held_item()
if((active_item && can_run(accessor, loud, access_to_check, downloading, active_item?.GetAccess())) || (inactive_item && can_run(accessor, loud, access_to_check, downloading, inactive_item?.GetAccess())))
return TRUE
else if(ishuman(accessor))
var/mob/living/carbon/human/human_accessor = accessor
if(can_run(accessor, loud, access_to_check, downloading, human_accessor.wear_id?.GetAccess()))
return TRUE
else if(isanimal(accessor))
var/mob/living/simple_animal/animal = accessor
if(can_run(accessor, loud, access_to_check, downloading, animal.access_card?.GetAccess()))
return TRUE
else if(isbrain(accessor))
var/obj/item/mmi/brain_mmi = get(accessor.loc, /obj/item/mmi)
if(brain_mmi && ismecha(brain_mmi.loc))
var/obj/vehicle/sealed/mecha/big_stompy_robot = brain_mmi.loc
return can_run(accessor, loud, access_to_check, downloading, big_stompy_robot.accesses)
return FALSE

// Required access override for disk_binded
/datum/computer_file/program/disk_binded/can_run_Adjacent(mob/accessor, loud, access_to_check, downloading, list/access)
if (!access_to_check && length(download_access))
access_to_check = download_access

return ..()

/datum/computer_file/program/proc/can_run_on_flags_to_text(flags = can_run_on_flags, as_list = FALSE)
if (flags == PROGRAM_ALL)
return as_list ? list("Anything") : "Anything"
else
var/list/supportable = bitfield_to_list(flags, list("Console", "Laptop", "PDA"))
return as_list ? supportable : supportable.Join(" | ")
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/obj/item/computer_console_disk
name = "Encrypted NTnet Modem"
desc = "Contains software which allows computer to establish secure connection to NTNet for certain function"
icon = 'icons/obj/devices/circuitry_n_data.dmi'
icon_state = "datadisk6"
// Actual program for instalation
var/datum/computer_file/program/disk_binded/program
// Pointer to program, cloned into PC, to remove when disk ejecting
var/datum/computer_file/program/disk_binded/installed_clone

/obj/item/computer_console_disk/Initialize(mapload)
. = ..()
if (program)
if (ispath(program))
program = new program()
name = "encrypted connection driver ([program.filename])"
desc = "Contains software which allows computer to establish secure connection to NTNet for certain function.\n\n[program.extended_desc]"

/obj/item/computer_console_disk/Destroy(force)
if (program && isdatum(program))
qdel(program)
program = null
if (installed_clone)
qdel(installed_clone)
installed_clone = null

. = ..()

/obj/item/computer_console_disk/command
icon_state = "datadisk7"
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/obj/item/modular_computer/proc/handle_ui_removable_media_insert(mob/user)
var/list/removable_media = list()

// Removable console data disk
var/datum/computer_file/program/filemanager/fm = locate() in stored_files
if (fm?.console_disk)
removable_media += "[HAS_TRAIT(user, TRAIT_KNOW_ENGI_WIRES) ? "Safe removal:" : "Unsafe eject:"] [fm.console_disk.program?.filename] driver"

// Science Hub disks
var/datum/computer_file/program/science/rnd = locate() in stored_files
if (rnd?.t_disk)
removable_media += "Technology Disk"
if (rnd?.d_disk)
removable_media += "Design Disk"

return removable_media

/obj/item/modular_computer/proc/handle_ui_removable_media_eject(param, mob/user)
// Removable console data disk (switch wants constant expression)
var/datum/computer_file/program/filemanager/fm = locate() in stored_files
if (param == "[HAS_TRAIT(user, TRAIT_KNOW_ENGI_WIRES) ? "Safe removal:" : "Unsafe eject:"] [fm?.console_disk?.program?.filename] driver")
if (fm?.try_eject(user))
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
return TRUE
return
switch(param)
// Science Hub disks
if ("Technology Disk", "Design Disk")
var/datum/computer_file/program/science/rnd = locate() in stored_files
if (!rnd)
return
if(rnd.try_eject(user))
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
return TRUE

return
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/obj/machinery/modular_computer/preset/battery_less
var/start_on_power_restore = FALSE

/obj/machinery/modular_computer/preset/battery_less/Initialize(mapload)
. = ..()
if (!cpu)
return

// ugh.. no idea how to change cpu type without breaking everything.. So just let it be and remove it's cell
var/cell = cpu.internal_cell
cpu.internal_cell = null
if (cell)
qdel(cell)

/obj/machinery/modular_computer/preset/battery_less/power_change()
if (!start_on_power_restore)
return ..()

var/was_unpowered = machine_stat & NOPOWER
. = ..()
if (was_unpowered && !(machine_stat & (BROKEN|NOPOWER)) && cpu && !cpu.enabled)
// Why not cpu.turn_on()? because its crashes without user =/
if(cpu.looping_sound)
cpu.soundloop.start()
cpu.enabled = TRUE
cpu.update_appearance()
SEND_SIGNAL(cpu, COMSIG_MODULAR_COMPUTER_TURNED_ON, null)

/obj/machinery/modular_computer/preset/battery_less/console
start_on_power_restore = TRUE
// Disk that will be installed on Initialize()
var/obj/item/computer_console_disk/console_disk
// If no disk. But us we making sure, that we autorun always as PC exist
// No need to fill if console_disk filled
var/datum/computer_file/program/autorunnable
// Sprites from consoles file. Written by program on console_disk. Can be overriden by you or mapper
var/icon_keyboard

/obj/machinery/modular_computer/preset/battery_less/console/Initialize(mapload)
if (!console_disk && autorunnable && !(autorunnable in starting_programs))
starting_programs += autorunnable

. = ..()

if (cpu && console_disk)
var/datum/computer_file/program/filemanager/filemanager = cpu.find_file_by_name("filemanager")
console_disk = new console_disk(cpu)

// Oh, preset? Get fancy keyboard for free! (if provided by your program and not overriden)
if (!icon_keyboard && console_disk.program)
icon_keyboard = console_disk.program.icon_keyboard

filemanager.application_attackby(console_disk)

else if (cpu && autorunnable)
var/datum/computer_file/program/prog = locate(autorunnable) in cpu.stored_files
// First start for free
cpu.active_program = prog
RegisterSignal(cpu, COMSIG_MODULAR_COMPUTER_TURNED_ON, PROC_REF(autorun))

// Autoenable on init
// cpu.turn_on() copycode
if(cpu.use_energy(cpu.base_active_power_usage)) // checks if the PC is powered
if(cpu.looping_sound)
cpu.soundloop.skip_starting_sounds = TRUE
cpu.soundloop.start()
cpu.soundloop.skip_starting_sounds = initial(cpu.soundloop.skip_starting_sounds)
cpu.enabled = TRUE
cpu.update_appearance()
SEND_SIGNAL(cpu, COMSIG_MODULAR_COMPUTER_TURNED_ON, null)

/obj/machinery/modular_computer/preset/battery_less/console/Destroy()
UnregisterSignal(cpu, COMSIG_MODULAR_COMPUTER_TURNED_ON)
. = ..()

// Custom keyboard icon for maploaded consoles
/obj/machinery/modular_computer/preset/battery_less/console/update_overlays()
. = ..()
if (icon_keyboard)
// There was keyboard_change_icon var but its always TRUE...
if(machine_stat & NOPOWER || !cpu?.enabled)
. += mutable_appearance('icons/obj/machines/computer.dmi', "[icon_keyboard]_off")
else
. += mutable_appearance('icons/obj/machines/computer.dmi', icon_keyboard)


// Only for not disked programs like Science Hub or Cargo. Those who accessed ingame via NTnet
/obj/machinery/modular_computer/preset/battery_less/console/proc/autorun(datum/source, mob/user)
SIGNAL_HANDLER

if (cpu && autorunnable)
var/datum/computer_file/program/prog = locate(autorunnable) in cpu.stored_files
if (prog)
// Not writing in active_programs so user need to check his access
cpu.open_program(user, prog, cpu.enabled)

// Actual presets of non console_disk computers
/obj/machinery/modular_computer/preset/battery_less/console/rdconsole_unQoL
name = "R&D Console"
desc = "A console used to interface with R&D tools."
icon_keyboard = "rd_key"
autorunnable = /datum/computer_file/program/science

/obj/machinery/modular_computer/preset/battery_less/console/cargo_unQoL
name = "supply console"
desc = "Used to order supplies, approve requests, and control the shuttle."
autorunnable = /datum/computer_file/program/budgetorders
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/datum/computer_file/program/disk_binded
size = 0
program_flags = PROGRAM_REQUIRES_NTNET
can_run_on_flags = PROGRAM_CONSOLE
undeletable = TRUE
// Okay. Now about accesses: we are never on NTstore, so download_access doesn't care
// Meanwhile program run is always (or almost) free, but interactions...
// So run_access should be empty, but all yours req_access type into download_access
// So I didn't have to create another access variable
download_access = list()
run_access = list()
// Icon_state of the keyboard overlay for mapload. If any...
var/icon_keyboard

/datum/computer_file/program/disk_binded/on_install(datum/computer_file/source, obj/item/modular_computer/computer_installing)
..()
RegisterSignal(computer, COMSIG_MODULAR_COMPUTER_TURNED_ON, PROC_REF(autorun))

/datum/computer_file/program/disk_binded/Destroy()
. = ..()

if (!QDELETED(computer))
UnregisterSignal(computer, COMSIG_MODULAR_COMPUTER_TURNED_ON)

/datum/computer_file/program/disk_binded/proc/autorun(datum/source, mob/user)
SIGNAL_HANDLER

computer.open_program(user, src, computer.enabled)
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/datum/computer_file/program/filemanager
var/obj/item/computer_console_disk/console_disk

/datum/computer_file/program/filemanager/application_attackby(obj/item/computer_console_disk/attacking_item, mob/living/user)
if (!istype(attacking_item))
return FALSE

if (console_disk)
if (user)
to_chat(user, span_warning("It's secure disk drive already occupied!"))
return FALSE
if (!attacking_item.program)
computer.say("I/O ERROR: Unable to access encrypted data disk. Ejecting...")
return FALSE

if (!attacking_item.program.is_supported_by_hardware(computer.hardware_flag))
var/supported_hardware = attacking_item.program.can_run_on_flags_to_text()
if (supported_hardware == "Anything")
// how you aren't supported, if you support anything?!
computer.say("HARDWARE ERROR: Software compatibility mismatch! Please report that info to NTTechSupport. PC hardware code: [computer.hardware_flag]. Filename: [attacking_item.program.filename].[lowertext(attacking_item.program.filetype)]")
return FALSE
else
computer.say("HARDWARE ERROR: Incompatible software. Ejecting... Supported devices: [supported_hardware]")
return FALSE

if(user && !user.transferItemToLoc(attacking_item, computer))
return FALSE
console_disk = attacking_item
playsound(computer, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)

if (console_disk.program)
// Remove BSOD if present
var/datum/computer_file/program/bsod/bsod = computer.find_file_by_name("nt_recovery")
if (bsod)
computer.remove_file(bsod)

var/datum/computer_file/program/disk_binded/clone = console_disk.program.clone()
console_disk.installed_clone = clone
computer.store_file(clone)
// Initial start
computer.open_program(user, clone, computer.enabled)

return TRUE

/datum/computer_file/program/filemanager/try_eject(mob/living/user, forced = FALSE)
if (forced || !user || HAS_TRAIT(user, TRAIT_KNOW_ENGI_WIRES))
if (user)
user.put_in_hands(console_disk)
user.visible_message(span_warning("[user] removes [console_disk] from [computer]!"), span_notice("You use 'Safely Remove Hardware' option to eject [console_disk] from [computer]..."))
else
console_disk.forceMove(computer.drop_location())
computer.remove_file(console_disk.installed_clone)
console_disk.installed_clone = null
console_disk = null
return TRUE
else
// 2 to unscrew, 3 to eject glass, cut wires and eject circuit
user.visible_message(span_warning("[user] tries to rip off [console_disk] from [computer]!"), span_notice("You try to forcibly remove stuck [console_disk] from [computer]..."))
if (do_after(user, 5 SECONDS, computer.physical ? computer.physical : get_turf(computer)))
var/datum/computer_file/program/bsod/bsod = new(lowertext("[console_disk.program.filename].[console_disk.program.filetype]"))

computer.remove_file(console_disk.installed_clone)
user.put_in_hands(console_disk)
console_disk.installed_clone = null
console_disk = null

computer.store_file(bsod)
return TRUE
to_chat(user, span_warning("You should be near \the [computer.physical ? computer.physical : computer]!"))
return FALSE
Loading
Loading