diff --git a/game/static/game/js/level_editor.js b/game/static/game/js/level_editor.js index 926209119..66152548e 100644 --- a/game/static/game/js/level_editor.js +++ b/game/static/game/js/level_editor.js @@ -126,13 +126,16 @@ ocargo.LevelEditor = function(levelId) { // Initialise the grid initialiseGrid(); - setTheme(THEMES.grass); + //setTheme(THEMES.grass); // Setup the toolbox setupToolbox(); if (levelId !== null) { loadLevel(levelId); + console.log(currentTheme); + } else { + setTheme(THEMES.grass); } setupTrashcan(); @@ -415,8 +418,8 @@ ocargo.LevelEditor = function(levelId) { for (var i = 0; i < BLOCKS.length; i++) { var type = BLOCKS[i]; - var block = Blockly.mainWorkspace.newBlock(type); - console.log(type); + let usePigeons = type === "cow_crossing" && currentTheme == THEMES.grass + var block = usePigeons ? Blockly.mainWorkspace.newBlock("pigeon_crossing_IMAGE_ONLY") : Blockly.mainWorkspace.newBlock(type); block.initSvg(); block.render(); @@ -2375,6 +2378,7 @@ ocargo.LevelEditor = function(levelId) { function setTheme(theme) { currentTheme = theme; + let newType = currentTheme == THEMES.city ? ocargo.Cow.PIGEON : ocargo.Cow.WHITE; for (var x = 0; x < GRID_WIDTH; x++) { for (var y = 0; y < GRID_HEIGHT; y++) { @@ -2416,6 +2420,29 @@ ocargo.LevelEditor = function(levelId) { for (let i = 0; i < cows.length; i++) { cows[i].updateTheme(); } + + let block = Blockly.mainWorkspace.newBlock("cow_crossing"); + + if (newType == ocargo.Cow.PIGEON) { + block = Blockly.mainWorkspace.newBlock("pigeon_crossing_IMAGE_ONLY"); + } + + block.initSvg(); + block.render(); + let svg = block.getSvgRoot(); + let innerHTML = svg.innerHTML; + let innerParts = innerHTML.split("