Skip to content

Commit

Permalink
Modular computer programs preset support unit test (#20069)
Browse files Browse the repository at this point in the history
Added some modular computer program preset tests.
Fixed some modular computer program preset that had duplicate programs.
Refactored how the computer program presets generate the list of
programs to install.
Turned some comments into DMDocs, some cleanup around.
Tests disabled reasons are now enclosed in the group correctly.
  • Loading branch information
FluffyGhoster authored Nov 14, 2024
1 parent 477e7fa commit 2ac1681
Show file tree
Hide file tree
Showing 12 changed files with 523 additions and 416 deletions.
1 change: 1 addition & 0 deletions aurorastation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3751,6 +3751,7 @@
#include "code\unit_tests\loadout_tests.dm"
#include "code\unit_tests\map_tests.dm"
#include "code\unit_tests\mob_tests.dm"
#include "code\unit_tests\modular_computers_tests.dm"
#include "code\unit_tests\object_tests.dm"
#include "code\unit_tests\observation_tests.dm"
#include "code\unit_tests\origins_tests.dm"
Expand Down
98 changes: 74 additions & 24 deletions code/modules/modular_computers/file_system/program.dm
Original file line number Diff line number Diff line change
@@ -1,34 +1,84 @@
// /program/ files are executable programs that do things.
/datum/computer_file/program
ABSTRACT_TYPE(/datum/computer_file/program)
filetype = "PRG"
filename = "UnknownProgram" // File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NTNET!
filedesc = "Unknown Program" // User-friendly name of this program.
var/program_type = PROGRAM_NORMAL // Program type, used to determine if program runs in background or not.
var/required_access_run // List of required accesses to run the program.
var/required_access_download // List of required accesses to download the program.
var/requires_access_to_run = PROGRAM_ACCESS_ONE // Whether the program checks for required_access when run. (1 = requires single access, 2 = requires single access from list, 3 = requires all access from list)
var/requires_access_to_download = PROGRAM_ACCESS_ONE // Whether the program checks for required_access when downloading. (1 = requires single access, 2 = requires single access from list, 3 = requires all access from list)
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/extended_desc = "N/A" // Short description of this program's function.
var/program_icon_state // Program-specific screen icon state
var/program_key_icon_state // Program-specific keyboard icon state (really only applies to consoles but can be used for other purposes like having mix-n-match screens)
var/requires_ntnet = FALSE // Set to TRUE for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes.
var/requires_ntnet_feature = FALSE // Optional, if above is set to TRUE checks for specific function of NTNet (currently NTNET_SOFTWAREDOWNLOAD, NTNET_PEERTOPEER, NTNET_SYSTEMCONTROL and NTNET_COMMUNICATION)
var/ntnet_status = TRUE // NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc.
var/usage_flags = PROGRAM_ALL // Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_TABLET combination) or PROGRAM_ALL
var/network_destination // Optional string that describes what NTNet server/system this program connects to. Used in default logging.
var/available_on_ntnet = TRUE // Whether the program can be downloaded from NTNet. Set to 0 to disable.
var/available_on_syndinet = FALSE // Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to 1 to enable.
var/computer_emagged = FALSE // Set to TRUE if computer that's running us was emagged. Computer updates this every Process() tick
var/ui_header // Example: "something.gif" - a header image that will be rendered in computer's UI when this program is running at background. Images are taken from /nano/images/status_icons. Be careful not to use too large images!
var/color = "#FFFFFF" // The color of light the computer should emit when this program is open.
var/service_state = PROGRAM_STATE_DISABLED // PROGRAM_STATE_KILLED or PROGRAM_STATE_ACTIVE - specifies whether this program's service is running.

/// File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NTNET!
filename = "UnknownProgram"

/// User-friendly name of this program.
filedesc = "Unknown Program"

/// Program type, used to determine if program runs in background or not.
var/program_type = PROGRAM_NORMAL

/// List of required accesses to run the program.
var/required_access_run

/// List of required accesses to download the program.
var/required_access_download

/// Whether the program checks for required_access when run. (1 = requires single access, 2 = requires single access from list, 3 = requires all access from list)
var/requires_access_to_run = PROGRAM_ACCESS_ONE

/// Whether the program checks for required_access when downloading. (1 = requires single access, 2 = requires single access from list, 3 = requires all access from list)
var/requires_access_to_download = PROGRAM_ACCESS_ONE

/// PROGRAM_STATE_KILLED or PROGRAM_STATE_BACKGROUND or PROGRAM_STATE_ACTIVE - specifies whether this program is running.
var/program_state = PROGRAM_STATE_KILLED

/// Device that runs this program.
var/obj/item/modular_computer/computer

/// Short description of this program's function.
var/extended_desc = "N/A"

/// Program-specific screen icon state
var/program_icon_state

/// Program-specific keyboard icon state (really only applies to consoles but can be used for other purposes like having mix-n-match screens)
var/program_key_icon_state

/// Set to TRUE for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes.
var/requires_ntnet = FALSE

/// Optional, if above is set to TRUE checks for specific function of NTNet (currently NTNET_SOFTWAREDOWNLOAD, NTNET_PEERTOPEER, NTNET_SYSTEMCONTROL and NTNET_COMMUNICATION)
var/requires_ntnet_feature = FALSE

/// NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc.
var/ntnet_status = TRUE

/// Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_TABLET combination) or PROGRAM_ALL
var/usage_flags = PROGRAM_ALL

/// Optional string that describes what NTNet server/system this program connects to. Used in default logging.
var/network_destination

/// Whether the program can be downloaded from NTNet. Set to 0 to disable.
var/available_on_ntnet = TRUE

/// Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to 1 to enable.
var/available_on_syndinet = FALSE

/// Set to TRUE if computer that's running us was emagged. Computer updates this every Process() tick
var/computer_emagged = FALSE

/// Example: "something.gif" - a header image that will be rendered in computer's UI when this program is running at background. Images are taken from /nano/images/status_icons. Be careful not to use too large images!
var/ui_header

/// The color of light the computer should emit when this program is open.
var/color = "#FFFFFF"

/// PROGRAM_STATE_KILLED or PROGRAM_STATE_ACTIVE - specifies whether this program's service is running.
var/service_state = PROGRAM_STATE_DISABLED

var/silent = FALSE

/// Name of the TGUI Interface
var/tgui_id

/// Theme of this TGUI interface
var/tgui_theme = "scc"

/// If this TGUI should autoupdate or not.
var/ui_auto_update = TRUE

Expand Down
90 changes: 52 additions & 38 deletions code/modules/modular_computers/file_system/programs/app_presets_.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
/datum/modular_computer_app_presets
ABSTRACT_TYPE(/datum/modular_computer_app_presets)
var/name = "default_preset"
var/display_name = "default preset"
var/description = "Description of the preset."
var/available = FALSE

/datum/modular_computer_app_presets/proc/return_install_programs(var/obj/item/modular_computer/comp)
return list()
/**
* A `/list` of `/datum/computer_file/program` _typepaths_ that constitute this preset
*
* Is instantiated and returned by `return_install_programs()` on the computers that request it
*
* **Do not set this directly**, add or remove tye typepaths to it in New() **only**
*/
var/list/program_list = list()

/datum/modular_computer_app_presets/proc/return_install_programs(obj/item/modular_computer/comp)
SHOULD_NOT_SLEEP(TRUE)
SHOULD_CALL_PARENT(TRUE)

. = list()

for(var/program_typepath in program_list)
. += new program_typepath(comp)


/datum/modular_computer_app_presets/all
name = "all"
Expand All @@ -14,54 +30,52 @@
available = FALSE

/datum/modular_computer_app_presets/all/return_install_programs(obj/item/modular_computer/comp)
var/list/_prg_list = list()
for(var/F in typesof(/datum/computer_file/program))
SHOULD_CALL_PARENT(FALSE) //Special snowflake case

. = list()
for(var/F in subtypesof(/datum/computer_file/program))
var/datum/computer_file/program/prog = new F(comp)
_prg_list += prog
return flatten_list(_prg_list)
. += prog

#define COMPUTER_APP_PRESET_SYSTEM list(\
new /datum/computer_file/program/ntnetdownload(comp),\
new /datum/computer_file/program/filemanager(comp),\
)
#define COMPUTER_APP_PRESET_SYSTEM list(/datum/computer_file/program/ntnetdownload, /datum/computer_file/program/filemanager)

