mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-31 00:49:06 +01:00
VueUI Canisters (#10800)
This commit is contained in:
@@ -329,7 +329,7 @@ update_flag
|
||||
..()
|
||||
|
||||
update_icon()
|
||||
SSnanoui.update_uis(src) // Update all NanoUIs attached to src
|
||||
SSvueui.check_uis_for_change(src) // Update all VueUIs attached to src
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/attack_ai(var/mob/user as mob)
|
||||
if(!ai_can_interact(user))
|
||||
@@ -339,37 +339,36 @@ update_flag
|
||||
/obj/machinery/portable_atmospherics/canister/attack_hand(var/mob/user as mob)
|
||||
return src.ui_interact(user)
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if (src.destroyed)
|
||||
/obj/machinery/portable_atmospherics/canister/ui_interact(mob/user)
|
||||
if(src.destroyed)
|
||||
return
|
||||
|
||||
// this is the data which will be sent to the ui
|
||||
var/data[0]
|
||||
data["name"] = name
|
||||
data["canLabel"] = can_label ? 1 : 0
|
||||
data["portConnected"] = connected_port ? 1 : 0
|
||||
data["tankPressure"] = round(air_contents.return_pressure() ? air_contents.return_pressure() : 0)
|
||||
data["releasePressure"] = round(release_pressure ? release_pressure : 0)
|
||||
data["minReleasePressure"] = round(ONE_ATMOSPHERE/10)
|
||||
data["maxReleasePressure"] = round(10*ONE_ATMOSPHERE)
|
||||
data["valveOpen"] = valve_open ? 1 : 0
|
||||
|
||||
data["hasHoldingTank"] = holding ? 1 : 0
|
||||
if (holding)
|
||||
data["holdingTank"] = list("name" = holding.name, "tankPressure" = round(holding.air_contents.return_pressure()))
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
var/datum/vueui/ui = SSvueui.get_open_ui(user, src)
|
||||
if (!ui)
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "canister.tmpl", "Canister", 480, 400)
|
||||
// when the ui is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
ui = new(user, src, "machinery-atmospherics-canister", 480, 400, "Canister", state = interactive_state)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(1)
|
||||
ui.auto_update_content = TRUE
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/vueui_data_change(list/data, mob/user, datum/vueui/ui)
|
||||
data = ..() || list()
|
||||
|
||||
// this is the data which will be sent to the ui
|
||||
data["name"] = name
|
||||
data["canLabel"] = can_label
|
||||
data["portConnected"] = !!connected_port
|
||||
data["tankPressure"] = round(air_contents.return_pressure() || 0)
|
||||
data["releasePressure"] = round(release_pressure || 0)
|
||||
data["minReleasePressure"] = round(ONE_ATMOSPHERE/10)
|
||||
data["maxReleasePressure"] = round(10*ONE_ATMOSPHERE)
|
||||
data["valveOpen"] = valve_open
|
||||
|
||||
data["hasHoldingTank"] = !!holding
|
||||
if (holding)
|
||||
data["holdingTank"] = list("name" = holding.name, "tankPressure" = round(holding.air_contents.return_pressure()))
|
||||
return data
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/Topic(href, href_list)
|
||||
|
||||
@@ -379,19 +378,20 @@ update_flag
|
||||
return 0
|
||||
|
||||
if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr)) // exploit protection -walter0o
|
||||
usr << browse(null, "window=canister")
|
||||
var/datum/vueui/ui = href_list["vueui"]
|
||||
ui?.close()
|
||||
onclose(usr, "canister")
|
||||
return
|
||||
|
||||
if(href_list["toggle"])
|
||||
if (valve_open)
|
||||
if (holding)
|
||||
release_log += "Valve was <b>closed</b> by [usr] ([usr.ckey]), stopping the transfer into the [holding]<br>"
|
||||
release_log += "Valve was <b>closed</b> by [usr] ([usr.ckey]), stopping the transfer into [holding]<br>"
|
||||
else
|
||||
release_log += "Valve was <b>closed</b> by [usr] ([usr.ckey]), stopping the transfer into the <span class='warning'><b>air</b></span><br>"
|
||||
else
|
||||
if (holding)
|
||||
release_log += "Valve was <b>opened</b> by [usr] ([usr.ckey]), starting the transfer into the [holding]<br>"
|
||||
release_log += "Valve was <b>opened</b> by [usr] ([usr.ckey]), starting the transfer into [holding]<br>"
|
||||
else
|
||||
release_log += "Valve was <b>opened</b> by [usr] ([usr.ckey]), starting the transfer into the <span class='warning'><b>air</b></span><br>"
|
||||
log_open()
|
||||
@@ -401,18 +401,14 @@ update_flag
|
||||
if(holding)
|
||||
if (valve_open)
|
||||
valve_open = 0
|
||||
release_log += "Valve was <b>closed</b> by [usr] ([usr.ckey]), stopping the transfer into the [holding]<br>"
|
||||
release_log += "Valve was <b>closed</b> by [usr] ([usr.ckey]), stopping the transfer into [holding]<br>"
|
||||
if(istype(holding, /obj/item/tank))
|
||||
holding.manipulated_by = usr.real_name
|
||||
usr.put_in_hands(holding)
|
||||
holding = null
|
||||
|
||||
if (href_list["pressure_adj"])
|
||||
var/diff = text2num(href_list["pressure_adj"])
|
||||
if(diff > 0)
|
||||
release_pressure = min(10*ONE_ATMOSPHERE, release_pressure+diff)
|
||||
else
|
||||
release_pressure = max(ONE_ATMOSPHERE/10, release_pressure+diff)
|
||||
if (href_list["pressure_set"])
|
||||
release_pressure = between(ONE_ATMOSPHERE/10, text2num(href_list["pressure_set"]), 10*ONE_ATMOSPHERE)
|
||||
|
||||
if (href_list["relabel"])
|
||||
if (can_label)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
################################
|
||||
# Example Changelog File
|
||||
#
|
||||
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
|
||||
#
|
||||
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
|
||||
# When it is, any changes listed below will disappear.
|
||||
#
|
||||
# Valid Prefixes:
|
||||
# bugfix
|
||||
# wip (For works in progress)
|
||||
# tweak
|
||||
# soundadd
|
||||
# sounddel
|
||||
# rscadd (general adding of nice things)
|
||||
# rscdel (general deleting of nice things)
|
||||
# imageadd
|
||||
# imagedel
|
||||
# maptweak
|
||||
# spellcheck (typo fixes)
|
||||
# experiment
|
||||
# balance
|
||||
# admin
|
||||
# backend
|
||||
# security
|
||||
# refactor
|
||||
#################################
|
||||
|
||||
# Your name.
|
||||
author: MoondancerPony
|
||||
|
||||
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
|
||||
delete-after: True
|
||||
|
||||
# Any changes you've made. See valid prefix list above.
|
||||
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
|
||||
# SCREW THIS UP AND IT WON'T WORK.
|
||||
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
|
||||
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
|
||||
changes:
|
||||
- refactor: "Makes canisters use VueUI."
|
||||
- backend: "Makes labels on vui-item components optional."
|
||||
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<div>
|
||||
<h3>Tank Status</h3>
|
||||
<vui-item label="Tank Label:">
|
||||
<div style="float: left; width: 180px;">{{name}}</div> <vui-button icon="pencil" :params="{relabel : 1}" :disabled="!canLabel">Relabel</vui-button>
|
||||
</vui-item>
|
||||
|
||||
<vui-item label="Tank Pressure:">
|
||||
{{tankPressure}} kPa
|
||||
</vui-item>
|
||||
|
||||
<vui-item label="Port Status:">
|
||||
<span :class="portConnected ? good : average">{{portConnected ? "Connected" : "Disconnected"}}</span>
|
||||
</vui-item>
|
||||
|
||||
<h3>Holding Tank Status</h3>
|
||||
<div v-if="hasHoldingTank">
|
||||
<vui-item label="Tank Label:">
|
||||
<div style="float: left; width: 180px;">{{holdingTank.name}}</div><vui-button icon="eject" :params="{remove_tank : 1}">Eject</vui-button>
|
||||
</vui-item>
|
||||
|
||||
<vui-item label="Tank Pressure:">
|
||||
{{holdingTank.tankPressure}} kPa
|
||||
</vui-item>
|
||||
</div>
|
||||
<div v-else>
|
||||
<vui-item><span class="average"><i>No holding tank inserted.</i></span></vui-item>
|
||||
<vui-item> </vui-item>
|
||||
</div>
|
||||
|
||||
|
||||
<h3>Release Valve Status</h3>
|
||||
<vui-item label="Release Pressure:">
|
||||
<vui-progress :value="releasePressure" :min="minReleasePressure" :max="maxReleasePressure"> </vui-progress>
|
||||
<div style="clear: both; padding-top: 4px;">
|
||||
<vui-input-numeric width="80px" v-model="releasePressure" :button-count="4" :min="minReleasePressure" :max="maxReleasePressure" @input="s({pressure_set : releasePressure})">{{releasePressure}} kPa </vui-input-numeric>
|
||||
</div>
|
||||
</vui-item>
|
||||
|
||||
<vui-item label="Release Valve:">
|
||||
<vui-button icon="unlocked" :params="{toggle : 1}" :class="{selected : valveOpen}">Open</vui-button><vui-button icon="locked" :params="{toggle : 1}" :class="{selected : valveOpen}"/>
|
||||
</vui-item>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Utils from "../../../../utils.js";
|
||||
export default {
|
||||
data() {
|
||||
return this.$root.$data.state;
|
||||
},
|
||||
methods: {
|
||||
s(parameters) {
|
||||
Utils.sendToTopic(parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.item {
|
||||
width: 100%;
|
||||
margin: 4px 0 0 0;
|
||||
clear: both;
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="item">
|
||||
<div class="itemLabel" :style="{ width: (1 - balance) * 100 + '%' }">{{ label }}</div>
|
||||
<div class="itemContent" :style="{ width: balance * 100 + '%' }"><slot/></div>
|
||||
<div v-if="label" class="itemLabel" :style="{ width: (1 - balance) * 100 + '%' }">{{ label }}</div>
|
||||
<div class="itemContent" :style="{ width: (label ? balance : 1) * 100 + '%' }"><slot/></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user