예제 #1
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");
    }
    public async void CreateAction()
    {
        string newActionName = (string)nameInput.GetValue();

        if (Base.Parameter.CheckIfAllValuesValid(actionParameters))
        {
            List <IO.Swagger.Model.ActionParameter> parameters = new List <IO.Swagger.Model.ActionParameter>();
            foreach (IParameter actionParameter in actionParameters)
            {
                if (!actionParametersMetadata.TryGetValue(actionParameter.GetName(), out Base.ParameterMetadata actionParameterMetadata))
                {
                    Base.Notifications.Instance.ShowNotification("Failed to create new action", "Failed to get metadata for action parameter: " + actionParameter.GetName());
                    return;
                }
                IO.Swagger.Model.ActionParameter ap = new IO.Swagger.Model.ActionParameter(name: actionParameter.GetName(), value: JsonConvert.SerializeObject(actionParameter.GetValue()), type: actionParameterMetadata.Type);
                parameters.Add(ap);
            }
            try {
                await Base.WebsocketManager.Instance.AddAction(CurrentActionPoint.Data.Id, parameters, Base.Action.BuildActionType(
                                                                   actionProvider.GetProviderId(), actionMetadata.Name), newActionName, actionMetadata.GetFlows(newActionName));

                Close();
            } catch (Base.RequestFailedException e) {
                Base.Notifications.Instance.ShowNotification("Failed to add action", e.Message);
            }
        }
    }
예제 #3
0
    public async void CreateAction()
    {
        string newActionName = (string)nameInput.GetValue();

        if (Base.Action.CheckIfAllValuesValid(actionParameters))
        {
            List <IO.Swagger.Model.ActionParameter> parameters = new List <IO.Swagger.Model.ActionParameter>();
            foreach (IActionParameter actionParameter in actionParameters)
            {
                if (!actionParametersMetadata.TryGetValue(actionParameter.GetName(), out Base.ActionParameterMetadata actionParameterMetadata))
                {
                    Base.Notifications.Instance.ShowNotification("Failed to create new action", "Failed to get metadata for action parameter: " + actionParameter.GetName());
                    return;
                }
                IO.Swagger.Model.ActionParameter ap = new IO.Swagger.Model.ActionParameter(id: actionParameter.GetName(), value: JsonConvert.SerializeObject(actionParameter.GetValue()), type: actionParameterMetadata.Type);
                parameters.Add(ap);
            }
            bool success = await Base.GameManager.Instance.AddAction(CurrentActionPoint.Data.Id, parameters, Base.Action.BuildActionType(actionProvider.GetProviderId(), actionMetadata.Name), newActionName);

            if (success)
            {
                Close();
            }
        }
    }
예제 #4
0
    public async void CreateActionObject()
    {
        string newActionObjectName = (string)nameInput.GetValue();

        if (Base.Parameter.CheckIfAllValuesValid(actionParameters))
        {
            List <IO.Swagger.Model.Parameter> parameters = new List <IO.Swagger.Model.Parameter>();
            foreach (IParameter actionParameter in actionParameters)
            {
                if (!parametersMetadata.TryGetValue(actionParameter.GetName(), out Base.ParameterMetadata actionParameterMetadata))
                {
                    Base.Notifications.Instance.ShowNotification("Failed to create new action", "Failed to get metadata for action parameter: " + actionParameter.GetName());
                    return;
                }
                IO.Swagger.Model.ActionParameter ap = new IO.Swagger.Model.ActionParameter(name: actionParameter.GetName(), value: JsonConvert.SerializeObject(actionParameter.GetValue()), type: actionParameterMetadata.Type);
                parameters.Add(DataHelper.ActionParameterToParameter(ap));
            }
            try {
                IO.Swagger.Model.Pose pose = null;
                if (actionObjectMetadata.HasPose)
                {
                    Vector3 abovePoint = SceneManager.Instance.GetCollisionFreePointAbove(SceneManager.Instance.SceneOrigin.transform, actionObjectMetadata.GetModelBB(), SceneManager.Instance.SceneOrigin.transform.localRotation);
                    IO.Swagger.Model.Position offset = DataHelper.Vector3ToPosition(TransformConvertor.UnityToROS(abovePoint));
                    pose = new IO.Swagger.Model.Pose(position: offset, orientation: new IO.Swagger.Model.Orientation(1, 0, 0, 0));
                }
                await Base.WebsocketManager.Instance.AddObjectToScene(newActionObjectName, actionObjectMetadata.Type, pose, parameters);

                Close();
            } catch (Base.RequestFailedException e) {
                Base.Notifications.Instance.ShowNotification("Failed to add action", e.Message);
            }
        }
    }
