Skip to content

Commit 706254a

Browse files
committed
Remove obsolete key name parameter from IEngine::addKeyPressScript()
1 parent 4c21c19 commit 706254a

File tree

6 files changed

+7
-8
lines changed

6 files changed

+7
-8
lines changed

include/scratchcpp/iengine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class LIBSCRATCHCPP_EXPORT IEngine
258258
virtual void addCloneInitScript(std::shared_ptr<Block> hatBlock) = 0;
259259

260260
/* Registers the given "when key pressed" script. */
261-
virtual void addKeyPressScript(std::shared_ptr<Block> hatBlock, std::string keyName) = 0;
261+
virtual void addKeyPressScript(std::shared_ptr<Block> hatBlock) = 0;
262262

263263
/*! Returns the list of targets. */
264264
virtual const std::vector<std::shared_ptr<Target>> &targets() const = 0;

src/blocks/eventblocks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void EventBlocks::compileWhenBackdropSwitchesTo(Compiler *compiler)
8888
void EventBlocks::compileWhenKeyPressed(Compiler *compiler)
8989
{
9090
// NOTE: Field values don't have to be registered because keys are referenced by their names
91-
compiler->engine()->addKeyPressScript(compiler->block(), compiler->field(KEY_OPTION)->value().toString());
91+
compiler->engine()->addKeyPressScript(compiler->block());
9292
}
9393

9494
unsigned int EventBlocks::broadcast(VirtualMachine *vm)

src/engine/internal/engine.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,8 @@ void Engine::addCloneInitScript(std::shared_ptr<Block> hatBlock)
772772
addHatToMap(m_cloneInitHats, m_scripts[hatBlock].get());
773773
}
774774

775-
void Engine::addKeyPressScript(std::shared_ptr<Block> hatBlock, std::string keyName)
775+
void Engine::addKeyPressScript(std::shared_ptr<Block> hatBlock)
776776
{
777-
std::transform(keyName.begin(), keyName.end(), keyName.begin(), ::tolower);
778777
addHatToMap(m_whenKeyPressedHats, m_scripts[hatBlock].get());
779778
}
780779

src/engine/internal/engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Engine : public IEngine
113113
void addBroadcastScript(std::shared_ptr<Block> whenReceivedBlock, Broadcast *broadcast) override;
114114
void addBackdropChangeScript(std::shared_ptr<Block> hatBlock) override;
115115
void addCloneInitScript(std::shared_ptr<Block> hatBlock) override;
116-
void addKeyPressScript(std::shared_ptr<Block> hatBlock, std::string keyName) override;
116+
void addKeyPressScript(std::shared_ptr<Block> hatBlock) override;
117117

118118
const std::vector<std::shared_ptr<Target>> &targets() const override;
119119
void setTargets(const std::vector<std::shared_ptr<Target>> &newTargets) override;

test/blocks/event_blocks_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,11 @@ TEST_F(EventBlocksTest, WhenKeyPressed)
337337

338338
compiler.init();
339339

340-
EXPECT_CALL(m_engineMock, addKeyPressScript(block1, "a"));
340+
EXPECT_CALL(m_engineMock, addKeyPressScript(block1));
341341
compiler.setBlock(block1);
342342
EventBlocks::compileWhenKeyPressed(&compiler);
343343

344-
EXPECT_CALL(m_engineMock, addKeyPressScript(block2, "left arrow"));
344+
EXPECT_CALL(m_engineMock, addKeyPressScript(block2));
345345
compiler.setBlock(block2);
346346
EventBlocks::compileWhenKeyPressed(&compiler);
347347

test/mocks/enginemock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class EngineMock : public IEngine
9595
MOCK_METHOD(void, addBroadcastScript, (std::shared_ptr<Block>, Broadcast *), (override));
9696
MOCK_METHOD(void, addBackdropChangeScript, (std::shared_ptr<Block>), (override));
9797
MOCK_METHOD(void, addCloneInitScript, (std::shared_ptr<Block>), (override));
98-
MOCK_METHOD(void, addKeyPressScript, (std::shared_ptr<Block>, std::string), (override));
98+
MOCK_METHOD(void, addKeyPressScript, (std::shared_ptr<Block>), (override));
9999

100100
MOCK_METHOD(const std::vector<std::shared_ptr<Target>> &, targets, (), (const, override));
101101
MOCK_METHOD(void, setTargets, (const std::vector<std::shared_ptr<Target>> &), (override));

0 commit comments

Comments
 (0)