mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-27 18:54:44 +08:00
Fix pin colors, input refactoring
This commit is contained in:
@@ -10,24 +10,24 @@ import Utility from "./Utility"
|
||||
|
||||
export default class Configuration {
|
||||
static #pinColor = {
|
||||
"/Script/CoreUObject.Rotator": css`152, 171, 241`,
|
||||
"/Script/CoreUObject.Transform": css`241, 110, 1`,
|
||||
"/Script/CoreUObject.Vector": css`215, 202, 11`,
|
||||
"/Script/Engine.Actor": css`0, 168, 242`,
|
||||
"/Script/Engine.GameStateBase": css`0, 168, 242`,
|
||||
"/Script/Engine.Pawn": css`0, 168, 242`,
|
||||
"/Script/Engine.PlayerState": css`0, 168, 242`,
|
||||
"bool": css`117, 0, 0`,
|
||||
"byte": css`0, 110, 98`,
|
||||
"/Script/CoreUObject.Rotator": css`157, 177, 251`,
|
||||
"/Script/CoreUObject.Transform": css`227, 103, 0`,
|
||||
"/Script/CoreUObject.Vector": css`251, 198, 34`,
|
||||
"bool": css`147, 0, 0`,
|
||||
"byte": css`0, 109, 99`,
|
||||
"class": css`88, 0, 186`,
|
||||
"default": css`255, 255, 255`,
|
||||
"delegate": css`255, 56, 56`,
|
||||
"exec": css`240, 240, 240`,
|
||||
"int": css`32, 224, 173`,
|
||||
"int64": css`170, 224, 172`,
|
||||
"name": css`203, 129, 252`,
|
||||
"real": css`50, 187, 0`,
|
||||
"string": css`213, 0, 176`,
|
||||
"int": css`31, 224, 172`,
|
||||
"int64": css`169, 223, 172`,
|
||||
"interface": css`238, 252, 168`,
|
||||
"name": css`201, 128, 251`,
|
||||
"object": css`0, 167, 240`,
|
||||
"real": css`54, 208, 0`,
|
||||
"string": css`251, 0, 209`,
|
||||
"struct": css`0, 88, 201`,
|
||||
"text": css`226, 121, 167`,
|
||||
"wildcard": css`128, 120, 120`,
|
||||
}
|
||||
static alphaPattern = "repeating-conic-gradient(#7c8184 0% 25%, #c2c3c4 0% 50%) 50% / 10px 10px"
|
||||
@@ -135,15 +135,16 @@ export default class Configuration {
|
||||
switch (node.getType()) {
|
||||
case Configuration.nodeType.callFunction:
|
||||
case Configuration.nodeType.commutativeAssociativeBinaryOperator:
|
||||
if (node.entity.FunctionReference.MemberName == "AddKey") {
|
||||
let memberName = node.entity.FunctionReference.MemberName ?? ""
|
||||
const memberParent = node.entity.FunctionReference.MemberParent?.path ?? ""
|
||||
if (memberName === "AddKey") {
|
||||
const sequencerScriptingNameRegex = /\/Script\/SequencerScripting\.MovieSceneScripting(.+)Channel/
|
||||
let result = node.entity.FunctionReference.MemberParent.path.match(sequencerScriptingNameRegex)
|
||||
let result = memberParent.match(sequencerScriptingNameRegex)
|
||||
if (result) {
|
||||
return `Add Key (${Utility.formatStringName(result[1])})`
|
||||
}
|
||||
}
|
||||
let memberName = node.entity.FunctionReference.MemberName
|
||||
if (node.entity.FunctionReference.MemberParent.path == "/Script/Engine.KismetMathLibrary") {
|
||||
if (memberParent == "/Script/Engine.KismetMathLibrary") {
|
||||
if (memberName.startsWith("Conv_")) {
|
||||
return "" // Conversion nodes do not have visible names
|
||||
}
|
||||
@@ -164,13 +165,13 @@ export default class Configuration {
|
||||
case "MinInt64": return "MIN"
|
||||
}
|
||||
}
|
||||
if (node.entity.FunctionReference.MemberParent.path === "/Script/Engine.BlueprintSetLibrary") {
|
||||
if (memberParent === "/Script/Engine.BlueprintSetLibrary") {
|
||||
const setOperationMatch = memberName.match(/Set_(\w+)/)
|
||||
if (setOperationMatch) {
|
||||
return Utility.formatStringName(setOperationMatch[1]).toUpperCase()
|
||||
}
|
||||
}
|
||||
if (node.entity.FunctionReference.MemberParent.path === "/Script/Engine.BlueprintMapLibrary") {
|
||||
if (memberParent === "/Script/Engine.BlueprintMapLibrary") {
|
||||
const setOperationMatch = memberName.match(/Map_(\w+)/)
|
||||
if (setOperationMatch) {
|
||||
return Utility.formatStringName(setOperationMatch[1]).toUpperCase()
|
||||
@@ -217,6 +218,7 @@ export default class Configuration {
|
||||
forEachLoopWithBreak: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoopWithBreak",
|
||||
forLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForLoop",
|
||||
forLoopWithBreak: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForLoopWithBreak",
|
||||
functionEntry: "/Script/BlueprintGraph.K2Node_FunctionEntry",
|
||||
ifThenElse: "/Script/BlueprintGraph.K2Node_IfThenElse",
|
||||
knot: "/Script/BlueprintGraph.K2Node_Knot",
|
||||
macro: "/Script/BlueprintGraph.K2Node_MacroInstance",
|
||||
@@ -226,6 +228,7 @@ export default class Configuration {
|
||||
pawn: "/Script/Engine.Pawn",
|
||||
reverseForEachLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ReverseForEachLoop",
|
||||
select: "/Script/BlueprintGraph.K2Node_Select",
|
||||
userDefinedEnum: "/Script/Engine.UserDefinedEnum",
|
||||
variableGet: "/Script/BlueprintGraph.K2Node_VariableGet",
|
||||
variableSet: "/Script/BlueprintGraph.K2Node_VariableSet",
|
||||
whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop",
|
||||
@@ -235,24 +238,9 @@ export default class Configuration {
|
||||
* @return {CSSResult}
|
||||
*/
|
||||
static pinColor(pin) {
|
||||
if (Configuration.#pinColor[pin.pinType]) {
|
||||
return Configuration.#pinColor[pin.pinType]
|
||||
}
|
||||
if (pin.entity.PinType.PinCategory == "struct" || pin.entity.PinType.PinCategory == "object") {
|
||||
switch (pin.entity.PinType.PinSubCategoryObject.type) {
|
||||
case "ScriptStruct":
|
||||
case "/Script/CoreUObject.ScriptStruct":
|
||||
return css`0, 88, 200`
|
||||
default:
|
||||
if (
|
||||
pin.entity.PinType.PinSubCategoryObject.getName().endsWith("Actor")
|
||||
|| pin.getPinDisplayName() == "Target"
|
||||
) {
|
||||
return Configuration.#pinColor["/Script/Engine.Actor"]
|
||||
}
|
||||
}
|
||||
}
|
||||
return Configuration.#pinColor["default"]
|
||||
return Configuration.#pinColor[pin.entity.getType()]
|
||||
?? Configuration.#pinColor[pin.entity.PinType.PinCategory]
|
||||
?? Configuration.#pinColor["default"]
|
||||
}
|
||||
static scale = {
|
||||
[-12]: 0.133333,
|
||||
|
||||
@@ -102,7 +102,8 @@ export default class NodeElement extends ISelectableDraggableElement {
|
||||
nodeEntity.getClass() === Configuration.nodeType.callFunction
|
||||
|| nodeEntity.getClass() === Configuration.nodeType.commutativeAssociativeBinaryOperator
|
||||
) {
|
||||
if (nodeEntity.FunctionReference.MemberParent.path === "/Script/Engine.KismetMathLibrary") {
|
||||
const memberParent = nodeEntity.FunctionReference.MemberParent?.path ?? ""
|
||||
if (memberParent === "/Script/Engine.KismetMathLibrary") {
|
||||
if (nodeEntity.FunctionReference.MemberName?.startsWith("Conv_")) {
|
||||
return VariableConversionNodeTemplate
|
||||
}
|
||||
@@ -123,10 +124,10 @@ export default class NodeElement extends ISelectableDraggableElement {
|
||||
return VariableOperationNodeTemplate
|
||||
}
|
||||
}
|
||||
if (nodeEntity.FunctionReference.MemberParent.path == "/Script/Engine.BlueprintSetLibrary") {
|
||||
if (memberParent === "/Script/Engine.BlueprintSetLibrary") {
|
||||
return VariableOperationNodeTemplate
|
||||
}
|
||||
if (nodeEntity.FunctionReference.MemberParent.path == "/Script/Engine.BlueprintMapLibrary") {
|
||||
if (memberParent === "/Script/Engine.BlueprintMapLibrary") {
|
||||
return VariableOperationNodeTemplate
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,4 @@ import ByteEntity from "./ByteEntity"
|
||||
|
||||
export default class EnumEntity extends ByteEntity {
|
||||
|
||||
constructor(values = 0) {
|
||||
super(values)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,10 @@ export default class ObjectEntity extends IEntity {
|
||||
value: false,
|
||||
showDefault: false,
|
||||
},
|
||||
bIsConstFunc: {
|
||||
value: false,
|
||||
showDefault: false,
|
||||
},
|
||||
VariableReference: {
|
||||
type: VariableReferenceEntity,
|
||||
value: null,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// @ts-nocheck
|
||||
import ByteEntity from "../entity/ByteEntity"
|
||||
import EnumEntity from "../entity/EnumEntity"
|
||||
import FunctionReferenceEntity from "../entity/FunctionReferenceEntity"
|
||||
import GuidEntity from "../entity/GuidEntity"
|
||||
import IdentifierEntity from "../entity/IdentifierEntity"
|
||||
@@ -77,6 +78,8 @@ export default class Grammar {
|
||||
return r.Boolean
|
||||
case ByteEntity:
|
||||
return r.Byte
|
||||
case EnumEntity:
|
||||
return r.Enum
|
||||
case FunctionReferenceEntity:
|
||||
return r.FunctionReference
|
||||
case GuidEntity:
|
||||
|
||||
@@ -80,9 +80,9 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
${name ? html`
|
||||
<div class="ueb-node-name-text ueb-ellipsis-nowrap-text">
|
||||
${name}
|
||||
${this.hasSubtitle && this.element.entity.FunctionReference.MemberParent ? html`
|
||||
${this.hasSubtitle && this.getTargetType().length > 0 ? html`
|
||||
<div class="ueb-node-subtitle-text ueb-ellipsis-nowrap-text">
|
||||
Target is ${Utility.formatStringName(this.element.entity.FunctionReference.MemberParent.getName())}
|
||||
Target is ${Utility.formatStringName(this.getTargetType())}
|
||||
</div>
|
||||
`: nothing}
|
||||
</div>
|
||||
@@ -115,13 +115,17 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
return this.element.getPinEntities()
|
||||
.filter(v => !v.isHidden())
|
||||
.map(pinEntity => {
|
||||
this.hasSubtitle = this.hasSubtitle || pinEntity.getDisplayName() === "Target"
|
||||
this.hasSubtitle = this.hasSubtitle || pinEntity.PinName === "self" && pinEntity.getDisplayName() === "Target"
|
||||
let pinElement = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin"))
|
||||
.newObject(pinEntity, undefined, this.element)
|
||||
return pinElement
|
||||
})
|
||||
}
|
||||
|
||||
getTargetType() {
|
||||
return this.element.entity.FunctionReference?.MemberParent?.getName() ?? "Untitled"
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {NodeElement} node
|
||||
* @returns {NodeListOf<PinElement>}
|
||||
|
||||
@@ -5,11 +5,6 @@ import Utility from "../../Utility"
|
||||
|
||||
/** @typedef {import("lit").PropertyValues} PropertyValues */
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("../../element/PinElement").default<T>} PinElement
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @extends PinTemplate<T>
|
||||
@@ -104,7 +99,7 @@ export default class IInputPinTemplate extends PinTemplate {
|
||||
return html`
|
||||
<div class="ueb-pin-input">
|
||||
<ueb-input .singleLine="${singleLine}" .selectOnFocus="${selectOnFocus}"
|
||||
.innerText="${IInputPinTemplate.stringFromUEToInput(this.element.entity.DefaultValue.toString())}">
|
||||
.innerText="${IInputPinTemplate.stringFromUEToInput(this.element.getDefaultValue()?.toString() ?? "")}">
|
||||
</ueb-input>
|
||||
</div>
|
||||
`
|
||||
|
||||
@@ -11,13 +11,16 @@ export default class InputTemplate extends ITemplate {
|
||||
getSelection().selectAllChildren(this.element)
|
||||
}
|
||||
}
|
||||
|
||||
#focusoutHandler = () => {
|
||||
this.blueprint.acknowledgeEditText(false)
|
||||
getSelection().removeAllRanges() // Deselect eventually selected text inside the input
|
||||
}
|
||||
|
||||
/** @param {InputEvent} e */
|
||||
#inputSingleLineHandler = e =>
|
||||
/** @type {HTMLElement} */(e.target).querySelectorAll("br").forEach(br => br.remove())
|
||||
|
||||
/** @param {KeyboardEvent} e */
|
||||
#onKeydownBlurOnEnterHandler = e => {
|
||||
if (e.code == "Enter" && !e.shiftKey) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { html } from "lit"
|
||||
import { html, nothing } from "lit"
|
||||
import ColorPickerWindowTemplate from "../ColorPickerWindowTemplate"
|
||||
import Configuration from "../../Configuration"
|
||||
import ElementFactory from "../../element/ElementFactory"
|
||||
@@ -48,9 +48,9 @@ export default class LinearColorPinTemplate extends PinTemplate {
|
||||
|
||||
renderInput() {
|
||||
return html`
|
||||
<span class="ueb-pin-input" data-linear-color="${this.element.defaultValue.toString()}"
|
||||
<span class="ueb-pin-input" data-linear-color="${this.element.getDefaultValue()?.toString() ?? nothing}"
|
||||
@click="${this.#launchColorPickerWindow}"
|
||||
style="--ueb-linear-color: rgba(${this.element.defaultValue.toString()})">
|
||||
style="--ueb-linear-color: rgba(${this.element.getDefaultValue()?.toString() ?? nothing})">
|
||||
</span>
|
||||
`
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { html } from "lit"
|
||||
import IInputPinTemplate from "./IInputPinTemplate"
|
||||
import INumericPinTemplate from "./INumericPinTemplate"
|
||||
import Utility from "../../Utility"
|
||||
|
||||
@@ -17,7 +16,7 @@ export default class RealPinTemplate extends INumericPinTemplate {
|
||||
return html`
|
||||
<div class="ueb-pin-input">
|
||||
<ueb-input .singleLine="${true}"
|
||||
.innerText="${IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue() ?? 0))}">
|
||||
.innerText="${Utility.minDecimals(this.element.getDefaultValue() ?? 0)}">
|
||||
</ueb-input>
|
||||
</div>
|
||||
`
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { html } from "lit"
|
||||
import IInputPinTemplate from "./IInputPinTemplate"
|
||||
import INumericPinTemplate from "./INumericPinTemplate"
|
||||
import RotatorEntity from "../../entity/RotatorEntity"
|
||||
import Utility from "../../Utility"
|
||||
@@ -10,15 +9,15 @@ import Utility from "../../Utility"
|
||||
export default class RotatorPinTemplate extends INumericPinTemplate {
|
||||
|
||||
#getR() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.R ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.R ?? 0)
|
||||
}
|
||||
|
||||
#getP() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.P ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.P ?? 0)
|
||||
}
|
||||
|
||||
#getY() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
|
||||
}
|
||||
|
||||
setDefaultValue(values = [], rawValues = values) {
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
import { html } from "lit"
|
||||
import IInputPinTemplate from "./IInputPinTemplate"
|
||||
import INumericPinTemplate from "./INumericPinTemplate"
|
||||
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))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0)
|
||||
}
|
||||
|
||||
#getY() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
import { html } from "lit"
|
||||
import IInputPinTemplate from "./IInputPinTemplate"
|
||||
import INumericPinTemplate from "./INumericPinTemplate"
|
||||
import Utility from "../../Utility"
|
||||
import VectorEntity from "../../entity/VectorEntity"
|
||||
|
||||
/** @typedef {import("../../entity/LinearColorEntity").default} LinearColorEntity */
|
||||
|
||||
/**
|
||||
* @extends INumericPinTemplate<VectorEntity>
|
||||
*/
|
||||
export default class VectorPinTemplate extends INumericPinTemplate {
|
||||
|
||||
#getX() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0)
|
||||
}
|
||||
|
||||
#getY() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
|
||||
}
|
||||
|
||||
#getZ() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Z ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.Z ?? 0)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user