mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-23 23:34:43 +08:00
Vector input type implemented
This commit is contained in:
@@ -12,6 +12,7 @@ import Select from "../input/mouse/Select"
|
||||
import SelectorElement from "../element/SelectorElement"
|
||||
import Unfocus from "../input/mouse/Unfocus"
|
||||
import Zoom from "../input/mouse/Zoom"
|
||||
import Utility from "../Utility"
|
||||
|
||||
/**
|
||||
* @typedef {import("../Blueprint").default} Blueprint
|
||||
@@ -32,13 +33,14 @@ export default class BlueprintTemplate extends ITemplate {
|
||||
"--ueb-grid-size": `${Configuration.gridSize}px`,
|
||||
"--ueb-link-min-width": `${Configuration.linkMinWidth}`,
|
||||
"--ueb-node-radius": `${Configuration.nodeRadius}px`,
|
||||
"--ueb-pin-bool-color": `${Configuration.pinColor["bool"]}`,
|
||||
"--ueb-pin-default-color": `${Configuration.pinColor["default"]}`,
|
||||
"--ueb-pin-exec-color": `${Configuration.pinColor["exec"]}`,
|
||||
"--ueb-pin-name-color": `${Configuration.pinColor["name"]}`,
|
||||
"--ueb-pin-real-color": `${Configuration.pinColor["real"]}`,
|
||||
"--ueb-pin-string-color": `${Configuration.pinColor["string"]}`,
|
||||
"--ueb-pin-linear-color": `${Configuration.pinColor["/Script/CoreUObject.LinearColor"]}`,
|
||||
...Object.entries(Configuration.pinColor)
|
||||
.map(([k, v]) => ({
|
||||
[`--ueb-pin-color-${Utility.getIdFromReference(k)}`]: v.toString()
|
||||
}))
|
||||
.reduce((acc, cur) => ({
|
||||
...acc,
|
||||
...cur,
|
||||
}), {}),
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,9 +53,7 @@ export default class IInputPinTemplate extends PinTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PinElement} pin
|
||||
*/
|
||||
/** @param {PinElement} pin */
|
||||
cleanup(pin) {
|
||||
super.cleanup(pin)
|
||||
this.#inputContentElements.forEach(element => {
|
||||
@@ -64,9 +62,7 @@ export default class IInputPinTemplate extends PinTemplate {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PinElement} pin
|
||||
*/
|
||||
/** @param {PinElement} pin */
|
||||
createInputObjects(pin) {
|
||||
return [
|
||||
...super.createInputObjects(pin),
|
||||
@@ -74,16 +70,12 @@ export default class IInputPinTemplate extends PinTemplate {
|
||||
]
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PinElement} pin
|
||||
*/
|
||||
/** @param {PinElement} pin */
|
||||
getInput(pin) {
|
||||
return this.getInputs(pin).reduce((acc, cur) => acc + cur, "")
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PinElement} pin
|
||||
*/
|
||||
/** @param {PinElement} pin */
|
||||
getInputs(pin) {
|
||||
return this.#inputContentElements.map(element =>
|
||||
// Faster than innerText which causes reflow
|
||||
@@ -108,9 +100,7 @@ export default class IInputPinTemplate extends PinTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PinElement} pin
|
||||
*/
|
||||
/** @param {PinElement} pin */
|
||||
renderInput(pin) {
|
||||
if (pin.isInput()) {
|
||||
return html`
|
||||
|
||||
@@ -12,18 +12,23 @@ export default class RealPinTemplate extends IInputPinTemplate {
|
||||
* @param {String[]?} values
|
||||
*/
|
||||
setInputs(pin, values = []) {
|
||||
let num = parseFloat(values.length ? values[0] : this.getInput(pin))
|
||||
if (!values || values.length == 0) {
|
||||
values = this.getInput(pin)
|
||||
}
|
||||
let updateDefaultValue = true
|
||||
if (isNaN(num)) {
|
||||
num = parseFloat(pin.entity.DefaultValue != ""
|
||||
? /** @type {String} */(pin.entity.DefaultValue)
|
||||
: pin.entity.AutogeneratedDefaultValue)
|
||||
for (let i = 0; i < values.length; ++i) {
|
||||
let num = parseFloat(values[i])
|
||||
if (isNaN(num)) {
|
||||
num = parseFloat(pin.entity.DefaultValue != ""
|
||||
? /** @type {String} */(pin.entity.DefaultValue)
|
||||
: pin.entity.AutogeneratedDefaultValue)
|
||||
}
|
||||
if (isNaN(num)) {
|
||||
num = 0
|
||||
updateDefaultValue = false
|
||||
}
|
||||
values[i] = Utility.minDecimals(num)
|
||||
}
|
||||
if (isNaN(num)) {
|
||||
num = 0
|
||||
updateDefaultValue = false
|
||||
}
|
||||
values[0] = Utility.minDecimals(num)
|
||||
super.setInputs(pin, values, updateDefaultValue)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,35 @@
|
||||
import { html } from "lit"
|
||||
import IInputPinTemplate from "./IInputPinTemplate"
|
||||
import RealPinTemplate from "./RealPinTemplate"
|
||||
|
||||
/**
|
||||
* @typedef {import("../element/PinElement").default} PinElement
|
||||
* @typedef {import("../entity/LinearColorEntity").default} LinearColorEntity}
|
||||
*/
|
||||
|
||||
export default class VectorPinTemplate extends IInputPinTemplate {
|
||||
export default class VectorPinTemplate extends RealPinTemplate {
|
||||
|
||||
/** @type {HTMLInputElement} */
|
||||
#input
|
||||
|
||||
/**
|
||||
* @param {PinElement} pin
|
||||
* @param {Map} changedProperties
|
||||
*/
|
||||
firstUpdated(pin, changedProperties) {
|
||||
super.firstUpdated(pin, changedProperties)
|
||||
this.#input = pin.querySelector(".ueb-pin-input")
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PinElement} pin
|
||||
*/
|
||||
getInputs(pin) {
|
||||
return [this.#input.dataset.linearColor]
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PinElement} pin
|
||||
* @param {String[]} value
|
||||
*/
|
||||
setInputs(pin, value = []) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {PinElement} pin
|
||||
*/
|
||||
/** @param {PinElement} pin */
|
||||
renderInput(pin) {
|
||||
if (pin.isInput()) {
|
||||
return html`
|
||||
<span class="ueb-pin-input-label">X</span>
|
||||
<div class="ueb-pin-input">
|
||||
<span class="ueb-pin-input-x" role="textbox" contenteditable="true" .innerText=${pin.unreactiveDefaultValue}></span>
|
||||
<span class="ueb-pin-input-content ueb-pin-input-x" role="textbox" contenteditable="true"
|
||||
.innerText="${IInputPinTemplate.stringFromUEToInput(pin.unreactiveDefaultValue.X.toString())}"></span>
|
||||
</div>
|
||||
<span class="ueb-pin-input-label">Y</span>
|
||||
<div class="ueb-pin-input">
|
||||
<span class="ueb-pin-input-content ueb-pin-input-y" role="textbox" contenteditable="true"
|
||||
.innerText="${IInputPinTemplate.stringFromUEToInput(pin.unreactiveDefaultValue.Y.toString())}"></span>
|
||||
</div>
|
||||
<span class="ueb-pin-input-label">Z</span>
|
||||
<div class="ueb-pin-input">
|
||||
<span class="ueb-pin-input-content ueb-pin-input-z" role="textbox" contenteditable="true"
|
||||
.innerText="${IInputPinTemplate.stringFromUEToInput(pin.unreactiveDefaultValue.Z.toString())}"></span>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
return super.renderInput(pin)
|
||||
return html``
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user