mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-11 16:14:08 +01:00
Fixes & Improves ntnrc client & ntnet conversations (#70854)
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
@@ -16,13 +16,16 @@
|
||||
tgui_id = "NtosNetChat"
|
||||
program_icon = "comment-alt"
|
||||
alert_able = TRUE
|
||||
var/last_message // Used to generate the toolbar icon
|
||||
|
||||
///The user's screen name.
|
||||
var/username
|
||||
///The last message you sent in a channel, used to tell if someone has sent a new message yet.
|
||||
var/last_message
|
||||
///The channel currently active in.
|
||||
var/active_channel
|
||||
var/list/channel_history = list()
|
||||
var/operator_mode = FALSE // Channel operator mode
|
||||
var/netadmin_mode = FALSE // Administrator mode (invisible to other users + bypasses passwords)
|
||||
//A list of all the converstations we're a part of
|
||||
///If the tablet is in Admin mode, you bypass Passwords and aren't announced when entering a channel.
|
||||
var/netadmin_mode = FALSE
|
||||
///All NTnet conversations the application is apart of.
|
||||
var/list/datum/ntnet_conversation/conversations = list()
|
||||
|
||||
/datum/computer_file/program/chatclient/New()
|
||||
@@ -34,6 +37,13 @@
|
||||
conversations.Cut()
|
||||
return ..()
|
||||
|
||||
/datum/computer_file/program/chatclient/proc/create_new_channel(channel_title, strong = FALSE)
|
||||
var/datum/ntnet_conversation/new_converstaion = new /datum/ntnet_conversation(channel_title, strong)
|
||||
new_converstaion.add_client(src)
|
||||
new_converstaion.title = channel_title
|
||||
active_channel = new_converstaion.id
|
||||
return new_converstaion
|
||||
|
||||
/datum/computer_file/program/chatclient/ui_act(action, params)
|
||||
. = ..()
|
||||
if(.)
|
||||
@@ -41,8 +51,9 @@
|
||||
|
||||
var/datum/ntnet_conversation/channel = SSnetworks.station_network.get_chat_channel_by_id(active_channel)
|
||||
var/authed = FALSE
|
||||
if(channel && ((channel.operator == src) || netadmin_mode))
|
||||
if(channel && ((channel.channel_operator == src) || netadmin_mode))
|
||||
authed = TRUE
|
||||
|
||||
switch(action)
|
||||
if("PRG_speak")
|
||||
if(!channel || isnull(active_channel))
|
||||
@@ -57,7 +68,7 @@
|
||||
|
||||
channel.add_message(message, username)
|
||||
var/mob/living/user = usr
|
||||
user.log_talk(message, LOG_CHAT, tag="as [username] to channel [channel.title]")
|
||||
user.log_talk(message, LOG_CHAT, tag = "as [username] to channel [channel.title]")
|
||||
return TRUE
|
||||
if("PRG_joinchannel")
|
||||
var/new_target = text2num(params["id"])
|
||||
@@ -82,24 +93,19 @@
|
||||
var/channel_title = reject_bad_chattext(params["new_channel_name"], CHANNELNAME_SIZE)
|
||||
if(!channel_title)
|
||||
return
|
||||
var/datum/ntnet_conversation/C = new /datum/ntnet_conversation()
|
||||
C.add_client(src)
|
||||
C.operator = src
|
||||
C.title = channel_title
|
||||
active_channel = C.id
|
||||
create_new_channel(channel_title)
|
||||
return TRUE
|
||||
if("PRG_toggleadmin")
|
||||
if(netadmin_mode)
|
||||
netadmin_mode = FALSE
|
||||
channel?.add_client(src)
|
||||
return TRUE
|
||||
return UI_UPDATE
|
||||
var/mob/living/user = usr
|
||||
if(can_run(user, TRUE, ACCESS_NETWORK))
|
||||
for(var/C in SSnetworks.station_network.chat_channels)
|
||||
var/datum/ntnet_conversation/chan = C
|
||||
chan.remove_client(src)
|
||||
for(var/datum/ntnet_conversation/channels as anything in SSnetworks.station_network.chat_channels)
|
||||
channels.remove_client(src)
|
||||
netadmin_mode = TRUE
|
||||
return TRUE
|
||||
return UI_UPDATE
|
||||
if("PRG_changename")
|
||||
var/newname = reject_bad_chattext(params["new_name"], USERNAME_SIZE)
|
||||
newname = replacetext(newname, " ", "_")
|
||||
@@ -109,7 +115,7 @@
|
||||
if(src in anychannel.active_clients)
|
||||
anychannel.add_status_message("[username] is now known as [newname].")
|
||||
username = newname
|
||||
return TRUE
|
||||
return UI_UPDATE
|
||||
if("PRG_savelog")
|
||||
if(!channel)
|
||||
return
|
||||
@@ -147,11 +153,9 @@
|
||||
if("PRG_setpassword")
|
||||
if(!authed)
|
||||
return
|
||||
|
||||
var/new_password = sanitize(params["new_password"])
|
||||
if(!authed)
|
||||
return
|
||||
|
||||
channel.password = new_password
|
||||
return TRUE
|
||||
if("PRG_mute_user")
|
||||
@@ -179,7 +183,7 @@
|
||||
last_message = null
|
||||
return TRUE
|
||||
if(channel?.messages?.len)
|
||||
ui_header = last_message == channel.messages[length(channel.messages)] ? "ntnrc_idle.gif" : "ntnrc_new.gif"
|
||||
ui_header = (last_message == channel.messages[length(channel.messages)] ? "ntnrc_idle.gif" : "ntnrc_new.gif")
|
||||
else
|
||||
ui_header = "ntnrc_idle.gif"
|
||||
|
||||
@@ -196,42 +200,38 @@
|
||||
for(var/datum/ntnet_conversation/channel as anything in SSnetworks.station_network.chat_channels)
|
||||
channel.go_offline(src)
|
||||
active_channel = null
|
||||
..()
|
||||
return ..()
|
||||
|
||||
/datum/computer_file/program/chatclient/ui_static_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["can_admin"] = can_run(user, FALSE, ACCESS_NETWORK)
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/chatclient/ui_data(mob/user)
|
||||
if(!SSnetworks.station_network || !SSnetworks.station_network.chat_channels)
|
||||
return list()
|
||||
|
||||
var/list/data = list()
|
||||
|
||||
data = get_header_data()
|
||||
|
||||
var/list/all_channels = list()
|
||||
for(var/C in SSnetworks.station_network.chat_channels)
|
||||
var/datum/ntnet_conversation/conv = C
|
||||
if(conv?.title)
|
||||
all_channels.Add(list(list(
|
||||
"chan" = conv.title,
|
||||
"id" = conv.id
|
||||
)))
|
||||
data["all_channels"] = all_channels
|
||||
|
||||
data["active_channel"] = active_channel
|
||||
data["selfref"] = REF(src) //used to verify who is you, as usernames can be copied.
|
||||
data["username"] = username
|
||||
data["adminmode"] = netadmin_mode
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/chatclient/ui_data(mob/user)
|
||||
var/list/data = get_header_data()
|
||||
if(!SSnetworks.station_network || !SSnetworks.station_network.chat_channels)
|
||||
return data
|
||||
|
||||
var/list/all_channels = list()
|
||||
for(var/datum/ntnet_conversation/conversations as anything in SSnetworks.station_network.chat_channels)
|
||||
if(conversations.title)
|
||||
all_channels.Add(list(list(
|
||||
"chan" = conversations.title,
|
||||
"id" = conversations.id,
|
||||
)))
|
||||
data["all_channels"] = all_channels
|
||||
data["active_channel"] = active_channel
|
||||
|
||||
var/datum/ntnet_conversation/channel = SSnetworks.station_network.get_chat_channel_by_id(active_channel)
|
||||
var/authed = FALSE
|
||||
data["clients"] = list()
|
||||
data["messages"] = list()
|
||||
if(channel)
|
||||
data["title"] = channel.title
|
||||
var/authed = FALSE
|
||||
if(!channel.password)
|
||||
authed = TRUE
|
||||
if(netadmin_mode)
|
||||
if(!channel.password || netadmin_mode)
|
||||
authed = TRUE
|
||||
var/list/clients = list()
|
||||
for(var/datum/computer_file/program/chatclient/channel_client as anything in channel.active_clients + channel.offline_clients)
|
||||
@@ -241,10 +241,9 @@
|
||||
"name" = channel_client.username,
|
||||
"status" = channel_client.program_state,
|
||||
"muted" = (channel_client in channel.muted_clients),
|
||||
"operator" = channel.operator == channel_client,
|
||||
"ref" = REF(channel_client)
|
||||
"operator" = (channel.channel_operator == channel_client),
|
||||
"ref" = REF(channel_client),
|
||||
)))
|
||||
data["authed"] = authed
|
||||
//no fishing for ui data allowed
|
||||
if(authed)
|
||||
data["strong"] = channel.strong
|
||||
@@ -252,18 +251,12 @@
|
||||
var/list/messages = list()
|
||||
for(var/message in channel.messages)
|
||||
messages.Add(list(list(
|
||||
"msg" = message
|
||||
"msg" = message,
|
||||
)))
|
||||
data["messages"] = messages
|
||||
data["is_operator"] = (channel.operator == src) || netadmin_mode
|
||||
else
|
||||
data["clients"] = list()
|
||||
data["messages"] = list()
|
||||
else
|
||||
data["clients"] = list()
|
||||
data["authed"] = FALSE
|
||||
data["messages"] = list()
|
||||
data["is_operator"] = (channel.channel_operator == src) || netadmin_mode
|
||||
|
||||
data["authed"] = authed
|
||||
return data
|
||||
|
||||
#undef USERNAME_SIZE
|
||||
|
||||
Reference in New Issue
Block a user