#define COMPUTER_APP_PRESET_HORIZON_CIVILIAN list(\
new /datum/computer_file/program/newsbrowser(comp),\
new /datum/computer_file/program/manifest(comp),\
new /datum/computer_file/program/chat_client(comp),\
new /datum/computer_file/program/civilian/cargoorder(comp),\
new /datum/computer_file/program/map(comp),\
/datum/computer_file/program/newsbrowser,\
/datum/computer_file/program/manifest,\
/datum/computer_file/program/chat_client,\
/datum/computer_file/program/civilian/cargoorder,\
/datum/computer_file/program/map,\
)

#define COMPUTER_APP_PRESET_HORIZON_ENGINEERING list(\
new /datum/computer_file/program/power_monitor(comp),\
new /datum/computer_file/program/alarm_monitor/engineering(comp),\
new /datum/computer_file/program/atmos_control(comp),\
new /datum/computer_file/program/rcon_console(comp),\
new /datum/computer_file/program/camera_monitor(comp),\
new /datum/computer_file/program/lighting_control(comp)\
/datum/computer_file/program/power_monitor,\
/datum/computer_file/program/alarm_monitor/engineering,\
/datum/computer_file/program/atmos_control,\
/datum/computer_file/program/rcon_console,\
/datum/computer_file/program/camera_monitor,\
/datum/computer_file/program/lighting_control,\
)

