From c94b35dc00a0cb5d9e51ffc9378c6c79f6d753c1 Mon Sep 17 00:00:00 2001 From: "elly1989@rocketmail.com" Date: Fri, 20 Jul 2012 20:47:44 +0000 Subject: [PATCH] Added a very stripped-down version of player-notes I made a while ago for a ban system. It's very no-thrills as it was intended merely as storage for the various parts to reference. I've pretty much stripped everything, added a switch to obj/admins/Topic and linked to a simple browser interface from the player panels. It's just a single buffer per ckey. You can use the [+] and [-] links to add/remove notes. Clicking the ckeys will allow you to navigate between player notes. They are listed chronologically. Their main perk is also their main flaw, they are only a single buffer, which is fast and small. But it kinda means playing with the format won't update existing notes. If you have any complaints about the format please make them known soonish. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4129 316c924e-a436-60f5-8080-3fe189b3f50e --- code/modules/admin/NewBan.dm | 2 +- code/modules/admin/admin.dm | 24 ++++++++- code/modules/admin/player_notes.dm | 83 ++++++++++++++++++++++++++++++ code/modules/admin/player_panel.dm | 1 + 4 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 code/modules/admin/player_notes.dm diff --git a/code/modules/admin/NewBan.dm b/code/modules/admin/NewBan.dm index 966fdd7667b..c05b864ffc5 100644 --- a/code/modules/admin/NewBan.dm +++ b/code/modules/admin/NewBan.dm @@ -115,7 +115,7 @@ var/savefile/Banlist Banlist["temp"] << temp if (temp) Banlist["minutes"] << bantimestamp - + notes_add(ckey, "Banned - [reason]") return 1 /proc/RemoveBan(foldername) diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index b8424dd4e0c..5c4e10e2aa9 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -528,6 +528,7 @@ var/global/BSACooldown = 0 jobban_fullban(M, job, "[reason]; By [usr.ckey] on [time2text(world.realtime)]") if(!msg) msg = job else msg += ", [job]" + notes_add(M.ckey, "Banned from [msg] - [reason]") message_admins("\blue [key_name_admin(usr)] banned [key_name_admin(M)] from [msg]", 1) M << "\redYou have been jobbanned by [usr.client.ckey] from: [msg]." M << "\red The reason is: [reason]" @@ -573,6 +574,26 @@ var/global/BSACooldown = 0 //M.client = null del(M.client) + //Player Notes + 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") + notes_show(ckey) + if("add") + notes_add(ckey,href_list["text"]) + notes_show(ckey) + if("remove") + notes_remove(ckey,text2num(href_list["from"]),text2num(href_list["to"])) + notes_show(ckey) + return + + if (href_list["removejobban"]) if ((src.rank in list("Game Admin", "Game Master" ))) var/t = href_list["removejobban"] @@ -2194,7 +2215,8 @@ var/global/BSACooldown = 0 body += "Kick | " body += "Ban | " - body += "Jobban " + body += "Jobban | " + body += "Notes " if(M.client) body += "| Prison | " diff --git a/code/modules/admin/player_notes.dm b/code/modules/admin/player_notes.dm new file mode 100644 index 00000000000..9f494297f91 --- /dev/null +++ b/code/modules/admin/player_notes.dm @@ -0,0 +1,83 @@ +//This stuff was originally intended to be integrated into the ban-system I was working on +//but it's safe to say that'll never be finished. So I've merged it into the current player panel. +//enjoy ~Carn + +#define NOTESFILE "data/player_notes.sav" //where the player notes are saved + +obj/admins/proc/notes_show(var/ckey) + usr << browse("Player Notes[notes_gethtml(ckey)]","window=player_notes;size=700x400") + + +obj/admins/proc/notes_gethtml(var/ckey) + var/savefile/notesfile = new(NOTESFILE) + if(!notesfile) return "Error: Cannot access [NOTESFILE]" + if(ckey) + . = "Notes for [ckey]: \[+\] \[-\]
" + notesfile.cd = "/[ckey]" + var/index = 1 + while( !notesfile.eof ) + var/note + notesfile >> note + . += "[note] \[-\]
" + index++ + else + . = "All Notes: \[+\] \[-\]
" + notesfile.cd = "/" + for(var/dir in notesfile.dir) + . += "[dir]
" + return + + +//handles adding notes to the end of a ckey's buffer +//originally had seperate entries such as var/by to record who left the note and when +//but the current bansystem is a heap of dung. +/proc/notes_add(var/ckey, var/note) + if(!ckey) + ckey = ckey(input(usr,"Who would you like to add notes for?","Enter a ckey",null) as text|null) + if(!ckey) return + + if(!note) + note = html_encode(input(usr,"Enter your note:","Enter some text",null) as message|null) + if(!note) return + + var/savefile/notesfile = new(NOTESFILE) + if(!notesfile) return + notesfile.cd = "/[ckey]" + notesfile.eof = 1 //move to the end of the buffer + notesfile << "[time2text(world.realtime,"DD-MMM-YYYY")] | [note][(usr && usr.ckey)?" ~[usr.ckey]":""]" + return + +//handles removing entries from the buffer, or removing the entire directory if no start_index is given +/proc/notes_remove(var/ckey, var/start_index, var/end_index) + var/savefile/notesfile = new(NOTESFILE) + if(!notesfile) return + + if(!ckey) + notesfile.cd = "/" + ckey = ckey(input(usr,"Who would you like to remove notes for?","Enter a ckey",null) as null|anything in notesfile.dir) + if(!ckey) return + + if(start_index) + notesfile.cd = "/[ckey]" + var/list/noteslist = list() + if(!end_index) end_index = start_index + var/index = 0 + while( !notesfile.eof ) + index++ + var/temp + notesfile >> temp + if( (start_index <= index) && (index <= end_index) ) + continue + noteslist += temp + + notesfile.eof = -2 //Move to the start of the buffer and then erase. + + for( var/note in noteslist ) + notesfile << note + else + notesfile.cd = "/" + if(alert(usr,"Are you sure you want to remove all their notes?","Confirmation","No","Yes - Remove all notes") == "Yes - Remove all notes") + notesfile.dir.Remove(ckey) + return + +#undef NOTESFILE \ No newline at end of file diff --git a/code/modules/admin/player_panel.dm b/code/modules/admin/player_panel.dm index ef1226001a5..422212f9768 100644 --- a/code/modules/admin/player_panel.dm +++ b/code/modules/admin/player_panel.dm @@ -75,6 +75,7 @@ body += ""; body += "PP - " + body += "N - " body += "VV - " body += "TP - " body += "PM - "