Exemplo n.º 1
0
    protected async virtual Task UpdateBtns(InteractiveObject obj)
    {
        if (CanvasGroup.alpha == 0)
        {
            return;
        }
        UpdateRobotSelectorAndSteppingButtons();
        if (requestingObject || obj == null)
        {
            SelectedObjectText.text = "";
            MoveButton.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(no object selected)");
            MoveButton2.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(no object selected)");
            RemoveButton.SetInteractivity(false, $"{REMOVE_BTN_LABEL}\n(no object selected)");
            RenameButton.SetInteractivity(false, $"{RENAME_BTN_LABEL}\n(no object selected)");
            CalibrationButton.SetInteractivity(false, $"{CALIBRATION_BTN_LABEL}\n(no object selected)");
            OpenMenuButton.SetInteractivity(false, $"{OPEN_MENU_BTN_LABEL}\n(no object selected)");
        }
        else if (obj.IsLocked && obj.LockOwner != LandingScreen.Instance.GetUsername())
        {
            SelectedObjectText.text = obj.GetName() + "\n" + obj.GetObjectTypeName();
            MoveButton.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(object is used by {obj.LockOwner})");
            MoveButton2.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(object is used by {obj.LockOwner})");
            RemoveButton.SetInteractivity(false, $"{REMOVE_BTN_LABEL}\n(object is used by {obj.LockOwner})");
            RenameButton.SetInteractivity(false, $"{RENAME_BTN_LABEL}\n(object is used by {obj.LockOwner})");
            CalibrationButton.SetInteractivity(false, $"{CALIBRATION_BTN_LABEL}\n(object is used by {obj.LockOwner})");
            OpenMenuButton.SetInteractivity(false, $"{OPEN_MENU_BTN_LABEL}\n(object is used by {obj.LockOwner})");
        }
        else
        {
            SelectedObjectText.text = obj.GetName() + "\n" + obj.GetObjectTypeName();
            MoveButton.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(loading...)");
            MoveButton2.SetInteractivity(false, $"{MOVE_BTN_LABEL}\n(loading...)");
            RemoveButton.SetInteractivity(false, $"{REMOVE_BTN_LABEL}\n(loading...)");
            Task <RequestResult> tMove   = Task.Run(() => obj.Movable());
            Task <RequestResult> tRemove = Task.Run(() => obj.Removable());
            UpdateMoveAndRemoveBtns(selectedObject.GetId(), tMove, tRemove);

            RenameButton.SetInteractivity(obj.GetType() == typeof(ActionPoint3D) ||
                                          obj.GetType() == typeof(Action3D) || (obj.GetType().IsSubclassOf(typeof(ActionObject)) && !SceneManager.Instance.SceneStarted &&
                                                                                GameManager.Instance.GetGameState() == GameStateEnum.SceneEditor) ||
                                          obj.GetType() == typeof(APOrientation), $"{RENAME_BTN_LABEL}\n(selected object could not be renamed)");
            CalibrationButton.SetInteractivity(obj.GetType() == typeof(Recalibrate) ||
                                               obj.GetType() == typeof(CreateAnchor) || obj.GetType() == typeof(RecalibrateUsingServer), $"{CALIBRATION_BTN_LABEL}\n(selected object is not calibration cube)");
            if (obj is Action3D action)
            {
                OpenMenuButton.SetInteractivity(action.Parameters.Count > 0, "Open action parameters menu\n(action has no parameters)");
            }
            else
            {
                OpenMenuButton.SetInteractivity(obj.HasMenu(), $"{OPEN_MENU_BTN_LABEL}\n(selected object has no menu)");
            }
        }
    }
Exemplo n.º 2
0
    public void ValidateInput()
    {
        if (isNewObject)
        {
            ConfirmButton.SetInteractivity(true);
            return;
        }

        bool valid = ((string)nameInput.GetValue()) != selectedObject.GetName();

        ConfirmButton.SetInteractivity(valid, "Name has not been changed");
    }
Exemplo n.º 3
0
 public void UpdateSelectorItem(InteractiveObject interactiveObject)
 {
     if (SelectorItems.TryGetValue(interactiveObject.GetId(), out SelectorItem selectorItem))
     {
         selectorItem.Label.text = interactiveObject.GetName();
     }
 }
