Skip to content

Commit

Permalink
adding code for text block
Browse files Browse the repository at this point in the history
  • Loading branch information
dlopezalvas committed Aug 22, 2024
1 parent 25e6fe1 commit d7d7c94
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/blockly/blockly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { enableUnwantedProcedureBlocks, disableUnwantedProcedureBlocks } from ".
import 'blockly/blocks';
import { createPrimitiveBlocks } from "./blocksGallery/primitives";
import { createSensorBlocks } from "./blocksGallery/sensors";
import { createValueBlocks } from "./values";
import { createValueBlocks } from "./blocksGallery/values";
import { createControlStructureBlocks } from "./blocksGallery/controlStructures";
import { createFirstBlock, createOthersBlocks } from "./blocksGallery/others";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { javascriptGenerator, Order } from "blockly/javascript";
import { BlocklyBlockDefinition, messageBlock } from "./blockly";
import { optionType, validateRequiredOptions } from "./utils";
import { BlocklyBlockDefinition, messageBlock } from "../blockly";
import { optionType, validateRequiredOptions } from "../utils";
import Blockly, { Block } from "blockly/core"

const directionsColor = '#2ba4e2';
Expand Down Expand Up @@ -78,4 +78,13 @@ export const createValueBlocks = (t: (key: string) => string) => {
javascriptGenerator.forBlock['Numero'] = function (block: Block) {
return [`${block.getFieldValue('NUM')}`, Order.ATOMIC];
};

Blockly.Blocks['Texto'] = {
init: Blockly.Blocks['text'].init,
categoryId: Blockly.Blocks['text'].categoryId,
}

javascriptGenerator.forBlock['Texto'] = function (block: Block) {
return [`${block.getFieldValue('TEXT')}`, Order.ATOMIC];
};
}
9 changes: 2 additions & 7 deletions src/components/challengeView/SceneButtons/Execute.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, IconButton, Stack } from "@mui/material"
import { scene } from "../scene"
import { interpreterFactory } from "./interpreter-factory"
import { interpreterFactory } from "./interpreterFactory"
import Interpreter from "js-interpreter"
import { useThemeContext } from "../../../theme/ThemeContext"
import styles from './sceneButtons.module.css'
Expand Down Expand Up @@ -55,9 +55,4 @@ export const ExecuteButton = ({ challenge }: ExecuteButtonProps) => {
}
</>

}

/**
* Bloques que no escupen codigo que deberian: con parametros, repeat (ver cambio al repeat de prod), procedimientos
* Test
*/
}
2 changes: 1 addition & 1 deletion src/components/challengeView/SceneButtons/SceneButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IconButton, Stack } from "@mui/material"
import { PBCard } from "../../PBCard"
import { Circle, Info, PlayArrow, SkipNext } from "@mui/icons-material"
import { Circle, Info, SkipNext } from "@mui/icons-material"
import { PBSwitch, pbIconStyle } from "../../PBSwitch"
import styles from './sceneButtons.module.css'
import BoltIcon from '@mui/icons-material/Bolt';
Expand Down
2 changes: 1 addition & 1 deletion src/components/challengeView/scene.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { adaptURL } from "../../scriptLoader";
import { Challenge } from "../../staticData/challenges";
import { Actor, Behaviour } from "./SceneButtons/interpreter-factory";
import { Actor, Behaviour } from "./SceneButtons/interpreterFactory";

class Scene {
iframe(): HTMLIFrameElement {
Expand Down

0 comments on commit d7d7c94

Please sign in to comment.