Skip to content

Commit

Permalink
add: clown mimic voice menu[bounty] (#5512)
Browse files Browse the repository at this point in the history
* almost

* final

* ue

* bundle

* bundle

* forgotten

* zwei talking

* Update code/game/jobs/job/support.dm

Co-authored-by: Zwei <[email protected]>

---------

Co-authored-by: Zwei <[email protected]>
Co-authored-by: Aziz Chynaliev <[email protected]>
  • Loading branch information
3 people authored Jul 29, 2024
1 parent 9e4427f commit a5521e4
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 3 deletions.
1 change: 1 addition & 0 deletions code/datums/outfits/outfit_security_clown.dm
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
I.access.Add(ACCESS_CLOWN, ACCESS_MIME, ACCESS_THEATRE)
I.assignment = name
H.sec_hud_set_ID()
H.grant_mimicking()


//=========== security clown equipment ===========
Expand Down
2 changes: 1 addition & 1 deletion code/datums/spells/cluwne.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
equip_to_slot_or_del(new /obj/item/clothing/gloves/cursedclown, ITEM_SLOT_GLOVES)
equip_to_slot_or_del(new /obj/item/clothing/mask/cursedclown, ITEM_SLOT_MASK)
equip_to_slot_or_del(new /obj/item/clothing/shoes/cursedclown, ITEM_SLOT_FEET)

grant_mimicking()

/mob/living/carbon/human/proc/makeAntiCluwne()
to_chat(src, "<span class='danger'>You don't feel very funny.</span>")
Expand Down
128 changes: 128 additions & 0 deletions code/game/jobs/job/support.dm
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,134 @@
H.force_gene_block(GLOB.clumsyblock, TRUE, TRUE)
H.force_gene_block(GLOB.comicblock, TRUE, TRUE)
H.add_language(LANGUAGE_CLOWN)
H.grant_mimicking()

/mob/living/carbon/human/proc/grant_mimicking()
if(!(locate(/datum/action/innate/mimicking) in actions))
var/datum/action/innate/mimicking/mimicking = new
mimicking.Grant(src)
verbs |= /mob/living/carbon/human/proc/mimicking

/datum/action/innate/mimicking
name = "Mimicking"
button_icon_state = "clown"
check_flags = AB_CHECK_CONSCIOUS
var/list/voice_slots = list()
var/empty_slots = 3
var/list/available_voices
var/datum/mimicking_voice/selected

/datum/action/innate/mimicking/New()
..()
var/donor_level = owner?.client ? owner.client.donator_level : 0
available_voices = list()
for(var/level in 0 to donor_level)
available_voices += SStts.tts_seeds_names_by_donator_levels["[level]"]

/datum/action/innate/mimicking/Trigger(left_click)
if(!..())
return FALSE
ui_interact(owner)

/datum/action/innate/mimicking/ui_state(mob/user)
return GLOB.conscious_state

/datum/action/innate/mimicking/ui_interact(mob/user, datum/tgui/ui = null)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Mimicking", "Mimicking")
ui.set_autoupdate(FALSE)
ui.open()

/datum/action/innate/mimicking/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(..())
return
var/datum/mimicking_voice/voice
if(params["id"])
for(var/datum/mimicking_voice/find_voice in voice_slots)
if(find_voice.UID() != params["id"])
continue
voice = find_voice
switch(action)
if("Choose")
if(!voice)
stack_trace("Mimicking can not find it own voice.")
return
if(voice.selected)
return
set_selected(voice)
owner.update_tts_seed(voice.voice)
if("Delete")
if(!voice)
stack_trace("Mimicking can not find it own voice.")
return
if(voice.selected)
selected = null
voice_slots -= voice
empty_slots++
if("Add")
if(empty_slots < 1)
to_chat(owner, span_notice("You have no available slots."))
return
var/voice_name = input(owner, "Choose a name for slot.", "Mimicking") as text|null
if(!voice_name)
return
var/voice_seed = tgui_input_list(owner, "Choose a voice for slot", "Mimicking", available_voices, owner.tts_seed)
if(!voice_seed)
return
var/new_voice = new /datum/mimicking_voice(voice_name, voice_seed)
add_voice(new_voice)
SStgui.update_uis(src)

/datum/action/innate/mimicking/ui_data(mob/user)
var/list/data = list()
var/list/slots = list()
for(var/datum/mimicking_voice/voice in voice_slots)
if(istype(voice))
slots += list(voice.voice_data())
data["slots"] = slots
return data

/datum/action/innate/mimicking/proc/set_selected(datum/mimicking_voice/new_voice)
if(selected)
selected.selected = FALSE
selected = new_voice
selected.selected = TRUE

/datum/action/innate/mimicking/proc/add_voice(datum/mimicking_voice/voice)
voice_slots += voice
empty_slots--

/datum/action/innate/mimicking/proc/remove_voice(datum/mimicking_voice/voice)
voice_slots -= voice
empty_slots++

/datum/mimicking_voice
var/name
var/voice
var/selected = FALSE

/datum/mimicking_voice/New(name, voice)
src.name = name
src.voice = voice

/datum/mimicking_voice/proc/voice_data()
return list("name" = name, "voice" = voice, "selected" = selected, "id" = UID())

/mob/living/carbon/human/proc/mimicking(var/mob/living/carbon/human/H)
set name = "Mimic voice"
set category = "IC"
if(!H)
to_chat(usr, span_notice("Use right click to choose target correctly."))
var/datum/action/innate/mimicking/mimic = locate(/datum/action/innate/mimicking) in usr.actions
if(!mimic)
return
if(mimic.empty_slots < 1)
to_chat(usr, span_notice("You have no available slots."))
return
var/new_voice = new /datum/mimicking_voice(H.name, H.tts_seed)
mimic.add_voice(new_voice)
SStgui.update_uis(mimic)

//action given to antag clowns
/datum/action/innate/toggle_clumsy
Expand Down
1 change: 1 addition & 0 deletions code/modules/admin/verbs/honksquad.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ GLOBAL_VAR_INIT(sent_clownsequritysquad, 0)
else
equip_to_slot_or_del(new /obj/item/gun/throw/piecannon(src), ITEM_SLOT_BACKPACK)
src.mutations.Add(CLUMSY)
grant_mimicking()
var/obj/item/implant/sad_trombone/S = new/obj/item/implant/sad_trombone(src)
S.implant(src)

Expand Down
46 changes: 46 additions & 0 deletions tgui/packages/tgui/interfaces/Mimicking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { useBackend } from '../backend';
import { Box, Button, Section, Stack } from '../components';
import { Window } from '../layouts';

export const Mimicking = (props, context) => {
const { act, data } = useBackend(context);
const slots = data.slots || [];

return (
<Window width={400} height={300}>
<Window.Content scrollable>
<Stack vertical fill>
<Section fill scrollable>
{slots.map((voice) => (
<Section
mb={0.5}
title={voice.name}
key={voice.id}
level={2}
buttons={
<>
<Button
content="Choose"
selected={voice.selected}
onClick={() => act('Choose', { 'id': voice.id })}
/>
<Button
content="Delete"
color="bad"
onClick={() => act('Delete', { 'id': voice.id })}
/>
</>
}
>
<Box preserveWhitespace textColor="#878787" fontSize="14px">
Voice: {voice.voice}
</Box>
</Section>
))}
<Button fluid content="Add" onClick={() => act('Add')} />
</Section>
</Stack>
</Window.Content>
</Window>
);
};
4 changes: 2 additions & 2 deletions tgui/public/tgui.bundle.js

Large diffs are not rendered by default.

0 comments on commit a5521e4

Please sign in to comment.