Ejemplo n.º 1
0
int ScriptOverride::getValue()
{
	GScopedInterface<IScriptFunction> func(this->getScriptFunction("getValue"));
	if(func) {
		return fromVariant<int>(invokeScriptFunction(func.get(), this).getValue());
	}
	else {
		return super::getValue();
	}
}
Ejemplo n.º 2
0
void callback_glutSpaceballButtonFunc(int button, int state)
{
	invokeScriptFunction(getCurrentCallbackData()->spaceballButton.get(), button, state);
}
Ejemplo n.º 3
0
void callback_glutSpaceballRotateFunc(int x, int y, int z)
{
	invokeScriptFunction(getCurrentCallbackData()->spaceballRotate.get(), x, y, z);
}
Ejemplo n.º 4
0
 void ScriptObject::onStart() {
   invokeScriptFunction(std::bind(script_on_start, script_object));
 }
Ejemplo n.º 5
0
void callback_glutJoystickFunc(unsigned int buttonMask, int x, int y, int z)
{
	invokeScriptFunction(getCurrentCallbackData()->joystick.get(), buttonMask, x, y, z);
}
Ejemplo n.º 6
0
void callback_glutKeyboardUpFunc(unsigned char key, int x, int y)
{
	invokeScriptFunction(getCurrentCallbackData()->keyboardUp.get(), key, x, y);
}
Ejemplo n.º 7
0
void callback_glutMenuStatusFunc(int status, int x, int y)
{
	invokeScriptFunction(getCurrentCallbackData()->menuStatus.get(), status, x, y);
}
Ejemplo n.º 8
0
void callback_glutTabletMotionFunc(int x, int y)
{
	invokeScriptFunction(getCurrentCallbackData()->tabletMotion.get(), x, y);
}
Ejemplo n.º 9
0
void callback_glutPassiveMotionFunc(int x, int y)
{
	invokeScriptFunction(getCurrentCallbackData()->passiveMotion.get(), x, y);
}
Ejemplo n.º 10
0
void callback_glutMouseFunc(int button, int state, int x, int y)
{
	invokeScriptFunction(getCurrentCallbackData()->mouse.get(), button, state, x, y);
}
Ejemplo n.º 11
0
void callback_glutReshapeFunc(int width, int height)
{
	invokeScriptFunction(getCurrentCallbackData()->reshape.get(), width, height);
}
Ejemplo n.º 12
0
 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;
     }
   }
 }
Ejemplo n.º 13
0
 void ScriptObject::onDestroy() {
   invokeScriptFunction(std::bind(script_on_destroy, script_object));
 }
Ejemplo n.º 14
0
 void ScriptObject::onUpdate(const float delta) {
   invokeScriptFunction(std::bind(script_on_update, script_object, delta));
   processEventQueue();
 }
Ejemplo n.º 15
0
void callback_glutButtonBoxFunc(int button, int state)
{
	invokeScriptFunction(getCurrentCallbackData()->buttonBox.get(), button, state);
}
Ejemplo n.º 16
0
void callback_glutEntryFunc(int state)
{
	invokeScriptFunction(getCurrentCallbackData()->entry.get(), state);
}
Ejemplo n.º 17
0
void callback_glutDialsFunc(int dial, int value)
{
	invokeScriptFunction(getCurrentCallbackData()->dials.get(), dial, value);
}
Ejemplo n.º 18
0
void callback_glutVisibilityFunc(int state)
{
	invokeScriptFunction(getCurrentCallbackData()->visibility.get(), state);
}
Ejemplo n.º 19
0
void callback_glutTabletButtonFunc(int button, int state, int x, int y)
{
	invokeScriptFunction(getCurrentCallbackData()->tabletButton.get(), button, state, x, y);
}
Ejemplo n.º 20
0
void callback_glutIdleFunc()
{
	invokeScriptFunction(getCurrentCallbackData()->idle.get());
}
Ejemplo n.º 21
0
void callback_glutWindowStatusFunc(int state)
{
	invokeScriptFunction(getCurrentCallbackData()->windowStatus.get(), state);
}
Ejemplo n.º 22
0
void callback_glutTimerFunc(int value)
{
	invokeScriptFunction(getCurrentCallbackData()->timer.get(), value);
}
Ejemplo n.º 23
0
void callback_glutSpecialUpFunc(int key, int x, int y)
{
	invokeScriptFunction(getCurrentCallbackData()->specialUp.get(), key, x, y);
}
Ejemplo n.º 24
0
void callback_glutMenuStateFunc(int state)
{
	invokeScriptFunction(getCurrentCallbackData()->menuState.get(), state);
}
Ejemplo n.º 25
0
void callback_glutDisplayFunc()
{
	invokeScriptFunction(getCurrentCallbackData()->display.get());
}
Ejemplo n.º 26
0
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;
}