/// <summary> /// Selects the week where the hit is contained /// </summary> /// <param name="hit"></param> private void SelectWeek(DateTime hit) { int preDays = (new int[] { 0, 1, 2, 3, 4, 5, 6 })[(int)hit.DayOfWeek] - (int)FirstDayOfWeek; _selectionStart = hit.AddDays(-preDays); SelectionEnd = SelectionStart.AddDays(6); }
/// <summary> /// Selecs the work-week where the hit is contanied /// </summary> /// <param name="hit"></param> private void SelectWorkWeek(DateTime hit) { int preDays = (new int[] { 0, 1, 2, 3, 4, 5, 6 })[(int)hit.DayOfWeek] - (int)WorkWeekStart; _selectionStart = hit.AddDays(-preDays); SelectionEnd = SelectionStart.AddDays(Math.Abs(WorkWeekStart - WorkWeekEnd)); }
protected override void RepaintInternal() { var unitWidth = Editor.FrameManagerComponent.GetCurrentFrameWidth() / (SongDataUtility.FRAMES_PER_BEAT / Editor.SubdivisionComponent.CurrentSubdivision.QuantityPerBeat); var squareRt = SelectionSquare.GetComponent <RectTransform>(); squareRt.anchoredPosition = new Vector2(unitWidth * SelectionStart, squareRt.anchoredPosition.y); StartFrameIndexText.text = SelectionStart.ToString(); if (CurrentMode == Mode.MULTI) { squareRt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, unitWidth * SelectionLength); SelectionSquare.enabled = true; var selectionLastFrame = SelectionImpliedEnd - 1; EndFrameIndexText.text = selectionLastFrame.ToString(); SelectionEndBar.SetActive(true); } else { SelectionSquare.enabled = false; SelectionEndBar.SetActive(false); } }
public void Reset() { currentScreen = Screen.StartScreen; currentSelection = SelectionStart.Singleplayer; SpelerRood.Playertype = 1; SpelerBlauw.Playertype = 1; livesBlue = 3; livesRed = 3; }
private IEnumerator <object> HandleInputTask() { bool wasFocused = false; var rightClickGesture = new ClickGesture(1); var clickGesture = new ClickGesture(); var doubleClickGesture = new DoubleClickGesture(); var dragGesture = new DragGesture(0, DragDirection.Any, dragThreshold: EditorParams.MouseSelectionThreshold); ClickableWidget.Gestures.Add(rightClickGesture); ClickableWidget.Gestures.Add(clickGesture); ClickableWidget.Gestures.Add(doubleClickGesture); ClickableWidget.Gestures.Add(dragGesture); while (true) { if (EditorParams.SelectAllOnFocus && !wasFocused && FocusableWidget.IsFocused()) { SelectAll(); CaretPos.TextPos = TextLength; } if (FocusableWidget.IsFocused()) { HandleKeys(); HandleTextInput(); } if (clickGesture.WasRecognized()) { if (!FocusableWidget.IsFocused()) { if (EditorParams.SelectAllOnFocus) { SelectAll(); } } else { HideSelection(); } FocusableWidget.SetFocus(); CaretPos.WorldPos = DisplayWidget.LocalMousePosition(); } if (doubleClickGesture.WasRecognized()) { if (IsTextReadable) { SelectWord(); } else { SelectAll(); } } if (rightClickGesture.WasRecognized()) { FocusableWidget.SetFocus(); ShowContextMenu(true); } if (dragGesture.WasRecognized()) { FocusableWidget.SetFocus(); CaretPos.WorldPos = DisplayWidget.ToLocalMousePosition(dragGesture.MousePressPosition); HideSelection(); EnsureSelection(); SelectionStart.AssignFrom(CaretPos); } else if (dragGesture.WasChanged()) { CaretPos.WorldPos = DisplayWidget.LocalMousePosition(); EnsureSelection(); SelectionEnd.AssignFrom(CaretPos); } Text.SyncCaretPosition(); AdjustSizeAndScrollToCaret(); var isFocused = CaretPos.IsVisible = FocusableWidget.IsFocused(); if (wasFocused && !isFocused) { HideSelection(); if (History.CanUndo()) { History.Clear(); Text.Submit(); } } wasFocused = isFocused; yield return(null); } }
void StartScreenUpdate(GameTime gameTime, GraphicsDeviceManager graphics, Game game) { PlayingBall.Update(gameTime, 0, graphics.GraphicsDevice.Viewport.Height - PlayingBall.BallTexture.Height, graphics.GraphicsDevice.Viewport.Width - PlayingBall.BallTexture.Width, 0); SpelerBlauw.Update(gameTime, Keys.Up, Keys.Down); SpelerRood.Update(gameTime, Keys.W, Keys.S); CheckYBoundaries(graphics); // Check Collision with the paddles, and if true change the angle and speed of the ball. if (SpelerBlauw.BoundariesPaddle.Intersects(PlayingBall.BoundariesBall) && PlayingBall.BallMovement.X > 0) { PlayingBall.BallMovement.Y *= -1.05f; PlayingBall.BallMovement.X *= -1; if (PlayingBall.BallMovement.X > -948) PlayingBall.BallMovement.X *= 1.1f; } if (SpelerRood.BoundariesPaddle.Intersects(PlayingBall.BoundariesBall) && PlayingBall.BallMovement.X < 0) { PlayingBall.BallMovement.Y *= 1.05f; PlayingBall.BallMovement.X *= -1; if (PlayingBall.BallMovement.X < 948) PlayingBall.BallMovement.X *= 1.1f; } if (currentSelection == SelectionStart.Singleplayer) // veranderen screen(singleplayer) { if (currentKeyBoardState.IsKeyDown(Keys.Space)) // wanneer op spatie gedrukt, spring naar singleplayermode(wordt uitgevoerd in screen.singleplayer). { PlayingBall.Reset(); SpelerBlauw.Reset(); SpelerRood.Reset(); SpelerBlauw.Playertype = 1; SpelerRood.Playertype = 0; currentScreen = Screen.Singleplayer; } else if (currentKeyBoardState.IsKeyDown(Keys.Down) && previousKeyBoardState.IsKeyUp(Keys.Down)) { currentSelection = SelectionStart.Multiplayer; // selecteer volgende optie } else if (currentKeyBoardState.IsKeyDown(Keys.Up) && previousKeyBoardState.IsKeyUp(Keys.Up)) { currentSelection = SelectionStart.Exit; } } else if (currentSelection == SelectionStart.Multiplayer) // veranderen screen(multiplayer) { if (currentKeyBoardState.IsKeyDown(Keys.Space)) { SpelerRood.Reset(); SpelerBlauw.Reset(); SpelerRood.Playertype = 0; SpelerBlauw.Playertype = 0; PlayingBall.Reset(); currentScreen = Screen.Multiplayer; // wanneer op spatie gedrukt, spring naar multiplayermode(wordt uitgevoerd in screen.multiplayer). } else if (currentKeyBoardState.IsKeyDown(Keys.Down) && previousKeyBoardState.IsKeyUp(Keys.Down)) { currentSelection = SelectionStart.Exit; } else if (currentKeyBoardState.IsKeyDown(Keys.Up) && previousKeyBoardState.IsKeyUp(Keys.Up)) { currentSelection = SelectionStart.Singleplayer; } } else // spel afsluiten { if (currentKeyBoardState.IsKeyDown(Keys.Space)) { game.Exit(); } else if (currentKeyBoardState.IsKeyDown(Keys.Down) && previousKeyBoardState.IsKeyUp(Keys.Down)) { currentSelection = SelectionStart.Singleplayer; } else if (currentKeyBoardState.IsKeyDown(Keys.Up) && previousKeyBoardState.IsKeyUp(Keys.Up)) { currentSelection = SelectionStart.Multiplayer; } } }
private void OnSelectionStarted() { SelectionInProgress = true; SelectionStartCell = ClampPositionToMapRect(Find.CurrentMap, UI.MouseCell()); SelectionStart?.Invoke(CellRect.SingleCell(SelectionStartCell)); }