Skip to content

Commit

Permalink
modernize codex (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapu1178 authored Nov 19, 2023
1 parent faef521 commit 13e9ef8
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 94 deletions.
5 changes: 0 additions & 5 deletions code/controllers/subsystem/codex.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ SUBSYSTEM_DEF(codex)
// <span codexlink='keyword'>whatever</span> when shit gets tricky
linkRegex = regex(@"<(span|l)(\s+codexlink='([^>]*)'|)>([^<]+)</(span|l)>","g")

// used to remove trailing linebreaks when retrieving codex body.
// TODO: clean up codex page generation so this isn't necessary.
trailingLinebreakRegexStart = regex(@"^<\s*\/*\s*br\s*\/*\s*>", "ig")
trailingLinebreakRegexEnd = regex(@"<\s*\/*\s*br\s*\/*\s*>$", "ig")

// Create general hardcoded entries.
for(var/datum/codex_entry/entry as anything in subtypesof(/datum/codex_entry))
if(initial(entry.name) && !(isabstract(entry)))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/codex/categories/_codex_category.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
SHOULD_CALL_PARENT(TRUE)

if(length(items))
var/lore_text = desc + "<hr>"
var/lore_text = "<div style='text-align:center'>[desc]</div>" + "<hr>"
if(guide_name && guide_html)
lore_text += "This category has <span codexlink='Guide to [capitalize(guide_name || name)]'>an associated guide</span>.<hr>"

Expand Down
2 changes: 1 addition & 1 deletion code/modules/codex/categories/reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

var/datum/codex_entry/entry = new(
_display_name = "[initial(R.name)] (chemical)",
_lore_text = "[initial(R.description)] It apparently tastes of [initial(R.taste_description)]."
_lore_text = "&nbsp;&nbsp;&nbsp;&nbsp;[initial(R.description)] It apparently tastes of [initial(R.taste_description)]."
)

var/list/production_strings = list()
Expand Down
23 changes: 10 additions & 13 deletions code/modules/codex/entries/_codex_entry.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,34 +105,31 @@
for(var/datum/codex_category/category in categories)
. += category.get_category_link(src)

// TODO: clean up codex bodies until trimming linebreaks is unnecessary.
#define TRIM_LINEBREAKS(TEXT) replacetext(replacetext(TEXT, SScodex.trailingLinebreakRegexStart, null), SScodex.trailingLinebreakRegexEnd, null)
/datum/codex_entry/proc/get_codex_body(mob/presenting_to, include_header = TRUE, include_footer = TRUE)
RETURN_TYPE(/list)

. = list()
if(include_header && presenting_to)
var/header = get_codex_header(presenting_to)
if(length(header))
. += "<span class='dmCodexHeader'>"
. += "<div class='dmCodexHeader'>"
. += jointext(header, null)
. += "</span>"
. += "</div>"

. += "<span class='dmCodexBody'>"
. += "<div class='dmCodexBody'>"
if(lore_text)
. += "<p><span class='codexLore'>[TRIM_LINEBREAKS(lore_text)]</span></p>"
. += "<div class='codexLore'>[lore_text]</div>"
if(mechanics_text)
. += "<h3>OOC Information</h3>\n<p><span class='codexMechanics'>[TRIM_LINEBREAKS(mechanics_text)]</span></p>"
. += "<h3>OOC Information</h3><div class='codexMechanics'>[mechanics_text]</div>"
if(antag_text && (!presenting_to || (presenting_to.mind && !length(presenting_to.mind.antag_datums))))
. += "<h3>Antagonist Information</h3>\n<p><span class='codexAntag'>[TRIM_LINEBREAKS(antag_text)]</span></p>"
. += "<h3>Antagonist Information</h3><div class='codexAntag'>[antag_text]</div>"
if(controls_text)
. += "<h3>Controls</h3>\n<p><span class='codexControls'>[TRIM_LINEBREAKS(controls_text)]</span></p>"
. += "</span>"
. += "<h3>Controls</h3><div class='codexControls'>[controls_text]</div>"
. += "</div>"

if(include_footer)
var/footer = get_codex_footer(presenting_to)
if(length(footer))
. += "<span class='dmCodexFooter'>"
. += "<div class='dmCodexFooter'>"
. += footer
. += "</span>"
#undef TRIM_LINEBREAKS
. += "</div>"
52 changes: 32 additions & 20 deletions code/modules/codex/entries/atmospherics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
name = "Pipes"
associated_paths = list(/obj/machinery/atmospherics/pipe/smart/simple, /obj/machinery/atmospherics/pipe/smart/manifold, /obj/machinery/atmospherics/pipe/smart/manifold4w)
use_typesof = TRUE
mechanics_text = "All pipes can be connected or disconnected with a wrench. More pipes can be obtained from a pipe dispenser. \
<br>Some pipes, like scrubbers and supply pipes, do not connect to 'normal' pipes. If you want to connect them, use a universal adapter pipe. \
<br>Pipes generally do not exchange thermal energy with the environment (ie. they do not heat up or cool down their turf), but heat exchange pipes are an exception. \
<br>To join three or more pipe segments, you can use a pipe manifold."
mechanics_text = "&nbsp;&nbsp;&nbsp;&nbsp;All pipes can be connected or disconnected with a wrench. More pipes can be obtained from a pipe dispenser. \
Some pipes, like scrubbers and supply pipes, do not connect to 'normal' pipes. If you want to connect them, use a universal adapter pipe. \
Pipes generally do not exchange thermal energy with the environment (ie. they do not heat up or cool down their turf), but heat exchange pipes are an exception. \
To join three or more pipe segments, you can use a pipe manifold."
disambiguator = "atmospherics"

/datum/codex_entry/atmos_pipe/New(_display_name, list/_associated_paths, list/_associated_strings, _lore_text, _mechanics_text, _antag_text)
Expand All @@ -14,37 +14,42 @@
name = "Manual Valve"
associated_paths = list(/obj/machinery/atmospherics/components/binary/valve)
use_typesof = TRUE
mechanics_text = "Click this to turn the valve. If red, the pipes on each end are seperated. Otherwise, they are connected."
mechanics_text = "&nbsp;&nbsp;&nbsp;&nbsp;Click this to turn the valve. If red, the pipes on each end are seperated. Otherwise, they are connected."
disambiguator = "atmospherics"

/datum/codex_entry/atmos_pump
name = "Pressure Pump"
use_typesof = TRUE
associated_paths = list(/obj/machinery/atmospherics/components/binary/pump)
mechanics_text = "This moves gas from one pipe to another. A higher target pressure demands more energy. The side with the red end is the output."
mechanics_text = "&nbsp;&nbsp;&nbsp;&nbsp;This moves gas from one pipe to another. A higher target pressure demands more energy. The side with the red end is the output."
disambiguator = "atmospherics"

/datum/codex_entry/atmos_vent_pump
name = "Vent Pump"
use_typesof = TRUE
associated_paths = list(/obj/machinery/atmospherics/components/unary/vent_pump)
mechanics_text = "This pumps the contents of the attached pipe out into the atmosphere, if needed."
mechanics_text = "&nbsp;&nbsp;&nbsp;&nbsp;This pumps the contents of the attached pipe out into the atmosphere, if needed."
controls_text = "Multitool - Toggle Low-Power mode."
disambiguator = "atmospherics"

/datum/codex_entry/atmos_freezer
name = "Thermomachine"
use_typesof = TRUE
associated_paths = list(/obj/machinery/atmospherics/components/unary/thermomachine)
mechanics_text = "Adjusts the temperature of gas flowing through it. It uses massive amounts of electricity while on. \
It can be upgraded by replacing the capacitors, manipulators, and matter bins."
mechanics_text = {"
&nbsp;&nbsp;&nbsp;&nbsp;Adjusts the temperature of gas flowing through it.
<ul>
<li>It uses massive amounts of electricity while on.</li>
<li>It can be upgraded by replacing the capacitors, manipulators, and matter bins.<li>
</ul>
"}
disambiguator = "atmospherics"

/datum/codex_entry/atmos_vent_scrubber
name = "Vent Scrubber"
use_typesof = TRUE
associated_paths = list(/obj/machinery/atmospherics/components/unary/vent_scrubber)
mechanics_text = "This filters the atmosphere of harmful gas. Filtered gas goes to the pipes connected to it, typically a scrubber pipe. \
mechanics_text = "&nbsp;&nbsp;&nbsp;&nbsp;This filters the atmosphere of harmful gas. Filtered gas goes to the pipes connected to it, typically a scrubber pipe. \
It can be controlled from an Air Alarm. Has a mode to siphon much faster, using much more power in the process."
controls_text = "Multitool - Toggle Low-Power mode."
disambiguator = "atmospherics"
Expand All @@ -53,31 +58,38 @@
name = "Gas Canister" // because otherwise it shows up as 'canister: [caution]'
associated_paths = list(/obj/machinery/portable_atmospherics/canister)
use_typesof = TRUE
mechanics_text = "The canister can be connected to a connector port with a wrench. Tanks of gas (the kind you can hold in your hand) \
can be filled by the canister, by using the tank on the canister, increasing the release pressure, then opening the valve until it is full, and then close it. \
*DO NOT* remove the tank until the valve is closed. A gas analyzer can be used to check the contents of the canister."
antag_text = "Canisters can be damaged, spilling their contents into the air, or you can just leave the release valve open."
mechanics_text = {"
&nbsp;&nbsp;&nbsp;&nbsp;The canister can be connected to a connector port with a wrench. Tanks of gas (the kind you can hold in your hand)
can be filled by the canister, by using the tank on the canister, increasing the release pressure, then opening the valve until it is full, and then close it.
<br>
*DO NOT* remove the tank until the valve is closed.
<br>
A gas analyzer can be used to check the contents of the canister.
"}
antag_text = "&nbsp;&nbsp;&nbsp;&nbsp;Canisters can be damaged, spilling their contents into the air, or you can just leave the release valve open."
disambiguator = "atmospherics"

/datum/codex_entry/atmos_meter
name = "Gas Meter"
use_typesof = TRUE
associated_paths = list(/obj/machinery/meter)
mechanics_text = "Measures the volume and temperature of the pipe under the meter."
mechanics_text = "&nbsp;&nbsp;&nbsp;&nbsp;Measures the volume and temperature of the pipe under the meter.</span>"
disambiguator = "atmospherics"

/datum/codex_entry/transfer_valve
name = "Tank Transfer Valve"
associated_paths = list(/obj/item/transfer_valve)
mechanics_text = "This machine is used to merge the contents of two different gas tanks. Plug the tanks into the transfer, then open the valve to mix them together. You can also attach various assembly devices to trigger this process."
antag_text = "With a tank of hot hydrogen and cold oxygen, this benign little atmospheric device becomes an incredibly deadly bomb. You don't want to be anywhere near it when it goes off."
mechanics_text = "&nbsp;&nbsp;&nbsp;&nbsp;This machine is used to merge the contents of two different gas tanks. Plug the tanks into the transfer, then open the valve to mix them together. You can also attach various assembly devices to trigger this process."
antag_text = "&nbsp;&nbsp;&nbsp;&nbsp;With a tank of hot hydrogen and cold oxygen, this benign little atmospheric device becomes an incredibly deadly bomb. You don't want to be anywhere near it when it goes off."
disambiguator = "component"

/datum/codex_entry/gas_analyzer
name = "Gas Analyzer"
use_typesof = TRUE
associated_paths = list(/obj/item/analyzer) //:(
mechanics_text = "A device that analyzes the gas contents of a tile or atmospherics devices. Has 3 modes: Default operates without \
additional output data; Moles and volume shows the moles per gas in the mixture and the total moles and volume; Gas \
traits and data describes the traits per gas, how it interacts with the world, and some of its property constants."
mechanics_text = {"
&nbsp;&nbsp;&nbsp;&nbsp;A device that analyzes the gas contents of a tile or atmospherics devices. Has 3 modes: Default operates without
additional output data; Moles and volume shows the moles per gas in the mixture and the total moles and volume; Gas
traits and data describes the traits per gas, how it interacts with the world, and some of its property constants.
"}
disambiguator = "equipment"
33 changes: 20 additions & 13 deletions code/modules/codex/entries/codex.dm
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
/datum/codex_entry/codex
name = "The Codex"
lore_text = "The Codex is the overall body containing the document that you are currently reading. It is a distributed encyclopedia maintained by a dedicated, hard-working staff of journalists, bartenders, hobos, space pirates and xeno-intelligences, all with the goal of providing you, the user, with supposedly up-to-date, nominally useful documentation on the topics you want to know about. \
<br><br> \
Access to the Codex is afforded instantly by a variety of unobtrusive devices, including PDA attachments, retinal implants, neuro-memetic indoctrination and hover-drone. All our access devices are affordable, stylish and guaranteed not to expose you to encephalo-malware. \
<br><br> \
The Codex editorial offices are located in Venus orbit and will offer cash payments for stories, anecdotes and evidence of the strange and undocumented miscellany cluttering up our observable universe. Remember our motto: <i>\"Knowledge is power, sell your excess.\"</i>"
lore_text = {"
&nbsp;&nbsp;&nbsp;&nbsp;The Codex is the overall body containing the document that you are currently reading.
It is a distributed encyclopedia maintained by a dedicated, hard-working staff of journalists, bartenders, hobos, space pirates and xeno-intelligences,
all with the goal of providing you, the user, with supposedly up-to-date, nominally useful documentation on the topics you want to know about.
<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;Access to the Codex is afforded instantly by a variety of unobtrusive devices, including PDA attachments, retinal implants, neuro-memetic indoctrination and hover-drone. All our access devices are affordable, stylish and guaranteed not to expose you to encephalo-malware. \
<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;The Codex editorial offices are located in Venus orbit and will offer cash payments for stories, anecdotes and evidence of the strange and undocumented miscellany cluttering up our observable universe. Remember our motto: <i>\"Knowledge is power, sell your excess.\"</i>
"}

/datum/codex_entry/codex/New()
mechanics_text = "The Codex is both an IC and OOC resource. ICly, it is as described; a space encyclopedia. You can use <b>Search-Codex <i>topic</i></b> to look something up, or you can click the links provided when examining some objects. \
<br><br> \
Any of the lore you find in the Codex, designated by <span class='codexLore'>green</span> text, can be freely referenced in-character. \
<br><br> \
OOC information on various mechanics and interactions is marked by <span class='codexMechanics'>blue</span> text. \
<br><br> \
Information for antagonists will not be shown unless you are an antagonist, and is marked by <span class='codexAntag'>red</span> text."
mechanics_text = {"
&nbsp;&nbsp;&nbsp;&nbsp;The Codex is both an IC and OOC resource.
ICly, it is as described; a space encyclopedia. You can use <b>Search-Codex <i>topic</i></b> to look something up,
or you can click the links provided when examining some objects.
<ul>
<li>* Any of the lore you find in the Codex, designated by <span class='codexLore'>green</span> text, can be freely referenced in-character.</li>
<li>* OOC information on various mechanics and interactions is marked by <span class='codexMechanics'>blue</span> text.</li>
<li>* Information for antagonists will not be shown unless you are an antagonist, and is marked by <span class='codexAntag'>red</span> text.</li>
</ul>
"}
..()

/datum/codex_entry/nexus
name = "Nexus"
mechanics_text = "The place to start with <span codexlink='the codex'>The Codex</span><br>"
mechanics_text = "&nbsp;&nbsp;&nbsp;&nbsp;The place to start with <span codexlink='the codex'>The Codex</span><br>"

/datum/codex_entry/nexus/get_codex_body(mob/presenting_to, include_header, include_footer)
. = list("<span class = 'codexMechanics'>")
Expand Down
2 changes: 1 addition & 1 deletion code/modules/codex/entries/machinery.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/datum/codex_entry/airlock
associated_paths = list(/obj/machinery/door/airlock)
mechanics_text = "An airtight mechanical door. Most airlocks require an ID to open (wearing it on your ID slot is enough), and many have special access requirements to be on your ID. You can open an airlock by clicking on one, or simply walking into it, and clicking on an open airlock will close it. If the lights on the door flash red, you don't have the required access to open the airlock, and if they're consistently red, the door is bolted. Airlocks also require power to operate. In a situation without power, a crowbar can be used to force it open. <BR><BR>Airlocks can also be <span codexlink='hacking'>hacked</span>.<BR>Airlock hacking information:<BR>* Door bolts will lock the door, preventing it from being opened by any means until the bolts are raised again. Pulsing the correct wire will toggle the bolts, but cutting it will only drop them.<BR>* IDscan light indicates the door can scan ID cards. If the wire for this is pulsed it will cause the door to flash red, and cutting it will cause doors with restricted access to be unable to scan ID, essentially locking it.<BR>* The AI control light shows whether or not AI and robots can control the door. Pulsing is only temporary, while cutting is more permanent.<BR>* The test light shows whether the door has power or not. When turned off, the door can be opened with a crowbar.<BR>* If the door sparks, it is electrified. Pulsing the corresponding wire causes this to happen for 30 seconds, and cutting it electrifies the door until mended.<BR>* The check wiring light will turn on if the safety is turned off. This causes the airlock to close even when someone is standing on it, crushing them.<BR>* If the Check Timing Mechanism light is on then the door will close much faster than normal. Dangerous in conjuction with the Check Wiring light.<BR><BR><B>Deconstruction</B><BR>To pull apart an airlock, you must open the maintenance panel, disable the power via hacking (or any other means), weld the door shut, and crowbar the electroncs out, cut the wires with a wirecutter, unsecure the whole assembly with a wrench, and then cut it into metal sheets with a welding tool."
antag_text = "Electrifying a door makes for a good trap, hurting and stunning whoever touches it. The same goes for a combination of disabling the safety and timing mechanisms. Bolting a door can also help ensure privacy, or slow down those in search of you. It's also a good idea to disable AI interaction when needed."
antag_text = "&nbsp;&nbsp;&nbsp;&nbsp;Electrifying a door makes for a good trap, hurting and stunning whoever touches it. The same goes for a combination of disabling the safety and timing mechanisms. Bolting a door can also help ensure privacy, or slow down those in search of you. It's also a good idea to disable AI interaction when needed."
disambiguator = "machine"
Loading

0 comments on commit 13e9ef8

Please sign in to comment.