[MIRROR] fix runechat offset (#10626)

Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-04-11 18:55:11 -07:00
committed by GitHub
parent dcc7ad1b21
commit f8b047a3a3
19 changed files with 340 additions and 247 deletions

View File

@@ -0,0 +1,2 @@
/// Window is fully visible and we can make fragile calls
#define COMSIG_TGUI_WINDOW_VISIBLE "tgui_window_visible"

View File

@@ -732,3 +732,6 @@
/datum/config_entry/string/chatlog_database_api_endpoint
/datum/config_entry/flag/forbid_admin_profiling
/datum/config_entry/flag/pixel_size_limit
default = FALSE

View File

@@ -452,24 +452,16 @@ var/list/runechat_image_cache = list()
return (width - bound_width) * -0.5 + get_oversized_icon_offsets()["x"]
/atom/movable/runechat_y_offset()
return ..() + get_oversized_icon_offsets()["y"]
return ..() + get_oversized_icon_offsets()["y"] * 1.5 // Fix to use 2 if we ever can measure sprites
/* Nothing special
/mob/runechat_x_offset(width, height)
return (width - bound_width) * -0.5
*/
/mob/runechat_y_offset(var/consider_height)
if(consider_height)
return ..()
/mob/runechat_y_offset()
return ..()*size_multiplier
/mob/living/runechat_y_offset(var/consider_height)
var/size_diff = vis_height - world.icon_size
if(size_diff > 0)
return (..(TRUE) + size_diff) * size_multiplier
return ..(FALSE)
// Allows you to specify a different attachment point for messages from yourself
/atom/proc/runechat_holder(datum/chatmessage/CM)
return src

View File

@@ -293,7 +293,7 @@ var/list/preferences_datums = list()
to_chat(usr,span_notice("Character [player_setup?.preferences?.real_name] saved!"))
save_preferences()
else if(href_list["reload"])
load_preferences()
load_preferences(TRUE)
load_character()
attempt_vr(client.prefs_vr,"load_vore","")
sanitize_preferences()
@@ -391,7 +391,7 @@ var/list/preferences_datums = list()
error("Player picked [choice] slot to load, but that wasn't one we sent.")
return
load_preferences()
load_preferences(TRUE)
load_character(slotnum)
attempt_vr(user.client?.prefs_vr,"load_vore","")
sanitize_preferences()

View File

@@ -134,7 +134,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
savefile.set_entry("lastnews", lastnews)
savefile.set_entry("lastlorenews", lastlorenews)
/datum/preferences/proc/load_preferences()
/datum/preferences/proc/load_preferences(skip_client)
if(!savefile)
stack_trace("Attempted to load the preferences of [client] without a savefile; did you forget to call load_savefile?")
load_savefile()
@@ -150,6 +150,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
fcopy(savefile.path, bacpath) //byond helpfully lets you use a savefile for the first arg.
return FALSE
if(!skip_client)
apply_all_client_preferences()
load_early_prefs()

View File

@@ -11,6 +11,7 @@
var/is_browser = FALSE
var/status = TGUI_WINDOW_CLOSED
var/locked = FALSE
var/visible = FALSE
var/datum/tgui/locked_by
var/datum/subscriber_object
var/subscriber_delegate
@@ -24,6 +25,8 @@
var/initial_inline_html
var/initial_inline_js
var/initial_inline_css
var/list/oversized_payloads = list()
var/mouse_event_macro_set = FALSE
/**
@@ -54,7 +57,6 @@
if(pooled)
src.pool_index = TGUI_WINDOW_INDEX(id)
/**
* public
*
@@ -116,7 +118,7 @@
html = replacetextEx(html, "<!-- tgui:assets -->\n", inline_assets_str)
// Inject inline HTML
if (inline_html)
html = replacetextEx(html, "<!-- tgui:inline-html -->", inline_html)
html = replacetextEx(html, "<!-- tgui:inline-html -->", isfile(inline_html) ? file2text(inline_html) : inline_html)
// Inject inline JS
if (inline_js)
inline_js = "<script>\n'use strict';\n[isfile(inline_js) ? file2text(inline_js) : inline_js]\n</script>"
@@ -230,7 +232,7 @@
*
* optional can_be_suspended bool
*/
/datum/tgui_window/proc/close(can_be_suspended = TRUE, logout = FALSE)
/datum/tgui_window/proc/close(can_be_suspended = TRUE)
if(!client)
return
if(mouse_event_macro_set)
@@ -241,25 +243,18 @@
#endif
status = TGUI_WINDOW_READY
send_message("suspend")
// You would think that BYOND would null out client or make it stop passing istypes or, y'know, ANYTHING during
// logout, but nope! It appears to be perfectly valid to call winset by every means we can measure in Logout,
// and yet it causes a bad client runtime. To avoid that happening, we just have to know if we're in Logout or
// not.
if(!logout && client)
winset(client, null, "mapwindow.map.focus=true")
return
#ifdef TGUI_DEBUGGING
log_tgui(client, "[id]/close")
#endif
release_lock()
visible = FALSE
status = TGUI_WINDOW_CLOSED
message_queue = null
// Do not close the window to give user some time
// to read the error message.
if(!fatally_errored)
client << browse(null, "window=[id]")
if(!logout && client)
winset(client, null, "mapwindow.map.focus=true")
/**
* public
@@ -388,6 +383,9 @@
switch(type)
if("ping")
send_message("ping/reply", payload)
if("visible")
visible = TRUE
// SEND_SIGNAL(src, COMSIG_TGUI_WINDOW_VISIBLE, client) // Not used yet
if("suspend")
close(can_be_suspended = TRUE)
if("close")
@@ -395,17 +393,55 @@
if("openLink")
client << link(href_list["url"])
if("cacheReloaded")
// Reinitialize
reinitialize()
// Resend the assets
for(var/asset in sent_assets)
send_asset(asset)
if("chat/resend")
SSchat.handle_resend(client, payload)
/* Does not work with tgui say, so not in use yet
if("oversizedPayloadRequest")
var/payload_id = payload["id"]
var/chunk_count = payload["chunkCount"]
var/permit_payload = chunk_count <= CONFIG_GET(number/tgui_max_chunk_count)
if(permit_payload)
create_oversized_payload(payload_id, payload["type"], chunk_count)
send_message("oversizePayloadResponse", list("allow" = permit_payload, "id" = payload_id))
if("payloadChunk")
var/payload_id = payload["id"]
append_payload_chunk(payload_id, payload["chunk"])
send_message("acknowlegePayloadChunk", list("id" = payload_id))
*/
/datum/tgui_window/vv_edit_var(var_name, var_value)
return var_name != NAMEOF(src, id) && ..()
/datum/tgui_window/proc/create_oversized_payload(payload_id, message_type, chunk_count)
if(oversized_payloads[payload_id])
stack_trace("Attempted to create oversized tgui payload with duplicate ID.")
return
oversized_payloads[payload_id] = list(
"type" = message_type,
"count" = chunk_count,
"chunks" = list(),
"timeout" = addtimer(CALLBACK(src, PROC_REF(remove_oversized_payload), payload_id), 1 SECONDS, TIMER_UNIQUE|TIMER_OVERRIDE|TIMER_STOPPABLE)
)
/datum/tgui_window/proc/append_payload_chunk(payload_id, chunk)
var/list/payload = oversized_payloads[payload_id]
if(!payload)
return
var/list/chunks = payload["chunks"]
chunks += chunk
if(length(chunks) >= payload["count"])
deltimer(payload["timeout"])
var/message_type = payload["type"]
var/final_payload = chunks.Join()
remove_oversized_payload(payload_id)
on_message(message_type, json_decode(final_payload), list("type" = message_type, "payload" = final_payload, "tgui" = TRUE, "window_id" = id))
else
payload["timeout"] = addtimer(CALLBACK(src, PROC_REF(remove_oversized_payload), payload_id), 1 SECONDS, TIMER_UNIQUE|TIMER_OVERRIDE|TIMER_STOPPABLE)
/datum/tgui_window/proc/remove_oversized_payload(payload_id)
oversized_payloads -= payload_id
/datum/tgui_window/proc/set_mouse_macro()
if(mouse_event_macro_set)

View File

@@ -86,19 +86,17 @@
* * ignore_prefs - CHANGE_ME. Default: FALSE
* * aura_animation - CHANGE_ME. Default: TRUE
*/
//#define USE_DIRECT_MULTIPLIERS //Uncomment to use old resize calculations.
/mob/living/proc/resize(var/new_size, var/animate = TRUE, var/uncapped = FALSE, var/ignore_prefs = FALSE, var/aura_animation = FALSE) //CHOMPEdit - Disable aura_animation. Too expensive for something you can't even see.
if(!uncapped)
#ifdef USE_DIRECT_MULTIPLIERS
new_size = clamp(new_size, RESIZE_MINIMUM, RESIZE_MAXIMUM)
#else
if((z in using_map.station_levels) && CONFIG_GET(flag/pixel_size_limit))
var/size_diff = ((runechat_y_offset() / size_multiplier) * new_size) // This returns 32 multiplied with the new size
var/size_cap = world.icon_size * (RESIZE_MAXIMUM+(ishuman(src)?0:0.5)) //Grace for non-humanoids so they don't get forcibly shrunk.
var/size_cap = world.icon_size * RESIZE_MAXIMUM //Grace for non-humanoids so they don't get forcibly shrunk.
if(size_diff - size_cap > 0)
var/real_diff = size_cap / size_diff // Returns our diff based on the offset to world size
new_size *= real_diff // Applies our diff to the new size
new_size = clamp(new_size, RESIZE_MINIMUM, RESIZE_MAXIMUM) //If the sprite is below 32, we clamp it to only go to the resize max.
#endif
else
new_size = clamp(new_size, RESIZE_MINIMUM, RESIZE_MAXIMUM)
var/datum/component/resize_guard/guard = GetComponent(/datum/component/resize_guard)
if(guard)
qdel(guard)
@@ -144,7 +142,7 @@
animate_aura(src, color = aura_color, offset = aura_offset, anim_duration = aura_anim_duration, loops = aura_loops, grow_to = aura_grow_to)
else
update_transform() //Lame way
//#undef USE_DIRECT_MULTIPLIERS //Uncomment to use old resize calculations.
/mob/living/carbon/human/resize(var/new_size, var/animate = TRUE, var/uncapped = FALSE, var/ignore_prefs = FALSE, var/aura_animation = FALSE) //CHOMPEdit - Disable aura_animation. Too expensive for something you can't even see.
if(!resizable && !ignore_prefs)
return 1

View File

@@ -611,3 +611,6 @@ JUKEBOX_TRACK_FILES config/jukebox.json
## Uncomment to block granting profiling privileges to users with R_DEBUG, for performance purposes
#FORBID_ADMIN_PROFILING
## Uncomment to limit resize caps depending on sprite icon height
#PIXEL_SIZE_LIMIT

View File

@@ -226,6 +226,7 @@ export const backendMiddleware = (store) => {
Byond.winset(Byond.windowId, {
'is-visible': true,
});
Byond.sendMessage('visible');
perf.mark('resume/finish');
if (process.env.NODE_ENV !== 'production') {
logger.log(

View File

@@ -1,7 +1,7 @@
import { useState } from 'react';
import { useBackend } from 'tgui/backend';
import { Window } from 'tgui/layouts';
import { Box, Button, LabeledList, Section } from 'tgui-core/components';
import { Box, Button, LabeledList, Section, Stack } from 'tgui-core/components';
import { CharacterDirectoryList } from './CharacterDirectoryList';
import { ViewCharacter } from './CharacterDirectoryViewCharacter';
@@ -37,10 +37,13 @@ export const CharacterDirectory = (props) => {
<Section
title="Settings and Preferences"
buttons={
<>
<Stack>
<Stack.Item>
<Box color="label" inline>
Save to current preferences slot:&nbsp;
</Box>
</Stack.Item>
<Stack.Item>
<Button
icon={overwritePrefs ? 'toggle-on' : 'toggle-off'}
selected={overwritePrefs}
@@ -48,7 +51,8 @@ export const CharacterDirectory = (props) => {
>
{overwritePrefs ? 'On' : 'Off'}
</Button>
</>
</Stack.Item>
</Stack>
}
>
<LabeledList>

View File

@@ -1,7 +1,7 @@
import { useBackend } from 'tgui/backend';
import { BeakerContents } from 'tgui/interfaces/common/BeakerContents';
import { modalOpen } from 'tgui/interfaces/common/ComplexModal';
import { Box, Button, Section } from 'tgui-core/components';
import { Box, Button, Section, Stack } from 'tgui-core/components';
import type { BooleanLike } from 'tgui-core/react';
import { transferAmounts } from './constants';
@@ -36,7 +36,8 @@ export const ChemMasterBeaker = (props: {
beakerLoaded
beakerContents={beakerReagents}
buttons={(chemical: reagent, i: number) => (
<Box mb={i < beakerReagents.length - 1 && '2px'}>
<Stack mb={i < beakerReagents.length - 1 && '2px'}>
<Stack.Item>
<Button
mb="0"
onClick={() =>
@@ -48,9 +49,10 @@ export const ChemMasterBeaker = (props: {
>
Analyze
</Button>
</Stack.Item>
{transferAmounts.map((am, j) => (
<Stack.Item key={j}>
<Button
key={j}
mb="0"
onClick={() =>
act('add', {
@@ -61,7 +63,9 @@ export const ChemMasterBeaker = (props: {
>
{am}
</Button>
</Stack.Item>
))}
<Stack.Item>
<Button
mb="0"
onClick={() =>
@@ -73,6 +77,8 @@ export const ChemMasterBeaker = (props: {
>
All
</Button>
</Stack.Item>
<Stack.Item>
<Button
mb="0"
onClick={() =>
@@ -81,9 +87,10 @@ export const ChemMasterBeaker = (props: {
})
}
>
Custom..
Custom...
</Button>
</Box>
</Stack.Item>
</Stack>
)}
/>
) : (

View File

@@ -1,7 +1,7 @@
import { useBackend } from 'tgui/backend';
import { BeakerContents } from 'tgui/interfaces/common/BeakerContents';
import { modalOpen } from 'tgui/interfaces/common/ComplexModal';
import { Box, Button, Section } from 'tgui-core/components';
import { Box, Button, Section, Stack } from 'tgui-core/components';
import type { BooleanLike } from 'tgui-core/react';
import { transferAmounts } from './constants';
@@ -17,8 +17,11 @@ export const ChemMasterBuffer = (props: {
<Section
title="Buffer"
buttons={
<Box color="label">
Transferring to&nbsp;
<Stack>
<Stack.Item>
<Box color="label">Transferring to</Box>
</Stack.Item>
<Stack.Item>
<Button
icon={mode ? 'flask' : 'trash'}
color={!mode && 'bad'}
@@ -26,7 +29,8 @@ export const ChemMasterBuffer = (props: {
>
{mode ? 'Beaker' : 'Disposal'}
</Button>
</Box>
</Stack.Item>
</Stack>
}
>
{bufferReagents.length > 0 ? (
@@ -34,7 +38,8 @@ export const ChemMasterBuffer = (props: {
beakerLoaded
beakerContents={bufferReagents}
buttons={(chemical, i) => (
<Box mb={i < bufferReagents.length - 1 && '2px'}>
<Stack mb={i < bufferReagents.length - 1 && '2px'}>
<Stack.Item>
<Button
mb="0"
onClick={() =>
@@ -46,9 +51,10 @@ export const ChemMasterBuffer = (props: {
>
Analyze
</Button>
</Stack.Item>
{transferAmounts.map((am, i) => (
<Stack.Item key={i}>
<Button
key={i}
mb="0"
onClick={() =>
act('remove', {
@@ -59,7 +65,9 @@ export const ChemMasterBuffer = (props: {
>
{am}
</Button>
</Stack.Item>
))}
<Stack.Item>
<Button
mb="0"
onClick={() =>
@@ -71,6 +79,8 @@ export const ChemMasterBuffer = (props: {
>
All
</Button>
</Stack.Item>
<Stack.Item>
<Button
mb="0"
onClick={() =>
@@ -79,9 +89,10 @@ export const ChemMasterBuffer = (props: {
})
}
>
Custom..
Custom...
</Button>
</Box>
</Stack.Item>
</Stack>
)}
/>
) : (

View File

@@ -1,6 +1,6 @@
import { useBackend } from 'tgui/backend';
import { modalOpen } from 'tgui/interfaces/common/ComplexModal';
import { Box, Button, Section } from 'tgui-core/components';
import { Box, Button, Section, Stack } from 'tgui-core/components';
import type { BooleanLike } from 'tgui-core/react';
export const ChemMasterCustomization = (props: {
@@ -28,12 +28,16 @@ export const ChemMasterCustomization = (props: {
return (
<Section title="Pill Bottle Customization">
<Stack>
<Stack.Item>
<Button
disabled={!loaded_pill_bottle}
onClick={() => modalOpen('change_pill_bottle_style')}
>
Customize Bottle Color
</Button>
</Stack.Item>
<Stack.Item>
<Button
disabled={!loaded_pill_bottle}
icon="eject"
@@ -49,6 +53,8 @@ export const ChemMasterCustomization = (props: {
')'
: 'None loaded'}
</Button>
</Stack.Item>
</Stack>
</Section>
);
};

View File

@@ -53,12 +53,15 @@ export const ChemSynthesizerChemicals = (props) => {
title="Catalyst"
minHeight="25%"
buttons={
<Box>
<Stack>
{!!catalyst && (
<Stack.Item>
<Box inline color="label" mr={2}>
{catalystCurrentVolume} / {catalystMaxVolume} units
</Box>
</Stack.Item>
)}
<Stack.Item>
<Button
icon="eject"
disabled={!catalyst || !!busy}
@@ -66,7 +69,8 @@ export const ChemSynthesizerChemicals = (props) => {
>
Eject
</Button>
</Box>
</Stack.Item>
</Stack>
}
>
<BeakerContents

View File

@@ -21,7 +21,8 @@ export const ChemSynthesizerQueueRecipes = (props) => {
title="Queue"
overflowY="scroll"
buttons={
<>
<Stack>
<Stack.Item>
<Button
disabled={!!busy}
color={use_catalyst ? 'green' : 'bad'}
@@ -31,6 +32,8 @@ export const ChemSynthesizerQueueRecipes = (props) => {
>
{use_catalyst ? 'Catalyst Active' : 'Catalyst Disabled'}
</Button>
</Stack.Item>
<Stack.Item>
<Button.Confirm
disabled={!queue.length}
color="bad"
@@ -38,15 +41,18 @@ export const ChemSynthesizerQueueRecipes = (props) => {
tooltip="Clear Queue"
onClick={() => act('clear_queue')}
/>
</Stack.Item>
{!busy && (
<Stack.Item>
<Button
disabled={!queue.length}
icon="play"
tooltip="Start Queue"
onClick={() => act('start_queue')}
/>
</Stack.Item>
)}
</>
</Stack>
}
>
<LabeledList>

View File

@@ -3,7 +3,6 @@ import { type RefObject, useEffect, useRef, useState } from 'react';
import { useBackend } from 'tgui/backend';
import { Window } from 'tgui/layouts';
import {
Box,
Button,
Divider,
Input,
@@ -104,13 +103,19 @@ export const Ticket = (props) => {
<Section
title={'Ticket #' + id}
buttons={
<Box nowrap>
<Stack>
<Stack.Item>
<Button icon="pen" onClick={() => act('retitle')}>
Rename Ticket
</Button>
</Stack.Item>
<Stack.Item>
<Button onClick={() => act('legacy')}>Legacy UI</Button>
</Stack.Item>
<Stack.Item>
<Button color={LevelColor[level]}>{Level[level]}</Button>
</Box>
</Stack.Item>
</Stack>
}
>
<LabeledList>

View File

@@ -3,7 +3,6 @@ import { type RefObject, useEffect, useRef, useState } from 'react';
import { useBackend } from 'tgui/backend';
import { Window } from 'tgui/layouts';
import {
Box,
Button,
Divider,
Input,
@@ -77,9 +76,7 @@ export const TicketChat = (props) => {
<Section
title={'Ticket #' + id}
buttons={
<Box nowrap>
<Button color={LevelColor[level]}>{Level[level]}</Button>
</Box>
}
>
<LabeledList>

View File

@@ -198,24 +198,34 @@ export const TicketsPanel = (props) => {
<Section
title={'Ticket #' + selected_ticket.id}
buttons={
<Box nowrap>
<Stack>
<Stack.Item>
<Button
icon="arrow-up"
onClick={() => act('undock_ticket')}
>
Undock
</Button>
</Stack.Item>
<Stack.Item>
<Button
icon="pen"
onClick={() => act('retitle_ticket')}
>
Rename Ticket
</Button>
<Button onClick={() => act('legacy')}>Legacy UI</Button>
</Stack.Item>
<Stack.Item>
<Button onClick={() => act('legacy')}>
Legacy UI
</Button>
</Stack.Item>
<Stack.Item>
<Button color={LevelColor[selected_ticket.level]}>
{Level[selected_ticket.level]}
</Button>
</Box>
</Stack.Item>
</Stack>
}
>
<LabeledList>
@@ -330,7 +340,8 @@ export const TicketsPanel = (props) => {
<Section
title="No ticket selected"
buttons={
<Box nowrap>
<Stack>
<Stack.Item>
<Button
disabled
icon="arrow-up"
@@ -338,6 +349,8 @@ export const TicketsPanel = (props) => {
>
Undock
</Button>
</Stack.Item>
<Stack.Item>
<Button
disabled
icon="pen"
@@ -345,8 +358,11 @@ export const TicketsPanel = (props) => {
>
Rename Ticket
</Button>
</Stack.Item>
<Stack.Item>
<Button onClick={() => act('legacy')}>Legacy UI</Button>
</Box>
</Stack.Item>
</Stack>
}
>
Please select a ticket on the left to view its details.

View File

@@ -193,6 +193,7 @@
#include "code\__defines\dcs\signals.dm"
#include "code\__defines\dcs\signals\signals_client.dm"
#include "code\__defines\dcs\signals\signals_subsystem.dm"
#include "code\__defines\dcs\signals\signals_tgui.dm"
#include "code\__defines\dcs\signals\signals_turf.dm"
#include "code\__defines\dcs\signals\signals_mobs\signals_mob_main.dm"
#include "code\__defines\traits\_traits.dm"