diff --git a/code/modules/client/preferences/types/ui.dm b/code/modules/client/preferences/types/ui.dm index 006c15527b..d9fedf0e30 100644 --- a/code/modules/client/preferences/types/ui.dm +++ b/code/modules/client/preferences/types/ui.dm @@ -35,3 +35,27 @@ /datum/preference/toggle/tgui_say_light/apply_to_client(client/client, value) client.tgui_say?.load() + +/datum/preference/toggle/tgui_say_emotes + category = PREFERENCE_CATEGORY_GAME_PREFERENCES + savefile_key = "tgui_say_emotes" + default_value = TRUE + savefile_identifier = PREFERENCE_PLAYER + +/datum/preference/toggle/tgui_say_emotes/apply_to_client(client/client, value) + client.tgui_say?.load() + +/datum/preference/numeric/tgui_say_height + category = PREFERENCE_CATEGORY_GAME_PREFERENCES + savefile_key = "tgui_say_height" + savefile_identifier = PREFERENCE_PLAYER + + minimum = 1 + maximum = 5 + step = 1 + +/datum/preference/numeric/tgui_say_height/create_default_value() + return 1 + +/datum/preference/numeric/tgui_say_height/apply_to_client(client/client, value) + client.tgui_say?.load() diff --git a/code/modules/mob/typing_indicator.dm b/code/modules/mob/typing_indicator.dm index 93310c5beb..327cb5378c 100644 --- a/code/modules/mob/typing_indicator.dm +++ b/code/modules/mob/typing_indicator.dm @@ -31,7 +31,7 @@ set name = "Me verb" set category = "IC.TGUI Say" //CHOMPEdit - if(client?.prefs?.read_preference(/datum/preference/toggle/tgui_say)) + if(client?.prefs?.read_preference(/datum/preference/toggle/tgui_say) && client?.prefs?.read_preference(/datum/preference/toggle/tgui_say_emotes)) winset(src, null, "command=[client.tgui_say_create_open_command(ME_CHANNEL)]") return @@ -65,7 +65,7 @@ set category = "IC.TGUI Say" //CHOMPEdit set desc = "Emote to nearby people (and your pred/prey)" - if(client?.prefs?.read_preference(/datum/preference/toggle/tgui_say)) + if(client?.prefs?.read_preference(/datum/preference/toggle/tgui_say) && client?.prefs?.read_preference(/datum/preference/toggle/tgui_say_emotes)) winset(src, null, "command=[client.tgui_say_create_open_command(SUBTLE_CHANNEL)]") return diff --git a/code/modules/tgui_input/say_modal/modal.dm b/code/modules/tgui_input/say_modal/modal.dm index 84e9906499..40dba424c0 100644 --- a/code/modules/tgui_input/say_modal/modal.dm +++ b/code/modules/tgui_input/say_modal/modal.dm @@ -64,10 +64,12 @@ /datum/tgui_say/proc/load() window_open = FALSE - winset(client, "tgui_say", "pos=410,400;size=360,30;is-visible=0;") + var/minimumHeight = client?.prefs?.read_preference(/datum/preference/numeric/tgui_say_height) || 1 + winset(client, "tgui_say", "pos=410,400;size=360,[(minimumHeight * 20) + 10];is-visible=0;") window.send_message("props", list( lightMode = client?.prefs?.read_preference(/datum/preference/toggle/tgui_say_light), + minimumHeight = minimumHeight, maxLength = max_length, )) diff --git a/tgui/packages/tgui-say/TguiSay.tsx b/tgui/packages/tgui-say/TguiSay.tsx index 4c05a7fafa..cb11f78e89 100644 --- a/tgui/packages/tgui-say/TguiSay.tsx +++ b/tgui/packages/tgui-say/TguiSay.tsx @@ -1,4 +1,5 @@ import { KEY } from 'common/keys'; +import { clamp } from 'common/math'; import { BooleanLike } from 'common/react'; import { Component, createRef, RefObject } from 'react'; import { dragStartHandler } from 'tgui/drag'; @@ -19,12 +20,13 @@ type ByondOpen = { type ByondProps = { maxLength: number; + minimumHeight: number; lightMode: BooleanLike; }; type State = { buttonContent: string | number; - size: WINDOW_SIZES; + size: number; }; const CHANNEL_REGEX = /^:\w\s|^,b\s/; @@ -35,6 +37,7 @@ export class TguiSay extends Component<{}, State> { private currentPrefix: keyof typeof RADIO_PREFIXES | null; private innerRef: RefObject; private lightMode: boolean; + private minimumHeight: number; private maxLength: number; private messages: typeof byondMessages; state: State; @@ -47,6 +50,7 @@ export class TguiSay extends Component<{}, State> { this.currentPrefix = null; this.innerRef = createRef(); this.lightMode = false; + this.minimumHeight = 1; this.maxLength = 1024; this.messages = byondMessages; this.state = { @@ -299,8 +303,10 @@ export class TguiSay extends Component<{}, State> { }; handleProps = (data: ByondProps) => { - const { maxLength, lightMode } = data; + const { maxLength, minimumHeight, lightMode } = data; this.maxLength = maxLength; + this.minimumHeight = minimumHeight; + this.setSize(); this.lightMode = !!lightMode; }; @@ -313,7 +319,7 @@ export class TguiSay extends Component<{}, State> { } setSize(length = 0) { - let newSize: WINDOW_SIZES; + let newSize: number; const currentValue = this.innerRef.current?.value; @@ -327,6 +333,9 @@ export class TguiSay extends Component<{}, State> { newSize = WINDOW_SIZES.small; } + newSize = clamp(newSize, this.minimumHeight * 20 + 10, WINDOW_SIZES.max); + console.log(newSize); + if (this.state.size !== newSize) { this.setState({ size: newSize }); windowSet(newSize); diff --git a/tgui/packages/tgui-say/constants.ts b/tgui/packages/tgui-say/constants.ts index 586a3e2317..dbf8913b79 100644 --- a/tgui/packages/tgui-say/constants.ts +++ b/tgui/packages/tgui-say/constants.ts @@ -3,6 +3,7 @@ export enum WINDOW_SIZES { small = 30, medium = 50, large = 70, + max = 130, width = 360, } diff --git a/tgui/packages/tgui-say/helpers.ts b/tgui/packages/tgui-say/helpers.ts index 100e3c0366..3d95055375 100644 --- a/tgui/packages/tgui-say/helpers.ts +++ b/tgui/packages/tgui-say/helpers.ts @@ -25,8 +25,9 @@ export const windowClose = () => { /** * Modifies the window size. */ -export const windowSet = (size = WINDOW_SIZES.small) => { +export const windowSet = (size: number = WINDOW_SIZES.small) => { let sizeStr = `${WINDOW_SIZES.width}x${size}`; + console.log(sizeStr); Byond.winset('tgui_say.browser', { size: sizeStr, @@ -41,6 +42,5 @@ export const windowSet = (size = WINDOW_SIZES.small) => { const setWindowVisibility = (visible: boolean) => { Byond.winset('tgui_say', { 'is-visible': visible, - size: `${WINDOW_SIZES.width}x${WINDOW_SIZES.small}`, }); }; diff --git a/tgui/packages/tgui-say/styles/window.scss b/tgui/packages/tgui-say/styles/window.scss index aba534113e..acbe1b34d2 100644 --- a/tgui/packages/tgui-say/styles/window.scss +++ b/tgui/packages/tgui-say/styles/window.scss @@ -27,3 +27,15 @@ .window-70 { height: 70px; } + +.window-90 { + height: 90px; +} + +.window-110 { + height: 110px; +} + +.window-130 { + height: 130px; +} diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/ui.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/ui.tsx index 7292b65de7..45a0f8bb68 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/ui.tsx +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/ui.tsx @@ -1,4 +1,9 @@ -import { CheckboxInput, FeatureToggle } from '../base'; +import { + CheckboxInput, + FeatureNumeric, + FeatureSliderInput, + FeatureToggle, +} from '../base'; export const BROWSER_STYLED: FeatureToggle = { name: 'Use Fake NanoUI Browser Style', @@ -27,3 +32,17 @@ export const TGUI_SAY_LIGHT_MODE: FeatureToggle = { description: 'Sets TGUI Say to use a light mode.', component: CheckboxInput, }; + +export const tgui_say_emotes: FeatureToggle = { + name: 'Say: Use TGUI For Emotes', + category: 'UI', + description: 'Sets whether to use TGUI Say for emotes.', + component: CheckboxInput, +}; + +export const tgui_say_height: FeatureNumeric = { + name: 'Say: TGUI Height (Lines)', + category: 'UI', + description: 'Amount of lines to show in the tgui say input.', + component: FeatureSliderInput, +};