Exemplo n.º 4
0
    public async void Init(InteractiveObject objectToRename, UnityAction updateVisibilityCallback, bool isNewObject = false, UnityAction cancelCallback = null, UnityAction confirmCallback = null, bool keepObjectLocked = false)
    {
        if (objectToRename == null)
        {
            return;
        }
        if (!await objectToRename.WriteLock(false))
        {
            return;
        }

        this.isNewObject          = isNewObject;
        _updateVisibilityCallback = updateVisibilityCallback;
        selectedObject            = objectToRename;


        Title.text            = "Rename " + selectedObject.GetObjectTypeName();
        this.keepObjectLocked = keepObjectLocked;

        nameInput.SetValue(objectToRename.GetName());
        nameInput.SetLabel("Name", "New name");
        nameInput.SetType("string");
        CloseBtn.Button.onClick.RemoveAllListeners();
        CloseBtn.Button.onClick.AddListener(Cancel);
        if (cancelCallback != null)
        {
            CloseBtn.Button.onClick.AddListener(cancelCallback);
        }
        this.confirmCallback = confirmCallback;
    }
Exemplo n.º 5
0
    /*
     * protected void CloseProjectCallback(string nothing, string data) {
     *  CloseProjectResponse response = JsonConvert.DeserializeObject<CloseProjectResponse>(data);
     *  if (response.Messages != null) {
     *      CloseButton.SetInteractivity(response.Result, response.Messages.FirstOrDefault());
     *  } else {
     *      CloseButton.SetInteractivity(response.Result);
     *  }
     * }*/

    public override void CopyObjectClick()
    {
        InteractiveObject selectedObject = SelectorMenu.Instance.GetSelectedObject();

        if (selectedObject is null)
        {
            return;
        }
        if (selectedObject.GetType() == typeof(ActionPoint3D))
        {
            selectAPNameWhenCreated = selectedObject.GetName() + "_copy";
            WebsocketManager.Instance.CopyActionPoint(selectedObject.GetId(), null, selectedObject.GetName(), CopyActionPointCallback);
        }
        else if (selectedObject is Base.Action action)
        {
            ActionPickerMenu.Instance.DuplicateAction(action);
        }
    }
Exemplo n.º 6
0
    protected async override Task UpdateBtns(InteractiveObject obj)
    {
        try {
            if (CanvasGroup.alpha == 0)
            {
                return;
            }

            if (requestingObject || obj == null)
            {
                SelectedObjectText.text = "";
                OpenMenuButton.SetInteractivity(false, "No object selected");
                CalibrationButton.SetInteractivity(false, "No object selected");
            }
            else if (obj.IsLocked)
            {
                SelectedObjectText.text = obj.GetName() + "\n" + obj.GetObjectTypeName();
                OpenMenuButton.SetInteractivity(false, "Object is locked");
                CalibrationButton.SetInteractivity(false, "Object is locked");
            }
            else
            {
                SelectedObjectText.text = obj.GetName() + "\n" + obj.GetObjectTypeName();
                CalibrationButton.SetInteractivity(obj.GetType() == typeof(Recalibrate) ||
                                                   obj.GetType() == typeof(CreateAnchor) || obj.GetType() == typeof(RecalibrateUsingServer), "Selected object is not calibration cube");
                if (obj is Action3D action)
                {
                    OpenMenuButton.SetInteractivity(action.Parameters.Count > 0, "Action has no parameters");
                }
                else
                {
                    OpenMenuButton.SetInteractivity(obj.HasMenu(), "Selected object has no menu");
                }
            }
        } finally {
            previousUpdateDone = true;
        }
    }
Exemplo n.º 7
0
    public void RemoveClick()
    {
        InteractiveObject selectedObject = SelectorMenu.Instance.GetSelectedObject();

        if (selectedObject is null)
        {
            return;
        }

        SetActiveSubmenu(CurrentSubmenuOpened);
        ConfirmationDialog.Open($"Remove {selectedObject.GetObjectTypeName().ToLower()}",
                                $"Do you want to remove {selectedObject.GetName()}",
                                () => RemoveObject(selectedObject),
                                null);
    }
