Skip to content

Commit

Permalink
Resolve #4154: DR doesn't show readable background image changes.
Browse files Browse the repository at this point in the history
While DR is unlikely to support every possible case (especially stuff driven by a game script), this particular GUI as reported in the issue report can be supported by running the GUI script in ContentsFadeIn and setting the gui::curPage state variable as done by TDM's readable GUI code.
  • Loading branch information
codereader committed Jan 2, 2018
1 parent 82fb5c8 commit 5f88cde
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 1 addition & 3 deletions plugins/dm.gui/ReadableEditorDialog.cpp
Expand Up @@ -758,13 +758,11 @@ void ReadableEditorDialog::initGuiState(const gui::IGuiPtr& gui)
gui->setStateString("curPage", string::to_string(_currentPageIndex + 1));
gui->setStateString("numPages", string::to_string(_numPages->GetValue()));

#if 0
// ContentsFadeIn is reponsible of setting custom backgrounds
if (gui->findWindowDef("ContentsFadeIn"))
{
gui->findWindowDef("ContentsFadeIn")->notime = false;
gui->findWindowDef("ContentsFadeIn")->notime.setValue(false);
}
#endif

// Initialise the time of this GUI
gui->initTime(0);
Expand Down
13 changes: 9 additions & 4 deletions plugins/dm.gui/gui/GuiScript.cpp
Expand Up @@ -340,9 +340,10 @@ GuiExpressionPtr GuiScript::getExpression(parser::DefTokeniser& tokeniser)
return GuiExpression::CreateFromTokens(_owner.getGui(), tokeniser);
}

GuiExpressionPtr GuiScript::getIfExpression(parser::DefTokeniser& tokeniser)
std::shared_ptr<IGuiExpression<bool>> GuiScript::getIfExpression(parser::DefTokeniser& tokeniser)
{
return getExpression(tokeniser);
// Parse the IF condition and pack it into a bool-typed expression
return std::make_shared<TypedExpression<bool>>(getExpression(tokeniser));
}

const Statement& GuiScript::getStatement(std::size_t index)
Expand Down Expand Up @@ -442,8 +443,12 @@ void GuiScript::execute()
case Statement::ST_TRANSITION:
break;
case Statement::ST_IF:
// TODO: Evaluate expression, for now just perform the jump
_ip = st.jmpDest;
// Evaluate expression
if (!st._condition || st._condition->evaluate() == false)
{
// Expression evaluated to false, jump over the block
_ip = st.jmpDest;
}
break;
case Statement::ST_SET_FOCUS:
break;
Expand Down
4 changes: 2 additions & 2 deletions plugins/dm.gui/gui/GuiScript.h
Expand Up @@ -45,7 +45,7 @@ struct Statement
Arguments args;

// Condition used by ST_IF
GuiExpressionPtr _condition;
std::shared_ptr<IGuiExpression<bool>> _condition;

// The jump destination used by ST_IF and ST_JMP
std::size_t jmpDest;
Expand Down Expand Up @@ -97,7 +97,7 @@ class GuiScript
std::size_t getCurPosition();

GuiExpressionPtr getExpression(parser::DefTokeniser& tokeniser);
GuiExpressionPtr getIfExpression(parser::DefTokeniser& tokeniser);
std::shared_ptr<IGuiExpression<bool>> getIfExpression(parser::DefTokeniser& tokeniser);

// Reads a "statement", which can be single one or a group (surrounded by curly braces)
void parseStatement(parser::DefTokeniser& tokeniser);
Expand Down

0 comments on commit 5f88cde

Please sign in to comment.