Skip to content
Merged
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/__DEFINES/computer4_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#define WIRELESS_FILTER_MODEMAX 2 //! Max of WIRELESS_FILTER_* Defines.

// ThinkDOS //
// Well-Known Directories
#define THINKDOS_BIN_DIRECTORY "/bin"
// Constants
#define THINKDOS_MAX_COMMANDS 3 //! The maximum amount of commands
// Symbols
Expand Down
4 changes: 2 additions & 2 deletions code/modules/computer4/computer4.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ TYPEINFO_DEF(/obj/machinery/computer4)
/// List of peripheral typepaths to install by default.
var/list/default_peripherals

/// The directory to install them in
var/default_program_dir = "/bin"
/// The directory to install them in.
var/default_program_dir = THINKDOS_BIN_DIRECTORY

/// Soundloop. Self explanatory.
var/datum/looping_sound/computer/soundloop
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/// Struct for the parsed stdin
/datum/shell_stdin
/datum/parsed_cmdline
var/raw = ""
var/command = ""
var/list/arguments = list()
var/list/options = list()

/datum/shell_stdin/New(text)
/datum/parsed_cmdline/New(text)
arguments = splittext(text, " ")

raw = text
command = lowertext(arguments[1])
options = list()
arguments.Cut(1, 2) // Pop out the command itself

if(length(arguments) == 1)
return
if(!length(arguments))
return //Bare command, no use going further.

// Parse out options
for(var/str in arguments)
Expand Down
12 changes: 7 additions & 5 deletions code/modules/computer4/data/terminal/_terminal_program.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
return TRUE

/// Called when a program is run.
/datum/c4_file/terminal_program/proc/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system)
system.clear_screen(TRUE)
/// Operating systems will have cmdline provided as a raw string.
/// Normal programs should expect and be passed a parsed_cmdline
/datum/c4_file/terminal_program/proc/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system, datum/parsed_cmdline/cmdline)
return

/// Called when a program is no longer running
/datum/c4_file/terminal_program/proc/on_close(datum/c4_file/terminal_program/operating_system/thinkdos/system)
Expand All @@ -51,10 +53,10 @@
return FALSE

/// Helper for splitting stdin into command and arguments.
/datum/c4_file/terminal_program/proc/parse_std_in(text) as /datum/shell_stdin
RETURN_TYPE(/datum/shell_stdin)
/datum/c4_file/terminal_program/proc/parse_cmdline(text) as /datum/parsed_cmdline
RETURN_TYPE(/datum/parsed_cmdline)

return new /datum/shell_stdin(text)
return new /datum/parsed_cmdline(text)

/// Called by computers to forward commands from peripherals to programs. Should probably be on OS but oh well.
/datum/c4_file/terminal_program/proc/peripheral_input(obj/item/peripheral/invoker, command, datum/signal/packet)
Expand Down
19 changes: 10 additions & 9 deletions code/modules/computer4/data/terminal/directive/directman.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,28 @@
if(!system.get_computer().get_peripheral(PERIPHERAL_TYPE_WIRELESS_CARD))
system.println("<b>Error:</b> Unable to locate wireless adapter.")

system.clear_screen(TRUE)
view_home()

/datum/c4_file/terminal_program/directman/std_in(text)
. = ..()
var/datum/shell_stdin/parsed_stdin = parse_std_in(text)
var/datum/parsed_cmdline/parsed_cmdline = parse_cmdline(text)

var/datum/c4_file/terminal_program/operating_system/system = get_os()
system.println(html_encode(text))

