tgui usr to ui.user

This commit is contained in:
Kashargul
2024-11-13 00:49:17 +01:00
parent 49d89c0059
commit 32c9f971bc
120 changed files with 1037 additions and 1061 deletions
@@ -30,7 +30,7 @@
if("PRG_newtextfile")
if(!HDD)
return
var/newname = sanitize(tgui_input_text(usr, "Enter file name or leave blank to cancel:", "File rename"))
var/newname = sanitize(tgui_input_text(ui.user, "Enter file name or leave blank to cancel:", "File rename"))
if(!newname)
return
if(HDD.find_file_by_name(newname))
@@ -60,13 +60,13 @@
var/datum/computer_file/data/F = computer.find_file_by_uid(open_file)
if(!F || !istype(F))
return
if(F.do_not_edit && (tgui_alert(usr, "WARNING: This file is not compatible with editor. Editing it may result in permanently corrupted formatting or damaged data consistency. Edit anyway?", "Incompatible File", list("No", "Yes")) != "Yes"))
if(F.do_not_edit && (tgui_alert(ui.user, "WARNING: This file is not compatible with editor. Editing it may result in permanently corrupted formatting or damaged data consistency. Edit anyway?", "Incompatible File", list("No", "Yes")) != "Yes"))
return
var/oldtext = html_decode(F.stored_data)
oldtext = replacetext(oldtext, "\[br\]", "\n")
var/newtext = sanitize(replacetext(tgui_input_text(usr, "Editing file [F.filename].[F.filetype]. You may use most tags used in paper formatting:", "Text Editor", oldtext, MAX_TEXTFILE_LENGTH, TRUE, prevent_enter = TRUE), "\n", "\[br\]"), MAX_TEXTFILE_LENGTH)
var/newtext = sanitize(replacetext(tgui_input_text(ui.user, "Editing file [F.filename].[F.filetype]. You may use most tags used in paper formatting:", "Text Editor", oldtext, MAX_TEXTFILE_LENGTH, TRUE, prevent_enter = TRUE), "\n", "\[br\]"), MAX_TEXTFILE_LENGTH)
if(!newtext)
return
@@ -107,7 +107,7 @@
/**
* This is tgui's replacement for Topic(). It handles any user input from the UI.
*/
/datum/computer_file/program/game/tgui_act(action, list/params)
/datum/computer_file/program/game/tgui_act(action, list/params, datum/tgui/ui)
if(..()) // Always call parent in tgui_act, it handles making sure the user is allowed to interact with the UI.
return TRUE
@@ -115,8 +115,8 @@
if(computer)
printer = computer.nano_printer
// var/gamerSkillLevel = usr.mind?.get_skill_level(/datum/skill/gaming)
// var/gamerSkill = usr.mind?.get_skill_modifier(/datum/skill/gaming, SKILL_RANDS_MODIFIER)
// var/gamerSkillLevel = ui.user.mind?.get_skill_level(/datum/skill/gaming)
// var/gamerSkill = ui.user.mind?.get_skill_modifier(/datum/skill/gaming, SKILL_RANDS_MODIFIER)
switch(action)
if("Attack")
var/attackamt = 0 //Spam prevention.
@@ -162,20 +162,20 @@
return TRUE
if("Dispense_Tickets")
if(!printer)
to_chat(usr, span_notice("Hardware error: A printer is required to redeem tickets."))
to_chat(ui.user, span_notice("Hardware error: A printer is required to redeem tickets."))
return
if(printer.stored_paper <= 0)
to_chat(usr, span_notice("Hardware error: Printer is out of paper."))
to_chat(ui.user, span_notice("Hardware error: Printer is out of paper."))
return
else
computer.visible_message(span_infoplain(span_bold("\The [computer]") + " prints out paper."))
if(ticket_count >= 1)
new /obj/item/stack/arcadeticket((get_turf(computer)), 1)
to_chat(usr, span_notice("[src] dispenses a ticket!"))
to_chat(ui.user, span_notice("[src] dispenses a ticket!"))
ticket_count -= 1
printer.stored_paper -= 1
else
to_chat(usr, span_notice("You don't have any stored tickets!"))
to_chat(ui.user, span_notice("You don't have any stored tickets!"))
return TRUE
if("Start_Game")
game_active = TRUE
@@ -106,7 +106,7 @@
if(downloading || !loaded_article)
return
var/savename = sanitize(tgui_input_text(usr, "Enter file name or leave blank to cancel:", "Save article", loaded_article.filename))
var/savename = sanitize(tgui_input_text(ui.user, "Enter file name or leave blank to cancel:", "Save article", loaded_article.filename))
if(!savename)
return TRUE
var/obj/item/computer_hardware/hard_drive/HDD = computer.hard_drive
@@ -26,7 +26,7 @@
/datum/computer_file/program/chatclient/New()
username = "DefaultUser[rand(100, 999)]"
/datum/computer_file/program/chatclient/tgui_act(action, params)
/datum/computer_file/program/chatclient/tgui_act(action, params, datum/tgui/ui)
if(..())
return
@@ -47,8 +47,7 @@
return TRUE
channel.add_message(message, username)
// var/mob/living/user = usr
// user.log_talk(message, LOG_CHAT, tag="as [username] to channel [channel.title]")
// ui.user.log_talk(message, LOG_CHAT, tag="as [username] to channel [channel.title]")
return TRUE
if("PRG_joinchannel")
var/new_target = text2num(params["id"])
@@ -85,8 +84,7 @@
if(channel)
channel.remove_client(src) // We shouldn't be in channel's user list, but just in case...
return TRUE
var/mob/living/user = usr
if(can_run(user, TRUE, access_network))
if(isliving(ui.user) && can_run(ui.user, TRUE, access_network))
for(var/datum/ntnet_conversation/chan as anything in ntnet_global.chat_channels)
chan.remove_client(src)
netadmin_mode = TRUE
@@ -134,7 +134,7 @@ var/global/nttransfer_uid = 0
if(!remote || !remote.provided_file)
return
if(remote.server_password)
var/pass = sanitize(tgui_input_text(usr, "Code 401 Unauthorized. Please enter password:", "Password required"))
var/pass = sanitize(tgui_input_text(ui.user, "Code 401 Unauthorized. Please enter password:", "Password required"))
if(pass != remote.server_password)
error = "Incorrect Password"
return
@@ -152,7 +152,7 @@ var/global/nttransfer_uid = 0
provided_file = null
return TRUE
if("PRG_setpassword")
var/pass = sanitize(tgui_input_text(usr, "Enter new server password. Leave blank to cancel, input 'none' to disable password.", "Server security", "none"))
var/pass = sanitize(tgui_input_text(ui.user, "Enter new server password. Leave blank to cancel, input 'none' to disable password.", "Server security", "none"))
if(!pass)
return
if(pass == "none")
@@ -74,11 +74,11 @@
switch(action)
if("PRG_txtrpeview")
show_browser(usr,"<HTML><HEAD><TITLE>[open_file]</TITLE></HEAD>[pencode2html(loaded_data)]</BODY></HTML>", "window=[open_file]")
show_browser(ui.user,"<HTML><HEAD><TITLE>[open_file]</TITLE></HEAD>[pencode2html(loaded_data)]</BODY></HTML>", "window=[open_file]")
return TRUE
if("PRG_taghelp")
to_chat(usr, span_notice("The hologram of a googly-eyed paper clip helpfully tells you:"))
to_chat(ui.user, span_notice("The hologram of a googly-eyed paper clip helpfully tells you:"))
var/help = {"
\[br\] : Creates a linebreak.
\[center\] - \[/center\] : Centers the text.
@@ -104,7 +104,7 @@
\[redlogo\] - Inserts red NT logo image.
\[sglogo\] - Inserts Solgov insignia image."}
to_chat(usr, help)
to_chat(ui.user, help)
return TRUE
if("PRG_closebrowser")
@@ -121,7 +121,7 @@
if("PRG_openfile")
if(is_edited)
if(tgui_alert(usr, "Would you like to save your changes first?","Save Changes",list("Yes","No")) == "Yes")
if(tgui_alert(ui.user, "Would you like to save your changes first?","Save Changes",list("Yes","No")) == "Yes")
save_file(open_file)
browsing = 0
if(!open_file(params["PRG_openfile"]))
@@ -130,10 +130,10 @@
if("PRG_newfile")
if(is_edited)
if(tgui_alert(usr, "Would you like to save your changes first?","Save Changes",list("Yes","No")) == "Yes")
if(tgui_alert(ui.user, "Would you like to save your changes first?","Save Changes",list("Yes","No")) == "Yes")
save_file(open_file)
var/newname = sanitize(tgui_input_text(usr, "Enter file name:", "New File"))
var/newname = sanitize(tgui_input_text(ui.user, "Enter file name:", "New File"))
if(!newname)
return TRUE
var/datum/computer_file/data/F = create_file(newname)
@@ -146,7 +146,7 @@
return TRUE
if("PRG_saveasfile")
var/newname = sanitize(tgui_input_text(usr, "Enter file name:", "Save As"))
var/newname = sanitize(tgui_input_text(ui.user, "Enter file name:", "Save As"))
if(!newname)
return TRUE
var/datum/computer_file/data/F = create_file(newname, loaded_data)
@@ -158,7 +158,7 @@
if("PRG_savefile")
if(!open_file)
open_file = sanitize(tgui_input_text(usr, "Enter file name:", "Save As"))
open_file = sanitize(tgui_input_text(ui.user, "Enter file name:", "Save As"))
if(!open_file)
return 0
if(!save_file(open_file))
@@ -169,7 +169,7 @@
var/oldtext = html_decode(loaded_data)
oldtext = replacetext(oldtext, "\[br\]", "\n")
var/newtext = sanitize(replacetext(tgui_input_text(usr, "Editing file '[open_file]'. You may use most tags used in paper formatting:", "Text Editor", oldtext, MAX_TEXTFILE_LENGTH, TRUE, prevent_enter = TRUE), "\n", "\[br\]"), MAX_TEXTFILE_LENGTH)
var/newtext = sanitize(replacetext(tgui_input_text(ui.user, "Editing file '[open_file]'. You may use most tags used in paper formatting:", "Text Editor", oldtext, MAX_TEXTFILE_LENGTH, TRUE, prevent_enter = TRUE), "\n", "\[br\]"), MAX_TEXTFILE_LENGTH)
if(!newtext)
return
loaded_data = newtext
@@ -66,7 +66,7 @@
return TRUE
// High security - can only be operated when the user has an ID with access on them.
var/obj/item/card/id/I = usr.GetIdCard()
var/obj/item/card/id/I = ui.user.GetIdCard()
if(!istype(I) || !(access_network in I.GetAccess()))
return TRUE
@@ -93,7 +93,7 @@
if(!current_account)
return TRUE
var/newpass = sanitize(tgui_input_text(usr,"Enter new password for account [current_account.login]", "Password", null, 100), 100)
var/newpass = sanitize(tgui_input_text(ui.user,"Enter new password for account [current_account.login]", "Password", null, 100), 100)
if(!newpass)
return TRUE
current_account.password = newpass
@@ -118,10 +118,10 @@
return TRUE
if("newaccount")
var/newdomain = sanitize(tgui_input_list(usr,"Pick domain:", "Domain name", using_map.usable_email_tlds))
var/newdomain = sanitize(tgui_input_list(ui.user,"Pick domain:", "Domain name", using_map.usable_email_tlds))
if(!newdomain)
return TRUE
var/newlogin = sanitize(tgui_input_text(usr,"Pick account name (@[newdomain]):", "Account name", null, 100), 100)
var/newlogin = sanitize(tgui_input_text(ui.user,"Pick account name (@[newdomain]):", "Account name", null, 100), 100)
if(!newlogin)
return TRUE
@@ -60,8 +60,8 @@
ntnet_global.setting_disabled = FALSE
return TRUE
var/response = tgui_alert(usr, "Really disable NTNet wireless? If your computer is connected wirelessly you won't be able to turn it back on! This will affect all connected wireless devices.", "NTNet shutdown", list("Yes", "No"))
if(response == "Yes" && tgui_status(usr, state) == STATUS_INTERACTIVE)
var/response = tgui_alert(ui.user, "Really disable NTNet wireless? If your computer is connected wirelessly you won't be able to turn it back on! This will affect all connected wireless devices.", "NTNet shutdown", list("Yes", "No"))
if(response == "Yes" && tgui_status(ui.user, state) == STATUS_INTERACTIVE)
ntnet_global.setting_disabled = TRUE
return TRUE
if("purgelogs")
@@ -81,14 +81,14 @@
if("ban_nid")
if(!ntnet_global)
return
var/nid = tgui_input_number(usr,"Enter NID of device which you want to block from the network:", "Enter NID")
if(nid && tgui_status(usr, state) == STATUS_INTERACTIVE)
var/nid = tgui_input_number(ui.user,"Enter NID of device which you want to block from the network:", "Enter NID")
if(nid && tgui_status(ui.user, state) == STATUS_INTERACTIVE)
ntnet_global.banned_nids |= nid
return TRUE
if("unban_nid")
if(!ntnet_global)
return
var/nid = tgui_input_number(usr,"Enter NID of device which you want to unblock from the network:", "Enter NID")
if(nid && tgui_status(usr, state) == STATUS_INTERACTIVE)
var/nid = tgui_input_number(ui.user,"Enter NID of device which you want to unblock from the network:", "Enter NID")
if(nid && tgui_status(ui.user, state) == STATUS_INTERACTIVE)
ntnet_global.banned_nids -= nid
return TRUE
@@ -72,19 +72,19 @@ var/warrant_uid = 0
// The following actions will only be possible if the user has an ID with security access equipped. This is in line with modular computer framework's authentication methods,
// which also use RFID scanning to allow or disallow access to some functions. Anyone can view warrants, editing requires ID. This also prevents situations where you show a tablet
// to someone who is to be arrested, which allows them to change the stuff there.
var/obj/item/card/id/I = usr.GetIdCard()
var/obj/item/card/id/I = ui.user.GetIdCard()
if(!istype(I) || !I.registered_name || !(access_security in I.GetAccess()))
to_chat(usr, "Authentication error: Unable to locate ID with appropriate access to allow this operation.")
to_chat(ui.user, "Authentication error: Unable to locate ID with appropriate access to allow this operation.")
return
switch(action)
if("addwarrant")
. = TRUE
var/datum/data/record/warrant/W = new()
var/temp = tgui_alert(usr, "Do you want to create a search-, or an arrest warrant?", "Warrant Type", list("Search","Arrest","Cancel"))
var/temp = tgui_alert(ui.user, "Do you want to create a search-, or an arrest warrant?", "Warrant Type", list("Search","Arrest","Cancel"))
if(!temp)
return
if(tgui_status(usr, state) == STATUS_INTERACTIVE)
if(tgui_status(ui.user, state) == STATUS_INTERACTIVE)
if(temp == "Arrest")
W.fields["namewarrant"] = "Unknown"
W.fields["charges"] = "No charges present"
@@ -112,24 +112,24 @@ var/warrant_uid = 0
var/namelist = list()
for(var/datum/data/record/t in data_core.general)
namelist += t.fields["name"]
var/new_name = sanitize(tgui_input_list(usr, "Please input name:", "Name Choice", namelist))
if(tgui_status(usr, state) == STATUS_INTERACTIVE)
var/new_name = sanitize(tgui_input_list(ui.user, "Please input name:", "Name Choice", namelist))
if(tgui_status(ui.user, state) == STATUS_INTERACTIVE)
if (!new_name)
return
activewarrant.fields["namewarrant"] = new_name
if("editwarrantnamecustom")
. = TRUE
var/new_name = sanitize(tgui_input_text(usr, "Please input name"))
if(tgui_status(usr, state) == STATUS_INTERACTIVE)
var/new_name = sanitize(tgui_input_text(ui.user, "Please input name"))
if(tgui_status(ui.user, state) == STATUS_INTERACTIVE)
if (!new_name)
return
activewarrant.fields["namewarrant"] = new_name
if("editwarrantcharges")
. = TRUE
var/new_charges = sanitize(tgui_input_text(usr, "Please input charges", "Charges", activewarrant.fields["charges"]))
if(tgui_status(usr, state) == STATUS_INTERACTIVE)
var/new_charges = sanitize(tgui_input_text(ui.user, "Please input charges", "Charges", activewarrant.fields["charges"]))
if(tgui_status(ui.user, state) == STATUS_INTERACTIVE)
if (!new_charges)
return
activewarrant.fields["charges"] = new_charges
@@ -137,6 +137,6 @@ var/warrant_uid = 0
if("editwarrantauth")
. = TRUE
if(!(access_hos in I.GetAccess())) // VOREStation edit begin
to_chat(usr, span_warning("You don't have the access to do this!"))
to_chat(ui.user, span_warning("You don't have the access to do this!"))
return // VOREStation edit end
activewarrant.fields["auth"] = "[I.registered_name] - [I.assignment ? I.assignment : "(Unknown)"]"