mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-19 12:09:42 +00:00
added missing button implementation for MessageBox
This commit is contained in:
parent
72cc0a3983
commit
276a9db6f7
5 changed files with 367 additions and 347 deletions
|
@ -196,7 +196,7 @@ namespace MWGui
|
|||
Compiler::Locals locals;
|
||||
Compiler::Output output (locals);
|
||||
|
||||
if (compile (cm, output))
|
||||
if (compile (cm + "\n", output))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -216,4 +216,3 @@ namespace MWGui
|
|||
command->setCaption("");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -505,8 +505,6 @@ namespace Compiler
|
|||
void message (CodeContainer& code, Literals& literals, const std::string& message,
|
||||
int buttons)
|
||||
{
|
||||
assert (buttons==0);
|
||||
|
||||
int index = literals.addString (message);
|
||||
|
||||
opPushInt (code, index);
|
||||
|
@ -773,4 +771,3 @@ namespace Compiler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -168,13 +168,19 @@ namespace Compiler
|
|||
mExprParser.parseArguments (arguments, scanner, mCode, true);
|
||||
}
|
||||
|
||||
// for now skip buttons
|
||||
SkipParser skip (getErrorHandler(), getContext());
|
||||
scanner.scan (skip);
|
||||
mName = name;
|
||||
mButtons = 0;
|
||||
|
||||
Generator::message (mCode, mLiterals, name, 0);
|
||||
mState = EndState;
|
||||
return false;
|
||||
mState = MessageButtonState;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mState==MessageButtonState || mState==MessageButtonCommaState)
|
||||
{
|
||||
Generator::pushString (mCode, mLiterals, name);
|
||||
mState = MessageButtonState;
|
||||
++mButtons;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mState==BeginState && mAllowExpression)
|
||||
|
@ -360,6 +366,18 @@ namespace Compiler
|
|||
return true;
|
||||
}
|
||||
|
||||
if (code==Scanner::S_newline && mState==MessageButtonState)
|
||||
{
|
||||
Generator::message (mCode, mLiterals, mName, mButtons);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (code==Scanner::S_comma && mState==MessageButtonState)
|
||||
{
|
||||
mState = MessageButtonCommaState;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mAllowExpression && mState==BeginState &&
|
||||
(code==Scanner::S_open || code==Scanner::S_minus))
|
||||
{
|
||||
|
@ -378,4 +396,3 @@ namespace Compiler
|
|||
mExplicit.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Compiler
|
|||
BeginState,
|
||||
ShortState, LongState, FloatState,
|
||||
SetState, SetLocalVarState, SetGlobalVarState,
|
||||
MessageState, MessageCommaState,
|
||||
MessageState, MessageCommaState, MessageButtonState, MessageButtonCommaState,
|
||||
EndState,
|
||||
PotentialExplicitState, ExplicitState
|
||||
};
|
||||
|
@ -32,6 +32,7 @@ namespace Compiler
|
|||
std::vector<Interpreter::Type_Code>& mCode;
|
||||
State mState;
|
||||
std::string mName;
|
||||
int mButtons;
|
||||
std::string mExplicit;
|
||||
char mType;
|
||||
ExprParser mExprParser;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "opcodes.hpp"
|
||||
#include "runtime.hpp"
|
||||
|
@ -18,8 +19,17 @@ namespace Interpreter
|
|||
|
||||
virtual void execute (Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
if (arg0!=0)
|
||||
throw std::logic_error ("message box buttons not implemented yet");
|
||||
// buttons
|
||||
std::vector<std::string> buttons;
|
||||
|
||||
for (std::size_t i=0; i<arg0; ++i)
|
||||
{
|
||||
int index = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
buttons.push_back (runtime.getStringLiteral (index));
|
||||
}
|
||||
|
||||
std::reverse (buttons.begin(), buttons.end());
|
||||
|
||||
// message
|
||||
int index = runtime[0].mInteger;
|
||||
|
@ -82,9 +92,6 @@ namespace Interpreter
|
|||
}
|
||||
}
|
||||
|
||||
// buttons (not implemented)
|
||||
std::vector<std::string> buttons;
|
||||
|
||||
runtime.getContext().messageBox (formattedMessage, buttons);
|
||||
}
|
||||
};
|
||||
|
@ -206,4 +213,3 @@ namespace Interpreter
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue