Make marking events as "sim events" slightly harder to mess up
A sim event being an event that takes place in the context of the simulation. Currently, this simply means that the RNG math.random uses is the sim's rather than the UI's.
This commit is contained in:
parent
0143a0a41f
commit
e20312a672
@ -4,16 +4,19 @@
|
||||
|
||||
struct TextInputEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
String text;
|
||||
};
|
||||
|
||||
struct TextEditingEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
String text;
|
||||
};
|
||||
|
||||
struct KeyEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
int key;
|
||||
int scan;
|
||||
bool repeat;
|
||||
@ -24,14 +27,17 @@ struct KeyEvent
|
||||
|
||||
struct KeyPressEvent : public KeyEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
};
|
||||
|
||||
struct KeyReleaseEvent : public KeyEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
};
|
||||
|
||||
struct MouseDownEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
int x;
|
||||
int y;
|
||||
unsigned int button;
|
||||
@ -39,6 +45,7 @@ struct MouseDownEvent
|
||||
|
||||
struct MouseUpEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
int x;
|
||||
int y;
|
||||
unsigned int button;
|
||||
@ -47,6 +54,7 @@ struct MouseUpEvent
|
||||
|
||||
struct MouseMoveEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
int x;
|
||||
int y;
|
||||
int dx;
|
||||
@ -55,6 +63,7 @@ struct MouseMoveEvent
|
||||
|
||||
struct MouseWheelEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
int x;
|
||||
int y;
|
||||
int d;
|
||||
@ -62,22 +71,27 @@ struct MouseWheelEvent
|
||||
|
||||
struct TickEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
};
|
||||
|
||||
struct BlurEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
};
|
||||
|
||||
struct CloseEvent
|
||||
{
|
||||
static constexpr bool simEvent = false;
|
||||
};
|
||||
|
||||
struct BeforeSimEvent
|
||||
{
|
||||
static constexpr bool simEvent = true;
|
||||
};
|
||||
|
||||
struct AfterSimEvent
|
||||
{
|
||||
static constexpr bool simEvent = true;
|
||||
};
|
||||
|
||||
using GameControllerEvent = std::variant<
|
||||
|
@ -4672,8 +4672,9 @@ bool LuaScriptInterface::HandleEvent(const GameControllerEvent &event)
|
||||
{
|
||||
lua_rawgeti(l, -1, i);
|
||||
int numArgs = PushGameControllerEvent(l, event);
|
||||
auto simEvent = std::get_if<BeforeSimEvent>(&event) ||
|
||||
std::get_if<AfterSimEvent>(&event);
|
||||
auto simEvent = std::visit([](auto &event) {
|
||||
return event.simEvent;
|
||||
}, event);
|
||||
int callret = tpt_lua_pcall(l, numArgs, 1, 0, simEvent);
|
||||
if (callret)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user