Skip to main content

scratch_test_model/attrs/
dropdowns.rs

1mod any_dropdown;
2mod direct_dropdown;
3mod dropdown_menu_of;
4mod instances_direct;
5mod instances_menu;
6
7pub use any_dropdown::AnyDropdownOf;
8pub use direct_dropdown::DirectDropdownOf;
9pub use dropdown_menu_of::DropdownMenuOf;
10use either::Either;
11pub use instances_direct::{
12    ForwardBackward, GreaterThan, LooksEffect, LooksGotoFrontBack,
13    LooksTargetNumbername as LooksBackdropnumbername,
14    LooksTargetNumbername as LooksCostumenumbername, MotionRotationstyle, OperatorMathop,
15    SensingCurrent, SensingDragmode, SensingOfProperty, SoundEffect,
16};
17pub use instances_menu::{
18    ChooseClone, LooksBackdrops, LooksCostume, MotionPointtowards, PenColorParam,
19    PossibleGlideToPos, PossibleGoToPos, SensingDistanceto, SensingKeyoptions, SensingOfObject,
20    SensingTouchingobject, SoundSounds, Text2SpeechLanguages, Text2SpeechVoices,
21};
22
23use crate::_exports::AsOpcodeUnit;
24
25/// This indicates that only the block-/data-referencing variants are needed
26pub type ExpressionRef = Expression;
27pub type RoundDropdownMenuOf<T, S = T> = Either<DropdownMenuOf<T, S>, ExpressionRef>;
28pub type RoundDirectDropdownOf<T> = Either<DirectDropdownOf<T>, ExpressionRef>;
29
30macro_rules! construct_menu_arr {
31    ($($ty: ident),* $(,)?) => {
32        [
33        $(
34        {
35        use instances_menu::*;
36        type X = <$ty as AsOpcodeUnit>::OpcodeUnit;
37           X::$ty.k_opcode_name()
38        }
39        ),*
40        ]
41    };
42}
43
44pub const META_DROPDOWN_MENUES: [&str; 14] = construct_menu_arr![
45    MotionPointtowardsMenu,
46    SensingTouchingobjectmenu,
47    SensingOfObjectMenu,
48    MotionGlidetoMenu,
49    LooksBackdropsMenu,
50    MotionGotoMenu,
51    ControlCreateCloneOfMenu,
52    LooksCostumeMenu,
53    SoundSoundsMenu,
54    SensingKeyoptionsMenu,
55    PenColorParamMenu,
56    Text2SpeechVoicesMenu,
57    Text2SpeechLanguagesMenu,
58    SensingDistancetoMenu,
59];
60
61use crate::attrs::Expression;
62use crate::attrs::dropdowns::direct_dropdown::FromDirectDropdownString;
63
64impl FromDirectDropdownString for svalue::ARc<str> {
65    const VALID_HINT: &'static str = "any string value";
66
67    fn from_direct_dropdown_string(val: &str) -> Option<Self> {
68        Some(val.into())
69    }
70}