Skip to content

Commit

Permalink
Added a text search to the global player notes panel.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Feb 2, 2017
1 parent ae95da1 commit 74f808d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 39 deletions.
45 changes: 17 additions & 28 deletions code/modules/admin/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -218,46 +218,35 @@ var/global/floorIsLava = 0
if (!istype(src,/datum/admins))
to_chat(usr, "Error: you are not an admin!")
return
PlayerNotesPage(1)
PlayerNotesPage()

/datum/admins/proc/PlayerNotesPage(page)
var/dat = "<B>Player notes</B><HR>"
/datum/admins/proc/PlayerNotesPage(var/filter_term)
var/list/dat = list()
dat += "<B>Player notes</B><HR>"
var/savefile/S=new("data/player_notes.sav")
var/list/note_keys
S >> note_keys

if(filter_term)
for(var/t in note_keys)
if(findtext(lowertext(t), lowertext(filter_term)))
continue
note_keys -= t

dat += "<center><b>Search term:</b> <a href='?src=\ref[src];notes=set_filter'>[filter_term ? filter_term : "-----"]</a></center><hr>"

if(!note_keys)
dat += "No notes found."
else
dat += "<table>"
note_keys = sortList(note_keys)

// Display the notes on the current page
var/number_pages = note_keys.len / PLAYER_NOTES_ENTRIES_PER_PAGE
// Emulate ceil(why does BYOND not have ceil)
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

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]
for(var/t in note_keys)
dat += "<tr><td><a href='?src=\ref[src];notes=show;ckey=[t]'>[t]</a></td></tr>"

dat += "</table><br>"

// 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> "
if(index == page)
dat += "</b>"

usr << browse(dat, "window=player_notes;size=400x400")
var/datum/browser/popup = new(usr, "player_notes", "Player Notes", 400, 400)
popup.set_content(jointext(dat, null))
popup.open()


/datum/admins/proc/player_has_info(var/key as text)
Expand Down
21 changes: 10 additions & 11 deletions code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1819,17 +1819,16 @@
show_player_info(key)

if(href_list["notes"])
var/ckey = href_list["ckey"]
if(!ckey)
var/mob/M = locate(href_list["mob"])
if(ismob(M))
ckey = M.ckey

switch(href_list["notes"])
if("show")
show_player_info(ckey)
if("list")
PlayerNotesPage(text2num(href_list["index"]))
if(href_list["notes"] == "set_filter")
var/choice = input(usr,"Please specify a text filter to use or cancel to clear.","Player Notes",null) as text|null
PlayerNotesPage(choice)
else
var/ckey = href_list["ckey"]
if(!ckey)
var/mob/M = locate(href_list["mob"])
if(ismob(M))
ckey = M.ckey
show_player_info(ckey)
return

mob/living/proc/can_centcom_reply()
Expand Down

0 comments on commit 74f808d

Please sign in to comment.