Пример #1
0
    public async void UpdateMenu()
    {
        DynamicContent.GetComponent <VerticalLayoutGroup>().enabled = true;
        ActionPointName.text = CurrentAction.ActionPoint.Data.Name;
        foreach (RectTransform o in DynamicContent.GetComponentsInChildren <RectTransform>())
        {
            if (o.name != "Layout" && o.gameObject.tag != "Persistent")
            {
                Destroy(o.gameObject);
            }
        }
        SetHeader(CurrentAction.Data.Name);
        ActionType.text = CurrentAction.ActionProvider.GetProviderName() + "/" + Base.Action.ParseActionType(CurrentAction.Data.Type).Item2;

        actionParameters = await Base.Action.InitParameters(CurrentAction.ActionProvider.GetProviderId(), CurrentAction.Parameters.Values.ToList(), DynamicContent, OnChangeParameterHandler, DynamicContentLayout, CanvasRoot);

        parametersChanged = false;
        SaveParametersBtn.SetInteractivity(false, "Parameters unchaged");
        UpdateExecuteAndStopBtns();
        Tuple <bool, string> actionRemovable = await GameManager.Instance.RemoveAction(CurrentAction.Data.Id, true);

        if (actionRemovable.Item1)
        {
            RemoveActionBtn.SetInteractivity(true);
        }
        else
        {
            RemoveActionBtn.SetInteractivity(false, actionRemovable.Item2);
        }
    }
Пример #2
0
    public async void SaveParameters()
    {
        if (Base.Action.CheckIfAllValuesValid(actionParameters))
        {
            List <IO.Swagger.Model.ActionParameter> parameters = new List <IO.Swagger.Model.ActionParameter>();
            foreach (IActionParameter actionParameter in actionParameters)
            {
                IO.Swagger.Model.ActionParameterMeta metadata = CurrentAction.Metadata.GetParamMetadata(actionParameter.GetName());
                IO.Swagger.Model.ActionParameter     ap       = new IO.Swagger.Model.ActionParameter(id: actionParameter.GetName(), value: JsonConvert.SerializeObject(actionParameter.GetValue()), type: metadata.Type);
                parameters.Add(ap);
            }
            bool success = await Base.GameManager.Instance.UpdateAction(CurrentAction.Data.Id, parameters);

            if (success)
            {
                Base.Notifications.Instance.ShowNotification("Parameters saved", "");
                SaveParametersBtn.SetInteractivity(false, "Parameters unchanged");
                parametersChanged = false;
                if (string.IsNullOrEmpty(GameManager.Instance.ExecutingAction))
                {
                    ExecuteActionBtn.SetInteractivity(true);
                }
            }
        }
    }
Пример #3
0
    public async void SaveParameters()
    {
        if (Base.Parameter.CheckIfAllValuesValid(actionParameters))
        {
            List <IO.Swagger.Model.ActionParameter> parameters = new List <IO.Swagger.Model.ActionParameter>();
            foreach (IParameter actionParameter in actionParameters)
            {
                IO.Swagger.Model.ParameterMeta   metadata = CurrentAction.Metadata.GetParamMetadata(actionParameter.GetName());
                IO.Swagger.Model.ActionParameter ap       = new IO.Swagger.Model.ActionParameter(name: actionParameter.GetName(), value: JsonConvert.SerializeObject(actionParameter.GetValue()), type: metadata.Type);
                parameters.Add(ap);
            }
            Debug.Assert(ProjectManager.Instance.AllowEdit);
            try {
                await WebsocketManager.Instance.UpdateAction(CurrentAction.Data.Id, parameters, CurrentAction.GetFlows());

                Base.Notifications.Instance.ShowToastMessage("Parameters saved");
                SaveParametersBtn.SetInteractivity(false, "Parameters unchanged");
                parametersChanged = false;
                if (string.IsNullOrEmpty(GameManager.Instance.ExecutingAction))
                {
                    ExecuteActionBtn.SetInteractivity(true);
                }
            } catch (RequestFailedException e) {
                Notifications.Instance.ShowNotification("Failed to update action ", e.Message);
            }
        }
    }
Пример #4
0
 protected override void UpdateSaveBtn()
 {
     if (SceneManager.Instance.SceneStarted)
     {
         SaveParametersBtn.SetInteractivity(false, "Parameters could be updated only when scene is stopped.");
         return;
     }
     if (!parametersChanged)
     {
         SaveParametersBtn.SetInteractivity(false, "No parameter changed");
         return;
     }
     // TODO: add dry run save
     SaveParametersBtn.SetInteractivity(true);
 }
Пример #5
0
 public void OnChangeParameterHandler(string parameterId, object newValue, bool isValueValid = true)
 {
     if (!isValueValid)
     {
         SaveParametersBtn.SetInteractivity(false, "Some parameter has invalid value");
         ExecuteActionBtn.SetInteractivity(false, "Save parameters first");
     }
     else if (CurrentAction.Parameters.TryGetValue(parameterId, out Base.ActionParameter actionParameter))
     {
         try {
             if (JsonConvert.SerializeObject(newValue) != actionParameter.Value)
             {
                 parametersChanged = true;
                 SaveParametersBtn.SetInteractivity(true);
                 ExecuteActionBtn.SetInteractivity(false, "Save parameters first");
             }
         } catch (JsonReaderException) {
             SaveParametersBtn.SetInteractivity(false, "Some parameter has invalid value");
             ExecuteActionBtn.SetInteractivity(false, "Save parameters first");
         }
     }
 }