int ScriptOverride::getValue() { GScopedInterface<IScriptFunction> func(this->getScriptFunction("getValue")); if(func) { return fromVariant<int>(invokeScriptFunction(func.get(), this).getValue()); } else { return super::getValue(); } }
void callback_glutSpaceballButtonFunc(int button, int state) { invokeScriptFunction(getCurrentCallbackData()->spaceballButton.get(), button, state); }
void callback_glutSpaceballRotateFunc(int x, int y, int z) { invokeScriptFunction(getCurrentCallbackData()->spaceballRotate.get(), x, y, z); }
void ScriptObject::onStart() { invokeScriptFunction(std::bind(script_on_start, script_object)); }
void callback_glutJoystickFunc(unsigned int buttonMask, int x, int y, int z) { invokeScriptFunction(getCurrentCallbackData()->joystick.get(), buttonMask, x, y, z); }
void callback_glutKeyboardUpFunc(unsigned char key, int x, int y) { invokeScriptFunction(getCurrentCallbackData()->keyboardUp.get(), key, x, y); }
void callback_glutMenuStatusFunc(int status, int x, int y) { invokeScriptFunction(getCurrentCallbackData()->menuStatus.get(), status, x, y); }
void callback_glutTabletMotionFunc(int x, int y) { invokeScriptFunction(getCurrentCallbackData()->tabletMotion.get(), x, y); }
void callback_glutPassiveMotionFunc(int x, int y) { invokeScriptFunction(getCurrentCallbackData()->passiveMotion.get(), x, y); }
void callback_glutMouseFunc(int button, int state, int x, int y) { invokeScriptFunction(getCurrentCallbackData()->mouse.get(), button, state, x, y); }
void callback_glutReshapeFunc(int width, int height) { invokeScriptFunction(getCurrentCallbackData()->reshape.get(), width, height); }
void ScriptObject::handleQueuedEvent(std::shared_ptr<Events::Event> event) { switch(event->getEventType()) { case Events::MOUSE_CURSOR: { auto handler = selectEventHandler<Input::MouseCursorEvent>(); auto casted_event = std::static_pointer_cast<Input::MouseCursorEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::MOUSE_SCROLL: { auto handler = selectEventHandler<Input::MouseScrollEvent>(); auto casted_event = std::static_pointer_cast<Input::MouseScrollEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::MOUSE_BUTTON_DOWN: { auto handler = selectEventHandler<Input::MouseButtonDownEvent>(); auto casted_event = std::static_pointer_cast<Input::MouseButtonDownEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::MOUSE_BUTTON_UP: { auto handler = selectEventHandler<Input::MouseButtonUpEvent>(); auto casted_event = std::static_pointer_cast<Input::MouseButtonUpEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::CURSOR_ENTER: { auto handler = selectEventHandler<Input::CursorEnterEvent>(); auto casted_event = std::static_pointer_cast<Input::CursorEnterEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::CURSOR_LEAVE: { auto handler = selectEventHandler<Input::CursorLeaveEvent>(); auto casted_event = std::static_pointer_cast<Input::CursorLeaveEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::KEY_DOWN: { auto handler = selectEventHandler<Input::KeyDownEvent>(); auto casted_event = std::static_pointer_cast<Input::KeyDownEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::KEY_UP: { auto handler = selectEventHandler<Input::KeyUpEvent>(); auto casted_event = std::static_pointer_cast<Input::KeyUpEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::KEY_REPEAT: { auto handler = selectEventHandler<Input::KeyRepeatEvent>(); auto casted_event = std::static_pointer_cast<Input::KeyRepeatEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::CHARACTER_TYPED: { auto handler = selectEventHandler<Input::CharacterTypedEvent>(); auto casted_event = std::static_pointer_cast<Input::CharacterTypedEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::SPRITE_MOVE: { auto handler = selectEventHandler<Game::SpriteMoveEvent>(); auto casted_event = std::static_pointer_cast<Game::SpriteMoveEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::SET_ACTIVE: { auto handler = selectEventHandler<SetActiveEvent>(); auto casted_event = std::static_pointer_cast<SetActiveEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::SET_ENTITY_ACTIVE: { auto handler = selectEventHandler<SetEntityActiveEvent>(); auto casted_event = std::static_pointer_cast<SetEntityActiveEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::SET_UNIFORM: { auto handler = selectEventHandler<Graphics::SetUniformEvent>(); auto casted_event = std::static_pointer_cast<Graphics::SetUniformEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::ANIMATION_TRIGGER: { auto handler = selectEventHandler<Game::AnimationTriggerEvent<Game::SpriteMovementMotor::SpriteState>>(); auto casted_event = std::static_pointer_cast<Game::AnimationTriggerEvent<Game::SpriteMovementMotor::SpriteState>>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::SUSPEND_KEY_INPUT: { auto handler = selectEventHandler<Graphics::UI::SuspendKeyInputEvent>(); auto casted_event = std::static_pointer_cast<Graphics::UI::SuspendKeyInputEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::RESUME_KEY_INPUT: { auto handler = selectEventHandler<Graphics::UI::ResumeKeyInputEvent>(); auto casted_event = std::static_pointer_cast<Graphics::UI::ResumeKeyInputEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::CHANGE_TEXT: { auto handler = selectEventHandler<Graphics::UI::ChangeTextEvent>(); auto casted_event = std::static_pointer_cast<Graphics::UI::ChangeTextEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::DEBUG_COMMAND: { auto handler = selectEventHandler<Utility::DebugCommandEvent>(); auto casted_event = std::static_pointer_cast<Utility::DebugCommandEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::LOAD_MAP: { auto handler = selectEventHandler<Utility::LoadMapEvent>(); auto casted_event = std::static_pointer_cast<Utility::LoadMapEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::LOAD_CHARACTER: { auto handler = selectEventHandler<Utility::LoadCharacterEvent>(); auto casted_event = std::static_pointer_cast<Utility::LoadCharacterEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::TOGGLE_FREE_CAMERA: { auto handler = selectEventHandler<Utility::ToggleFreeCameraEvent>(); auto casted_event = std::static_pointer_cast<Utility::ToggleFreeCameraEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::LIST_MAPS: { auto handler = selectEventHandler<Utility::ListMapsEvent>(); auto casted_event = std::static_pointer_cast<Utility::ListMapsEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::LIST_CHARACTERS: { auto handler = selectEventHandler<Utility::ListCharactersEvent>(); auto casted_event = std::static_pointer_cast<Utility::ListCharactersEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::LIST_LAYERS: { auto handler = selectEventHandler<Utility::ListLayersEvent>(); auto casted_event = std::static_pointer_cast<Utility::ListLayersEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::TOGGLE_LIGHTS: { auto handler = selectEventHandler<Utility::ToggleLightsEvent>(); auto casted_event = std::static_pointer_cast<Utility::ToggleLightsEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::TOGGLE_LAYER: { auto handler = selectEventHandler<Utility::ToggleLayerEvent>(); auto casted_event = std::static_pointer_cast<Utility::ToggleLayerEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } case Events::WINDOW_EXIT: { auto handler = selectEventHandler<Utility::WindowExitEvent>(); auto casted_event = std::static_pointer_cast<Utility::WindowExitEvent>(event); invokeScriptFunction(std::bind(handler, script_object, casted_event)); break; } default: { LOG(WARNING)<<"Trying to pass event to script that hasn't been implemented!"; break; } } }
void ScriptObject::onDestroy() { invokeScriptFunction(std::bind(script_on_destroy, script_object)); }
void ScriptObject::onUpdate(const float delta) { invokeScriptFunction(std::bind(script_on_update, script_object, delta)); processEventQueue(); }
void callback_glutButtonBoxFunc(int button, int state) { invokeScriptFunction(getCurrentCallbackData()->buttonBox.get(), button, state); }
void callback_glutEntryFunc(int state) { invokeScriptFunction(getCurrentCallbackData()->entry.get(), state); }
void callback_glutDialsFunc(int dial, int value) { invokeScriptFunction(getCurrentCallbackData()->dials.get(), dial, value); }
void callback_glutVisibilityFunc(int state) { invokeScriptFunction(getCurrentCallbackData()->visibility.get(), state); }
void callback_glutTabletButtonFunc(int button, int state, int x, int y) { invokeScriptFunction(getCurrentCallbackData()->tabletButton.get(), button, state, x, y); }
void callback_glutIdleFunc() { invokeScriptFunction(getCurrentCallbackData()->idle.get()); }
void callback_glutWindowStatusFunc(int state) { invokeScriptFunction(getCurrentCallbackData()->windowStatus.get(), state); }
void callback_glutTimerFunc(int value) { invokeScriptFunction(getCurrentCallbackData()->timer.get(), value); }
void callback_glutSpecialUpFunc(int key, int x, int y) { invokeScriptFunction(getCurrentCallbackData()->specialUp.get(), key, x, y); }
void callback_glutMenuStateFunc(int state) { invokeScriptFunction(getCurrentCallbackData()->menuState.get(), state); }
void callback_glutDisplayFunc() { invokeScriptFunction(getCurrentCallbackData()->display.get()); }
int testExecAddCallback() { int n = fromVariant<int>(invokeScriptFunction(testScriptFunction.get(), 5, 6).getValue()); testScriptFunction.reset(); // destroy it to avoid crash between different script engine such as Lua and V8. It's not a bug return n; }