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

Banishes the entire crew to being in a group chat together #205

Merged
merged 5 commits into from
Nov 20, 2024
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
6 changes: 6 additions & 0 deletions code/__DEFINES/~doppler_defines/ntnrc.dm
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 19 additions & 0 deletions code/modules/modular_computers/computers/item/computer_ui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions code/modules/modular_computers/computers/item/pda.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,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
Expand Down
7 changes: 7 additions & 0 deletions modular_doppler/ntnrc_for_all/code/common_chat.dm
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions modular_doppler/ntnrc_for_all/code/ntnrc_client_edits.dm
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions modular_doppler/ntnrc_for_all/code/pda_prefs_edits.dm
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 19 additions & 0 deletions modular_doppler/ntnrc_for_all/code/username_prefs.dm
Original file line number Diff line number Diff line change
@@ -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)
28 changes: 28 additions & 0 deletions modular_doppler/ntnrc_for_all/readme.md
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,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"
Expand Down Expand Up @@ -7052,6 +7053,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"
Expand Down
Loading