From 76440d9acd4ac221ec313812561daef4f4634fad Mon Sep 17 00:00:00 2001 From: "elly1989@rocketmail.com" Date: Sun, 12 Aug 2012 21:58:18 +0000 Subject: [PATCH] Tidied up the preferences screen a tiny bit. It now uses switches and should fix another: The following runtime has occured 23 time(s). runtime error: Cannot read null.key proc name: process link (/datum/preferences/proc/process_link) source file: preferences.dm,638 usr: null src: /datum/preferences (/datum/preferences) git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4384 316c924e-a436-60f5-8080-3fe189b3f50e --- .../machinery/computer/HolodeckControl.dm | 2 +- code/modules/mob/new_player/new_player.dm | 2 +- code/modules/mob/new_player/preferences.dm | 485 ++++++++---------- 3 files changed, 221 insertions(+), 268 deletions(-) diff --git a/code/game/machinery/computer/HolodeckControl.dm b/code/game/machinery/computer/HolodeckControl.dm index affbcb3fbf6..25d7148ab6e 100644 --- a/code/game/machinery/computer/HolodeckControl.dm +++ b/code/game/machinery/computer/HolodeckControl.dm @@ -544,7 +544,7 @@ /obj/machinery/readybutton name = "Ready Declaration Device" - desc = "This device is used to declare ready. If all devices in an area are ready, the event will begin!" + desc = "This device is used to declare ready. If all devices in an area are ready, the event will begin!" icon = 'icons/obj/monitors.dmi' icon_state = "auth_off" var/ready = 0 diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index bd2629ed8e2..15d1c04aac0 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -205,7 +205,7 @@ dbcon.Disconnect() - if(!ready && href_list["preferences"]) + if(!ready && href_list["preference"]) preferences.process_link(src, href_list) else if(!href_list["late_join"]) new_player_panel() diff --git a/code/modules/mob/new_player/preferences.dm b/code/modules/mob/new_player/preferences.dm index 3b6b98d767b..6633b4eef51 100644 --- a/code/modules/mob/new_player/preferences.dm +++ b/code/modules/mob/new_player/preferences.dm @@ -1,8 +1,5 @@ //This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33 -#define UI_OLD 0 -#define UI_NEW 1 - var/global/list/special_roles = list( //keep synced with the defines BE_* in setup.dm --rastaf //some autodetection here. "traitor" = IS_MODE_COMPILED("traitor"), // 0 @@ -81,8 +78,6 @@ datum/preferences var/g_eyes = 0 var/b_eyes = 0 - //UI style - //UI = UI_OLD var/UI_style = "Midnight" //Mob preview @@ -120,6 +115,7 @@ datum/preferences proc/ShowChoices(mob/user) + if(!user || !user.client) return update_preview_icon() user << browse_rsc(preview_icon_front, "previewicon.png") user << browse_rsc(preview_icon_side, "previewicon2.png") @@ -132,10 +128,10 @@ datum/preferences for(var/i = 1; i <= MAX_SAVE_SLOTS; i += 1) var/savefile/F = new /savefile("data/player_saves/[copytext(user.ckey, 1, 2)]/[user.ckey]/preferences[i].sav") F["slotname"] >> n - if((n == "") || !n) - saves += "Save Slot [i]" + if(!n) + saves += "Save Slot [i]" else - saves += "[n]" + saves += "[n]" for(var/i = 1; i <= MAX_SAVE_SLOTS; i += 1) if(i == user.client.activeslot) @@ -148,12 +144,12 @@ datum/preferences if(i == default_slot) dat += "(D)" else - dat += "(D)" + dat += "(D)" if(i != MAX_SAVE_SLOTS) dat += " / " dat += "
" - dat += "*" + dat += "*" else dat += "Please create an account to save your preferences." @@ -161,66 +157,65 @@ datum/preferences dat += "
" dat += "Name: " - dat += "[real_name] " - dat += "(®) " - dat += "(® = [be_random_name ? "Yes" : "No"])" + dat += "[real_name] " + dat += "(®) " + dat += "(® = [be_random_name ? "Yes" : "No"])" dat += "
" - dat += "Gender: [gender == MALE ? "Male" : "Female"]
" - dat += "Age: [age]" + dat += "Gender: [gender == MALE ? "Male" : "Female"]
" + dat += "Age: [age]" dat += "
" - dat += "UI Style: [UI_style]
" - dat += "Play admin midis: [midis == 1 ? "Yes" : "No"]
" - dat += "Ghost ears: [ghost_ears == 0 ? "Nearest Creatures" : "All Speech"]
" - dat += "Ghost sight: [ghost_sight == 0 ? "Nearest Creatures" : "All Emotes"]
" + dat += "UI Style: [UI_style]
" + dat += "Play admin midis: [midis == 1 ? "Yes" : "No"]
" + dat += "Ghost ears: [ghost_ears == 0 ? "Nearest Creatures" : "All Speech"]
" + dat += "Ghost sight: [ghost_sight == 0 ? "Nearest Creatures" : "All Emotes"]
" if(config.allow_Metadata) - dat += "OOC Notes: Edit
" + dat += "OOC Notes: Edit
" if((user.client) && (user.client.holder) && (user.client.holder.rank)) dat += "Adminhelp sound: " - dat += "[(sound_adminhelp)?"On":"Off"] toggle
" + dat += "[(sound_adminhelp)?"On":"Off"] toggle
" if(user.client.holder.level >= 5) dat += "
OOC
" - dat += "Change color
__

