Skip to content

Commit a53d908

Browse files
committed
Add sound monitor name functions
1 parent d37e73d commit a53d908

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/blocks/soundblocks.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ void SoundBlocks::registerBlocks(IEngine *engine)
2525
engine->addCompileFunction(this, "sound_setvolumeto", &compileSetVolumeTo);
2626
engine->addCompileFunction(this, "sound_volume", &compileVolume);
2727

28+
// Monitor names
29+
engine->addMonitorNameFunction(this, "sound_volume", &volumeMonitorName);
30+
2831
// Inputs
2932
engine->addInput(this, "SOUND_MENU", SOUND_MENU);
3033
engine->addInput(this, "VOLUME", VOLUME);
@@ -115,6 +118,12 @@ void SoundBlocks::compileVolume(Compiler *compiler)
115118
compiler->addFunctionCall(&volume);
116119
}
117120

121+
const std::string &SoundBlocks::volumeMonitorName(Block *block)
122+
{
123+
static const std::string name = "volume";
124+
return name;
125+
}
126+
118127
Sound *SoundBlocks::getSoundByIndex(Target *target, long index)
119128
{
120129
long soundCount = target->sounds().size();

src/blocks/soundblocks.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class SoundBlocks : public IBlockSection
4545
static void compileSetVolumeTo(Compiler *compiler);
4646
static void compileVolume(Compiler *compiler);
4747

48+
static const std::string &volumeMonitorName(Block *block);
49+
4850
static Sound *getSoundByIndex(Target *target, long index);
4951
static Sound *playCommon(VirtualMachine *vm);
5052
static Sound *playByIndexCommon(VirtualMachine *vm);

test/blocks/sound_blocks_test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ TEST_F(SoundBlocksTest, RegisterBlocks)
105105
EXPECT_CALL(m_engineMock, addCompileFunction(m_section.get(), "sound_setvolumeto", &SoundBlocks::compileSetVolumeTo));
106106
EXPECT_CALL(m_engineMock, addCompileFunction(m_section.get(), "sound_volume", &SoundBlocks::compileVolume));
107107

108+
// Monitor names
109+
EXPECT_CALL(m_engineMock, addMonitorNameFunction(m_section.get(), "sound_volume", &SoundBlocks::volumeMonitorName));
110+
108111
// Inputs
109112
EXPECT_CALL(m_engineMock, addInput(m_section.get(), "SOUND_MENU", SoundBlocks::SOUND_MENU));
110113
EXPECT_CALL(m_engineMock, addInput(m_section.get(), "VOLUME", SoundBlocks::VOLUME));
@@ -697,6 +700,11 @@ TEST_F(SoundBlocksTest, Volume)
697700
ASSERT_TRUE(compiler.constValues().empty());
698701
}
699702

703+
TEST_F(SoundBlocksTest, VolumeMonitorName)
704+
{
705+
ASSERT_EQ(SoundBlocks::volumeMonitorName(nullptr), "volume");
706+
}
707+
700708
TEST_F(SoundBlocksTest, VolumeImpl)
701709
{
702710
static unsigned int bytecode[] = { vm::OP_START, vm::OP_EXEC, 0, vm::OP_HALT };

0 commit comments

Comments
 (0)