Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TGUI для Identification Computer #13008

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e40a9ac
Хоть что-то
Slavik2001 Mar 21, 2024
e8ab8f8
Auth
Slavik2001 Mar 23, 2024
c60f2f8
Maybe.....
Slavik2001 Mar 25, 2024
d66fbae
DoneMapError
Slavik2001 Mar 26, 2024
f8efc1d
Тест_пуш
Slavik2001 Mar 27, 2024
6c83d7d
Almost win
Slavik2001 Mar 28, 2024
dd42d9d
Titles
Slavik2001 Mar 28, 2024
a6a3f0f
Mode
Slavik2001 Mar 28, 2024
8b1d337
Custom, Demote, Terminate, Selection detect for Access List, Fix Mode…
Slavik2001 Mar 29, 2024
353a83f
Some back...
Slavik2001 Mar 29, 2024
c78edfe
Fix_CentCom
Slavik2001 Mar 29, 2024
2562b03
Regions
Slavik2001 Mar 29, 2024
f2d9e5d
Accesses
Slavik2001 Mar 29, 2024
a265811
Def/Undef
Slavik2001 Mar 29, 2024
4bbba77
TGUI_Crew_Manifest
Slavik2001 Mar 30, 2024
c9553a3
Printing
Slavik2001 Mar 30, 2024
b2b02ab
Merge branch 'master' into tgui_cardcomp
Slavik2001 Mar 30, 2024
8de1af3
Удаление не используемого НаноУИ
Slavik2001 Mar 30, 2024
1a79292
Merge branch 'tgui_cardcomp' of https://github.com/Slavik2001/TauCeti…
Slavik2001 Mar 30, 2024
f2f156b
Some...
Slavik2001 Apr 6, 2024
a62f06d
-title
Slavik2001 Apr 6, 2024
005d23f
Full/Region
Slavik2001 Apr 8, 2024
245a8d3
Fix get_acc, useLocalState
Slavik2001 Apr 8, 2024
799dcca
Done for now
Slavik2001 Apr 16, 2024
2579a0a
Merge branch 'master' into tgui_cardcomp
Slavik2001 Apr 30, 2024
63f529c
F*** Conflicts
Slavik2001 Apr 30, 2024
cc5ae7f
Merge branch 'tgui_cardcomp' of https://github.com/Slavik2001/TauCeti…
Slavik2001 Apr 30, 2024
3a8c180
Done?!
Slavik2001 Apr 30, 2024
0de309d
Merge branch 'master' into tgui_cardcomp
Slavik2001 May 1, 2024
7855b55
useLocalState
Slavik2001 Jun 9, 2024
a235ed4
Merge branch 'master' into tgui_cardcomp
Slavik2001 Jun 9, 2024
13bba7a
F*** y TGUI
Slavik2001 Jun 9, 2024
f50002e
1
Slavik2001 Jun 11, 2024
d73ea93
Color for Comman and fix error of lenth in CrewManifest
Slavik2001 Jun 12, 2024
d7626d3
Done
Slavik2001 Jul 4, 2024
d9d09df
Merge branch 'master' into tgui_cardcomp
Slavik2001 Jul 4, 2024
9c3c378
F
Slavik2001 Jul 4, 2024
0aabc08
Finish?
Slavik2001 Jul 5, 2024
994d9c7
...
Slavik2001 Jul 13, 2024
6f14824
F***
Slavik2001 Jul 14, 2024
366e447
Finally
Slavik2001 Jul 26, 2024
dd62141
Mode
Slavik2001 Jul 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 87 additions & 69 deletions code/game/machinery/computer/card.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#define IDCOMPUTER_SCREEN_ACCESS 0
#define IDCOMPUTER_SCREEN_MANIFEST 1
#define IDCOMPUTER_SCREEN_PRINT 2
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved

/obj/machinery/computer/card
name = "Identification Computer"
desc = "Terminal for programming NanoTrasen employee ID cards to access parts of the station."
Expand All @@ -8,7 +12,7 @@
allowed_checks = ALLOWED_CHECK_NONE
var/obj/item/weapon/card/id/scan = null //card that gives access to this console
var/obj/item/weapon/card/id/modify = null //the card we will change
var/mode = 0.0
var/mode = 0
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved
var/printing = null
var/datum/money_account/datum_account = null //if money account is tied to the card and the card is inserted into the console, the account is stored here
required_skills = list(/datum/skill/command = SKILL_LEVEL_PRO)
Expand All @@ -20,16 +24,16 @@
/obj/machinery/computer/card/proc/is_authenticated()
return scan ? check_access(scan) : 0

