Skip to content

Commit

Permalink
[MIRROR] Adds NTNRC Notifications and NT Relay Chat to PDA defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
BurpleBineapple authored and SierraHelper committed Dec 4, 2023
1 parent 9075006 commit 2bb2ca5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
var/datum/extension/interactive/ntos/os = get_extension(src, /datum/extension/interactive/ntos)
if(os)
os.create_file(new/datum/computer_file/program/email_client())
os.create_file(new/datum/computer_file/program/chatclient())
os.create_file(new/datum/computer_file/program/crew_manifest())
os.create_file(new/datum/computer_file/program/wordprocessor())
os.create_file(new/datum/computer_file/program/records())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
program_key_state = "med_key"
program_menu_icon = "comment"
extended_desc = "This program allows communication over NTNRC network"
size = 8
size = 2
processing_size = 0
requires_ntnet = TRUE
requires_ntnet_feature = NTNET_COMMUNICATION
network_destination = "NTNRC server"
Expand All @@ -20,6 +21,8 @@
var/operator_mode = FALSE
/// Administrator mode (invisible to other users + bypasses passwords)
var/netadmin_mode = FALSE
/// Mutes notifications
var/muted = FALSE
usage_flags = PROGRAM_ALL

/datum/computer_file/program/chatclient/New()
Expand All @@ -38,6 +41,7 @@
if(!message || !channel)
return
channel.add_message(message, username)
ntnrc_alert("[username] sent an NTNRC message.")

if(href_list["PRG_joinchannel"])
. = TOPIC_HANDLED
Expand All @@ -60,26 +64,29 @@
if(C && (password == C.password))
C.add_client(src)
channel = C
ntnrc_alert("A user has joined your channel.")
return TOPIC_HANDLED
C.add_client(src)
channel = C
ntnrc_alert("A user has joined your channel.")
if(href_list["PRG_leavechannel"])
. = TOPIC_HANDLED
if(channel)
channel.remove_client(src)
ntnrc_alert("A user has left your channel.")
channel = null
if(href_list["PRG_newchannel"])
. = TOPIC_HANDLED
var/mob/living/user = usr
var/channel_title = sanitizeSafe(input(user,"Enter channel name or leave blank to cancel:"), 64)
if(!channel_title)
return
var/atom/A = computer.get_physical_host()
var/datum/ntnet_conversation/C = new/datum/ntnet_conversation(A.z)
C.add_client(src)
C.operator = src
channel = C
C.title = channel_title
var/turf/turf = get_turf(computer.get_physical_host())
var/datum/ntnet_conversation/conversation = new/datum/ntnet_conversation(turf.z)
conversation.add_client(src)
conversation.operator = src
channel = conversation
conversation.title = channel_title
if(href_list["PRG_toggleadmin"])
. = TOPIC_HANDLED
if(netadmin_mode)
Expand All @@ -95,6 +102,7 @@
if(response == "Yes")
if(channel)
channel.remove_client(src)
ntnrc_alert("A user has left your channel.")
channel = null
else
return
Expand All @@ -109,6 +117,14 @@
channel.add_status_message("[username] is now known as [newname].")
username = newname

if (href_list["PRG_mutenotif"])
. = TOPIC_HANDLED
muted = !muted
if (muted)
computer.visible_notification(SPAN_NOTICE("Channel notifications have been disabled."))
return
computer.visible_notification(SPAN_NOTICE("Channel notifications have been enabled."))

if(href_list["PRG_savelog"])
. = TOPIC_HANDLED
if(!channel)
Expand Down Expand Up @@ -157,9 +173,10 @@

/datum/computer_file/program/chatclient/process_tick()
..()
var/atom/A = computer.get_physical_host()
if(channel && !(channel.source_z in GetConnectedZlevels(A.z)))
var/turf/turf = get_turf(computer.get_physical_host())
if (channel && !(channel.source_z in GetConnectedZlevels(turf.z)))
channel.remove_client(src)
ntnrc_alert("A user has left your channel.")
channel = null

if(program_state != PROGRAM_STATE_KILLED)
Expand All @@ -179,9 +196,19 @@
/datum/computer_file/program/chatclient/on_shutdown(forced = FALSE)
if(channel)
channel.remove_client(src)
src.ntnrc_alert("A user has left your channel.")
channel = null
..(forced)

/datum/computer_file/program/chatclient/proc/ntnrc_alert(message)
if (!istype(src))
return
for (var/datum/computer_file/program/chatclient/client in channel.clients)
if (client == src || client.muted)
continue
client.computer.visible_notification(SPAN_NOTICE(message))
client.computer.audible_notification("sound/machines/ping.ogg")

/datum/nano_module/program/computer_chatclient
name = "NTNet Relay Chat Client"

Expand Down Expand Up @@ -217,8 +244,8 @@

else // Channel selection screen
var/list/all_channels[0]
var/atom/A = C.computer.get_physical_host()
var/list/connected_zs = GetConnectedZlevels(A.z)
var/turf/turf = get_turf(C.computer.get_physical_host())
var/list/connected_zs = GetConnectedZlevels(turf.z)
for(var/datum/ntnet_conversation/conv in ntnet_global.chat_channels)
if(conv && conv.title && (conv.source_z in connected_zs))
all_channels.Add(list(list(
Expand Down
15 changes: 8 additions & 7 deletions nano/templates/ntnet_chat.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

{{if data.title}}
<div class="itemLabel">
Current channel:
Current channel:
</div>
<div class="itemContent">
{{:data.title}}
</div>
<div class="itemLabel">
Operator access:
Operator access:
</div>
<div class="itemContent">
{{if data.is_operator}}
Expand All @@ -20,12 +20,13 @@
{{/if}}
</div>
<div class="itemLabel">
Controls:
Controls:
</div>
<div class="itemContent">
<table>
<tr><td>{{:helper.link("Send message", null, {'PRG_speak' : 1})}}
<tr><td>{{:helper.link("Change nickname", null, {'PRG_changename' : 1})}}
<tr><td>{{:helper.link("Toggle notifications", null, {'PRG_mutenotif' : 1})}}
<tr><td>{{:helper.link("Toggle administration mode", null, {'PRG_toggleadmin' : 1})}}
<tr><td>{{:helper.link("Leave channel", null, {'PRG_leavechannel' : 1})}}
<tr><td>{{:helper.link("Save log to local drive", null, {'PRG_savelog' : 1})}}
Expand All @@ -35,7 +36,7 @@
<tr><td>{{:helper.link("Delete channel", null, {'PRG_deletechannel' : 1})}}
{{/if}}
</table>
</div>
</div>
<b>Chat Window</b>
<div class="statusDisplay" style="overflow: auto;">
<div class="item">
Expand All @@ -45,7 +46,7 @@
{{/for}}
</div>
</div>
</div>
</div>
<b>Connected Users</b><br>
{{for data.clients}}
{{:value.name}}<br>
Expand All @@ -59,8 +60,8 @@
</table>
<b>Available channels:</b>
<table>
{{for data.all_channels}}
{{for data.all_channels}}
<tr><td>{{:helper.link(value.chan, null, {'PRG_joinchannel' : value.id})}}<br>
{{/for}}
</table>
{{/if}}
{{/if}}

0 comments on commit 2bb2ca5

Please sign in to comment.