From d4ddacc8430f5deabb6acb41fc5a98647354c8fe Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 10 Dec 2023 11:23:40 +0000 Subject: [PATCH 1/4] Close Video after popup close --- game/static/game/js/drawing.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/game/static/game/js/drawing.js b/game/static/game/js/drawing.js index 806551491..4c6339b73 100644 --- a/game/static/game/js/drawing.js +++ b/game/static/game/js/drawing.js @@ -1013,6 +1013,14 @@ ocargo.Drawing.translate = function (coordinate) { return new ocargo.Coordinate(coordinate.x, GRID_HEIGHT - 1 - coordinate.y) } +// A Function used to stop the iframe video +function stopVideo() { + // https://gist.github.com/cferdinandi/9044694 + const video = document.getElementsByClassName("video"); + var iframeSrc = video[0].src; + video[0].src = iframeSrc; +} + /* This is the function that starts the pop-up. Buttons should be passed in separately to the function instead of concatenating @@ -1073,6 +1081,11 @@ ocargo.Drawing.startPopup = function ( const regexID = /id=\"*\w+_\w+\"/ + // Close the video on pressing the top right close button + $("#close-modal").click(function () { + stopVideo(); + }); + for (let i = 0; i < buttons.length; i++) { // get id with regex by stripping the html content let currentID = buttons[i].match(regexID)[0].slice(3).replaceAll('"', '') @@ -1088,6 +1101,11 @@ ocargo.Drawing.startPopup = function ( currentButton.attr("onclick", currentLink) } + // Close the video on the play button + currentButton.click(function () { + stopVideo(); + }); + // first level shouldn't have prev_button // and last level shouldn't have next_button if (currentButton.attr("onclick")) buttonDiv.append(currentButton) From c813fdf8204681f1bb8fb81b2ca1b2ee430e4c2c Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Wed, 13 Dec 2023 07:30:30 +0000 Subject: [PATCH 2/4] Replace var with const --- game/static/game/js/drawing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/static/game/js/drawing.js b/game/static/game/js/drawing.js index 4c6339b73..b14f6bb24 100644 --- a/game/static/game/js/drawing.js +++ b/game/static/game/js/drawing.js @@ -1017,7 +1017,7 @@ ocargo.Drawing.translate = function (coordinate) { function stopVideo() { // https://gist.github.com/cferdinandi/9044694 const video = document.getElementsByClassName("video"); - var iframeSrc = video[0].src; + const iframeSrc = video[0].src; video[0].src = iframeSrc; } From 11e95a641ccfeb670b44a62e5e1473712bfcd266 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Thu, 4 Jan 2024 06:05:30 +0000 Subject: [PATCH 3/4] Hide characters above level 80 --- game/static/game/js/game.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/game/static/game/js/game.js b/game/static/game/js/game.js index e0eb469f1..1d12d4205 100644 --- a/game/static/game/js/game.js +++ b/game/static/game/js/game.js @@ -123,12 +123,14 @@ ocargo.Game.prototype.onLevelChange = function() { } this.drawing.enablePanning() + + const showMascot = BLOCKLY_ENABLED && !PYTHON_VIEW_ENABLED && LEVEL_NAME <= 80; // show mascot on Blockly-only levels that are not above 80 ocargo.Drawing.startPopup( title, LESSON, message, - BLOCKLY_ENABLED && !PYTHON_VIEW_ENABLED, // show mascot on Blockly-only levels + showMascot, [ ocargo.button.dismissButtonHtml("prev_button", gettext("Previous level")), ocargo.button.dismissButtonHtml('play_button', gettext('Play')), From 6a3de413c6e40820d41d62726bd7a76d68ead785 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 14 Jan 2024 09:25:15 +0000 Subject: [PATCH 4/4] Always generate start block at position (100, 100) --- game/static/game/js/blocklyControl.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/game/static/game/js/blocklyControl.js b/game/static/game/js/blocklyControl.js index 4e3cc28a7..f3ade14ba 100644 --- a/game/static/game/js/blocklyControl.js +++ b/game/static/game/js/blocklyControl.js @@ -80,7 +80,8 @@ ocargo.BlocklyControl.prototype.reset = function () { // has a start button, if not then create a start button if (!wasGameStarted(allBlocks)) { let startBlock = this.createBlock("start"); - startBlock.moveBy(30 + (i % 2) * 200, 30 + Math.floor(i / 2) * 100); + // Generate the first block on the (100, 100) position + startBlock.moveBy(100, 100); } this.clearIncorrectBlock();