Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit f4a11d9

Browse files
committed
[[ Tutorial ]] Ensure object is always selected when step requires
If an object waiting for a palette to open becomes deselected, go back to the selection step. Also, ensure this works for stacks by implementing similar code in ideActiveStacksChanged to ideSelectedObjectChanged
1 parent 7e50e45 commit f4a11d9

1 file changed

Lines changed: 55 additions & 5 deletions

File tree

Toolset/palettes/tutorial/revtutorial.livecodescript

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,17 @@ on revTutorialStartAtStep pCourse, pTutorial, pLesson, pLocation, pStepName
15711571
revTutorialStartWithState pStepName, sTaggedObjects
15721572
end revTutorialStartAtStep
15731573

1574+
command revTutorialGoBackToSelectStep
1575+
// At the moment it should be a safe assumption that the relevant
1576+
// 'select' step is the previous one
1577+
local tPreviousStep
1578+
put revTutorialPreviousStep() into tPreviousStep
1579+
if sSteps[tPreviousStep]["actions"]["wait"]["wait condition"] is "state" and \
1580+
sSteps[tPreviousStep]["actions"]["wait"]["state"] is "selected" then
1581+
revTutorialGoBackToPreviousStep
1582+
end if
1583+
end revTutorialGoBackToSelectStep
1584+
15741585
command revTutorialSkipCurrentStep
15751586
revTutorialSkipStep sStepName
15761587
end revTutorialSkipCurrentStep
@@ -1686,7 +1697,7 @@ on revTutorialClearAllPalettes
16861697
end repeat
16871698
end revTutorialClearAllPalettes
16881699

1689-
on revTutorialContinue
1700+
on revTutorialContinue pBack
16901701
repeat forever
16911702
if sWaiting then
16921703
exit repeat
@@ -1698,7 +1709,7 @@ on revTutorialContinue
16981709
else if sSteps[sStepName]["actions"]["go"] is empty then
16991710
revTutorialFinish
17001711
exit repeat
1701-
else
1712+
else if not pBack then
17021713
// Otherwise we're here after a wait, so go to the next step
17031714
revTutorialExecuteAction sSteps[sStepName]["actions"]["go"]
17041715
end if
@@ -1953,7 +1964,23 @@ end revTutorialCanSkipStep
19531964
#
19541965
##############################################################################
19551966

1956-
on revTutorialDoGoToStep pStep
1967+
local sPreviousStep
1968+
private function revTutorialPreviousStep
1969+
return sPreviousStep
1970+
end revTutorialPreviousStep
1971+
1972+
command revTutorialGoBackToPreviousStep
1973+
if sPreviousStep is empty then
1974+
exit revTutorialGoBackToPreviousStep
1975+
end if
1976+
revTutorialDoGoToStep sPreviousStep, true
1977+
send "revTutorialContinue true" to stack "revTutorial" in 0 millisecs
1978+
end revTutorialGoBackToPreviousStep
1979+
1980+
on revTutorialDoGoToStep pStep, pBack
1981+
if not pBack then
1982+
put sStepName into sPreviousStep
1983+
end if
19571984
revTutorialInitialiseStep
19581985
revTutorialClearHighlights
19591986
revTutorialClearGuides
@@ -2184,6 +2211,7 @@ on revTutorialWaitUntilThereIsAPaletteForObject pPalette
21842211
revIDEHighlightPaletteObject "menubar", "standard"
21852212
revIDESubscribe "ideEditScript"
21862213
end if
2214+
revIDESubscribe "ideSelectedObjectChanged"
21872215
end revTutorialWaitUntilThereIsAPaletteForObject
21882216

21892217
on revTutorialWaitUntilTheToolIs
@@ -2549,6 +2577,20 @@ end revTutorialReShow
25492577

25502578
on ideActiveStacksChanged
25512579
revTutorialReShow
2580+
2581+
local tObject
2582+
put revIDESelectedObjects() into tObject
2583+
if sWait["wait condition"] is "there is a palette for object" then
2584+
-- If the object became deselected, go back a step
2585+
if not revTutorialObjectIsTaggedObject(tObject, sWait["object"]) then
2586+
revTutorialGoBackToSelectStep
2587+
end if
2588+
else if sWait["wait condition"] is "state" and sWait["state"] is "selected" then
2589+
if revTutorialObjectIsTaggedObject(tObject, sWait["object"]) then
2590+
revIDEUnsubscribe "ideSelectedObjectChanged"
2591+
revTutorialWaitConditionSatisfied
2592+
end if
2593+
end if
25522594
end ideActiveStacksChanged
25532595

25542596
on ideCloseStackRequest pStack
@@ -2780,19 +2822,26 @@ on ideMouseDoubleUp pWhich, pTarget
27802822
end ideMouseDoubleUp
27812823

27822824
on ideSelectedObjectChanged
2825+
local tObject
2826+
put revIDESelectedObjects() into tObject
27832827
if sWait["wait condition"] is "state" and sWait["state"] is "selected" then
2784-
local tObject
2785-
put revIDESelectedObjects() into tObject
27862828
if revTutorialObjectIsTaggedObject(tObject, sWait["object"]) then
2829+
revIDEUnsubscribe "ideSelectedObjectChanged"
27872830
revTutorialWaitConditionSatisfied
27882831
end if
2832+
else if sWait["wait condition"] is "there is a palette for object" then
2833+
-- If the object became deselected, go back a step
2834+
if not revTutorialObjectIsTaggedObject(tObject, sWait["object"]) then
2835+
revTutorialGoBackToSelectStep
2836+
end if
27892837
end if
27902838
end ideSelectedObjectChanged
27912839

27922840
on ideInspectObjects pObjects
27932841
if sWait["wait condition"] is "there is a palette for object" and sWait["palette"] is "inspector" then
27942842
if revTutorialObjectIsTaggedObject(pObjects, sWait["object"]) then
27952843
revIDEUnsubscribe "ideInspectObjects"
2844+
revIDEUnsubscribe "ideSelectedObjectChanged"
27962845
put pObjects into sLastObjects[sWait["palette"]]
27972846
revTutorialWaitConditionSatisfied
27982847
end if
@@ -2803,6 +2852,7 @@ on ideEditScript pObject
28032852
if sWait["wait condition"] is "there is a palette for object" and sWait["palette"] is "script editor" then
28042853
if revTutorialObjectIsTaggedObject(the long id of pObject, sWait["object"]) then
28052854
revIDEUnsubscribe "ideEditScript"
2855+
revIDEUnsubscribe "ideSelectedObjectChanged"
28062856
put pObject into sLastObjects[sWait["palette"]]
28072857
revTutorialWaitConditionSatisfied
28082858
end if

0 commit comments

Comments
 (0)