|
| 1 | +#define TAB_ARCHIVES 1 |
| 2 | +#define TAB_RUNES 2 |
| 3 | + |
1 | 4 | /// Arcane tomes are the quintessential cultist "tool" and are used to draw runes, smack things with, and other such things.
|
2 | 5 | /// The interface they open (ArcaneTome.js) also contains a lot of in-game documentation about how the antagonist works.
|
3 | 6 | /obj/item/arcane_tome
|
|
17 | 20 | pickup_sound = 'sound/items/pickup/book.ogg'
|
18 | 21 | /// How long it takes to draw a rune using this tome. Non-positive values are instant.
|
19 | 22 | var/scribe_speed = 5 SECONDS
|
| 23 | + /// This tome's selected UI tab. |
| 24 | + var/selected_tab = TAB_ARCHIVES |
| 25 | + var/archives_entry = 0 |
| 26 | + var/compact_mode = FALSE |
20 | 27 |
|
21 | 28 | /obj/item/arcane_tome/get_examine_desc()
|
22 | 29 | if (iscultist(usr) || isobserver(usr))
|
|
27 | 34 | /obj/item/arcane_tome/attack_self(mob/user)
|
28 | 35 | if (!iscultist(user))
|
29 | 36 | to_chat(user, "The book is full of illegible scribbles and crudely-drawn shapes. Is this a joke...?")
|
30 |
| - tgui_interact(user) |
| 37 | + ui_interact(user) |
31 | 38 |
|
32 |
| -/obj/item/arcane_tome/tgui_interact(mob/user, datum/tgui/ui, datum/tgui/parent_ui) |
| 39 | +/obj/item/arcane_tome/ui_interact(mob/user, ui_key, datum/nanoui/ui, force_open, master_ui, datum/topic_state/state) |
33 | 40 | if (!iscultist(user))
|
34 | 41 | return
|
35 |
| - ui = SStgui.try_update_ui(user, src, ui) |
| 42 | + var/dat = ui_data() |
| 43 | + ui = SSnanoui.try_update_ui(user, src, ui_key, ui, dat, force_open = force_open) |
36 | 44 | if (!ui)
|
37 |
| - ui = new(user, src, "ArcaneTome", name) |
| 45 | + archives_entry = 0 |
| 46 | + dat["archives_entry"] = selected_tab |
| 47 | + ui = new(user, src, ui_key, "arcane_tome.tmpl", "Arcane Tome", 500, 600) |
| 48 | + ui.set_initial_data(dat) |
38 | 49 | ui.open()
|
39 | 50 | playsound(user, 'sound/bureaucracy/bookopen.ogg', 25, TRUE)
|
40 | 51 |
|
41 |
| -/obj/item/arcane_tome/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state) |
42 |
| - var/list/data = list() |
43 |
| - |
44 |
| - var/list/rune_data = list() |
| 52 | +/obj/item/arcane_tome/proc/ui_data() |
| 53 | + var/dat[0] |
| 54 | + var/runes[0] |
45 | 55 | for (var/V in subtypesof(/obj/effect/rune))
|
46 | 56 | var/obj/effect/rune/NR = V
|
47 | 57 | if (!initial(NR.can_write))
|
48 | 58 | continue
|
49 | 59 | var/obj/item/paper/talisman/T = initial(NR.talisman_path)
|
50 |
| - rune_data += list(list( |
| 60 | + runes[++runes.len] = list( |
51 | 61 | "name" = initial(NR.rune_name),
|
52 | 62 | "invokers" = initial(NR.required_invokers),
|
53 | 63 | "talisman" = T ? initial(T.tome_desc) : null,
|
54 | 64 | "shorthand" = initial(NR.rune_shorthand) ? initial(NR.rune_shorthand) : initial(NR.rune_desc),
|
55 | 65 | "typepath" = NR
|
56 |
| - )) |
57 |
| - data["runes"] = rune_data |
58 |
| - |
59 |
| - return data |
| 66 | + ) |
| 67 | + dat["runes"] = runes |
| 68 | + dat["selected_tab"] = selected_tab |
| 69 | + dat["archives_entry"] = archives_entry |
| 70 | + dat["compact_mode"] = compact_mode |
| 71 | + return dat |
60 | 72 |
|
61 |
| -/obj/item/arcane_tome/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state) |
62 |
| - if (..()) |
| 73 | +/obj/item/arcane_tome/Topic(href, href_list, datum/topic_state/state) |
| 74 | + if (..() || !iscultist(usr)) |
63 | 75 | return TRUE
|
64 |
| - switch (action) |
65 |
| - if ("turnPage") |
66 |
| - playsound(src, "pageturn", 25, TRUE) |
67 |
| - if ("writeRune") |
68 |
| - var/obj/effect/rune/R = text2path(params["runePath"]) |
69 |
| - if (!ispath(R, /obj/effect/rune)) |
70 |
| - return |
| 76 | + if (href_list["switch_tab"]) |
| 77 | + selected_tab = text2num(href_list["switch_tab"]) |
| 78 | + playsound(src, "pageturn", 25, TRUE) |
| 79 | + if (href_list["switch_archive"]) |
| 80 | + archives_entry = text2num(href_list["switch_archive"]) |
| 81 | + playsound(src, "pageturn", 25, TRUE) |
| 82 | + if (href_list["compact_mode"]) |
| 83 | + compact_mode = !compact_mode |
| 84 | + if (href_list["write_rune"]) |
| 85 | + var/obj/effect/rune/R = text2path(href_list["write_rune"]) |
| 86 | + if (ispath(R, /obj/effect/rune)) |
71 | 87 | scribe_rune(usr, R)
|
72 |
| - return |
| 88 | + SSnanoui.update_uis(src) |
73 | 89 |
|
74 | 90 | /obj/item/arcane_tome/attack(mob/living/M, mob/living/user, target_zone, attack_modifier)
|
75 | 91 | // This is basically a reimplementation of weapon logic for cultists only
|
|
130 | 146 | var/obj/effect/rune/NR = new rune_type (get_turf(user))
|
131 | 147 | NR.after_scribe(user)
|
132 | 148 |
|
133 |
| -/obj/item/arcane_tome/admin |
134 |
| - scribe_speed = 0 // Instant |
| 149 | +/// Debug tome that automatically converts someone on pickup. Should never appear regularly. |
| 150 | +/obj/item/arcane_tome/debug |
| 151 | + scribe_speed = 1 SECOND // Not quite instant, but close to it |
| 152 | + |
| 153 | +/obj/item/arcane_tome/debug/pickup() |
| 154 | + . = ..() |
| 155 | + if (usr.mind) |
| 156 | + cult.add_antagonist(usr.mind) |
| 157 | + |
| 158 | +#undef TAB_ARCHIVES |
| 159 | +#undef TAB_RUNES |
0 commit comments