equal
deleted
inserted
replaced
3 "{ Package: 'stx:libtool2' }" |
3 "{ Package: 'stx:libtool2' }" |
4 |
4 |
5 "{ NameSpace: Smalltalk }" |
5 "{ NameSpace: Smalltalk }" |
6 |
6 |
7 Object subclass:#ShowMeHowItWorks |
7 Object subclass:#ShowMeHowItWorks |
8 instanceVariableNames:'application opStream lastComponentName lastComponent lastResult' |
8 instanceVariableNames:'application opStream lastComponentName lastComponent lastResult |
9 classVariableNames:'' |
9 voice translate' |
|
10 classVariableNames:'IntroShownCount' |
10 poolDictionaries:'' |
11 poolDictionaries:'' |
11 category:'Interface-Help' |
12 category:'Interface-Help' |
12 ! |
13 ! |
13 |
14 |
14 !ShowMeHowItWorks class methodsFor:'documentation'! |
15 !ShowMeHowItWorks class methodsFor:'documentation'! |
52 ! ! |
53 ! ! |
53 |
54 |
54 !ShowMeHowItWorks class methodsFor:'running'! |
55 !ShowMeHowItWorks class methodsFor:'running'! |
55 |
56 |
56 do:specArray |
57 do:specArray |
57 "must run as a separate process; |
58 "spec contains a list of action commands (show: / moveTo: etc.)" |
58 otherwise - if started by the app itself - |
59 |
59 no events will be processed while running" |
60 self new do:specArray |
60 |
|
61 |appWhichStartedMe| |
|
62 |
|
63 appWhichStartedMe := WindowGroup activeMainApplication. |
|
64 |
|
65 [ |
|
66 Error handle:[:ex | |
|
67 Dialog warn:(self classResources stringWithCRs:'An error was encountered in the show:\\%1' with:ex description) |
|
68 ] do:[ |
|
69 self new |
|
70 application:appWhichStartedMe; |
|
71 doStream:(specArray readStream) |
|
72 ]. |
|
73 ] fork. |
|
74 |
61 |
75 " |
62 " |
76 ShowMeHowItWorks do: |
63 ShowMeHowItWorks do: |
77 #( |
64 #( |
78 (show: 'bla bla') |
65 (language: de) |
|
66 (show: 'üben üben üben') |
|
67 (wait: 0.5) |
79 (moveTo: NameOfComponent) |
68 (moveTo: NameOfComponent) |
80 ) |
69 ) |
81 " |
70 " |
82 |
71 |
83 "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger" |
72 "Created: / 19-07-2019 / 10:52:59 / Claus Gittinger" |
84 "Modified: / 23-07-2019 / 09:19:40 / Claus Gittinger" |
73 "Modified (comment): / 23-07-2019 / 10:26:42 / Claus Gittinger" |
85 ! ! |
74 ! ! |
86 |
75 |
87 !ShowMeHowItWorks methodsFor:'accessing'! |
76 !ShowMeHowItWorks methodsFor:'accessing'! |
88 |
77 |
89 application:something |
78 application:something |
93 !ShowMeHowItWorks methodsFor:'commands'! |
82 !ShowMeHowItWorks methodsFor:'commands'! |
94 |
83 |
95 intro |
84 intro |
96 <action> |
85 <action> |
97 |
86 |
|
87 "/ only say this a few times.. |
|
88 IntroShownCount := (IntroShownCount ? 0) + 1. |
|
89 IntroShownCount > 3 ifTrue:[^ self]. |
|
90 |
98 self tell:(self class classResources |
91 self tell:(self class classResources |
99 string:'you can stop the show - by pressing - the shift key'). |
92 string:'you can stop the show - by pressing - the shift key'). |
100 |
93 |
101 "Created: / 19-07-2019 / 15:49:19 / Claus Gittinger" |
94 "Created: / 19-07-2019 / 15:49:19 / Claus Gittinger" |
|
95 "Modified: / 23-07-2019 / 10:55:15 / Claus Gittinger" |
|
96 ! |
|
97 |
|
98 language:lang |
|
99 <action> |
|
100 |
|
101 voice := OperatingSystem bestVoiceForLanguage:lang. |
|
102 translate := false. |
|
103 |
|
104 "Created: / 23-07-2019 / 10:27:02 / Claus Gittinger" |
102 ! |
105 ! |
103 |
106 |
104 pause |
107 pause |
105 <action> |
108 <action> |
106 |
109 |
138 |
141 |
139 <action> |
142 <action> |
140 |
143 |
141 |xLatedMessage messageView talkDone| |
144 |xLatedMessage messageView talkDone| |
142 |
145 |
143 xLatedMessage := application notNil |
146 xLatedMessage := (translate and:[application notNil]) |
144 ifTrue:[application resources string:message] |
147 ifTrue:[application resources string:message] |
145 ifFalse:[message]. |
148 ifFalse:[message]. |
146 |
149 |
147 self assert:(operationsOrNothing isNil or:[operationsOrNothing isSequenceable]). |
150 self assert:(operationsOrNothing isNil or:[operationsOrNothing isSequenceable]). |
148 |
151 |
149 messageView := ActiveHelpView for:xLatedMessage. |
152 messageView := ActiveHelpView for:xLatedMessage. |
150 "/ messageView shapeStyle:#cartoon. |
153 "/ messageView shapeStyle:#cartoon. |
151 [ |
154 [ |
159 talkDone signal |
162 talkDone signal |
160 ] fork. |
163 ] fork. |
161 |
164 |
162 "/ |
165 "/ |
163 "/ allow speaker some headoff |
166 "/ allow speaker some headoff |
164 Delay waitForSeconds:(xLatedMessage size / 30). |
167 Delay waitForSeconds:(xLatedMessage size / 15)+0.5. |
165 ]. |
168 ]. |
166 |
169 |
167 operationsOrNothing notEmptyOrNil ifTrue:[ |
170 operationsOrNothing notEmptyOrNil ifTrue:[ |
168 self doStream:(operationsOrNothing readStream). |
171 self doStream:(operationsOrNothing readStream). |
169 ]. |
172 ]. |
173 self talking ifTrue:[ |
176 self talking ifTrue:[ |
174 talkDone wait. |
177 talkDone wait. |
175 ]. |
178 ]. |
176 |
179 |
177 "Created: / 19-07-2019 / 11:19:27 / Claus Gittinger" |
180 "Created: / 19-07-2019 / 11:19:27 / Claus Gittinger" |
178 "Modified: / 19-07-2019 / 21:37:07 / Claus Gittinger" |
181 "Modified: / 23-07-2019 / 10:52:30 / Claus Gittinger" |
|
182 ! |
|
183 |
|
184 thankyou |
|
185 <action> |
|
186 |
|
187 self show:(self randomThankYou). |
|
188 |
|
189 "Created: / 23-07-2019 / 10:50:43 / Claus Gittinger" |
179 ! |
190 ! |
180 |
191 |
181 wait:seconds |
192 wait:seconds |
182 <action> |
193 <action> |
183 |
194 |
528 "Created: / 19-07-2019 / 21:39:18 / Claus Gittinger" |
539 "Created: / 19-07-2019 / 21:39:18 / Claus Gittinger" |
529 ! |
540 ! |
530 |
541 |
531 tell:message |
542 tell:message |
532 self talking ifTrue:[ |
543 self talking ifTrue:[ |
533 OperatingSystem speak:message. |
544 OperatingSystem speak:message voiceName:voice. |
534 ]. |
545 ]. |
535 |
546 |
536 "Created: / 19-07-2019 / 14:57:50 / Claus Gittinger" |
547 "Created: / 19-07-2019 / 14:57:50 / Claus Gittinger" |
|
548 "Modified: / 23-07-2019 / 10:28:02 / Claus Gittinger" |
537 ! ! |
549 ! ! |
538 |
550 |
539 !ShowMeHowItWorks methodsFor:'helpers - broken'! |
551 !ShowMeHowItWorks methodsFor:'helpers - broken'! |
540 |
552 |
541 click:buttonNr atPosition:position |
553 click:buttonNr atPosition:position |
927 "Modified: / 23-07-2019 / 09:38:38 / Claus Gittinger" |
939 "Modified: / 23-07-2019 / 09:38:38 / Claus Gittinger" |
928 ! ! |
940 ! ! |
929 |
941 |
930 !ShowMeHowItWorks methodsFor:'running'! |
942 !ShowMeHowItWorks methodsFor:'running'! |
931 |
943 |
|
944 do:specArray |
|
945 "must run as a separate process; |
|
946 otherwise - if started by the app itself - |
|
947 no events will be processed while running" |
|
948 |
|
949 voice := OperatingSystem bestVoiceForLanguage:(Smalltalk language). |
|
950 translate := false. |
|
951 |
|
952 application isNil ifTrue:[ |
|
953 application := WindowGroup activeMainApplication. |
|
954 ]. |
|
955 |
|
956 [ |
|
957 Error handle:[:ex | |
|
958 Dialog warn:(self class classResources stringWithCRs:'An error was encountered in the show:\\%1' with:ex description) |
|
959 ] do:[ |
|
960 self doStream:(specArray readStream) |
|
961 ]. |
|
962 ] fork. |
|
963 |
|
964 " |
|
965 ShowMeHowItWorks do: |
|
966 #( |
|
967 (show: 'bla bla') |
|
968 (moveTo: NameOfComponent) |
|
969 ) |
|
970 " |
|
971 |
|
972 "Created: / 23-07-2019 / 10:24:53 / Claus Gittinger" |
|
973 ! |
|
974 |
932 doCommand:op |
975 doCommand:op |
933 "execute a single command" |
976 "execute a single command" |
934 |
977 |
935 |numArgs sel args method| |
978 |numArgs sel args method| |
936 |
979 |
1000 [ |
1043 [ |
1001 opStream := specStream. |
1044 opStream := specStream. |
1002 [opStream atEnd] whileFalse:[ |
1045 [opStream atEnd] whileFalse:[ |
1003 self nextCommand. |
1046 self nextCommand. |
1004 Display shiftDown ifTrue:[ |
1047 Display shiftDown ifTrue:[ |
1005 self tell:(resources string:'you pressed the shift key, do you want to stop the show?'). |
1048 (IntroShownCount ? 0) > 3 ifFalse:[ |
|
1049 self tell:(resources string:'you pressed the shift key,'). |
|
1050 ]. |
|
1051 self tell:(resources string:'do you want to stop the show?'). |
1006 (Dialog confirm:(resources stringWithCRs:'Stop the demonstration?')) |
1052 (Dialog confirm:(resources stringWithCRs:'Stop the demonstration?')) |
1007 ifTrue:[ |
1053 ifTrue:[ |
1008 self tell:(resources string:'you stopped the show,'). |
1054 self tell:(resources string:'OK,'). |
1009 self tell:(resources string:(self randomThankYou)). |
1055 self tell:(resources string:(self randomThankYou)). |
1010 ^ AbortOperationRequest raise |
1056 ^ AbortOperationRequest raise |
1011 ]. |
1057 ]. |
1012 ]. |
1058 ]. |
1013 ]. |
1059 ]. |
1042 ) |
1088 ) |
1043 ) |
1089 ) |
1044 END" |
1090 END" |
1045 |
1091 |
1046 "Created: / 19-07-2019 / 10:52:24 / Claus Gittinger" |
1092 "Created: / 19-07-2019 / 10:52:24 / Claus Gittinger" |
1047 "Modified: / 19-07-2019 / 21:41:43 / Claus Gittinger" |
1093 "Modified: / 23-07-2019 / 10:54:49 / Claus Gittinger" |
1048 ! |
1094 ! |
1049 |
1095 |
1050 nextCommand |
1096 nextCommand |
1051 self doCommand:(opStream next). |
1097 self doCommand:(opStream next). |
1052 |
1098 |