예제 #5
0
    public async void NewProject()
    {
        string name = NewProjectName.GetValue()?.ToString();
        string sceneName;
        bool   generateLogic;

        try {
            sceneName = GetSelectedValue(ToggleGroup);
            string sceneId = Base.GameManager.Instance.GetSceneId(sceneName);
            generateLogic = GenerateLogicToggle.GetComponent <Toggle>().isOn;
            await Base.GameManager.Instance.NewProject(name, sceneId, generateLogic);

            Close();
        } catch (Exception ex) when(ex is Base.ItemNotFoundException || ex is Base.RequestFailedException)
        {
            Base.Notifications.Instance.ShowNotification("Failed to create new project", ex.Message);
        }
    }
예제 #6
0
    public async void ValidateInput()
    {
        bool valid = true;

        if (string.IsNullOrEmpty((string)nameInput.GetValue()))
        {
            ConfirmButton.SetInteractivity(false, "Name cannot be empty");
            valid = false;
        }
        else if (string.IsNullOrEmpty(valueInput.Input.text) && selectedType != ProjectParameterTypes.boolean)
        {
            ConfirmButton.SetInteractivity(false, "Value cannot be empty");
            valid = false;
        }

        if (!isNewConstant)
        {
            if (((string)nameInput.GetValue()) == projectParameter.Name && valueInput.Input.text == projectParameter.Value)    //known bug: always false when parameter's type is double or boolean
            {
                ConfirmButton.SetInteractivity(false, "Project parameter unchanged");
                valid = false;
            }
        }

        if (!valid)
        {
            return;
        }

        try {
            await Confirm(true);

            ConfirmButton.SetInteractivity(true);
        } catch (RequestFailedException e) {
            ConfirmButton.SetInteractivity(false, e.Message);
        }
    }
예제 #7
0
    public void OnValueChagned(string paramId)
    {
        if (pose == null)
        {
            return;
        }
        switch (paramId)
        {
        case "posX":
            pose.Position.X = (decimal)(double)posX.GetValue();
            break;

        case "posY":
            pose.Position.Y = (decimal)(double)posY.GetValue();
            break;

        case "posZ":
            pose.Position.Z = (decimal)(double)posZ.GetValue();
            break;

        case "orX":
            pose.Orientation.X = (decimal)(double)orX.GetValue();
            break;

        case "orY":
            pose.Orientation.Y = (decimal)(double)orY.GetValue();
            break;

        case "orZ":
            pose.Orientation.Z = (decimal)(double)orZ.GetValue();
            break;

        case "orW":
            pose.Orientation.W = (decimal)(double)orW.GetValue();
            break;
        }
        OnValueChangedEvent.Invoke(pose);
    }
예제 #8
0
    public async void CreateActionObject()
    {
        string newActionObjectName = (string)nameInput.GetValue();

        if (Base.Parameter.CheckIfAllValuesValid(actionParameters))
        {
            List <IO.Swagger.Model.Parameter> parameters = new List <IO.Swagger.Model.Parameter>();
            foreach (IParameter actionParameter in actionParameters)
            {
                if (!parametersMetadata.TryGetValue(actionParameter.GetName(), out Base.ParameterMetadata actionParameterMetadata))
                {
                    Base.Notifications.Instance.ShowNotification("Failed to create new action object", "Failed to get metadata for action object parameter: " + actionParameter.GetName());
                    return;
                }
                IO.Swagger.Model.ActionParameter ap = new IO.Swagger.Model.ActionParameter(name: actionParameter.GetName(), value: JsonConvert.SerializeObject(actionParameter.GetValue()), type: actionParameterMetadata.Type);
                parameters.Add(DataHelper.ActionParameterToParameter(ap));
            }
            try {
                Ray     ray   = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0f));
                Vector3 point = TransformConvertor.UnityToROS(GameManager.Instance.Scene.transform.InverseTransformPoint(ray.GetPoint(0.5f)));
                IO.Swagger.Model.Pose pose = null;
                if (actionObjectMetadata.HasPose)
                {
                    pose = new IO.Swagger.Model.Pose(position: DataHelper.Vector3ToPosition(point), orientation: DataHelper.QuaternionToOrientation(Quaternion.identity));
                }
                SceneManager.Instance.SelectCreatedActionObject = newActionObjectName;

                await Base.WebsocketManager.Instance.AddObjectToScene(newActionObjectName, actionObjectMetadata.Type, pose, parameters);

                callback?.Invoke();
                Close();
            } catch (Base.RequestFailedException e) {
                Base.Notifications.Instance.ShowNotification("Failed to add action", e.Message);
            }
        }
    }