[MIRROR] fix tguiSay style (#10192)

Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-02-16 17:08:29 -07:00
committed by GitHub
parent fa70686c20
commit 4944978a4f
3 changed files with 97 additions and 11 deletions

View File

@@ -9,7 +9,13 @@ import { type BooleanLike, classes } from 'tgui-core/react';
import { Channel, ChannelIterator } from './ChannelIterator';
import { ChatHistory } from './ChatHistory';
import { LineLength, RADIO_PREFIXES, WindowSize } from './constants';
import { getPrefix, windowClose, windowOpen, windowSet } from './helpers';
import {
getMarkupString,
getPrefix,
windowClose,
windowOpen,
windowSet,
} from './helpers';
import { byondMessages } from './timers';
type ByondOpen = {
@@ -49,6 +55,7 @@ export function TguiSay() {
const [minimumHeight, setMinimumHeight] = useState(WindowSize.Small);
const [minimumWidth, setMinimumWidth] = useState(WindowSize.Width);
const [lightMode, setLightMode] = useState(false);
const [position, setPosition] = useState([window.screenX, window.screenY]);
const [value, setValue] = useState('');
function handleArrowKeys(direction: KEY.PageUp | KEY.PageDown): void {
@@ -135,6 +142,9 @@ export function TguiSay() {
}
function handleIncrementChannel(): void {
const xPos = window.screenX;
const yPos = window.screenY;
if (JSON.stringify(position) !== JSON.stringify([xPos, yPos])) return;
const iterator = channelIterator.current;
iterator.next();
@@ -168,6 +178,7 @@ export function TguiSay() {
setButtonContent(RADIO_PREFIXES[newPrefix]);
setCurrentPrefix(newPrefix);
newValue = newValue.slice(3);
iterator.set('Say');
if (newPrefix === ',b ') {
Byond.sendMessage('thinking', { visible: false });
@@ -182,15 +193,6 @@ export function TguiSay() {
setValue(newValue);
}
function getMarkupString(
inputText: string,
markupType: string,
startPosition: number,
endPosition: number,
) {
return `${inputText.substring(0, startPosition)}${markupType}${inputText.substring(startPosition, endPosition)}${markupType}${inputText.substring(endPosition)}`;
}
function handleKeyDown(event: KeyboardEvent<HTMLTextAreaElement>): void {
if (event.getModifierState('AltGraph')) return;
@@ -268,6 +270,13 @@ export function TguiSay() {
}
}
function handleButtonDrag(e: React.MouseEvent<Element, MouseEvent>): void {
const xPos = window.screenX;
const yPos = window.screenY;
setPosition([xPos, yPos]);
dragStartHandler(e);
}
function handleOpen(data: ByondOpen): void {
setTimeout(() => {
innerRef.current?.focus();
@@ -348,7 +357,7 @@ export function TguiSay() {
<button
className={`button button-${theme}`}
onClick={handleIncrementChannel}
onMouseDown={dragStartHandler}
onMouseDown={handleButtonDrag}
type="button"
>
{buttonContent}

View File

@@ -69,3 +69,12 @@ export function getPrefix(
return adjusted;
}
export function getMarkupString(
inputText: string,
markupType: string,
startPosition: number,
endPosition: number,
) {
return `${inputText.substring(0, startPosition)}${markupType}${inputText.substring(startPosition, endPosition)}${markupType}${inputText.substring(endPosition)}`;
}

View File

@@ -46,6 +46,74 @@
height: 70px;
}
.window-90 {
height: 90px;
}
.window-110 {
height: 110px;
}
.window-130 {
height: 130px;
}
.window-150 {
height: 150px;
}
.window-170 {
height: 170px;
}
.window-190 {
height: 190px;
}
.window-210 {
height: 210px;
}
.window-230 {
height: 230px;
}
.window-250 {
height: 250px;
}
.window-270 {
height: 270px;
}
.window-290 {
height: 290px;
}
.window-310 {
height: 310px;
}
.window-330 {
height: 330px;
}
.window-350 {
height: 350px;
}
.window-370 {
height: 370px;
}
.window-390 {
height: 390px;
}
.window-410 {
height: 410px;
}
.content {
background-color: black;
display: grid;