From 428c43fa5f19931ea0f6a43884213d73aaf5a632 Mon Sep 17 00:00:00 2001 From: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Date: Wed, 11 Mar 2026 16:07:37 -0400 Subject: [PATCH] Screenshots now in keybindings properly (removes from skin) (#95152) --- code/__DEFINES/keybinding.dm | 1 + code/datums/keybinding/_keybindings.dm | 3 ++ code/datums/keybinding/client.dm | 27 ++++++++++++--- .../preferences/middleware/keybindings.dm | 1 + interface/skin.dmf | 15 --------- .../GamePreferences/KeybindingsPage.tsx | 33 ++++++++++++------- 6 files changed, 49 insertions(+), 31 deletions(-) diff --git a/code/__DEFINES/keybinding.dm b/code/__DEFINES/keybinding.dm index 9f9d22e2643..d9883f5d7c4 100644 --- a/code/__DEFINES/keybinding.dm +++ b/code/__DEFINES/keybinding.dm @@ -27,6 +27,7 @@ //Client #define COMSIG_KB_CLIENT_GETHELP_DOWN "keybinding_client_gethelp_down" #define COMSIG_KB_CLIENT_SCREENSHOT_DOWN "keybinding_client_screenshot_down" +#define COMSIG_KB_CLIENT_SCREENSHOT_AS_DOWN "keybinding_client_screenshot_as_down" #define COMSIG_KB_CLIENT_FULLSCREEN_DOWN "keybinding_client_fullscreen_down" #define COMSIG_KB_CLIENT_MINIMALHUD_DOWN "keybinding_client_minimalhud_down" #define COMSIG_KB_CLIENT_CLOSEUI_DOWN "keybinding_client_closeui_down" diff --git a/code/datums/keybinding/_keybindings.dm b/code/datums/keybinding/_keybindings.dm index e92eaf1d177..cd33213e638 100644 --- a/code/datums/keybinding/_keybindings.dm +++ b/code/datums/keybinding/_keybindings.dm @@ -7,6 +7,9 @@ var/category = CATEGORY_MISC var/weight = WEIGHT_LOWEST var/keybind_signal + ///Boolean on whether players are able to edit this keybinding. Used for BYOND built-in binds we wish to + ///tell the player of its existence, but don't want it being edited because BYOND doesn't let us. + var/can_edit = TRUE /datum/keybinding/New() if(!keybind_signal) diff --git a/code/datums/keybinding/client.dm b/code/datums/keybinding/client.dm index aa178cc1e0c..f20d38397bd 100644 --- a/code/datums/keybinding/client.dm +++ b/code/datums/keybinding/client.dm @@ -20,16 +20,35 @@ /datum/keybinding/client/screenshot hotkey_keys = list("F2") - name = "screenshot" - full_name = "Screenshot" - description = "Take a screenshot." + name = "quick screenshot" + full_name = "Quick Screenshot" + description = "Take a screenshot, which will be stored in BYOND's screenshots folder." keybind_signal = COMSIG_KB_CLIENT_SCREENSHOT_DOWN + can_edit = FALSE /datum/keybinding/client/screenshot/down(client/user, turf/target, mousepos_x, mousepos_y) . = ..() if(.) return - winset(user, null, "command=.auto") + to_chat(user, span_notice("Screenshot saved in 'BYOND/screenshots' folder.")) + //This is dealt by BYOND. Keeping this here in case that ever changes, though this command doesn't actually work when manually called. + //winset(user, null, "command=.screenshot auto") + return TRUE + +/datum/keybinding/client/screenshot_loc + hotkey_keys = list("ShiftF2") + name = "screenshot as" + full_name = "Save Screenshot as" + description = "Take a screenshot and save it at a specific location." + keybind_signal = COMSIG_KB_CLIENT_SCREENSHOT_AS_DOWN + can_edit = FALSE + +/datum/keybinding/client/screenshot_loc/down(client/user, turf/target, mousepos_x, mousepos_y) + . = ..() + if(.) + return + //This is dealt by BYOND. Keeping this here in case that ever changes. + //winset(user, null, "command=.screenshot") return TRUE /datum/keybinding/client/toggle_fullscreen diff --git a/code/modules/client/preferences/middleware/keybindings.dm b/code/modules/client/preferences/middleware/keybindings.dm index 5c1cddfa352..f8b8a128fe8 100644 --- a/code/modules/client/preferences/middleware/keybindings.dm +++ b/code/modules/client/preferences/middleware/keybindings.dm @@ -94,6 +94,7 @@ keybindings[keybinding.category][keybinding.name] = list( "name" = keybinding.full_name, "description" = keybinding.description, + "can_edit" = keybinding.can_edit, "default" = keybinding.hotkey_keys, ) diff --git a/interface/skin.dmf b/interface/skin.dmf index f268cf77887..366919f4b1c 100644 --- a/interface/skin.dmf +++ b/interface/skin.dmf @@ -14,21 +14,6 @@ menu "menu" name = "&File" command = "" saved-params = "is-checked" - elem - name = "&Quick screenshot\tF2" - command = ".screenshot auto" - category = "&File" - saved-params = "is-checked" - elem - name = "&Save screenshot as...\tShift+F2" - command = ".screenshot" - category = "&File" - saved-params = "is-checked" - elem - name = "" - command = "" - category = "&File" - saved-params = "is-checked" elem "reconnectbutton" name = "&Reconnect" command = ".reconnect" diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/GamePreferences/KeybindingsPage.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/GamePreferences/KeybindingsPage.tsx index 42dc60e768e..34b35c04a00 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/GamePreferences/KeybindingsPage.tsx +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/GamePreferences/KeybindingsPage.tsx @@ -13,6 +13,7 @@ import { import type { KeyEvent } from 'tgui-core/events'; import { fetchRetry } from 'tgui-core/http'; import { isEscape, KEY } from 'tgui-core/keys'; +import type { BooleanLike } from 'tgui-core/react'; import { LoadingScreen } from '../../common/LoadingScreen'; import type { PreferencesMenuData } from '../types'; @@ -21,6 +22,7 @@ import { TabbedMenu } from './TabbedMenu'; type Keybinding = { name: string; description?: string; + can_edit: BooleanLike; default?: string[]; }; @@ -119,6 +121,7 @@ function moveToBottom(entries: [string, unknown][], findCategory: string) { } class KeybindingButton extends Component<{ + can_edit: BooleanLike; currentHotkey?: string; onClick?: () => void; typingHotkey?: string; @@ -132,7 +135,8 @@ class KeybindingButton extends Component<{ } render() { - const { currentHotkey, onClick, typingHotkey, defaults } = this.props; + const { can_edit, currentHotkey, onClick, typingHotkey, defaults } = + this.props; const keyText = typingHotkey || currentHotkey || 'Unbound'; const child = ( @@ -141,15 +145,19 @@ class KeybindingButton extends Component<{ textAlign="center" captureKeys={typingHotkey === undefined} onClick={(event) => { - event.stopPropagation(); - onClick?.(); + if (can_edit) { + event.stopPropagation(); + onClick?.(); + } }} selected={typingHotkey !== undefined} textColor={keyText === 'Unbound' ? 'grey' : undefined} color={ - keyText === 'Unbound' || !defaults || defaults.includes(keyText) - ? undefined - : 'green' + !can_edit + ? 'transparent' + : keyText === 'Unbound' || !defaults || defaults.includes(keyText) + ? undefined + : 'green' } > {keyText} @@ -243,10 +251,10 @@ function getKeybindingNodes( {name} - - {range(0, 3).map((key) => ( + {range(0, keybinding.can_edit ? 3 : 1).map((key) => ( ))} - - - - + {!!keybinding.can_edit && ( + + + + )} );