mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-11 07:04:01 +01:00
Working filter
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/timestamp // Because this is bloody annoying
|
||||
|
||||
#define PLAYER_NOTES_ENTRIES_PER_PAGE 50
|
||||
/datum/admins/proc/PlayerNotes()
|
||||
set category = "Admin"
|
||||
set name = "Player Notes"
|
||||
@@ -239,7 +238,6 @@ var/global/floorIsLava = 0
|
||||
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
|
||||
@@ -247,39 +245,6 @@ var/global/floorIsLava = 0
|
||||
if(note_keys)
|
||||
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=show;ckey=[t]'>[t]</a></td></tr>"
|
||||
|
||||
// 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>"
|
||||
|
||||
var/datum/tgui_module/player_notes/A = new(src)
|
||||
A.ckeys = note_keys
|
||||
A.tgui_interact(usr)
|
||||
|
||||
Reference in New Issue
Block a user