|
10 | 10 | #include <scratchcpp/stage.h>
|
11 | 11 | #include <scratchcpp/costume.h>
|
12 | 12 | #include <scratchcpp/variable.h>
|
| 13 | +#include <scratchcpp/block.h> |
13 | 14 | #include "sensingblocks.h"
|
14 | 15 |
|
15 | 16 | #include "../engine/internal/clock.h"
|
@@ -38,6 +39,14 @@ void SensingBlocks::registerBlocks(IEngine *engine)
|
38 | 39 | engine->addCompileFunction(this, "sensing_current", &compileCurrent);
|
39 | 40 | engine->addCompileFunction(this, "sensing_dayssince2000", &compileDaysSince2000);
|
40 | 41 |
|
| 42 | + // Monitor names |
| 43 | + engine->addMonitorNameFunction(this, "sensing_mousedown", &mouseDownMonitorName); |
| 44 | + engine->addMonitorNameFunction(this, "sensing_mousex", &mouseXMonitorName); |
| 45 | + engine->addMonitorNameFunction(this, "sensing_mousey", &mouseYMonitorName); |
| 46 | + engine->addMonitorNameFunction(this, "sensing_timer", &timerMonitorName); |
| 47 | + engine->addMonitorNameFunction(this, "sensing_current", ¤tMonitorName); |
| 48 | + engine->addMonitorNameFunction(this, "sensing_dayssince2000", &daysSince2000MonitorName); |
| 49 | + |
41 | 50 | // Inputs
|
42 | 51 | engine->addInput(this, "DISTANCETOMENU", DISTANCETOMENU);
|
43 | 52 | engine->addInput(this, "KEY_OPTION", KEY_OPTION);
|
@@ -310,6 +319,83 @@ void SensingBlocks::compileDaysSince2000(Compiler *compiler)
|
310 | 319 | compiler->addFunctionCall(&daysSince2000);
|
311 | 320 | }
|
312 | 321 |
|
| 322 | +const std::string &SensingBlocks::mouseDownMonitorName(Block *block) |
| 323 | +{ |
| 324 | + static const std::string name = "mouse down?"; |
| 325 | + return name; |
| 326 | +} |
| 327 | + |
| 328 | +const std::string &SensingBlocks::mouseXMonitorName(Block *block) |
| 329 | +{ |
| 330 | + static const std::string name = "mouse x"; |
| 331 | + return name; |
| 332 | +} |
| 333 | + |
| 334 | +const std::string &SensingBlocks::mouseYMonitorName(Block *block) |
| 335 | +{ |
| 336 | + static const std::string name = "mouse y"; |
| 337 | + return name; |
| 338 | +} |
| 339 | + |
| 340 | +const std::string &SensingBlocks::timerMonitorName(Block *block) |
| 341 | +{ |
| 342 | + static const std::string name = "timer"; |
| 343 | + return name; |
| 344 | +} |
| 345 | + |
| 346 | +const std::string &SensingBlocks::currentMonitorName(Block *block) |
| 347 | +{ |
| 348 | + int id = block->findFieldById(CURRENTMENU)->specialValueId(); |
| 349 | + |
| 350 | + switch (id) { |
| 351 | + case YEAR: { |
| 352 | + static const std::string name = "year"; |
| 353 | + return name; |
| 354 | + } |
| 355 | + |
| 356 | + case MONTH: { |
| 357 | + static const std::string name = "month"; |
| 358 | + return name; |
| 359 | + } |
| 360 | + |
| 361 | + case DATE: { |
| 362 | + static const std::string name = "date"; |
| 363 | + return name; |
| 364 | + } |
| 365 | + |
| 366 | + case DAYOFWEEK: { |
| 367 | + static const std::string name = "day of week"; |
| 368 | + return name; |
| 369 | + } |
| 370 | + |
| 371 | + case HOUR: { |
| 372 | + static const std::string name = "hour"; |
| 373 | + return name; |
| 374 | + } |
| 375 | + |
| 376 | + case MINUTE: { |
| 377 | + static const std::string name = "minute"; |
| 378 | + return name; |
| 379 | + } |
| 380 | + |
| 381 | + case SECOND: { |
| 382 | + static const std::string name = "second"; |
| 383 | + return name; |
| 384 | + } |
| 385 | + |
| 386 | + default: { |
| 387 | + static const std::string name = ""; |
| 388 | + return name; |
| 389 | + } |
| 390 | + } |
| 391 | +} |
| 392 | + |
| 393 | +const std::string &SensingBlocks::daysSince2000MonitorName(Block *block) |
| 394 | +{ |
| 395 | + static const std::string name = "days since 2000"; |
| 396 | + return name; |
| 397 | +} |
| 398 | + |
313 | 399 | unsigned int SensingBlocks::keyPressed(VirtualMachine *vm)
|
314 | 400 | {
|
315 | 401 | vm->replaceReturnValue(vm->engine()->keyPressed(vm->getInput(0, 1)->toString()), 1);
|
|
0 commit comments