Files
Alexis 21b4095dfd [MDB IGNORE] [IDB IGNORE] Upstream Sync - 04/17/2026 (#5453)
Upstream 04/17/2026

fixes https://github.com/Bubberstation/Bubberstation/issues/5549

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com>
Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com>
Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com>
Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com>
Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com>
Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com>
Co-authored-by: loganuk <fakeemail123@aol.com>
Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com>
Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com>
Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com>
Co-authored-by: Lucy <lucy@absolucy.moe>
Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com>
Co-authored-by: Isratosh <Isratosh@hotmail.com>
Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com>
Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com>
Co-authored-by: Alexander V. <volas@ya.ru>
Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com>
Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
Co-authored-by: Tim <timothymtorres@gmail.com>
Co-authored-by: Iamgoofball <iamgoofball@gmail.com>
Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com>
Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com>
Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com>
Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com>
Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com>
Co-authored-by: Josh <josh.adam.powell@gmail.com>
Co-authored-by: Josh Powell <josh.powell@softwire.com>
Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com>
Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com>
Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com>
Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
2026-05-16 00:56:00 +02:00

177 lines
6.2 KiB
Plaintext

/datum/computer_file/program/maintenance/camera
filename = "camera_app"
filedesc = "Camera"
program_open_overlay = "camera"
downloader_category = PROGRAM_CATEGORY_EQUIPMENT
extended_desc = "This program allows the taking of pictures."
size = 4
can_run_on_flags = PROGRAM_PDA
tgui_id = "NtosCamera"
program_icon = "camera"
circuit_comp_type = /obj/item/circuit_component/mod_program/camera
/// Camera built-into the tablet.
var/obj/item/camera/app/internal_camera
/// Latest picture taken by the app.
var/datum/picture/internal_picture
/// base64 of the current taken picture
var/internal_picture_icon
/// How many pictures were taken already, used for the camera's TGUI photo display
var/picture_number = 1
/// Can we edit the metadata of the latest picture?
var/can_edit_metadata = TRUE
/// The name we will give to the picture when we first save it
var/current_picture_name
/// The description we will give to the picture when we first save it
var/current_picture_desc
/// The caption we will give to the picture when we first save it
var/current_picture_caption
// Special type of camera for this exact usecase to prevent harddels
/obj/item/camera/app
print_picture_on_snap = FALSE
cooldown = 1 SECONDS
light_range = 3
/datum/computer_file/program/maintenance/camera/on_install(datum/computer_file/source, obj/item/modular_computer/computer_installing, mob/user)
. = ..()
internal_camera = new(computer)
RegisterSignal(internal_camera, COMSIG_CAMERA_IMAGE_CAPTURED, PROC_REF(on_image_captured))
/datum/computer_file/program/maintenance/camera/Destroy()
QDEL_NULL(internal_camera)
QDEL_NULL(internal_picture)
return ..()
/datum/computer_file/program/maintenance/camera/tap(atom/tapped_atom, mob/living/user, list/modifiers)
. = ..()
take_picture(user, get_turf(tapped_atom))
/datum/computer_file/program/maintenance/camera/on_made_active_program(user)
RegisterSignal(computer, COMSIG_RANGED_ITEM_INTERACTING_WITH_ATOM_SECONDARY, PROC_REF(on_computer_ranged_interact))
/datum/computer_file/program/maintenance/camera/kill_program(mob/user)
. = ..()
UnregisterSignal(computer, COMSIG_RANGED_ITEM_INTERACTING_WITH_ATOM_SECONDARY)
QDEL_NULL(internal_picture)
/datum/computer_file/program/maintenance/camera/background_program(mob/user)
. = ..()
UnregisterSignal(computer, COMSIG_RANGED_ITEM_INTERACTING_WITH_ATOM_SECONDARY)
/datum/computer_file/program/maintenance/camera/proc/on_computer_ranged_interact(_source, mob/user, atom/target, list/modifiers)
SIGNAL_HANDLER
take_picture(user, get_turf(target))
/datum/computer_file/program/maintenance/camera/proc/take_picture(mob/user, turf/target)
internal_camera.see_ghosts = (locate(/datum/computer_file/program/maintenance/spectre_meter) in computer.stored_files) ? CAMERA_SEE_GHOSTS_BASIC : CAMERA_NO_GHOSTS
internal_camera.attempt_picture(target, user)
/datum/computer_file/program/maintenance/camera/proc/on_image_captured(cam, target, user, datum/picture/picture)
SIGNAL_HANDLER
QDEL_NULL(internal_picture)
internal_picture = picture
internal_picture_icon = icon2base64(internal_picture.picture_image)
current_picture_name = null
current_picture_desc = null
current_picture_caption = null
can_edit_metadata = TRUE
picture_number++
/datum/computer_file/program/maintenance/camera/proc/commit_metadata()
if(can_edit_metadata)
internal_picture.picture_name = current_picture_name
internal_picture.picture_desc = "[current_picture_desc] - [internal_picture.picture_desc]"
internal_picture.caption = current_picture_caption
can_edit_metadata = FALSE
/datum/computer_file/program/maintenance/camera/ui_static_data(mob/user)
return list(
"maxNameLength" = 32,
"maxDescLength" = 128,
"maxCaptionLength" = 256,
"printCost" = 1,
"minSize" = 2,
"maxSize" = CAMERA_PICTURE_SIZE_HARD_LIMIT
)
/datum/computer_file/program/maintenance/camera/ui_data(mob/user)
var/list/data = list()
if(!isnull(internal_picture))
data["photo"] = internal_picture_icon
data["canEditMetadata"] = can_edit_metadata
data["name"] = current_picture_name
data["desc"] = current_picture_desc
data["caption"] = current_picture_caption
data["storedPaper"] = computer.stored_paper
data["width"] = internal_camera.picture_size_x
data["height"] = internal_camera.picture_size_y
data["size"] = "[APERTURE_TO_METERS(internal_camera.picture_size_x)]x[APERTURE_TO_METERS(internal_camera.picture_size_y)]"
return data
/datum/computer_file/program/maintenance/camera/ui_act(action, params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
switch(action)
if("adjustWidth")
var/new_size = text2num(params["value"])
if(!new_size)
return
return internal_camera.adjust_zoom(desired_x = new_size)
if("adjustHeight")
var/new_size = text2num(params["value"])
if(!new_size)
return
return internal_camera.adjust_zoom(desired_y = new_size)
if("setName")
if(!(internal_picture && can_edit_metadata))
return FALSE
current_picture_name = trim(params["value"], PREVENT_CHARACTER_TRIM_LOSS(32))
return TRUE
if("setDesc")
if(!(internal_picture && can_edit_metadata))
return
current_picture_desc = trim(params["value"], PREVENT_CHARACTER_TRIM_LOSS(128))
return TRUE
if("setCaption")
if(!(internal_picture && can_edit_metadata))
return
current_picture_caption = trim(params["value"], PREVENT_CHARACTER_TRIM_LOSS(256))
return TRUE
if("savePhoto")
if(!internal_picture)
return
var/datum/computer_file/image/photo_file = new(
internal_picture.picture_image,
display_name = internal_picture.picture_name || "photo[picture_number]",
source_photo_or_painting = internal_picture
)
if(computer.store_file(photo_file, ui.user))
return FALSE
commit_metadata()
return TRUE
if("printPhoto")
if(!internal_picture)
return FALSE
if(computer.stored_paper < PHOTO_PAPER_COST)
return FALSE
commit_metadata()
var/obj/item/photo/new_photo = new(computer.physical.drop_location())
new_photo.set_picture(internal_picture, TRUE, TRUE)
ui.user.put_in_hands(new_photo)
playsound(computer.physical, 'sound/machines/printer.ogg', 100, TRUE)
computer.stored_paper--
computer.visible_message(span_notice("\The [computer] prints out a paper."))
return TRUE