/obj/machinery/computer/card/proc/get_target_rank()
/obj/machinery/computer/card/proc/get_modify_rank()
return modify && modify.assignment ? modify.assignment : "Unassigned"

/obj/machinery/computer/card/proc/format_jobs(list/jobs)
var/list/formatted = list()
for(var/job in jobs)
formatted.Add(list(list(
"display_name" = replacetext(job, " ", "&nbsp"),
"target_rank" = get_target_rank(),
"job" = job)))
"modify_rank" = get_modify_rank(),
"job" = job)))

return formatted
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -85,80 +89,92 @@
datum_account = null //delete information if there is something in the variable

playsound(src, 'sound/machines/terminal_insert.ogg', VOL_EFFECTS_MASTER, null, FALSE)
nanomanager.update_uis(src)
SStgui.update_uis(src)
attack_hand(user)

/obj/machinery/computer/card/ui_interact(mob/user, ui_key="main", datum/nanoui/ui=null)
var/data[0]
/obj/machinery/computer/card/ui_interact(mob/user)
tgui_interact(user)

/obj/machinery/computer/card/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "ComputerCard")
ui.open()

/obj/machinery/computer/card/tgui_data(mob/user)
var/list/data = list()
data["src"] = "\ref[src]"
data["station_name"] = station_name()
data["mode"] = mode
data["printing"] = printing
data["manifest"] = data_core ? data_core.html_manifest(monochrome=0) : null
data["target_name"] = modify ? modify.name : "-----"
data["target_owner"] = modify && modify.registered_name ? modify.registered_name : "-----"
data["target_rank"] = get_target_rank()
data["scan_name"] = scan ? scan.name : "-----"
data["modify_name"] = modify ? modify.name : FALSE
data["modify_owner"] = modify && modify.registered_name ? modify.registered_name : "-----"
data["modify_rank"] = get_modify_rank()
data["scan_name"] = scan ? scan.name : FALSE
data["scan_rank"] = scan ? scan.rank : FALSE
data["authenticated"] = is_authenticated()
data["has_modify"] = !!modify
data["account_number"] = modify ? modify.associated_account_number : null
data["salary"] = datum_account ? datum_account.owner_salary : "not_found"
data["centcom_access"] = is_centcom()
data["all_centcom_access"] = null
data["all_centcom_access"] = is_centcom() ? TRUE : FALSE
data["regions"] = null

data["engineering_jobs"] = format_jobs(engineering_positions)
data["medical_jobs"] = format_jobs(medical_positions)
data["science_jobs"] = format_jobs(science_positions)
data["security_jobs"] = format_jobs(security_positions)
data["civilian_jobs"] = format_jobs(civilian_positions)
data["centcom_jobs"] = format_jobs(get_all_centcom_jobs())
data["command_jobs"] = command_positions
data["engineering_jobs"] = engineering_positions
data["medical_jobs"] = medical_positions
data["science_jobs"] = science_positions
data["security_jobs"] = security_positions
data["civilian_jobs"] = civilian_positions
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved
data["centcom_jobs"] = get_all_centcom_jobs()

data["fast_modify_region"] = is_skill_competent(user, list(/datum/skill/command = SKILL_LEVEL_PRO))
data["fast_full_access"] = is_skill_competent(user, list(/datum/skill/command = SKILL_LEVEL_MASTER))
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved

if (modify && is_centcom())
var/list/all_centcom_access = list()
for(var/access in get_all_centcom_access())
all_centcom_access.Add(list(list(
"desc" = replacetext(get_centcom_access_desc(access), " ", "&nbsp"),
"ref" = access,
"allowed" = (access in modify.access) ? 1 : 0)))

