protected override void InitializeCore() { base.InitializeCore(); Name = "UIComponentRenderer"; game = (IGame)Services.GetService(typeof(IGame)); input = (InputManager)Services.GetService(typeof(InputManager)); uiSystem = (UISystem)Services.GetService(typeof(UISystem)); rendererManager = new RendererManager(new DefaultRenderersFactory(Services)); batch = uiSystem.Batch; }
public override void Initialize() { base.Initialize(); input = Services.GetServiceAs<InputManager>(); Enabled = true; Visible = false; if (Game != null) // thumbnail system has no game { Game.Activated += OnApplicationResumed; Game.Deactivated += OnApplicationPaused; } }
protected override void InitializeCore() { base.InitializeCore(); Name = "UIComponentRenderer"; game = (IGame)RenderSystem.Services.GetService(typeof(IGame)); input = (InputManager)RenderSystem.Services.GetService(typeof(InputManager)); uiSystem = (UISystem)RenderSystem.Services.GetService(typeof(UISystem)); graphicsDeviceService = RenderSystem.Services.GetSafeServiceAs<IGraphicsDeviceService>(); if (uiSystem == null) { var gameSytems = RenderSystem.Services.GetServiceAs<IGameSystemCollection>(); uiSystem = new UISystem(RenderSystem.Services); gameSytems.Add(uiSystem); } rendererManager = new RendererManager(new DefaultRenderersFactory(RenderSystem.Services)); batch = uiSystem.Batch; }
/// <summary> /// Initializes a new instance of the <see cref="Game"/> class. /// </summary> public Game() { // Register the logger backend before anything else logListener = GetLogListener(); if (logListener != null) GlobalLogger.GlobalMessageLogged += logListener; // Create and register all core services Input = new InputManager(Services); Script = new ScriptSystem(Services); SceneSystem = new SceneSystem(Services); Audio = new AudioSystem(Services); UI = new UISystem(Services); gameFontSystem = new GameFontSystem(Services); SpriteAnimation = new SpriteAnimationSystem(Services); ProfilerSystem = new GameProfilingSystem(Services); // --------------------------------------------------------- // Add common GameSystems - Adding order is important // (Unless overriden by gameSystem.UpdateOrder) // --------------------------------------------------------- // Add the input manager GameSystems.Add(Input); // Add the scheduler system // - Must be after Input, so that scripts are able to get latest input // - Must be before Entities/Camera/Audio/UI, so that scripts can apply // changes in the same frame they will be applied GameSystems.Add(Script); // Add the UI System GameSystems.Add(UI); // Add the Audio System GameSystems.Add(Audio); // Add the Font system GameSystems.Add(gameFontSystem); //Add the sprite animation System GameSystems.Add(SpriteAnimation); Asset.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector; // Creates the graphics device manager GraphicsDeviceManager = new GraphicsDeviceManager(this); GameSystems.Add(ProfilerSystem); AutoLoadDefaultSettings = true; }
private void InterpretKey(Keys key, InputManager input) { // delete and back space have same behavior when there is a selection if (SelectionLength > 0 && (key == Keys.Delete || key == Keys.Back)) { SelectedText = ""; return; } // backspace with caret if (key == Keys.Back) { selectionStart = Math.Max(0, selectionStart - 1); SelectedText = ""; return; } // delete with caret if (key == Keys.Delete) { SelectionLength = 1; SelectedText = ""; return; } // select backward if (key == Keys.Left && (input.IsKeyDown(Keys.LeftShift) || input.IsKeyDown(Keys.RightShift))) { if (caretAtStart || selectionStart == selectionStop) Select(selectionStart - 1, SelectionLength + 1, true); else Select(selectionStart, SelectionLength - 1); return; } // select forward if (key == Keys.Right && (input.IsKeyDown(Keys.LeftShift) || input.IsKeyDown(Keys.RightShift))) { if (caretAtStart && selectionStart != selectionStop) Select(selectionStart + 1, SelectionLength - 1, true); else Select(selectionStart, SelectionLength + 1); return; } // move backward if (key == Keys.Left) { CaretPosition = CaretPosition - 1; return; } // move forward if (key == Keys.Right) { CaretPosition = CaretPosition + 1; return; } // validate the text with "enter" or "escape" if (key == Keys.Enter || key == Keys.Escape) { IsSelectionActive = false; return; } // try to convert the key to character and insert it at the caret position or replace the current selection var character = '\0'; if (TryConvertKeyToCharacter(key, input.IsKeyDown(Keys.LeftShift) || input.IsKeyDown(Keys.RightShift), ref character)) SelectedText = new string(character, 1); }
/// <summary> /// Updates this instance. /// </summary> public override void Update() { isTouched = false; hasGesture = false; SiliconStudio.Xenko.Input.InputManager manager = XenkoInputDevice.NativeInputManager; if (manager.PointerEvents.Count > 0) { var pointerEvent = manager.PointerEvents[0]; if (pointerEvent.PointerType != PointerType.Touch) { isTouched = false; return; } id = pointerEvent.PointerId; isTouched = true; normalizedX = pointerEvent.Position.X; normalizedY = pointerEvent.Position.Y; previousState = pointerEvent.State; previousLocation = pointerEvent.Position; switch (pointerEvent.State) { case PointerState.Cancel: action = TouchAction.None; break; case PointerState.Down: action = TouchAction.Pressed; break; case PointerState.Move: action = TouchAction.Moved; break; case PointerState.Out: action = TouchAction.None; break; case PointerState.Up: action = TouchAction.Released; break; default: break; } } else if (previousState == PointerState.Move) { previousState = PointerState.Out; action = TouchAction.Released; normalizedX = previousLocation.X; normalizedY = previousLocation.Y; isTouched = true; } if (manager.GestureEvents.Count > 0) { hasGesture = true; var gestureEvent = manager.GestureEvents[0]; switch (gestureEvent.Type) { case GestureType.Composite: gesture = TouchGestures.MoveRotateAndScale; var compositeEvent = gestureEvent as GestureEventComposite; normalizedX = compositeEvent.CenterCurrentPosition.X; normalizedY = compositeEvent.CenterCurrentPosition.Y; moveX = compositeEvent.DeltaTranslation.X; moveY = compositeEvent.DeltaTranslation.Y; break; case GestureType.Drag: gesture = TouchGestures.FreeDrag; var dragGestureEvent = gestureEvent as GestureEventDrag; normalizedX = dragGestureEvent.CurrentPosition.X; normalizedY = dragGestureEvent.CurrentPosition.Y; moveX = dragGestureEvent.DeltaTranslation.X; moveY = dragGestureEvent.DeltaTranslation.Y; break; case GestureType.Flick: gesture = TouchGestures.Flick; var flickEvent = gestureEvent as GestureEventFlick; normalizedX = flickEvent.CurrentPosition.X; normalizedY = flickEvent.CurrentPosition.Y; moveX = flickEvent.DeltaTranslation.X; moveY = flickEvent.DeltaTranslation.Y; break; case GestureType.LongPress: gesture = TouchGestures.Hold; var longPressEvent = gestureEvent as GestureEventLongPress; normalizedX = longPressEvent.Position.X; normalizedY = longPressEvent.Position.Y; moveX = moveY = 0; break; case GestureType.Tap: gesture = TouchGestures.Tap; var tapEvent = gestureEvent as GestureEventTap; normalizedX = tapEvent.TapPosition.X; normalizedY = tapEvent.TapPosition.Y; moveX = moveY = 0; break; default: break; } } }
public ViewListener(InputManager inputManager) { this.inputManager = inputManager; }
public abstract float GetValue(InputManager manager);