# HG changeset patch # User Claus Gittinger # Date 1563872252 -7200 # Node ID e7faeed17679bb591eac7eb6ec851a55d097de7e # Parent 6faffd2a64a369fb9bd5e5acb1b85b6d68a4d705 #UI_ENHANCEMENT by cg class: ShowMeHowItWorks class definition added: #do: #language: #thankyou comment/format in: #showing:do: changed: #doStream: #intro #tell: class: ShowMeHowItWorks class comment/format in: #do: diff -r 6faffd2a64a3 -r e7faeed17679 ShowMeHowItWorks.st --- a/ShowMeHowItWorks.st Tue Jul 23 10:14:34 2019 +0200 +++ b/ShowMeHowItWorks.st Tue Jul 23 10:57:32 2019 +0200 @@ -5,8 +5,9 @@ "{ NameSpace: Smalltalk }" Object subclass:#ShowMeHowItWorks - instanceVariableNames:'application opStream lastComponentName lastComponent lastResult' - classVariableNames:'' + instanceVariableNames:'application opStream lastComponentName lastComponent lastResult + voice translate' + classVariableNames:'IntroShownCount' poolDictionaries:'' category:'Interface-Help' ! @@ -54,34 +55,22 @@ !ShowMeHowItWorks class methodsFor:'running'! do:specArray - "must run as a separate process; - otherwise - if started by the app itself - - no events will be processed while running" - - |appWhichStartedMe| - - appWhichStartedMe := WindowGroup activeMainApplication. + "spec contains a list of action commands (show: / moveTo: etc.)" - [ - Error handle:[:ex | - Dialog warn:(self classResources stringWithCRs:'An error was encountered in the show:\\%1' with:ex description) - ] do:[ - self new - application:appWhichStartedMe; - doStream:(specArray readStream) - ]. - ] fork. + self new do:specArray " ShowMeHowItWorks do: #( - (show: 'bla bla') + (language: de) + (show: 'üben üben üben') + (wait: 0.5) (moveTo: NameOfComponent) ) " "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger" - "Modified: / 23-07-2019 / 09:19:40 / Claus Gittinger" + "Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger" ! ! !ShowMeHowItWorks methodsFor:'accessing'! @@ -95,10 +84,24 @@ intro + "/ only say this a few times.. + IntroShownCount := (IntroShownCount ? 0) + 1. + IntroShownCount > 3 ifTrue:[^ self]. + self tell:(self class classResources string:'you can stop the show - by pressing - the shift key'). "Created: / 19-07-2019 / 15:49:19 / Claus Gittinger" + "Modified: / 23-07-2019 / 10:55:15 / Claus Gittinger" +! + +language:lang + + + voice := OperatingSystem bestVoiceForLanguage:lang. + translate := false. + + "Created: / 23-07-2019 / 10:27:02 / Claus Gittinger" ! pause @@ -140,10 +143,10 @@ |xLatedMessage messageView talkDone| - xLatedMessage := application notNil - ifTrue:[application resources string:message] - ifFalse:[message]. - + xLatedMessage := (translate and:[application notNil]) + ifTrue:[application resources string:message] + ifFalse:[message]. + self assert:(operationsOrNothing isNil or:[operationsOrNothing isSequenceable]). messageView := ActiveHelpView for:xLatedMessage. @@ -161,7 +164,7 @@ "/ "/ allow speaker some headoff - Delay waitForSeconds:(xLatedMessage size / 30). + Delay waitForSeconds:(xLatedMessage size / 15)+0.5. ]. operationsOrNothing notEmptyOrNil ifTrue:[ @@ -175,7 +178,15 @@ ]. "Created: / 19-07-2019 / 11:19:27 / Claus Gittinger" - "Modified: / 19-07-2019 / 21:37:07 / Claus Gittinger" + "Modified: / 23-07-2019 / 10:52:30 / Claus Gittinger" +! + +thankyou + + + self show:(self randomThankYou). + + "Created: / 23-07-2019 / 10:50:43 / Claus Gittinger" ! wait:seconds @@ -530,10 +541,11 @@ tell:message self talking ifTrue:[ - OperatingSystem speak:message. + OperatingSystem speak:message voiceName:voice. ]. "Created: / 19-07-2019 / 14:57:50 / Claus Gittinger" + "Modified: / 23-07-2019 / 10:28:02 / Claus Gittinger" ! ! !ShowMeHowItWorks methodsFor:'helpers - broken'! @@ -929,6 +941,37 @@ !ShowMeHowItWorks methodsFor:'running'! +do:specArray + "must run as a separate process; + otherwise - if started by the app itself - + no events will be processed while running" + + voice := OperatingSystem bestVoiceForLanguage:(Smalltalk language). + translate := false. + + application isNil ifTrue:[ + application := WindowGroup activeMainApplication. + ]. + + [ + Error handle:[:ex | + Dialog warn:(self class classResources stringWithCRs:'An error was encountered in the show:\\%1' with:ex description) + ] do:[ + self doStream:(specArray readStream) + ]. + ] fork. + + " + ShowMeHowItWorks do: + #( + (show: 'bla bla') + (moveTo: NameOfComponent) + ) + " + + "Created: / 23-07-2019 / 10:24:53 / Claus Gittinger" +! + doCommand:op "execute a single command" @@ -1002,10 +1045,13 @@ [opStream atEnd] whileFalse:[ self nextCommand. Display shiftDown ifTrue:[ - self tell:(resources string:'you pressed the shift key, do you want to stop the show?'). + (IntroShownCount ? 0) > 3 ifFalse:[ + self tell:(resources string:'you pressed the shift key,'). + ]. + self tell:(resources string:'do you want to stop the show?'). (Dialog confirm:(resources stringWithCRs:'Stop the demonstration?')) ifTrue:[ - self tell:(resources string:'you stopped the show,'). + self tell:(resources string:'OK,'). self tell:(resources string:(self randomThankYou)). ^ AbortOperationRequest raise ]. @@ -1044,7 +1090,7 @@ END" "Created: / 19-07-2019 / 10:52:24 / Claus Gittinger" - "Modified: / 19-07-2019 / 21:41:43 / Claus Gittinger" + "Modified: / 23-07-2019 / 10:54:49 / Claus Gittinger" ! nextCommand