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

[TM ONLY] Early mirror of one NTNRC fix prs #208

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 2 additions & 2 deletions code/modules/modular_computers/computers/item/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,14 @@
if(NTNET_ETHERNET_SIGNAL)
data["PC_ntneticon"] = "sig_lan.gif"

var/list/program_headers = list()
if(length(idle_threads))
var/list/program_headers = list()
for(var/datum/computer_file/program/idle_programs as anything in idle_threads)
if(!idle_programs.ui_header)
continue
program_headers.Add(list(list("icon" = idle_programs.ui_header)))

data["PC_programheaders"] = program_headers
data["PC_programheaders"] = program_headers

data["PC_stationtime"] = station_time_timestamp()
data["PC_stationdate"] = "[time2text(world.realtime, "DDD, Month DD")], [CURRENT_STATION_YEAR]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
///ID using the UID.
var/id

///List of all messages sent in the conversation.
///Associative list of all messages sent in the conversation. id > message
var/list/messages = list()
///ID used for next message, increments each use. Convert to string before use.
var/next_message_id = 0

///The "Administrator" of the channel, the creator starts as channel's operator by default.
var/datum/computer_file/program/chatclient/channel_operator
Expand Down Expand Up @@ -45,11 +47,16 @@

/datum/ntnet_conversation/proc/add_message(message, username)
message = "[station_time_timestamp(format = "hh:mm")] [username]: [message]"
messages.Add(message)
var/message_id = "[next_message_id]"
next_message_id++
messages[message_id] = message
trim_message_list()

/datum/ntnet_conversation/proc/add_status_message(message)
messages.Add("[station_time_timestamp(format = "hh:mm")] -!- [message]")
message = "[station_time_timestamp(format = "hh:mm")] -!- [message]"
var/message_id = "[next_message_id]"
next_message_id++
messages[message_id] = message
trim_message_list()

/datum/ntnet_conversation/proc/trim_message_list()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

///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 id of the last message sent in a channel, used to tell if someone has sent a new message yet.
var/last_message_id
///The channel currently active in.
var/active_channel
///If the tablet is in Admin mode, you bypass Passwords and aren't announced when entering a channel.
Expand Down Expand Up @@ -133,8 +133,8 @@
// Now we will generate HTML-compliant file that can actually be viewed/printed.
logfile.filename = logname
logfile.stored_text = "\[b\]Logfile dump from NTNRC channel [channel.title]\[/b\]\[BR\]"
for(var/logstring in channel.messages)
logfile.stored_text = "[logfile.stored_text][logstring]\[BR\]"
for(var/message_id in channel.messages)
logfile.stored_text = "[logfile.stored_text][channel.messages[message_id]]\[BR\]"
logfile.stored_text = "[logfile.stored_text]\[b\]Logfile dump completed.\[/b\]"
logfile.calculate_size()
if(!computer || !computer.store_file(logfile))
Expand Down Expand Up @@ -183,19 +183,23 @@

/datum/computer_file/program/chatclient/process_tick(seconds_per_tick)
. = ..()
var/datum/ntnet_conversation/channel = SSmodular_computers.get_chat_channel_by_id(active_channel)
if(src in computer.idle_threads)

if(!(src in computer.idle_threads))
return

var/datum/ntnet_conversation/watched_channel = SSmodular_computers.get_chat_channel_by_id(active_channel)
if(isnull(watched_channel)) // If we're not in a channel, no need for a message notification header.
ui_header = null
return
if(!length(watched_channel.messages)) // But if there's no messages, we do still wait for a message.
ui_header = "ntnrc_idle.gif"
if(channel)
// Remember the last message. If there is no message in the channel remember null.
last_message = length(channel.messages) ? channel.messages[length(channel.messages)] : null
else
last_message = null
return TRUE
if(channel?.messages?.len)
ui_header = (last_message == channel.messages[length(channel.messages)] ? "ntnrc_idle.gif" : "ntnrc_new.gif")
else
return

var/last_message_id_found = watched_channel.messages[length(watched_channel.messages)]
if(last_message_id_found == last_message_id)
ui_header = "ntnrc_idle.gif"
return
ui_header = "ntnrc_new.gif"

/datum/computer_file/program/chatclient/on_start(mob/living/user)
. = ..()
Expand All @@ -220,6 +224,17 @@
return STATUS_AWAY
return STATUS_OFFLINE

/datum/computer_file/program/chatclient/background_program(mob/user)
. = ..()
var/datum/ntnet_conversation/open_channel = SSmodular_computers.get_chat_channel_by_id(active_channel)
if(isnull(open_channel) || !length(open_channel.messages))
last_message_id = null
ui_header = null
return

last_message_id = open_channel.messages[length(open_channel.messages)]
ui_header = "ntnrc_idle.gif"

/datum/computer_file/program/chatclient/ui_static_data(mob/user)
var/list/data = list()
data["selfref"] = REF(src) //used to verify who is you, as usernames can be copied.
Expand Down Expand Up @@ -265,8 +280,10 @@
data["clients"] = clients
var/list/messages = list()
for(var/i=channel.messages.len to 1 step -1)
var/message_id = channel.messages[i]
messages.Add(list(list(
"msg" = channel.messages[i],
"key" = message_id,
"msg" = channel.messages[message_id],
)))
data["messages"] = messages
data["is_operator"] = (channel.channel_operator == src) || netadmin_mode
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui/interfaces/NtosNetChat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const NtosNetChat = (props) => {
{(in_channel &&
(authorized ? (
messages.map((message) => (
<Box key={message.msg}>{message.msg}</Box>
<Box key={message.key}>{message.msg}</Box>
))
) : (
<Box textAlign="center">
Expand Down
Loading