diff --git a/code/__DEFINES/~doppler_defines/ntnrc.dm b/code/__DEFINES/~doppler_defines/ntnrc.dm new file mode 100644 index 0000000000000..585b09dc58b8d --- /dev/null +++ b/code/__DEFINES/~doppler_defines/ntnrc.dm @@ -0,0 +1,6 @@ + +/// Name used for the common chat all crew gets added to when they join. +#define NTNRC_COMMON_CHAT "#general" + +/// Name used for the preference for the default NTNRC username. +#define NTRNC_USERNAME_PREF_NAME "NTNRC username" diff --git a/code/modules/modular_computers/computers/item/computer_ui.dm b/code/modules/modular_computers/computers/item/computer_ui.dm index d8b97c523019d..009ad0370b219 100644 --- a/code/modules/modular_computers/computers/item/computer_ui.dm +++ b/code/modules/modular_computers/computers/item/computer_ui.dm @@ -139,6 +139,25 @@ //you can't close apps in emergency mode. if(isnull(internal_cell) || internal_cell.charge) active_program.kill_program(usr) + // DOPPLER EDIT ADDITION START - NTNRC_FOR_ALL + else // Slightly cursed code to let you swap between the chat client or messenger instead + + if(istype(active_program, /datum/computer_file/program/chatclient)) + var/datum/computer_file/program/messenger/our_messenger = locate() in stored_files + if(isnull(our_messenger)) + return TRUE + open_program(usr, our_messenger) + + else if(istype(active_program, /datum/computer_file/program/messenger)) + var/datum/computer_file/program/chatclient/our_chat_client = locate() in stored_files + if(isnull(our_chat_client)) + return TRUE + if(!get_ntnet_status()) // Can't swap to NTNRC without NTNet. + to_chat(usr, span_danger("\The [src]'s screen shows \"Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning.")) + return TRUE + open_program(usr, our_chat_client) + + // DOPPLER EDIT ADDITION END - NTNRC_FOR_ALL return TRUE if("PC_shutdown") shutdown_computer() diff --git a/code/modules/modular_computers/computers/item/pda.dm b/code/modules/modular_computers/computers/item/pda.dm index 1fea772b85e58..05882d17f582b 100644 --- a/code/modules/modular_computers/computers/item/pda.dm +++ b/code/modules/modular_computers/computers/item/pda.dm @@ -39,6 +39,7 @@ /datum/computer_file/program/nt_pay, /datum/computer_file/program/notepad, /datum/computer_file/program/crew_manifest, + /datum/computer_file/program/chatclient, // DOPPLER EDIT ADDITION - NTNRC_FOR_ALL ) ///List of items that can be stored in a PDA var/static/list/contained_item = list( diff --git a/code/modules/modular_computers/file_system/programs/chatroom/ntnrc_client.dm b/code/modules/modular_computers/file_system/programs/chatroom/ntnrc_client.dm index 8045bcb1db0db..fc743caa66c67 100644 --- a/code/modules/modular_computers/file_system/programs/chatroom/ntnrc_client.dm +++ b/code/modules/modular_computers/file_system/programs/chatroom/ntnrc_client.dm @@ -160,6 +160,11 @@ if("PRG_setpassword") if(!authed) return + // DOPPLER EDIT ADDITION START - NTNRC_FOR_ALL + if(channel.strong) // Block setting passwords on important channels + computer.visible_message(span_warning("Warning. May not set a password on common channels.")) + return + // DOPPLER EDIT ADDITION END - NTNRC_FOR_ALL var/new_password = sanitize(params["new_password"]) if(!authed) return diff --git a/modular_doppler/ntnrc_for_all/code/common_chat.dm b/modular_doppler/ntnrc_for_all/code/common_chat.dm new file mode 100644 index 0000000000000..634e4e508518a --- /dev/null +++ b/modular_doppler/ntnrc_for_all/code/common_chat.dm @@ -0,0 +1,7 @@ + +/// Conversation subtype that doesn't allow for the addition of any single operator. Netadmin mode can still override. +/datum/ntnet_conversation/common + +/// Override to block adding an operator. +/datum/ntnet_conversation/common/changeop(datum/computer_file/program/chatclient/newop, silent = FALSE) + return diff --git a/modular_doppler/ntnrc_for_all/code/ntnrc_client_edits.dm b/modular_doppler/ntnrc_for_all/code/ntnrc_client_edits.dm new file mode 100644 index 0000000000000..445a057b25f36 --- /dev/null +++ b/modular_doppler/ntnrc_for_all/code/ntnrc_client_edits.dm @@ -0,0 +1,14 @@ + +/// Enables the chat client to run without using up power. +/datum/computer_file/program/chatclient + program_flags = PROGRAM_ON_NTNET_STORE | PROGRAM_REQUIRES_NTNET | PROGRAM_RUNS_WITHOUT_POWER + power_cell_use = 0 + +/datum/computer_file/program/chatclient/on_start(mob/living/user) + . = ..() + if(!.) + return + + // If we're already in the common chat, start with it open. + if((src in SSmodular_computers.common_chat.active_clients) || (src in SSmodular_computers.common_chat.offline_clients)) + active_channel = SSmodular_computers.common_chat.id diff --git a/modular_doppler/ntnrc_for_all/code/pda_prefs_edits.dm b/modular_doppler/ntnrc_for_all/code/pda_prefs_edits.dm new file mode 100644 index 0000000000000..83b48a7190c89 --- /dev/null +++ b/modular_doppler/ntnrc_for_all/code/pda_prefs_edits.dm @@ -0,0 +1,18 @@ + +/// Apply our ntnrc client username prefs +/obj/item/modular_computer/pda/update_pda_prefs(client/owner_client) + . = ..() + if(isnull(owner_client)) + return + + var/datum/computer_file/program/chatclient/our_chat_client = locate() in stored_files + if(isnull(our_chat_client)) + return + + var/default_username = owner_client.prefs.read_preference(/datum/preference/name/ntnrc_username) + if(isnull(default_username)) + return + + our_chat_client.username = default_username + SSmodular_computers.common_chat.add_client(our_chat_client) + open_program(null, our_chat_client, FALSE) diff --git a/modular_doppler/ntnrc_for_all/code/ss_modular_computers_edits.dm b/modular_doppler/ntnrc_for_all/code/ss_modular_computers_edits.dm new file mode 100644 index 0000000000000..67b879c9dabd3 --- /dev/null +++ b/modular_doppler/ntnrc_for_all/code/ss_modular_computers_edits.dm @@ -0,0 +1,8 @@ + +/datum/controller/subsystem/modular_computers + /// Reference to the common chat used for all crew + var/datum/ntnet_conversation/common/common_chat + +/datum/controller/subsystem/modular_computers/Initialize() + . = ..() + common_chat = new(title = NTNRC_COMMON_CHAT, strong = TRUE) diff --git a/modular_doppler/ntnrc_for_all/code/username_prefs.dm b/modular_doppler/ntnrc_for_all/code/username_prefs.dm new file mode 100644 index 0000000000000..ddad401e8f197 --- /dev/null +++ b/modular_doppler/ntnrc_for_all/code/username_prefs.dm @@ -0,0 +1,19 @@ + +/// The username to default to for NTNRC +/datum/preference/name/ntnrc_username + explanation = NTRNC_USERNAME_PREF_NAME + group = "_usernames" // Underscore puts it high up, but below `_real_names` + savefile_key = "chat_client_username" + + +/datum/preference/name/ntnrc_username/create_default_value() + return pick(GLOB.hacker_aliases) + +/datum/preference/name/ntnrc_username/is_valid(value) + return !isnull(permissive_sanitize_name(value)) + +/datum/preference/name/ntnrc_username/deserialize(input, datum/preferences/preferences) + return permissive_sanitize_name(input) + +/datum/preference/name/ntnrc_username/serialize(input) + return permissive_sanitize_name(input) diff --git a/modular_doppler/ntnrc_for_all/readme.md b/modular_doppler/ntnrc_for_all/readme.md new file mode 100644 index 0000000000000..705a33b2fca52 --- /dev/null +++ b/modular_doppler/ntnrc_for_all/readme.md @@ -0,0 +1,28 @@ +## Title: NTNRC For All + +MODULE ID: NTNRC_FOR_ALL + +### Description: + +Implements a general NTNRC channel every crewmember is added to by default, and related username pref. + +### TG Proc Changes: + +- `/datum/computer_file/program/chatclient/ui_act(...)` - Blocked passwords from being set on `strong` channels. +- `/obj/item/modular_computer/ui_act(...)` - Emergency mode exit program swaps between NTNRC and messenger. + +### Defines: + +- `code\__DEFINES\~doppler_defines\ntnrc.dm` + +### Master file additions + +N/A + +### Included files that are not contained in this module: + +N/A + +### Credits: + +- Ephe diff --git a/tgstation.dme b/tgstation.dme index 593af4983890d..2eae02a624f25 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -424,6 +424,7 @@ #include "code\__DEFINES\~doppler_defines\mobs.dm" #include "code\__DEFINES\~doppler_defines\mutant_blacklists.dm" #include "code\__DEFINES\~doppler_defines\mutant_variations.dm" +#include "code\__DEFINES\~doppler_defines\ntnrc.dm" #include "code\__DEFINES\~doppler_defines\obj_flags_doppler.dm" #include "code\__DEFINES\~doppler_defines\organ_slots.dm" #include "code\__DEFINES\~doppler_defines\preferences.dm" @@ -7116,6 +7117,11 @@ #include "modular_doppler\modular_weapons\company_and_or_faction_based\carwo_defense_systems\gunsets.dm" #include "modular_doppler\modular_weapons\manufacturer_examine\code\gun_company_additions.dm" #include "modular_doppler\modular_weapons\manufacturer_examine\code\manufacturer_element.dm" +#include "modular_doppler\ntnrc_for_all\code\common_chat.dm" +#include "modular_doppler\ntnrc_for_all\code\ntnrc_client_edits.dm" +#include "modular_doppler\ntnrc_for_all\code\pda_prefs_edits.dm" +#include "modular_doppler\ntnrc_for_all\code\ss_modular_computers_edits.dm" +#include "modular_doppler\ntnrc_for_all\code\username_prefs.dm" #include "modular_doppler\obj_flags_doppler\code\objs.dm" #include "modular_doppler\objects_and_structures\code\flora.dm" #include "modular_doppler\objects_and_structures\code\icemoon_tiles.dm"