|
1 | 1 | #include <scratchcpp/iengine.h> |
2 | 2 | #include <scratchcpp/compiler.h> |
| 3 | +#include <scratchcpp/input.h> |
3 | 4 | #include <scratchcpp/executioncontext.h> |
4 | 5 | #include <scratchcpp/target.h> |
5 | 6 | #include <scratchcpp/ispritehandler.h> |
@@ -142,15 +143,26 @@ CompilerValue *PenBlocks::compileSetPenColorToColor(Compiler *compiler) |
142 | 143 |
|
143 | 144 | CompilerValue *PenBlocks::compileChangePenColorParamBy(Compiler *compiler) |
144 | 145 | { |
145 | | - CompilerValue *param = compiler->addInput("COLOR_PARAM"); |
| 146 | + Input *paramInput = compiler->input("COLOR_PARAM"); |
| 147 | + CompilerValue *param = compiler->addInput(paramInput); |
146 | 148 | CompilerValue *value = compiler->addInput("VALUE"); |
147 | 149 | CompilerValue *change = compiler->addConstValue(true); |
148 | 150 |
|
149 | | - compiler->addTargetFunctionCall( |
150 | | - "pen_set_or_change_color_param", |
151 | | - Compiler::StaticType::Void, |
152 | | - { Compiler::StaticType::String, Compiler::StaticType::Number, Compiler::StaticType::Bool }, |
153 | | - { param, value, change }); |
| 151 | + if (paramInput->pointsToDropdownMenu()) { |
| 152 | + static const std::unordered_set<std::string> options = { "color", "saturation", "brightness", "transparency" }; |
| 153 | + std::string option = paramInput->selectedMenuItem(); |
| 154 | + |
| 155 | + if (options.find(option) != options.cend()) { |
| 156 | + std::string f = "pen_set_or_change_" + option; |
| 157 | + compiler->addTargetFunctionCall(f, Compiler::StaticType::Void, { Compiler::StaticType::Number, Compiler::StaticType::Bool }, { value, change }); |
| 158 | + } |
| 159 | + } else { |
| 160 | + compiler->addTargetFunctionCall( |
| 161 | + "pen_set_or_change_color_param", |
| 162 | + Compiler::StaticType::Void, |
| 163 | + { Compiler::StaticType::String, Compiler::StaticType::Number, Compiler::StaticType::Bool }, |
| 164 | + { param, value, change }); |
| 165 | + } |
154 | 166 |
|
155 | 167 | return nullptr; |
156 | 168 | } |
|
0 commit comments