From f15d583a686bbae4176f7c750b22b217a053eb49 Mon Sep 17 00:00:00 2001 From: carnie Date: Mon, 24 Jun 2013 05:35:39 +0100 Subject: [PATCH] Resolves #830 - ghost_form is only selectable by members. ghost_form is now saved with other preferences. Public visibility of memberships is toggable and saved with other preferences. ooc-colors for admins and members are now sanitized. Bright colours like Yellow, white and baby-blue will be darkened for the sake of legibility. Related to above - added helper procs to convert between RGB and HSL colour models. Admins cannot modify var/unlock_content without +DEBUG rights. unlock_content moved from client into prefs. Player savefile version number updated - this will trigger savefile updates, no data should be lost. --- code/__DEFINES.dm | 3 +- code/__HELPERS/sanitize_values.dm | 8 +++- code/__HELPERS/type2type.dm | 53 ++++++++++++++++++++- code/game/verbs/ooc.dm | 14 +++--- code/modules/admin/verbs/massmodvar.dm | 2 +- code/modules/admin/verbs/modifyvariables.dm | 4 +- code/modules/client/client defines.dm | 2 - code/modules/client/client procs.dm | 10 ++-- code/modules/client/preferences.dm | 28 ++++++++--- code/modules/client/preferences_savefile.dm | 19 +++----- code/modules/client/preferences_toggles.dm | 23 ++++++++- code/modules/mob/dead/observer/login.dm | 4 +- code/modules/mob/dead/observer/observer.dm | 10 +--- code/modules/mob/mob_helpers.dm | 3 -- tgstation.dme | 1 + 15 files changed, 135 insertions(+), 49 deletions(-) diff --git a/code/__DEFINES.dm b/code/__DEFINES.dm index 242b17f8ef3..399f4ade816 100644 --- a/code/__DEFINES.dm +++ b/code/__DEFINES.dm @@ -402,8 +402,9 @@ var/list/TAGGERLOCATIONS = list("Disposals", #define CHAT_GHOSTSIGHT 128 #define CHAT_PRAYER 256 #define CHAT_RADIO 512 +#define MEMBER_PUBLIC 1024 -#define TOGGLES_DEFAULT (SOUND_ADMINHELP|SOUND_MIDI|SOUND_AMBIENCE|SOUND_LOBBY|CHAT_OOC|CHAT_DEAD|CHAT_GHOSTEARS|CHAT_GHOSTSIGHT|CHAT_PRAYER|CHAT_RADIO) +#define TOGGLES_DEFAULT (SOUND_ADMINHELP|SOUND_MIDI|SOUND_AMBIENCE|SOUND_LOBBY|CHAT_OOC|CHAT_DEAD|CHAT_GHOSTEARS|CHAT_GHOSTSIGHT|CHAT_PRAYER|CHAT_RADIO|MEMBER_PUBLIC) #define BE_TRAITOR 1 #define BE_OPERATIVE 2 diff --git a/code/__HELPERS/sanitize_values.dm b/code/__HELPERS/sanitize_values.dm index dfcc7d314b0..c065fec9b81 100644 --- a/code/__HELPERS/sanitize_values.dm +++ b/code/__HELPERS/sanitize_values.dm @@ -54,4 +54,10 @@ if(default) return default return crunch + repeat_string(desired_format, "0") - return crunch + . \ No newline at end of file + return crunch + . + +/proc/sanitize_ooccolor(color) + var/list/HSL = rgb2hsl(hex2num(copytext(color,2,4)),hex2num(copytext(color,4,6)),hex2num(copytext(color,6,8))) + HSL[3] = min(HSL[3],0.4) + var/list/RGB = hsl2rgb(arglist(HSL)) + return "#[num2hex(RGB[1],2)][num2hex(RGB[2],2)][num2hex(RGB[3],2)]" \ No newline at end of file diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index c7045f207c1..21dc90509a4 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -243,4 +243,55 @@ proc/tg_list2text(list/list, glue=",") switch(ui_style) if("Retro") return 'icons/mob/screen_retro.dmi' if("Plasmafire") return 'icons/mob/screen_plasmafire.dmi' - else return 'icons/mob/screen_midnight.dmi' \ No newline at end of file + else return 'icons/mob/screen_midnight.dmi' + +//colour formats +/proc/rgb2hsl(red, green, blue) + red /= 255;green /= 255;blue /= 255; + var/max = max(red,green,blue) + var/min = min(red,green,blue) + var/range = max-min + + var/hue=0;var/saturation=0;var/lightness=0; + lightness = (max + min)/2 + if(range != 0) + if(lightness < 0.5) saturation = range/(max+min) + else saturation = range/(2-max-min) + + var/dred = ((max-red)/(6*max)) + 0.5 + var/dgreen = ((max-green)/(6*max)) + 0.5 + var/dblue = ((max-blue)/(6*max)) + 0.5 + + if(max==red) hue = dblue - dgreen + else if(max==green) hue = dred - dblue + (1/3) + else hue = dgreen - dred + (2/3) + if(hue < 0) hue++ + else if(hue > 1) hue-- + + return list(hue, saturation, lightness) + +/proc/hsl2rgb(hue, saturation, lightness) + var/red;var/green;var/blue; + if(saturation == 0) + red = lightness * 255 + green = red + blue = red + else + var/a;var/b; + if(lightness < 0.5) b = lightness*(1+saturation) + else b = (lightness+saturation) - (saturation*lightness) + a = 2*lightness - b + + red = round(255 * hue2rgb(a, b, hue+(1/3))) + green = round(255 * hue2rgb(a, b, hue)) + blue = round(255 * hue2rgb(a, b, hue-(1/3))) + + return list(red, green, blue) + +/proc/hue2rgb(a, b, hue) + if(hue < 0) hue++ + else if(hue > 1) hue-- + if(6*hue < 1) return (a+(b-a)*6*hue) + if(2*hue < 1) return b + if(3*hue < 2) return (a+(b-a)*((2/3)-hue)*6) + return a \ No newline at end of file diff --git a/code/game/verbs/ooc.dm b/code/game/verbs/ooc.dm index f64a36c9c05..7ebf272cf4d 100644 --- a/code/game/verbs/ooc.dm +++ b/code/game/verbs/ooc.dm @@ -37,8 +37,11 @@ return log_ooc("[mob.name]/[key] : [msg]") - - var/keyname = unlock_content ? "[key]" : key + + var/keyname = key + if(prefs.unlock_content) + if(prefs.toggles & MEMBER_PUBLIC) + keyname = "[keyname]" for(var/client/C in clients) if(C.prefs.toggles & CHAT_OOC) @@ -65,13 +68,12 @@ var/global/normal_ooc_colour = "#002eb8" set name = "OOC Text Color" set category = "Preferences" - if(!unlock_content && !(holder && (holder.rights & R_ADMIN))) - src << "You must be a byond member or admin with +ADMIN rights to access this feature. Sorry" - return + if(!holder || !(holder.rights & R_ADMIN)) + if(!is_content_unlocked()) return var/new_ooccolor = input(src, "Please select your OOC colour.", "OOC colour") as color|null if(new_ooccolor) - prefs.ooccolor = new_ooccolor + prefs.ooccolor = sanitize_ooccolor(new_ooccolor) prefs.save_preferences() feedback_add_details("admin_verb","OC") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! return \ No newline at end of file diff --git a/code/modules/admin/verbs/massmodvar.dm b/code/modules/admin/verbs/massmodvar.dm index a35fb151745..910f7530bb2 100644 --- a/code/modules/admin/verbs/massmodvar.dm +++ b/code/modules/admin/verbs/massmodvar.dm @@ -26,7 +26,7 @@ /client/proc/massmodify_variables(var/atom/O, var/var_name = "", var/method = 0) if(!check_rights(R_VAREDIT)) return - var/list/locked = list("vars", "key", "ckey", "client") + var/list/locked = list("vars", "key", "ckey", "client", "unlock_content") for(var/p in forbidden_varedit_object_types) if( istype(O,p) ) diff --git a/code/modules/admin/verbs/modifyvariables.dm b/code/modules/admin/verbs/modifyvariables.dm index da36e048340..5ffda7985a6 100644 --- a/code/modules/admin/verbs/modifyvariables.dm +++ b/code/modules/admin/verbs/modifyvariables.dm @@ -130,7 +130,7 @@ var/list/forbidden_varedit_object_types = list( if(!istype(L,/list)) src << "Not a List." - var/list/locked = list("vars", "client", "firemut", "ishulk", "telekinesis", "xray", "virus", "viruses", "cuffed", "ka", "last_eaten", "urine", "poo") + var/list/locked = list("vars", "client", "virus", "viruses", "cuffed", "last_eaten", "unlock_content") var/list/ckey_edit = list("key", "ckey") var/list/icon_edit = list("icon", "icon_state", "overlays", "underlays") var/list/names = sortList(L) @@ -274,7 +274,7 @@ var/list/forbidden_varedit_object_types = list( /client/proc/modify_variables(var/atom/O, var/param_var_name = null, var/autodetect_class = 0) if(!check_rights(R_VAREDIT)) return - var/list/locked = list("vars", "client", "firemut", "ishulk", "telekinesis", "xray", "virus", "cuffed", "ka", "last_eaten", "mutantrace") + var/list/locked = list("vars", "client", "virus", "cuffed", "last_eaten", "mutantrace") var/list/ckey_edit = list("key", "ckey") var/list/icon_edit = list("icon", "icon_state", "overlays", "underlays") diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index b88ee8fadd3..3ef743c60b8 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -17,8 +17,6 @@ var/adminobs = null var/area = null - var/unlock_content = 0 //byond-member content - /////////////// //SOUND STUFF// /////////////// diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 3056a000378..adef2c387cc 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -87,8 +87,6 @@ if(byond_version < MIN_CLIENT_VERSION) //Out of date client. return null - unlock_content = IsByondMember() - clients += src directory[ckey] = src @@ -269,4 +267,10 @@ 'icons/stamp_icons/large_stamp-cap.png', 'icons/stamp_icons/large_stamp-qm.png', 'icons/stamp_icons/large_stamp-law.png' - ) \ No newline at end of file + ) + +/client/proc/is_content_unlocked() + if(!prefs.unlock_content) + src << "Become a BYOND member to access member-perks and features, as well as support the engine that makes this game possible. Click Here to find out more." + return 0 + return 1 \ No newline at end of file diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index b9fd5d3e4a3..cab7dd9c4ae 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -35,6 +35,7 @@ datum/preferences var/be_special = 0 //Special role selection var/UI_style = "Midnight" var/toggles = TOGGLES_DEFAULT + var/ghost_form = "ghost" //character preferences var/real_name //our character's name @@ -76,6 +77,8 @@ datum/preferences // OOC Metadata: var/metadata = "" + + var/unlock_content = 0 /datum/preferences/New(client/C) b_type = random_blood_type() @@ -83,7 +86,8 @@ datum/preferences if(istype(C)) if(!IsGuestKey(C.key)) load_path(C.ckey) - if(C.unlock_content) + unlock_content = C.IsByondMember() + if(unlock_content) max_save_slots = 8 var/loaded_preferences_successfully = load_preferences() if(loaded_preferences_successfully) @@ -203,12 +207,16 @@ datum/preferences if(user.client) if(user.client.holder) - dat += "Adminhelp Sound: " + dat += "Adminhelp Sound: " dat += "[(toggles & SOUND_ADMINHELP)?"On":"Off"]
" - if(user.client.unlock_content || (user.client.holder && (user.client.holder.rights & R_ADMIN))) - dat += "
OOC
" - dat += "    Change
" + if(unlock_content || (user.client.holder && (user.client.holder.rights & R_ADMIN))) + dat += "OOC:     Change
" + + if(unlock_content) + dat += "BYOND Membership Publicity: [(toggles & MEMBER_PUBLIC) ? "Public" : "Hidden"]
" + dat += "Ghost Form: [ghost_form]
" + dat += "" @@ -532,6 +540,11 @@ datum/preferences if("input") switch(href_list["preference"]) + if("ghostform") + if(unlock_content) + var/new_form = input(user, "Thanks for supporting BYOND - Choose your ghostly form:","Thanks for supporting BYOND",null) as null|anything in ghost_forms + if(new_form) + ghost_form = new_form if("name") var/new_name = reject_bad_name( input(user, "Choose your character's name:", "Character Preference") as text|null ) if(new_name) @@ -600,7 +613,7 @@ datum/preferences if("ooccolor") var/new_ooccolor = input(user, "Choose your OOC colour:", "Game Preference") as color|null if(new_ooccolor) - ooccolor = new_ooccolor + ooccolor = sanitize_ooccolor(new_ooccolor) if("bag") var/new_backbag = input(user, "Choose your character's style of bag:", "Character Preference") as null|anything in backbaglist @@ -608,6 +621,9 @@ datum/preferences backbag = backbaglist.Find(new_backbag) else switch(href_list["preference"]) + if("publicity") + if(unlock_content) + toggles ^= MEMBER_PUBLIC if("gender") if(gender == MALE) gender = FEMALE diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index b0be8e5d1b5..1c4edf7acf6 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -2,7 +2,7 @@ #define SAVEFILE_VERSION_MIN 8 //This is the current version, anything below this will attempt to update (if it's not obsolete) -#define SAVEFILE_VERSION_MAX 9 +#define SAVEFILE_VERSION_MAX 10 /* SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn This proc checks if the current directory of the savefile S needs updating @@ -31,6 +31,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car return -1 /datum/preferences/proc/update_preferences(current_version) + if(current_version < 10) + toggles |= MEMBER_PUBLIC return //should this proc get fairly long (say 3 versions long), @@ -71,14 +73,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car if(11) underwear = "Ladies Kinky" if(12) underwear = "Tankini" if(13) underwear = "Nude" - - /* - if(current_version < 10) //would be the step to upgrade 9 to 10 - //do stuff - if(current_version < 11) //and so on... - //more stuff - */ - return /datum/preferences/proc/load_path(ckey,filename="preferences.sav") @@ -104,20 +98,20 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car S["be_special"] >> be_special S["default_slot"] >> default_slot S["toggles"] >> toggles + S["ghost_form"] >> ghost_form //try to fix any outdated data if necessary if(needs_update >= 0) update_preferences(needs_update) //needs_update = savefile_version if we need an update (positive integer) - - //Sanitize - ooccolor = sanitize_hexcolor(ooccolor, 6, 1, initial(ooccolor)) + ooccolor = sanitize_ooccolor(sanitize_hexcolor(ooccolor, 6, 1, initial(ooccolor))) lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog)) UI_style = sanitize_inlist(UI_style, list("Midnight", "Plasmafire", "Retro"), initial(UI_style)) be_special = sanitize_integer(be_special, 0, 65535, initial(be_special)) default_slot = sanitize_integer(default_slot, 1, max_save_slots, initial(default_slot)) toggles = sanitize_integer(toggles, 0, 65535, initial(toggles)) + ghost_form = sanitize_inlist(ghost_form, ghost_forms, initial(ghost_form)) return 1 @@ -136,6 +130,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car S["be_special"] << be_special S["default_slot"] << default_slot S["toggles"] << toggles + S["ghost_form"] << ghost_form return 1 diff --git a/code/modules/client/preferences_toggles.dm b/code/modules/client/preferences_toggles.dm index 4761b6695b0..5c435640d88 100644 --- a/code/modules/client/preferences_toggles.dm +++ b/code/modules/client/preferences_toggles.dm @@ -119,4 +119,25 @@ prefs.be_special ^= role_flag prefs.save_preferences() src << "You will [(prefs.be_special & role_flag) ? "now" : "no longer"] be considered for [role] events (where possible)." - feedback_add_details("admin_verb","TBeSpecial") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! \ No newline at end of file + feedback_add_details("admin_verb","TBeSpecial") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! + +/client/verb/toggle_member_publicity() + set name = "Toggle Membership Publicity" + set category = "Preferences" + set desc = "Toggles whether other players can see that you are a BYOND member (OOC blag icon/colours)." + prefs.toggles ^= MEMBER_PUBLIC + prefs.save_preferences() + src << "Others can[(prefs.toggles & MEMBER_PUBLIC) ? "" : "not"] see whether you are a byond member." + +var/list/ghost_forms = list("ghost","ghostking","ghostian2") +/client/verb/pick_form() + set name = "Pick Ghost Form" + set category = "Preferences" + set desc = "Choose your preferred ghostly appearance." + if(!is_content_unlocked()) return + var/new_form = input(src, "Thanks for supporting BYOND - Choose your ghostly form:","Thanks for supporting BYOND",null) as null|anything in ghost_forms + if(new_form) + prefs.ghost_form = new_form + prefs.save_preferences() + if(istype(mob,/mob/dead/observer)) + mob.icon_state = new_form \ No newline at end of file diff --git a/code/modules/mob/dead/observer/login.dm b/code/modules/mob/dead/observer/login.dm index ce0dbe3d57f..85ca2f8eff4 100644 --- a/code/modules/mob/dead/observer/login.dm +++ b/code/modules/mob/dead/observer/login.dm @@ -1,2 +1,4 @@ /mob/dead/observer/Login() - ..() \ No newline at end of file + ..() + if(client.prefs.unlock_content) + icon_state = client.prefs.ghost_form \ No newline at end of file diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index b71594cd192..ae343e49f5f 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -256,12 +256,4 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp if (see_invisible == SEE_INVISIBLE_OBSERVER_NOLIGHTING) see_invisible = SEE_INVISIBLE_OBSERVER else - see_invisible = SEE_INVISIBLE_OBSERVER_NOLIGHTING - -/mob/dead/observer/verb/pick_form() - set name = "Pick Ghost Form" - set category = "Ghost" - set desc = "Choose your ghostly appearance" - var/new_form = input(src, "Thanks for supporting BYOND - Choose your ghostly form:","Thanks for supporting BYOND","ghost") as null|anything in list("ghost","ghostking","ghostian2") - if(new_form) - icon_state = new_form \ No newline at end of file + see_invisible = SEE_INVISIBLE_OBSERVER_NOLIGHTING \ No newline at end of file diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 5963da7068f..ec3a2e2de24 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -120,9 +120,6 @@ proc/isorgan(A) return 1 return 0 -/proc/hsl2rgb(h, s, l) - return - /proc/isloyal(A) //Checks to see if the person contains a loyalty implant, then checks that the implant is actually inside of them for(var/obj/item/weapon/implant/loyalty/L in A) if(L && L.implanted) diff --git a/tgstation.dme b/tgstation.dme index d076018f544..3b3fe92853f 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -798,6 +798,7 @@ #include "code\modules\mob\update_icons.dm" #include "code\modules\mob\dead\death.dm" #include "code\modules\mob\dead\observer\hud.dm" +#include "code\modules\mob\dead\observer\login.dm" #include "code\modules\mob\dead\observer\logout.dm" #include "code\modules\mob\dead\observer\observer.dm" #include "code\modules\mob\dead\observer\say.dm"