mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-13 16:13:19 +01:00
Character-based rebindable custom emotes (#18506)
* 1 * 2 * 3 * make it (mostly) work * character-based emotes * bump SQL version * where did you go little s * no more raw json * partial AA review * makes it not coded as stupidly * donor exclusive emotes 4-7 * ship it Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> * Update code/datums/keybindings/emote.dm Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> * spacings Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
This commit is contained in:
@@ -98,6 +98,8 @@
|
||||
var/h_grad_offset_y = 0
|
||||
var/h_grad_colour = "#000000"
|
||||
var/h_grad_alpha = 255
|
||||
/// Custom emote text ("name" = "emote text")
|
||||
var/list/custom_emotes = list()
|
||||
|
||||
// Fuckery to prevent null characters
|
||||
/datum/character_save/New()
|
||||
@@ -183,7 +185,8 @@
|
||||
hair_gradient=:h_grad_style,
|
||||
hair_gradient_offset=:h_grad_offset,
|
||||
hair_gradient_colour=:h_grad_colour,
|
||||
hair_gradient_alpha=:h_grad_alpha
|
||||
hair_gradient_alpha=:h_grad_alpha,
|
||||
custom_emotes=:custom_emotes
|
||||
WHERE ckey=:ckey
|
||||
AND slot=:slot"}, list(
|
||||
// OH GOD SO MANY PARAMETERS
|
||||
@@ -240,6 +243,7 @@
|
||||
"h_grad_offset" = "[h_grad_offset_x],[h_grad_offset_y]",
|
||||
"h_grad_colour" = h_grad_colour,
|
||||
"h_grad_alpha" = h_grad_alpha,
|
||||
"custom_emotes" = json_encode(custom_emotes),
|
||||
"ckey" = C.ckey,
|
||||
"slot" = slot_number
|
||||
))
|
||||
@@ -280,7 +284,7 @@
|
||||
player_alt_titles,
|
||||
disabilities, organ_data, rlimb_data, nanotrasen_relation, speciesprefs,
|
||||
socks, body_accessory, gear, autohiss,
|
||||
hair_gradient, hair_gradient_offset, hair_gradient_colour, hair_gradient_alpha)
|
||||
hair_gradient, hair_gradient_offset, hair_gradient_colour, hair_gradient_alpha, custom_emotes)
|
||||
VALUES
|
||||
(:ckey, :slot, :metadata, :name, :be_random_name, :gender,
|
||||
:age, :species, :language,
|
||||
@@ -307,7 +311,7 @@
|
||||
:playertitlelist,
|
||||
:disabilities, :organlist, :rlimblist, :nanotrasen_relation, :speciesprefs,
|
||||
:socks, :body_accessory, :gearlist, :autohiss_mode,
|
||||
:h_grad_style, :h_grad_offset, :h_grad_colour, :h_grad_alpha)
|
||||
:h_grad_style, :h_grad_offset, :h_grad_colour, :h_grad_alpha, :custom_emotes)
|
||||
"}, list(
|
||||
// This has too many params for anyone to look at this without going insae
|
||||
"ckey" = C.ckey,
|
||||
@@ -364,7 +368,8 @@
|
||||
"h_grad_style" = h_grad_style,
|
||||
"h_grad_offset" = "[h_grad_offset_x],[h_grad_offset_y]",
|
||||
"h_grad_colour" = h_grad_colour,
|
||||
"h_grad_alpha" = h_grad_alpha
|
||||
"h_grad_alpha" = h_grad_alpha,
|
||||
"custom_emotes" = json_encode(custom_emotes),
|
||||
))
|
||||
|
||||
if(!query.warn_execute())
|
||||
@@ -449,6 +454,7 @@
|
||||
h_grad_offset_x = query.item[52] // parsed down below
|
||||
h_grad_colour = query.item[53]
|
||||
h_grad_alpha = query.item[54]
|
||||
var/custom_emotes_tmp = query.item[55]
|
||||
|
||||
//Sanitize
|
||||
var/datum/species/SP = GLOB.all_species[species]
|
||||
@@ -520,7 +526,9 @@
|
||||
h_grad_offset_y = text2num(expl[2]) || 0
|
||||
h_grad_colour = sanitize_hexcolor(h_grad_colour)
|
||||
h_grad_alpha = sanitize_integer(h_grad_alpha, 0, 255, initial(h_grad_alpha))
|
||||
loadout_gear = sanitize_json(loadout_gear)
|
||||
loadout_gear = sanitize_json(loadout_gear)
|
||||
custom_emotes_tmp = sanitize_json(custom_emotes_tmp)
|
||||
custom_emotes = init_custom_emotes(custom_emotes_tmp)
|
||||
|
||||
if(!player_alt_titles)
|
||||
player_alt_titles = new()
|
||||
@@ -2086,3 +2094,15 @@
|
||||
|
||||
from_db = FALSE
|
||||
return TRUE
|
||||
|
||||
/datum/character_save/proc/init_custom_emotes(overrides)
|
||||
custom_emotes = overrides
|
||||
|
||||
for(var/datum/keybinding/custom/custom_emote in GLOB.keybindings)
|
||||
var/emote_text = overrides && overrides[custom_emote.name]
|
||||
if(!emote_text)
|
||||
continue //we don't set anything without an override
|
||||
|
||||
custom_emotes[custom_emote.name] = emote_text
|
||||
|
||||
return custom_emotes
|
||||
|
||||
@@ -1186,6 +1186,21 @@
|
||||
var/datum/keybinding/KB = kb
|
||||
keybindings_overrides[KB.name] = list()
|
||||
|
||||
else if(href_list["custom_emote_set"])
|
||||
var/datum/keybinding/custom/custom_emote_keybind = locateUID(href_list["custom_emote_set"])
|
||||
if(custom_emote_keybind)
|
||||
var/emote_text = active_character.custom_emotes[custom_emote_keybind.name]
|
||||
var/desired_emote = stripped_input(user, "Enter your custom emote text, 128 character limit.", "Custom Emote Setter", emote_text, max_length = 128)
|
||||
if(desired_emote && (desired_emote != custom_emote_keybind.default_emote_text)) //don't let them save the default custom emote text
|
||||
active_character.custom_emotes[custom_emote_keybind.name] = desired_emote
|
||||
active_character.save(user)
|
||||
|
||||
else if(href_list["custom_emote_reset"])
|
||||
var/datum/keybinding/custom/custom_emote_keybind = locateUID(href_list["custom_emote_reset"])
|
||||
if(custom_emote_keybind)
|
||||
active_character.custom_emotes.Remove(custom_emote_keybind.name)
|
||||
active_character.save(user)
|
||||
|
||||
init_keybindings(keybindings_overrides)
|
||||
save_preferences(user) //Ideally we want to save people's keybinds when they enter them
|
||||
|
||||
|
||||
@@ -518,6 +518,24 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
|
||||
dat += "<td style='width: 25%'>[KB.name]</td>"
|
||||
dat += "<td style='width: 45%'>[keys_buttons][(length(keys) < 5) ? "<a href='?_src_=prefs;preference=keybindings;set=[KB.UID()];'><span class='good'>+</span></a></td>" : "</td>"]"
|
||||
dat += "<td style='width: 20%'><a href='?_src_=prefs;preference=keybindings;reset=[KB.UID()]'>Reset to Default</a> <a href='?_src_=prefs;preference=keybindings;clear=[KB.UID()]'>Clear</a></td>"
|
||||
if(KB.category == KB_CATEGORY_EMOTE_CUSTOM)
|
||||
var/datum/keybinding/custom/custom_emote_keybind = kb
|
||||
if(custom_emote_keybind.donor_exclusive && !(user.client.donator_level || user.client.holder || unlock_content))
|
||||
dat += "</tr>"
|
||||
dat += "<tr>"
|
||||
dat += "<td><b>The use of this emote is restricted to patrons and byond members.</b></td>"
|
||||
dat += "</tr>"
|
||||
continue
|
||||
dat += "</tr>"
|
||||
dat += "<tr>"
|
||||
var/emote_text = active_character.custom_emotes[custom_emote_keybind.name] //check if this emote keybind has an associated value on the character save
|
||||
if(!emote_text)
|
||||
dat += "<td style='width: 25%'>[custom_emote_keybind.default_emote_text]</td>"
|
||||
else
|
||||
dat += "<td style='width: 25%'><i>\"[active_character.real_name] [emote_text]\"</i></td>"
|
||||
dat += "<td style='width: 45%'><a href='?_src_=prefs;preference=keybindings;custom_emote_set=[custom_emote_keybind.UID()];'>Change Text</a></td>"
|
||||
dat += "<td style='width: 20%'><a href='?_src_=prefs;preference=keybindings;custom_emote_reset=[custom_emote_keybind.UID()];'>Reset to Default</a></td>"
|
||||
dat += "<tr><td colspan=4><br></td></tr>"
|
||||
dat += "</tr>"
|
||||
dat += "<tr><td colspan=4><br></td></tr>"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user