forked from Aurorastation/Aurora.3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chemistry codex - VueUI edition (Aurorastation#9413)
Mostly contains fuzzy search what should make search experence nice and responsive. Data generation assumes rections do not change.
- Loading branch information
1 parent
4f1b29f
commit 7cbc3bd
Showing
8 changed files
with
196 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
code/modules/modular_computers/file_system/programs/research/chemistry_codex.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/datum/computer_file/program/chemistry_codex | ||
filename = "chemcodex" | ||
filedesc = "Chemistry codex" | ||
program_icon_state = "generic" | ||
extended_desc = "Useful program to view chemical reactions and how to make them." | ||
size = 14 | ||
required_access_run = access_medical | ||
required_access_download = access_medical | ||
available_on_ntnet = TRUE | ||
|
||
/datum/computer_file/program/chemistry_codex/ui_interact(mob/user) | ||
var/datum/vueui/ui = SSvueui.get_open_ui(user, src) | ||
if (!ui) | ||
ui = new /datum/vueui/modularcomputer(user, src, "mcomputer-chemcodex", 450, 600, filedesc) | ||
ui.open() | ||
|
||
/datum/computer_file/program/chemistry_codex/vueui_transfer(oldobj) | ||
SSvueui.transfer_uis(oldobj, src, "mcomputer-chemcodex", 450, 600, filedesc) | ||
return TRUE | ||
|
||
// Gathers data for ui. This is not great vueui example, all data sent from server is static. | ||
/datum/computer_file/program/chemistry_codex/vueui_data_change(var/list/data, var/mob/user, var/datum/vueui/ui) | ||
. = ..() | ||
data = . || data || list() | ||
// Gather data for computer header | ||
var/headerdata = get_header_data(data["_PC"]) | ||
if(headerdata) | ||
data["_PC"] = headerdata | ||
. = data | ||
|
||
// Here goes listification | ||
if(data["reactions"] == null) | ||
. = data | ||
data["reactions"] = SSchemistry.codex_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
author: Karolis2011 | ||
|
||
delete-after: True | ||
|
||
changes: | ||
- rscadd: "Added chemical codex program, that tells chemists about possible reactions." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<template> | ||
<div> | ||
<vui-input-search :input="s.reactions" v-model="output" :keys="['result.name', 'reagents.name', 'result.description']" autofocus :threshold="threshold" include-score/> | ||
<vui-button @click="desc = !desc">Toggle descriptions</vui-button> | ||
<div class="recipe-block" v-for="reac in output" :key="reac.item.id" :style="{opacity: 1 - (reac.score * score_multiplier)}"> | ||
<h2 class="highlight">{{ reac.item.result.name }} ({{ u(reac.item.result.amount) }})</h2> | ||
<p v-show="desc">{{ reac.item.result.description }}</p> | ||
<h3 class="highlight">Required Reagents</h3> | ||
<span v-for="r in reac.item.reagents" :key="'re'+r.name+reac.item.result.name">{{ r.name }}: {{ u(r.amount) }}<br></span> | ||
<template v-if="reac.item.catalysts.length"> | ||
<h3 class="highlight">Catalysts</h3> | ||
<span v-for="r in reac.item.catalysts" :key="'ca'+r.name+reac.item.result.name">{{ r.name }}: {{ u(r.amount) }}<br></span> | ||
</template> | ||
<template v-if="reac.item.inhibitors.length"> | ||
<h3 class="highlight">Inhibitors</h3> | ||
<span v-for="r in reac.item.inhibitors" :key="'in'+r.name+reac.item.result.name">{{ r.name }}: {{ u(r.amount) }}<br></span> | ||
</template> | ||
<template v-if="reac.item.temp_min.length"> | ||
<h3 class="highlight">Minimum required temparatures</h3> | ||
<span v-for="t in reac.item.temp_min" :key="'tm'+t.name+reac.item.result.name">{{ t.name }}: {{ t.temp }}°K<br></span> | ||
</template> | ||
<template v-if="reac.item.temp_max.length"> | ||
<h3 class="highlight">Maximum required temparatures</h3> | ||
<span v-for="t in reac.item.temp_max" :key="'tx'+t.name+reac.item.result.name">{{ t.name }}: {{ t.temp }}°K<br></span> | ||
</template> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
s: this.$root.$data.state, | ||
output: [], | ||
threshold: 0.3, | ||
desc: true | ||
} | ||
}, | ||
methods: { | ||
u(num) { | ||
if(num == 1) { | ||
return `${num} unit` | ||
} else { | ||
return `${num} units` | ||
} | ||
} | ||
}, | ||
computed: { | ||
score_multiplier() { | ||
return 1 / this.threshold | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.recipe-block { | ||
h2, h3 { | ||
padding: 2px 0; | ||
} | ||
background-color: rgba(0, 0, 0, 0); | ||
border-bottom: 2px solid transparent; | ||
transition: background-color 0.2s, color 0.2s border-bottom 0.2s; | ||
padding: 2px; | ||
&:hover { | ||
background-color: rgba(0, 0, 0, 0.5); | ||
border-bottom: 2px solid #4f7c9e; | ||
} | ||
} | ||
</style> |