Exemplo n.º 8
0
    public SelectorItem CreateSelectorItem(InteractiveObject interactiveObject)
    {
        Debug.Assert(!string.IsNullOrEmpty(interactiveObject.GetId()));
        Debug.Assert(!SelectorItems.ContainsKey(interactiveObject.GetId()));

        SelectorItem selectorItem = Instantiate(SelectorItemPrefab).GetComponentInChildren <SelectorItem>();

        selectorItem.SublistContent.SetActive(false);
        if (interactiveObject is ISubItem subItem)
        {
            InteractiveObject parent = subItem.GetParentObject();
            if (parent != null && parent.SelectorItem != null)
            {
                selectorItem.transform.SetParent(parent.SelectorItem.SublistContent.transform);
                parent.SelectorItem.AddChild(selectorItem);
            }
            else
            {
                throw new RequestFailedException("Trying to create subitem without parent item in list. This should not had happened, please report");
            }
        }
        else
        {
            selectorItem.transform.SetParent(ContentAlphabet.transform);
        }
        selectorItem.CollapsableButton.interactable = false;
        //selectorItem.gameObject.SetActive(false);
        selectorItem.SetText(interactiveObject.GetName());
        selectorItem.SetObject(interactiveObject, 0, iteration);
        SelectorItems.Add(interactiveObject.GetId(), selectorItem);
        if (ContainerAlphabet.activeSelf && ((GameManager.Instance.GetGameState() == GameStateEnum.SceneEditor && SceneManager.Instance.Valid) ||
                                             (GameManager.Instance.GetGameState() == GameStateEnum.ProjectEditor && ProjectManager.Instance.Valid))) // only sort when project / scene is fully loaded
        {
            SwitchToAlphabet(false);
        }

        selectorItem.transform.localScale = Vector3.one;
        selectorItem.CollapsableButton.gameObject.SetActive(!ContainerAim.activeSelf);
        return(selectorItem);
    }
