mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-02 13:02:38 +00:00
* Add the system for managed global variables * Travis ban old globals * So you CAN inline proccall, that's neat * Fix that * master.dm * Remove the hack procs * Move InitGlobals to the proper spot * configuration.dm * Fix the missing pre-slash * clockcult.dm * This is probably for the best * Doy * Fix shit * Rest of the DEFINES tree * Fix * Use global. for access * Update find_references_in_globals Always hated that proc Whoever made it must've bee a r e a l idiot... * __HELPERS tree * Move global initialization to master. Fix the declaration * database.dm * Dat newline * I said DECLARATIVE order! * Here's something you can chew on @Iamgoofball * game_modes.dm * Fix this * genetics.dm * flavor_misc.dm * More stuff * Do it mso's way. Keep the controllers as global * Make master actually see it * Fix * Finish _globalvars/lists * Finish the rest of the _globalvars tree * This is weird * Migrate the controllers * SLOTH -> GLOB * Lighting globals * round_start_time -> ticker * PAI card list -> pai SS * record_id_num -> static * Diseases list -> SSdisease * More disease globals to the SS * More disease stuff * Emote list * Better and better * Bluh * So much stuff * Ahh * Wires * dview * station_areas * Teleportlocs * blood_splatter_icons * Stuff and such * More stuff * RAD IO * More stuff and such * Blob shit * Changeling stuff * Add "Balance" to changelogs * Balance for changelog compiler + Auto Tagging * Update the PR template * hivemind_bank * Bip * sacrificed * Good shit * Better define * More cult shit * Devil shit * Gang shit * > borers Fix shit * Rename the define * Nuke * Objectives * Sandbox * Multiverse sword * Announce systems * Stuff and such * TC con * Airlock * doppllllerrrrrr * holopads * Shut up byond you inconsistent fuck * Sneaky fuck * Burp * Bip * Fixnshit * Port without regard * askdlfjs; * asdfjasoidojfi * Protected globals and more * SO MANY * ajsimkvahsaoisd * akfdsiaopwimfeoiwafaw * gsdfigjosidjfgiosdg * AHHHHHHHHHHHHHHHHHHHHHHH!!!!! * facerolll * ASDFASDFASDF * Removes the unused parts of dmm_suite * WIP * Fix quote * asdfjauwfnkjs * afwlunhskjfda * asfjlaiwuefhaf * SO CLOSE * wwwweeeeeewwwww * agdgmoewranwg * HOLY MOTHER OF FUCK AND THATS JUST HALF THE JOB?!? * Fix syntax errors * 100 errors * Another 100 * So many... * Ugh * More shit * kilme * Stuuuuuufffff * ajrgmrlshio;djfa;sdkl * jkbhkhjbmjvjmh * soi soi soi * butt * TODAY WE LEARNED THAT GLOBAL AND STATIC ARE THE EXACT SAME FUCKING THING * lllllllllllllllllllllllllllllllllllllllllll * afsdijfiawhnflnjhnwsdfs * yugykihlugk,kj * time to go * STUFFF!!! * AAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!! * ngoaijdjlfkamsdlkf * Break time * aufjsdklfalsjfi * CONTROL KAY AND PRAY * IT COMPILEELEELELAKLJFKLDAFJLKFDJLADKJHFLJKAJGAHIEJALDFJ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * Goteem * Fix testing mode * This does not belong in this PR * Convert it to a controller * Eh, fuck this option * Revert controllerization Ill do it some other time * Fix * Working controllerization * FOR THE LOVE OF CHRIST PROTECT THE LOGS * Protect admins and deadmins * Use the inbuilt proc
237 lines
7.5 KiB
Plaintext
237 lines
7.5 KiB
Plaintext
/datum/computer_file/program/chatclient
|
|
filename = "ntnrc_client"
|
|
filedesc = "NTNet Relay Chat Client"
|
|
program_icon_state = "command"
|
|
extended_desc = "This program allows communication over NTNRC network"
|
|
size = 8
|
|
requires_ntnet = 1
|
|
requires_ntnet_feature = NTNET_COMMUNICATION
|
|
network_destination = "NTNRC server"
|
|
ui_header = "ntnrc_idle.gif"
|
|
available_on_ntnet = 1
|
|
var/last_message = null // Used to generate the toolbar icon
|
|
var/username
|
|
var/datum/ntnet_conversation/channel = null
|
|
var/operator_mode = 0 // Channel operator mode
|
|
var/netadmin_mode = 0 // Administrator mode (invisible to other users + bypasses passwords)
|
|
|
|
/datum/computer_file/program/chatclient/New()
|
|
username = "DefaultUser[rand(100, 999)]"
|
|
|
|
/datum/computer_file/program/chatclient/ui_act(action, params)
|
|
if(..())
|
|
return 1
|
|
|
|
switch(action)
|
|
if("PRG_speak")
|
|
. = 1
|
|
if(!channel)
|
|
return 1
|
|
var/mob/living/user = usr
|
|
var/message = reject_bad_text(input(user, "Enter message or leave blank to cancel: "))
|
|
if(!message || !channel)
|
|
return
|
|
channel.add_message(message, username)
|
|
log_chat("[user]/([user.ckey]) as [username] sent to [channel.title]: [message]")
|
|
|
|
if("PRG_joinchannel")
|
|
. = 1
|
|
var/datum/ntnet_conversation/C
|
|
for(var/datum/ntnet_conversation/chan in GLOB.ntnet_global.chat_channels)
|
|
if(chan.id == text2num(params["id"]))
|
|
C = chan
|
|
break
|
|
|
|
if(!C)
|
|
return 1
|
|
|
|
if(netadmin_mode)
|
|
channel = C // Bypasses normal leave/join and passwords. Technically makes the user invisible to others.
|
|
return 1
|
|
|
|
if(C.password)
|
|
var/mob/living/user = usr
|
|
var/password = reject_bad_text(input(user,"Access Denied. Enter password:"))
|
|
if(C && (password == C.password))
|
|
C.add_client(src)
|
|
channel = C
|
|
return 1
|
|
C.add_client(src)
|
|
channel = C
|
|
if("PRG_leavechannel")
|
|
. = 1
|
|
if(channel)
|
|
channel.remove_client(src)
|
|
channel = null
|
|
if("PRG_newchannel")
|
|
. = 1
|
|
var/mob/living/user = usr
|
|
var/channel_title = reject_bad_text(input(user,"Enter channel name or leave blank to cancel:"))
|
|
if(!channel_title)
|
|
return
|
|
var/datum/ntnet_conversation/C = new/datum/ntnet_conversation()
|
|
C.add_client(src)
|
|
C.operator = src
|
|
channel = C
|
|
C.title = channel_title
|
|
if("PRG_toggleadmin")
|
|
. = 1
|
|
if(netadmin_mode)
|
|
netadmin_mode = 0
|
|
if(channel)
|
|
channel.remove_client(src) // We shouldn't be in channel's user list, but just in case...
|
|
channel = null
|
|
return 1
|
|
var/mob/living/user = usr
|
|
if(can_run(usr, 1, GLOB.access_network))
|
|
if(channel)
|
|
var/response = alert(user, "Really engage admin-mode? You will be disconnected from your current channel!", "NTNRC Admin mode", "Yes", "No")
|
|
if(response == "Yes")
|
|
if(channel)
|
|
channel.remove_client(src)
|
|
channel = null
|
|
else
|
|
return
|
|
netadmin_mode = 1
|
|
if("PRG_changename")
|
|
. = 1
|
|
var/mob/living/user = usr
|
|
var/newname = sanitize(input(user,"Enter new nickname or leave blank to cancel:"))
|
|
if(!newname)
|
|
return 1
|
|
if(channel)
|
|
channel.add_status_message("[username] is now known as [newname].")
|
|
username = newname
|
|
|
|
if("PRG_savelog")
|
|
. = 1
|
|
if(!channel)
|
|
return
|
|
var/mob/living/user = usr
|
|
var/logname = input(user,"Enter desired logfile name (.log) or leave blank to cancel:")
|
|
if(!logname || !channel)
|
|
return 1
|
|
var/datum/computer_file/data/logfile = new/datum/computer_file/data/logfile()
|
|
// Now we will generate HTML-compliant file that can actually be viewed/printed.
|
|
logfile.filename = logname
|
|
logfile.stored_data = "\[b\]Logfile dump from NTNRC channel [channel.title]\[/b\]\[BR\]"
|
|
for(var/logstring in channel.messages)
|
|
logfile.stored_data += "[logstring]\[BR\]"
|
|
logfile.stored_data += "\[b\]Logfile dump completed.\[/b\]"
|
|
logfile.calculate_size()
|
|
var/obj/item/weapon/computer_hardware/hard_drive/hard_drive = computer.all_components[MC_HDD]
|
|
if(!computer || !hard_drive || !hard_drive.store_file(logfile))
|
|
if(!computer)
|
|
// This program shouldn't even be runnable without computer.
|
|
CRASH("Var computer is null!")
|
|
return 1
|
|
if(!hard_drive)
|
|
computer.visible_message("\The [computer] shows an \"I/O Error - Hard drive connection error\" warning.")
|
|
else // In 99.9% cases this will mean our HDD is full
|
|
computer.visible_message("\The [computer] shows an \"I/O Error - Hard drive may be full. Please free some space and try again. Required space: [logfile.size]GQ\" warning.")
|
|
if("PRG_renamechannel")
|
|
. = 1
|
|
if(!operator_mode || !channel)
|
|
return 1
|
|
var/mob/living/user = usr
|
|
var/newname = reject_bad_text(input(user, "Enter new channel name or leave blank to cancel:"))
|
|
if(!newname || !channel)
|
|
return
|
|
channel.add_status_message("Channel renamed from [channel.title] to [newname] by operator.")
|
|
channel.title = newname
|
|
if("PRG_deletechannel")
|
|
. = 1
|
|
if(channel && ((channel.operator == src) || netadmin_mode))
|
|
qdel(channel)
|
|
channel = null
|
|
if("PRG_setpassword")
|
|
. = 1
|
|
if(!channel || ((channel.operator != src) && !netadmin_mode))
|
|
return 1
|
|
|
|
var/mob/living/user = usr
|
|
var/newpassword = sanitize(input(user, "Enter new password for this channel. Leave blank to cancel, enter 'nopassword' to remove password completely:"))
|
|
if(!channel || !newpassword || ((channel.operator != src) && !netadmin_mode))
|
|
return 1
|
|
|
|
if(newpassword == "nopassword")
|
|
channel.password = ""
|
|
else
|
|
channel.password = newpassword
|
|
|
|
/datum/computer_file/program/chatclient/process_tick()
|
|
..()
|
|
if(program_state != PROGRAM_STATE_KILLED)
|
|
ui_header = "ntnrc_idle.gif"
|
|
if(channel)
|
|
// Remember the last message. If there is no message in the channel remember null.
|
|
last_message = channel.messages.len ? channel.messages[channel.messages.len - 1] : null
|
|
else
|
|
last_message = null
|
|
return 1
|
|
if(channel && channel.messages && channel.messages.len)
|
|
ui_header = last_message == channel.messages[channel.messages.len - 1] ? "ntnrc_idle.gif" : "ntnrc_new.gif"
|
|
else
|
|
ui_header = "ntnrc_idle.gif"
|
|
|
|
/datum/computer_file/program/chatclient/kill_program(forced = FALSE)
|
|
if(channel)
|
|
channel.remove_client(src)
|
|
channel = null
|
|
..()
|
|
|
|
/datum/computer_file/program/chatclient/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
|
|
|
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
|
if (!ui)
|
|
|
|
|
|
var/datum/asset/assets = get_asset_datum(/datum/asset/simple/headers)
|
|
assets.send(user)
|
|
|
|
|
|
ui = new(user, src, ui_key, "ntnet_chat", "NTNet Relay Chat Client", 575, 700, state = state)
|
|
ui.open()
|
|
ui.set_autoupdate(state = 1)
|
|
|
|
|
|
/datum/computer_file/program/chatclient/ui_data(mob/user)
|
|
if(!GLOB.ntnet_global || !GLOB.ntnet_global.chat_channels)
|
|
return
|
|
|
|
var/list/data = list()
|
|
|
|
data = get_header_data()
|
|
|
|
|
|
data["adminmode"] = netadmin_mode
|
|
if(channel)
|
|
data["title"] = channel.title
|
|
var/list/messages[0]
|
|
for(var/M in channel.messages)
|
|
messages.Add(list(list(
|
|
"msg" = M
|
|
)))
|
|
data["messages"] = messages
|
|
var/list/clients[0]
|
|
for(var/C in channel.clients)
|
|
var/datum/computer_file/program/chatclient/cl = C
|
|
clients.Add(list(list(
|
|
"name" = cl.username
|
|
)))
|
|
data["clients"] = clients
|
|
operator_mode = (channel.operator == src) ? 1 : 0
|
|
data["is_operator"] = operator_mode || netadmin_mode
|
|
|
|
else // Channel selection screen
|
|
var/list/all_channels[0]
|
|
for(var/C in GLOB.ntnet_global.chat_channels)
|
|
var/datum/ntnet_conversation/conv = C
|
|
if(conv && conv.title)
|
|
all_channels.Add(list(list(
|
|
"chan" = conv.title,
|
|
"id" = conv.id
|
|
)))
|
|
data["all_channels"] = all_channels
|
|
|
|
return data |