Files
ueblueprint/js/Configuration.js
2023-09-26 22:12:39 +02:00

413 lines
18 KiB
JavaScript
Executable File

import { css } from "lit"
export default class Configuration {
static nodeColors = {
black: css`20, 20, 20`,
blue: css`84, 122, 156`,
darkBlue: css`32, 80, 128`,
darkTurquoise: css`19, 100, 137`,
gray: css`150,150,150`,
green: css`95, 129, 90`,
lime: css`150, 160, 30`,
red: css`151, 33, 32`,
turquoise: css`46, 104, 106`,
violet: css`126, 28, 150`,
yellow: css`148, 116, 24`,
}
static alphaPattern = "repeating-conic-gradient(#7c8184 0% 25%, #c2c3c4 0% 50%) 50% / 10px 10px"
static colorDragEventName = "ueb-color-drag"
static colorPickEventName = "ueb-color-pick"
static colorWindowEventName = "ueb-color-window"
static colorWindowName = "Color Picker"
static defaultCommentHeight = 96
static defaultCommentWidth = 400
static distanceThreshold = 5 // px
static dragEventName = "ueb-drag"
static dragGeneralEventName = "ueb-drag-general"
static edgeScrollThreshold = 50
static editTextEventName = {
begin: "ueb-edit-text-begin",
end: "ueb-edit-text-end",
}
static expandGridSize = 400
static focusEventName = {
begin: "blueprint-focus",
end: "blueprint-unfocus",
}
static fontSize = css`12.5px`
static gridAxisLineColor = css`black`
static gridExpandThreshold = 0.25 // remaining size factor threshold to cause an expansion event
static gridLineColor = css`#353535`
static gridLineWidth = 1 // px
static gridSet = 8
static gridSetLineColor = css`#161616`
static gridShrinkThreshold = 4 // exceding size factor threshold to cause a shrink event
static gridSize = 16 // px
static hexColorRegex = /^\s*#(?<r>[0-9a-fA-F]{2})(?<g>[0-9a-fA-F]{2})(?<b>[0-9a-fA-F]{2})([0-9a-fA-F]{2})?|#(?<rs>[0-9a-fA-F])(?<gs>[0-9a-fA-F])(?<bs>[0-9a-fA-F])\s*$/
static indentation = " "
static keysSeparator = /[\.\(\)]/
static knotOffset = [-Configuration.gridSize, -0.5 * Configuration.gridSize]
static lineTracePattern = /LineTrace(Single|Multi)(\w*)/
static linkCurveHeight = 15 // px
static linkCurveWidth = 80 // px
static linkMinWidth = 100 // px
static nameRegexSpaceReplacement = new RegExp(
// Leading K2_ or K2Node_
"^K2(?:[Nn]ode)?_"
// End of a word (lower case followed by either upper case or number)
+ "|(?<=[a-z])(?=[A-Z0-9])"
// End of upper case work (upper case followed by either word or number)
+ "|(?<=[A-Z])"
+ /* Except "UVs" */ "(?<!U(?=Vs(?![a-z])))"
+ /* Except V2, V3 */ "(?<!V(?=[23](?![0-9])))"
+ /* Except T2d */ "(?<!T(?=2d(?![a-z])))"
+ "(?=[A-Z][a-z]|[0-9])"
// Number followed by a letter
+ "|(?<=[0-9])"
+ /* Except 2D, 3D */ "(?<![23](?=[dD](?![a-z])))"
+ "(?=[a-zA-Z])"
// "Alpha__Bravo" => "Alpha Bravo"
+ "|\\s*_+\\s*"
+ "|\\s{2,}",
"g"
)
/**
* @param {Number} start
* @param {Number} c1
* @param {Number} c2
*/
static linkRightSVGPath = (start, c1, c2) => {
let end = 100 - start
return `M ${start} 0 C ${c1.toFixed(3)} 0, ${c2.toFixed(3)} 0, 50 50 S ${(end - c1 + start).toFixed(3)} 100, `
+ `${end.toFixed(3)} 100`
}
static maxZoom = 7
static minZoom = -12
static mouseClickButton = 0
static mouseRightClickButton = 2
static mouseWheelZoomThreshold = 80
static nodeDragEventName = "ueb-node-drag"
static nodeDragGeneralEventName = "ueb-node-drag-general"
static nodeTitle = (name, counter) => `${name}_${counter}`
static nodeRadius = 8 // px
static nodeReflowEventName = "ueb-node-reflow"
static paths = {
actorBoundEvent: "/Script/BlueprintGraph.K2Node_ActorBoundEvent",
addDelegate: "/Script/BlueprintGraph.K2Node_AddDelegate",
ambientSound: "/Script/Engine.AmbientSound",
asyncAction: "/Script/BlueprintGraph.K2Node_AsyncAction",
blueprint: "/Script/Engine.Blueprint",
blueprintGameplayTagLibrary: "/Script/GameplayTags.BlueprintGameplayTagLibrary",
blueprintMapLibrary: "/Script/Engine.BlueprintMapLibrary",
blueprintSetLibrary: "/Script/Engine.BlueprintSetLibrary",
callArrayFunction: "/Script/BlueprintGraph.K2Node_CallArrayFunction",
callDelegate: "/Script/BlueprintGraph.K2Node_CallDelegate",
callFunction: "/Script/BlueprintGraph.K2Node_CallFunction",
comment: "/Script/UnrealEd.EdGraphNode_Comment",
commutativeAssociativeBinaryOperator: "/Script/BlueprintGraph.K2Node_CommutativeAssociativeBinaryOperator",
componentBoundEvent: "/Script/BlueprintGraph.K2Node_ComponentBoundEvent",
createDelegate: "/Script/BlueprintGraph.K2Node_CreateDelegate",
customEvent: "/Script/BlueprintGraph.K2Node_CustomEvent",
doN: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N",
doOnce: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:DoOnce",
dynamicCast: "/Script/BlueprintGraph.K2Node_DynamicCast",
edGraph: "/Script/Engine.EdGraph",
edGraphPinDeprecated: "/Script/Engine.EdGraphPin_Deprecated",
eDrawDebugTrace: "/Script/Engine.EDrawDebugTrace",
eMaterialSamplerType: "/Script/Engine.EMaterialSamplerType",
enum: "/Script/CoreUObject.Enum",
enumLiteral: "/Script/BlueprintGraph.K2Node_EnumLiteral",
eSamplerSourceMode: "/Script/Engine.ESamplerSourceMode",
eSearchCase: "/Script/CoreUObject.ESearchCase",
eSearchDir: "/Script/CoreUObject.ESearchDir",
eSpawnActorCollisionHandlingMethod: "/Script/Engine.ESpawnActorCollisionHandlingMethod",
eTextureMipValueMode: "/Script/Engine.ETextureMipValueMode",
eTraceTypeQuery: "/Script/Engine.ETraceTypeQuery",
event: "/Script/BlueprintGraph.K2Node_Event",
executionSequence: "/Script/BlueprintGraph.K2Node_ExecutionSequence",
flipflop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:FlipFlop",
forEachElementInEnum: "/Script/BlueprintGraph.K2Node_ForEachElementInEnum",
forEachLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoop",
forEachLoopWithBreak: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoopWithBreak",
forLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForLoop",
forLoopWithBreak: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForLoopWithBreak",
functionEntry: "/Script/BlueprintGraph.K2Node_FunctionEntry",
functionResult: "/Script/BlueprintGraph.K2Node_FunctionResult",
getInputAxisKeyValue: "/Script/BlueprintGraph.K2Node_GetInputAxisKeyValue",
ifThenElse: "/Script/BlueprintGraph.K2Node_IfThenElse",
inputAxisKeyEvent: "/Script/BlueprintGraph.K2Node_InputAxisKeyEvent",
inputDebugKey: "/Script/InputBlueprintNodes.K2Node_InputDebugKey",
inputKey: "/Script/BlueprintGraph.K2Node_InputKey",
inputVectorAxisEvent: "/Script/BlueprintGraph.K2Node_InputVectorAxisEvent",
isValid: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:IsValid",
kismetArrayLibrary: "/Script/Engine.KismetArrayLibrary",
kismetMathLibrary: "/Script/Engine.KismetMathLibrary",
knot: "/Script/BlueprintGraph.K2Node_Knot",
linearColor: "/Script/CoreUObject.LinearColor",
literal: "/Script/BlueprintGraph.K2Node_Literal",
macro: "/Script/BlueprintGraph.K2Node_MacroInstance",
makeArray: "/Script/BlueprintGraph.K2Node_MakeArray",
makeMap: "/Script/BlueprintGraph.K2Node_MakeMap",
makeSet: "/Script/BlueprintGraph.K2Node_MakeSet",
makeStruct: "/Script/BlueprintGraph.K2Node_MakeStruct",
materialExpressionConstant: "/Script/Engine.MaterialExpressionConstant",
materialExpressionConstant2Vector: "/Script/Engine.MaterialExpressionConstant2Vector",
materialExpressionConstant3Vector: "/Script/Engine.MaterialExpressionConstant3Vector",
materialExpressionConstant4Vector: "/Script/Engine.MaterialExpressionConstant4Vector",
materialExpressionLogarithm: "/Script/InterchangeImport.MaterialExpressionLogarithm",
materialExpressionLogarithm10: "/Script/Engine.MaterialExpressionLogarithm10",
materialExpressionLogarithm2: "/Script/Engine.MaterialExpressionLogarithm2",
materialExpressionMaterialFunctionCall: "/Script/Engine.MaterialExpressionMaterialFunctionCall",
materialExpressionSquareRoot: "/Script/Engine.MaterialExpressionSquareRoot",
materialExpressionTextureCoordinate: "/Script/Engine.MaterialExpressionTextureCoordinate",
materialExpressionTextureSample: "/Script/Engine.MaterialExpressionTextureSample",
materialGraphNode: "/Script/UnrealEd.MaterialGraphNode",
materialGraphNodeComment: "/Script/UnrealEd.MaterialGraphNode_Comment",
multiGate: "/Script/BlueprintGraph.K2Node_MultiGate",
pawn: "/Script/Engine.Pawn",
pcgEditorGraphNode: "/Script/PCGEditor.PCGEditorGraphNode",
pcgEditorGraphNodeInput: "/Script/PCGEditor.PCGEditorGraphNodeInput",
pcgEditorGraphNodeOutput: "/Script/PCGEditor.PCGEditorGraphNodeOutput",
pcgHiGenGridSizeSettings: "/Script/PCG.PCGHiGenGridSizeSettings",
pcgSubgraphSettings: "/Script/PCG.PCGSubgraphSettings",
promotableOperator: "/Script/BlueprintGraph.K2Node_PromotableOperator",
reverseForEachLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ReverseForEachLoop",
rotator: "/Script/CoreUObject.Rotator",
select: "/Script/BlueprintGraph.K2Node_Select",
slateBlueprintLibrary: "/Script/UMG.SlateBlueprintLibrary",
spawnActorFromClass: "/Script/BlueprintGraph.K2Node_SpawnActorFromClass",
switchEnum: "/Script/BlueprintGraph.K2Node_SwitchEnum",
switchGameplayTag: "/Script/GameplayTagsEditor.GameplayTagsK2Node_SwitchGameplayTag",
switchInteger: "/Script/BlueprintGraph.K2Node_SwitchInteger",
switchName: "/Script/BlueprintGraph.K2Node_SwitchName",
switchString: "/Script/BlueprintGraph.K2Node_SwitchString",
timeline: "/Script/BlueprintGraph.K2Node_Timeline",
timeManagementBlueprintLibrary: "/Script/TimeManagement.TimeManagementBlueprintLibrary",
transform: "/Script/CoreUObject.Transform",
userDefinedEnum: "/Script/Engine.UserDefinedEnum",
variableGet: "/Script/BlueprintGraph.K2Node_VariableGet",
variableSet: "/Script/BlueprintGraph.K2Node_VariableSet",
vector: "/Script/CoreUObject.Vector",
vector2D: "/Script/CoreUObject.Vector2D",
whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop",
}
static pinColor = {
[this.paths.rotator]: css`157, 177, 251`,
[this.paths.transform]: css`227, 103, 0`,
[this.paths.vector]: css`251, 198, 34`,
"Any": css`132, 132, 132`,
"Any[]": css`132, 132, 132`,
"blue": css`0, 0, 255`,
"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`,
"enum": css`0, 109, 99`,
"exec": css`240, 240, 240`,
"green": css`0, 255, 0`,
"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`,
"Param": css`255, 166, 39`,
"Param[]": css`255, 166, 39`,
"Point": css`63, 137, 255`,
"Point[]": css`63, 137, 255`,
"real": css`54, 208, 0`,
"red": css`255, 0, 0`,
"string": css`251, 0, 209`,
"struct": css`0, 88, 201`,
"Surface": css`69, 196, 126`,
"Surface[]": css`69, 196, 126`,
"text": css`226, 121, 167`,
"Volume": css`230, 69, 188`,
"Volume[]": css`230, 69, 188`,
"wildcard": css`128, 120, 120`,
}
static pinColorMaterial = css`120, 120, 120`
static pinInputWrapWidth = 143 // px
static removeEventName = "ueb-element-delete"
static scale = {
[-12]: 0.133333,
[-11]: 0.166666,
[-10]: 0.2,
[-9]: 0.233333,
[-8]: 0.266666,
[-7]: 0.3,
[-6]: 0.333333,
[-5]: 0.375,
[-4]: 0.5,
[-3]: 0.675,
[-2]: 0.75,
[-1]: 0.875,
0: 1,
1: 1.25,
2: 1.375,
3: 1.5,
4: 1.675,
5: 1.75,
6: 1.875,
7: 2,
}
static smoothScrollTime = 1000 // ms
static stringEscapedCharacters = /['"\\]/g
static subObjectAttributeNamePrefix = "#SubObject"
/** @param {ObjectEntity} objectEntity */
static subObjectAttributeNameFromEntity = (objectEntity, nameOnly = false) =>
this.subObjectAttributeNamePrefix + (!nameOnly && objectEntity.Class ? `_${objectEntity.Class}` : "")
+ `_${objectEntity.Name}`
/** @param {ObjectReferenceEntity} objectReferenceEntity */
static subObjectAttributeNameFromReference = (objectReferenceEntity, nameOnly = false) =>
this.subObjectAttributeNamePrefix + (!nameOnly ? "_" + objectReferenceEntity.type : "") + "_" + objectReferenceEntity.path
static subObjectAttributeNameFromName = name => this.subObjectAttributeNamePrefix + "_" + name
static switchTargetPattern = /\/Script\/[\w\.\/\:]+K2Node_Switch([A-Z]\w+)+/
static trackingMouseEventName = {
begin: "ueb-tracking-mouse-begin",
end: "ueb-tracking-mouse-end",
}
static unescapedBackslash = /(?<=(?:[^\\]|^)(?:\\\\)*)\\(?!\\)/
static windowApplyEventName = "ueb-window-apply"
static windowApplyButtonText = "OK"
static windowCancelEventName = "ueb-window-cancel"
static windowCancelButtonText = "Cancel"
static windowCloseEventName = "ueb-window-close"
static CommonEnums = {
[this.paths.eMaterialSamplerType]: [
"Color",
"Grayscale",
"Alpha",
"Normal",
"Masks",
"Distance Field Font",
"Linear Color",
"Linear Grayscale",
"Data",
"External",
"Virtual Color",
"Virtual Grayscale",
"Virtual Alpha",
"Virtual Normal",
"Virtual Mask",
"Virtual Linear Color",
"Virtual Linear Grayscal",
],
[this.paths.eSamplerSourceMode]: ["From texture asset", "Shared: Wrap", "Shared: Clamp", "Hidden"],
[this.paths.eSpawnActorCollisionHandlingMethod]: [
["Undefined", "Default"],
["AlwaysSpawn", "Always Spawn, Ignore Collisions"],
["AdjustIfPossibleButAlwaysSpawn", "Try To Adjust Location, But Always Spawn"],
["AdjustIfPossibleButDontSpawnIfColliding", "Try To Adjust Location, Don't Spawn If Still Colliding"],
["DontSpawnIfColliding", "Do Not Spawn"],
],
[this.paths.eSearchCase]: ["CaseSensitive", "IgnoreCase"],
[this.paths.eSearchDir]: ["FromStart", "FromEnd"],
[this.paths.eDrawDebugTrace]: ["None", "ForOneFrame", "ForDuration", "Persistent"],
[this.paths.eTextureMipValueMode]: [
"None (use computed mip level)",
"MipLevel (absolute, 0 is full resolution)",
"MipBias (relative to the computed mip level)",
"Derivative (explicit derivative to compute mip level)",
],
[this.paths.eTraceTypeQuery]: [["TraceTypeQuery1", "Visibility"], ["TraceTypeQuery2", "Camera"]]
}
static ModifierKeys = [
"Ctrl",
"Shift",
"Alt",
"Meta",
]
static Keys = {
/* UE name: JS name */
"Backspace": "Backspace",
"Tab": "Tab",
"LeftControl": "ControlLeft",
"RightControl": "ControlRight",
"LeftShift": "ShiftLeft",
"RightShift": "ShiftRight",
"LeftAlt": "AltLeft",
"RightAlt": "AltRight",
"Enter": "Enter",
"Pause": "Pause",
"CapsLock": "CapsLock",
"Escape": "Escape",
"Space": "Space",
"PageUp": "PageUp",
"PageDown": "PageDown",
"End": "End",
"Home": "Home",
"ArrowLeft": "ArrowLeft",
"ArrowUp": "ArrowUp",
"ArrowRight": "ArrowRight",
"ArrowDown": "ArrowDown",
"PrintScreen": "PrintScreen",
"Insert": "Insert",
"Delete": "Delete",
"Zero": "Digit0",
"One": "Digit1",
"Two": "Digit2",
"Three": "Digit3",
"Four": "Digit4",
"Five": "Digit5",
"Six": "Digit6",
"Seven": "Digit7",
"Eight": "Digit8",
"Nine": "Digit9",
"A": "KeyA",
"B": "KeyB",
"C": "KeyC",
"D": "KeyD",
"E": "KeyE",
"F": "KeyF",
"G": "KeyG",
"H": "KeyH",
"I": "KeyI",
"K": "KeyK",
"L": "KeyL",
"M": "KeyM",
"N": "KeyN",
"O": "KeyO",
"P": "KeyP",
"Q": "KeyQ",
"R": "KeyR",
"S": "KeyS",
"T": "KeyT",
"U": "KeyU",
"V": "KeyV",
"W": "KeyW",
"X": "KeyX",
"Y": "KeyY",
"Z": "KeyZ",
"NumPadZero": "Numpad0",
"NumPadOne": "Numpad1",
"NumPadTwo": "Numpad2",
"NumPadThree": "Numpad3",
"NumPadFour": "Numpad4",
"NumPadFive": "Numpad5",
"NumPadSix": "Numpad6",
"NumPadSeven": "Numpad7",
"NumPadEight": "Numpad8",
"NumPadNine": "Numpad9",
"Multiply": "NumpadMultiply",
"Add": "NumpadAdd",
"Subtract": "NumpadSubtract",
"Decimal": "NumpadDecimal",
"Divide": "NumpadDivide",
"F1": "F1",
"F2": "F2",
"F3": "F3",
"F4": "F4",
"F5": "F5",
"F6": "F6",
"F7": "F7",
"F8": "F8",
"F9": "F9",
"F10": "F10",
"F11": "F11",
"F12": "F12",
"NumLock": "NumLock",
"ScrollLock": "ScrollLock",
}
}