/// <summary> /// /// </summary> /// <param name="ev"></param> /// <returns></returns> protected internal static SdlEventArgs CreateEventArgs(Sdl.SDL_Event ev) { switch ((EventTypes)ev.type) { case EventTypes.KeyDown: return new KeyboardEventArgs(ev); case EventTypes.KeyUp: return new KeyboardEventArgs(ev); case EventTypes.ActiveEvent: return new ActiveEventArgs(ev); case EventTypes.Quit: return new QuitEventArgs(ev); case EventTypes.MouseButtonUp: return new MouseButtonEventArgs(ev); case EventTypes.MouseButtonDown: return new MouseButtonEventArgs(ev); case EventTypes.MouseMotion: return new MouseMotionEventArgs(ev); case EventTypes.VideoExpose: return new VideoExposeEventArgs(ev); case EventTypes.VideoResize: return new VideoResizeEventArgs(ev); case EventTypes.UserEvent: return new UserEventArgs(ev); default: return new SdlEventArgs(ev); } }
public void MouseDownHandler(Sdl.SDL_MouseButtonEvent button) { if (button.button == Sdl.SDL_BUTTON_LEFT) { grabPos = m_keyboard.MousePos - Position; grab = Bounds.Contains(m_keyboard.MousePos); } }
public virtual void AddLetter(Sdl.SDL_keysym key) { if (!HasFocus) return; if (m_keyboard.KeyIsChar(key)) { Contents.Contents += m_keyboard.KeyToChar(key); } else if (key.sym == Sdl.SDLK_BACKSPACE && Contents.Contents.Length > 0) { Contents.Contents = Contents.Contents.Substring(0, Contents.Contents.Length-1); } }
//public void onKeyPress(object o, KeyPressEventArgs args) public void onKeyPress(Sdl.SDL_keysym keysym) { switch(keysym.sym) { case Sdl.SDLK_RETURN: this.m_shouldStart = true; break; case Sdl.SDLK_e: this.m_usePotion = true; break; case Sdl.SDLK_q: this.m_dropItem = true; break; case Sdl.SDLK_SPACE: this.m_useAutoAttack = true; break; case Sdl.SDLK_g: this.m_lootItem = true; break; case Sdl.SDLK_w: this.m_currentMoveDirection = MovingDirection.UP; if(!this.m_moveKeys.Contains(keysym.sym)) this.m_moveKeys.Add(keysym.sym); break; case Sdl.SDLK_a: this.m_currentMoveDirection = MovingDirection.LEFT; if(!this.m_moveKeys.Contains(keysym.sym)) this.m_moveKeys.Add(keysym.sym); break; case Sdl.SDLK_s: this.m_currentMoveDirection = MovingDirection.DOWN; if(!this.m_moveKeys.Contains(keysym.sym)) this.m_moveKeys.Add(keysym.sym); break; case Sdl.SDLK_d: this.m_currentMoveDirection = MovingDirection.RIGHT; if(!this.m_moveKeys.Contains(keysym.sym)) this.m_moveKeys.Add(keysym.sym); break; default: break; } if(keysym.mod == Sdl.SDLK_LSHIFT) this.m_useSpecial = true; }
public void MouseDownHandler(Sdl.SDL_MouseButtonEvent button) { if (button.button == Sdl.SDL_BUTTON_LEFT) { grabPos = m_keyboard.MousePos - Position; if (MouseOnLeft ()) { leftGrab = true; } if (MouseOnRight ()) { rightGrab = true; } if (MouseOnBottom()) { bottomGrab = true; } if (MouseOnTop()) { topGrab = true; } if (MouseInMiddle()) { middleGrab = true; } } }
public void HandleInput(Sdl.SDL_Event sdl_event) { switch (sdl_event.type) { case Sdl.SDL_QUIT: Dispose(); return; case Sdl.SDL_KEYDOWN: if (sdl_event.key.keysym.sym == Sdl.SDLK_ESCAPE) { Dispose(); return; } else if (sdl_event.key.keysym.sym == 'n') { rotation += (float)(Math.PI / 100); Vector3 newPos = new Vector3((float)Math.Cos(rotation), 0, (float)Math.Sin(rotation)); newPos = newPos * 25; newPos.Y = 10; CameraManager.Current.position = newPos; } else if (sdl_event.key.keysym.sym == 'm') { rotation -= (float)(Math.PI / 100); Vector3 newPos = new Vector3((float)Math.Cos(rotation), 0, (float)Math.Sin(rotation)); newPos = newPos * 25; newPos.Y = 10; CameraManager.Current.position = newPos; } break; case Sdl.SDL_MOUSEBUTTONDOWN: if (sdl_event.button.button == Sdl.SDL_BUTTON_LEFT) { this.mrExplody = new Explosion(new Vector3(1, 1, 1), 0f, 5.0f); return; } break; } }
private static void ProcessEvent(Sdl.SDL_Event ev) { switch ((EventTypes)ev.type) { case EventTypes.ActiveEvent: OnActiveEvent(new ActiveEventArgs(ev)); break; case EventTypes.JoystickAxisMotion: OnJoystickAxisMotion(new JoystickAxisEventArgs(ev)); break; case EventTypes.JoystickBallMotion: OnJoystickBallMotion(new JoystickBallEventArgs(ev)); break; case EventTypes.JoystickButtonDown: OnJoystickButtonDown(new JoystickButtonEventArgs(ev)); break; case EventTypes.JoystickButtonUp: OnJoystickButtonUp(new JoystickButtonEventArgs(ev)); break; case EventTypes.JoystickHatMotion: OnJoystickHatMotion(new JoystickHatEventArgs(ev)); break; case EventTypes.KeyDown: OnKeyboardDown(new KeyboardEventArgs(ev)); break; case EventTypes.KeyUp: OnKeyboardUp(new KeyboardEventArgs(ev)); break; case EventTypes.MouseButtonDown: OnMouseButtonDown(new MouseButtonEventArgs(ev)); break; case EventTypes.MouseButtonUp: OnMouseButtonUp(new MouseButtonEventArgs(ev)); break; case EventTypes.MouseMotion: OnMouseMotion(new MouseMotionEventArgs(ev)); break; case EventTypes.Quit: OnQuitEvent(new QuitEventArgs(ev)); break; case EventTypes.UserEvent: OnUserEvent(new UserEventArgs(ev)); break; case EventTypes.VideoExpose: OnVideoExpose(new VideoExposeEventArgs(ev)); break; case EventTypes.VideoResize: OnVideoResize(new VideoResizeEventArgs(ev)); break; } }
public static IntPtr TTF_RenderUTF8_Shaded(IntPtr font, string text, Sdl.SDL_Color fg, Sdl.SDL_Color bg);
public static IntPtr TTF_RenderUTF8_Solid(IntPtr font, string text, Sdl.SDL_Color fg);
internal MouseMotionEventArgs(Sdl.SDL_Event evt) : base(evt) { }
internal JoystickButtonEventArgs(Sdl.SDL_Event evt) : base(evt) { }
public static extern IntPtr TTF_RenderUTF8_Blended( IntPtr font, string text, Sdl.SDL_Color fg);
public static extern IntPtr TTF_RenderGlyph_Blended( IntPtr font, short ch, Sdl.SDL_Color fg);
public void MouseUpHandler(Sdl.SDL_MouseButtonEvent button) { if (button.button == Sdl.SDL_BUTTON_LEFT) { leftGrab = false; rightGrab = false; topGrab = false; bottomGrab = false; middleGrab = false; } }
internal MouseButtonEventArgs(Sdl.SDL_Event evt) : base(evt) { }
internal QuitEventArgs(Sdl.SDL_Event evt) : base(evt) { }
public static int SDL_GetWMInfo(out Sdl.SDL_SysWMinfo info);
internal VideoResizeEventArgs(Sdl.SDL_Event evt) : base(evt) { }
public virtual void MouseClicked(Sdl.SDL_MouseButtonEvent button) { if (Hidden) return; if (button.button == Sdl.SDL_BUTTON_LEFT && Bounds.Contains(m_keyboard.MousePos)) { if (Pressed != null) Pressed(); GetFocus(this); } }
internal KeyboardEventArgs(Sdl.SDL_Event evt) : base(evt) { }
internal JoystickHatEventArgs(Sdl.SDL_Event evt) : base(evt) { }
public static int SDL_GetWMInfo(out Sdl.SDL_SysWMinfo_Windows info);
public static extern IntPtr TTF_RenderText_Shaded( IntPtr font, string text, Sdl.SDL_Color fg, Sdl.SDL_Color bg);
public static IntPtr TTF_RenderGlyph_Shaded(IntPtr font, short ch, Sdl.SDL_Color fg, Sdl.SDL_Color bg);
public static extern IntPtr TTF_RenderUNICODE_Blended( IntPtr font, [MarshalAs(UnmanagedType.LPWStr)] string text, Sdl.SDL_Color fg);
public static IntPtr TTF_RenderGlyph_Solid(IntPtr font, short ch, Sdl.SDL_Color fg);
internal VideoExposeEventArgs(Sdl.SDL_Event evt) : base(evt) { }
public static IntPtr TTF_RenderText_Blended(IntPtr font, string text, Sdl.SDL_Color fg);
public static extern int SDL_gfxBlitRGBA(IntPtr src, ref Sdl.SDL_Rect srcrect, IntPtr dst, Sdl.SDL_Rect dstrect);
/// <summary> /// Holds SDL_Event /// </summary> /// <param name="eventStruct">Event Struct</param> protected SdlEventArgs(Sdl.SDL_Event eventStruct) { this.eventStruct = eventStruct; }