Skip to content

Commit ac55899

Browse files
author
Ava
committed
Start work on nanoui iteration at the request of ater
1 parent 8eb46f4 commit ac55899

File tree

4 files changed

+133
-38
lines changed

4 files changed

+133
-38
lines changed

code/game/gamemodes/cult/arcane_tome.dm

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#define TAB_ARCHIVES 1
2+
#define TAB_RUNES 2
3+
14
/// Arcane tomes are the quintessential cultist "tool" and are used to draw runes, smack things with, and other such things.
25
/// The interface they open (ArcaneTome.js) also contains a lot of in-game documentation about how the antagonist works.
36
/obj/item/arcane_tome
@@ -17,6 +20,10 @@
1720
pickup_sound = 'sound/items/pickup/book.ogg'
1821
/// How long it takes to draw a rune using this tome. Non-positive values are instant.
1922
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
2027

2128
/obj/item/arcane_tome/get_examine_desc()
2229
if (iscultist(usr) || isobserver(usr))
@@ -27,49 +34,58 @@
2734
/obj/item/arcane_tome/attack_self(mob/user)
2835
if (!iscultist(user))
2936
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)
3138

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)
3340
if (!iscultist(user))
3441
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)
3644
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)
3849
ui.open()
3950
playsound(user, 'sound/bureaucracy/bookopen.ogg', 25, TRUE)
4051

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]
4555
for (var/V in subtypesof(/obj/effect/rune))
4656
var/obj/effect/rune/NR = V
4757
if (!initial(NR.can_write))
4858
continue
4959
var/obj/item/paper/talisman/T = initial(NR.talisman_path)
50-
rune_data += list(list(
60+
runes[++runes.len] = list(
5161
"name" = initial(NR.rune_name),
5262
"invokers" = initial(NR.required_invokers),
5363
"talisman" = T ? initial(T.tome_desc) : null,
5464
"shorthand" = initial(NR.rune_shorthand) ? initial(NR.rune_shorthand) : initial(NR.rune_desc),
5565
"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
6072

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))
6375
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))
7187
scribe_rune(usr, R)
72-
return
88+
SSnanoui.update_uis(src)
7389

7490
/obj/item/arcane_tome/attack(mob/living/M, mob/living/user, target_zone, attack_modifier)
7591
// This is basically a reimplementation of weapon logic for cultists only
@@ -130,5 +146,14 @@
130146
var/obj/effect/rune/NR = new rune_type (get_turf(user))
131147
NR.after_scribe(user)
132148

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

nano/images/uiBackground-Cult.png

233 KB
Loading

nano/js/nano_base_helpers.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ NanoBaseHelpers = function ()
1515

1616
return '';
1717
},
18+
19+
// As above, but for culty stuff
20+
spookyMode: function() {
21+
$('body').css("color", "#9A9A9A");
22+
$('body').css("background-color", "#0D0C0C");
23+
$('body').css("background-image", "url('uiBackground-Cult.png')");
24+
$('body').css("background-position", "50% 0");
25+
$('body').css("background-repeat", "repeat-x");
26+
27+
$('#uiTitleText').css("color", "#777777");
28+
// Hide the NT icon completely
29+
$('#uiTitleFluff').css("width", "0px");
30+
$('#uiTitleFluff').css("height", "0px");
31+
return '';
32+
},
1833
// Generate a Byond link
1934
link: function( text, icon, parameters, status, elementClass, elementId) {
2035

@@ -129,12 +144,12 @@ NanoBaseHelpers = function ()
129144
{
130145
showText = '';
131146
}
132-
147+
133148
if (typeof difClass == 'undefined' || !difClass)
134149
{
135150
difClass = ''
136151
}
137-
152+
138153
if(typeof direction == 'undefined' || !direction)
139154
{
140155
direction = 'width'
@@ -143,9 +158,9 @@ NanoBaseHelpers = function ()
143158
{
144159
direction = 'height'
145160
}
146-
161+
147162
var percentage = Math.round((value - rangeMin) / (rangeMax - rangeMin) * 100);
148-
163+
149164
return '<div class="displayBar' + difClass + ' ' + styleClass + '"><div class="displayBar' + difClass + 'Fill ' + styleClass + '" style="' + direction + ': ' + percentage + '%;"></div><div class="displayBar' + difClass + 'Text ' + styleClass + '">' + showText + '</div></div>';
150165
},
151166
// Display DNA Blocks (for the DNA Modifier UI)
@@ -203,7 +218,7 @@ NanoBaseHelpers = function ()
203218
return html;
204219
}
205220
};
206-
221+
207222
return {
208223
addHelpers: function ()
209224
{
@@ -217,14 +232,7 @@ NanoBaseHelpers = function ()
217232
{
218233
NanoTemplate.removeHelper(helperKey);
219234
}
220-
}
235+
}
221236
}
222237
};
223238
} ();
224-
225-
226-
227-
228-
229-
230-

