public CharacterBoard() { _settings = DependencyInjection.Resolve <IReadOnlySettings>(); _mouseInput = DependencyInjection.Resolve <IMouseInput>(); _editingArea = new AreaRectangle(205, 110, 380, 345, new Color(10, 10, 10, 50)); _characterPosition = new Vector2(400, 450); }
public IconsPalette() { _items = new List <IconPaletteItem>(); _characterDefinition = DependencyInjection.Resolve <CharacterDefinition>(); _mouseInput = DependencyInjection.Resolve <IMouseInput>(); _settings = DependencyInjection.Resolve <IReadOnlySettings>(); for (var l = 0; l < 4; l++) { for (var i = 0; i < 25; i++) { var source = new Rectangle((i % 5) * 64, (i / 5) * 64, 64, 64); var destination = new Rectangle(i * 23, 467 + l * 32, 23, 32); if (l == 3) { source.X = (i % 4) * 80; source.Y = (i / 4) * 64; source.Width = 80; if (i < 15) { destination.X = i * 30; destination.Width = 30; } } _items.Add(new IconPaletteItem(i + 64 * l, l, source, destination)); } } }
public PropertyWheelWidgetBase(HudParentBase parent = null) : base(parent) { confirmButton = new BorderedButton() { Text = "Confirm", Height = 40f, Width = 150f, Padding = Vector2.Zero, TextPadding = Vector2.Zero, }; cancelButton = new BorderedButton() { Text = "Cancel", Height = 40f, Width = 150f, Padding = Vector2.Zero, TextPadding = Vector2.Zero, }; buttonChain = new HudChain(false) { ParentAlignment = ParentAlignments.Left | ParentAlignments.Inner, Spacing = 8f, CollectionContainer = { confirmButton, cancelButton } }; DimAlignment = DimAlignments.Width | DimAlignments.IgnorePadding; MouseInput = new MouseInputElement(this) { ZOffset = 10, DimAlignment = DimAlignments.Both | DimAlignments.IgnorePadding, ShareCursor = true, }; }
public CharacterBoard() { _settings = DependencyInjection.Resolve<IReadOnlySettings>(); _mouseInput = DependencyInjection.Resolve<IMouseInput>(); _editingArea = new AreaRectangle(205, 110, 380, 345, new Color(10, 10, 10, 50)); _characterPosition = new Vector2(400, 450); }
public FlipTextButton(int x, int y) { _text = DependencyInjection.Resolve <IText>(); _mouseInput = DependencyInjection.Resolve <IMouseInput>(); Position = new Vector2(x, y); _options = new List <FlipTextOption>(); }
//---------------------------------------------------------------------- public override void Awake() { background = this.gameObject.GetComponent <Image>(); mInput = this.gameObject.GetComponent <UiMouseInputProvider>(); Subscribe(); base.Awake(); }
public IconsPalette() { _items = new List<IconPaletteItem>(); _characterDefinition = DependencyInjection.Resolve<CharacterDefinition>(); _mouseInput = DependencyInjection.Resolve<IMouseInput>(); _settings = DependencyInjection.Resolve<IReadOnlySettings>(); for (var l = 0; l < 4; l++) { for (var i = 0; i < 25; i++) { var source = new Rectangle((i % 5) * 64, (i / 5) * 64, 64, 64); var destination = new Rectangle(i * 23, 467 + l * 32, 23, 32); if (l == 3) { source.X = (i % 4) * 80; source.Y = (i / 4) * 64; source.Width = 80; if (i < 15) { destination.X = i * 30; destination.Width = 30; } } _items.Add(new IconPaletteItem(i + 64 * l, l, source, destination)); } } }
public NpcNameFinder(ILogger logger, IDirectBitmapProvider bitmapProvider, IMouseInput mouseInput) { this.logger = logger; this.mouseInput = mouseInput; this.bitmapProvider = bitmapProvider; locFindAndClickNpc = new List <Point> { new Point(0, 0), new Point(10, 10).Scale(scaleToRefWidth, scaleToRefHeight), new Point(-10, -10).Scale(scaleToRefWidth, scaleToRefHeight), new Point(20, 20).Scale(scaleToRefWidth, scaleToRefHeight), new Point(-20, -20).Scale(scaleToRefWidth, scaleToRefHeight) }; locFindByCursorType = new List <Point> { new Point(0, 0), new Point(0, -25).Scale(scaleToRefWidth, scaleToRefHeight), new Point(-5, 10).Scale(scaleToRefWidth, scaleToRefHeight), new Point(5, 35).Scale(scaleToRefWidth, scaleToRefHeight), new Point(-5, 75).Scale(scaleToRefWidth, scaleToRefHeight), new Point(0, 125).Scale(scaleToRefWidth, scaleToRefHeight), new Point(0, 160).Scale(scaleToRefWidth, scaleToRefHeight), }; }
protected override void Awake() { base.Awake(); CardHandSelector = transform.parent.GetComponentInChildren <UiCardHandSelector>(); Input = GetComponent <IMouseInput>(); Input.OnPointerUp += OnPointerUp; }
public TextEditor(int x, int y) { _text = DependencyInjection.Resolve<IText>(); _mouseInput = DependencyInjection.Resolve<IMouseInput>(); _keyboardControl = DependencyInjection.Resolve<IKeyboardControl>(); Position = new Vector2(x, y); Visible = true; }
public Button(IMouseInput mouseInput, string textureName, Vector2 position, Rectangle size) { MouseInput = mouseInput; Size = size; this.Scale = new Vector2(0.5f, 0.5f); this.AddPositionComponent(position.X, position.Y); this.AddTextureComponent(textureName, size.Width, size.Height); }
public TextEditor(int x, int y) { _text = DependencyInjection.Resolve <IText>(); _mouseInput = DependencyInjection.Resolve <IMouseInput>(); _keyboardControl = DependencyInjection.Resolve <IKeyboardControl>(); Position = new Vector2(x, y); Visible = true; }
public override void Initialize() { base.Initialize(); mouseInput = (IMouseInput)Game.Services.GetService(typeof(IMouseInput)); cursorManager = (ICursorManager)Game.Services.GetService(typeof(ICursorManager)); graphicsManager = (IGraphicsManager)Game.Services.GetService(typeof(IGraphicsManager)); }
public TextButton(string text, int x, int y) { _guiText = DependencyInjection.Resolve<IText>(); _mouseInput = DependencyInjection.Resolve<IMouseInput>(); Text = text; Position = new Vector2(x, y); Visible = true; }
public static void InitializeServices(IServiceProvider serviceProvider) { KeyboardInput = (IKeyboardInput)serviceProvider.GetService(typeof(IKeyboardInput)); MouseInput = (IMouseInput)serviceProvider.GetService(typeof(IMouseInput)); CursorManager = (ICursorManager)serviceProvider.GetService(typeof(ICursorManager)); GraphicsManager = (IGraphicsManager)serviceProvider.GetService(typeof(IGraphicsManager)); ResourceManager = (IResourceManager)serviceProvider.GetService(typeof(IResourceManager)); Debug = (IDebug)serviceProvider.GetService(typeof(IDebug)); }
public TextButton(string text, int x, int y) { _guiText = DependencyInjection.Resolve <IText>(); _mouseInput = DependencyInjection.Resolve <IMouseInput>(); Text = text; Position = new Vector2(x, y); Visible = true; }
protected override void Attach(IControl control) { _isprite = control as ISpriteContent; _imouse = control as IMouseInput; _ihitbox = control as ICustomHitBox; _icursor = control as ICustomCursor; if (_imouse != null || _ihitbox != null) { gameObject.AddComponent <BoxCollider>(); } }
public LiveEditor(QuickGameScene scene) { Scene = scene; KeyboardInput = Input.GetInput(scene); MouseInput = Input.GetMouseInput(scene); scene.AddObject(this); Cursor = new EditorCursor(scene); Menu = new EditorMenu(scene, this); ItemSelector = new ItemSelector(scene, this); }
/// <summary> /// Called the the control loses focus by the user clicking elsewhere. /// This takes care of hiding the drop down box. /// </summary> private void OnLoseFocusInternal(object sender, IMouseInput newFocus) { if (newFocus != dropDownToggle && newFocus != dropDownBox && newFocus != dropDownBox.ScrollBar) { if (dropDownVisible) { Parent.RemoveElement(dropDownBox); } dropDownBox.AllowScrollBar = false; dropDownToggle.Enabled = false; dropDownVisible = false; } }
public GameScene(IDynamicRenderer renderer, IKeyboardInput keyboardInput, IMouseInput mouseInput) { this.renderer = renderer; renderer.Tick += (s, e) => Tick(); this.keyboardInput = keyboardInput; this.mouseInput = mouseInput; this.mouseInput.OnMouseMoved += (s, e) => lastMousePosition = e; lastMousePosition = this.mouseInput.MousePosition; obstacles = GenerateObstacles(); TestTriangulation(); }
public static bool OnMouseClick(int button, int state, int x, int y) { MousePosition = new Click(x, y, (MouseButton)button, (MouseState)state); // call OnLoseFocus if a control lost focus if (MousePosition.State == MouseState.Down) { if (Focus != null && currentSelection != Focus && Focus.OnLoseFocus != null) { Focus.OnLoseFocus(null, currentSelection); } Focus = currentSelection; } if (activeSelection != null && MousePosition.State == MouseState.Up) { // if mouseup while a pickable object is active if (activeSelection.OnMouseUp != null) { activeSelection.OnMouseUp(null, new MouseEventArgs(MousePosition, LastMousePosition)); } activeSelection = null; } else if (currentSelection != null && !(currentSelection is UIContainer)) { // if the mouse is current over a pickable object and clicks if (MousePosition.State == MouseState.Down) { if (currentSelection.OnMouseDown != null) { currentSelection.OnMouseDown(null, new MouseEventArgs(MousePosition, LastMousePosition)); } activeSelection = currentSelection; } else { if (currentSelection.OnMouseUp != null) { currentSelection.OnMouseUp(null, new MouseEventArgs(MousePosition, LastMousePosition)); } activeSelection = null; } if (currentSelection.OnMouseClick != null) { currentSelection.OnMouseClick(null, new MouseEventArgs(MousePosition, LastMousePosition)); } } return(activeSelection != null); }
protected override void Initialize() { _editArea = new AreaRectangle(100, 50, 400, 450, new Color(255, 255, 255, 100)); App.Register(); _mouseComponent = DependencyInjection.Resolve <IMouseComponent>(); _mouseInput = DependencyInjection.Resolve <IMouseInput>(); _mouseDrawer = DependencyInjection.Resolve <IMouseDrawer>(); _settings = DependencyInjection.Resolve <ISettings>(); _map = DependencyInjection.Resolve <IMapComponent>(); _keyboardComponent = DependencyInjection.Resolve <IKeyboardComponent>(); base.Initialize(); }
public Button(Texture2D texture, Rectangle source, int x, int y, float scale) { _position = new Vector2(x, y); _texture = texture; _source = source; _destination = new Rectangle(x, y, (int)(source.Width * scale), (int)(source.Height * scale)); _mouseInput = DependencyInjection.Resolve <IMouseInput>(); _destinationHover = _destination; _destinationHover.X -= 1; _destinationHover.Y -= 1; _destinationHover.Width += 2; _destinationHover.Height += 2; }
private void OnLoseFocusInternal(object sender, IMouseInput newFocus) { if (newFocus == this.dropDownToggle || newFocus == this.dropDownBox || newFocus == this.dropDownBox.ScrollBar) { return; } if (this.dropDownVisible) { this.Parent.RemoveElement((UIElement)this.dropDownBox); } this.dropDownBox.AllowScrollBar = false; this.dropDownToggle.Enabled = false; this.dropDownVisible = false; }
public Button(Texture2D texture, Rectangle source, int x, int y, float scale) { _position = new Vector2(x, y); _texture = texture; _source = source; _destination = new Rectangle(x, y, (int)(source.Width * scale), (int)(source.Height * scale)); _mouseInput = DependencyInjection.Resolve<IMouseInput>(); _destinationHover = _destination; _destinationHover.X -= 1; _destinationHover.Y -= 1; _destinationHover.Width += 2; _destinationHover.Height += 2; }
private float shootingSpeed; //Max kliksnelheid voor schieten public RocketLauncher(Entity anObject, IMouseInput mouse) { Mouse = mouse; animationFactory = new AnimationFactory(); GunAnimationHandler animationHandler = new GunAnimationHandler(); animationHandler.Texture = Textures.gunTexture; animationHandler.Mouse = mouse; animationHandler.animations = CreateGunAnimations(); animationHandler.ParentTransform = anObject; //Volg object _AnimationHandler = animationHandler; _collision = anObject._collision; Position = anObject.Position; //Startpositie cooldown = new Cooldown(); Team = ((Human)anObject).Team; shootingSpeed = 1f; Scale = 1f; }
public static bool OnMouseClick(int button, int state, int x, int y) { UserInterface.MousePosition = new Click(x, y, (MouseButton)button, (MouseState)state); if (UserInterface.MousePosition.State == MouseState.Down) { if (UserInterface.Focus != null && UserInterface.currentSelection != UserInterface.Focus && UserInterface.Focus.OnLoseFocus != null) { UserInterface.Focus.OnLoseFocus((object)null, (IMouseInput)UserInterface.currentSelection); } UserInterface.Focus = (IMouseInput)UserInterface.currentSelection; } if (UserInterface.activeSelection != null && UserInterface.MousePosition.State == MouseState.Up) { if (UserInterface.activeSelection.OnMouseUp != null) { UserInterface.activeSelection.OnMouseUp((object)null, new MouseEventArgs(UserInterface.MousePosition, UserInterface.LastMousePosition)); } UserInterface.activeSelection = (UIElement)null; } else if (UserInterface.currentSelection != null && !(UserInterface.currentSelection is UIContainer)) { if (UserInterface.MousePosition.State == MouseState.Down) { if (UserInterface.currentSelection.OnMouseDown != null) { UserInterface.currentSelection.OnMouseDown((object)null, new MouseEventArgs(UserInterface.MousePosition, UserInterface.LastMousePosition)); } UserInterface.activeSelection = UserInterface.currentSelection; } else { if (UserInterface.currentSelection.OnMouseUp != null) { UserInterface.currentSelection.OnMouseUp((object)null, new MouseEventArgs(UserInterface.MousePosition, UserInterface.LastMousePosition)); } UserInterface.activeSelection = (UIElement)null; } if (UserInterface.currentSelection.OnMouseClick != null) { UserInterface.currentSelection.OnMouseClick((object)null, new MouseEventArgs(UserInterface.MousePosition, UserInterface.LastMousePosition)); } } return(UserInterface.activeSelection != null); }
protected override void HandleInput(Vector2 cursorPos) { /* TextBoard Offsets: * * The TextBoard allows you to set an offset for the text being rendered starting from the * center of the element. Text outside the bounds of the element will not be drawn. * Offset is measured in pixels and updates with changes to scale. * * An offset in the negative direction on the X-axis will offset the text to the left; a positive * offset will move the text to the right. * * On the Y-axis, a negative offset will move the text down and a positive offset will move it in * the opposite direction. * * By default, the visible range of text will start at the first line on the first character. * It starts in the upper left hand corner. */ ITextBoard textBoard = text.TextBoard; IMouseInput horzControl = horizontalScroll.slide.MouseInput, vertControl = verticalScroll.slide.MouseInput; // If the total width of the text is greater than the size of the element, then I can scroll // horiztonally. This value is negative because the text is starts at the right hand side // and I need to move it left. horizontalScroll.Max = Math.Max(0f, textBoard.TextSize.X - textBoard.Size.X); // Same principle, but vertical and moving up. TextBoards start at the first line which means // every line that follows lower than the last, so I need to move up. verticalScroll.Max = Math.Max(0f, textBoard.TextSize.Y - textBoard.Size.Y); // Update the ScrollBar positions to represent the current offset unless they're being clicked. if (!horzControl.IsLeftClicked) { horizontalScroll.Current = -textBoard.TextOffset.X; } if (!vertControl.IsLeftClicked) { verticalScroll.Current = textBoard.TextOffset.Y; } textBoard.TextOffset = new Vector2(-horizontalScroll.Current, verticalScroll.Current); }
public static void Initialise(IKeyboardInput keyboardInput, IWindow window, IMouseInput mouseInput, ISoundOutput soundOutput, long seed) { if (_instance != null) { throw new System.InvalidOperationException("Already Created"); } Keyboard.Initialise(keyboardInput); _instance = new Engine(); _instance._root = new Ent(null); _instance._time = new Time(); _instance._window = window; _instance._toBeUpdated = new Stack <IEnt>(); _instance._mouse = mouseInput; _instance._sound = soundOutput; _instance.Seed = seed; _instance._window.OnStart(); _instance._time.Start(); }
public NpcNameTargeting(ILogger logger, NpcNameFinder npcNameFinder, IMouseInput input) { this.logger = logger; this.npcNameFinder = npcNameFinder; this.input = input; locTargetingAndClickNpc = new List <Point> { new Point(0, 0), new Point(-10, 15).Scale(npcNameFinder.scaleToRefWidth, npcNameFinder.scaleToRefHeight), new Point(10, 15).Scale(npcNameFinder.scaleToRefWidth, npcNameFinder.scaleToRefHeight), }; locFindByCursorType = new List <Point> { new Point(0, 0), new Point(0, 25).Scale(npcNameFinder.scaleToRefWidth, npcNameFinder.scaleToRefHeight), new Point(0, 75).Scale(npcNameFinder.scaleToRefWidth, npcNameFinder.scaleToRefHeight), }; }
/// <summary> /// Create the user interface instance. /// </summary> public UserInterface() { // sanity test if (_content == null) { throw new Exceptions.InvalidStateException("Cannot create a UserInterface before calling UserInterface.Initialize()!"); } // create default input providers MouseInputProvider = new DefaultInputProvider(); KeyboardInputProvider = new DefaultInputProvider(); // create draw utils DrawUtils = new DrawUtils(); // create the root panel Root = new RootPanel(); // set default cursor SetCursor(CursorType.Default); }
protected override void HandleInput(Vector2 cursorPos) { ITextBoard textBoard = textBox.TextBoard; IMouseInput vertControl = verticalScroll.slide.MouseInput; verticalScroll.Max = Math.Max(0f, textBoard.TextSize.Y - textBoard.Size.Y); // Update the ScrollBar positions to represent the current offset unless they're being clicked. if (!vertControl.IsLeftClicked) { if (IsMousedOver || verticalScroll.IsMousedOver) { Vector2I lineRange = textBoard.VisibleLineRange; if (SharedBinds.MousewheelUp.IsPressed || SharedBinds.UpArrow.IsNewPressed || SharedBinds.UpArrow.IsPressedAndHeld) { textBoard.MoveToChar(new Vector2I(lineRange.X - 1, 0)); } else if (SharedBinds.MousewheelDown.IsPressed || SharedBinds.DownArrow.IsNewPressed || SharedBinds.DownArrow.IsPressedAndHeld) { textBoard.MoveToChar(new Vector2I(lineRange.Y + 1, 0)); } else if (SharedBinds.PageUp.IsNewPressed || SharedBinds.PageUp.IsPressedAndHeld) { // A hacky, somewhat inefficient solution, but it works well textBoard.MoveToChar(new Vector2I(0, 0)); textBoard.MoveToChar(new Vector2I(lineRange.X - 1, 0)); } else if (SharedBinds.PageDown.IsNewPressed || SharedBinds.PageDown.IsPressedAndHeld) { textBoard.MoveToChar(new Vector2I(textBoard.Count - 1, 0)); textBoard.MoveToChar(new Vector2I(lineRange.Y + 1, 0)); } } verticalScroll.Current = textBoard.TextOffset.Y; } textBoard.TextOffset = new Vector2(0, verticalScroll.Current); }
public static bool OnMouseClick(MouseButtonEvent e) { //MousePosition = new Click(x, y, (MouseButton)button, (MouseState)state); // call OnLoseFocus if a control lost focus if (e is MouseButtonPressedEvent) { if (Focus != null && currentSelection != Focus && Focus.OnLoseFocus != null) { Focus.OnLoseFocus(null, currentSelection); } Focus = currentSelection; } if (activeSelection != null && e is MouseButtonReleasedEvent) { // if mouseup while a pickable object is active //if (activeSelection.OnMouseUp != null) activeSelection.OnMouseUp(null, new MouseEventArgs(MousePosition, LastMousePosition)); activeSelection = null; } else if (currentSelection != null && !(currentSelection is UIContainer)) { // if the mouse is current over a pickable object and clicks if (e is MouseButtonPressedEvent) { //if (currentSelection.OnMouseDown != null) currentSelection.OnMouseDown(null, new MouseEventArgs(MousePosition, LastMousePosition)); activeSelection = currentSelection; } else { //if (currentSelection.OnMouseUp != null) currentSelection.OnMouseUp(null, new MouseEventArgs(MousePosition, LastMousePosition)); activeSelection = null; } //if (currentSelection.OnMouseClick != null) currentSelection.OnMouseClick(null, new MouseEventArgs(MousePosition, LastMousePosition)); } return(activeSelection != null); }
public TextBox(HudParentBase parent) : base(parent) { MouseInput = new MouseInputElement(this) { ShareCursor = true }; textInput = new TextInput(AddChar, RemoveLastChar, TextInputFilter); caret = new TextCaret(this) { Visible = false }; selectionBox = new SelectionBox(caret, this) { Color = new Color(255, 255, 255, 140) }; warningToolTip = new ToolTip() { text = "Open Chat to Enable Text Editing", bgColor = ToolTip.orangeWarningBG }; caret.CaretMoved += CaretMoved; MouseInput.GainedInputFocus += GainFocus; MouseInput.LostInputFocus += LoseFocus; ShareCursor = true; EnableEditing = true; EnableHighlighting = true; UseCursor = true; MoveToEndOnGainFocus = false; ClearSelectionOnLoseFocus = true; Size = new Vector2(60f, 200f); }
public static void SetEngineInput(IMouseInput mouse, IKeyboardInput keyboard) { DualityApp.Mouse = mouse; DualityApp.Keyboard = keyboard; }
public static void Load(SpriteBatch spriteBatch) { _spriteBatch = spriteBatch; _text = DependencyInjection.Resolve<IText>(); _mouseInput = DependencyInjection.Resolve<IMouseInput>(); }
public MenuSceneGenerator(IServiceProvider serviceProvider, IMouseInput mouseInput) { ServiceProvider = serviceProvider; MouseInput = mouseInput; }
protected override void Initialize() { _editArea = new AreaRectangle(100, 50, 400, 450, new Color(255, 255, 255, 100)); App.Register(); _mouseComponent = DependencyInjection.Resolve<IMouseComponent>(); _mouseInput = DependencyInjection.Resolve<IMouseInput>(); _mouseDrawer = DependencyInjection.Resolve<IMouseDrawer>(); _settings = DependencyInjection.Resolve<ISettings>(); _map = DependencyInjection.Resolve<IMapComponent>(); _keyboardComponent = DependencyInjection.Resolve<IKeyboardComponent>(); base.Initialize(); }
public MouseDrawer(IMouseInput mouseInput) { _mouseInput = mouseInput; }