mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-10 18:02:57 +00:00
announcement side
This commit is contained in:
@@ -84,7 +84,7 @@
|
|||||||
if(..())
|
if(..())
|
||||||
return
|
return
|
||||||
var/mob/living/silicon/ai/AI = usr
|
var/mob/living/silicon/ai/AI = usr
|
||||||
AI.announcement()
|
AI.ai_announcement()
|
||||||
|
|
||||||
/atom/movable/screen/ai/call_shuttle
|
/atom/movable/screen/ai/call_shuttle
|
||||||
name = "Call Emergency Shuttle"
|
name = "Call Emergency Shuttle"
|
||||||
|
|||||||
@@ -104,6 +104,8 @@
|
|||||||
// TODO: Currently unused, needs port from TG.
|
// TODO: Currently unused, needs port from TG.
|
||||||
/// Station alert datum for showing alerts UI
|
/// Station alert datum for showing alerts UI
|
||||||
var/datum/station_alert/alert_control
|
var/datum/station_alert/alert_control
|
||||||
|
/// Announcement UI
|
||||||
|
var/datum/ai_announcement/ai_announcement
|
||||||
/// Lists possible spoken words for announcements
|
/// Lists possible spoken words for announcements
|
||||||
var/datum/announcement_help/announcement_help
|
var/datum/announcement_help/announcement_help
|
||||||
///remember AI's last location
|
///remember AI's last location
|
||||||
@@ -206,6 +208,7 @@
|
|||||||
QDEL_NULL(doomsday_device)
|
QDEL_NULL(doomsday_device)
|
||||||
QDEL_NULL(robot_control)
|
QDEL_NULL(robot_control)
|
||||||
// QDEL_NULL(alert_control)
|
// QDEL_NULL(alert_control)
|
||||||
|
QDEL_NULL(ai_announcement)
|
||||||
QDEL_NULL(announcement_help)
|
QDEL_NULL(announcement_help)
|
||||||
QDEL_NULL(aiMulti)
|
QDEL_NULL(aiMulti)
|
||||||
QDEL_NULL(aiPDA)
|
QDEL_NULL(aiPDA)
|
||||||
|
|||||||
55
code/modules/mob/living/silicon/ai/ai_announcement.dm
Normal file
55
code/modules/mob/living/silicon/ai/ai_announcement.dm
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#ifdef AI_VOX
|
||||||
|
/mob/living/silicon/ai/verb/ai_announcement()
|
||||||
|
set name = "Vox Announcement"
|
||||||
|
set desc = "Make an audible announcement!"
|
||||||
|
set category = "AI Commands"
|
||||||
|
|
||||||
|
if(incapacitated())
|
||||||
|
return
|
||||||
|
|
||||||
|
if(!ai_announcement)
|
||||||
|
ai_announcement = new(src)
|
||||||
|
|
||||||
|
ai_announcement.ui_interact(src)
|
||||||
|
|
||||||
|
/datum/ai_announcement
|
||||||
|
var/mob/living/silicon/ai/owner
|
||||||
|
|
||||||
|
/datum/ai_announcement/New(mob/living/silicon/ai/new_owner)
|
||||||
|
if(!istype(new_owner))
|
||||||
|
qdel(src)
|
||||||
|
owner = new_owner
|
||||||
|
|
||||||
|
/datum/ai_announcement/ui_status(mob/living/silicon/ai/user)
|
||||||
|
if(owner == user && !owner.incapacitated())
|
||||||
|
return ..()
|
||||||
|
return UI_CLOSE
|
||||||
|
|
||||||
|
/datum/ai_announcement/ui_state(mob/user)
|
||||||
|
return GLOB.always_state
|
||||||
|
|
||||||
|
/datum/ai_announcement/ui_interact(mob/user, datum/tgui/ui)
|
||||||
|
ui = SStgui.try_update_ui(user, src, ui)
|
||||||
|
if(!ui)
|
||||||
|
ui = new(user, src, "AIAnnouncement")
|
||||||
|
ui.open()
|
||||||
|
|
||||||
|
/datum/ai_announcement/ui_static_data(mob/user)
|
||||||
|
var/list/data = ..()
|
||||||
|
data["last_announcement"] = owner.last_announcement
|
||||||
|
data["vox_types"] = GLOB.vox_types
|
||||||
|
return data
|
||||||
|
|
||||||
|
/datum/ai_announcement/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||||
|
. = ..()
|
||||||
|
switch(action)
|
||||||
|
if("announce")
|
||||||
|
var/vox_type = params["vox_type"]
|
||||||
|
if(!vox_type)
|
||||||
|
return
|
||||||
|
var/to_speak = params["to_speak"]
|
||||||
|
if(!to_speak)
|
||||||
|
return
|
||||||
|
owner.announcement(vox_type, to_speak)
|
||||||
|
ui.close()
|
||||||
|
#endif
|
||||||
@@ -79,27 +79,23 @@
|
|||||||
|
|
||||||
// Make sure that the code compiles with AI_VOX undefined
|
// Make sure that the code compiles with AI_VOX undefined
|
||||||
#ifdef AI_VOX
|
#ifdef AI_VOX
|
||||||
#define VOX_DELAY 600
|
#define VOX_DELAY 1 MINUTES
|
||||||
/mob/living/silicon/ai/proc/announcement()
|
/mob/living/silicon/ai/proc/announcement(voxType = "Female", message)
|
||||||
var/static/announcing_vox = 0 // Stores the time of the last announcement
|
var/static/announcing_vox = 0 // Stores the time of the last announcement
|
||||||
if(announcing_vox > world.time)
|
if(announcing_vox > world.time)
|
||||||
to_chat(src, "<span class='notice'>Please wait [DisplayTimeText(announcing_vox - world.time)].</span>")
|
to_chat(src, span_notice("Please wait [DisplayTimeText(announcing_vox - world.time)]."))
|
||||||
return
|
return
|
||||||
|
|
||||||
var/message = input(src, "WARNING: Misuse of this verb can result in you being job banned. More help is available in 'Announcement Help'", "Announcement", src.last_announcement) as text
|
|
||||||
|
|
||||||
last_announcement = message
|
last_announcement = message
|
||||||
|
|
||||||
var/voxType = input(src, "Male or female VOX?", "VOX-gender") in GLOB.vox_types
|
if(!message || !GLOB.vox_types[voxType])
|
||||||
|
|
||||||
if(!message || announcing_vox > world.time)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if(incapacitated())
|
if(incapacitated())
|
||||||
return
|
return
|
||||||
|
|
||||||
if(control_disabled)
|
if(control_disabled)
|
||||||
to_chat(src, "<span class='warning'>Wireless interface disabled, unable to interact with announcement PA.</span>")
|
to_chat(src, span_warning("Wireless interface disabled, unable to interact with announcement PA."))
|
||||||
return
|
return
|
||||||
|
|
||||||
var/list/words = splittext(trim(message), " ")
|
var/list/words = splittext(trim(message), " ")
|
||||||
@@ -117,7 +113,7 @@
|
|||||||
incorrect_words += word
|
incorrect_words += word
|
||||||
|
|
||||||
if(incorrect_words.len)
|
if(incorrect_words.len)
|
||||||
to_chat(src, "<span class='notice'>These words are not available on the announcement system: [english_list(incorrect_words)].</span>")
|
to_chat(src, span_notice("These words are not available on the announcement system: [english_list(incorrect_words)]."))
|
||||||
return
|
return
|
||||||
|
|
||||||
announcing_vox = world.time + VOX_DELAY
|
announcing_vox = world.time + VOX_DELAY
|
||||||
|
|||||||
@@ -2830,6 +2830,7 @@
|
|||||||
#include "code\modules\mob\living\silicon\silicon_defense.dm"
|
#include "code\modules\mob\living\silicon\silicon_defense.dm"
|
||||||
#include "code\modules\mob\living\silicon\silicon_movement.dm"
|
#include "code\modules\mob\living\silicon\silicon_movement.dm"
|
||||||
#include "code\modules\mob\living\silicon\ai\ai.dm"
|
#include "code\modules\mob\living\silicon\ai\ai.dm"
|
||||||
|
#include "code\modules\mob\living\silicon\ai\ai_announcement.dm"
|
||||||
#include "code\modules\mob\living\silicon\ai\ai_defense.dm"
|
#include "code\modules\mob\living\silicon\ai\ai_defense.dm"
|
||||||
#include "code\modules\mob\living\silicon\ai\ai_portrait_picker.dm"
|
#include "code\modules\mob\living\silicon\ai\ai_portrait_picker.dm"
|
||||||
#include "code\modules\mob\living\silicon\ai\announcement_help.dm"
|
#include "code\modules\mob\living\silicon\ai\announcement_help.dm"
|
||||||
|
|||||||
88
tgui/packages/tgui/interfaces/AIAnnouncement.js
Normal file
88
tgui/packages/tgui/interfaces/AIAnnouncement.js
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
import { filter } from 'common/collections';
|
||||||
|
import { useBackend } from '../backend';
|
||||||
|
import { Button, Icon, Input, Section, Stack, Tabs } from '../components';
|
||||||
|
import { useLocalState } from '../backend';
|
||||||
|
import { Window } from '../layouts';
|
||||||
|
|
||||||
|
export const AIAnnouncement = (props, context) => {
|
||||||
|
const { act, data } = useBackend(context);
|
||||||
|
const {
|
||||||
|
last_announcement,
|
||||||
|
vox_types = {},
|
||||||
|
} = data;
|
||||||
|
|
||||||
|
const [
|
||||||
|
current_page,
|
||||||
|
set_page,
|
||||||
|
] = useLocalState(context, 'current_page', 0);
|
||||||
|
|
||||||
|
const [
|
||||||
|
announcement_input,
|
||||||
|
set_announcement_input,
|
||||||
|
] = useLocalState(context, 'announcement_input', last_announcement);
|
||||||
|
|
||||||
|
// I love `Object`s!!
|
||||||
|
const words_filtered = Object.keys(vox_types[Object.keys(vox_types)[current_page]]);
|
||||||
|
|
||||||
|
const search_split = announcement_input.split(" ").filter(element => element);
|
||||||
|
|
||||||
|
const missing_words = search_split.map(element => words_filtered.includes(element) ? null : element).filter(element => element);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Window
|
||||||
|
width={630}
|
||||||
|
height={175}
|
||||||
|
resizable
|
||||||
|
title="Vox Announcement">
|
||||||
|
<Window.Content>
|
||||||
|
<Section fill overflow="auto">
|
||||||
|
<Stack vertical>
|
||||||
|
<Stack.Item>
|
||||||
|
<font color="red">WARNING:</font> Misuse of this verb can result in you being job banned. More help is available in 'Announcement Help'
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item>
|
||||||
|
<Tabs fluid textAlign="center">
|
||||||
|
{
|
||||||
|
Object.keys(vox_types).map((vox_type, index) => (
|
||||||
|
<Tabs.Tab
|
||||||
|
key={index}
|
||||||
|
onClick={() => set_page(index)}
|
||||||
|
selected={current_page === index}>
|
||||||
|
{vox_type}
|
||||||
|
</Tabs.Tab>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</Tabs>
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item>
|
||||||
|
<Stack>
|
||||||
|
<Stack.Item grow>
|
||||||
|
<Input
|
||||||
|
fluid
|
||||||
|
value={last_announcement}
|
||||||
|
placeholder="Announce something..."
|
||||||
|
onInput={(e, value) => set_announcement_input(value)}
|
||||||
|
onEnter={(e, value) => act("announce", {
|
||||||
|
"vox_type": Object.keys(vox_types)[current_page],
|
||||||
|
"to_speak": value,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item>
|
||||||
|
<Button icon="volume-high" mt={-0.2} onClick={() => act("announce", {
|
||||||
|
"vox_type": Object.keys(vox_types)[current_page],
|
||||||
|
"to_speak": announcement_input,
|
||||||
|
})} />
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
</Stack.Item>
|
||||||
|
<Stack.Item>
|
||||||
|
{missing_words.length
|
||||||
|
? <div>These words are not available on the announcement system: <font color="red">{missing_words.join(" ")}</font></div> : null}
|
||||||
|
</Stack.Item>
|
||||||
|
</Stack>
|
||||||
|
</Section>
|
||||||
|
</Window.Content>
|
||||||
|
</Window>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user