" + dat += "Change color
__

" dat += "
Occupation Choices
" - dat += "\tSet Preferences
" + dat += "\tSet Preferences
" dat += "
Body " - dat += "(®)" // Random look + dat += "(®)" dat += "
" - dat += "Blood Type: [b_type]
" - dat += "Skin Tone: [-s_tone + 35]/220
" + dat += "Blood Type: [b_type]
" + dat += "Skin Tone: [-s_tone + 35]/220
" - // if(!IsGuestKey(user.key))//Seeing as it doesn't do anything, it may as well not show up. if(gender == MALE) - dat += "Underwear: [underwear_m[underwear]]
" + dat += "Underwear: [underwear_m[underwear]]
" else - dat += "Underwear: [underwear_f[underwear]]
" + dat += "Underwear: [underwear_f[underwear]]
" - dat += "Backpack Type:
[backbaglist[backbag]]
" + dat += "Backpack Type:
[backbaglist[backbag]]
" - dat += "
Preview
" //Carn: Now with profile! + dat += "
Preview
" dat += "" dat += "
Hair
" - dat += "Change Color
__
" + dat += "Change Color
__
" - dat += "Style: [h_style]
" + dat += "Style: [h_style]
" dat += "
Facial
" - dat += "Change Color
__
" + dat += "Change Color
__
" - dat += "Style: [f_style]
" + dat += "Style: [f_style]
" dat += "
Eyes
" - dat += "Change Color
__
" + dat += "Change Color
__
" dat += "

