示例#1
0
        //
        // Returns a list of review groups from the given server
        //
        public static ReviewGroup[] GetReviewGroups(string workingDirectory, string server, string username, string password, Logging logger)
        {
            // Build up the command
            string commandOptions = string.Format(@"api-get --server {0} /groups/", server);
            string rbtPath        = RB_Tools.Shared.Targets.Reviewboard.Path();

            // Update process
            logger.Log("Getting review groups");
            logger.Log("* Calling {0} {1}", rbtPath, commandOptions);

            // Run the process
            Process.Output output = Process.Start(workingDirectory, rbtPath, commandOptions);

            // Throw to return the error
            if (string.IsNullOrWhiteSpace(output.StdErr) == false)
            {
                logger.Log("Error encountered when getting review groups\n\n{0}", output.StdErr);
                throw new ApplicationException(output.StdErr);
            }

            // Get the list we'll add out review groups to
            var returnedGroups = new[] { new { display_name = "", name = "" } }.ToList();

            // Parse the results of the operation
            JObject        parsedJson = JObject.Parse(output.StdOut);
            IList <JToken> results    = parsedJson["groups"].Children().ToList();

            // Pull out our groups and put them in our list
            foreach (JToken result in results)
            {
                // Add it to the list
                var anonObject   = returnedGroups.ElementAt(0);
                var searchResult = JsonConvert.DeserializeAnonymousType(result.ToString(), anonObject);

                returnedGroups.Add(searchResult);
                logger.Log(" * Found group - {0} : {1}", searchResult.display_name, searchResult.name);
            }

            // Remove the dummy entry
            returnedGroups.RemoveAt(0);

            // Build up the list to return
            ReviewGroup[] groups = new ReviewGroup[returnedGroups.Count];
            for (int i = 0; i < groups.Length; ++i)
            {
                var thisGroup = returnedGroups.ElementAt(i);
                groups[i] = new ReviewGroup(thisGroup.display_name, thisGroup.name);
            }

            // Return the list of groups
            logger.Log(" * Found {0} groups", groups.Length);
            return(groups);
        }
示例#2
0
 /// <summary>
 /// Event handler triggered whenever the update action of the review group changes
 /// </summary>
 /// <param name="group">
 ///		Group whose update action changed.
 /// </param>
 private void OnGroupUpdateActionChanged(ReviewGroup group)
 {
     bool enabled = !(group.UpdateAction == UpdateAction.Replay ||
         (group.UpdateAction == UpdateAction.None && !EnableOnNone));
     foreach (Component c in Registry)
     {
         if (c.GetType().IsSubclassOf(typeof(Collider)))
             ;//((Collider)c).enabled = enabled;
         else if (c.GetType().IsSubclassOf(typeof(Behaviour)))
             ((Behaviour)c).enabled = enabled;
     }
 }
示例#3
0
        public List <double> GetRatingPercentages(List <Review> reviews)
        {
            var RatingPercentages =

                from Review in reviews
                group Review by Review.StarRating into ReviewGroup
                orderby ReviewGroup.Key
                select Math.Round(ReviewGroup.ToList().Count / (double)reviews.Count * 100.0, 0);

            List <double> Percentages = RatingPercentages.ToList();

            //If movie has no reviews for one or more ratingstars insert 0 value for missing ratingstar review
            //(to avoid displaying ratingpercentage at wrong ratingstar)
            //Add missing review(s) after linq query to avoid added review being taken in total percentage
            for (int i = 0; i < 5; i++)
            {
                if (!reviews.Exists(x => x.StarRating == i + 1))
                {
                    Percentages.Insert(i, 0);
                }
            }
            return(Percentages);
        }
示例#4
0
    /**
    * Called before the script's update methods are called for the first time,
    *	should be used to initialize the behavior.
    */
    private void Start()
    {
        // retrieve gui controls
        m_recordTimeline = GameObject.Find("RecordTimeline").GetComponent<AARRGuiProgressBar>();
        m_replayTimeline = GameObject.Find("ReplayTimeline").GetComponent<AARRGuiProgressBar>();

        m_recordButton = GameObject.Find("RecordButton").GetComponent<newRecordButton>();
        m_playButton = GameObject.Find("PlayButton").GetComponent<newPlayButton>();
        m_pauseButton = GameObject.Find("PauseButton").GetComponent<newPauseButton>();

        // set up review group
        m_group = ReviewSystem.Instance.GetGroup(GroupName);
        m_group.UpdateTrigger = UpdateTrigger.OnUpdate;

        // commenting this line as (version 1.0.745 does not support this)
        //m_group.PlaybackEvent += OnReplayFinished;

        // retrieve recorded objects
        m_player = GameObject.Find("Player");
        m_camera = GameObject.Find("Camera");

        // initiallly set the player to a disabled state
        SetPlayerEnabled(false);

        // set initial state
        SetReviewState(ReviewState.None);
    }