private void ReloadOverlay() { ov?.Close(); if (!OverlayLoader.TryLoadOverlay(br.InternalOverlayAssemblyPath, br, out ov)) { br.InternalOverlayAssemblyPath = null; } br.ClearOverlayDelegates(); br.OnOverlayVisibilityChanged += ov.SetVisibility; br.OnOverlayClickthroughChanged += ov.SetClickthrough; br.ConfShowOverlay = br.ConfShowOverlay; // take effect once br.ConfClickthough = br.ConfClickthough; }
void UpdateDraggingOverlay() { if (MovingOverlay != null) { Quaternion rotation = Hand.transform.rotation * Quaternion.Inverse(MovingOriginalRotation); Vector3 unRolled = (rotation * MovingOriginalOverlayRotation).eulerAngles; float rollDeadzone = 15; if (!applyRollDeadzone && (unRolled.z <= rollDeadzone || unRolled.z >= 360 - rollDeadzone)) { applyRollDeadzone = true; } if (applyRollDeadzone) { if (unRolled.z < 180) { if (unRolled.z <= rollDeadzone) { unRolled.z = 0; } else { unRolled.z -= rollDeadzone; } } else { if (unRolled.z >= 360 - rollDeadzone) { unRolled.z = 0; } else { unRolled.z += rollDeadzone; } } } rotation = Quaternion.Euler(unRolled); MovingOverlay.transform.rotation = rotation; Vector3 originalOffset = MovingOriginalOverlayPosition - MovingOriginalPosition; Vector3 offset = (rotation * Quaternion.Inverse(MovingOriginalOverlayRotation)) * originalOffset; MovingOverlay.transform.position = MovingOriginalOverlayPosition + BallPosition() - MovingOriginalPosition - originalOffset + offset; if (PressedUp(SteamVR_Controller.ButtonMask.Grip)) { MovingOverlay.SavePosition(); MovingOverlay = null; applyRollDeadzone = false; } } }
private static void CreateProfileOverlay() { Profile profile = new Profile(); profile.name = "Profiles"; profile.directory = DirectoryInfo.FolderPath; profile.grids = new List <ButtonGrid>(1); profile.index = -1; ButtonGrid grid = new ButtonGrid(); grid.parent = profile; profile.grids.Add(grid); grid.name = "Profiles"; grid.filename = DirectoryInfo.ProfilesTextureName; float buttonSize = 0.1f; int gridWidth = 4; int gridHeight = 2; while ((gridWidth * (gridHeight - 1)) < profiles.Count) { if (gridWidth == gridHeight - 1) { gridWidth++; } else { gridHeight++; } } grid.gridWidth = gridWidth; grid.gridHeight = gridHeight; grid.width = buttonSize * gridWidth; grid.height = buttonSize * gridHeight; grid.buttons = new List <GridButton>(profiles.Count); grid.x = 0; grid.y = 1; grid.z = 0; grid.pitch = 0; grid.yaw = 0; grid.roll = 0; grid.alpha = 1; GridButton resetButton = new GridButton(); resetButton.x = 0; resetButton.y = 0; resetButton.width = gridWidth / 2; resetButton.height = 1; resetButton.text = "Reset Seated Position"; resetButton.fontSize = 0.0125; resetButton.keypress = null; grid.buttons.Add(resetButton); GridButton laserButton = new GridButton(); laserButton.x = 2; laserButton.y = 0; laserButton.width = gridWidth - (gridWidth / 2); laserButton.height = 1; laserButton.text = "Reset Seated Position"; laserButton.fontSize = 0.0125; laserButton.keypress = null; grid.buttons.Add(laserButton); int x = 0; int y = 1; foreach (Profile p in profiles) { GridButton button = new GridButton(); button.x = x; button.y = y; button.width = 1; button.height = 1; button.text = p.name; button.fontSize = 0.01; button.keypress = null; grid.buttons.Add(button); x++; if (x >= gridWidth) { x = 0; y++; } } grid.RebuildSpatialIndex(); GameObject overlay = (GameObject)GameObject.Instantiate(Resources.Load("Overlay")); OverlayLoader loader = overlay.GetComponent <OverlayLoader>(); overlay.GetComponent <HOTK_Overlay>().OverlayTexture = new Texture2D(16, 16); loader.ButtonGrid = grid; ProfileOverlay = loader; ProfileOverlayList = new List <OverlayLoader>(1); ProfileOverlayList.Add(ProfileOverlay); }
private void Start() { session = FindObjectOfType <GameSession>(); overlayLoader = FindObjectOfType <OverlayLoader>(); }
public BaseWeaponTypeEnum(OverlayLoader loader) : base((RelativePath)@"weapons\baseWeaponTypes.json", loader) { }
public DynamicEnum(RelativePath file, OverlayLoader loader) { _file = file; Loader = loader; _data = new Lazy <IDictionary <string, T> >(() => Loader.LoadDictionaryCaseInsensitive <T>(file)); }
public MaterialEnum(OverlayLoader loader) : base((RelativePath)@"materials.json", loader) { }
public WeaponClassEnum(OverlayLoader loader) : base((RelativePath)@"weapons\weaponClasses.json", loader) { }
void UpdateOverlays() { if (PressedDown(SteamVR_Controller.ButtonMask.ApplicationMenu)) { DataLoader.StartSelectingProfile(DataLoader.Settings.Lasermode ? Hand.transform.position + 0.2f * LaserDirection() : BallPosition(), Head.transform.position); } if (PressedUp(SteamVR_Controller.ButtonMask.ApplicationMenu) && DataLoader.SelectingProfile) { DataLoader.StopSelectingProfile(profileIndex); } bool profileSet = false; if (CurrentButton != null) { isLeftRight = CurrentButton.isLeftRight; } Vector2 touchPos = TouchpadPos(); bool touchModeTouchpadActive = Mathf.Abs(isLeftRight ? touchPos.x : touchPos.y) >= 0.5; bool touchModeTouchpadPressed = touchModeTouchpadActive && !this.TouchModeTouchpadWasActive; bool touchModeTouchpadReleased = !touchModeTouchpadActive && this.TouchModeTouchpadWasActive; this.TouchModeTouchpadWasActive = touchModeTouchpadActive; if (CurrentButton == null) { bool showOverlay = false; OverlayLoader closestOverlay = null; Vector3 closestPos = new Vector3(0, 0, 1000); float closestDist = 1000; List <OverlayLoader> overlays = DataLoader.SelectingProfile ? DataLoader.ProfileOverlayList : DataLoader.Overlays; foreach (OverlayLoader overlay in overlays) { float dist; Vector3 relPos = overlay.RelativePosition(DataLoader.Settings.Lasermode ? Hand.transform.position : BallPosition(), DataLoader.Settings.Lasermode ? LaserDirection() : Vector3.zero, out dist); if (overlay.PositionInRange(relPos, 0.1f) && dist < closestDist) { closestOverlay = overlay; closestPos = relPos; closestDist = dist; } } if (closestOverlay != null) { if (DataLoader.Settings.Lasermode) { SetLaserLength(closestDist); } GridButton button = closestOverlay.PointedButton(closestPos); if (button != null) { showOverlay = true; ButtonOverlay.OverlayTexture = OverlayTextureForButton(button); closestOverlay.ShowButtonOverlay(button, ButtonOverlay); if (!DataLoader.SelectingProfile) { if (PressedDown(SteamVR_Controller.ButtonMask.Trigger)) { CurrentButton = button; CurrentKeypress = button.keypress; if (button.buttonType == ButtonType.Normal || button.buttonType == ButtonType.ThreeWaySwitch) { KeyboardInput.Down(button.keypress); } else { RotaryDirection = PointingDirection(); RotaryOriginalUp = PointingUpDirection(); } ButtonOverlay.OverlayTexture = OverlayTexturePressed; } else if ((!DataLoader.Settings.OculusTouchMode && PressedDown(SteamVR_Controller.ButtonMask.Touchpad)) || (DataLoader.Settings.OculusTouchMode && touchModeTouchpadPressed)) { if (button.buttonType == ButtonType.ThreeWaySwitch) { CurrentButton = button; ButtonOverlay.OverlayTexture = OverlayTexturePressed; CurrentKeypress = (CurrentButton.isLeftRight ? touchPos.x : touchPos.y) >= 0 ? button.cwKeypress : button.ccwKeypress; KeyboardInput.Down(CurrentKeypress); } else if (button.buttonType == ButtonType.MultiPositionSwitch) { CurrentButton = button; ButtonOverlay.OverlayTexture = OverlayTexturePressed; int sign = (CurrentButton.isLeftRight ? touchPos.x : touchPos.y) >= 0 ? 1 : -1; int nextPosition = CurrentButton.currentKeypress + (int)sign; if (nextPosition >= 0 && nextPosition < CurrentButton.multiKeypresses.Count) { CurrentButton.currentKeypress = nextPosition; KeyCombo keypress = CurrentButton.multiKeypresses[nextPosition]; KeyboardInput.Down(keypress); KeyboardInput.Up(keypress); } } } } else { profileIndex = closestOverlay.ButtonGrid.buttons.IndexOf(button); profileSet = true; } } if (!DataLoader.SelectingProfile && !closestOverlay.ButtonGrid.locked && PressedDown(SteamVR_Controller.ButtonMask.Grip)) { MovingOverlay = closestOverlay; MovingOriginalPosition = BallPosition(); MovingOriginalRotation = Hand.transform.rotation; MovingOriginalOverlayPosition = closestOverlay.transform.position; MovingOriginalOverlayRotation = closestOverlay.transform.rotation; } } else if (DataLoader.Settings.Lasermode) { SetLaserLength(0.2f); } if (!showOverlay) { ButtonOverlay.enabled = false; } } else { if (PressedUp(SteamVR_Controller.ButtonMask.Trigger) || (((!DataLoader.Settings.OculusTouchMode && PressedUp(SteamVR_Controller.ButtonMask.Touchpad)) || (DataLoader.Settings.OculusTouchMode && touchModeTouchpadReleased)) && (CurrentButton.buttonType == ButtonType.ThreeWaySwitch || CurrentButton.buttonType == ButtonType.MultiPositionSwitch))) { if (CurrentButton.buttonType == ButtonType.Normal || CurrentButton.buttonType == ButtonType.ThreeWaySwitch || CurrentButton.buttonType == ButtonType.MultiPositionSwitch) { KeyboardInput.Up(CurrentKeypress); } ButtonOverlay.OverlayTexture = OverlayTexture; CurrentButton = null; CurrentKeypress = null; } else if (CurrentButton.buttonType == ButtonType.TwoDirectionRotary || CurrentButton.buttonType == ButtonType.MultiPositionRotary) { float angle = AngleBetween(this.RotaryOriginalUp, PointingUpDirection(), this.RotaryDirection); if (Mathf.Abs(angle) >= CurrentButton.rotaryAngle) { float sign = Mathf.Sign(angle); this.RotaryOriginalUp = Quaternion.AngleAxis((float)CurrentButton.rotaryAngle * (-sign), this.RotaryDirection) * this.RotaryOriginalUp; if (CurrentButton.buttonType == ButtonType.TwoDirectionRotary) { KeyCombo keypress = sign > 0 ? CurrentButton.cwKeypress : CurrentButton.ccwKeypress; KeyboardInput.Down(keypress); keypressToRelease = keypress; } else if (CurrentButton.buttonType == ButtonType.MultiPositionRotary) { int nextPosition = CurrentButton.currentKeypress + (int)sign; if (nextPosition >= 0 && nextPosition < CurrentButton.multiKeypresses.Count) { CurrentButton.currentKeypress = nextPosition; KeyCombo keypress = CurrentButton.multiKeypresses[nextPosition]; KeyboardInput.Down(keypress); keypressToRelease = keypress; } } } } } if (!profileSet && DataLoader.SelectingProfile) { profileIndex = -1; } }