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

Commit a38a01d

Browse files
committed
[[ Tutorial ]] Add 'Do It For Me' buton to non-script action steps
This enables users to skip individual action steps.
1 parent 94b48d0 commit a38a01d

1 file changed

Lines changed: 58 additions & 32 deletions

File tree

Toolset/palettes/tutorial/revtutorial.livecodescript

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -820,10 +820,12 @@ constant kMaxScriptHeight = 200
820820
local sDontShow
821821
local sLastShape
822822
on revTutorialPositionStack pStack, pObject, pWidthOverride, pForceVertical
823-
local tGotItButtonID, tCopyButtonID
823+
local tGotItButtonID, tCopyButtonID, tDoItButtonID
824824
local tMsgFieldID, tScriptFieldID, tImageID
825+
local tActionButton
825826

826827
put the long id of button "Got It" of stack "revTutorial" into tGotItButtonID
828+
put the long id of button "Do It For Me" of stack "revTutorial" into tDoItButtonID
827829
put the long id of button "Copy Script" of stack "revTutorial" into tCopyButtonID
828830
put the long id of field "Message" of stack "revTutorial" into tMsgFieldID
829831
put the long id of field "Script" of stack "revTutorial" into tScriptFieldID
@@ -844,9 +846,7 @@ on revTutorialPositionStack pStack, pObject, pWidthOverride, pForceVertical
844846
put the defaultStack into tDefaultStack
845847
set the defaultstack to "revTutorial"
846848
if sIsInterlude then
847-
show tGotItButtonID
848-
set the height of tGotItButtonID to the formattedHeight of tGotItButtonID
849-
set the width of tGotItButtonID to the formattedWidth of tGotItButtonID
849+
put tGotItButtonID into tActionButton
850850
put max(pWidthOverride, 460) into pWidthOverride
851851
else
852852
hide tGotItButtonID
@@ -859,9 +859,14 @@ on revTutorialPositionStack pStack, pObject, pWidthOverride, pForceVertical
859859
else
860860
put true into tHasScript
861861
show tScriptFieldID
862-
set the height of tCopyButtonID to the formattedHeight of tCopyButtonID
863-
set the width of tCopyButtonID to the formattedWidth of tCopyButtonID
864-
show tCopyButtonID
862+
put tCopyButtonID into tActionButton
863+
end if
864+
865+
# If this is a non-script action step, show the 'Do It For Me' button
866+
if sIsInterlude or tHasScript then
867+
hide tDoItButtonID
868+
else
869+
put tDoItButtonID into tActionButton
865870
end if
866871

867872
local tHasImage
@@ -945,10 +950,11 @@ on revTutorialPositionStack pStack, pObject, pWidthOverride, pForceVertical
945950
put max(tWidth, the width of tUrlControlID + kMargin * 2) into tWidth
946951
end if
947952

948-
if sIsInterlude then
949-
add the height of tGotItButtonID + kMargin to tHeight
950-
else if tHasScript then
951-
add the height of tCopyButtonID + kMargin to tHeight
953+
if tActionButton is not empty then
954+
set the height of tActionButton to the formattedHeight of tActionButton
955+
set the width of tActionButton to the formattedWidth of tActionButton
956+
show tActionButton
957+
add the height of tActionButton + kMargin to tHeight
952958
end if
953959

954960
if tHasImage then
@@ -1013,15 +1019,18 @@ on revTutorialPositionStack pStack, pObject, pWidthOverride, pForceVertical
10131019
set the rect of stack "revTutorial" to 0, 0, tWidth, tHeight
10141020
set the topleft of stack "revTutorial" to tStackLeft, tStackTop
10151021
else
1016-
if sIsInterlude then
1017-
set the bottomright of tGotItButtonID to tWidth - kMargin, tHeight - kMargin
1018-
else if tHasScript then
1019-
set the bottomright of tCopyButtonID to tWidth - kMargin, tHeight - kMargin
1020-
end if
10211022
set the rect of stack "revTutorial" to 0, 0, tWidth, tHeight
10221023
set the loc of stack "revTutorial" to item 3 of tScreenRect / 2, item 4 of tScreenRect / 2
10231024
end if
1024-
1025+
if tActionButton is not empty then
1026+
local tButtonBottom, tButtonRight
1027+
put tWidth - kMargin into tButtonRight
1028+
put tHeight - kMargin into tButtonBottom
1029+
if tHasPointer and not tPointerLeft and not tPointVertical then
1030+
subtract kPointerWidth / 2 from tButtonRight
1031+
end if
1032+
set the bottomright of tActionButton to tButtonRight,tButtonBottom
1033+
end if
10251034
if sIsInterlude then
10261035
set the backColor of stack "revTutorial" to revTutorialInterludeColor()
10271036
else
@@ -1313,6 +1322,10 @@ on revInitialiseTutorial
13131322
delete button "Got It" of stack "revTutorial"
13141323
end if
13151324

