mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-13 15:27:30 +08:00
Vector2D support
This commit is contained in:
@@ -25,8 +25,8 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
|
||||
)
|
||||
}
|
||||
element.classList.add("ueb-node-style-comment", "ueb-node-resizeable")
|
||||
element.sizeX ??= 25 * Configuration.gridSize
|
||||
element.sizeY ??= 6 * Configuration.gridSize
|
||||
element.sizeX = 25 * Configuration.gridSize
|
||||
element.sizeY = 6 * Configuration.gridSize
|
||||
super.initialize(element) // Keep it at the end because it calls this.getColor() where this.#color must be initialized
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ export default class PinTemplate extends ITemplate {
|
||||
firstUpdated(changedProperties) {
|
||||
super.firstUpdated(changedProperties)
|
||||
this.element.style.setProperty("--ueb-pin-color-rgb", Configuration.getPinColor(this.element).cssText)
|
||||
this.#iconElement = this.element.querySelector(".ueb-pin-icon") ?? this.element
|
||||
this.#iconElement = this.element.querySelector(".ueb-pin-icon svg") ?? this.element
|
||||
}
|
||||
|
||||
getLinkLocation() {
|
||||
|
||||
50
js/template/pin/Vector2DPinTemplate.js
Normal file
50
js/template/pin/Vector2DPinTemplate.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import { html } from "lit"
|
||||
import IInputPinTemplate from "./IInputPinTemplate"
|
||||
import INumericPinTemplate from "./INumericInputPinTemplate"
|
||||
import Utility from "../../Utility"
|
||||
import Vector2DEntity from "../../entity/Vector2DEntity"
|
||||
|
||||
/** @typedef {import("../../entity/LinearColorEntity").default} LinearColorEntity */
|
||||
|
||||
/**
|
||||
* @extends INumericPinTemplate<Vector2DEntity>
|
||||
*/
|
||||
export default class VectorInputPinTemplate extends INumericPinTemplate {
|
||||
|
||||
#getX() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0))
|
||||
}
|
||||
|
||||
#getY() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number[]} values
|
||||
* @param {String[]} rawValues
|
||||
*/
|
||||
setDefaultValue(values, rawValues) {
|
||||
const vector = this.element.getDefaultValue(true)
|
||||
if (!(vector instanceof Vector2DEntity)) {
|
||||
throw new TypeError("Expected DefaultValue to be a Vector2DEntity")
|
||||
}
|
||||
vector.X = values[0]
|
||||
vector.Y = values[1]
|
||||
this.element.requestUpdate("DefaultValue", vector)
|
||||
}
|
||||
|
||||
renderInput() {
|
||||
return html`
|
||||
<div class="ueb-pin-input-wrapper">
|
||||
<span class="ueb-pin-input-label">X</span>
|
||||
<div class="ueb-pin-input">
|
||||
<ueb-input .singleLine="${true}" .innerText="${this.#getX()}"></ueb-input>
|
||||
</div>
|
||||
<span class="ueb-pin-input-label">Y</span>
|
||||
<div class="ueb-pin-input">
|
||||
<ueb-input .singleLine="${true}" .innerText="${this.#getY()}"></ueb-input>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import VectorEntity from "../../entity/VectorEntity"
|
||||
/**
|
||||
* @extends INumericPinTemplate<VectorEntity>
|
||||
*/
|
||||
export default class VectorInputPinTemplate extends INumericPinTemplate {
|
||||
export default class VectorPinTemplate extends INumericPinTemplate {
|
||||
|
||||
#getX() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0))
|
||||
Reference in New Issue
Block a user