mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Merge pull request #10258 from VOREStation/Arokha/notesfilter
Simple player notes filter
This commit is contained in:
committed by
Chompstation Bot
parent
f516265384
commit
3f0269a138
@@ -229,8 +229,17 @@ proc/admin_notice(var/message, var/rights)
|
||||
return
|
||||
PlayerNotesPage(1)
|
||||
|
||||
/datum/admins/proc/PlayerNotesPage(page)
|
||||
var/dat = "<B>Player notes</B><HR>"
|
||||
/datum/admins/proc/PlayerNotesFilter()
|
||||
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
|
||||
PlayerNotesPage(1, 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/list/note_keys
|
||||
S >> note_keys
|
||||
@@ -240,29 +249,38 @@ proc/admin_notice(var/message, var/rights)
|
||||
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)
|
||||
return
|
||||
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>"
|
||||
|
||||
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><br>"
|
||||
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]'>[index]</a> "
|
||||
dat += "<a href='?src=\ref[src];notes=list;index=[index];filter=[filter ? url_encode(filter) : 0]'>[index]</a> "
|
||||
if(index == page)
|
||||
dat += "</b>"
|
||||
|
||||
|
||||
@@ -1971,7 +1971,12 @@
|
||||
if("show")
|
||||
show_player_info(ckey)
|
||||
if("list")
|
||||
PlayerNotesPage(text2num(href_list["index"]))
|
||||
var/filter
|
||||
if(href_list["filter"] && href_list["filter"] != "0")
|
||||
filter = url_decode(href_list["filter"])
|
||||
PlayerNotesPage(text2num(href_list["index"]), filter)
|
||||
if("filter")
|
||||
PlayerNotesFilter()
|
||||
return
|
||||
|
||||
mob/living/proc/can_centcom_reply()
|
||||
|
||||
Reference in New Issue
Block a user