if(home_command.try_exec(parsed_stdin.command, system, src, parsed_stdin.arguments, parsed_stdin.options))
if(home_command.try_exec(parsed_cmdline.command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE

switch(current_menu)
if(DIRECTMAN_MENU_HOME)
for(var/datum/shell_command/potential_command as anything in main_commands)
if(potential_command.try_exec(parsed_stdin.command, system, src, parsed_stdin.arguments, parsed_stdin.options))
if(potential_command.try_exec(parsed_cmdline.command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE

if(DIRECTMAN_MENU_CURRENT)
var/number = text2num(parsed_stdin.raw)
if(lowertext(parsed_stdin.raw) == "b")
var/number = text2num(parsed_cmdline.raw)
if(lowertext(parsed_cmdline.raw) == "b")
system.clear_screen(TRUE)
view_home()
return TRUE
Expand All @@ -58,13 +59,13 @@
return TRUE

if(DIRECTMAN_MENU_ACTIVE_DIRECTIVE)
if(lowertext(parsed_stdin.raw) == "b")
if(lowertext(parsed_cmdline.raw) == "b")
system.clear_screen(TRUE)
view_current()
return TRUE

if(DIRECTMAN_MENU_NEW_DIRECTIVES)
var/number = text2num(parsed_stdin.raw)
var/number = text2num(parsed_cmdline.raw)
if(!(number in 1 to length(SSdirectives.get_directives_for_selection())))
return

Expand All @@ -76,7 +77,7 @@
return TRUE

if(DIRECTMAN_MENU_NEW_DIRECTIVE)
if(lowertext(parsed_stdin.raw) == "b")
if(lowertext(parsed_cmdline.raw) == "b")
system.clear_screen(TRUE)
if(!system.get_computer().get_peripheral(PERIPHERAL_TYPE_WIRELESS_CARD))
view_home()
Expand All @@ -86,7 +87,7 @@
return TRUE


if(lowertext(parsed_stdin.raw) == "s")
if(lowertext(parsed_cmdline.raw) == "s")
if(!system.get_computer().get_peripheral(PERIPHERAL_TYPE_WIRELESS_CARD))
view_home()
system.println("<b>Error:</b> Unable to locate wireless adapter.")
Expand Down
19 changes: 10 additions & 9 deletions code/modules/computer4/data/terminal/medtrak/medtrak.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@

write_log("[system.current_user.registered_name] accessed the records database.")

system.clear_screen(TRUE)
home_text()

/// Getter for the log file. This isn't kept as a ref because I don't want to manage the ref. :)
Expand Down Expand Up @@ -98,24 +99,24 @@
return

var/datum/c4_file/terminal_program/operating_system/thinkdos/system = get_os()
var/datum/shell_stdin/parsed_stdin = parse_std_in(text)
var/datum/parsed_cmdline/parsed_cmdline = parse_cmdline(text)

if(awaiting_input)
var/datum/callback/_awaiting = awaiting_input // Null beforehand incase the awaiting input awaits another input.
awaiting_input = null
_awaiting.Invoke(src, parsed_stdin)
_awaiting.Invoke(src, parsed_cmdline)
return

var/lowertext_command = lowertext(parsed_stdin.command)
var/lowertext_command = lowertext(parsed_cmdline.command)

switch(current_menu)
if(MEDTRAK_MENU_HOME)
for(var/datum/shell_command/command as anything in home_commands)
if(command.try_exec(lowertext_command, system, src, parsed_stdin.arguments, parsed_stdin.options))
if(command.try_exec(lowertext_command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE

if(MEDTRAK_MENU_INDEX)
var/input_num = text2num(parsed_stdin.command)
var/input_num = text2num(parsed_cmdline.command)
if(isnum(input_num))
if(input_num == 0)
view_home()
Expand All @@ -131,11 +132,11 @@
return TRUE

for(var/datum/shell_command/command as anything in index_commands)
if(command.try_exec(lowertext_command, system, src, parsed_stdin.arguments, parsed_stdin.options))
if(command.try_exec(lowertext_command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE

if(MEDTRAK_MENU_RECORD)
var/input_num = text2num(parsed_stdin.command)
var/input_num = text2num(parsed_cmdline.command)
if(isnum(input_num))
if(input_num == 0)
view_index()
Expand All @@ -145,12 +146,12 @@
return TRUE

for(var/datum/shell_command/command as anything in record_commands)
if(command.try_exec(lowertext_command, system, src, parsed_stdin.arguments, parsed_stdin.options))
if(command.try_exec(lowertext_command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE

if(MEDTRAK_MENU_COMMENTS)
for(var/datum/shell_command/command as anything in comment_commands)
if(command.try_exec(lowertext_command, system, src, parsed_stdin.arguments, parsed_stdin.options))
if(command.try_exec(lowertext_command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE

/// Prints the home menu options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
var/datum/c4_file/terminal_program/medtrak/medtrak = program
medtrak.await_input("Enter a new comment", CALLBACK(src, PROC_REF(fulfill_new_comment)))

/datum/shell_command/medtrak/comment/new_comment/proc/fulfill_new_comment(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/shell_command/medtrak/comment/new_comment/proc/fulfill_new_comment(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/datum/c4_file/terminal_program/operating_system/thinkdos/system = medtrak.get_os()
if(!length(stdin.raw))
medtrak.view_comments()
Expand Down
24 changes: 12 additions & 12 deletions code/modules/computer4/data/terminal/medtrak/medtrak_edit_record.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/datum/c4_file/terminal_program/medtrak/proc/edit_name(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_name(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_name = trim(html_encode(stdin.raw), MAX_NAME_LEN)

if(!(length(new_name)))
Expand All @@ -8,7 +8,7 @@
medtrak.update_record(DATACORE_NAME, "NAME", new_name)
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_sex(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_sex(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_sex = trim(html_encode(stdin.raw), MAX_NAME_LEN)

if(!length(new_sex))
Expand All @@ -18,7 +18,7 @@
medtrak.update_record(DATACORE_GENDER, "SEX", new_sex)
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_age(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_age(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_age = text2num(ckey(stdin.raw))

if(isnull(new_age) || !(new_age in 1 to 200))
Expand All @@ -28,7 +28,7 @@
medtrak.update_record(DATACORE_AGE, "AGE", "[new_age]")
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_species(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_species(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_species = trim(html_encode(stdin.raw), MAX_NAME_LEN)

if(!length(new_species))
Expand All @@ -38,7 +38,7 @@
medtrak.update_record(DATACORE_SPECIES, "SPECIES", new_species)
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_blood_type(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_blood_type(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_blood_type = trim(html_encode(stdin.raw), MAX_NAME_LEN)

if(!length(new_blood_type))
Expand All @@ -48,7 +48,7 @@
medtrak.update_record(DATACORE_BLOOD_TYPE, "BLOOD_TYPE", new_blood_type)
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_blood_dna(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_blood_dna(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_blood_dna = trim(html_encode(stdin.raw), MAX_NAME_LEN)

if(!length(new_blood_dna))
Expand All @@ -58,7 +58,7 @@
medtrak.update_record(DATACORE_BLOOD_DNA, "BLOOD_DNA", new_blood_dna)
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_disabilities(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_disabilities(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_disabilities = trim(html_encode(stdin.raw), MAX_MESSAGE_LEN)

if(!length(new_disabilities))
Expand All @@ -68,7 +68,7 @@
medtrak.update_record(DATACORE_DISABILITIES, "DISABILITIES", new_disabilities)
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_diseases(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_diseases(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_diseases = trim(html_encode(stdin.raw), MAX_MESSAGE_LEN)

if(!length(new_diseases))
Expand All @@ -78,7 +78,7 @@
medtrak.update_record(DATACORE_DISEASES, "DISEASES", new_diseases)
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_allergies(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_allergies(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_allergies = trim(html_encode(stdin.raw), MAX_MESSAGE_LEN)

if(!length(new_allergies))
Expand All @@ -88,7 +88,7 @@
medtrak.update_record(DATACORE_ALLERGIES, "ALLERGIES", new_allergies)
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_physical_health(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_physical_health(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/choice = text2num(stdin.raw)
var/list/options = list(
PHYSHEALTH_OK,
Expand All @@ -110,7 +110,7 @@
medtrak.update_record(DATACORE_PHYSICAL_HEALTH, "PHYSICAL_STATUS", options[choice])
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_mental_health(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_mental_health(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/choice = text2num(stdin.raw)
var/list/options = list(
MENHEALTH_OK,
Expand All @@ -134,7 +134,7 @@
medtrak.update_record(DATACORE_MENTAL_HEALTH, "MENTAL_STATUS", options[choice])
medtrak.view_record()

/datum/c4_file/terminal_program/medtrak/proc/edit_notes(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/c4_file/terminal_program/medtrak/proc/edit_notes(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_notes = trim(html_encode(stdin.raw), MAX_MESSAGE_LEN)

if(!length(new_notes))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
var/datum/c4_file/terminal_program/medtrak/medtrak = program
medtrak.await_input("Enter target Name, or ID.", CALLBACK(src, PROC_REF(search_input)))

/datum/shell_command/medtrak/home/search/proc/search_input(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/shell_command/medtrak/home/search/proc/search_input(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/search_text = stdin.raw
if(isnull(search_text))
medtrak.view_home()
Expand Down Expand Up @@ -52,7 +52,7 @@
medtrak.await_input(jointext(out, "<br>"), CALLBACK(src, PROC_REF(fulfill_search), results))
return

/datum/shell_command/medtrak/home/search/proc/fulfill_search(list/results, datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/shell_command/medtrak/home/search/proc/fulfill_search(list/results, datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/number = text2num(ckey(stdin.raw))
if(isnull(number) || !(number in 1 to length(results)))
medtrak.view_home()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
medtrak.view_record(medtrak.current_record)
medtrak.await_input("Are you sure you want to delete '[medtrak.current_record.fields[DATACORE_NAME]]'?(Y/N)", CALLBACK(src, PROC_REF(confirm_delete), medtrak))

/datum/shell_command/medtrak/record/delete/proc/confirm_delete(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
/datum/shell_command/medtrak/record/delete/proc/confirm_delete(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
switch(lowertext(jointext(stdin.raw, "")))
if("y")
medtrak.write_log("Record [medtrak.current_record.fields[DATACORE_ID]] deleted.")
Expand Down
5 changes: 3 additions & 2 deletions code/modules/computer4/data/terminal/netpage/netpage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
if(.)
return

system.clear_screen(TRUE)
var/title_text = list(
@"<pre style='margin: 0px'> ___ ___ __ __ ___</pre>",
@"<pre style='margin: 0px'>|\ | |__ | |__) /\ / _` |__ </pre>",
Expand All @@ -34,13 +35,13 @@

/datum/c4_file/terminal_program/netpage/std_in(text)
. = ..()
var/datum/shell_stdin/parsed_stdin = parse_std_in(text)
var/datum/parsed_cmdline/parsed_cmdline = parse_cmdline(text)

var/datum/c4_file/terminal_program/operating_system/system = get_os()
system.println(html_encode(text))

for(var/datum/shell_command/potential_command as anything in commands)
if(potential_command.try_exec(parsed_stdin.command, system, src, parsed_stdin.arguments, parsed_stdin.options))
if(potential_command.try_exec(parsed_cmdline.command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE

/datum/c4_file/terminal_program/netpage/proc/check_for_errors()
Expand Down
5 changes: 3 additions & 2 deletions code/modules/computer4/data/terminal/notepad/notepad.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@
@"<pre style='margin: 0px'> / / / ) / ' / / / ) / ' /( </pre>",
@"<pre style='margin: 0px'>_/____/___(___/_(___ _/____/___(___/_(___ _/___\__</pre>",
).Join("")
system.clear_screen(TRUE)
system.println(title_text)
system.println("Welcome to DocDock, type !help to get started.")

/datum/c4_file/terminal_program/notepad/parse_std_in(text)
/datum/c4_file/terminal_program/notepad/parse_cmdline(text)
return splittext(text, " ")

/datum/c4_file/terminal_program/notepad/std_in(text)
. = ..()
var/list/arguments = parse_std_in(text)
var/list/arguments = parse_cmdline(text)
var/command = arguments[1]
arguments.Cut(1,2)

Expand Down
Loading
Loading