diff --git a/code/modules/economy/ATM.dm b/code/modules/economy/ATM.dm
index 0ff4af7b405..46c8aaeb560 100644
--- a/code/modules/economy/ATM.dm
+++ b/code/modules/economy/ATM.dm
@@ -46,11 +46,11 @@ log transactions
if(stat & NOPOWER)
return
- if(linked_db && ( (linked_db.stat & NOPOWER) || !linked_db.activated ) )
+ if(linked_db && ((linked_db.stat & NOPOWER) || !linked_db.activated))
linked_db = null
authenticated_account = null
- src.visible_message("\red [bicon(src)] [src] buzzes rudely, \"Connection to remote database lost.\"")
- updateDialog()
+ visible_message("[bicon(src)][src] buzzes rudely, \"Connection to remote database lost.\"")
+ nanomanager.update_uis(src)
if(ticks_left_timeout > 0)
ticks_left_timeout--
@@ -66,41 +66,35 @@ log transactions
if(istype(T) && locate(/obj/item/weapon/spacecash) in T)
var/list/cash_found = list()
for(var/obj/item/weapon/spacecash/S in T)
- cash_found+=S
- if(cash_found.len>0)
- if(prob(50))
- playsound(loc, 'sound/items/polaroid1.ogg', 50, 1)
- else
- playsound(loc, 'sound/items/polaroid2.ogg', 50, 1)
+ cash_found += S
+ if(cash_found.len > 0)
+ playsound(loc, pick('sound/items/polaroid1.ogg', 'sound/items/polaroid2.ogg'), 50, 1)
var/amount = count_cash(cash_found)
for(var/obj/item/weapon/spacecash/S in cash_found)
qdel(S)
- authenticated_account.charge(-amount,null,"Credit deposit",terminal_id=machine_id,dest_name = "Terminal")
+ authenticated_account.charge(-amount, null, "Credit deposit", terminal_id = machine_id, dest_name = "Terminal")
/obj/machinery/atm/proc/reconnect_database()
- for(var/obj/machinery/computer/account_database/DB in world) //Hotfix until someone finds out why it isn't in 'machines'
- if( DB.z == src.z && !(DB.stat & NOPOWER) && DB.activated )
+ for(var/obj/machinery/computer/account_database/DB in machines)
+ if(DB.z == z && !(DB.stat & NOPOWER) && DB.activated)
linked_db = DB
break
-/obj/machinery/atm/attackby(obj/item/I as obj, mob/user as mob, params)
+/obj/machinery/atm/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/weapon/card))
- var/obj/item/weapon/card/id/idcard = I
if(!held_card)
- usr.drop_item()
- idcard.loc = src
- held_card = idcard
+ user.drop_item()
+ I.forceMove(src)
+ held_card = I
if(authenticated_account && held_card.associated_account_number != authenticated_account.account_number)
authenticated_account = null
+ nanomanager.update_uis(src)
else if(authenticated_account)
- if(istype(I,/obj/item/weapon/spacecash))
+ if(istype(I, /obj/item/weapon/spacecash))
//consume the money
var/obj/item/weapon/spacecash/C = I
authenticated_account.money += C.get_total()
- if(prob(50))
- playsound(loc, 'sound/items/polaroid1.ogg', 50, 1)
- else
- playsound(loc, 'sound/items/polaroid2.ogg', 50, 1)
+ playsound(loc, pick('sound/items/polaroid1.ogg', 'sound/items/polaroid2.ogg'), 50, 1)
//create a transaction log entry
var/datum/transaction/T = new()
@@ -113,108 +107,55 @@ log transactions
authenticated_account.transaction_log.Add(T)
to_chat(user, "You insert [C] into [src].")
- src.attack_hand(user)
+ nanomanager.update_uis(src)
qdel(I)
else
..()
-/obj/machinery/atm/attack_hand(mob/user as mob)
- if(istype(user, /mob/living/silicon))
- to_chat(user, "\red Artificial unit recognized. Artificial units do not currently receive monetary compensation, as per Nanotrasen regulation #1005.")
+/obj/machinery/atm/attack_hand(mob/user)
+ if(..())
+ return 1
+ if(issilicon(user))
+ to_chat(user, "Artificial unit recognized. Artificial units do not currently receive monetary compensation, as per Nanotrasen regulation #1005.")
return
- if(get_dist(src,user) <= 1)
- add_fingerprint(user)
+ ui_interact(user)
- //js replicated from obj/machinery/computer/card
- var/dat = {"
Nanotrasen Automatic Teller Machine
- For all your monetary needs!
- This terminal is [machine_id]. Report this code when contacting Nanotrasen IT Support
- Card: [held_card ? held_card.name : "------"]
"}
+/obj/machinery/atm/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
+ user.set_machine(src)
+ ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
+ if (!ui)
+ ui = new(user, src, ui_key, "atm.tmpl", name, 550, 650)
+ ui.open()
- if(ticks_left_locked_down > 0)
- dat += "Maximum number of pin attempts exceeded! Access to this ATM has been temporarily disabled."
- else if(authenticated_account)
- switch(view_screen)
- if(CHANGE_SECURITY_LEVEL)
- dat += "Select a new security level for this account:
"
- var/text = "Zero - Either the account number or card is required to access this account. EFTPOS transactions will require a card and ask for a pin, but not verify the pin is correct."
- if(authenticated_account.security_level != 0)
- text = "[text]"
- dat += "[text]
"
- text = "One - An account number and pin must be manually entered to access this account and process transactions."
- if(authenticated_account.security_level != 1)
- text = "[text]"
- dat += "[text]
"
- text = "Two - In addition to account number and pin, a card is required to access this account and process transactions."
- if(authenticated_account.security_level != 2)
- text = "[text]"
- dat += {"[text]
- Back"}
- if(VIEW_TRANSACTION_LOGS)
- dat += {"Transaction logs
- Back
-
-
- | Date |
- Time |
- Target |
- Purpose |
- Value |
- Source terminal ID |
-
"}
- for(var/datum/transaction/T in authenticated_account.transaction_log)
- dat += {"
- | [T.date] |
- [T.time] |
- [T.target_name] |
- [T.purpose] |
- $[T.amount] |
- [T.source_terminal] |
-
"}
- dat += "
"
- if(TRANSFER_FUNDS)
- dat += {"Account balance: $[authenticated_account.money]
- Back
- "}
- else
- dat += {"Welcome, [authenticated_account.owner_name].
- Account balance: $[authenticated_account.money]
-
- Change account security level
- Make transfer
- View transaction log
- Print balance statement
- Logout
"}
- else if(linked_db)
- dat += {""}
- else
- dat += "Unable to connect to accounts database, please retry and if the issue persists contact Nanotrasen IT support."
- reconnect_database()
+/obj/machinery/atm/ui_data(mob/user, ui_key = "main", datum/topic_state/state = default_state)
+ var/data[0]
+ data["src"] = UID()
+ data["view_screen"] = view_screen
+ data["machine_id"] = machine_id
+ data["held_card_name"] = held_card ? held_card.name : "------"
+ data["ticks_left_locked_down"] = ticks_left_locked_down
+ data["linked_db"] = linked_db
- var/datum/browser/popup = new(user, "atm", name, 550, 650)
- popup.set_content(dat)
- popup.open(0)
- else
- user << browse(null,"window=atm")
+ data["authenticated_account"] = authenticated_account
+ if(authenticated_account)
+ data["owner_name"] = authenticated_account.owner_name
+ data["money"] = authenticated_account.money
+ data["security_level"] = authenticated_account.security_level
-/obj/machinery/atm/Topic(var/href, var/href_list)
+ var/list/trx = list()
+ for(var/datum/transaction/T in authenticated_account.transaction_log)
+ trx[++trx.len] = list(
+ "date" = T.date,
+ "time" = T.time,
+ "target_name" = T.target_name,
+ "purpose" = T.purpose,
+ "amount" = T.amount,
+ "source_terminal" = T.source_terminal)
+ data["transaction_log"] = trx
+
+ return data
+
+/obj/machinery/atm/Topic(href, list/href_list)
if(href_list["choice"])
switch(href_list["choice"])
if("transfer")
@@ -253,7 +194,7 @@ log transactions
if(linked_db)
// check if they have low security enabled
scan_user(usr)
-
+
if(!ticks_left_locked_down && held_card)
var/tried_account_num = text2num(href_list["account_num"])
if(!tried_account_num)
@@ -280,11 +221,11 @@ log transactions
T.time = worldtime2text()
failed_account.transaction_log.Add(T)
else
- to_chat(usr, "\red [bicon(src)] Incorrect pin/account combination entered, [max_pin_attempts - number_incorrect_tries] attempts remaining.")
+ to_chat(usr, "[bicon(src)]Incorrect pin/account combination entered, [max_pin_attempts - number_incorrect_tries] attempts remaining.")
previous_account_number = tried_account_num
playsound(src, 'sound/machines/buzz-sigh.ogg', 50, 1)
else
- to_chat(usr, "\red [bicon(src)] incorrect pin/account combination entered.")
+ to_chat(usr, "[bicon(src)]Incorrect pin/account combination entered.")
number_incorrect_tries = 0
else
playsound(src, 'sound/machines/twobeep.ogg', 50, 1)
@@ -300,7 +241,7 @@ log transactions
T.time = worldtime2text()
authenticated_account.transaction_log.Add(T)
- to_chat(usr, "\blue [bicon(src)] Access granted. Welcome user '[authenticated_account.owner_name].'")
+ to_chat(usr, "[bicon(src)]Access granted. Welcome user '[authenticated_account.owner_name].'")
previous_account_number = tried_account_num
if("withdrawal")
@@ -313,7 +254,7 @@ log transactions
//remove the money
if(amount > 10000) // prevent crashes
- to_chat(usr, "\blue The ATM's screen flashes, 'Maximum single withdrawl limit reached, defaulting to 10,000.'")
+ to_chat(usr, "The ATM's screen flashes, 'Maximum single withdrawl limit reached, defaulting to 10,000.'")
amount = 10000
authenticated_account.money -= amount
withdraw_arbitrary_sum(amount)
@@ -332,11 +273,11 @@ log transactions
if("balance_statement")
if(authenticated_account)
if(world.timeofday < lastprint + PRINT_DELAY)
- to_chat(usr, "The [src.name] flashes an error on its display.")
+ to_chat(usr, "The [name] flashes an error on its display.")
return
lastprint = world.timeofday
playsound(loc, 'sound/goonstation/machines/printer_thermal.ogg', 50, 1)
- var/obj/item/weapon/paper/R = new(src.loc)
+ var/obj/item/weapon/paper/R = new(loc)
R.name = "Account balance: [authenticated_account.owner_name]"
R.info = {"NT Automated Teller Account Statement
Account holder: [authenticated_account.owner_name]
@@ -349,54 +290,49 @@ log transactions
var/image/stampoverlay = image('icons/obj/bureaucracy.dmi')
stampoverlay.icon_state = "paper_stamp-cent"
if(!R.stamped)
- R.stamped = new
+ R.stamped = new()
R.stamped += /obj/item/weapon/stamp
R.overlays += stampoverlay
R.stamps += "
This paper has been stamped by the Automatic Teller Machine."
- if(prob(50))
- playsound(loc, 'sound/items/polaroid1.ogg', 50, 1)
- else
- playsound(loc, 'sound/items/polaroid2.ogg', 50, 1)
+ playsound(loc, pick('sound/items/polaroid1.ogg', 'sound/items/polaroid2.ogg'), 50, 1)
if("insert_card")
if(held_card)
- held_card.loc = src.loc
+ held_card.forceMove(loc)
authenticated_account = null
-
if(ishuman(usr) && !usr.get_active_hand())
usr.put_in_hands(held_card)
held_card = null
-
else
var/obj/item/I = usr.get_active_hand()
if(istype(I, /obj/item/weapon/card/id))
usr.drop_item()
- I.loc = src
+ I.forceMove(src)
held_card = I
if("logout")
authenticated_account = null
- //usr << browse(null,"window=atm")
- src.attack_hand(usr)
+ nanomanager.update_uis(src)
+ return 1
//create the most effective combination of notes to make up the requested amount
-/obj/machinery/atm/proc/withdraw_arbitrary_sum(var/arbitrary_sum)
- dispense_cash(arbitrary_sum,get_step(get_turf(src),turn(dir,180))) // Spawn on the ATM.
+/obj/machinery/atm/proc/withdraw_arbitrary_sum(arbitrary_sum)
+ dispense_cash(arbitrary_sum, get_step(get_turf(src), turn(dir, 180))) // Spawn on the ATM.
//stolen wholesale and then edited a bit from newscasters, which are awesome and by Agouri
-/obj/machinery/atm/proc/scan_user(mob/living/carbon/human/human_user as mob)
+/obj/machinery/atm/proc/scan_user(mob/living/carbon/human/H)
if(!authenticated_account && linked_db)
- if(human_user.wear_id)
+ if(H.wear_id)
var/obj/item/weapon/card/id/I
- if(istype(human_user.wear_id, /obj/item/weapon/card/id) )
- I = human_user.wear_id
- else if(istype(human_user.wear_id, /obj/item/device/pda) )
- var/obj/item/device/pda/P = human_user.wear_id
+ if(istype(H.wear_id, /obj/item/weapon/card/id) )
+ I = H.wear_id
+ else if(istype(H.wear_id, /obj/item/device/pda) )
+ var/obj/item/device/pda/P = H.wear_id
I = P.id
if(I)
authenticated_account = attempt_account_access(I.associated_account_number)
if(authenticated_account)
- to_chat(human_user, "\blue [bicon(src)] Access granted. Welcome user '[authenticated_account.owner_name].'")
+ to_chat(H, "[bicon(src)]Access granted. Welcome user '[authenticated_account.owner_name].'")
//create a transaction log entry
var/datum/transaction/T = new()
@@ -406,5 +342,6 @@ log transactions
T.date = current_date_string
T.time = worldtime2text()
authenticated_account.transaction_log.Add(T)
-
+
view_screen = NO_SCREEN
+ nanomanager.update_uis(src)
diff --git a/nano/templates/atm.tmpl b/nano/templates/atm.tmpl
new file mode 100644
index 00000000000..fa6c818b081
--- /dev/null
+++ b/nano/templates/atm.tmpl
@@ -0,0 +1,149 @@
+
+
+
+
+
+
+Nanotrasen Automatic Teller Machine
+For all your monetary needs!
+
+This terminal is {{:data.machine_id}}. Report this code when contacting Nanotrasen IT Support
+
+
+
+
Card:
+
{{:helper.link(data.held_card_name, 'eject', {'choice' : 'insert_card'})}}
+
+
+{{if data.ticks_left_locked_down > 0}}
+ Maximum number of pin attempts exceeded! Access to this ATM has been temporarily disabled.
+{{else data.authenticated_account}}
+ {{if data.view_screen == 1}}
+ Select a new security level for this account:
+
+
Level:
+
{{:helper.link('Zero', 'unlock', {'choice' : 'change_security_level', 'new_security_level' : 0}, data.security_level == 0 ? 'selected' : null)}}
+
+
+
Description:
+
Either the account number or card is required to access this account. EFTPOS transactions will require a card and ask for a pin, but not verify the pin is correct.
+
+
+
+
Level:
+
{{:helper.link('One', 'unlock-alt', {'choice' : 'change_security_level', 'new_security_level' : 1}, data.security_level == 1 ? 'selected' : null)}}
+
+
+
Description:
+
An account number and pin must be manually entered to access this account and process transactions.
+
+
+
+
Level:
+
{{:helper.link('Two', 'lock', {'choice' : 'change_security_level', 'new_security_level' : 2}, data.security_level == 2 ? 'selected' : null)}}
+
+
+
Description:
+
In addition to account number and pin, a card is required to access this account and process transactions.
+
+
+ {{:helper.link('Back', 'arrow-left', {'choice' : 'view_screen', 'view_screen' : 0})}}
+ {{else data.view_screen == 2}}
+ Account balance: ${{:helper.smoothRound(data.money)}}
+
+
+ {{:helper.link('Back', 'arrow-left', {'choice' : 'view_screen', 'view_screen' : 0})}}
+ {{else data.view_screen == 3}}
+ Transaction logs
+ {{:helper.link('Back', 'arrow-left', {'choice' : 'view_screen', 'view_screen' : 0})}}
+
+
+ {{if data.transaction_log}}
+
+
+
+ | Timestamp |
+ Target |
+ Reason |
+ Value |
+ Terminal |
+
+
+
+ {{for data.transaction_log}}
+
+ | {{:value.date}} {{:value.time}} |
+ {{:value.target_name}} |
+ {{:value.purpose}} |
+ ${{:value.amount}} |
+ {{:value.source_terminal}} |
+
+ {{/for}}
+
+
+ {{else}}
+
Your account has no financial transactions on record for today.
+ {{/if}}
+
+ {{else}}
+ Welcome, {{:data.owner_name}}.
+ Account balance: ${{:helper.smoothRound(data.money)}}
+
+
+
+ Menu
+ {{:helper.link('Change account security level', 'lock', {'choice' : 'view_screen', 'view_screen' : 1})}}
+ {{:helper.link('Make transfer', 'exchange', {'choice' : 'view_screen', 'view_screen' : 2})}}
+ {{:helper.link('View transaction log', 'list', {'choice' : 'view_screen', 'view_screen' : 3})}}
+ {{:helper.link('Print balance statement', 'print', {'choice' : 'balance_statement'})}}
+ {{:helper.link('Logout', 'sign-out', {'choice' : 'logout'})}}
+ {{/if}}
+{{else data.linked_db}}
+
+{{else}}
+ Unable to connect to accounts database, please retry and if the issue persists contact Nanotrasen IT support.
+{{/if}}
\ No newline at end of file