Files
GhomandGitHub 8c534a521e Maintenance PDA themes are added to roundstart PDAs on future rounds as well once installed (#92983)
## About The Pull Request
I'm making the ordeal of finding a maint disk (or buying blackmarket
bootleg disk) with a theme in it a slightly more rewarding experience,
while sticking to the concept that it's something you've to find, unlike
default PDA themes.

This PR also proves to be an opportunity to put the progress tab that I
coded a year ago for the 'Fishdex' to good use.

TODO:
~~Refactor preferences to allow specific choices to be shown/hidden
depending on whether the player meets a defined criteria, otherwise
you'll have to do it manually every round, which is lame~~

- [x] Make some simple ui icons associated with each unlockable theme to
be shown in the cheevo progress tab

- [x] Code to validate deserialized DB values, in the remote case that
any theme is removed in the future, as well as unit test code for any
non-abstract theme without ID

- [x] Add sound cue and chat feedback when unlocking a theme (or when
fishing a new kind of fish for the first time, like, the code's similar)

- [x] Test all of this

## Why It's Good For The Game
These themes are basically an end in itself, and I understand the reason
behind their existence is to make for some cute, little maint loot, but
relegating it to chance of finding a disk somewhere in maintenance,
**every single round** really rots whatever little substance this purely
cosmetic feature already has.

## Changelog

🆑
add: Once installed, special PDA themes from maintenance disks will be
present on your roundstart PDA on future rounds (Sadly I couldn't figure
out a way to add those to the preferences UI yet). You can check which
PDA themes you've unlocked in the Progress tab of the achievements UI.
/🆑
2026-01-16 17:18:03 -05:00

110 lines
3.5 KiB
Plaintext

/**
* store_file
*
* Adds an already initialized file to the computer, checking if one already exists.
* Returns TRUE if successfully stored, FALSE otherwise.
* user is optional: If set, the action was done by a mob/player
*/
/obj/item/modular_computer/proc/store_file(datum/computer_file/file_storing, mob/user)
if(!file_storing || !istype(file_storing))
return FALSE
if(!can_store_file(file_storing))
return FALSE
// This file is already stored. Don't store it again.
if(file_storing in stored_files)
return FALSE
file_storing.computer = src
used_capacity += file_storing.size
SEND_SIGNAL(file_storing, COMSIG_COMPUTER_FILE_STORE, src, user)
SEND_SIGNAL(src, COMSIG_MODULAR_COMPUTER_FILE_STORE, file_storing, user)
return TRUE
/**
* remove_file
*
* Removes a given file from the computer, if possible.
* Properly checking if the file even exists and is in the computer.
* Returns TRUE if successfully completed, FALSE otherwise
*/
/obj/item/modular_computer/proc/remove_file(datum/computer_file/file_removing)
if(!file_removing || !istype(file_removing))
return FALSE
if(!(file_removing in stored_files))
return FALSE
if(istype(file_removing, /datum/computer_file/program))
var/datum/computer_file/program/program_file = file_removing
program_file.kill_program()
stored_files.Remove(file_removing)
used_capacity -= file_removing.size
SEND_SIGNAL(src, COMSIG_MODULAR_COMPUTER_FILE_DELETE, file_removing)
SEND_SIGNAL(file_removing, COMSIG_COMPUTER_FILE_DELETE, src)
qdel(file_removing)
return TRUE
/**
* can_store_file
*
* Checks if a computer can store a file, as computers can only store unique files.
* returns TRUE if possible, FALSE otherwise.
*/
/obj/item/modular_computer/proc/can_store_file(datum/computer_file/file)
if(!file || !istype(file))
return FALSE
if(file in stored_files)
return FALSE
if(find_file_by_name(file.filename))
return FALSE
// In the unlikely event someone manages to create that many files.
// BYOND is acting weird with numbers above 999 in loops (infinite loop prevention)
if(stored_files.len >= 999)
return FALSE
if((used_capacity + file.size) > max_capacity)
return FALSE
if(!file.can_store_file(src))
return FALSE
return TRUE
/**
* find_file_by_name
*
* Will check all applications in a tablet for files and, if they have \
* the same filename (disregarding extension), will return it.
* If a computer disk is passed instead, it will check the disk over the computer.
*/
/obj/item/modular_computer/proc/find_file_by_name(filename, obj/item/disk/computer/target_disk)
if(!istext(filename))
return null
if(isnull(target_disk))
for(var/datum/computer_file/file as anything in stored_files)
if(file.filename == filename)
return file
else
for(var/datum/computer_file/file as anything in target_disk.stored_files)
if(file.filename == filename)
return file
return null
/**
* find_file_by_uid
*
* Will check all files in this computer and returns the file with the matching uid.
* A file's uid is always unique to them, so this proc is sometimes preferable over find_file_by_name.
* If a computer disk is passed instead, it will check the disk over the computer.
*/
/obj/item/modular_computer/proc/find_file_by_uid(uid, obj/item/disk/computer/target_disk)
if(!isnum(uid))
return null
if(isnull(target_disk))
for(var/datum/computer_file/file as anything in stored_files)
if(file.uid == uid)
return file
else
for(var/datum/computer_file/file as anything in target_disk.stored_files)
if(file.uid == uid)
return file
return null