forked from DaedalusDock/daedalusdock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodex_client.dm
94 lines (71 loc) · 2.86 KB
/
codex_client.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/client
var/codex_cooldown = FALSE
/client/verb/search_codex(searching as text)
set name = "Search Codex"
set category = "IC"
set src = usr
if(!mob || !SScodex)
return
if(codex_cooldown >= world.time)
to_chat(src, span_warning("You cannot perform codex actions currently."))
return
if(!searching)
searching = input("Enter a search string.", "Codex Search") as text|null
if(!searching)
return
codex_cooldown = world.time + 1 SECONDS
var/list/found_entries = SScodex.retrieve_entries_for_string(searching)
if(mob && mob.mind && !length(mob.mind.antag_datums))
found_entries = found_entries.Copy() // So we aren't messing with the codex search cache.
for(var/datum/codex_entry/entry in found_entries)
if(entry.antag_text && !entry.mechanics_text && !entry.lore_text)
found_entries -= entry
switch(LAZYLEN(found_entries))
if(null)
to_chat(src, span_alert("The codex reports <b>no matches</b> for '[searching]'."))
if(1)
SScodex.present_codex_entry(mob, found_entries[1])
else
SScodex.present_codex_search(mob, found_entries, searching)
/client/verb/list_codex_entries()
set name = "List Codex Entries"
set category = "IC"
set src = usr
if(!mob || !SScodex.initialized)
return
if(codex_cooldown >= world.time)
to_chat(src, span_warning("You cannot perform codex actions currently."))
return
codex_cooldown = world.time + 1 SECONDS
var/datum/browser/popup = new(mob, "codex", "Codex Index") //"codex-index"
var/datum/codex_entry/nexus = SScodex.get_codex_entry(/datum/codex_entry/nexus)
var/list/codex_data = list(nexus.get_codex_header(mob).Join(), "<h2>Codex Entries</h2>")
codex_data += "<table width = 100%>"
var/antag_check = mob && mob.mind && length(mob.mind.antag_datums)
var/last_first_letter
for(var/thing in SScodex.index_file)
var/datum/codex_entry/entry = SScodex.index_file[thing]
if(!antag_check && entry.antag_text && !entry.mechanics_text && !entry.lore_text && !entry.controls_text)
continue
var/first_letter = uppertext(copytext(thing, 1, 2))
if(first_letter != last_first_letter)
last_first_letter = first_letter
codex_data += "<tr><td colspan = 2><hr></td></tr>"
codex_data += "<tr><td colspan = 2>[last_first_letter]</td></tr>"
codex_data += "<tr><td colspan = 2><hr></td></tr>"
codex_data += "<tr><td>[thing]</td><td><a href='?src=\ref[SScodex];show_examined_info=\ref[SScodex.index_file[thing]];show_to=\ref[mob]'>View</a></td></tr>"
codex_data += "</table>"
popup.set_content(codex_data.Join())
popup.open()
/client/verb/codex()
set name = "Codex"
set category = "IC"
set src = usr
if(!SScodex.initialized)
return
if(codex_cooldown >= world.time)
to_chat(src, span_warning("You cannot perform codex actions currently."))
return
codex_cooldown = world.time + 1 SECONDS
var/datum/codex_entry/entry = SScodex.get_codex_entry("nexus")
SScodex.present_codex_entry(mob, entry)