mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-20 03:30:01 +01:00
+37






![tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)


Alexis
GitHub
tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com>
ArcaneMusic
MrMelbert
Rhials
rageguy505
LemonInTheDark
John Willard
Aliceee2ch
Time-Green
Tsar-Salat
SmArtKar
Maxipat
SyncIt21
deltanedas
SimplyLogan
loganuk
Leland Kemble
FalloutFalcon
Roxy
Lucy
siliconOpossum
Isratosh
TheRyeGuyWhoWillNowDie
Neocloudy
Alexander V.
ElGitificador
Twaticus
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bloop
Cameron Lennox
Tim
Iamgoofball
Layzu666
Arturlang
_0Steven
mrmanlikesbt
Ben10Omintrix
John F. Kennedy
Cursor
Josh
Josh Powell
Yobrocharlie
Hardly3D
shayoki
LT3
21b4095dfd
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>
119 lines
4.2 KiB
Plaintext
119 lines
4.2 KiB
Plaintext
#define BARCODE_SCANNER_CHECKIN "check_in"
|
|
#define BARCODE_SCANNER_CHECKOUT "check_out"
|
|
#define BARCODE_SCANNER_INVENTORY "inventory"
|
|
|
|
/obj/item/barcodescanner
|
|
name = "barcode scanner"
|
|
icon = 'icons/obj/service/library.dmi'
|
|
icon_state ="scanner"
|
|
desc = "A fabulous tool if you need to scan a barcode."
|
|
throw_speed = 3
|
|
throw_range = 5
|
|
w_class = WEIGHT_CLASS_TINY
|
|
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 2)
|
|
///Weakref to the library computer we are connected to.
|
|
var/datum/weakref/computer_ref
|
|
///The current scanning mode (BARCODE_SCANNER_CHECKIN|BARCODE_SCANNER_CHECKOUT|BARCODE_SCANNER_INVENTORY)
|
|
var/scan_mode = BARCODE_SCANNER_CHECKIN
|
|
|
|
/obj/item/barcodescanner/Initialize(mapload)
|
|
. = ..()
|
|
register_item_context()
|
|
register_context()
|
|
|
|
/obj/item/barcodescanner/add_item_context(obj/item/source, list/context, atom/target, mob/living/user)
|
|
if(!istype(target, /obj/item/book))
|
|
return NONE
|
|
|
|
switch(scan_mode)
|
|
if(BARCODE_SCANNER_CHECKIN)
|
|
context[SCREENTIP_CONTEXT_LMB] = "Check in"
|
|
if(BARCODE_SCANNER_CHECKOUT)
|
|
context[SCREENTIP_CONTEXT_LMB] = "Check out"
|
|
if(BARCODE_SCANNER_INVENTORY)
|
|
context[SCREENTIP_CONTEXT_LMB] = "Add to inventory"
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
|
|
/obj/item/barcodescanner/add_context(atom/source, list/context, obj/item/held_item, mob/living/user)
|
|
if(held_item == src)
|
|
context[SCREENTIP_CONTEXT_LMB] = "Toggle scanning mode"
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
return NONE
|
|
|
|
/obj/item/barcodescanner/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
|
|
if(istype(interacting_with, /obj/item/book))
|
|
return interact_with_book(interacting_with, user)
|
|
return NONE
|
|
|
|
/obj/item/barcodescanner/proc/interact_with_book(obj/item/book/target_book, mob/living/user)
|
|
var/obj/machinery/computer/libraryconsole/bookmanagement/linked_computer = computer_ref?.resolve()
|
|
if(isnull(linked_computer))
|
|
user.balloon_alert(user, "not connected to computer!")
|
|
return ITEM_INTERACT_BLOCKING
|
|
|
|
switch(scan_mode)
|
|
if(BARCODE_SCANNER_CHECKIN)
|
|
var/list/checkouts = linked_computer.checkouts
|
|
for(var/checkout_ref in checkouts)
|
|
var/datum/borrowbook/maybe_ours = checkouts[checkout_ref]
|
|
if(!target_book.book_data.compare(maybe_ours.book_data))
|
|
continue
|
|
checkouts -= checkout_ref
|
|
linked_computer.checkout_update()
|
|
balloon_alert(user, "checked in")
|
|
playsound(src, 'sound/items/barcodebeep.ogg', 20, FALSE)
|
|
return ITEM_INTERACT_SUCCESS
|
|
|
|
user.balloon_alert(user, "isn't checked out!")
|
|
return ITEM_INTERACT_BLOCKING
|
|
|
|
if(BARCODE_SCANNER_CHECKOUT)
|
|
var/list/checkouts = linked_computer.checkouts
|
|
for(var/checkout_ref in checkouts)
|
|
var/datum/borrowbook/maybe_ours = checkouts[checkout_ref]
|
|
if(target_book.book_data.compare(maybe_ours.book_data))
|
|
user.balloon_alert(user, "already checked out!")
|
|
return ITEM_INTERACT_BLOCKING
|
|
for(var/copy_ref in linked_computer.inventory)
|
|
if(!target_book.book_data.compare(linked_computer.inventory[copy_ref]))
|
|
continue
|
|
linked_computer.checking_out_book = target_book.book_data
|
|
balloon_alert(user, "set for check out")
|
|
playsound(src, 'sound/items/barcodebeep.ogg', 20, FALSE)
|
|
return ITEM_INTERACT_SUCCESS
|
|
user.balloon_alert(user, "not in inventory!")
|
|
return ITEM_INTERACT_BLOCKING
|
|
|
|
if(BARCODE_SCANNER_INVENTORY)
|
|
var/datum/book_info/our_copy = target_book.book_data.return_copy()
|
|
linked_computer.inventory[ref(our_copy)] = our_copy
|
|
linked_computer.inventory_update()
|
|
balloon_alert(user, "added to inventory")
|
|
playsound(src, 'sound/items/barcodebeep.ogg', 20, FALSE)
|
|
return ITEM_INTERACT_SUCCESS
|
|
|
|
return NONE
|
|
|
|
/obj/item/barcodescanner/attack_self(mob/user)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
if(!computer_ref?.resolve())
|
|
balloon_alert(user, "connect to computer!")
|
|
return
|
|
switch(scan_mode)
|
|
if(BARCODE_SCANNER_CHECKIN)
|
|
scan_mode = BARCODE_SCANNER_CHECKOUT
|
|
balloon_alert(user, "check-out mode")
|
|
if(BARCODE_SCANNER_CHECKOUT)
|
|
scan_mode = BARCODE_SCANNER_INVENTORY
|
|
balloon_alert(user, "inventory adding mode")
|
|
if(BARCODE_SCANNER_INVENTORY)
|
|
scan_mode = BARCODE_SCANNER_CHECKIN
|
|
balloon_alert(user, "check-in mode")
|
|
playsound(loc, 'sound/items/click.ogg', 20, TRUE)
|
|
|
|
#undef BARCODE_SCANNER_CHECKIN
|
|
#undef BARCODE_SCANNER_CHECKOUT
|
|
#undef BARCODE_SCANNER_INVENTORY
|