" if(jobban_isbanned(user, "Syndicate")) @@ -236,15 +231,15 @@ datum/preferences if(jobban_isbanned(user, "pAI")) dat += "Be [i]: \[BANNED]
" else - dat += "Be [i]: [src.be_special&(1<
" + dat += "Be [i]: [src.be_special&(1<
" n++ dat += "
" if(!IsGuestKey(user.key)) - dat += "Undo - " - dat += "Save Setup - " + dat += "Undo - " + dat += "Save Setup - " - dat += "Reset Setup" + dat += "Reset Setup" dat += "
" user << browse(dat, "window=preferences;size=550x545") @@ -259,7 +254,7 @@ datum/preferences var/HTML = "" HTML += "
" HTML += "Choose occupation chances
Unavailable occupations are in red.

" - HTML += "\[Done\]

" // Easier to press up here. + HTML += "\[Done\]

" // Easier to press up here. HTML += "
" // Table within a table for alignment, also allows you to easily add more colomns. HTML += "" var/index = -1 @@ -295,7 +290,7 @@ datum/preferences HTML += "
" - HTML += "" + HTML += "" if(rank == "Assistant")//Assistant is special if(job_civilian_low & ASSISTANT) @@ -319,7 +314,7 @@ datum/preferences HTML += "
" - HTML += "

Get random job if preferences unavailable" : "red>Be assistant if preference unavailable"]
" + HTML += "

Get random job if preferences unavailable" : "red>Be assistant if preference unavailable"]
" HTML += "" @@ -436,269 +431,231 @@ datum/preferences return 1 - proc/process_link(mob/user, list/link_tags) - if(!user) - return + proc/process_link(mob/user, list/href_list) + if(!user) return - if(link_tags["togglerandjob"]) - userandomjob = !userandomjob - SetChoices(user) - return 1 - - if(link_tags["occ"]) - if(link_tags["cancel"]) - user << browse(null, "window=\ref[user]occupation") - return - else if(link_tags["job"]) - SetJob(user, link_tags["job"]) - else - if(job_master) + if(href_list["preference"] == "job") + switch(href_list["task"]) + if("close") + user << browse(null, "window=mob_occupation") + ShowChoices(user) + if("random") + userandomjob = !userandomjob + SetChoices(user) + if("input") + SetJob(user, href_list["text"]) + else SetChoices(user) - return 1 + switch(href_list["task"]) + if("random") + switch(href_list["preference"]) + if("name") + randomize_name() - if(link_tags["real_name"]) - var/new_name + if("age") + age = rand(17, 45) - switch(link_tags["real_name"]) - if("input") - new_name = reject_bad_name( input(user, "Please select a name:", "Character Generation") as text|null ) - if(new_name) - real_name = new_name - else - user << "Invalid name. Your name should be at least 2 and at most [MAX_NAME_LEN] characters long. It may only contain the characters A-Z, a-z, -, ' and ." + if("b_type") + b_type = pick( 31;"A+", 7;"A-", 8;"B+", 2;"B-", 2;"AB+", 1;"AB-", 40;"O+", 9;"O-" ) - if("random") - randomize_name() + if("hair") + randomize_hair_color("hair") - if(link_tags["age"]) - switch(link_tags["age"]) - if("input") - var/new_age = input(user, "Please select type in age: 17-45", "Character Generation") as num - if(new_age) - age = max(min(round(text2num(new_age)), 45), 17) - if("random") - age = rand (17, 45) + if("h_style") + randomize_hair(gender) - if(link_tags["OOC"]) - var/tempnote = "" - tempnote = copytext(sanitize(input(user, "Please enter your OOC Notes!:", "OOC notes" , metadata) as text),1,MAX_MESSAGE_LEN) - if(tempnote) - metadata = tempnote - return + if("facial") + randomize_hair_color("facial") + if("f_style") + randomize_facial(gender) + if("underwear") + underwear = rand(1,12) + if("eyes") + randomize_eyes_color() - if(link_tags["b_type"]) - switch(link_tags["b_type"]) - if("input") - var/new_b_type = input(user, "Please select a blood type:", "Character Generation") as null|anything in list( "A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-" ) - if(new_b_type) - b_type = new_b_type - if("random") - b_type = pickweight ( list ("A+" = 31, "A-" = 7, "B+" = 8, "B-" = 2, "AB+" = 2, "AB-" = 1, "O+" = 40, "O-" = 9)) + if("s_tone") + randomize_skin_tone() + if("bag") + backbag = rand(1,3) - if(link_tags["hair"]) - switch(link_tags["hair"]) - if("input") - var/new_hair = input(user, "Please select hair color.", "Character Generation") as color - if(new_hair) - r_hair = hex2num(copytext(new_hair, 2, 4)) - g_hair = hex2num(copytext(new_hair, 4, 6)) - b_hair = hex2num(copytext(new_hair, 6, 8)) - if("random") - randomize_hair_color("hair") + if("all") + gender = pick(MALE,FEMALE) + randomize_name() + age = rand(17,45) + underwear = rand(1,12) + backbag = rand(1,3) + randomize_hair_color("hair") + randomize_hair(gender) + randomize_hair_color("facial") + randomize_facial(gender) + randomize_eyes_color() + randomize_skin_tone() + b_type = pick( 31;"A+", 7;"A-", 8;"B+", 2;"B-", 2;"AB+", 1;"AB-", 40;"O+", 9;"O-" ) - if(link_tags["facial"]) - switch(link_tags["facial"]) - if("input") - var/new_facial = input(user, "Please select facial hair color.", "Character Generation") as color - if(new_facial) - r_facial = hex2num(copytext(new_facial, 2, 4)) - g_facial = hex2num(copytext(new_facial, 4, 6)) - b_facial = hex2num(copytext(new_facial, 6, 8)) - if("random") - randomize_hair_color("facial") + job_civilian_high = 0 + job_civilian_med = 0 + job_civilian_low = 0 + job_medsci_high = 0 + job_medsci_med = 0 + job_medsci_low = 0 + job_engsec_high = 0 + job_engsec_med = 0 + job_engsec_low = 0 + be_special = 0 + be_random_name = 0 + UI_style = "Midnight" + midis = 1 + ghost_ears = 1 + userandomjob = 1 - if(link_tags["eyes"]) - switch(link_tags["eyes"]) - if("input") - var/new_eyes = input(user, "Please select eye color.", "Character Generation") as color - if(new_eyes) - r_eyes = hex2num(copytext(new_eyes, 2, 4)) - g_eyes = hex2num(copytext(new_eyes, 4, 6)) - b_eyes = hex2num(copytext(new_eyes, 6, 8)) - if("random") - randomize_eyes_color() + if("input") + switch(href_list["preference"]) + if("name") + var/new_name = reject_bad_name( input(user, "Choose your character's name:", "Character Preference") as text|null ) + if(new_name) + real_name = new_name + else + user << "Invalid name. Your name should be at least 2 and at most [MAX_NAME_LEN] characters long. It may only contain the characters A-Z, a-z, -, ' and ." - if(link_tags["s_tone"]) - switch(link_tags["s_tone"]) - if("random") - randomize_skin_tone() - if("input") - var/new_tone = input(user, "Please select skin tone level: 1-220 (1=albino, 35=caucasian, 150=black, 220='very' black)", "Character Generation") as num - if(new_tone) - s_tone = max(min(round(new_tone), 220), 1) - s_tone = -s_tone + 35 + if("age") + var/new_age = input(user, "Choose your character's age:\n(17-45)", "Character Preference") as num|null + if(new_age) + age = max(min(round(text2num(new_age)), 45), 17) - if(link_tags["h_style"]) - switch(link_tags["h_style"]) + if("metadata") + var/new_metadata = input(user, "Enter any information you'd like others to see, such as Roleplay-preferences:", "Game Preference" , metadata) as message|null + if(new_metadata) + metadata = sanitize(copytext(new_metadata,1,MAX_MESSAGE_LEN)) - // New and improved hair selection code, by Doohl - if("random") // random hair selection + if("b_type") + var/new_b_type = input(user, "Choose your character's blood-type:", "Character Preference") as null|anything in list( "A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-" ) + if(new_b_type) + b_type = new_b_type - randomize_hair(gender) // call randomize_hair() proc with var/gender parameter - // see preferences_setup.dm for proc + if("hair") + var/new_hair = input(user, "Choose your character's hair colour:", "Character Preference") as color|null + if(new_hair) + r_hair = hex2num(copytext(new_hair, 2, 4)) + g_hair = hex2num(copytext(new_hair, 4, 6)) + b_hair = hex2num(copytext(new_hair, 6, 8)) - if("input") // input hair selection - var/new_style = input(user, "Select a hair style", "Character Generation") as null|anything in hair_styles_list - if(new_style) - h_style = new_style + if("h_style") + var/new_h_style = input(user, "Choose your character's hair style:", "Character Preference") as null|anything in hair_styles_list + if(new_h_style) + h_style = new_h_style + if("facial") + var/new_facial = input(user, "Choose your character's facial-hair colour:", "Character Preference") as color|null + if(new_facial) + r_facial = hex2num(copytext(new_facial, 2, 4)) + g_facial = hex2num(copytext(new_facial, 4, 6)) + b_facial = hex2num(copytext(new_facial, 6, 8)) - if(link_tags["ooccolor"]) - var/ooccolor = input(user, "Please select OOC colour.", "OOC colour") as color + if("f_style") + var/new_f_style = input(user, "Choose your character's facial-hair style:", "Character Preference") as null|anything in facial_hair_styles_list + if(new_f_style) + f_style = new_f_style - if(ooccolor) - src.ooccolor = ooccolor + if("underwear") + var/list/underwear_options + if(gender == MALE) + underwear_options = underwear_m + else + underwear_options = underwear_f - if(link_tags["toggleadminhelpsound"]) - src.sound_adminhelp = !src.sound_adminhelp + var/new_underwear = input(user, "Choose your character's underwear:", "Character Preference") as null|anything in underwear_options + if(new_underwear) + underwear = underwear_options.Find(new_underwear) - if(link_tags["f_style"]) - switch(link_tags["f_style"]) + if("eyes") + var/new_eyes = input(user, "Choose your character's eye colour:", "Character Preference") as color|null + if(new_eyes) + r_eyes = hex2num(copytext(new_eyes, 2, 4)) + g_eyes = hex2num(copytext(new_eyes, 4, 6)) + b_eyes = hex2num(copytext(new_eyes, 6, 8)) - // see above for commentation. This is just a slight modification of the hair code for facial hairs - if("random") - randomize_facial(gender) + if("s_tone") + var/new_s_tone = input(user, "Choose your character's skin-tone:\n(Light 1 - 220 Dark)", "Character Preference") as num|null + if(new_s_tone) + s_tone = max(min(round(new_s_tone), 220), 1) + s_tone = -s_tone + 35 - if("input") - var/new_style = input(user, "Select a facial hair style", "Character Generation") as null|anything in facial_hair_styles_list - if(new_style) - f_style = new_style + if("ooccolor") + var/new_ooccolor = input(user, "Choose your OOC colour:", "Game Preference") as color|null + if(new_ooccolor) + ooccolor = new_ooccolor + + if("bag") + var/new_backbag = input(user, "Choose your character's style of bag:", "Character Preference") as null|anything in backbaglist + if(new_backbag) + backbag = backbaglist.Find(new_backbag) + + if("slotname") + var/new_slotname = input(user, "Please name this savefile:", "Save Slot Name") as text|null + if(ckey(new_slotname))//Checks to make sure there is one letter + slot_name = strip_html_simple(new_slotname,16) - if(link_tags["gender"]) - if(gender == MALE) - gender = FEMALE else - gender = MALE + switch(href_list["preference"]) + if("gender") + if(gender == MALE) + gender = FEMALE + else + gender = MALE - if(link_tags["UI"]) - switch(UI_style) - if("Midnight") - UI_style = "Orange" - if("Orange") - UI_style = "old" - if("old") - UI_style = "Midnight" - else - UI_style = "Midnight" + if("hear_adminhelps") + sound_adminhelp = !sound_adminhelp - if(link_tags["midis"]) - midis = !midis + if("ui") + switch(UI_style) + if("Midnight") + UI_style = "Orange" + if("Orange") + UI_style = "old" + else + UI_style = "Midnight" - if(link_tags["ghost_ears"]) - ghost_ears = !ghost_ears + if("be_special") + var/num = text2num(href_list["num"]) + be_special ^= (1<