protected override void DisassembleComponent() { VirtualButton virtualButton = GetComponent <VirtualButton>(); if (virtualButton != null) { virtualButton.OnButtonEnter -= startAction; virtualButton.OnButtonExit -= endAction; } RayCastButton rcButton = GetComponent <RayCastButton>(); if (rcButton != null) { rcButton.OnButtonEnter -= startAction; rcButton.OnButtonExit -= endAction; } TouchButton touchButton = GetComponent <TouchButton>(); if (touchButton != null) { touchButton.OnButtonEnter -= startAction; touchButton.OnButtonExit -= endAction; } }
protected override void AssembleComponent() { VirtualButton virtualButton = GetComponent <VirtualButton>(); if (virtualButton != null) { virtualButton.OnButtonEnter += startAction; virtualButton.OnButtonExit += endAction; } RayCastButton rcButton = GetComponent <RayCastButton>(); if (rcButton != null) { rcButton.OnButtonEnter += startAction; rcButton.OnButtonExit += endAction; } TouchButton touchButton = GetComponent <TouchButton>(); if (touchButton != null) { touchButton.OnButtonEnter += startAction; touchButton.OnButtonExit += endAction; } if (State != 2) { State = 0; } }
public void show() { Canvas canvas = new Canvas(); this.MainWindow.Content = canvas; Image backgroundImage = new Image { Name = "background", Source = new BitmapImage(new Uri("C:/tempConcours/newGameBackground.png", UriKind.Absolute)), }; backgroundImage.RenderTransform = MainScaleTransform; canvas.Children.Add(backgroundImage); Canvas.SetLeft(backgroundImage, 0); Canvas.SetTop(backgroundImage, 0); Label teamNameLabel = new Label { Name = "teamNameLabel", FontSize = 60, Content = "Nom de l'équipe" }; canvas.Children.Add(teamNameLabel); Canvas.SetTop(teamNameLabel, 650); Canvas.SetRight(teamNameLabel, 800); this.teamNameTextBox = new UbiTextBox { Name = "teamNameTextBox", Text = "nom", FontSize = 40, Width = 500, Height = 70 }; canvas.Children.Add(teamNameTextBox); Canvas.SetTop(teamNameTextBox, 670); Canvas.SetRight(teamNameTextBox, 250); TouchButton startButton = new TouchButton { Content = "Lancer le jeu", Width = 200, Height = 69 }; startButton.Background = Brushes.YellowGreen; startButton.ButtonTap += startButton_Tap; canvas.Children.Add(startButton); Canvas.SetTop(startButton, 661); Canvas.SetRight(startButton, 50); //this.startButton_Tap(null, null); }
protected override void AssembleComponent() { VirtualButton virtualButton = GetComponent <VirtualButton>(); if (virtualButton != null) { virtualButton.OnButtonPress += pressAction; virtualButton.OnButtonUnpress += unpressAction; } RayCastButton rcButton = GetComponent <RayCastButton>(); if (rcButton != null) { rcButton.OnButtonPress += pressAction; rcButton.OnButtonUnpress += unpressAction; } TouchButton touchButton = GetComponent <TouchButton>(); if (touchButton != null) { touchButton.OnButtonPress += pressAction; touchButton.OnButtonUnpress += unpressAction; } if (State != 2) { State = 0; } }
/// <summary> /// Make a linked button. If a prim linked to the given root prim is called name then touching it will trigger the button. /// </summary> /// <param name="name">The name of the button.</param> /// <param name="id">The root primitive of the link set. Any children of this primitive with name 'name' will be listened to as a button.</param> /// <returns>A button object that allows listeners to be attached to the button.</returns> public IButton MakeButton(string name, IPermissions permissions, params UUID[] ids) { IButton button = new TouchButton(this, name, permissions, ids); _logger.Info("Made button " + name + " with " + button.Prims.Count() + " primitives."); return(button); }
/// <summary> /// Make a button tied to a specific name. Any primitives with the given name and the following script embedded in them will trigger this button when touched. /// </summary> /// <param name="name">The name of the button.</param> /// <returns>A button object that allows listeners to be attached to the button.</returns> public IButton MakeButton(string name, IPermissions permissions) { IButton button = new TouchButton(this, name, permissions); _logger.Info("Made button " + name + " with " + button.Prims.ToArray().Length + " primitives."); return(button); }
protected virtual void Start() { VirtualButton virtualButton = GetComponent <VirtualButton>(); if (virtualButton != null) { virtualButton.OnButtonEnter += ButtonEnterBehavior; virtualButton.OnButtonExit += ButtonExitBehavior; } RayCastButton rcButton = GetComponent <RayCastButton>(); if (rcButton != null) { rcButton.OnButtonEnter += ButtonEnterBehavior; rcButton.OnButtonExit += ButtonExitBehavior; } TouchButton touchButton = GetComponent <TouchButton>(); if (touchButton != null) { touchButton.OnButtonEnter += ButtonEnterBehavior; touchButton.OnButtonExit += ButtonExitBehavior; } }
// ------------------- static public TouchButtonSpriteAnimator CreateButtonAnimator( TouchButton target, string nameSuffix, Sprite sprite, float scale, string undoLabel = null) { RectTransform subObj = CreateSubRectTr(target.transform, target.name + nameSuffix, scale); // Create Sprite animator... TouchButtonSpriteAnimator sprAnimator = subObj.gameObject.AddComponent <TouchButtonSpriteAnimator>(); sprAnimator.autoConnectToSource = true; sprAnimator.SetSourceControl(target); sprAnimator.SetStateSprite(TouchButtonSpriteAnimator.ControlState.Neutral, sprite); SetImagePreserveAspectRatio(subObj.gameObject, true); if (undoLabel != null) { Undo.RegisterCreatedObjectUndo(subObj.gameObject, undoLabel); } return(sprAnimator); }
void Start() { touchButton = obj_touchbutton.GetComponent <TouchButton> (); smb = obj_smb.GetComponent <SideMenuBehavior> (); string_infotext = " Agge är fan king"; string_statstext = "tiotusentvåhundrafyra"; }
// Update is called once per frame void Update() { if (TouchButton.IsPressing()) { canMove = true; anim.SetBool("Run", true); } else { canMove = false; anim.SetBool("Run", false); } if (canMove) { if (this.gameObject == GameController.instance.armyList[0].gameObject) { startMove = true; } if (startMove) { localPlayerZ += transform.position.z; transform.position = new Vector3(transform.position.x, transform.position.y, (transform.position.z) + runSpeed * 0.025f * Time.deltaTime); } } TurnThePlayer(); }
// Use this for initialization void Start() { tbu = obj_tbu.GetComponent <TouchButtonRight> (); tbd = obj_tbd.GetComponent <TouchButton> (); cMovement = obj_camera.GetComponent <CameraMovment> (); ridigbody2d = gameObject.GetComponent <Rigidbody2D> (); }
private void OnClicked(TouchButton btn) { if (!m_bInited) return; Debug.Log ("Button ID:"+btn.ID); MenuManager.Instance.ShowMenu (btn.ID); TouchButtonManager.Instance.Hide (); }
private void register(TouchButton input) { if (TouchButtons.ContainsKey(input.ButtonName)) { Debug.LogWarning("Trying to register multiple touch inputs for button '" + input.ButtonName + "'"); return; } TouchButtons.Add(input.ButtonName, input); }
internal bool RegisterLinkButton(IObject prim, TouchButton button) { if (!prim.Root.GlobalID.Equals(prim.GlobalID)) { _linkButtons[prim.LocalID] = button; return(true); } return(false); }
/// <summary> /// Move positions to preconfigured positions /// </summary> void MoveButtonsToPositions(Vector4 vThrottle, Vector4 vBrake, Vector4 vSteerLeft, Vector4 vSteerRight, Vector4 vSteerWheel, Vector4 vShiftUp, Vector4 vShiftDown, Vector4 vMisc1, Vector4 vMisc2) { if (Throttle != null) { TouchButton tbThrottle = Throttle as TouchButton; tbThrottle.transform.position = FlipPosition(vThrottle); } if (Brake != null) { Brake.transform.position = FlipPosition(vBrake); } if (SteerLeft != null) { SteerLeft.transform.position = FlipPosition(vSteerLeft); } if (FlipPositions && SteerLeft != null) { SteerLeft.transform.position = FlipPosition(vSteerRight); //fix swap position } if (SteerRight != null) { SteerRight.transform.position = FlipPosition(vSteerRight); } if (FlipPositions && SteerRight != null) { SteerRight.transform.position = FlipPosition(vSteerLeft); //fix swap position } if (Wheel != null) { Wheel.transform.position = FlipPosition(vSteerWheel); } if (ShiftUp != null) { ShiftUp.transform.position = FlipPosition(vShiftUp); } if (FlipPositions && ShiftUp != null) { ShiftUp.transform.position = FlipPosition(vShiftDown); } if (ShiftDown != null) { ShiftDown.transform.position = FlipPosition(vShiftDown); } if (FlipPositions && ShiftDown != null) { ShiftDown.transform.position = FlipPosition(vShiftUp); } if (Misc1Button != null) { Misc1Button.transform.position = FlipPosition(vMisc1); } if (Misc2Button != null) { Misc2Button.transform.position = FlipPosition(vMisc2); } }
public AlarmWindow(params object[] options) : base() { sceneTitle = "Current Alarms"; var acknowledgeButton = new TouchButton(); acknowledgeButton.SetSizeRequest(100, 60); acknowledgeButton.text = "Acknowledge Alarms"; acknowledgeButton.buttonColor = "compl"; acknowledgeButton.ButtonReleaseEvent += (o, args) => { Alarm.Acknowledge(); Update(); }; tv = new TextView(); tv.ModifyFont(Pango.FontDescription.FromString("Sans 11")); tv.ModifyBase(StateType.Normal, TouchColor.NewGtkColor("grey4")); tv.CanFocus = false; var sw = new ScrolledWindow(); sw.SetSizeRequest(720, 340); sw.VScrollbar.WidthRequest = 30; sw.HScrollbar.HeightRequest = 30; sw.Add(tv); Put(sw, 65, 60); sw.Show(); tv.Show(); if (options.Length >= 2) { var lastScreen = options[1] as string; if (lastScreen != null) { var b = new TouchButton(); b.SetSizeRequest(100, 60); b.text = "Back\n" + lastScreen; b.ButtonReleaseEvent += (o, args) => { AquaPicGui.AquaPicUserInterface.ChangeScreens(lastScreen, Toplevel, AquaPicGui.AquaPicUserInterface.currentScene); }; Put(b, 575, 405); b.Show(); Put(acknowledgeButton, 685, 405); } else { Put(acknowledgeButton, 575, 405); } } acknowledgeButton.Show(); Update(); Show(); }
public ButtonWidget(string name, int row, int column) : base("Button", name, row, column) { button = new TouchButton(); button.SetSizeRequest(100, 82); button.text = name; button.buttonColor = Bit.Instance.Check(button.text) ? "pri" : "seca"; button.ButtonReleaseEvent += OnButtonRelease; Put(button, 0, 0); button.Show(); }
void Awake() { button = gameObject.AddComponent <TouchButton>(); // Event Subscribtion: button.onEnter += OnEnter; button.onTap += OnTap; button.onHolding += OnHolding; button.onRelease += OnRelease; button.onClick += OnClick; }
public AnalogOutputWindow(params object[] options) : base() { card = Driver.AnalogOutput.firstCard; if (card.IsNotEmpty()) { sceneTitle = "Analog Output Cards"; } else { sceneTitle = "No Analog Output Cards Added"; } displays = new AnalogChannelDisplay[4]; for (int i = 0; i < 4; ++i) { displays[i] = new AnalogChannelDisplay(); displays[i].divisionSteps = 1000; displays[i].typeLabel.Visible = true; displays[i].ForceButtonReleaseEvent += OnForceRelease; displays[i].ValueChangedEvent += OnValueChanged; Put(displays[i], 70, 90 + (i * 75)); if (card.IsNotEmpty()) { displays[i].Show(); } else { displays[i].Visible = false; } } settingsButton = new TouchButton(); settingsButton.SetSizeRequest(30, 30); settingsButton.buttonColor = "grey4"; settingsButton.text = Convert.ToChar(0x2699).ToString(); settingsButton.ButtonReleaseEvent += OnGlobalSettingsRelease; Put(settingsButton, 755, 35); settingsButton.Show(); combo = new TouchComboBox(Driver.AnalogOutput.GetAllCardNames()); combo.comboList.Add("New card..."); if (card.IsNotEmpty()) { combo.activeText = card; } combo.WidthRequest = 200; combo.ComboChangedEvent += OnComboChanged; Put(combo, 550, 35); combo.Show(); GetCardData(); Show(); }
public AnalogChannelDisplay() { SetSizeRequest(710, 50); label = new TouchLabel(); label.WidthRequest = 490; Put(label, 5, 0); label.Show(); textBox = new TouchTextBox(); textBox.WidthRequest = 175; textBox.TextChangedEvent += (sender, args) => { try { currentValue = Convert.ToSingle(args.text); ValueChanged(); } catch { ; } }; Put(textBox, 0, 20); textBox.Show(); progressBar = new TouchProgressBar(TouchOrientation.Horizontal); progressBar.WidthRequest = 425; progressBar.ProgressChangedEvent += (sender, args) => { currentValue = args.currentProgress * divisionSteps; ValueChanged(); }; Put(progressBar, 185, 20); progressBar.Show(); typeLabel = new TouchLabel(); typeLabel.Visible = false; typeLabel.WidthRequest = 200; typeLabel.textAlignment = TouchAlignment.Right; Put(typeLabel, 500, 0); forceButton = new TouchButton(); forceButton.SetSizeRequest(85, 30); forceButton.buttonColor = "grey4"; forceButton.text = "Force"; forceButton.ButtonReleaseEvent += OnForceReleased; Put(forceButton, 620, 20); forceButton.Show(); Show(); }
public SettingsWindow(params object[] options) : base() { sceneTitle = "Settings"; if (options.Length >= 1) { topWindow = options[0] as AquaPicGui; if (topWindow != null) { if (topWindow.IsTopLevel) { var b = new TouchButton(); b.SetSizeRequest(100, 60); b.text = "Unfullscreen"; b.ButtonReleaseEvent += (o, args) => { topWindow.ShowDecoration(); #if RPI_BUILD topWindow.Unfullscreen(); #endif }; Put(b, 685, 140); b.Show(); b = new TouchButton(); b.SetSizeRequest(100, 60); b.text = "Back"; b.ButtonReleaseEvent += (o, args) => AquaPicGui.AquaPicUserInterface.ChangeScreens("Home"); Put(b, 685, 210); b.Show(); } else { topWindow = null; } } } var btn = new TouchButton(); btn.SetSizeRequest(100, 60); btn.text = "Close"; btn.ButtonReleaseEvent += OnCloseButtonRelease; Put(btn, 685, 70); btn.Show(); Show(); }
/// <summary> /// Enable or disable buttons based the template config /// </summary> void EnableDisableButtons(bool bThrottle, bool bBreak, bool bSteerLeft, bool bSteerRight, bool bSteerWheel, bool bShiftUp, bool bShiftDown) { //if (Throttle != null) Throttle.gameObject.SetActiveRecursively(bThrottle); if (Throttle != null) { TouchButton tbThrottle = Throttle as TouchButton; tbThrottle.gameObject.SetActiveRecursively(bThrottle); } if (Brake != null) { TouchButton tbBrake = Brake as TouchButton; tbBrake.gameObject.SetActiveRecursively(bBreak); } if (SteerLeft != null) { TouchButton tbSteerLeft = SteerLeft as TouchButton; tbSteerLeft.gameObject.SetActiveRecursively(bSteerLeft); } if (SteerRight != null) { TouchButton tbSteerRight = SteerRight as TouchButton; tbSteerRight.gameObject.SetActiveRecursively(bSteerRight); } if (ShiftUp != null) { TouchButton tbShiftUp = ShiftUp as TouchButton; tbShiftUp.gameObject.SetActiveRecursively(bShiftUp); } if (ShiftDown != null) { TouchButton tbShiftDown = ShiftDown as TouchButton; tbShiftDown.gameObject.SetActiveRecursively(bShiftDown); } if (Wheel != null) { TouchWheel twWheel = Wheel as TouchWheel; twWheel.gameObject.SetActiveRecursively(bSteerWheel); } //if (Brake != null) Brake.gameObject.SetActiveRecursively(bBreak); //if (SteerLeft != null) SteerLeft.gameObject.SetActiveRecursively(bSteerLeft); //if (SteerRight != null) SteerRight.gameObject.SetActiveRecursively(bSteerRight); //if (Wheel != null) Wheel.gameObject.SetActiveRecursively(bSteerWheel); //if (ShiftUp != null) ShiftUp.gameObject.SetActiveRecursively(bShiftUp); //if (ShiftDown != null) ShiftDown.gameObject.SetActiveRecursively(bShiftDown); }
internal bool GetTouchButton(TouchButton touchButton) { switch (touchButton) { case TouchButton.A: return(touch.a); case TouchButton.B: return(touch.b); case TouchButton.Home: return(touch.home); case TouchButton.Menu: return(touch.menu); } return(false); }
public override void _Ready() { // Parent is a MarginContainer, next parent is VirtualControls parent = (VirtualControls)GetParent().GetParent(); defaultFont = SimpleDefaultFont.Regular; // Add buttons buttonA = new TouchButton(ButtonALabel, ButtonAColor); AddChild(buttonA); buttonB = new TouchButton(ButtonBLabel, ButtonBColor); AddChild(buttonB); // Check for touchscreen mode if (parent.VisibilityMode == VisibilityModeEnum.TouchscreenOnly && !OS.HasTouchscreenUiHint()) { Hide(); } }
// Use this for initialization void Start() { rcButton = GetComponent <RayCastButton>(); touchButton = GetComponent <TouchButton>(); if (rcButton == null) { rcButton = gameObject.AddComponent <RayCastButton>(); } if (touchButton == null) { touchButton = gameObject.AddComponent <TouchButton>(); } rcButton.OnButtonEnter += PressButton; rcButton.OnButtonExit += UnpressButton; touchButton.OnButtonEnter += PressButton; touchButton.OnButtonExit += UnpressButton; }
void Update() { // Input foreach (Touch t in Input.touches) { Vector2 position = Camera.main.ScreenToWorldPoint(t.position); Collider2D[] colliders = Physics2D.OverlapPointAll(position); foreach (Collider2D collider in colliders) { TouchButton button = collider.GetComponent <TouchButton>(); processor.SendInput(button.button); //button.SetState(true); } } if (Input.GetKey(KeyCode.N)) { processor.SendInput(PicoEmulator.Buttons.CIRCLE); //processor2.SendInput(PicoEmulator.Buttons.CIRCLE); } } if (Input.GetKey(KeyCode.E)) { processor.SendInput(PicoEmulator.Buttons.CROSS); //processor2.SendInput(PicoEmulator.Buttons.CROSS); } } if (Input.GetKey(KeyCode.W)) { processor.SendInput(PicoEmulator.Buttons.UP); //processor2.SendInput(PicoEmulator.Buttons.UP); } } if (Input.GetKey(KeyCode.A)) { processor.SendInput(PicoEmulator.Buttons.LEFT); //processor2.SendInput(PicoEmulator.Buttons.LEFT); } } if (Input.GetKey(KeyCode.S)) { processor.SendInput(PicoEmulator.Buttons.RIGHT); //processor2.SendInput(PicoEmulator.Buttons.RIGHT); } } if (Input.GetKey(KeyCode.D)) { processor.SendInput(PicoEmulator.Buttons.DOWN); //processor2.SendInput(PicoEmulator.Buttons.DOWN); } } processor.Update(); //processor2.Update(); }
internal static void SetButtonState(TouchButton touchButton, bool value) { switch (touchButton) { case TouchButton.A: a = value; break; case TouchButton.B: b = value; break; case TouchButton.Home: home = value; break; case TouchButton.Menu: menu = value; break; } }
public void show() { Canvas canvas = new Canvas(); this.MainWindow.Content = canvas; Image backgroundImage = new Image { Name = "background", Source = new BitmapImage(new Uri("C:/tempConcours/welcomeBackground.png", UriKind.Absolute)), }; backgroundImage.RenderTransform = MainScaleTransform; canvas.Children.Add(backgroundImage); Canvas.SetLeft(backgroundImage, 0); Canvas.SetTop(backgroundImage, 0); TouchButton startButton = new TouchButton(); startButton.Content = "Demarrer le jeu"; startButton.Width = 400; startButton.Height = 75; startButton.ButtonTap += startButton_Tap; startButton.Background = Brushes.YellowGreen; canvas.Children.Add(startButton); Canvas.SetTop(startButton, 700); Canvas.SetRight(startButton, 560); }
public DigitalDisplay() { SetSizeRequest(120, 140); label = new TouchLabel(); label.WidthRequest = 120; label.textAlignment = TouchAlignment.Center; label.textRender.textWrap = TouchTextWrap.Shrink; label.textColor = "grey3"; Put(label, 0, 35); textBox = new TouchLabel(); textBox.text = "Open"; textBox.textColor = "seca"; textBox.textAlignment = TouchAlignment.Center; textBox.textSize = 20; textBox.SetSizeRequest(120, 30); Put(textBox, 0, 0); button = new TouchButton(); button.text = "Force"; button.buttonColor = "grey3"; button.ButtonReleaseEvent += OnForceReleased; button.SetSizeRequest(120, 30); Put(button, 0, 55); selector = new TouchSelectorSwitch(2); selector.SetSizeRequest(120, 30); selector.sliderSize = MySliderSize.Large; selector.textOptions[0] = "Open"; selector.textOptions[1] = "Closed"; selector.sliderColorOptions[0] = "grey2"; selector.sliderColorOptions[1] = "pri"; selector.SelectorChangedEvent += OnSelectorChange; selector.Visible = false; Put(selector, 0, 90); Show(); }
public MenuWindow(params object[] options) : base() { sceneTitle = "Menu"; List <string> screenNames = new List <string> (); foreach (var screen in AquaPicGui.AquaPicUserInterface.scenes.Keys) { screenNames.Add(screen); } screenNames.Sort(); int x = 60; int y = 80; foreach (var name in screenNames) { SceneData screen = AquaPicGui.AquaPicUserInterface.scenes[name]; if (screen.showInMenu) { var b = new TouchButton(); b.SetSizeRequest(220, 50); b.text = screen.name; b.textColor = "black"; b.ButtonReleaseEvent += OnButtonClick; Put(b, x, y); x += 230; if (x >= 690) { x = 60; y += 60; } } } ShowAll(); }
protected void ActionWithHoldCheck(TouchButton touchButton, int _selection, bool _isEquipment) { if (touchButton.IsPressedDown() && canUse[_selection]) { holdTimers[_selection] += Time.deltaTime; if (holdTimers[_selection] > holdTimerThreshold) { if (_isEquipment) { OnEquipmentPressed(_selection - 1, true); } else { OnInteractPressed(true); } canUse[_selection] = false; } } else if (!touchButton.IsPressedDown()) { if (holdTimers[_selection] > 0 && canUse[_selection]) { if (_isEquipment) { OnEquipmentPressed(_selection - 1, false); } else { OnInteractPressed(false); } } holdTimers[_selection] = 0; canUse[_selection] = true; } }
private void AddButton(TouchButton TButton) { _buttons.Add(TButton.Group + TButton.Name, TButton); }
// --------------- public override void OnInspectorGUI() { TouchButton c = (TouchButton)this.target; GUILayout.Box(GUIContent.none, CFEditorStyles.Inst.headerButton, GUILayout.ExpandWidth(true)); this.DrawWarnings(c); bool toggle = c.toggle, linkToggleToRigSwitch = c.linkToggleToRigSwitch, autoToggleOff = c.autoToggleOff, toggleOffWhenHiding = c.toggleOffWhenHiding; float autoToggleOffTimeOut = c.autoToggleOffTimeOut; TouchButton.ToggleOnAction toggleOnAction = c.toggleOnAction; TouchButton.ToggleOffAction toggleOffAction = c.toggleOffAction; string toggleRigSwitchName = c.toggleRigSwitchName; this.emulateTouchPressure = c.emulateTouchPressure; // Button specific inspector.... const float LABEL_WIDTH = 110; InspectorUtils.BeginIndentedSection(new GUIContent("Toggle Settings")); toggle = EditorGUILayout.ToggleLeft(new GUIContent("Toggle Mode", "Enable toggle mode."), toggle); if (toggle) { CFGUI.BeginIndentedVertical(); toggleOnAction = (TouchButton.ToggleOnAction)CFGUI.EnumPopup(new GUIContent("Toggle On Action", "Select when toggle state should change from OFF to ON."), toggleOnAction, LABEL_WIDTH); toggleOffAction = (TouchButton.ToggleOffAction)CFGUI.EnumPopup(new GUIContent("Toggle Off Action", "Select when toggle state should change from ON to OFF."), toggleOffAction, LABEL_WIDTH); if (toggleOffAction != TouchButton.ToggleOffAction.OnTimeout) { autoToggleOff = EditorGUILayout.ToggleLeft(new GUIContent("Auto Toggle Off", "When enabled, this button will auto-toggle off itself after specified amount of time."), autoToggleOff); } if (autoToggleOff || toggleOffAction == TouchButton.ToggleOffAction.OnTimeout) { CFGUI.BeginIndentedVertical(); autoToggleOffTimeOut = CFGUI.FloatFieldEx(new GUIContent("Timeout (ms)", "Auto-toggle off time-out in milliseconds."), autoToggleOffTimeOut, 0.1f, 1000, 1000, true, LABEL_WIDTH); CFGUI.EndIndentedVertical(); } linkToggleToRigSwitch = EditorGUILayout.ToggleLeft(new GUIContent("Link toggle to Rig Switch", "Links this toggle button to Rig Switch's state.\nExternal modification to assigned flag will also affect this button's toggle state!"), linkToggleToRigSwitch); if (linkToggleToRigSwitch) { CFGUI.BeginIndentedVertical(); toggleRigSwitchName = this.toggleRigSwitchInsp.Draw("Switch", toggleRigSwitchName, c.rig, 50); toggleOffWhenHiding = EditorGUILayout.ToggleLeft(new GUIContent("Turn the Switch Off when hiding", "When enabled, this button will turn off linked Rig Switch when hidden."), toggleOffWhenHiding); CFGUI.EndIndentedVertical(); } CFGUI.EndIndentedVertical(); } InspectorUtils.EndIndentedSection(); InspectorUtils.BeginIndentedSection(new GUIContent("Button Bindings")); this.pressBindingInsp.Draw(c.pressBinding, c.rig); this.touchPressureBindingInsp.Draw(c.touchPressureBinding, c.rig); if (toggle) { this.toggleBindingInsp.Draw(c.toggleOnlyBinding, c.rig); } InspectorUtils.EndIndentedSection(); // Register undo... if ((toggle != c.toggle) || (linkToggleToRigSwitch != c.linkToggleToRigSwitch) || (toggleOnAction != c.toggleOnAction) || (toggleOffAction != c.toggleOffAction) || (autoToggleOff != c.autoToggleOff) || (autoToggleOffTimeOut != c.autoToggleOffTimeOut) || (this.emulateTouchPressure != c.emulateTouchPressure) || (toggleOffWhenHiding != c.toggleOffWhenHiding) || (toggleRigSwitchName != c.toggleRigSwitchName)) { CFGUI.CreateUndo("CF2 Button modification", c); c.toggle = toggle; c.linkToggleToRigSwitch = linkToggleToRigSwitch; c.toggleOnAction = toggleOnAction; c.toggleOffAction = toggleOffAction; c.toggleRigSwitchName = toggleRigSwitchName; c.autoToggleOff = autoToggleOff; c.autoToggleOffTimeOut = autoToggleOffTimeOut; c.toggleOffWhenHiding = toggleOffWhenHiding; c.emulateTouchPressure = this.emulateTouchPressure; CFGUI.EndUndo(c); } // Draw Shared Dynamic Control Params... this.DrawDynamicTouchControlGUI(c); }
// Use this for initialization private void Start() { // if( this.rigidbody == null ) { Debug.LogError( "This GameObject has not a Component: 'Rigidbody'.", this ); return; } m_TouchButton = this.GetComponent<TouchButton>(); if( m_TouchButton == null ) { Debug.LogError( "This GameObject has not a Component: 'TouchButton'.", this ); return; } // m_MoveDir.Normalize(); if( m_MoveDir.x != 1 && m_MoveDir.y != 1 && m_MoveDir.z != 1 && m_MoveDir.x != -1 && m_MoveDir.y != -1 && m_MoveDir.z != -1 ) { Debug.LogWarning( "The MoveDir is invalid. Set it to default.", this ); m_MoveDir = Vector3.right; } // m_vPos = this.transform.position; // m_vLocalPos = this.transform.localPosition; // m_bInit = true; }
public ChemistryWindow(params object[] options) : base(false) { sceneTitle = "Chemistry"; string path = System.IO.Path.Combine(Utils.AquaPicEnvironment, "TestProcedures"); var d = new DirectoryInfo(path); FileInfo[] files = d.GetFiles("*.json"); testIdx = -1; tests = new List <TestProcedure> (); foreach (var file in files) { try { tests.Add(new TestProcedure(file.FullName)); } catch (Exception ex) { Logger.AddError(ex.ToString()); } } timerProgress = new TouchCurvedProgressBar( new TouchColor("grey3"), new TouchColor("pri"), 100.0f); timerProgress.SetSizeRequest(250, 175); timerProgress.curveStyle = CurveStyle.ThreeQuarterCurve; Put(timerProgress, 275, 100); timerProgress.Visible = false; timerLabel = new TouchLabel(); timerLabel.WidthRequest = 200; timerLabel.textAlignment = TouchAlignment.Center; timerLabel.textSize = 20; Put(timerLabel, 300, 240); timerLabel.Visible = false; stepButton = new TouchButton(); stepButton.SetSizeRequest(200, 50); stepButton.buttonColor = "grey2"; stepButton.text = "N/A"; stepButton.ButtonReleaseEvent += OnStepButtonReleased; Put(stepButton, 300, 365); stepButton.Show(); resetBtn = new TouchButton(); resetBtn.SetSizeRequest(200, 50); resetBtn.text = "Restart"; resetBtn.ButtonReleaseEvent += OnResetButtonReleased; Put(resetBtn, 510, 365); resetBtn.Visible = false; skipBtn = new TouchButton(); skipBtn.SetSizeRequest(200, 50); skipBtn.text = "Skip"; skipBtn.buttonColor = "seca"; skipBtn.ButtonReleaseEvent += OnSkipButtonReleased; Put(skipBtn, 90, 365); skipBtn.Visible = false; nameLabel = new TouchLabel(); nameLabel.WidthRequest = 700; nameLabel.textSize = 14; nameLabel.textColor = "seca"; nameLabel.textAlignment = TouchAlignment.Center; Put(nameLabel, 50, 65); nameLabel.Show(); stepLabel = new TouchTextBox(); stepLabel.SetSizeRequest(620, 75); stepLabel.textAlignment = TouchAlignment.Center; stepLabel.text = "Please select a test procedure"; Put(stepLabel, 90, 280); stepLabel.Show(); actionLabel = new TouchLabel(); actionLabel.WidthRequest = 200; actionLabel.textAlignment = TouchAlignment.Right; Put(actionLabel, 510, 420); actionLabel.Show(); combo = new TouchComboBox(); foreach (var test in tests) { combo.comboList.Add(test.name); } combo.nonActiveMessage = "Select test"; combo.WidthRequest = 235; combo.ComboChangedEvent += OnComboChanged; Put(combo, 550, 35); combo.Show(); CanFocus = true; KeyPressEvent += EntryKeyPressEvent; ExposeEvent += (o, args) => { GrabFocus(); }; Show(); }
public void LoadButtons(FileInfo OptionsFile) { if (!OptionsFile.Exists) return; string newActive = ""; StreamReader sr = null; try { sr = OptionsFile.OpenText(); while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line.StartsWith("#")) continue; string[] parts = line.Split("=".ToCharArray(), 2); if (parts.Length < 2) continue; switch (parts[0]) { case "button": TouchButton tb = new TouchButton(parts[1]); if (tb.Name != "") AddButton(tb); break; case "active": newActive = parts[1]; break; default: break; } } } catch (SystemException se) { ShowError(se); } finally { if (sr != null) sr.Close(); } UpdateGroups(); ActivateGroup(newActive); }
public void show() { List<Tuple<int, string, int>> result = this.Game.Scores.getFinalResult(this.Game.TeamName); int max = result.Count; if(max > 10) { max = 10; } Canvas canvas = new Canvas(); this.MainWindow.Content = canvas; canvas.Background = Brushes.LavenderBlush; Grid grid = new Grid(); grid.Background = Brushes.LightCyan; grid.ShowGridLines = true; grid.Width = 500; grid.Height = 500; canvas.Children.Add(grid); Canvas.SetTop(grid, 200); Canvas.SetRight(grid, 100); List <RowDefinition> ScoreRows = new List<RowDefinition>(); List<Tuple<Label, Label, Label>> Labels = new List<Tuple<Label, Label, Label>>(); ColumnDefinition col0 = new ColumnDefinition(); ColumnDefinition col1 = new ColumnDefinition(); ColumnDefinition col2 = new ColumnDefinition(); grid.ColumnDefinitions.Add(col0); grid.ColumnDefinitions.Add(col1); grid.ColumnDefinitions.Add(col2); for (int i = 0; i < max; i++) { ScoreRows.Add(new RowDefinition()); Labels.Add(new Tuple<Label, Label, Label>(new Label { Content = result[i].Item1.ToString(), FontSize = 20 }, new Label { Content = result[i].Item2, FontSize = 20 }, new Label { Content = result[i].Item3.ToString(), FontSize = 20 })); grid.RowDefinitions.Add(ScoreRows[i]); if(result[i].Item2 == this.Game.TeamName) { //Change color of the row Border border1 = new Border { Background = Brushes.Red}; Border border2 = new Border { Background = Brushes.Red }; Border border3 = new Border { Background = Brushes.Red }; Grid.SetRow(border1, i); Grid.SetRow(border2, i); Grid.SetRow(border3, i); Grid.SetColumn(border1, 0); Grid.SetColumn(border2, 1); Grid.SetColumn(border3, 2); grid.Children.Add(border1); grid.Children.Add(border2); grid.Children.Add(border3); } Grid.SetRow(Labels[i].Item1, i); Grid.SetColumn(Labels[i].Item1, 0); grid.Children.Add(Labels[i].Item1); Labels[i].Item1.HorizontalAlignment = HorizontalAlignment.Center; Labels[i].Item1.VerticalAlignment = VerticalAlignment.Center; Grid.SetRow(Labels[i].Item2, i); Grid.SetColumn(Labels[i].Item2, 1); grid.Children.Add(Labels[i].Item2); Labels[i].Item2.HorizontalAlignment = HorizontalAlignment.Center; Labels[i].Item2.VerticalAlignment = VerticalAlignment.Center; Grid.SetRow(Labels[i].Item3, i); Grid.SetColumn(Labels[i].Item3, 2); grid.Children.Add(Labels[i].Item3); Labels[i].Item3.HorizontalAlignment = HorizontalAlignment.Center; Labels[i].Item3.VerticalAlignment = VerticalAlignment.Center; } TouchButton finishButton = new TouchButton { Content = "Terminer", Width = 200, Height = 69 }; finishButton.Background = Brushes.YellowGreen; finishButton.ButtonTap += FinishButton_ButtonTap; canvas.Children.Add(finishButton); Canvas.SetTop(finishButton, 700); Canvas.SetRight(finishButton, 90); }
// private void OnTouchButtonHover( TouchButton btn, bool b ) { // if( !m_bInit ) return; if(HasInteractive == false) return; // if( b ) btn.ShowToolTip(); else btn.HideToolTip(); }
public void show() { //Main Grid================================================================= this.grid = new Grid(); this.MainWindow.Content = grid; grid.Background = Brushes.Aqua; grid.ShowGridLines = true; RowDefinition UpperRow = new RowDefinition(); RowDefinition MiddleRow = new RowDefinition(); RowDefinition MainRow = new RowDefinition(); UpperRow.Height = new GridLength(200); MiddleRow.Height = new GridLength(200); grid.RowDefinitions.Add(UpperRow); grid.RowDefinitions.Add(MiddleRow); grid.RowDefinitions.Add(MainRow); //UpperCanvas================================================================= Canvas UpperCanvas = new Canvas(); UpperCanvas.Background = Brushes.Ivory; Grid.SetRow(UpperCanvas, 0); grid.Children.Add(UpperCanvas); //Trophies ScaleTransform trophyScaleTransform = new ScaleTransform(0.5, 0.5, 0, 0); foreach (Trophy t in this.Game.Trophies.Trophies) { //scaling t.Image.RenderTransform = trophyScaleTransform; //positioning UpperCanvas.Children.Add(t.Image); Canvas.SetLeft(t.Image, t.PosX); Canvas.SetTop(t.Image, t.PosY); } //Timer this.timerLabel = new Label { Name = "TextBlockRemainingTime", FontSize = 60, Content = "Temps restant : 15:00" }; UpperCanvas.Children.Add(this.timerLabel); Canvas.SetTop(timerLabel, 15); Canvas.SetRight(timerLabel, 20); //Score this.scoreLabel = new Label { Name = "ScoreLabel", FontSize = 60, Content = "Score actuel : 0", }; UpperCanvas.Children.Add(this.scoreLabel); Canvas.SetTop(scoreLabel, 100); Canvas.SetRight(scoreLabel, 20); //MiddleCanvas================================================================= this.MiddleCanvas = new Canvas(); MiddleCanvas.Background = Brushes.GreenYellow; Grid.SetRow(this.MiddleCanvas, 1); grid.Children.Add(this.MiddleCanvas); this.updateMiddleCanvas(3); //MainCanvas=================================================================== this.MainCanvas = new Canvas(); Grid.SetRow(MainCanvas, 2); grid.Children.Add(MainCanvas); //action scroll viewer this.actionsScrollViewer = new TouchScrollViewer(); this.actionsScrollViewer.Height = 100; this.actionsScrollViewer.Width = 700; this.actionsScrollViewer.Background = Brushes.Fuchsia; this.actionsScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; this.actionsScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden; this.actionsStackPanel = new StackPanel(); this.actionsStackPanel.Orientation = Orientation.Horizontal; this.actionsStackPanel.HorizontalAlignment = HorizontalAlignment.Left; this.actionsStackPanel.VerticalAlignment = VerticalAlignment.Top; this.actionsScrollViewer.Content = this.actionsStackPanel; Canvas.SetRight(this.actionsScrollViewer, 400); this.MainCanvas.Children.Add(this.actionsScrollViewer); this.updateActionScrollViewer(); //Tests************************* //UbiContextMenu contextMenu = new UbiContextMenu(); //contextMenu.Placement = UbiContextMenu.PlacementMode.GestureCenter; ////contextMenu.Template = //Control control = new Control(); ////UpperCanvas.Children.Add(contextMenu); //*** //ListBox lb = new ListBox(); //ListBoxItem item1 = new ListBoxItem(); //ListBoxItem item2 = new ListBoxItem(); //item1.Content = "item1"; //item2.Content = "item2"; //lb.Items.Add(item1); //lb.Items.Add(item2); //MainCanvas.Children.Add(lb); TouchButton but = new TouchButton(); but.Content = "test disturbance"; but.ButtonTap += But_ButtonTap; but.Width = 200; but.Background = Brushes.Red; Canvas.SetTop(but, 200); this.MainCanvas.Children.Add(but); //Test Ends************************************************** //IslandControls class test IslandControls IslandControls2 = new IslandControls(null, this.MainCanvas, 0, 0); //To be removed Random random = new Random(); this.Game.Scores.increaseScore(random.Next(1, 50)); this.Game.ResourceManager.changeResourceProduction(ResourceType.Bois, 75); }
private void AddButtonToForm(TouchButton TButton) { Button b = new Button(); b.Padding = new Padding(0); b.Text = TButton.Name; b.Name = TButton.Group + TButton.Name; b.Location = new System.Drawing.Point(0, 0); b.Size = new System.Drawing.Size(MINBUTTONWIDTH, MINBUTTONHEIGHT); b.UseVisualStyleBackColor = false; b.MouseUp += new MouseEventHandler(managedButton_MouseUp); b.GotFocus += new EventHandler(shared_GotFocus); this.Controls.Add(b); }
// private void OnClicked( TouchButton btn ) { // if( !m_bInit ) return; if(HasInteractive == false) return; Debug.Log("Button ID:"+btn.ID); // HasInteractive = false; // if( btn.ID == m_IDOutDoor ) { ProcessOutDoor(); MenuManager.Instance.ShowMenu( btn.ID, m_CameraTweenDuration ); // StartCoroutine( DelayHideOnOutDoorMoveIn( m_DelayHideOnOutDoorMoveIn ) ); } else { // MenuManager.Instance.ShowMenu( btn.ID ); } // TouchButtonManager.Instance.Hide(); TouchButtonManager.Instance.HideToolTips(); }