data["all_centcom_access"] = all_centcom_access
else if (modify)
var/list/regions = list()
for(var/i = 1; i <= 7; i++)
var/list/accesses = list()
var/region_allowed = 0
for(var/access in get_region_accesses(i))
if (get_access_desc(access))
region_allowed += (access in modify.access) ? 1 : 0
accesses.Add(list(list(
"desc" = replacetext(get_access_desc(access), " ", "&nbsp"),
switch(mode)
if(IDCOMPUTER_SCREEN_ACCESS)
if (modify && is_centcom())
var/list/all_centcom_access = list()
for(var/access in get_all_centcom_access())
all_centcom_access.Add(list(list(
"desc" = replacetext(get_centcom_access_desc(access), " ", "&nbsp"),
"ref" = access,
"allowed" = (access in modify.access) ? 1 : 0)))

regions.Add(list(list(
"name" = get_region_accesses_name(i),
"accesses" = accesses,
"id" = i,
"region_allowed" = (region_allowed == length(get_region_accesses(i)) ? 1 : 0))))

data["regions"] = regions

ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
if (!ui)
ui = new(user, src, ui_key, "identification_computer.tmpl", src.name, 600, 700)
ui.set_initial_data(data)
ui.open()

/obj/machinery/computer/card/Topic(href, href_list)
data["all_centcom_access"] = all_centcom_access
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved
else if (modify)
var/list/regions = list()
for(var/i = 1; i <= 7; i++)
var/list/accesses = list()
var/region_allowed = 0
for(var/access in get_region_accesses(i))
if (get_access_desc(access))
region_allowed += (access in modify.access) ? 1 : 0
accesses.Add(list(list(
"desc" = replacetext(get_access_desc(access), " ", "&nbsp"),
"ref" = access,
"allowed" = (access in modify.access) ? 1 : 0)))

regions.Add(list(list(
"name" = get_region_accesses_name(i),
"accesses" = accesses,
"id" = i,
"region_allowed" = (region_allowed == length(get_region_accesses(i)) ? 1 : 0))))

data["regions"] = regions

if(IDCOMPUTER_SCREEN_MANIFEST)

if(IDCOMPUTER_SCREEN_PRINT)
printing = 1
return data

/obj/machinery/computer/card/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
. = ..()
if(!.)
if(.)
return

switch(href_list["choice"])
switch(action)
if ("modify")
if (modify)
data_core.manifest_modify(modify.registered_name, modify.assignment)
Expand Down Expand Up @@ -209,28 +225,31 @@
H.sec_hud_set_ID()

if("access")
if(href_list["allowed"])
if(params["allowed"])
if(is_authenticated())
var/access_type = text2num(href_list["access_target"])
var/access_allowed = text2num(href_list["allowed"])
var/access_type = text2num(params["access_modify"])
var/access_allowed = text2num(params["allowed"])
if(access_type in (is_centcom() ? get_all_centcom_access() : get_all_accesses()))
modify.access -= access_type
if(!access_allowed)
modify.access += access_type
if("access_region")
if(is_authenticated())
var/region_id = text2num(href_list["region_id"])
var/region_id = text2num(params["region_id"])
var/region_accesses = get_region_accesses(region_id)
var/region_allowed = text2num(href_list["region_allowed"])
var/region_allowed = text2num(params["region_allowed"])
modify.access -= region_accesses
if(!region_allowed)
modify.access += region_accesses
if("access_full")
if(is_authenticated())
modify.access += get_all_accesses()
if("clear_all")
if(is_authenticated())
modify.access -= get_all_accesses()
if ("assign")
if (is_authenticated() && modify)
var/t1 = sanitize(href_list["assign_target"] , 45)
var/t1 = params["assign_modify"]
var/new_salary = 0
var/datum/job/jobdatum
if(t1 == "Custom")
Expand Down Expand Up @@ -260,36 +279,35 @@

if(datum_account)
datum_account.set_salary(new_salary, jobdatum.salary_ratio) //set the new salary equal to job

if ("reg")
if (is_authenticated())
if (Adjacent(usr) || issilicon(usr))
var/temp_name = sanitize_name(href_list["reg"])
var/temp_name = sanitize(input("Who is this ID for?", "Name", modify.registered_name) as text | null)
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved
if(temp_name)
modify.registered_name = temp_name
else
visible_message("<span class='notice'>[src] buzzes rudely.</span>")
nanomanager.update_uis(src)
SStgui.update_uis(src)
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved

if ("account")
if (is_authenticated())
if (Adjacent(usr) || issilicon(usr))
var/datum/money_account/account = get_account(text2num(href_list["account"]))
var/datum/money_account/account = sanitize_numbers(input("Account Number", "Input Number", modify.associated_account_number) as text | null)
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved
if(account)
modify.associated_account_number = account.account_number
modify.associated_account_number = account
else
to_chat(usr, "<span class='warning'> Account with such number does not exist!</span>")
nanomanager.update_uis(src)
SStgui.update_uis(src)
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved

if ("mode")
mode = text2num(href_list["mode_target"])
mode = text2num(params["mode"])
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved
Slavik2001 marked this conversation as resolved.
Show resolved Hide resolved

if ("print")
if (!printing)
printing = 1
spawn(50)
printing = null
nanomanager.update_uis(src)
SStgui.update_uis(src)

var/obj/item/weapon/paper/P = new(loc)
if (mode)
Expand Down
Loading
Loading