mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 03:33:21 +00:00
TGUI Additions
This commit is contained in:
@@ -218,7 +218,6 @@ var/global/floorIsLava = 0
|
|||||||
/datum/player_info/var/content // text content of the information
|
/datum/player_info/var/content // text content of the information
|
||||||
/datum/player_info/var/timestamp // Because this is bloody annoying
|
/datum/player_info/var/timestamp // Because this is bloody annoying
|
||||||
|
|
||||||
#define PLAYER_NOTES_ENTRIES_PER_PAGE 50
|
|
||||||
/datum/admins/proc/PlayerNotes()
|
/datum/admins/proc/PlayerNotes()
|
||||||
set category = "Admin"
|
set category = "Admin"
|
||||||
set name = "Player Notes"
|
set name = "Player Notes"
|
||||||
@@ -235,56 +234,20 @@ var/global/floorIsLava = 0
|
|||||||
if (!istype(src,/datum/admins))
|
if (!istype(src,/datum/admins))
|
||||||
to_chat(usr, "Error: you are not an admin!")
|
to_chat(usr, "Error: you are not an admin!")
|
||||||
return
|
return
|
||||||
var/filter = input(usr, "Filter string (case-insensitive regex)", "Player notes filter") as text|null
|
var/filter = tgui_input_text(usr, "Filter string (case-insensitive regex)", "Player notes filter")
|
||||||
PlayerNotesPage(1, filter)
|
PlayerNotesPage(1, filter)
|
||||||
|
|
||||||
/datum/admins/proc/PlayerNotesPage(page, filter)
|
/datum/admins/proc/PlayerNotesPage(page, filter)
|
||||||
var/dat = "<B>Player notes</B> - <a href='?src=\ref[src];notes=filter'>Apply Filter</a><HR>"
|
|
||||||
var/savefile/S=new("data/player_notes.sav")
|
var/savefile/S=new("data/player_notes.sav")
|
||||||
var/list/note_keys
|
var/list/note_keys
|
||||||
S >> note_keys
|
S >> note_keys
|
||||||
if(!note_keys)
|
|
||||||
dat += "No notes found."
|
if(note_keys)
|
||||||
else
|
|
||||||
dat += "<table>"
|
|
||||||
note_keys = sortList(note_keys)
|
note_keys = sortList(note_keys)
|
||||||
|
|
||||||
if(filter)
|
var/datum/tgui_module/player_notes/A = new(src)
|
||||||
var/list/results = list()
|
A.ckeys = note_keys
|
||||||
var/regex/needle = regex(filter, "i")
|
A.tgui_interact(usr)
|
||||||
for(var/haystack in note_keys)
|
|
||||||
if(needle.Find(haystack))
|
|
||||||
results += haystack
|
|
||||||
note_keys = results
|
|
||||||
|
|
||||||
// Display the notes on the current page
|
|
||||||
var/number_pages = note_keys.len / PLAYER_NOTES_ENTRIES_PER_PAGE
|
|
||||||
// Emulate CEILING(why does BYOND not have ceil, 1)
|
|
||||||
if(number_pages != round(number_pages))
|
|
||||||
number_pages = round(number_pages) + 1
|
|
||||||
var/page_index = page - 1
|
|
||||||
|
|
||||||
if(page_index < 0 || page_index >= number_pages)
|
|
||||||
dat += "<tr><td>No keys found.</td></tr>"
|
|
||||||
else
|
|
||||||
var/lower_bound = page_index * PLAYER_NOTES_ENTRIES_PER_PAGE + 1
|
|
||||||
var/upper_bound = (page_index + 1) * PLAYER_NOTES_ENTRIES_PER_PAGE
|
|
||||||
upper_bound = min(upper_bound, note_keys.len)
|
|
||||||
for(var/index = lower_bound, index <= upper_bound, index++)
|
|
||||||
var/t = note_keys[index]
|
|
||||||
dat += "<tr><td><a href='?src=\ref[src];notes=show;ckey=[t]'>[t]</a></td></tr>"
|
|
||||||
|
|
||||||
dat += "</table><hr>"
|
|
||||||
|
|
||||||
// Display a footer to select different pages
|
|
||||||
for(var/index = 1, index <= number_pages, index++)
|
|
||||||
if(index == page)
|
|
||||||
dat += "<b>"
|
|
||||||
dat += "<a href='?src=\ref[src];notes=list;index=[index];filter=[filter ? url_encode(filter) : 0]'>[index]</a> "
|
|
||||||
if(index == page)
|
|
||||||
dat += "</b>"
|
|
||||||
|
|
||||||
usr << browse(dat, "window=player_notes;size=400x400")
|
|
||||||
|
|
||||||
|
|
||||||
/datum/admins/proc/player_has_info(var/key as text)
|
/datum/admins/proc/player_has_info(var/key as text)
|
||||||
@@ -303,44 +266,10 @@ var/global/floorIsLava = 0
|
|||||||
if (!istype(src,/datum/admins))
|
if (!istype(src,/datum/admins))
|
||||||
to_chat(usr, "Error: you are not an admin!")
|
to_chat(usr, "Error: you are not an admin!")
|
||||||
return
|
return
|
||||||
var/dat = "<html><head><title>Info on [key]</title></head>"
|
|
||||||
dat += "<body>"
|
|
||||||
|
|
||||||
var/p_age = "unknown"
|
|
||||||
for(var/client/C in GLOB.clients)
|
|
||||||
if(C.ckey == key)
|
|
||||||
p_age = C.player_age
|
|
||||||
break
|
|
||||||
dat +="<span style='color:#000000; font-weight: bold'>Player age: [p_age]</span><br>"
|
|
||||||
|
|
||||||
var/savefile/info = new("data/player_saves/[copytext(key, 1, 2)]/[key]/info.sav")
|
|
||||||
var/list/infos
|
|
||||||
info >> infos
|
|
||||||
if(!infos)
|
|
||||||
dat += "No information found on the given key.<br>"
|
|
||||||
else
|
|
||||||
var/update_file = 0
|
|
||||||
var/i = 0
|
|
||||||
for(var/datum/player_info/I in infos)
|
|
||||||
i += 1
|
|
||||||
if(!I.timestamp)
|
|
||||||
I.timestamp = "Pre-4/3/2012"
|
|
||||||
update_file = 1
|
|
||||||
if(!I.rank)
|
|
||||||
I.rank = "N/A"
|
|
||||||
update_file = 1
|
|
||||||
dat += "<font color=#008800>[I.content]</font> <i>by [I.author] ([I.rank])</i> on <i><font color=blue>[I.timestamp]</i></font> "
|
|
||||||
if(I.author == usr.key || I.author == "Adminbot" || ishost(usr))
|
|
||||||
dat += "<A href='?src=\ref[src];remove_player_info=[key];remove_index=[i]'>Remove</A>"
|
|
||||||
dat += "<br><br>"
|
|
||||||
if(update_file) info << infos
|
|
||||||
|
|
||||||
dat += "<br>"
|
|
||||||
dat += "<A href='?src=\ref[src];add_player_info=[key]'>Add Comment</A><br>"
|
|
||||||
|
|
||||||
dat += "</body></html>"
|
|
||||||
usr << browse(dat, "window=adminplayerinfo;size=480x480")
|
|
||||||
|
|
||||||
|
var/datum/tgui_module/player_notes_info/A = new(src)
|
||||||
|
A.key = key
|
||||||
|
A.tgui_interact(usr)
|
||||||
|
|
||||||
|
|
||||||
/datum/admins/proc/access_news_network() //MARKER
|
/datum/admins/proc/access_news_network() //MARKER
|
||||||
|
|||||||
@@ -2019,21 +2019,6 @@
|
|||||||
|
|
||||||
// player info stuff
|
// player info stuff
|
||||||
|
|
||||||
if(href_list["add_player_info"])
|
|
||||||
var/key = href_list["add_player_info"]
|
|
||||||
var/add = sanitize(input(usr, "Add Player Info") as null|text)
|
|
||||||
if(!add) return
|
|
||||||
|
|
||||||
notes_add(key,add,usr)
|
|
||||||
show_player_info(key)
|
|
||||||
|
|
||||||
if(href_list["remove_player_info"])
|
|
||||||
var/key = href_list["remove_player_info"]
|
|
||||||
var/index = text2num(href_list["remove_index"])
|
|
||||||
|
|
||||||
notes_del(key, index)
|
|
||||||
show_player_info(key)
|
|
||||||
|
|
||||||
if(href_list["notes"])
|
if(href_list["notes"])
|
||||||
var/ckey = href_list["ckey"]
|
var/ckey = href_list["ckey"]
|
||||||
if(!ckey)
|
if(!ckey)
|
||||||
@@ -2043,7 +2028,9 @@
|
|||||||
|
|
||||||
switch(href_list["notes"])
|
switch(href_list["notes"])
|
||||||
if("show")
|
if("show")
|
||||||
show_player_info(ckey)
|
var/datum/tgui_module/player_notes_info/A = new(src)
|
||||||
|
A.key = ckey
|
||||||
|
A.tgui_interact(usr)
|
||||||
if("list")
|
if("list")
|
||||||
var/filter
|
var/filter
|
||||||
if(href_list["filter"] && href_list["filter"] != "0")
|
if(href_list["filter"] && href_list["filter"] != "0")
|
||||||
|
|||||||
326
code/modules/tgui/modules/admin/player_notes.dm
Normal file
326
code/modules/tgui/modules/admin/player_notes.dm
Normal file
@@ -0,0 +1,326 @@
|
|||||||
|
#define PLAYER_NOTES_ENTRIES_PER_PAGE 50
|
||||||
|
|
||||||
|
/datum/tgui_module/player_notes
|
||||||
|
name = "Player Notes"
|
||||||
|
tgui_id = "PlayerNotes"
|
||||||
|
|
||||||
|
var/ckeys = list()
|
||||||
|
|
||||||
|
var/current_filter = ""
|
||||||
|
var/current_page = 1
|
||||||
|
|
||||||
|
var/number_pages = 0
|
||||||
|
|
||||||
|
/datum/tgui_module/player_notes/proc/filter_ckeys(var/page, var/filter)
|
||||||
|
var/savefile/S=new("data/player_notes.sav")
|
||||||
|
var/list/note_keys
|
||||||
|
S >> note_keys
|
||||||
|
if(!note_keys)
|
||||||
|
to_chat(usr, "No notes found.")
|
||||||
|
else
|
||||||
|
note_keys = sortList(note_keys)
|
||||||
|
|
||||||
|
if(filter)
|
||||||
|
var/list/results = list()
|
||||||
|
var/regex/needle = regex(filter, "i")
|
||||||
|
for(var/haystack in note_keys)
|
||||||
|
if(needle.Find(haystack))
|
||||||
|
results += haystack
|
||||||
|
note_keys = results
|
||||||
|
|
||||||
|
// Display the notes on the current page
|
||||||
|
number_pages = note_keys.len / PLAYER_NOTES_ENTRIES_PER_PAGE
|
||||||
|
// Emulate CEILING(why does BYOND not have ceil, 1)
|
||||||
|
if(number_pages != round(number_pages))
|
||||||
|
number_pages = round(number_pages) + 1
|
||||||
|
var/page_index = page - 1
|
||||||
|
|
||||||
|
if(page_index < 0 || page_index >= number_pages)
|
||||||
|
to_chat(usr, "No keys found.")
|
||||||
|
else
|
||||||
|
var/lower_bound = page_index * PLAYER_NOTES_ENTRIES_PER_PAGE + 1
|
||||||
|
var/upper_bound = (page_index + 1) * PLAYER_NOTES_ENTRIES_PER_PAGE
|
||||||
|
upper_bound = min(upper_bound, note_keys.len)
|
||||||
|
ckeys = list()
|
||||||
|
for(var/index = lower_bound, index <= upper_bound, index++)
|
||||||
|
ckeys += note_keys[index]
|
||||||
|
|
||||||
|
current_filter = filter
|
||||||
|
|
||||||
|
/datum/tgui_module/player_notes/proc/open_legacy()
|
||||||
|
var/datum/admins/A = admin_datums[usr.ckey]
|
||||||
|
A.PlayerNotesLegacy()
|
||||||
|
|
||||||
|
/datum/tgui_module/player_notes/tgui_state(mob/user)
|
||||||
|
return GLOB.tgui_admin_state
|
||||||
|
|
||||||
|
/datum/tgui_module/player_notes/tgui_act(action, params, datum/tgui/ui)
|
||||||
|
if(..())
|
||||||
|
return TRUE
|
||||||
|
|
||||||
|
switch(action)
|
||||||
|
if("__fallback")
|
||||||
|
log_runtime(EXCEPTION("TGUI Fallback Triggered: \"[ui.user]\" tried to use/open \"[ui.title]/[ui.interface]\"! Trying to open legacy UI!"))
|
||||||
|
open_legacy()
|
||||||
|
|
||||||
|
if("show_player_info")
|
||||||
|
var/datum/tgui_module/player_notes_info/A = new(src)
|
||||||
|
A.key = params["name"]
|
||||||
|
A.tgui_interact(usr)
|
||||||
|
|
||||||
|
if("filter_player_notes")
|
||||||
|
var/input = tgui_input_text(usr, "Filter string (case-insensitive regex)", "Player notes filter")
|
||||||
|
current_filter = input
|
||||||
|
|
||||||
|
if("set_page")
|
||||||
|
var/page = params["index"]
|
||||||
|
current_page = page
|
||||||
|
|
||||||
|
if("clear_player_info_filter")
|
||||||
|
current_filter = ""
|
||||||
|
|
||||||
|
if("open_legacy_ui")
|
||||||
|
open_legacy()
|
||||||
|
|
||||||
|
/datum/tgui_module/player_notes/tgui_data(mob/user)
|
||||||
|
var/list/data = list()
|
||||||
|
|
||||||
|
filter_ckeys(current_page, current_filter)
|
||||||
|
data["ckeys"] = list()
|
||||||
|
data["pages"] = number_pages + 1
|
||||||
|
data["filter"] = current_filter
|
||||||
|
|
||||||
|
for(var/ckey in ckeys)
|
||||||
|
data["ckeys"] += list(list(
|
||||||
|
"name" = ckey
|
||||||
|
))
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
// PLAYER NOTES INFO
|
||||||
|
/datum/tgui_module/player_notes_info
|
||||||
|
name = "Player Notes Info"
|
||||||
|
tgui_id = "PlayerNotesInfo"
|
||||||
|
|
||||||
|
var/key = null
|
||||||
|
|
||||||
|
/datum/tgui_module/player_notes_info/tgui_state(mob/user)
|
||||||
|
return GLOB.tgui_admin_state
|
||||||
|
|
||||||
|
/datum/tgui_module/player_notes_info/tgui_act(action, params, datum/tgui/ui)
|
||||||
|
if(..())
|
||||||
|
return TRUE
|
||||||
|
|
||||||
|
switch(action)
|
||||||
|
if("__fallback")
|
||||||
|
var/datum/admins/A = admin_datums[usr.ckey]
|
||||||
|
A.show_player_info_legacy(key)
|
||||||
|
|
||||||
|
if("add_player_info")
|
||||||
|
var/key = params["ckey"]
|
||||||
|
var/add = tgui_input_message(usr, "Write your comment below.", "Add Player Info")
|
||||||
|
if(!add) return
|
||||||
|
|
||||||
|
notes_add(key,add,usr)
|
||||||
|
|
||||||
|
if("remove_player_info")
|
||||||
|
var/key = params["ckey"]
|
||||||
|
var/index = params["index"]
|
||||||
|
|
||||||
|
notes_del(key, index)
|
||||||
|
|
||||||
|
/datum/tgui_module/player_notes_info/tgui_data(mob/user)
|
||||||
|
var/list/data = list()
|
||||||
|
|
||||||
|
if(!key)
|
||||||
|
return
|
||||||
|
|
||||||
|
var/p_age = "unknown"
|
||||||
|
for(var/client/C in GLOB.clients)
|
||||||
|
if(C.ckey == key)
|
||||||
|
p_age = C.player_age
|
||||||
|
break
|
||||||
|
|
||||||
|
data["entries"] = list()
|
||||||
|
|
||||||
|
var/savefile/info = new("data/player_saves/[copytext(key, 1, 2)]/[key]/info.sav")
|
||||||
|
var/list/infos
|
||||||
|
info >> infos
|
||||||
|
if(infos)
|
||||||
|
var/update_file = 0
|
||||||
|
var/i = 0
|
||||||
|
for(var/datum/player_info/I in infos)
|
||||||
|
i += 1
|
||||||
|
if(!I.timestamp)
|
||||||
|
I.timestamp = "Pre-4/3/2012"
|
||||||
|
update_file = 1
|
||||||
|
if(!I.rank)
|
||||||
|
I.rank = "N/A"
|
||||||
|
update_file = 1
|
||||||
|
|
||||||
|
data["entries"] += list(list(
|
||||||
|
"comment" = I.content,
|
||||||
|
"author" = "[I.author] ([I.rank])",
|
||||||
|
"date" = "[I.timestamp]"
|
||||||
|
))
|
||||||
|
if(update_file) info << infos
|
||||||
|
|
||||||
|
data["ckey"] = key
|
||||||
|
data["age"] = p_age
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
// ==== LEGACY UI ====
|
||||||
|
|
||||||
|
/datum/admins/proc/PlayerNotesLegacy()
|
||||||
|
if (!istype(src,/datum/admins))
|
||||||
|
src = usr.client.holder
|
||||||
|
if (!istype(src,/datum/admins))
|
||||||
|
to_chat(usr, "Error: you are not an admin!")
|
||||||
|
return
|
||||||
|
PlayerNotesPageLegacy(1)
|
||||||
|
|
||||||
|
/datum/admins/proc/PlayerNotesFilterLegacy()
|
||||||
|
if (!istype(src,/datum/admins))
|
||||||
|
src = usr.client.holder
|
||||||
|
if (!istype(src,/datum/admins))
|
||||||
|
to_chat(usr, "Error: you are not an admin!")
|
||||||
|
return
|
||||||
|
var/filter = input(usr, "Filter string (case-insensitive regex)", "Player notes filter") as text|null
|
||||||
|
PlayerNotesPageLegacy(1, filter)
|
||||||
|
|
||||||
|
/datum/admins/proc/PlayerNotesPageLegacy(page, filter)
|
||||||
|
var/dat = "<B>Player notes</B> - <a href='?src=\ref[src];notes_legacy=filter'>Apply Filter</a><HR>"
|
||||||
|
var/savefile/S=new("data/player_notes.sav")
|
||||||
|
var/list/note_keys
|
||||||
|
S >> note_keys
|
||||||
|
if(!note_keys)
|
||||||
|
dat += "No notes found."
|
||||||
|
else
|
||||||
|
dat += "<table>"
|
||||||
|
note_keys = sortList(note_keys)
|
||||||
|
|
||||||
|
if(filter)
|
||||||
|
var/list/results = list()
|
||||||
|
var/regex/needle = regex(filter, "i")
|
||||||
|
for(var/haystack in note_keys)
|
||||||
|
if(needle.Find(haystack))
|
||||||
|
results += haystack
|
||||||
|
note_keys = results
|
||||||
|
|
||||||
|
// Display the notes on the current page
|
||||||
|
var/number_pages = note_keys.len / PLAYER_NOTES_ENTRIES_PER_PAGE
|
||||||
|
// Emulate CEILING(why does BYOND not have ceil, 1)
|
||||||
|
if(number_pages != round(number_pages))
|
||||||
|
number_pages = round(number_pages) + 1
|
||||||
|
var/page_index = page - 1
|
||||||
|
|
||||||
|
if(page_index < 0 || page_index >= number_pages)
|
||||||
|
dat += "<tr><td>No keys found.</td></tr>"
|
||||||
|
else
|
||||||
|
var/lower_bound = page_index * PLAYER_NOTES_ENTRIES_PER_PAGE + 1
|
||||||
|
var/upper_bound = (page_index + 1) * PLAYER_NOTES_ENTRIES_PER_PAGE
|
||||||
|
upper_bound = min(upper_bound, note_keys.len)
|
||||||
|
for(var/index = lower_bound, index <= upper_bound, index++)
|
||||||
|
var/t = note_keys[index]
|
||||||
|
dat += "<tr><td><a href='?src=\ref[src];notes_legacy=show;ckey=[t]'>[t]</a></td></tr>"
|
||||||
|
|
||||||
|
dat += "</table><hr>"
|
||||||
|
|
||||||
|
// Display a footer to select different pages
|
||||||
|
for(var/index = 1, index <= number_pages, index++)
|
||||||
|
if(index == page)
|
||||||
|
dat += "<b>"
|
||||||
|
dat += "<a href='?src=\ref[src];notes_legacy=list;index=[index];filter=[filter ? url_encode(filter) : 0]'>[index]</a> "
|
||||||
|
if(index == page)
|
||||||
|
dat += "</b>"
|
||||||
|
|
||||||
|
usr << browse(dat, "window=player_notes;size=400x400")
|
||||||
|
|
||||||
|
/datum/admins/proc/player_has_info_legacy(var/key as text)
|
||||||
|
var/savefile/info = new("data/player_saves/[copytext(key, 1, 2)]/[key]/info.sav")
|
||||||
|
var/list/infos
|
||||||
|
info >> infos
|
||||||
|
if(!infos || !infos.len) return 0
|
||||||
|
else return 1
|
||||||
|
|
||||||
|
/datum/admins/proc/show_player_info_legacy(var/key as text)
|
||||||
|
if (!istype(src,/datum/admins))
|
||||||
|
src = usr.client.holder
|
||||||
|
if (!istype(src,/datum/admins))
|
||||||
|
to_chat(usr, "Error: you are not an admin!")
|
||||||
|
return
|
||||||
|
var/dat = "<html><head><title>Info on [key]</title></head>"
|
||||||
|
dat += "<body>"
|
||||||
|
|
||||||
|
var/p_age = "unknown"
|
||||||
|
for(var/client/C in GLOB.clients)
|
||||||
|
if(C.ckey == key)
|
||||||
|
p_age = C.player_age
|
||||||
|
break
|
||||||
|
dat +="<span style='color:#000000; font-weight: bold'>Player age: [p_age]</span><br>"
|
||||||
|
|
||||||
|
var/savefile/info = new("data/player_saves/[copytext(key, 1, 2)]/[key]/info.sav")
|
||||||
|
var/list/infos
|
||||||
|
info >> infos
|
||||||
|
if(!infos)
|
||||||
|
dat += "No information found on the given key.<br>"
|
||||||
|
else
|
||||||
|
var/update_file = 0
|
||||||
|
var/i = 0
|
||||||
|
for(var/datum/player_info/I in infos)
|
||||||
|
i += 1
|
||||||
|
if(!I.timestamp)
|
||||||
|
I.timestamp = "Pre-4/3/2012"
|
||||||
|
update_file = 1
|
||||||
|
if(!I.rank)
|
||||||
|
I.rank = "N/A"
|
||||||
|
update_file = 1
|
||||||
|
dat += "<font color=#008800>[I.content]</font> <i>by [I.author] ([I.rank])</i> on <i><font color=blue>[I.timestamp]</i></font> "
|
||||||
|
if(I.author == usr.key || I.author == "Adminbot" || ishost(usr))
|
||||||
|
dat += "<A href='?src=\ref[src];remove_player_info_legacy=[key];remove_index=[i]'>Remove</A>"
|
||||||
|
dat += "<br><br>"
|
||||||
|
if(update_file) info << infos
|
||||||
|
|
||||||
|
dat += "<br>"
|
||||||
|
dat += "<A href='?src=\ref[src];add_player_info_legacy=[key]'>Add Comment</A><br>"
|
||||||
|
|
||||||
|
dat += "</body></html>"
|
||||||
|
usr << browse(dat, "window=adminplayerinfo;size=480x480")
|
||||||
|
|
||||||
|
/datum/admins/Topic(href, href_list)
|
||||||
|
..()
|
||||||
|
|
||||||
|
if(href_list["add_player_info_legacy"])
|
||||||
|
var/key = href_list["add_player_info_legacy"]
|
||||||
|
var/add = sanitize(input(usr, "Add Player Info (Legacy)") as null|text)
|
||||||
|
if(!add) return
|
||||||
|
|
||||||
|
notes_add(key,add,usr)
|
||||||
|
show_player_info_legacy(key)
|
||||||
|
|
||||||
|
if(href_list["remove_player_info_legacy"])
|
||||||
|
var/key = href_list["remove_player_info_legacy"]
|
||||||
|
var/index = text2num(href_list["remove_index"])
|
||||||
|
|
||||||
|
notes_del(key, index)
|
||||||
|
show_player_info_legacy(key)
|
||||||
|
|
||||||
|
if(href_list["notes_legacy"])
|
||||||
|
var/ckey = href_list["ckey"]
|
||||||
|
if(!ckey)
|
||||||
|
var/mob/M = locate(href_list["mob"])
|
||||||
|
if(ismob(M))
|
||||||
|
ckey = M.ckey
|
||||||
|
|
||||||
|
switch(href_list["notes_legacy"])
|
||||||
|
if("show")
|
||||||
|
show_player_info_legacy(ckey)
|
||||||
|
if("list")
|
||||||
|
var/filter
|
||||||
|
if(href_list["filter"] && href_list["filter"] != "0")
|
||||||
|
filter = url_decode(href_list["filter"])
|
||||||
|
PlayerNotesPageLegacy(text2num(href_list["index"]), filter)
|
||||||
|
if("filter")
|
||||||
|
PlayerNotesFilterLegacy()
|
||||||
|
return
|
||||||
87
tgui/packages/tgui/interfaces/PlayerNotes.js
Normal file
87
tgui/packages/tgui/interfaces/PlayerNotes.js
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import { useBackend } from '../backend';
|
||||||
|
import { Button, Divider, Section, Table } from '../components';
|
||||||
|
import { Window } from '../layouts';
|
||||||
|
|
||||||
|
export const PlayerNotes = (props, context) => {
|
||||||
|
const { act, data } = useBackend(context);
|
||||||
|
const {
|
||||||
|
device_theme,
|
||||||
|
filter,
|
||||||
|
pages,
|
||||||
|
ckeys = [],
|
||||||
|
} = data;
|
||||||
|
|
||||||
|
const runCallback = (cb) => {
|
||||||
|
return cb();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Window
|
||||||
|
title={'Player Notes'}
|
||||||
|
theme={device_theme}
|
||||||
|
width={400}
|
||||||
|
height={500}
|
||||||
|
resizable>
|
||||||
|
<Window.Content scrollable>
|
||||||
|
<Section title="Player notes">
|
||||||
|
<Button
|
||||||
|
icon="filter"
|
||||||
|
onClick={() => act("filter_player_notes")}>
|
||||||
|
Apply Filter
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
icon="sidebar"
|
||||||
|
onClick={() => act("open_legacy_ui")}>
|
||||||
|
Open Legacy UI
|
||||||
|
</Button>
|
||||||
|
<Divider />
|
||||||
|
<Button.Input
|
||||||
|
content="CKEY to Open"
|
||||||
|
onCommit={(e, value) => act('show_player_info', {
|
||||||
|
name: value,
|
||||||
|
})} />
|
||||||
|
<Divider vertical />
|
||||||
|
<Button
|
||||||
|
color="green"
|
||||||
|
content={filter}
|
||||||
|
onClick={() => act("clear_player_info_filter")} />
|
||||||
|
<Divider />
|
||||||
|
<Table>
|
||||||
|
{ckeys.map(ckey => (
|
||||||
|
<Table.Row key={ckey.name}>
|
||||||
|
<Table.Cell>
|
||||||
|
<Button
|
||||||
|
fluid
|
||||||
|
color="transparent"
|
||||||
|
icon={'user'}
|
||||||
|
content={ckey.desc}
|
||||||
|
onClick={() => act('show_player_info', {
|
||||||
|
name: ckey.name,
|
||||||
|
})}>
|
||||||
|
{ckey.name}
|
||||||
|
</Button>
|
||||||
|
</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
|
))}
|
||||||
|
</Table>
|
||||||
|
<Divider />
|
||||||
|
{runCallback(() => {
|
||||||
|
const row = [];
|
||||||
|
for (let i = 1; i < pages; i++) {
|
||||||
|
row.push(
|
||||||
|
<Button
|
||||||
|
key={i}
|
||||||
|
onClick={() => act("set_page", {
|
||||||
|
index: i,
|
||||||
|
})}>
|
||||||
|
{i}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
})}
|
||||||
|
</Section>
|
||||||
|
</Window.Content>
|
||||||
|
</Window>
|
||||||
|
);
|
||||||
|
};
|
||||||
56
tgui/packages/tgui/interfaces/PlayerNotesInfo.js
Normal file
56
tgui/packages/tgui/interfaces/PlayerNotesInfo.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import { useBackend } from '../backend';
|
||||||
|
import { Box, Button, Divider, Section, Table } from '../components';
|
||||||
|
import { Window } from '../layouts';
|
||||||
|
|
||||||
|
export const PlayerNotesInfo = (props, context) => {
|
||||||
|
const { act, data } = useBackend(context);
|
||||||
|
const {
|
||||||
|
device_theme,
|
||||||
|
age,
|
||||||
|
ckey,
|
||||||
|
entries = [],
|
||||||
|
} = data;
|
||||||
|
return (
|
||||||
|
<Window
|
||||||
|
title={`Info on ${ckey}`}
|
||||||
|
theme={device_theme}
|
||||||
|
width={400}
|
||||||
|
height={500}
|
||||||
|
resizable>
|
||||||
|
<Window.Content scrollable>
|
||||||
|
<Section title={`Player age: ${age}`}>
|
||||||
|
<Table>
|
||||||
|
This ckey has {entries.length} comments.
|
||||||
|
{entries.map((entry, index) => (
|
||||||
|
<Table.Row key={entry.comment}>
|
||||||
|
<Table.Cell
|
||||||
|
collapsing={false}>
|
||||||
|
<Divider />
|
||||||
|
<Box>
|
||||||
|
Written by {entry.author} on <span color="blue">{entry.date}</span><br />
|
||||||
|
<span color="green">"{entry.comment}"</span>
|
||||||
|
</Box>
|
||||||
|
<Button
|
||||||
|
icon="trash"
|
||||||
|
onClick={() => act("remove_player_info", {
|
||||||
|
ckey: ckey,
|
||||||
|
index: index+1,
|
||||||
|
})}>
|
||||||
|
Remove
|
||||||
|
</Button>
|
||||||
|
</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
|
))}
|
||||||
|
</Table>
|
||||||
|
</Section>
|
||||||
|
<Button
|
||||||
|
icon="comment"
|
||||||
|
onClick={() => act("add_player_info", {
|
||||||
|
ckey: ckey,
|
||||||
|
})}>
|
||||||
|
Add Comment
|
||||||
|
</Button>
|
||||||
|
</Window.Content>
|
||||||
|
</Window>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -364,6 +364,12 @@
|
|||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
|
|
||||||
window.onerror = function (msg, url, line, col, error) {
|
window.onerror = function (msg, url, line, col, error) {
|
||||||
|
// Send fallback command
|
||||||
|
Byond.topic({
|
||||||
|
tgui: 1,
|
||||||
|
window_id: window.__windowId__,
|
||||||
|
type: 'act/__fallback',
|
||||||
|
});
|
||||||
// Proper stacktrace
|
// Proper stacktrace
|
||||||
var stack = error && error.stack;
|
var stack = error && error.stack;
|
||||||
// Ghetto stacktrace
|
// Ghetto stacktrace
|
||||||
@@ -615,7 +621,7 @@ Thank you for your cooperation.
|
|||||||
</marquee>
|
</marquee>
|
||||||
<div id="FatalError__stack" class="FatalError__stack"></div>
|
<div id="FatalError__stack" class="FatalError__stack"></div>
|
||||||
<div class="FatalError__footer">
|
<div class="FatalError__footer">
|
||||||
Nanotrasen (c) 2225-2322
|
Nanotrasen (c) 2284-2322
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -4216,6 +4216,7 @@
|
|||||||
#include "code\modules\tgui\modules\shutoff_monitor.dm"
|
#include "code\modules\tgui\modules\shutoff_monitor.dm"
|
||||||
#include "code\modules\tgui\modules\supermatter_monitor.dm"
|
#include "code\modules\tgui\modules\supermatter_monitor.dm"
|
||||||
#include "code\modules\tgui\modules\teleporter.dm"
|
#include "code\modules\tgui\modules\teleporter.dm"
|
||||||
|
#include "code\modules\tgui\modules\admin\player_notes.dm"
|
||||||
#include "code\modules\tgui\modules\ntos-only\cardmod.dm"
|
#include "code\modules\tgui\modules\ntos-only\cardmod.dm"
|
||||||
#include "code\modules\tgui\modules\ntos-only\configurator.dm"
|
#include "code\modules\tgui\modules\ntos-only\configurator.dm"
|
||||||
#include "code\modules\tgui\modules\ntos-only\email.dm"
|
#include "code\modules\tgui\modules\ntos-only\email.dm"
|
||||||
|
|||||||
Reference in New Issue
Block a user