Skip to content

Commit

Permalink
#6092: Parse the first few action members
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 4, 2022
1 parent 4b5a2ac commit 9c5815d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion radiantcore/fx/FxAction.cpp
@@ -1,5 +1,8 @@
#include "FxAction.h"

#include "parser/DefTokeniser.h"
#include "string/case_conv.h"

namespace fx
{

Expand All @@ -20,7 +23,23 @@ bool FxAction::getIgnoreMaster()

void FxAction::parseFromTokens(parser::DefTokeniser& tokeniser)
{

while (tokeniser.hasMoreTokens())
{
auto token = tokeniser.nextToken();
string::to_lower(token);

// Hit a closing brace and we're done with this action
if (token == "}") return;

if (token == "ignoremaster")
{
_ignoreMaster = true;
}
else if (token == "delay")
{
_delayInSeconds = string::convert<float>(tokeniser.nextToken());
}
}
}


Expand Down
2 changes: 1 addition & 1 deletion test/Fx.cpp
Expand Up @@ -44,7 +44,7 @@ TEST_F(FxTest, ParseActionDelay)
{
EXPECT_EQ(getFxByName("fx/sparks")->getAction(0)->getDelay(), 0);
EXPECT_EQ(getFxByName("fx/sparks")->getAction(1)->getDelay(), 2);
EXPECT_EQ(getFxByName("fx/sparks")->getAction(2)->getDelay(), 1.5);
EXPECT_EQ(getFxByName("fx/sparks")->getAction(2)->getDelay(), 1.5f);
}

TEST_F(FxTest, ParseActionIgnoreMaster)
Expand Down

0 comments on commit 9c5815d

Please sign in to comment.