mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-24 12:37:26 +01:00
EFTPOS Tweaks + TGUI makeover (#20095)
* eftpos changes * Apply suggestions from code review Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com> * request changes * tgui rebuild * Update code/modules/economy/economy_machinery/eftpos.dm Co-authored-by: Vi3trice <80771500+Vi3trice@users.noreply.github.com> --------- Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com> Co-authored-by: Vi3trice <80771500+Vi3trice@users.noreply.github.com>
This commit is contained in:
co-authored by
Henri215
Vi3trice
parent
99d8e3473f
commit
a7848ee5be
@@ -6,30 +6,33 @@
|
||||
icon = 'icons/obj/device.dmi'
|
||||
icon_state = "eftpos"
|
||||
w_class = WEIGHT_CLASS_SMALL
|
||||
/// Unique identifying name of this EFTPOS for transaction tracking in money accounts
|
||||
var/machine_name = ""
|
||||
var/transaction_locked = 0
|
||||
var/transaction_paid = 0
|
||||
/// Whether or not the EFTPOS is locked into a transaction
|
||||
var/transaction_locked = FALSE
|
||||
/// Did the transaction go through? Will reset back to FALSE after 5 seconds, used as a cooldown and indicator to consumer
|
||||
var/transaction_paid = FALSE
|
||||
/// Amount in space credits to charge card swiper
|
||||
var/transaction_amount = 0
|
||||
var/transaction_purpose = "Default charge"
|
||||
/// The pin number needed to changed settings on the EFTPOS
|
||||
var/access_code
|
||||
var/transaction_sound = 'sound/machines/chime.ogg'
|
||||
|
||||
///linked money account database to this EFTPOS
|
||||
var/datum/money_account_database/account_database
|
||||
var/datum/money_account_database/main_station/account_database
|
||||
///Current money account the EFTPOS is depositing to
|
||||
var/datum/money_account/linked_account
|
||||
|
||||
/obj/item/eftpos/Initialize(mapload)
|
||||
machine_name = "[station_name()] EFTPOS #[rand(101,999)]"
|
||||
machine_name = "EFTPOS #[rand(101, 999)]"
|
||||
access_code = rand(1000, 9999)
|
||||
reconnect_database()
|
||||
//linked account starts as service account by default
|
||||
linked_account = account_database.get_account_by_department(DEPARTMENT_SERVICE)
|
||||
print_reference()
|
||||
|
||||
//by default, connect to the station vendor account
|
||||
linked_account = GLOB.station_money_database.vendor_account
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/item/eftpos/proc/reconnect_database()
|
||||
account_database = GLOB.station_money_database
|
||||
|
||||
@@ -55,7 +58,7 @@
|
||||
/obj/item/eftpos/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.inventory_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "EFTPOS", name, 800, 300, master_ui, state)
|
||||
ui = new(user, src, ui_key, "EFTPOS", name, 500, 250, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
/obj/item/eftpos/ui_data(mob/user)
|
||||
@@ -65,7 +68,16 @@
|
||||
data["transaction_paid"] = transaction_paid
|
||||
data["transaction_purpose"] = transaction_purpose
|
||||
data["transaction_amount"] = transaction_amount
|
||||
data["linked_account"] = linked_account ? linked_account.account_name : null
|
||||
data["linked_account"] = list("name" = linked_account?.account_name, "UID" = linked_account?.UID())
|
||||
data["available_accounts"] = list()
|
||||
for(var/datum/money_account/department as anything in (account_database.get_all_department_accounts() + account_database.user_accounts))
|
||||
var/list/account_data = list(
|
||||
"name" = department.account_name,
|
||||
"UID" = department.UID()
|
||||
)
|
||||
data["available_accounts"] += list(account_data)
|
||||
|
||||
|
||||
return data
|
||||
|
||||
/obj/item/eftpos/ui_act(action, list/params, datum/tgui/ui)
|
||||
@@ -95,7 +107,7 @@
|
||||
if(account_database)
|
||||
var/attempt_account_num = input("Enter account number to pay EFTPOS charges into", "New account number") as num
|
||||
var/attempt_pin = input("Enter pin code", "Account pin") as num
|
||||
if(!check_user_position(user))
|
||||
if(!check_user_position(user) || !account_database)
|
||||
return
|
||||
var/datum/money_account/target_account = GLOB.station_money_database.find_user_account(attempt_account_num, include_departments = TRUE)
|
||||
if(!target_account)
|
||||
@@ -109,6 +121,14 @@
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>Unable to connect to inputed account.</span>")
|
||||
else
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>Unable to connect to accounts database.</span>")
|
||||
return
|
||||
var/datum/money_account/target_account = locateUID(params["account"])
|
||||
if(!istype(target_account))
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>Unable to connect to inputted account.</span>")
|
||||
return
|
||||
// in this case we don't care about authenticating login because we're sending money into the account
|
||||
linked_account = target_account
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>Linked account successfully set to [target_account.account_name]</span>")
|
||||
if("trans_purpose")
|
||||
var/purpose = clean_input("Enter reason for EFTPOS transaction", "Transaction purpose", transaction_purpose)
|
||||
if(!check_user_position(user))
|
||||
@@ -138,16 +158,6 @@
|
||||
transaction_locked = TRUE
|
||||
else
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>No account connected to send transactions to.</span>")
|
||||
if("scan_card")
|
||||
//attempt to connect to a new db, and if that doesn't work then fail
|
||||
if(!account_database)
|
||||
reconnect_database()
|
||||
if(account_database && linked_account)
|
||||
var/obj/item/I = user.get_active_hand()
|
||||
if(istype(I, /obj/item/card))
|
||||
scan_card(I, user)
|
||||
else
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>Unable to link accounts.</span>")
|
||||
if("reset")
|
||||
//reset the access code - requires HoP/captain access
|
||||
var/obj/item/I = user.get_active_hand()
|
||||
@@ -182,7 +192,7 @@
|
||||
if(!D || !GLOB.station_money_database.try_authenticate_login(D, attempt_pin, restricted_bypass = FALSE))
|
||||
to_chat(user, "[bicon(src)]<span class='warning'>Unable to access account, insufficient access.</span>")
|
||||
return
|
||||
if(alert("Are you sure you want to pay $[transaction_amount] to Account: [linked_account.account_name] ", "Confirm transaction", "Yes", "No") != "Yes")
|
||||
if(alert("Are you sure you want to pay $[transaction_amount] to: [linked_account.account_name] ", "Confirm transaction", "Yes", "No") != "Yes")
|
||||
return
|
||||
if(!Adjacent(user))
|
||||
return
|
||||
@@ -194,6 +204,7 @@
|
||||
playsound(src, transaction_sound, 50, TRUE)
|
||||
visible_message("<span class='notice'>[src] chimes!</span>")
|
||||
transaction_paid = TRUE
|
||||
addtimer(VARSET_CALLBACK(src, transaction_paid, FALSE), 5 SECONDS)
|
||||
|
||||
///creates and builds paper with info about the EFTPOS
|
||||
/obj/item/eftpos/proc/print_reference()
|
||||
|
||||
Reference in New Issue
Block a user