Skip to main content

scratch_test_model/blocks/
statements.rs

1use std::collections::HashMap;
2
3use scratch_test_model_proc::Block;
4
5use super::procedures::procedures_call;
6use crate::{
7    attrs::{
8        BroadcastId, Color, DirectDropdownOf, DropdownMenuOf, Expression, ExpressionRef, List,
9        ProcedureArgumentId, RefBlock, RoundDropdownMenuOf, Variable,
10        dropdowns::{
11            ChooseClone, ForwardBackward, LooksBackdrops, LooksCostume, LooksEffect,
12            LooksGotoFrontBack, MotionPointtowards, MotionRotationstyle, PenColorParam,
13            PossibleGlideToPos, PossibleGoToPos, SensingDragmode, SoundEffect, SoundSounds,
14            Text2SpeechLanguages, Text2SpeechVoices,
15        },
16    },
17    blocks::{comparisons::CmpBlockKind, procedures::ProcedureId},
18};
19
20#[derive(Debug, PartialEq, Clone, Block)]
21#[block(default_location = inputs)]
22pub enum StmtBlockKind {
23    ControlCreateCloneOf {
24        clone_option: RoundDropdownMenuOf<ChooseClone>,
25    },
26    ControlDeleteThisClone,
27    ControlForever {
28        substack: Option<RefBlock<Vec<StmtBlockKind>>>,
29    },
30    ControlIf {
31        condition: Option<RefBlock<CmpBlockKind>>,
32        substack: Option<RefBlock<Vec<StmtBlockKind>>>,
33    },
34    ControlIfElse {
35        condition: Option<RefBlock<CmpBlockKind>>,
36        substack: Option<RefBlock<Vec<StmtBlockKind>>>,
37        substack2: Option<RefBlock<Vec<StmtBlockKind>>>,
38    },
39    ControlRepeat {
40        times: Expression,
41        substack: Option<RefBlock<Vec<StmtBlockKind>>>,
42    },
43    ControlRepeatUntil {
44        condition: Option<RefBlock<CmpBlockKind>>,
45        substack: Option<RefBlock<Vec<StmtBlockKind>>>,
46    },
47    ControlStartAsClone,
48    ControlStop {
49        #[block(location = fields)]
50        stop_option: DirectDropdownOf<svalue::ARc<str>>,
51    },
52    ControlWait {
53        duration: Expression,
54    },
55    ControlWaitUntil {
56        condition: Option<RefBlock<CmpBlockKind>>,
57    },
58
59    DataAddtolist {
60        #[block(location = fields)]
61        list: List,
62        item: Expression,
63    },
64    DataChangevariableby {
65        #[block(location = fields)]
66        variable: Variable,
67        value: Expression,
68    },
69    DataDeletealloflist {
70        #[block(location = fields)]
71        list: List,
72    },
73    DataDeleteoflist {
74        #[block(location = fields)]
75        list: List,
76        index: Expression,
77    },
78    DataHidelist {
79        #[block(location = fields)]
80        list: List,
81    },
82    DataHidevariable {
83        #[block(location = fields)]
84        variable: Variable,
85    },
86    DataInsertatlist {
87        #[block(location = fields)]
88        list: List,
89        index: Expression,
90        item: Expression,
91    },
92    DataReplaceitemoflist {
93        #[block(location = fields)]
94        list: List,
95        index: Expression,
96        item: Expression,
97    },
98    DataSetvariableto {
99        #[block(location = fields)]
100        variable: Variable,
101        value: Expression,
102    },
103    DataShowlist {
104        #[block(location = fields)]
105        list: List,
106    },
107
108    DataShowvariable {
109        #[block(location = fields)]
110        variable: Variable,
111    },
112
113    EventBroadcast {
114        broadcast_input: BroadcastId,
115    },
116    EventBroadcastandwait {
117        broadcast_input: BroadcastId,
118    },
119
120    LooksChangeeffectby {
121        #[block(location = fields)]
122        effect: DirectDropdownOf<LooksEffect>,
123        change: Expression,
124    },
125    LooksChangesizeby {
126        change: Expression,
127    },
128    LooksCleargraphiceffects,
129    LooksGoforwardbackwardlayers {
130        #[block(location = fields)]
131        forward_backward: DirectDropdownOf<ForwardBackward>,
132        num: Expression,
133    },
134    LooksGotofrontback {
135        #[block(location = fields)]
136        front_back: DirectDropdownOf<LooksGotoFrontBack>,
137    },
138    LooksHide,
139    LooksNextcostume,
140    LooksNextbackdrop,
141    LooksSay {
142        message: Expression,
143    },
144    LooksSayforsecs {
145        message: Expression,
146        secs: Expression,
147    },
148    LooksSetsizeto {
149        size: Expression,
150    },
151    LooksSeteffectto {
152        #[block(location = fields)]
153        effect: DirectDropdownOf<LooksEffect>,
154        value: Expression,
155    },
156    LooksShow,
157    LooksSwitchbackdropto {
158        backdrop: RoundDropdownMenuOf<LooksBackdrops>,
159    },
160    LooksSwitchcostumeto {
161        costume: RoundDropdownMenuOf<LooksCostume>,
162    },
163    LooksThink {
164        message: Expression,
165    },
166    LooksThinkforsecs {
167        message: Expression,
168        secs: Expression,
169    },
170
171    MotionPointtowards {
172        towards: RoundDropdownMenuOf<MotionPointtowards>,
173    },
174    MotionGotoxy {
175        x: Expression,
176        y: Expression,
177    },
178    MotionTurnright {
179        degrees: Expression,
180    },
181    MotionGoto {
182        to: RoundDropdownMenuOf<PossibleGoToPos>,
183    },
184    MotionTurnleft {
185        degrees: Expression,
186    },
187
188    MotionSetrotationstyle {
189        #[block(location = fields)]
190        style: DirectDropdownOf<MotionRotationstyle>,
191    },
192    MotionGlidesecstoxy {
193        secs: Expression,
194        x: Expression,
195        y: Expression,
196    },
197    MotionSetx {
198        x: Expression,
199    },
200    MotionSety {
201        y: Expression,
202    },
203    MotionChangexby {
204        dx: Expression,
205    },
206    MotionMovesteps {
207        steps: Expression,
208    },
209    MotionPointindirection {
210        direction: Expression,
211    },
212    MotionChangeyby {
213        dy: Expression,
214    },
215
216    MotionGlideto {
217        secs: Expression,
218        to: RoundDropdownMenuOf<PossibleGlideToPos>,
219    },
220
221    SensingAskandwait {
222        question: Expression,
223    },
224
225    SensingSetdragmode {
226        #[block(location = fields)]
227        drag_mode: DirectDropdownOf<SensingDragmode>,
228    },
229    SoundChangevolumeby {
230        volume: Expression,
231    },
232    SoundStopallsounds,
233    SoundChangeeffectby {
234        #[block(location = fields)]
235        effect: DirectDropdownOf<SoundEffect>,
236        value: Expression,
237    },
238    SoundSeteffectto {
239        #[block(location = fields)]
240        effect: DirectDropdownOf<SoundEffect>,
241        value: Expression,
242    },
243    SoundPlayuntildone {
244        sound_menu: RoundDropdownMenuOf<SoundSounds>,
245    },
246    SoundSetvolumeto {
247        volume: Expression,
248    },
249    SoundCleareffects,
250    SoundPlay {
251        sound_menu: RoundDropdownMenuOf<SoundSounds>,
252    },
253
254    PenClear,
255    PenStamp,
256    #[block(opcode = "pen_setPenColorToColor")]
257    PenSetPenColorToColor {
258        color: either::Either<Color, ExpressionRef>,
259    },
260    #[block(opcode = "pen_changePenColorParamBy")]
261    PenChangePenColorParamBy {
262        color_param: DropdownMenuOf<PenColorParam>,
263        value: Expression,
264    },
265    #[block(opcode = "pen_setPenColorParamTo")]
266    PenSetPenColorParamTo {
267        color_param: DropdownMenuOf<PenColorParam>,
268        value: Expression,
269    },
270    #[block(opcode = "pen_changePenSizeBy")]
271    PenChangePenSizeBy {
272        size: Expression,
273    },
274    #[block(opcode = "pen_penUp")]
275    PenUp,
276    #[block(opcode = "pen_penDown")]
277    PenDown,
278    #[block(opcode = "pen_setPenSizeTo")]
279    PenSetPenSizeTo {
280        size: Expression,
281    },
282
283    #[block(opcode = "procedures_call", parse_via = procedures_call)]
284    ProceduresCall {
285        procedure_id: ProcedureId,
286        arguments: HashMap<ProcedureArgumentId, Option<Expression>>,
287        warp: bool,
288    },
289
290    #[block(opcode = "text2speech_setVoice")]
291    Text2SpeechSetVoice {
292        voice: DropdownMenuOf<Text2SpeechVoices>,
293    },
294    #[block(opcode = "text2speech_setLanguage")]
295    Text2SpeechSetLanguage {
296        language: DropdownMenuOf<Text2SpeechLanguages>,
297    },
298    #[block(opcode = "text2speech_speakAndWait")]
299    Text2SpeechSpeakAndWait {
300        words: Expression,
301    },
302}
303
304//
305/*
306    skip => {
307        ("procedures_call")  ProceduresCall {
308            // argument_values: HashMap<Id, Expression>,
309            proccode: ARc<str>,
310            // argumentids: ARc<[ARc<str>]>,
311            arguments: ARc<[(Id, Option<Expression>)]>
312        },
313    },
314*/