Exemplo n.º 9
0
    protected async override Task UpdateBtns(InteractiveObject obj)
    {
        try {
            if (CanvasGroup.alpha == 0)
            {
                previousUpdateDone = true;
                return;
            }

            await base.UpdateBtns(obj);

#if UNITY_ANDROID && AR_ON
            if (!CalibrationManager.Instance.Calibrated && !TrackingManager.Instance.IsDeviceTracking())
            {
                SetActionPointParentButton.SetInteractivity(false, $"{SET_ACTION_POINT_PARENT_LABEL}\n(AR not calibrated)");
                AddActionButton.SetInteractivity(false, $"{ADD_ACTION_LABEL}\n(AR not calibrated)");
                AddActionButton2.SetInteractivity(false, $"{ADD_ACTION_LABEL}\n(AR not calibrated)");
                AddConnectionButton.SetInteractivity(false, $"{ADD_CONNECTION_LABEL}\n(AR not calibrated)");
                AddConnectionButton2.SetInteractivity(false, $"{ADD_CONNECTION_LABEL}\n(AR not calibrated)");
                RunButton.SetInteractivity(false, $"{RUN_ACTION_OR_PACKAGE_LABEL}\n(AR not calibrated)");
                RunButton2.SetInteractivity(false, $"{RUN_ACTION_OR_PACKAGE_LABEL}\n(AR not calibrated)");
                AddActionPointButton.SetInteractivity(false, $"{ADD_ACTION_POINT_LABEL}\n(AR not calibrated)");
                AddActionPointButton2.SetInteractivity(false, $"{ADD_ACTION_POINT_LABEL}\n(AR not calibrated)");
                CopyButton.SetInteractivity(false, $"{COPY_LABEL}\n(AR not calibrated");
                ActionPointAimingMenuButton.SetInteractivity(false, $"{ACTION_POINT_AIMING_LABEL}\n(AR not calibrated)");
            }
            else
#endif
            if (requestingObject || obj == null)
            {
                SetActionPointParentButton.SetInteractivity(false, $"{SET_ACTION_POINT_PARENT_LABEL}\n(no action point is selected)");
                AddActionButton.SetInteractivity(false, $"{ADD_ACTION_LABEL}\n(no action point is selected)");
                AddActionButton2.SetInteractivity(false, $"{ADD_ACTION_LABEL}\n(no action point is selected)");
                AddConnectionButton.SetInteractivity(false, $"{ADD_CONNECTION_LABEL}\n(no input / output is selected)");
                AddConnectionButton2.SetInteractivity(false, $"{ADD_CONNECTION_LABEL}\n(no input / output is selected)");
                RunButton.SetInteractivity(false, $"{RUN_ACTION_OR_PACKAGE_LABEL}\n(select action to execute it or START to run project)");
                RunButton2.SetInteractivity(false, RunButton.GetAlternativeDescription());
                AddActionPointButton.SetInteractivity(true);
                AddActionPointButton2.SetInteractivity(true);
                AddActionPointButton.SetDescription(ADD_ACTION_POINT_GLOBAL_LABEL);
                AddActionPointButton2.SetDescription(ADD_ACTION_POINT_GLOBAL_LABEL);
                CopyButton.SetInteractivity(false, $"{COPY_LABEL}\n(no object to duplicate selected)");
                ActionPointAimingMenuButton.SetInteractivity(false, $"{ACTION_POINT_AIMING_LABEL}\n(no action point selected)");
                RunDebugButton.SetInteractivity(false, $"{RUN_DEBUG_OR_TRIGGER_BREAKPOINT_LABEL}\n(select action point to trigger breakpoint or START to run debug mode)");
            }
            else if (obj.IsLocked && obj.LockOwner != LandingScreen.Instance.GetUsername())
            {
                SetActionPointParentButton.SetInteractivity(false, $"{SET_ACTION_POINT_PARENT_LABEL}\n(object is used by {obj.LockOwner})");
                AddConnectionButton.SetInteractivity(false, $"{ADD_CONNECTION_LABEL}\n(object is used by {obj.LockOwner})");
                AddConnectionButton2.SetInteractivity(false, $"{ADD_CONNECTION_LABEL}\n(object is used by {obj.LockOwner})");
                RunButton.SetInteractivity(false, $"{RUN_ACTION_OR_PACKAGE_LABEL}\n(object is used by {obj.LockOwner})");
                RunButton2.SetInteractivity(false, $"{RUN_ACTION_OR_PACKAGE_LABEL}\n(object is used by {obj.LockOwner})");
                AddActionButton.SetInteractivity(false, $"{ADD_ACTION_POINT_LABEL}\n(object is used by {obj.LockOwner})");
                AddActionButton2.SetInteractivity(false, $"{ADD_ACTION_POINT_LABEL}\n(object is used by {obj.LockOwner})");
                CopyButton.SetInteractivity(false, $"{COPY_LABEL}\n(object is used by {obj.LockOwner})");
                ActionPointAimingMenuButton.SetInteractivity(false, $"{ACTION_POINT_AIMING_LABEL}\n(object is used by {obj.LockOwner})");
                RunDebugButton.SetInteractivity(false, $"{RUN_DEBUG_OR_TRIGGER_BREAKPOINT_LABEL}\n(object is used by {obj.LockOwner})");
            }
            else
            {
                RunDebugButton.SetInteractivity(false, $"{RUN_DEBUG_OR_TRIGGER_BREAKPOINT_LABEL}\n(select action point to trigger breakpoint or START to run debug mode)");
                SetActionPointParentButton.SetInteractivity(obj is ActionPoint3D, $"{SET_ACTION_POINT_PARENT_LABEL}\n(selected object is not action point)");
                if (obj is ActionPoint3D ap)
                {
                    AddActionButton.SetInteractivity(ProjectManager.Instance.AnyAvailableAction, $"{ADD_ACTION_LABEL}\n(no actions available)");
                    AddActionButton2.SetInteractivity(ProjectManager.Instance.AnyAvailableAction, $"{ADD_ACTION_LABEL}\n(no actions available)");
                    CopyButton.SetInteractivity(false, $"{COPY_LABEL}\n(checking...)");
                    WebsocketManager.Instance.CopyActionPoint(obj.GetId(), null, obj.GetName(), CopyActionPointDryRunCallback, true);
                    RunDebugButton.SetInteractivity(true);
                    RunDebugButton.SetDescription(ap.BreakPoint ? TRIGGER_BREAKPOINT_OFF_LABEL : TRIGGER_BREAKPOINT_ON_LABEL);
                }
                else
                {
                    AddActionButton.SetInteractivity(false, $"{ADD_ACTION_LABEL}\n(selected object is not action point)");
                    AddActionButton2.SetInteractivity(false, $"{ADD_ACTION_LABEL}\n(selected object is not action point)");
                    CopyButton.SetInteractivity(obj is Base.Action && !(obj is StartEndAction), $"{COPY_LABEL}\n(selected object cannot be duplicated)");
                }

                ActionPointAimingMenuButton.SetInteractivity(obj is ActionPoint3D || obj is APOrientation, $"{ACTION_POINT_AIMING_LABEL}\n(selected object is not action point or orientation)");
                if (obj is IActionPointParent)
                {
                    AddActionPointButton.SetDescription($"Add AP relative to {obj.GetName()}");
                    AddActionPointButton.SetInteractivity(true);
                }
                else
                {
                    AddActionPointButton.SetInteractivity(false, $"{ADD_ACTION_POINT_LABEL}\n(selected object could not be parent of AP");
                }
                AddActionPointButton2.SetInteractivity(AddActionPointButton.IsInteractive(), $"{ADD_ACTION_POINT_LABEL}\n({AddActionPointButton.GetAlternativeDescription()})");
                AddActionPointButton2.SetDescription(AddActionPointButton.GetDescription());

                if (!MainSettingsMenu.Instance.ConnectionsSwitch.IsOn())
                {
                    AddConnectionButton.SetInteractivity(false, $"{ADD_CONNECTION_LABEL}\n(connections are hidden)");
                    AddConnectionButton2.SetInteractivity(false, $"{ADD_CONNECTION_LABEL}\n(connections are hidden)");
                }
                else
                {
                    if (obj is Base.Action)
                    {
                        if (obj is EndAction)
                        {
                            AddConnectionButton.SetInteractivity(false, $"{ADD_CONNECTION_LABEL}\n(end action could not be connected to anything else)");
                        }
                        else
                        {
                            AddConnectionButton.SetInteractivity(true);
                        }
                        AddConnectionButton2.SetInteractivity(AddConnectionButton.IsInteractive(), AddConnectionButton.GetAlternativeDescription());
                    }
                }
                string runBtnInteractivity = null;

                if (obj.GetType() == typeof(Action3D))
                {
                    if (!SceneManager.Instance.SceneStarted)
                    {
                        runBtnInteractivity = "scene offline";
                    }
                    else if (!string.IsNullOrEmpty(GameManager.Instance.ExecutingAction))
                    {
                        string actionName = ProjectManager.Instance.GetAction(GameManager.Instance.ExecutingAction).GetName();
                        runBtnInteractivity = $"action '{actionName}' running";
                    }
                    RunButton.SetDescription(RUN_ACTION_LABEL);
                    RunButton2.SetDescription(RUN_ACTION_LABEL);
                    RunButton.SetInteractivity(string.IsNullOrEmpty(runBtnInteractivity), $"{RUN_ACTION_LABEL}\n({runBtnInteractivity})");
                    RunButton2.SetInteractivity(string.IsNullOrEmpty(runBtnInteractivity), $"{RUN_ACTION_LABEL}\n({runBtnInteractivity})");
                }
                else if (obj.GetType() == typeof(StartAction))
                {
                    if (!ProjectManager.Instance.ProjectMeta.HasLogic)
                    {
                        runBtnInteractivity = "project without logic could not be started from editor";
                    }
                    else if (ProjectManager.Instance.ProjectChanged)
                    {
                        runBtnInteractivity = "project has unsaved changes";
                    }
                    RunButton.SetDescription(RUN_TEMP_PACKAGE_LABEL);
                    RunButton2.SetDescription(RUN_TEMP_PACKAGE_LABEL);
                    RunDebugButton.SetDescription(RUN_DEBUG_LABEL);
                    RunButton.SetInteractivity(string.IsNullOrEmpty(runBtnInteractivity), $"{RUN_TEMP_PACKAGE_LABEL}\n({runBtnInteractivity})");
                    RunButton2.SetInteractivity(string.IsNullOrEmpty(runBtnInteractivity), $"{RUN_TEMP_PACKAGE_LABEL}\n({runBtnInteractivity})");
                    RunDebugButton.SetInteractivity(string.IsNullOrEmpty(runBtnInteractivity), $"{RUN_DEBUG_LABEL}\n({runBtnInteractivity})");
                }
                else
                {
                    runBtnInteractivity = "select action to execute it or START to run project";
                    RunButton.SetInteractivity(false, $"{RUN_ACTION_OR_PACKAGE_LABEL}\n({runBtnInteractivity})");
                    RunButton2.SetInteractivity(false, $"{RUN_ACTION_OR_PACKAGE_LABEL}\n({runBtnInteractivity})");
                }
            }

            if (!SceneManager.Instance.SceneStarted)
            {
                AddActionPointUsingRobotButton.SetInteractivity(false, $"{ADD_ACTION_POINT_USING_ROBOT_LABEL}\n(scene offline");
            }
            else
            {
                AddActionPointUsingRobotButton.SetInteractivity(true);
            }
        } finally {
            previousUpdateDone = true;
        }
    }