public void CopyJumpCard(GameObject obj) { if (freeButtonMovePosition < 5) { for (int i = 0; i < chosenMovesButtons.Count; i++) { if (chosenMovesButtons[i].obj == obj) { GameObject newButton = Instantiate(JumpChosenCard) as GameObject; newButton.GetComponent <RectTransform>().localPosition = new Vector3(posX[freeButtonMovePosition], posY, 0); newButton.transform.Find("ChosenCardJump/PowerValue").gameObject.GetComponent <TextMeshProUGUI>().text = chosenMovesButtons[i].power.ToString(); newButton.transform.Find("ChosenCardJump/AngleValue").gameObject.GetComponent <TextMeshProUGUI>().text = chosenMovesButtons[i].angle.ToString(); newButton.transform.SetParent(Canvas.transform, false); Button copy = newButton.transform.Find("CopyButton").gameObject.GetComponent <Button>(); copy.onClick.AddListener(() => CopyJumpCard(newButton)); Button delete = newButton.transform.Find("Button").gameObject.GetComponent <Button>(); delete.onClick.AddListener(() => RearangeChosenMovesButtons(newButton)); Button card = newButton.transform.Find("ChosenCardJump").gameObject.GetComponent <Button>(); card.onClick.AddListener(() => JumpChange(newButton)); MoveButton x = new MoveButton(freeButtonMovePosition, newButton, "jump", transform, chosenMovesButtons[i].speed, chosenMovesButtons[i].distance, chosenMovesButtons[i].time, chosenMovesButtons[i].power, chosenMovesButtons[i].angle); chosenMovesButtons.Add(x); freeButtonMovePosition++; } } } }
public static FlowLayoutWidget CreateZButtons(PrinterConfig printer, double buttonSeparationDistance, out MoveButton zPlusControl, out MoveButton zMinusControl, XYZColors colors, ThemeConfig theme, bool levelingButtons = false) { var zButtons = new FlowLayoutWidget(FlowDirection.TopToBottom) { Margin = new BorderDouble(0, 5), }; zPlusControl = theme.CreateMoveButton(printer, "Z+", PrinterConnection.Axis.Z, printer.Settings.ZSpeed(), levelingButtons); zPlusControl.Name = "Move Z positive".Localize(); zPlusControl.ToolTipText = "Move Z positive".Localize(); zButtons.AddChild(zPlusControl); // spacer zButtons.AddChild(new GuiWidget(1, buttonSeparationDistance) { HAnchor = HAnchor.Center, BackgroundColor = colors.ZColor }); zMinusControl = theme.CreateMoveButton(printer, "Z-", PrinterConnection.Axis.Z, printer.Settings.ZSpeed(), levelingButtons); zMinusControl.ToolTipText = "Move Z negative".Localize(); zButtons.AddChild(zMinusControl); return(zButtons); }
// Start is called before the first frame update void Start() { Button click1 = TalkButton1.GetComponent <Button>(); Button click2 = TalkButton2.GetComponent <Button>(); Button click3 = TalkButton3.GetComponent <Button>(); Button click4 = TalkButton4.GetComponent <Button>(); Button click5 = TalkButton5.GetComponent <Button>(); Button click6 = TalkButton6.GetComponent <Button>(); Button click7 = TalkButton7.GetComponent <Button>(); Button click8 = TalkButton8.GetComponent <Button>(); Button click9 = TalkButton9.GetComponent <Button>(); Button click10 = MoveButton.GetComponent <Button>(); click1.onClick.AddListener(goodChoice); click2.onClick.AddListener(badChoice); click3.onClick.AddListener(conciliateChoice); click4.onClick.AddListener(coerciveChoice); click5.onClick.AddListener(observation); click6.onClick.AddListener(behavior); click7.onClick.AddListener(pass); click8.onClick.AddListener(arrest); click9.onClick.AddListener(dead); click10.onClick.AddListener(dead); //click4.onClick.AddListener(envisiable); startMsg(); }
public static FlowLayoutWidget CreateZButtons(RGBA_Bytes color, double buttonSeparationDistance, out MoveButton zPlusControl, out MoveButton zMinusControl, bool levelingButtons = false) { FlowLayoutWidget zButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); { MoveButtonFactory moveButtonFactory = new MoveButtonFactory(); moveButtonFactory.Colors.Fill.Normal = color; zPlusControl = CreateMoveButton("Z+", PrinterConnectionAndCommunication.Axis.Z, MovementControls.ZSpeed, levelingButtons, moveButtonFactory); zPlusControl.Name = "Move Z positive".Localize(); zPlusControl.ToolTipText = "Move Z positive".Localize(); zButtons.AddChild(zPlusControl); GuiWidget spacer = new GuiWidget(2, buttonSeparationDistance); spacer.HAnchor = Agg.UI.HAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.zColor; zButtons.AddChild(spacer); zMinusControl = CreateMoveButton("Z-", PrinterConnectionAndCommunication.Axis.Z, MovementControls.ZSpeed, levelingButtons, moveButtonFactory); zMinusControl.ToolTipText = "Move Z negative".Localize(); zButtons.AddChild(zMinusControl); } zButtons.Margin = new BorderDouble(0, 5); return(zButtons); }
void moveAxis_Click(object sender, EventArgs mouseEvent) { MoveButton moveButton = (MoveButton)sender; //Add more fancy movement here PrinterConnectionAndCommunication.Instance.MoveRelative(this.moveAxis, this.MoveAmount, movementFeedRate); }
public MoveButton(double x, double y, GuiWidget buttonView, PrinterConnectionAndCommunication.Axis axis, double movementFeedRate) : base(x, y, buttonView) { this.moveAxis = axis; this.movementFeedRate = movementFeedRate; this.Click += (s, e) => { MoveButton moveButton = (MoveButton)s; if (PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.Printing) { if (moveAxis == PrinterConnectionAndCommunication.Axis.Z) // only works on z { var currentZ = ActiveSliceSettings.Instance.GetValue <double>(SettingsKey.baby_step_z_offset); currentZ += this.MoveAmount; ActiveSliceSettings.Instance.SetValue(SettingsKey.baby_step_z_offset, currentZ.ToString("0.##")); } } else { PrinterConnectionAndCommunication.Instance.MoveRelative(this.moveAxis, this.MoveAmount, movementFeedRate); } }; }
///------------------------------------------------------------------------------------------------- /// \fn public override void ShowAsSelected() /// /// \brief Shows as selected ///------------------------------------------------------------------------------------------------- public override void ShowAsSelected() { base.ShowAsSelected(); PictureBox pictureBox = MainWin.GetInstance().MainView(); int sumx = 0, sumy = 0; for (int i = 0; i < pointArray.Count; i++) { Point pointtemp = pointArray[i]; AdjustButton temp = new AdjustButton( pictureBox, this, new Point(pointtemp.X - 3, pointtemp.Y - 3), Cursors.SizeNS); adjustButtons.Add(temp); temp.MouseDown += AdjustButton_MouseDown; temp.MouseUp += AdjustButton_MouseUp; temp.MouseMove += AdjustButton_MouseMove; sumx += pointtemp.X; sumy += pointtemp.Y; } //set moveButton attributes moveButton = new MoveButton(pictureBox, this, new Point(sumx / pointArray.Count, sumy / pointArray.Count), Cursors.SizeAll ); moveButton.MouseDown += MoveButton_MouseDown; moveButton.MouseMove += MoveButton_MouseMove; moveButton.MouseUp += MoveButton_MouseUp; Log.LogText("Select BSpline"); }
///------------------------------------------------------------------------------------------------- /// \fn public override void ShowAsSelected() /// /// \brief Shows as selected ///------------------------------------------------------------------------------------------------- public override void ShowAsSelected() { base.ShowAsSelected(); if (adjustButton == null) { adjustButton = new AdjustButton(MainWin.GetInstance().MainView(), this, Common.RotatingPoint(new Point(rect.Right, rect.Top), midPoint, angle), Cursors.SizeNS); adjustButton.MouseDown += AdjustButton_MouseDown; adjustButton.MouseUp += AdjustButton_MouseUp; adjustButton.MouseMove += AdjustButton_MouseMove; } if (moveButton == null) { moveButton = new MoveButton(MainWin.GetInstance().MainView(), this, Common.RotatingPoint(new Point(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2), midPoint, angle), Cursors.SizeAll); moveButton.MouseDown += MoveButton_MouseDown; moveButton.MouseMove += MoveButton_MouseMove; moveButton.MouseUp += MoveButton_MouseUp; moveButton.SetBindingPoints( new Ref <Point>(() => rect.Location, z => { rect.Location = Common.RotatingPoint(z, midPoint, -angle); }), new Ref <Point>(() => adjustButton.Location, z => { adjustButton.Location = z; }) ); } Log.LogText(string.Format("Select Ellipse ({0},{1}),({2},{3})", rect.Left, rect.Top, rect.Right, rect.Bottom)); }
// Start is called before the first frame update void Start() { spriteList = new SpriteRenderer[0, 0]; xSizeField.onValueChanged.AddListener(SetXSize); ySizeField.onValueChanged.AddListener(SetYSize); mapSize = minMapSize; isInputMode = false; obstacleSpriteDictionary = new Dictionary <AdjacentObstacle, Sprite>(); for (int i = 0; i < tileSpriteTable.ObstacleSprites.Length; i++) { obstacleSpriteDictionary.Add(tileSpriteTable.ObstacleSprites[i].adjacentObstacleDirection, tileSpriteTable.ObstacleSprites[i].sprite); } prisonSpriteDictionary = new Dictionary <AdjacentObstacle, Sprite>(); for (int i = 0; i < tileSpriteTable.PrisonSprites.Length; i++) { prisonSpriteDictionary.Add(tileSpriteTable.PrisonSprites[i].adjacentObstacleDirection, tileSpriteTable.PrisonSprites[i].sprite); } saveButton.onClick.AddListener(() => fileSystem.Open(this, FileSystemMode.Save)); loadButton.onClick.AddListener(() => fileSystem.Open(this, FileSystemMode.Load)); for (int i = 0; i < prisonMoveButtons.Length; i++) { MoveButton buttonPair = prisonMoveButtons[i]; buttonPair.button.onClick.AddListener(() => MovePrison(buttonPair.direction)); } }
public static void SetFocusUnit(BaseUnit b) { if (FocusUnit != null) { for (int j = 0; j < MoveButtons.Count; j++) { MoveButtons[j].uiButton.onClick.RemoveAllListeners(); MoveButtons[j].ToggleUiButton(true); } } FocusUnit = b; int numberOfMoves = b.UnitCombatMoves.Count; for (int i = 0; i < MoveButtons.Count; i++) { if (i < numberOfMoves) { Button bu = MoveButtons[i].uiButton; MoveButtons[i] = new MoveButton(bu, b.UnitCombatMoves[i]); MoveButtons[i].ToggleUiButton(true); MoveButtons[i].AddUnitAttackListener(b, MoveButtons[i].moveTypeToDisplay); //MoveButtons[i].uiButton.onClick.AddListener(() => SetTimeStamp(MoveButtons[i])); } else { MoveButtons[i].ToggleUiButton(false); MoveButtons[i].buttonText.text = ""; } } }
public Boolean btnReleased(MoveButton BTN_CODE) { if (((byte)BTN_CODE & currButtons) == 0) { return(true); } return(false); }
public Boolean btnOnRelease(MoveButton BTN_CODE) { if (((byte)BTN_CODE & releasedButtons) != 0) { return(true); } return(false); }
public Boolean btnOnPress(MoveButton BTN_CODE) { if (((byte)BTN_CODE & pressedButtons) != 0) { return(true); } return(false); }
private GuiWidget CreateXYGridControl(XYZColors colors, double distanceBetweenControls, double buttonSeparationDistance) { ActiveSliceSettings.SettingChanged.RegisterEvent(Printer_SettingChanged, ref unregisterEvents); GuiWidget xyGrid = new GuiWidget(); { FlowLayoutWidget xButtons = new FlowLayoutWidget(); { xButtons.HAnchor |= HAnchor.Center; xButtons.VAnchor |= VAnchor.Center; xMinusControl = theme.CreateMoveButton(printer, "X-", PrinterConnection.Axis.X, printer.Settings.XSpeed()); xMinusControl.ToolTipText = "Move X negative".Localize(); xButtons.AddChild(xMinusControl); // spacer xButtons.AddChild(new GuiWidget(xMinusControl.Width + buttonSeparationDistance * 2, 1) { VAnchor = VAnchor.Center, BackgroundColor = colors.XColor }); xPlusControl = theme.CreateMoveButton(printer, "X+", PrinterConnection.Axis.X, printer.Settings.XSpeed()); xPlusControl.ToolTipText = "Move X positive".Localize(); xButtons.AddChild(xPlusControl); } xyGrid.AddChild(xButtons); FlowLayoutWidget yButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); { yButtons.HAnchor |= HAnchor.Center; yButtons.VAnchor |= VAnchor.Center; yPlusControl = theme.CreateMoveButton(printer, "Y+", PrinterConnection.Axis.Y, printer.Settings.YSpeed()); yPlusControl.ToolTipText = "Move Y positive".Localize(); yButtons.AddChild(yPlusControl); // spacer yButtons.AddChild(new GuiWidget(1, buttonSeparationDistance) { HAnchor = HAnchor.Center, BackgroundColor = colors.YColor }); yMinusControl = theme.CreateMoveButton(printer, "Y-", PrinterConnection.Axis.Y, printer.Settings.YSpeed()); yMinusControl.ToolTipText = "Move Y negative".Localize(); yButtons.AddChild(yMinusControl); } xyGrid.AddChild(yButtons); } xyGrid.HAnchor = HAnchor.Fit; xyGrid.VAnchor = VAnchor.Fit; xyGrid.VAnchor = VAnchor.Bottom; xyGrid.Margin = new BorderDouble(0, 5, distanceBetweenControls, 5); return(xyGrid); }
public MoveButton Generate(string label, PrinterConnectionAndCommunication.Axis axis, double movementFeedRate) { //Create button based on view container widget ButtonViewStates buttonViewWidget = GetButtonView(label); MoveButton textImageButton = new MoveButton(0, 0, buttonViewWidget, axis, movementFeedRate); textImageButton.Margin = new BorderDouble(0); textImageButton.Padding = new BorderDouble(0); return(textImageButton); }
private GuiWidget CreateXYGridControl(XYZColors colors, double distanceBetweenControls, double buttonSeparationDistance) { xyGrid = new GuiWidget { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit | VAnchor.Bottom, Margin = new BorderDouble(0, 5, distanceBetweenControls, 5) }; var xButtons = new FlowLayoutWidget(); xButtons.HAnchor = HAnchor.Fit | HAnchor.Center; xButtons.VAnchor = VAnchor.Fit | VAnchor.Center; xyGrid.AddChild(xButtons); xMinusControl = theme.CreateMoveButton(printer, "X-", PrinterAxis.X, printer.Settings.XSpeed()); xMinusControl.ToolTipText = "Move X negative".Localize(); xButtons.AddChild(xMinusControl); // spacer xButtons.AddChild(new GuiWidget(xMinusControl.Width + buttonSeparationDistance * 2, 1) { VAnchor = VAnchor.Center, BackgroundColor = colors.XColor }); xPlusControl = theme.CreateMoveButton(printer, "X+", PrinterAxis.X, printer.Settings.XSpeed()); xPlusControl.ToolTipText = "Move X positive".Localize(); xButtons.AddChild(xPlusControl); var yButtons = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Fit | HAnchor.Center, VAnchor = VAnchor.Fit | VAnchor.Center }; xyGrid.AddChild(yButtons); yPlusControl = theme.CreateMoveButton(printer, "Y+", PrinterAxis.Y, printer.Settings.YSpeed()); yPlusControl.ToolTipText = "Move Y positive".Localize(); yButtons.AddChild(yPlusControl); // spacer yButtons.AddChild(new GuiWidget(1, buttonSeparationDistance) { HAnchor = HAnchor.Center, BackgroundColor = colors.YColor }); yMinusControl = theme.CreateMoveButton(printer, "Y-", PrinterAxis.Y, printer.Settings.YSpeed()); yMinusControl.ToolTipText = "Move Y negative".Localize(); yButtons.AddChild(yMinusControl); return(xyGrid); }
// Use this for initialization void Start() { if (instance == null) { instance = this; } Button btn = this.GetComponent <Button> (); btn.onClick.AddListener(OnClick); }
private void RefPanel() { point1 = new MoveButton(TextPanel1.Location.X, TextPanel1.Location.Y); point2 = new MoveButton(TextPanel2.Location.X, TextPanel2.Location.Y); point3 = new MoveButton(TextPanel3.Location.X, TextPanel3.Location.Y); point4 = new MoveButton(TextPanel4.Location.X, TextPanel4.Location.Y); point5 = new MoveButton(TextPanel5.Location.X, TextPanel5.Location.Y); point6 = new MoveButton(TextPanel6.Location.X, TextPanel6.Location.Y); point7 = new MoveButton(TextPanel7.Location.X, TextPanel7.Location.Y); ref MoveButton refPoint1 = ref point1;
public void SetToggles(MoveButton moveButton) { if (moveButton.ToggleIsOn) { this.buttons.ForEach(t => { t.UnselecteButton(); t.ToggleIsOn = false; }); moveButton.SelectButton(); } else { moveButton.UnselecteButton(); } }
private GuiWidget CreateXYGridControl(XYZColors colors, double distanceBetweenControls, double buttonSeparationDistance) { GuiWidget xyGrid = new GuiWidget(); { FlowLayoutWidget xButtons = new FlowLayoutWidget(); { moveButtonFactory.Colors.Fill.Normal = XYZColors.xColor; xButtons.HAnchor |= Agg.UI.HAnchor.ParentCenter; xButtons.VAnchor |= Agg.UI.VAnchor.ParentCenter; xMinusControl = CreateMoveButton("X-", PrinterConnectionAndCommunication.Axis.X, MovementControls.XSpeed, false, moveButtonFactory); xMinusControl.ToolTipText = "Move X negative".Localize(); xButtons.AddChild(xMinusControl); GuiWidget spacer = new GuiWidget(xMinusControl.Width + buttonSeparationDistance * 2, 2); spacer.VAnchor = Agg.UI.VAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.xColor; xButtons.AddChild(spacer); xPlusControl = CreateMoveButton("X+", PrinterConnectionAndCommunication.Axis.X, MovementControls.XSpeed, false, moveButtonFactory); xPlusControl.ToolTipText = "Move X positive".Localize(); xButtons.AddChild(xPlusControl); } xyGrid.AddChild(xButtons); FlowLayoutWidget yButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); { moveButtonFactory.Colors.Fill.Normal = XYZColors.yColor; yButtons.HAnchor |= Agg.UI.HAnchor.ParentCenter; yButtons.VAnchor |= Agg.UI.VAnchor.ParentCenter; yPlusControl = CreateMoveButton("Y+", PrinterConnectionAndCommunication.Axis.Y, MovementControls.YSpeed, false, moveButtonFactory); yPlusControl.ToolTipText = "Move Y positive".Localize(); yButtons.AddChild(yPlusControl); GuiWidget spacer = new GuiWidget(2, buttonSeparationDistance); spacer.HAnchor = Agg.UI.HAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.yColor; yButtons.AddChild(spacer); yMinusControl = CreateMoveButton("Y-", PrinterConnectionAndCommunication.Axis.Y, MovementControls.YSpeed, false, moveButtonFactory); yMinusControl.ToolTipText = "Move Y negative".Localize(); yButtons.AddChild(yMinusControl); } xyGrid.AddChild(yButtons); } xyGrid.HAnchor = HAnchor.FitToChildren; xyGrid.VAnchor = VAnchor.FitToChildren; xyGrid.VAnchor = Agg.UI.VAnchor.ParentBottom; xyGrid.Margin = new BorderDouble(0, 5, distanceBetweenControls, 5); return(xyGrid); }
private void moveAxis_Click(object sender, EventArgs mouseEvent) { MoveButton moveButton = (MoveButton)sender; if (PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.Printing) { PrinterConnectionAndCommunication.Instance.AddToBabyStepOffset(this.moveAxis, this.MoveAmount); } else { PrinterConnectionAndCommunication.Instance.MoveRelative(this.moveAxis, this.MoveAmount, movementFeedRate); } }
void Start() { Button click1 = TalkButton1.GetComponent <Button>(); Button click2 = TalkButton2.GetComponent <Button>(); Button click3 = TalkButton3.GetComponent <Button>(); Button click4 = MoveButton.GetComponent <Button>(); click1.onClick.AddListener(envisiable); click1.onClick.AddListener(goodChoice); click2.onClick.AddListener(envisiable); click2.onClick.AddListener(badChoice); click3.onClick.AddListener(envisiable); click3.onClick.AddListener(restChoice); click4.onClick.AddListener(envisiable); Talk(); }
private GuiWidget CreateXYGridControl(XYZColors colors, double distanceBetweenControls, double buttonSeparationDistance) { GuiWidget xyGrid = new GuiWidget(); { FlowLayoutWidget xButtons = new FlowLayoutWidget(); { moveButtonFactory.normalFillColor = XYZColors.xColor; xButtons.HAnchor |= Agg.UI.HAnchor.ParentCenter; xButtons.VAnchor |= Agg.UI.VAnchor.ParentCenter; xMinusControl = moveButtonFactory.Generate("X-", PrinterCommunication.Axis.X, ManualPrinterControls.XSpeed); xButtons.AddChild(xMinusControl); GuiWidget spacer = new GuiWidget(xMinusControl.Width + buttonSeparationDistance * 2, 2); spacer.VAnchor = Agg.UI.VAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.xColor; xButtons.AddChild(spacer); xPlusControl = moveButtonFactory.Generate("X+", PrinterCommunication.Axis.X, ManualPrinterControls.XSpeed); xButtons.AddChild(xPlusControl); } xyGrid.AddChild(xButtons); FlowLayoutWidget yButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); { moveButtonFactory.normalFillColor = XYZColors.yColor; yButtons.HAnchor |= Agg.UI.HAnchor.ParentCenter; yButtons.VAnchor |= Agg.UI.VAnchor.ParentCenter; yPlusControl = moveButtonFactory.Generate("Y+", PrinterCommunication.Axis.Y, ManualPrinterControls.YSpeed); yButtons.AddChild(yPlusControl); GuiWidget spacer = new GuiWidget(2, buttonSeparationDistance); spacer.HAnchor = Agg.UI.HAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.yColor; yButtons.AddChild(spacer); yMinusControl = moveButtonFactory.Generate("Y-", PrinterCommunication.Axis.Y, ManualPrinterControls.YSpeed); yButtons.AddChild(yMinusControl); } xyGrid.AddChild(yButtons); } xyGrid.HAnchor = HAnchor.FitToChildren; xyGrid.VAnchor = VAnchor.FitToChildren; xyGrid.VAnchor = Agg.UI.VAnchor.ParentBottom; xyGrid.Margin = new BorderDouble(0, 5, distanceBetweenControls, 5); return(xyGrid); }
///------------------------------------------------------------------------------------------------- /// \fn public override void ShowAsNotSelected() /// /// \brief Shows as not selected ///------------------------------------------------------------------------------------------------- public override void ShowAsNotSelected() { base.ShowAsNotSelected(); try { adjustButton.Visible = moveButton.Visible = false; adjustButton.Dispose(); moveButton.Dispose(); } catch (NullReferenceException) { ; } finally { adjustButton = null; moveButton = null; } }
///------------------------------------------------------------------------------------------------- /// \fn public override void ShowAsSelected() /// /// \brief Shows as selected ///------------------------------------------------------------------------------------------------- public override void ShowAsSelected() { base.ShowAsSelected(); if (adjustButtonA == null) { adjustButtonA = new AdjustButton(MainWin.GetInstance().MainView(), this, new Point(a.X - 3, a.Y - 3), Cursors.SizeNS); adjustButtonA.MouseDown += ResizeButtonA_MouseDown; adjustButtonA.MouseUp += ResizeButtonA_MouseUp; adjustButtonA.MouseMove += ResizeButtonA_MouseMove; } if (adjustButtonB == null) { adjustButtonB = new AdjustButton(MainWin.GetInstance().MainView(), this, new Point(b.X - 3, b.Y - 3), Cursors.SizeNS); adjustButtonB.MouseDown += ResizeButtonA_MouseDown; adjustButtonB.MouseUp += ResizeButtonA_MouseUp; adjustButtonB.MouseMove += ResizeButtonA_MouseMove; } if (moveButton == null) { moveButton = new MoveButton(MainWin.GetInstance().MainView(), this, new Point(a.X / 2 + b.X / 2, a.Y / 2 + b.Y / 2), Cursors.SizeAll); moveButton.MouseDown += MoveButton_MouseDown; moveButton.MouseMove += MoveButton_MouseMove; moveButton.MouseUp += MoveButton_MouseUp; } adjustButtonA.SetBindingPoints( new Ref <Point>(() => a, z => { a = z; }) ); adjustButtonB.SetBindingPoints( new Ref <Point>(() => b, z => { b = z; }) ); moveButton.SetBindingPoints( new Ref <Point>(() => a, z => { a = z; }), new Ref <Point>(() => b, z => { b = z; }), // only lines'point moving is not enough. We need move its buttons. new Ref <Point>(() => adjustButtonA.Location, z => { adjustButtonA.Location = z; }), new Ref <Point>(() => adjustButtonB.Location, z => { adjustButtonB.Location = z; }) ); Log.LogText("Select Line"); }
public void Wait(float time) { dead = false; if (freeButtonMovePosition < 5) { Debug.Log("dodano czekanie"); GameObject newButton = Instantiate(WaitChosenCard) as GameObject; newButton.GetComponent <RectTransform>().localPosition = new Vector3(posX[freeButtonMovePosition], posY, 0); newButton.transform.Find("ChosenCardWait/TimeValue").gameObject.GetComponent <TextMeshProUGUI>().text = ((int)time).ToString(); newButton.transform.SetParent(Canvas.transform, false); Button copy = newButton.transform.Find("CopyButton").gameObject.GetComponent <Button>(); copy.onClick.AddListener(() => CopyWaitCard(newButton)); Button siema = newButton.transform.Find("Button").gameObject.GetComponent <Button>(); siema.onClick.AddListener(() => RearangeChosenMovesButtons(newButton)); Button card = newButton.transform.Find("ChosenCardWait").gameObject.GetComponent <Button>(); card.onClick.AddListener(() => WaitChange(newButton)); MoveButton x = new MoveButton(freeButtonMovePosition, newButton, "wait", null, 0, 0, (int)time, 0, 0); chosenMovesButtons.Add(x); freeButtonMovePosition++; } }
public void Move() { if (HandRotatable) { HandRotatable.IsEnabled = false; } if (HandDraggable) { var newVal = !HandDraggable.IsEnabled; // Set button state manually if (MoveButton) { MoveButton.CanActive = true; MoveButton.SetState(newVal); } HandDraggable.IsEnabled = newVal; } }
void Start() { GameManager.Instance.Restart(); currentLife = GameManager.Instance.MaxLife; SetUiMenuName(lifeField); score = 0; SetUiMenuName(scoreField); SetScoreField(scoreField, score); highScore = PlayerPrefs.GetInt("HighScore", 0); SetUiMenuName(highScoreField); SetScoreField(highScoreField, highScore); GetUiTransformWithControlMode(out Dictionary <Direction, Vector2> position, out Dictionary <Direction, Vector2> anchor, out RectTransform screen); gameScreen.rectTransform.offsetMin = screen.offsetMin; gameScreen.rectTransform.offsetMax = screen.offsetMax; for (int i = 0; i < moveButtons.Length; i++) { MoveButton buttonPair = moveButtons[i]; RectTransform rt = buttonPair.button.GetComponent <RectTransform>(); rt.anchorMin = anchor[buttonPair.direction]; rt.anchorMax = anchor[buttonPair.direction]; rt.anchoredPosition = position[buttonPair.direction]; buttonPair.button.onClick.AddListener(() => { if (pacman.isActiveAndEnabled) { pacman.SetDirection(buttonPair.direction); } }); } StartNewGame(); }
public static FlowLayoutWidget CreateZButtons(RGBA_Bytes color, double buttonSeparationDistance, out MoveButton zPlusControl, out MoveButton zMinusControl) { FlowLayoutWidget zButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); { MoveButtonFactory moveButtonFactory = new MoveButtonFactory(); moveButtonFactory.normalFillColor = color; zPlusControl = moveButtonFactory.Generate("Z+", PrinterConnectionAndCommunication.Axis.Z, MovementControls.ZSpeed); zButtons.AddChild(zPlusControl); GuiWidget spacer = new GuiWidget(2, buttonSeparationDistance); spacer.HAnchor = Agg.UI.HAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.zColor; zButtons.AddChild(spacer); zMinusControl = moveButtonFactory.Generate("Z-", PrinterConnectionAndCommunication.Axis.Z, MovementControls.ZSpeed); zButtons.AddChild(zMinusControl); } zButtons.Margin = new BorderDouble(0, 5); return(zButtons); }
public void Jump(float power, float angle) { dead = false; if (freeButtonMovePosition < 5) { Debug.Log("Dodano skok"); GameObject newButton = Instantiate(JumpChosenCard) as GameObject; newButton.GetComponent <RectTransform>().localPosition = new Vector3(posX[freeButtonMovePosition], posY, 0); newButton.transform.Find("ChosenCardJump/PowerValue").gameObject.GetComponent <TextMeshProUGUI>().text = ((int)power).ToString(); newButton.transform.Find("ChosenCardJump/AngleValue").gameObject.GetComponent <TextMeshProUGUI>().text = ((int)angle).ToString(); newButton.transform.SetParent(Canvas.transform, false); Button copy = newButton.transform.Find("CopyButton").gameObject.GetComponent <Button>(); copy.onClick.AddListener(() => CopyJumpCard(newButton)); Button delete = newButton.transform.Find("Button").gameObject.GetComponent <Button>(); delete.onClick.AddListener(() => RearangeChosenMovesButtons(newButton)); Button card = newButton.transform.Find("ChosenCardJump").gameObject.GetComponent <Button>(); card.onClick.AddListener(() => JumpChange(newButton)); MoveButton x = new MoveButton(freeButtonMovePosition, newButton, "jump", null, 0, 0, 0, (int)power, (int)angle); chosenMovesButtons.Add(x); freeButtonMovePosition++; } }
public static FlowLayoutWidget CreateZButtons(RGBA_Bytes color, double buttonSeparationDistance, out MoveButton zPlusControl, out MoveButton zMinusControl) { FlowLayoutWidget zButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); { MoveButtonFactory moveButtonFactory = new MoveButtonFactory(); moveButtonFactory.normalFillColor = color; zPlusControl = moveButtonFactory.Generate("Z+", PrinterCommunication.Axis.Z, ManualPrinterControls.ZSpeed); zButtons.AddChild(zPlusControl); GuiWidget spacer = new GuiWidget(2, buttonSeparationDistance); spacer.HAnchor = Agg.UI.HAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.zColor; zButtons.AddChild(spacer); zMinusControl = moveButtonFactory.Generate("Z-", PrinterCommunication.Axis.Z, ManualPrinterControls.ZSpeed); zButtons.AddChild(zMinusControl); } zButtons.Margin = new BorderDouble(0, 5); return zButtons; }
// Update is called once per frame void Update() { if (PSMoveExample.curButton != null) { if (PSMoveExample.curButton == MoveButton.Square && prevButon != PSMoveExample.curButton) { prevButon = PSMoveExample.curButton; //Debug.Log ("Trigger Square"); onPSMoveButtonClick(); }else if (PSMoveExample.curButton == MoveButton.Triangle && prevButon != PSMoveExample.curButton) { prevButon = PSMoveExample.curButton; //Debug.Log ("Trigger Circle"); onPSMoveButtonClick(); } else if (PSMoveExample.curButton == MoveButton.Cross && prevButon != PSMoveExample.curButton) { prevButon = PSMoveExample.curButton; //Debug.Log ("Trigger Cross"); onPSMoveButtonClick(); } else if (PSMoveExample.curButton == MoveButton.Circle && prevButon != PSMoveExample.curButton) { prevButon = PSMoveExample.curButton; //Debug.Log ("Trigger Circle"); onPSMoveButtonClick(); } else if (PSMoveExample.curButton == MoveButton.T && prevButon != PSMoveExample.curButton) { prevButon = PSMoveExample.curButton; onPSMoveTriggerClick(); } else if (PSMoveExample.curButton == MoveButton.None) { prevButon = MoveButton.None; } } UpdateSeaMonsterStart (); }
public Boolean btnOnPress(MoveButton BTN_CODE) { if (((byte)BTN_CODE & pressedButtons) != 0) return true; return false; }
public Boolean btnOnRelease(MoveButton BTN_CODE) { if (((byte)BTN_CODE & releasedButtons) != 0) return true; return false; }
public Boolean btnReleased(MoveButton BTN_CODE) { if (((byte)BTN_CODE & currButtons) == 0) return true; return false; }
void OnGUI() { if(!PSMoveInput.IsConnected) { /* GUI.Label(new Rect(20, 45, 30, 35), "IP:"); ipAddress = GUI.TextField(new Rect(60, 45, 120, 25), ipAddress); GUI.Label(new Rect(190, 45, 30, 35), "port:"); port = GUI.TextField(new Rect(230, 45, 50, 25), port); if(GUI.Button(new Rect(300, 40, 100, 35), "Connect")) { PSMoveInput.Connect(ipAddress, int.Parse(port)); }*/ } else { /* if(GUI.Button(new Rect(20, 40, 100, 35), "Disconnect")) { PSMoveInput.Disconnect(); Reset(); } GUI.Label(new Rect(10, 10, 150, 100), "PS Move count : " + PSMoveInput.MoveCount); GUI.Label(new Rect(140, 10, 150, 100), "PS Nav count : " + PSMoveInput.NavCount); //camera stream on/off if(GUI.Button(new Rect(5, 80, 130, 35), cameraStr)) { if(cameraStr == "Camera Switch On") { PSMoveInput.CameraFrameResume(); cameraStr = "Camera Switch Off"; } else { PSMoveInput.CameraFramePause(); cameraStr = "Camera Switch On"; } } //color and rumble for move number 0 if(PSMoveInput.MoveControllers[0].Connected) { //Set Color and Track GUI.Label(new Rect(300, 50, 200,20), "R,G,B are floats that fall in 0 ~ 1"); GUI.Label(new Rect(260, 20, 20, 20), "R"); rStr = GUI.TextField(new Rect(280, 20, 60, 20), rStr); GUI.Label(new Rect(350, 20, 20, 20), "G"); gStr = GUI.TextField(new Rect(370, 20, 60, 20), gStr); GUI.Label(new Rect(440, 20, 20, 20), "B"); bStr = GUI.TextField(new Rect(460, 20, 60, 20), bStr); if(GUI.Button(new Rect(550, 30, 160, 35), "SetColorAndTrack")) { try { float r = float.Parse(rStr); float g = float.Parse(gStr); float b = float.Parse(bStr); PSMoveInput.MoveControllers[0].SetColorAndTrack(new Color(r,g,b)); } catch(Exception e) { Debug.Log("input problem: " + e.Message); } } //Rumble rumbleStr = GUI.TextField(new Rect(805, 20, 40, 20), rumbleStr); GUI.Label(new Rect(800, 50, 200,20), "0 ~ 19"); if(GUI.Button(new Rect(870, 30, 100, 35), "Rumble")) { try { int rumbleValue = int.Parse(rumbleStr); PSMoveInput.MoveControllers[0].SetRumble(rumbleValue); } catch(Exception e) { Debug.Log("input problem: " + e.Message); } } } */ //move controller information for(int i=0; i<PSMoveInput.MAX_MOVE_NUM; i++) { MoveController moveController = PSMoveInput.MoveControllers[i]; //moveController.SetColor(Color.blue); if(moveController.Connected) { MoveData moveData = moveController.Data; /* string display = "PS Move #" + i + "\nPosition:\t\t"+moveData.Position + "\nVelocity:\t\t"+moveData.Velocity + "\nAcceleration:\t\t"+moveData.Acceleration + "\nOrientation:\t\t"+moveData.Orientation + "\nAngular Velocity:\t\t"+moveData.AngularVelocity + "\nAngular Acceleration:\t\t"+moveData.AngularAcceleration + "\nHandle Position:\t\t"+moveData.HandlePosition + "\nHandle Velocity:\t\t"+moveData.HandleVelocity + "\nHandle Acceleration:\t\t"+moveData.HandleAcceleration + "\n" + "\nTrigger Value:\t\t" + moveData.ValueT + "\nButtons 1:\t\t" + moveData.Buttons + "\nSphere Color:\t\t" + moveData.SphereColor + "\nIs Tracking:\t\t" + moveData.IsTracking + "\nTracking Hue:\t\t" + moveData.TrackingHue; */ string display = "PS Move #" + i + "\nPosition:\t\t"+moveData.Position; if(i == 1){ curButton = moveData.Buttons; } //GUI.Label(new Rect( 10 + 650 * (i/2), 120+310*(i%2), 300, 400), display); } } /* for(int j = 0; j < PSMoveInput.MAX_NAV_NUM; j++) { NavController navController = PSMoveInput.NavControllers[j]; if(navController.Connected) { NavData navData = navController.Data; string navDisplay = "PS Nav #" + j + "\nAnalog :\t\t" + navData.ValueAnalog + "\nL2 Value:\t\t" + navData.ValueL2 + "\nButtons:\t\t" + navData.Buttons; GUI.Label(new Rect(400, 100 + 95 * j, 150, 95), navDisplay); } }*/ } }
private FlowLayoutWidget CreateEButtons(double buttonSeparationDistance) { FlowLayoutWidget eButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); { FlowLayoutWidget eMinusButtonAndText = new FlowLayoutWidget(); eMinusControl = moveButtonFactory.Generate("E-", PrinterCommunication.Axis.E, ManualPrinterControls.EFeedRate(0)); eMinusControl.Margin = new BorderDouble(0, 0, 5, 0); eMinusButtonAndText.AddChild(eMinusControl); TextWidget eMinusControlLabel = new TextWidget(new LocalizedString("Retract").Translated); eMinusControlLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; eMinusControlLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; eMinusButtonAndText.AddChild(eMinusControlLabel); eMinusButtonAndText.HAnchor = Agg.UI.HAnchor.ParentLeft; eButtons.AddChild(eMinusButtonAndText); eMinusButtonAndText.HAnchor = HAnchor.FitToChildren; eMinusButtonAndText.VAnchor = VAnchor.FitToChildren; GuiWidget eSpacer = new GuiWidget(2, buttonSeparationDistance); eSpacer.HAnchor = Agg.UI.HAnchor.ParentLeft; eSpacer.Margin = new BorderDouble(eMinusControl.Width / 2, 0, 0, 0); eSpacer.BackgroundColor = XYZColors.eColor; eButtons.AddChild(eSpacer); FlowLayoutWidget ePlusButtonAndText = new FlowLayoutWidget(); ePlusControl = moveButtonFactory.Generate("E+", PrinterCommunication.Axis.E, ManualPrinterControls.EFeedRate(0)); ePlusControl.Margin = new BorderDouble(0, 0, 5, 0); ePlusButtonAndText.AddChild(ePlusControl); TextWidget ePlusControlLabel = new TextWidget(new LocalizedString("Extrude").Translated); ePlusControlLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; ePlusControlLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; ePlusButtonAndText.AddChild(ePlusControlLabel); ePlusButtonAndText.HAnchor = Agg.UI.HAnchor.ParentLeft; eButtons.AddChild(ePlusButtonAndText); ePlusButtonAndText.HAnchor = HAnchor.FitToChildren; ePlusButtonAndText.VAnchor = VAnchor.FitToChildren; } eButtons.AddChild(new GuiWidget(10, 6)); // add in some movement radio buttons FlowLayoutWidget setMoveDistanceControl = new FlowLayoutWidget(); TextWidget buttonsLabel = new TextWidget("Distance:", textColor: RGBA_Bytes.White); buttonsLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; //setMoveDistanceControl.AddChild(buttonsLabel); { TextImageButtonFactory buttonFactory = new TextImageButtonFactory(); buttonFactory.FixedHeight = 20; buttonFactory.FixedWidth = 30; buttonFactory.fontSize = 10; buttonFactory.Margin = new BorderDouble(0); FlowLayoutWidget moveRadioButtons = new FlowLayoutWidget(); RadioButton oneButton = buttonFactory.GenerateRadioButton("1"); oneButton.VAnchor = Agg.UI.VAnchor.ParentCenter; oneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetEMoveAmount(1); }; moveRadioButtons.AddChild(oneButton); RadioButton tenButton = buttonFactory.GenerateRadioButton("10"); tenButton.VAnchor = Agg.UI.VAnchor.ParentCenter; tenButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetEMoveAmount(10); }; moveRadioButtons.AddChild(tenButton); RadioButton oneHundredButton = buttonFactory.GenerateRadioButton("100"); oneHundredButton.VAnchor = Agg.UI.VAnchor.ParentCenter; oneHundredButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetEMoveAmount(100); }; moveRadioButtons.AddChild(oneHundredButton); tenButton.Checked = true; moveRadioButtons.Margin = new BorderDouble(0,3); setMoveDistanceControl.AddChild(moveRadioButtons); } TextWidget mmLabel = new TextWidget("mm", textColor: RGBA_Bytes.White, pointSize:10); mmLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; setMoveDistanceControl.AddChild(mmLabel); setMoveDistanceControl.HAnchor = Agg.UI.HAnchor.ParentLeft; eButtons.AddChild(setMoveDistanceControl); eButtons.HAnchor = HAnchor.Max_FitToChildren_ParentWidth; eButtons.VAnchor = VAnchor.FitToChildren | VAnchor.ParentBottom; return eButtons; }
private bool GetButtonsAny(MoveButton state, MoveButton requestButtons) { return (state & requestButtons) > 0; }
private bool GetButtons(MoveButton state, MoveButton requestButtons) { return (state & requestButtons) == requestButtons; }
public bool GetButtonsUp(MoveButton requestButtons) { return GetButtons(PrevButtons, requestButtons) && !GetButtons(Buttons, requestButtons); }
public bool GetButtonsDown(MoveButton requestButtons) { return !GetButtons(PrevButtons, requestButtons) && GetButtons(Buttons, requestButtons); }
public bool GetButtonsAny(MoveButton requestButtons) { return GetButtons(Buttons, requestButtons); }
private GuiWidget CreateXYGridControl(XYZColors colors, double distanceBetweenControls, double buttonSeparationDistance) { GuiWidget xyGrid = new GuiWidget(); { FlowLayoutWidget xButtons = new FlowLayoutWidget(); { moveButtonFactory.normalFillColor = XYZColors.xColor; xButtons.HAnchor |= Agg.UI.HAnchor.ParentCenter; xButtons.VAnchor |= Agg.UI.VAnchor.ParentCenter; xMinusControl = moveButtonFactory.Generate("X-", PrinterCommunication.Axis.X, ManualPrinterControls.XSpeed); xButtons.AddChild(xMinusControl); GuiWidget spacer = new GuiWidget(xMinusControl.Width + buttonSeparationDistance * 2, 2); spacer.VAnchor = Agg.UI.VAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.xColor; xButtons.AddChild(spacer); xPlusControl = moveButtonFactory.Generate("X+", PrinterCommunication.Axis.X, ManualPrinterControls.XSpeed); xButtons.AddChild(xPlusControl); } xyGrid.AddChild(xButtons); FlowLayoutWidget yButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); { moveButtonFactory.normalFillColor = XYZColors.yColor; yButtons.HAnchor |= Agg.UI.HAnchor.ParentCenter; yButtons.VAnchor |= Agg.UI.VAnchor.ParentCenter; yPlusControl = moveButtonFactory.Generate("Y+", PrinterCommunication.Axis.Y, ManualPrinterControls.YSpeed); yButtons.AddChild(yPlusControl); GuiWidget spacer = new GuiWidget(2, buttonSeparationDistance); spacer.HAnchor = Agg.UI.HAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.yColor; yButtons.AddChild(spacer); yMinusControl = moveButtonFactory.Generate("Y-", PrinterCommunication.Axis.Y, ManualPrinterControls.YSpeed); yButtons.AddChild(yMinusControl); } xyGrid.AddChild(yButtons); } xyGrid.HAnchor = HAnchor.FitToChildren; xyGrid.VAnchor = VAnchor.FitToChildren; xyGrid.VAnchor = Agg.UI.VAnchor.ParentBottom; xyGrid.Margin = new BorderDouble(0, 5, distanceBetweenControls, 5); return xyGrid; }
public MoveButton Generate(string label, PrinterCommunication.Axis axis, double movementFeedRate) { //Create button based on view container widget ButtonViewStates buttonViewWidget = getButtonView(label); MoveButton textImageButton = new MoveButton(0, 0, buttonViewWidget, axis, movementFeedRate); textImageButton.Margin = new BorderDouble(0); textImageButton.Padding = new BorderDouble(0); return textImageButton; }