示例#1
0
        private async void Start()
        {
            // in case that the card was already setup, e.g. in the local instance => do not setup again
            if (issueDataDisplay.Content != null)
            {
                Debug.Log("Card was already setup");
                return;
            }

            if (photonView.CreatorActorNr == PhotonNetwork.LocalPlayer.ActorNumber)
            {
                Debug.Log("Card created by local player; will not set up");
                return;
            }

            int issueId;

            if (photonView.InstantiationData.Length == 1) // requirements bazaar => only id was sent
            {
                issueId = (int)photonView.InstantiationData[0];
                ApiResult <Issue> result = await RequirementsBazaar.GetRequirement(issueId);

                if (result.Successful)
                {
                    issueDataDisplay.Setup(result.Value);
                }
                else
                {
                    Debug.LogError("Card synchronizer could not fetch requirement with id " + issueId + ": " + result.ErrorMessage);
                }
            }
            else if (photonView.InstantiationData.Length == 2) // GitHub => id and project id was sent
            {
                issueId = (int)photonView.InstantiationData[0];
                int projectId            = (int)photonView.InstantiationData[1];
                ApiResult <Issue> result = await GitHub.GetIssue(projectId, issueId);

                if (result.Successful)
                {
                    issueDataDisplay.Setup(result.Value);
                }
                else
                {
                    Debug.LogError("Card synchronizer could not fetch GitHub issue of project "
                                   + projectId + " and id " + issueId + ": " + result.ErrorMessage);
                }
            }
            else
            {
                Debug.Log("Unexpected number of instantiation data on issue");
                return;
            }
        }
示例#2
0
        /// <summary>
        /// Deserializes the given SerializedObject and applies its values
        /// Expects the keys "source", "issueId", "projectId" in order to load the issue
        /// </summary>
        /// <param name="serializedObject">The SerializedObject with the save data</param>
        public async void Deserialize(SerializedObject serializedObject)
        {
            DataSource        source    = (DataSource)serializedObject.Integers[sourceKey];
            int               issueId   = serializedObject.Integers[issueIdKey];
            int               projectId = serializedObject.Integers[projectIdKey];
            Issue             issue     = null;
            ApiResult <Issue> res       = null;

            switch (source)
            {
            case DataSource.REQUIREMENTS_BAZAAR:
                res = await RequirementsBazaar.GetRequirement(issueId);

                break;

            case DataSource.GITHUB:
                res = await GitHub.GetIssue(projectId, issueId);

                break;
            }
            if (res != null && res.Successful)
            {
                issue = res.Value;
            }
            dataDisplay.Setup(issue);
        }
        /// <summary>
        /// If the user presses space, a request to the Requirements Bazaar is started
        /// </summary>
        private async void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                ApiResult <Issue> res = await RequirementsBazaar.GetRequirement(requirementId);

                if (res.Successful)
                {
                    dataDisplay.Setup(res.Value);
                }
                else
                {
                    Debug.LogError("Error fetching the requirement: (Code " + res.ResponseCode + ") " + res.ErrorMessage);
                    dataDisplay.Setup(null);
                }
            }
        }
示例#4
0
 /// <summary>
 /// Called if the issue has been edited from the issue shelf
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnIssueEdited(object sender, IssueEditedArgs e)
 {
     if (e.IssueID == issueDataDisplay.Content.Id)
     {
         Issue newIssue = new Issue(issueDataDisplay.Content.Source, issueDataDisplay.Content.Id, e.NewName, e.NewDescription, issueDataDisplay.Content.ProjectId, issueDataDisplay.Content.Creator, issueDataDisplay.Content.Status, issueDataDisplay.Content.CreationDateString, issueDataDisplay.Content.ClosedDateString, issueDataDisplay.Content.Developers, issueDataDisplay.Content.Commenters);
         issueDataDisplay.Setup(newIssue);
     }
 }
示例#5
0
        /// <summary>
        /// Called if the user starts a gesture on the object
        /// Creates a copy based on the given prefab and initializes the copy
        /// </summary>
        /// <param name="eventData">The event data of the gesture</param>
        public void OnPointerDown(MixedRealityPointerEventData eventData)
        {
            GameObject currentPointerTarget = eventData.Pointer.Result.CurrentPointerTarget;

            // only do this if we are out of selection mode, otherwise this is in conflict with the selection gesture
            if (!IssueSelectionManager.Instance.SelectionModeActive
                //clicking the edit or delete button shouldn't spawn a card
                && currentPointerTarget.GetComponent <EditButton>() == null && currentPointerTarget.GetComponent <DeleteButton>() == null)
            {
                // pass instantiation data to the copy so that other clients also know which issue is contained in the created copy
                object[] instantiationData;
                if (localDataDisplay.Content.Source == DataSource.REQUIREMENTS_BAZAAR)
                {
                    instantiationData = new object[1];
                }
                else if (localDataDisplay.Content.Source == DataSource.GITHUB)
                {
                    instantiationData    = new object[2];
                    instantiationData[1] = localDataDisplay.Content.ProjectId;
                }
                else
                {
                    Debug.LogError("Unexpected source: " + localDataDisplay.Content.Source, gameObject);
                    return;
                }

                instantiationData[0] = localDataDisplay.Content.Id; // same for ReqBaz and GitHub

                // create the copy, get the relevant components and set them up
                ResourceManager.Instance.SceneNetworkInstantiate(copyObject, transform.position, transform.rotation,
                                                                 (obj) =>
                {
                    copyInstance  = obj;
                    handlerOnCopy = copyInstance?.GetComponentInChildren <ObjectManipulator>();
                    IssueDataDisplay remoteDataDisplay = copyInstance?.GetComponent <IssueDataDisplay>();
                    if (handlerOnCopy == null || remoteDataDisplay == null)
                    {
                        if (handlerOnCopy == null)
                        {
                            SpecialDebugMessages.LogComponentNotFoundError(this, nameof(ObjectManipulator), copyInstance);
                        }
                        if (remoteDataDisplay == null)
                        {
                            SpecialDebugMessages.LogComponentNotFoundError(this, nameof(IssueDataDisplay), copyInstance);
                        }
                        PhotonNetwork.Destroy(copyInstance);
                    }
                    else
                    {
                        remoteDataDisplay.Setup(localDataDisplay.Content);
                        handlerOnCopy.OnPointerDown(eventData);
                    }
                },
                                                                 instantiationData);
            }
        }