#define COMPUTER_APP_PRESET_HORIZON_MEDICAL list(\
new /datum/computer_file/program/suit_sensors(comp),\
new /datum/computer_file/program/records/medical(comp),\
new /datum/computer_file/program/chemistry_codex(comp),\
new /datum/computer_file/program/scanner/medical(comp),\
)
/datum/computer_file/program/suit_sensors,\
/datum/computer_file/program/records/medical,\
/datum/computer_file/program/chemistry_codex,\
/datum/computer_file/program/scanner/medical,\
)

#define COMPUTER_APP_PRESET_HORIZON_RESEARCH list(\
new /datum/computer_file/program/ntnetmonitor(comp),\
new /datum/computer_file/program/aidiag(comp),\
new /datum/computer_file/program/chemistry_codex(comp),\
new /datum/computer_file/program/scanner/science(comp),\
new /datum/computer_file/program/scanner/gas(comp),\
new /datum/computer_file/program/away_manifest(comp),\
/datum/computer_file/program/ntnetmonitor,\
/datum/computer_file/program/aidiag,\
/datum/computer_file/program/chemistry_codex,\
/datum/computer_file/program/scanner/science,\
/datum/computer_file/program/scanner/gas,\
/datum/computer_file/program/away_manifest,\
)

#define COMPUTER_APP_PRESET_HORIZON_SECURITY list(\
new /datum/computer_file/program/alarm_monitor/security(comp),\
new /datum/computer_file/program/camera_monitor(comp),\
new /datum/computer_file/program/digitalwarrant(comp),\
new /datum/computer_file/program/records/security(comp),\
new /datum/computer_file/program/guntracker(comp),\
/datum/computer_file/program/alarm_monitor/security,\
/datum/computer_file/program/camera_monitor,\
/datum/computer_file/program/digitalwarrant,\
/datum/computer_file/program/records/security,\
/datum/computer_file/program/guntracker,\
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,41 @@
description = "Contains the most common command programs and has a special teleporter control program loaded."
available = FALSE

/datum/modular_computer_app_presets/command/teleporter/ninja/return_install_programs(obj/item/modular_computer/comp)
var/list/_prg_list = list(
COMPUTER_APP_PRESET_SYSTEM,
COMPUTER_APP_PRESET_HORIZON_CIVILIAN,
new /datum/computer_file/program/comm(comp, FALSE),
new /datum/computer_file/program/records/employment(comp),
new /datum/computer_file/program/teleporter/ninja(comp)
)
return flatten_list(_prg_list)
/datum/modular_computer_app_presets/command/teleporter/ninja/New()
. = ..()
program_list += /datum/computer_file/program/teleporter/ninja


/datum/modular_computer_app_presets/merc
name = "merc"
display_name = "Mercenary"
description = "Preset for the Merc Console."
available = FALSE

/datum/modular_computer_app_presets/merc/return_install_programs(obj/item/modular_computer/comp)
var/list/_prg_list = list(
COMPUTER_APP_PRESET_SYSTEM,
new /datum/computer_file/program/newsbrowser(comp),
new /datum/computer_file/program/manifest(comp),
new /datum/computer_file/program/camera_monitor/hacked(comp)
)
return flatten_list(_prg_list)
/datum/modular_computer_app_presets/merc/New()
. = ..()
program_list += COMPUTER_APP_PRESET_SYSTEM
program_list += list(/datum/computer_file/program/newsbrowser,
/datum/computer_file/program/manifest,
/datum/computer_file/program/camera_monitor/hacked
)



/datum/modular_computer_app_presets/ert
name = "ert"
display_name = "EmergencyResposeTeam"
description = "Preset for the ERT Console."
available = FALSE

/datum/modular_computer_app_presets/ert/return_install_programs(obj/item/modular_computer/comp)
var/list/_prg_list = list(
COMPUTER_APP_PRESET_SYSTEM,
new /datum/computer_file/program/camera_monitor/hacked(comp),
new /datum/computer_file/program/comm(comp, FALSE),
new /datum/computer_file/program/suit_sensors(comp),
new /datum/computer_file/program/alarm_monitor/all(comp),
new /datum/computer_file/program/lighting_control(comp),
new /datum/computer_file/program/aidiag(comp),
new /datum/computer_file/program/records(comp)
)
return flatten_list(_prg_list)
/datum/modular_computer_app_presets/ert/New()
. = ..()
program_list += COMPUTER_APP_PRESET_SYSTEM
program_list += list(/datum/computer_file/program/camera_monitor/hacked,
/datum/computer_file/program/comm,
/datum/computer_file/program/suit_sensors,
/datum/computer_file/program/alarm_monitor/all,
/datum/computer_file/program/lighting_control,
/datum/computer_file/program/aidiag,
/datum/computer_file/program/records
)
Loading

0 comments on commit 2ac1681

Please sign in to comment.