tutorial_fix_and_better_node_snap Tentacule23
This commit is contained in:
1 parent
e32f5244f0
commit
ee29bbcb11
5 files changed
+102
-43
No files matched your search
@@ -459,6 +459,32 @@ function newCanvas() {
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
event.shiftKey === true &&
|
||||
(event.ctrlKey === true || event.metaKey === true) &&
|
||||
(event.key === UI.projects.foundations.spaces.floatingSpace.settings.shortcuts.saveFloatingObjectToBeMoved || event.key === UI.projects.foundations.spaces.floatingSpace.settings.shortcuts.saveFloatingObjectToBeMoved.toLowerCase())
|
||||
|
||||
) {
|
||||
UI.projects.foundations.spaces.floatingSpace.saveFloatingObjectToBeMoved()
|
||||
if (event.preventDefault !== undefined) {
|
||||
event.preventDefault()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
event.shiftKey === true &&
|
||||
(event.ctrlKey === true || event.metaKey === true) &&
|
||||
(event.key === UI.projects.foundations.spaces.floatingSpace.settings.shortcuts.moveSavedFloatingObjectToMouse || event.key === UI.projects.foundations.spaces.floatingSpace.settings.shortcuts.moveSavedFloatingObjectToMouse.toLowerCase())
|
||||
|
||||
) {
|
||||
UI.projects.foundations.spaces.floatingSpace.moveSavedFloatingObjectToMouse(thisObject.mouse.position)
|
||||
if (event.preventDefault !== undefined) {
|
||||
event.preventDefault()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
let nodeOnFocus = await UI.projects.foundations.spaces.designSpace.workspace.getNodeThatIsOnFocus()
|
||||
if (nodeOnFocus !== undefined) {
|
||||
if (nodeOnFocus.payload.uiObject.codeEditor !== undefined) {
|
||||
|
||||
@@ -1536,8 +1536,9 @@ function newEducationTutorialSpace() {
|
||||
|
||||
function onOpening() {
|
||||
//console.log('onOpening');
|
||||
let nodeResume = navigationStack.pop()
|
||||
if (currentStatus !== "Stopped"){return}
|
||||
|
||||
let nodeResume = navigationStack.pop()
|
||||
switch (nodeResume.type) {
|
||||
case 'Tutorial': {
|
||||
resumeTutorial(nodeResume)
|
||||
|
||||
@@ -779,48 +779,14 @@ function newFoundationsActionSwitch() {
|
||||
UI.projects.foundations.functionLibraries.socialBotsFunctions.sendSlackTestMessage(action.node, action.callBackFunction)
|
||||
}
|
||||
break
|
||||
case 'Copy Position':
|
||||
case 'Save node to be moved':
|
||||
{
|
||||
UI.projects.foundations.utilities.clipboard.copyTextToClipboard( action.node.payload.position.x + ';' + action.node.payload.position.y)
|
||||
action.node.payload.uiObject.setInfoMessage('Position copied')
|
||||
UI.projects.foundations.spaces.floatingSpace.saveFloatingObjectToBeMoved()
|
||||
}
|
||||
break
|
||||
case 'Snap to Position':
|
||||
case 'Snap saved node to position':
|
||||
{
|
||||
navigator.clipboard.readText()
|
||||
.then(text => {
|
||||
//console.log('Pasted content: ', text);
|
||||
let newPosition = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
let newVector = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
let positionArray = text.split(";",2)
|
||||
|
||||
newPosition.x = positionArray[0]
|
||||
newPosition.y = positionArray[1]
|
||||
|
||||
if (newPosition.x >= 0 && newPosition.x <= UI.projects.foundations.spaces.floatingSpace.container.frame.width) {
|
||||
newVector.x = newPosition.x - action.node.payload.position.x
|
||||
|
||||
if (newPosition.y >= 0 && newPosition.y <= UI.projects.foundations.spaces.floatingSpace.container.frame.height) {
|
||||
|
||||
newVector.y = newPosition.y - action.node.payload.position.y
|
||||
action.node.payload.floatingObject.container.displace(newVector)
|
||||
action.node.payload.uiObject.setInfoMessage('Snapped to new position')
|
||||
}
|
||||
}
|
||||
else {
|
||||
action.node.payload.uiObject.setErrorMessage('[Error]:Failed to read clipboard contents')
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('[Error]:Failed to read clipboard contents: ', err);
|
||||
action.node.payload.uiObject.setErrorMessage('[Error]:Failed to read clipboard contents')
|
||||
});
|
||||
UI.projects.foundations.spaces.floatingSpace.moveFloatingObject(action.node.payload.position)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ function newFoundationsFloatingSpace() {
|
||||
drawChainLines: true,
|
||||
style: undefined,
|
||||
settings: undefined,
|
||||
floatingObjetSaved: undefined,
|
||||
toggleDrawChainLines: toggleDrawChainLines,
|
||||
toggleDrawReferenceLines: toggleDrawReferenceLines,
|
||||
toggleMapMode: toggleMapMode,
|
||||
@@ -38,7 +39,10 @@ function newFoundationsFloatingSpace() {
|
||||
physics: physics,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
finalize: finalize,
|
||||
saveFloatingObjectToBeMoved: saveFloatingObjectToBeMoved,
|
||||
moveSavedFloatingObjectToMouse: moveSavedFloatingObjectToMouse,
|
||||
moveFloatingObject: moveFloatingObject
|
||||
}
|
||||
|
||||
thisObject.container = newContainer()
|
||||
@@ -106,7 +110,9 @@ function newFoundationsFloatingSpace() {
|
||||
toggleDrawRelationshipLines: "R",
|
||||
toggleDrawParentLines: "C",
|
||||
saveWorkspace: "S",
|
||||
adjustAspectRatio: "A"
|
||||
adjustAspectRatio: "A",
|
||||
saveFloatingObjectToBeMoved: "Z",
|
||||
moveSavedFloatingObjectToMouse: "X"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,6 +570,13 @@ function newFoundationsFloatingSpace() {
|
||||
if (configSettings.shortcuts.adjustAspectRatio !== undefined) {
|
||||
thisObject.settings.shortcuts.adjustAspectRatio = configSettings.shortcuts.adjustAspectRatio
|
||||
}
|
||||
if (configSettings.shortcuts.saveFloatingObjectToBeMoved !== undefined) {
|
||||
thisObject.settings.shortcuts.saveFloatingObjectToBeMoved = configSettings.shortcuts.saveFloatingObjectToBeMoved
|
||||
}
|
||||
if (configSettings.shortcuts.moveSavedFloatingObjectToMouse !== undefined) {
|
||||
thisObject.settings.shortcuts.moveSavedFloatingObjectToMouse = configSettings.shortcuts.moveSavedFloatingObjectToMouse
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -607,4 +620,57 @@ function newFoundationsFloatingSpace() {
|
||||
browserCanvasContext.closePath()
|
||||
browserCanvasContext.fill()
|
||||
}
|
||||
|
||||
function saveFloatingObjectToBeMoved() {
|
||||
|
||||
thisObject.floatingObjetSaved = undefined
|
||||
|
||||
if(floatingObjetOnFocus.isOnFocus === true){
|
||||
thisObject.floatingObjetSaved = floatingObjetOnFocus
|
||||
}
|
||||
if(thisObject.floatingObjetSaved === undefined){
|
||||
UI.projects.foundations.spaces.cockpitSpace.setStatus('No node on focus', 100, UI.projects.foundations.spaces.cockpitSpace.statusTypes.WARNING)
|
||||
}else{
|
||||
UI.projects.foundations.spaces.cockpitSpace.setStatus('Type : [' + thisObject.floatingObjetSaved.payload.node.type + '] , Name : [' + thisObject.floatingObjetSaved.payload.node.name + '] -> Node saved and ready to be moved', 100, UI.projects.foundations.spaces.cockpitSpace.statusTypes.ALL_GOOD)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function moveSavedFloatingObjectToMouse(mousePosition) {
|
||||
|
||||
mousePosition.y = mousePosition.y + CURRENT_TOP_MARGIN
|
||||
let positionConv
|
||||
positionConv = thisObject.container.frame.frameThisPoint(mousePosition)
|
||||
positionConv.x = (2 * mousePosition.x) - positionConv.x
|
||||
positionConv.y = (2 * mousePosition.y) - positionConv.y
|
||||
|
||||
moveFloatingObject(positionConv)
|
||||
|
||||
}
|
||||
|
||||
function moveFloatingObject(position){
|
||||
|
||||
if(thisObject.floatingObjetSaved === undefined){
|
||||
UI.projects.foundations.spaces.cockpitSpace.setStatus('No node saved, unable to move.', 100, UI.projects.foundations.spaces.cockpitSpace.statusTypes.WARNING)
|
||||
}else{
|
||||
|
||||
let newPosition = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
let newVector = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
newPosition.x = position.x
|
||||
newPosition.y = position.y
|
||||
|
||||
newVector.x = newPosition.x - thisObject.floatingObjetSaved.payload.position.x
|
||||
newVector.y = newPosition.y - thisObject.floatingObjetSaved.payload.position.y
|
||||
|
||||
thisObject.floatingObjetSaved.container.displace(newVector)
|
||||
UI.projects.foundations.spaces.cockpitSpace.setStatus('Type : [' + UI.projects.foundations.spaces.floatingSpace.floatingObjetSaved.payload.node.type + '] , Name : [' + UI.projects.foundations.spaces.floatingSpace.floatingObjetSaved.payload.node.name + '] -> Snapped to new position', 100, UI.projects.foundations.spaces.cockpitSpace.statusTypes.ALL_GOOD)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -367,7 +367,7 @@ function newUiObjectConstructor() {
|
||||
}
|
||||
menuItemsInitialValues.push(
|
||||
{
|
||||
action: 'Copy Position',
|
||||
action: 'Save node to be moved',
|
||||
actionFunction: floatingObject.payload.executeAction,
|
||||
actionProject: 'Foundations',
|
||||
label: undefined,
|
||||
@@ -383,7 +383,7 @@ function newUiObjectConstructor() {
|
||||
)
|
||||
menuItemsInitialValues.push(
|
||||
{
|
||||
action: 'Snap to Position',
|
||||
action: 'Snap saved node to position',
|
||||
actionFunction: floatingObject.payload.executeAction,
|
||||
actionProject: 'Foundations',
|
||||
label: undefined,
|
||||
|
||||
Reference in new issue
Block a user