[MIRROR] Kitchen Sink P2 TGUI Prefs (#10770)

Co-authored-by: Cameron Lennox <killer65311@gmail.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-04-26 23:50:26 +02:00
committed by GitHub
co-authored by Cameron Lennox Kashargul
parent 77b972fed3
commit ca9de6648e
48 changed files with 222 additions and 816 deletions
@@ -35,60 +35,7 @@
apply_layer(SHOES_LAYER)
apply_layer(SHOES_LAYER_ALT)
/mob/living/carbon/human/proc/GetAppearanceFromPrefs(var/flavourtext, var/oocnotes)
/* Jank code that effectively creates the client's mob from save, then copies its appearance to our current mob.
Intended to be used with shapeshifter species so we don't reset their organs in doing so.*/
if(client.prefs)
var/mob/living/carbon/human/dummy/mannequin/Dummy = get_mannequin(client.ckey)
client.prefs.copy_to(Dummy)
//Important, since some sprites only work for specific species
/* Probably not needed anymore since impersonate_bodytype no longer exists
if(Dummy.species.base_species == "Promethean")
impersonate_bodytype = "Human"
else
impersonate_bodytype = Dummy.species.base_species
*/
custom_species = Dummy.custom_species
var/list/traits = dna.species_traits.Copy()
dna = Dummy.dna.Clone()
dna.species_traits.Cut()
dna.species_traits = traits.Copy()
UpdateAppearance()
icon = Dummy.icon
if(flavourtext)
flavor_texts = client.prefs.flavor_texts.Copy()
if(oocnotes)
ooc_notes = client.prefs.read_preference(/datum/preference/text/living/ooc_notes)
ooc_notes_likes = client.prefs.read_preference(/datum/preference/text/living/ooc_notes_likes)
ooc_notes_dislikes = client.prefs.read_preference(/datum/preference/text/living/ooc_notes_dislikes)
ooc_notes_favs = read_preference(/datum/preference/text/living/ooc_notes_favs)
ooc_notes_maybes = read_preference(/datum/preference/text/living/ooc_notes_maybes)
ooc_notes_style = read_preference(/datum/preference/toggle/living/ooc_notes_style)
/* Alternative version of the above proc, incase it turns out cloning our dummy mob's DNA is an awful, terrible bad idea.
Would need to fix this proc up to work as smoothly as the above proc, though.
/mob/living/carbon/human/proc/GetAppearanceFromPrefs()
/* Jank code that effectively creates the client's mob from save, then copies its appearance to our current mob.
Intended to be used with shapeshifter species so we don't reset their organs in doing so.*/
var/mob/living/carbon/human/dummy/mannequin/Dummy = new
if(client.prefs)
client.prefs.copy_to(Dummy)
//Important, since some sprites only work for specific species
if(Dummy.species.base_species == "Promethean")
impersonate_bodytype = "Human"
else
impersonate_bodytype = Dummy.species.base_species
custom_species = Dummy.custom_species
for(var/tag in Dummy.dna.body_markings)
var/obj/item/organ/external/E = organs_by_name[tag]
if(E)
E.markings.Cut()
var/list/marklist = Dummy.dna.body_markings[tag]
E.markings = marklist.Copy()
UpdateAppearance(Dummy.dna.UI.Copy())
icon = Dummy.icon
qdel(Dummy)
*/
/mob/living/carbon/human/update_tail_showing()
. = ..()
@@ -37,41 +37,3 @@ Maybe later, gotta figure out a way to click yourself when in a locker etc.
/mob/living/proc/handle_vorefootstep(m_intent, turf/T) // Moved from living_ch.dm
return FALSE
//ChompEDIT START - Removal of usr
/mob/living/proc/set_metainfo_favs(var/mob/user, var/reopen = TRUE)
if(user != src)
return
var/new_metadata = strip_html_simple(tgui_input_text(user, "Enter any information you'd like others to see relating to your FAVOURITE roleplay preferences. This will not be saved permanently unless you click save in the OOC notes panel! Type \"!clear\" to empty.", "Game Preference" , html_decode(ooc_notes_favs), multiline = TRUE, prevent_enter = TRUE))
if(new_metadata && CanUseTopic(user))
if(new_metadata == "!clear")
new_metadata = ""
ooc_notes_favs = new_metadata
client.prefs.update_preference_by_type(/datum/preference/text/living/ooc_notes_favs, new_metadata)
to_chat(user, span_filter_notice("OOC note favs have been updated. Don't forget to save!"))
log_admin("[key_name(user)] updated their OOC note favs mid-round.")
if(reopen)
ooc_notes_window(user)
/mob/living/proc/set_metainfo_maybes(var/mob/user, var/reopen = TRUE)
if(user != src)
return
var/new_metadata = strip_html_simple(tgui_input_text(user, "Enter any information you'd like others to see relating to your MAYBE roleplay preferences. This will not be saved permanently unless you click save in the OOC notes panel! Type \"!clear\" to empty.", "Game Preference" , html_decode(ooc_notes_maybes), multiline = TRUE, prevent_enter = TRUE))
if(new_metadata && CanUseTopic(user))
if(new_metadata == "!clear")
new_metadata = ""
ooc_notes_maybes = new_metadata
client.prefs.update_preference_by_type(/datum/preference/text/living/ooc_notes_maybes, new_metadata)
to_chat(user, span_filter_notice("OOC note maybes have been updated. Don't forget to save!"))
log_admin("[key_name(user)] updated their OOC note maybes mid-round.")
if(reopen)
ooc_notes_window(user)
/mob/living/proc/set_metainfo_ooc_style(var/mob/user, var/reopen = TRUE)
if(user != src)
return
ooc_notes_style = !ooc_notes_style
client.prefs.update_preference_by_type(/datum/preference/toggle/living/ooc_notes_style, ooc_notes_style)
if(reopen)
ooc_notes_window(user)
//ChompEDIT END - Removal of usr
@@ -1,4 +0,0 @@
/mob/living
var/ooc_notes_favs = null
var/ooc_notes_maybes = null
var/ooc_notes_style = FALSE
@@ -1,208 +0,0 @@
/mob/living/ooc_notes_window(mob/user)
if(!ooc_notes)
return
//I tried to get it to accept things like emojis and all that, but, it wouldn't do! It would be cool if it did.
var/notes = replacetext(html_decode(src.ooc_notes), "\n", "<BR>")
var/favs = replacetext(html_decode(src.ooc_notes_favs), "\n", "<BR>")
var/likes = replacetext(html_decode(src.ooc_notes_likes), "\n", "<BR>")
var/maybes = replacetext(html_decode(src.ooc_notes_maybes), "\n", "<BR>")
var/dislikes = replacetext(html_decode(src.ooc_notes_dislikes), "\n", "<BR>")
var/style = src.ooc_notes_style
var/dat = {"
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>
<style>
* {
box-sizing: border-box;
}
.collapsible {
background-color: #1a1e3f;
color: white;
width: 100%;
text-align: left;
font-size: 20px;
}
.collapsible_a {
background-color: #263d20;
color: white;
width: 100%;
text-align: left;
font-size: 20px;
}
.collapsible_b {
background-color: #3e3f1a;
color: white;
width: 100%;
text-align: left;
font-size: 20px;
}
.collapsible_c {
background-color: #3f1a1a;
color: white;
width: 100%;
text-align: left;
font-size: 20px;
}
.content {
padding: 5;
width: 100%;
background-color: #363636;
}
.column {
verflow-wrap: break-word;
float: left;
width: 25%;
}
.row:after {
content: "";
display: table;
clear: both;
}
</style>
</head>"}
dat += {"<body><table>"}
if(user == src)
dat += {"
<td class="button">
<a href='byond://?src=\ref[src];save_ooc_panel=1' class='button'>Save Character Preferences</a>
</td>
"}
dat += {"
<td class="button">
<a href='byond://?src=\ref[src];print_ooc_notes_chat=1' class='button'>Print to chat</a>
</td>
"}
if(user == src)
if(style)
dat += {"
<td class="button">
<a href='byond://?src=\ref[src];set_metainfo_ooc_style=1' class='button'>Lists</a>
</td>
"}
else
dat += {"
<td class="button">
<a href='byond://?src=\ref[src];set_metainfo_ooc_style=1' class='button'>Fields</a>
</td>
"}
dat += {"</table>"}
if(user == src)
dat += {"
<br>
<table>
<td class="button">
<a href='byond://?src=\ref[src];edit_ooc_notes=1' class='button'>Edit</a>
</td>
</table>
"}
dat += {"
<br>
<div class="content">
<p>[notes]</p>
</div>
<br>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">"}
if(style)
dat += {"<div class='row'><div class='column'>"}
if(favs || user == src)
dat += "<div class=\"collapsible\">" + span_bold("<center>Favourites</center>") + "</div>"
if(user == src)
dat += {"
<table>
<td class="button">
<a href='byond://?src=\ref[src];edit_ooc_note_favs=1' class='button'>Edit</a>
</td>
</table>
"}
if(favs)
dat += {"
<div class="content">
<p>[favs]</p>
</div>"}
if(style)
dat += {"</div>"}
dat += {"<div class='column'>"}
if(likes || user == src)
dat += "<div class=\"collapsible_a\">" + span_bold("<center>Likes</center>") + "</div>"
if(user == src)
dat += {"
<table>
<td class="button">
<a href='byond://?src=\ref[src];edit_ooc_note_likes=1' class='button'>Edit</a>
</td>
</table>
"}
if(likes)
dat += {"
<div class="content">
<p>[likes]</p>
</div>"}
if(style)
dat += {"</div>"}
dat += {"<div class='column'>"}
if(maybes || user == src)
dat += "<div class=\"collapsible_b\">" + span_bold("<center>Maybes</center>") + "</div>"
if(user == src)
dat += {"
<table>
<td class="button">
<a href='byond://?src=\ref[src];edit_ooc_note_maybes=1' class='button'>Edit</a>
</td>
</table>
"}
if(maybes)
dat += {"
<div class="content">
<p>[maybes]</p>
</div>
"}
if(style)
dat += {"</div>"}
dat += {"<div class='column'>"}
if(dislikes || user == src)
dat += "<div class=\"collapsible_c\">" + span_bold("<center>Dislikes</center>") + "</div>"
if(user == src)
dat += {"
<table>
<td class="button">
<a href='byond://?src=\ref[src];edit_ooc_note_dislikes=1' class='button'>Edit</a>
</td>
</table>
"}
if(dislikes)
dat += {"
<div class="content">
<p>[dislikes]</p>
</div>
"}
if(style)
dat += {"</div></div>"}
dat+= {" </body>
</html>"}
var/key = "ooc_notes[src.real_name]" //Generate a unique key so we can make unique clones of windows, that way we can have more than one
if(src.ckey)
key = "[key][src.ckey]" //Add a ckey if they have one, in case their name is the same
winclone(user, "ooc_notes", key) //Allows us to have more than one OOC notes panel open
winshow(user, key, TRUE) //Register our window
var/datum/browser/popup = new(user, key, "OOC Notes: [src.name]", 500, 600) //Create the window
popup.set_content(dat) //Populate window contents
popup.open(FALSE) // Skip registring onclose on the browser pane
onclose(user, key, src) // We want to register on the window itself