1325+
if there is a button "Do It For Me" of stack "revTutorial" then
1326+
delete button "Do It For Me" of stack "revTutorial"
1327+
end if
1328+
13161329
if there is a button "Copy Script" of stack "revTutorial" then
13171330
delete button "Copy Script" of stack "revTutorial"
13181331
end if
@@ -1383,6 +1396,10 @@ on revInitialiseTutorial
13831396
set the backColor of it to revTutorialMessageAltColor()
13841397
set the label of it to "Copy Script To Editor"
13851398

1399+
create button "Do It For Me"
1400+
set the backColor of it to revTutorialMessageAltColor()
1401+
set the label of it to "Do It For Me"
1402+
13861403
reset the templateButton
13871404

13881405
create image "Image"
@@ -1533,33 +1550,39 @@ on revTutorialStartAtStep pCourse, pTutorial, pLesson, pLocation, pStepName
15331550
revTutorialStartWithState pStepName, sTaggedObjects
15341551
end revTutorialStartAtStep
15351552

1553+
command revTutorialSkipCurrentStep
1554+
revTutorialSkipStep sStepName
1555+
end revTutorialSkipCurrentStep
1556+
15361557
on revTutorialSkip
1537-
local tTutorialInfo
1538-
put revIDETutorialInProgress() into tTutorialInfo
1539-
1540-
if tTutorialInfo is empty then
1541-
exit revTutorialSkip
1542-
end if
1543-
15441558
# Calculate the skip point
15451559
local tSkipPoint
15461560
put sStepName into tSkipPoint
15471561
repeat while tSkipPoint is not empty and sSteps[tSkipPoint]["skip point"] is not true
15481562
put sSteps[tSkipPoint]["actions"]["go"]["step"] into tSkipPoint
15491563
end repeat
15501564

1551-
local tRunUntil
1552-
put sSteps[tSkipPoint]["actions"]["go"]["step"] into tRunUntil
1565+
revTutorialSkipStep tSkipPoint
1566+
end revTutorialSkip
1567+
1568+
command revTutorialSkipStep pStep
1569+
local tTutorialInfo
1570+
put revIDETutorialInProgress() into tTutorialInfo
1571+
1572+
if tTutorialInfo is empty then
1573+
exit revTutorialSkipStep
1574+
end if
15531575

15541576
# Run from the current step to the next skip point
15551577
revTutorialRunTutorial tTutorialInfo["course"], tTutorialInfo["tutorial"], \
1556-
tTutorialInfo["lesson"], tTutorialInfo["location"], sStepName, tRunUntil
1578+
tTutorialInfo["lesson"], tTutorialInfo["location"], sStepName, pStep
1579+
15571580
revTutorialInitialiseStep
15581581

15591582
# Due to how the run loop works, we need to continue from the step
15601583
# *prior* to the next executed step
1561-
revTutorialContinueFromStep tSkipPoint
1562-
end revTutorialSkip
1584+
revTutorialContinueFromStep pStep
1585+
end revTutorialSkipStep
15631586

15641587
on revTutorialStop
15651588
revTutorialClearHighlights
@@ -2706,6 +2729,10 @@ on mouseUp pWhich
27062729
revTutorialCopyScriptToEditor
27072730
end if
27082731

2732+
if tObject is the long id of button "Do It For Me" of stack "revTutorial" then
2733+
revTutorialSkipCurrentStep
2734+
end if
2735+
27092736
if word 1 of tObject is "button" then
27102737
revTutorialSetUnpressedState tObject
27112738
end if
@@ -3155,12 +3182,11 @@ on revTutorialRunSteps pSteps, pFromStep, pUntilStep
31553182
local tStep, tStepNum
31563183
put pFromStep into tStep
31573184
repeat until tStep is empty
3185+
revTutorialSetContextualStepData pSteps[tStep]
3186+
revTutorialRunStep pSteps[tStep]["actions"]
31583187
if tStep is pUntilStep then
31593188
exit repeat
31603189
end if
3161-
3162-
revTutorialSetContextualStepData pSteps[tStep]
3163-
revTutorialRunStep pSteps[tStep]["actions"]
31643190
put pSteps[tStep]["actions"]["go"]["step"] into tStep
31653191
end repeat
31663192
unlock screen

0 commit comments

Comments
 (0)