Skip to content

Commit

Permalink
Another set of typo/style-changes according to the review of @falko17
Browse files Browse the repository at this point in the history
  • Loading branch information
lilSander committed Oct 22, 2024
1 parent acb150d commit c7a9a0c
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 91 deletions.
7 changes: 3 additions & 4 deletions Assets/SEE/Controls/Actions/AddEdgeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,18 @@ public override bool Update()
// Assigning the game objects to be connected.
// Checking whether the two game objects are not null and whether they are
// actually nodes.
// FIXME: We need an interaction for VR, too.
if (SceneSettings.InputType == PlayerInputType.VRPlayer)
{
if (XRSEEActions.hoveredGameObject != null && XRSEEActions.Selected && XRSEEActions.hoveredGameObject.HasNodeRef())
if (XRSEEActions.Selected && InteractableObject.HoveredObjectWithWorldFlag.gameObject != null && InteractableObject.HoveredObjectWithWorldFlag.gameObject.HasNodeRef())
{
if (from == null)
{
from = XRSEEActions.hoveredGameObject;
from = InteractableObject.HoveredObjectWithWorldFlag.gameObject;
XRSEEActions.Selected = false;
}
else if (to == null)
{
to = XRSEEActions.hoveredGameObject;
to = InteractableObject.HoveredObjectWithWorldFlag.gameObject;
XRSEEActions.Selected = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/SEE/Controls/Actions/AddNodeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override bool Update()
GameObject parent = raycastHit.collider.gameObject;
AddNode(raycastHit.collider.gameObject, raycastHit.point);
}
else if (SceneSettings.InputType == PlayerInputType.VRPlayer && XRSEEActions.hoveredGameObject != null && XRSEEActions.Selected && XRSEEActions.hoveredGameObject.HasNodeRef() &&
else if (SceneSettings.InputType == PlayerInputType.VRPlayer && XRSEEActions.Selected && InteractableObject.HoveredObjectWithWorldFlag.gameObject != null && InteractableObject.HoveredObjectWithWorldFlag.gameObject.HasNodeRef() &&
XRSEEActions.RayInteractor.TryGetCurrent3DRaycastHit(out RaycastHit res))
{
// the hit object is the parent in which to create the new node
Expand Down
2 changes: 1 addition & 1 deletion Assets/SEE/Controls/Actions/DeleteAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public override bool Update()
else if (SceneSettings.InputType == PlayerInputType.VRPlayer && XRSEEActions.Selected)
{
// the hit object is the one to be deleted
hitGraphElements.Add(XRSEEActions.hoveredGameObject);
hitGraphElements.Add(InteractableObject.HoveredObjectWithWorldFlag.gameObject);
XRSEEActions.Selected = false;
return Delete(); // the selected objects are deleted and this action is done now
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/SEE/Controls/Actions/MoveAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public void Grab(GameObject gameObject)
GrabbedGameObject = gameObject;
if (SceneSettings.InputType == PlayerInputType.VRPlayer)
{
originalParent = XRSEEActions.oldParent;
originalParent = XRSEEActions.OldParent;
}
else
{
Expand Down Expand Up @@ -307,7 +307,7 @@ public bool UnGrab()
{
// Node does not fit, resetting…
UnReparent();
XRSEEActions.oldParent = null;
XRSEEActions.OldParent = null;
wasMoved = false;
}
else
Expand Down
2 changes: 1 addition & 1 deletion Assets/SEE/UI/Window/TreeWindow/DesktopTreeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ void RegisterClickHandler()
});
}

IEnumerable<PopupMenuEntry> CreateContextMenuActions (TreeWindowContextMenu contextMenu, Vector2 position, GraphElement representedGraphElement, GameObject representedGameObject)
IEnumerable<PopupMenuEntry> CreateContextMenuActions(TreeWindowContextMenu contextMenu, Vector2 position, GraphElement representedGraphElement, GameObject representedGameObject)
{
List<PopupMenuAction> appends = new()
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/SEE/XR/KeyboardManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class KeyboardManager : MonoBehaviour
public Button deleteButton;

/// <summary>
/// The spacebuttom, which adds a space.
/// The spacebutton, which adds a space.
/// </summary>
public Button spaceButton;

Expand Down
86 changes: 21 additions & 65 deletions Assets/SEE/XR/RadialSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using UnityEngine.InputSystem;
using UnityEngine.UI;
using SEE.Utils;
using System;

namespace SEE.XR
{
Expand Down Expand Up @@ -63,41 +64,41 @@ public class RadialSelection : MonoBehaviour
public InputActionReference RadialMenuActionRef;

/// <summary>
/// All actions, which are currently available.
/// All actions which are currently available.
/// </summary>
List<string> actions = new();
private List<string> actions = new();

/// <summary>
/// Alle submenus and their entries.
/// All submenus and their entries.
/// </summary>
List<(string, List<string>)> subMenus = new();
private List<(string, List<string>)> subMenus = new();

/// <summary>
/// All entry of a submenu.
/// This list is used, to swap between the main-menu and sub-menus.
/// All entries of a submenu.
/// This list is used to swap between the main-menu and sub-menus.
/// The main menu contains all "main-actions" and the sub-menus more
/// specific sub-actions. We safe the main-actions here for the case,
/// specific sub-actions. We save the main-actions here for the case
/// that the user wants to go back to the main-menu.
/// </summary>
List<string> menuEntries = new();
private List<string> menuEntries = new();

/// <summary>
/// This is used for the rotate-action, because in this case we
/// have a dial, which is getting spawned, and should be despawned, when the action changes.
/// </summary>
GameObject actionObject;
private GameObject actionObject;

/// <summary>
/// The position of the submenu.
/// It should be the same, as the position from the mainmenu.
/// It should be the same as the position from the mainmenu.
/// </summary>
Vector3? subMenuPosition;
private Vector3? subMenuPosition;

/// <summary>
/// The rotation of the submenu.
/// It should be the same, as the rotation from the mainmenu.
/// It should be the same as the rotation from the mainmenu.
/// </summary>
Quaternion? subMenuRotation;
private Quaternion? subMenuRotation;

/// <summary>
/// The selected HideMode.
Expand Down Expand Up @@ -134,7 +135,7 @@ bool Visit(AbstractActionStateType child, AbstractActionStateType parent)
{
if (parent is ActionStateTypeGroup parentGroup)
{
var search = subMenus.FirstOrDefault(item => item.Item1 == parent.Name);
(string, List<string>) search = subMenus.FirstOrDefault(item => item.Item1 == parent.Name);
for (int i = 0; i < subMenus.Count; i++)
{
if (subMenus[i].Item1 == parent.Name && subMenus[i].Item2 == null)
Expand Down Expand Up @@ -167,10 +168,10 @@ bool Visit(AbstractActionStateType child, AbstractActionStateType parent)
/// <summary>
/// Whether the radial menu is open.
/// </summary>
bool radialMenuTrigger;
private bool radialMenuTrigger;

/// <summary>
/// This method gets called, when the button for the radial-menu is pressed.
/// This method gets called when the button for the radial-menu is pressed.
/// </summary>
/// <param name="context">Information provided to action callbacks about what triggered an action.</param>
private void RadialMenu(InputAction.CallbackContext context)
Expand Down Expand Up @@ -256,12 +257,12 @@ public void UpdateSelectedRadialPart()
/// <summary>
/// Is true if the radial menu is open.
/// </summary>
bool spawned;
private bool spawned;

/// <summary>
/// This list represents all hideActions.
/// </summary>
static List<string> hideActions = new()
private static List<string> hideActions = new()
{
"HideAll",
"HideSelected",
Expand Down Expand Up @@ -295,54 +296,9 @@ public void SelectAction(int i)
subMenuPosition = radialPartCanvas.position;
subMenuRotation = radialPartCanvas.rotation;
}
else if (actions[i] == "HideAll")
else if (Enum.TryParse(actions[i], out HideModeSelector mode))
{
HideMode = HideModeSelector.HideAll;
TriggerHideAction();
}
else if (actions[i] == "HideSelected")
{
HideMode = HideModeSelector.HideSelected;
TriggerHideAction();
}
else if (actions[i] == "HideUnselected")
{
HideMode = HideModeSelector.HideUnselected;
TriggerHideAction();
}
else if (actions[i] == "HideOutgoing")
{
HideMode = HideModeSelector.HideOutgoing;
TriggerHideAction();
}
else if (actions[i] == "HideIncoming")
{
HideMode = HideModeSelector.HideIncoming;
TriggerHideAction();
}
else if (actions[i] == "HideAllEdgesOfSelected")
{
HideMode = HideModeSelector.HideAllEdgesOfSelected;
TriggerHideAction();
}
else if (actions[i] == "HideForwardTransitiveClosure")
{
HideMode = HideModeSelector.HideForwardTransitiveClosure;
TriggerHideAction();
}
else if (actions[i] == "HideBackwardTransitiveClosure")
{
HideMode = HideModeSelector.HideBackwardTransitiveClosure;
TriggerHideAction();
}
else if (actions[i] == "HideAllTransitiveClosure")
{
HideMode = HideModeSelector.HideAllTransitiveClosure;
TriggerHideAction();
}
else if (actions[i] == "HighlightEdges")
{
HideMode = HideModeSelector.HighlightEdges;
HideMode = mode;
TriggerHideAction();
}
else
Expand Down
27 changes: 18 additions & 9 deletions Assets/SEE/XR/Rotator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private void Update()
if (ShouldGetHandRotation)
{
float rotationAngle = GetInteractorRotation();
GetRotationDistance(rotationAngle);
DetermineRotationDistance(rotationAngle);
}
}

Expand All @@ -117,7 +117,7 @@ private void Update()
/// Determines in which direction and how much the dial/node should be rotated.
/// </summary>
/// <param name="currentAngle">The current angle from the controller.</param>
private void GetRotationDistance(float currentAngle)
private void DetermineRotationDistance(float currentAngle)
{
if (!firstRotation)
{
Expand All @@ -126,11 +126,9 @@ private void GetRotationDistance(float currentAngle)
{
if (angleDifference > 270f)
{
float angleCheck;
if (startAngle < currentAngle)
{
angleCheck = CheckAngle(currentAngle, startAngle);
if (angleCheck < angleTolerance)
if (!CheckAngle(currentAngle, startAngle, angleTolerance))
{
return;
}
Expand All @@ -142,8 +140,7 @@ private void GetRotationDistance(float currentAngle)
}
else if (startAngle > currentAngle)
{
angleCheck = CheckAngle(currentAngle, startAngle);
if (angleCheck < angleTolerance)
if (!CheckAngle(currentAngle, startAngle, angleTolerance))
{
return;
}
Expand Down Expand Up @@ -176,12 +173,24 @@ private void GetRotationDistance(float currentAngle)
}

/// <summary>
/// Calculates the current rotation angle of the controller.
/// Checks if the rotation was significant enough (bigger than the angleTolerance).
/// If so, the selected object will be rotated, otherwise nothing will happen.
/// </summary>
/// <param name="currentAngle">The current angle of the controller.</param>
/// <param name="startAngle">The base angle.</param>
/// <param name="angleTolerance">The minimum angle, which needs to be reached to cause a rotation of the selected object.</param>
/// <returns>the amount of rotation</returns>
private float CheckAngle(float currentAngle, float startAngle) => (360f - currentAngle) + startAngle;
private bool CheckAngle(float currentAngle, float startAngle, float angleTolerance)
{
if (((360f - currentAngle) + startAngle) < angleTolerance)
{
return false;
}
else
{
return true;
}
}

/// <summary>
/// Rotates the dial/node clockwise.
Expand Down
14 changes: 7 additions & 7 deletions Assets/SEE/XR/XRSEEActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class XRSEEActions : MonoBehaviour
/// <summary>
/// The GameObject the user is currently hovering over.
/// </summary>
public static GameObject hoveredGameObject { get; private set; }
private static GameObject hoveredGameObject { get; set; }

/// <summary>
/// The old parent of a node. We need this for the MoveAction.
/// </summary>
public static Transform oldParent { get; set; }
public static Transform OldParent { get; set; }

/// <summary>
/// The button that's used for the primary actions.
Expand Down Expand Up @@ -76,7 +76,7 @@ private void Awake()
}

/// <summary>
/// This method gets called, when the user begins to hover over an interactable.
/// This method gets called when the user begins to hover over an interactable.
/// It provides the input data from the controller with regard to the start of a hover over an object in the CodeCity.
/// </summary>
/// <param name="args">Event data associated with the event when an Interactor first initiates hovering over an Interactable.</param>
Expand All @@ -86,7 +86,7 @@ public void OnHoverEnter(HoverEnterEventArgs args)
hoveredGameObject = args.interactableObject.transform.gameObject;
if (GlobalActionHistory.Current() == ActionStateTypes.Move)
{
oldParent = args.interactableObject.transform.parent;
OldParent = args.interactableObject.transform.parent;
}
if (hoveredGameObject.transform.TryGetComponent(out showLabel))
{
Expand Down Expand Up @@ -176,7 +176,7 @@ private void Action(InputAction.CallbackContext context)
}
}
Selected = true;
if (GlobalActionHistory.Current() != ActionStateTypes.Move)
if (GlobalActionHistory.Current() != ActionStateTypes.Move && GlobalActionHistory.Current() != ActionStateTypes.Delete)
{
SelectedFlag = true;
}
Expand All @@ -191,7 +191,7 @@ private void Action(InputAction.CallbackContext context)
/// <summary>
/// Whether the TreeView is open while the user tries to move a node.
/// We need to know if the user has the TreeView open, while moving a node,
/// because this can caus lags, which we prevent by closing the TreeView, befor
/// because this can cause lags, which we prevent by closing the TreeView before
/// the node gets moved.
/// </summary>
public static bool CloseTreeView { get; set; }
Expand Down Expand Up @@ -262,7 +262,7 @@ private void Undo(InputAction.CallbackContext context)
public static bool RedoToggle { get; set; }

/// <summary>
/// This method gets called, when the button for the redo-action is pressed.
/// This method gets called when the button for the redo-action is pressed.
/// It will redo the last action that was undone.
/// </summary>
/// <param name="context">Information provided to action callbacks about what triggered an action.</param>
Expand Down

0 comments on commit c7a9a0c

Please sign in to comment.