nano/templates/arcane_tome.tmpl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{:helper.spookyMode()}}
2+
{{:helper.link("Archives", null, { 'switch_tab': 1 }, data.selected_tab == 1 ? 'selected' : null)}}
3+
{{:helper.link("Runes", null, { 'switch_tab': 2 }, data.selected_tab == 2 ? 'selected' : null)}}
4+
<br/><br/>
5+
{{if data.selected_tab == 1}}
6+
<i>You are a cultist of <b>Nar-Sie</b>, the One who Sees, the Geometer of Blood. It has revealed to you the fact of Its existence by necessity, and graciously inducted you into Its followers so that you may better serve Its will.
7+
<br/><br/>
8+
These archives serve as an <b>out-of-character</b> knowledge base for information about the cult, how your abilities work, and your ultimate goals. Refer back to it any time you are lost!</i>
9+
<br/><hr/>
10+
{{:helper.link("What is this?", null, { 'switch_archive' : 1 }, data.archives_entry == 1 ? 'selected' : null)}}
11+
{{:helper.link("What are runes?", null, { 'switch_archive' : 2 }, data.archives_entry == 2 ? 'selected' : null)}}
12+
{{:helper.link("What are talismans?", null, { 'switch_archive' : 3 }, data.archives_entry == 3 ? 'selected' : null)}}
13+
{{:helper.link("What should I do?", null, { 'switch_archive' : 4 }, data.archives_entry == 4 ? 'selected' : null)}}
14+
<br/><br/>
15+
{{if data.archives_entry == 1}}
16+
You are holding an <b>arcane tome</b>, a book that contains the rites and scriptures of the Geometer. <b>Every cultist should have a tome unless they have a good reason not to.</b> In addition to this informational page, you can browse <b>Runes</b> within a dedicated section of the tome, allowing you to see their functions or scribe them onto the ground.
17+
<br /><br />
18+
If need be, your tome can serve as a weapon as well. Simply switch to Harm intent and attack your foes with it to deal burn damage. Naturally, it will be abundantly obvious to the target that you are doing something otherworldly and very harmful.
19+
{{else data.archives_entry == 2}}
20+
<b>Runes</b> are eldritch scrawlings, etched with precise shapes and words to invoke the power of Nar-Sie. They are the primary source of your power as a cultist, and they allow you to perform anomalous feats alike to magic. Some runes can be made into <b>talismans</b> that offer something akin to their abilities in a more portable form.
21+
<br /><br />
22+
There are many different types of rune, each with their own functions and methods of use. In order to create a rune, you use your own blood, meaning that you will take a small amount of damage each time you create one. To invoke a rune, simply click on it with an empty hand.
23+
<br /><br />
24+
Runes are naturally very conspicuous, and you should be careful to keep them well-hidden to avoid drawing unnecessary suspicion. You can erase a rune by clicking on it with your tome - leaving no trace of its existence - or just mop it up like any regular spill.
25+
<br /><br />
26+
Notably, AIs cannot perceive runes. Instead, they just see them as a regular pool of blood. That is still conspicuous in its own right, mind you!
27+
{{else data.archives_entry == 3}}
28+
Runes are essential for success, but they can be difficult to lay down quickly. <b>Talismans</b> can be of use there; by invoking the <i>Imbue Talisman</i> rune with a blank sheet of paper on top and a relevant rune nearby, that rune can be inscribed onto the paper, which can then be activated at any time to mirror its effects.
29+
<br /><br />
30+
The effects of talismans are usually equivalent to that of their respective rune, but weaker. Some, however, can be vastly different; the Stun talisman, for instance, causes a heavy stun to a single target struck with the talisman, instead of disorienting everyone nearby. Cultists starting aboard the station are equipped with a special Supply talisman that allows them to make certain talismans for free or to create soul shards and construct shells.
31+
{{else data.archives_entry == 4}}
32+
Depends! Stealth and infiltration are your best ally, so unless you have already been ousted, it is never a bad idea to simply go back to what you were doing as if nothing had transpired. You can keep in touch with other cultists across distances and z-levels by using a <i>Communicate</i> rune, and coordinating in this manner is very important.
33+
<br /><br />
34+
When you feel ready to introduce more people to the fold, you should go about it carefully. The <i>Convert</i> rune is opt-in - the convertee can simply keep refusing to join the cult and will take increasing damage instead - so above all else, remember to <b>roleplay</b> and make it an interesting experience. Avoid just stunning someone and dragging them to the rune - lead up to it. Talk to them, manipulate them. Make their conversion <i>mean</i> something.
35+
{{/if}}
36+
{{else data.selected_tab == 2}}
37+
{{:helper.link(data.compact_mode ? "Switch to standard display" : "Switch to compact display", null, { "compact_mode" : 1 })}}
38+
<br/><hr/>
39+
{{if !data.compact_mode}}
40+
{{for data.runes}}
41+
<div class="item">
42+
<div class="itemLabel">
43+
{{:helper.link(value.name, null, { "write_rune" : value.typepath })}}
44+
</div>
45+
<div class="itemContent">
46+
{{:value.shorthand}}
47+
{{if value.talisman}}
48+
<br/><br/><b><i>Talisman effect - </i></b>{{:value.talisman}}
49+
{{/if}}
50+
</div>
51+
</div>
52+
<hr/>
53+
{{/for}}
54+
{{else}}
55+
<div align="center">
56+
<i>Entries marked with an asterisk (*) can be made into a talisman.</i><br /><br />
57+
{{for data.runes}}
58+
{{:helper.link(value.talisman ? value.name + " *" : value.name, null, { "write_rune" : value.typepath })}}
59+
{{/for}}
60+
</div>
61+
{{/if}}
62+
{{/if}}

0 commit comments

Comments
 (0)