Exemple #1
0
 public static ResourceTransfer Start (Parts.Part fromPart, Parts.Part toPart, string resource, float maxAmount)
 {
     if (ReferenceEquals (fromPart, null))
         throw new ArgumentNullException ("fromPart");
     if (ReferenceEquals (toPart, null))
         throw new ArgumentNullException ("toPart");
     // Get the internal part objects
     var internalFromPart = fromPart.InternalPart;
     var internalToPart = toPart.InternalPart;
     // Check the parts are in the same vessel
     if (internalFromPart.vessel.id != internalToPart.vessel.id)
         throw new ArgumentException ("Parts are not on the same vessel");
     // Check the parts are different
     if (internalFromPart.flightID == internalToPart.flightID)
         throw new ArgumentException ("Source and destination parts are the same");
     // Get the resource info object
     if (!PartResourceLibrary.Instance.resourceDefinitions.Contains (resource))
         throw new ArgumentException ("Resource '" + resource + "' does not exist");
     var resourceInfo = PartResourceLibrary.Instance.GetDefinition (resource);
     // Check the parts contain the required resource
     if (internalFromPart.Resources.Get (resourceInfo.id) == null)
         throw new ArgumentException ("Source part does not contain '" + resource + "'");
     if (internalToPart.Resources.Get (resourceInfo.id) == null)
         throw new ArgumentException ("Destination part cannot store '" + resource + "'");
     // Create the resource transfer
     return new ResourceTransfer (internalFromPart, internalToPart, resourceInfo, maxAmount);
 }
        public static void ReadConfiguration(Parts.IActor actor, Kc.Chunk inputChunk)
        {
            Parts.IProperty[] properties = actor.Properties;

            foreach (Parts.IProperty p in properties)
            {
                ReadValue(inputChunk, p);
            }
        }
        public static void WriteConfiguration(Parts.IActor actor, Kc.Chunk outputChunk)
        {
            Parts.IProperty[] properties = actor.Properties;

            foreach (Parts.IProperty p in properties)
            {
                WriteValue(outputChunk, p);
            }
        }
 public static bool ReadValue(Kc.Chunk inputChunk,Parts.IProperty property )
 {
     if ( property.DefaultValue != null)
     {
         object valueObject = inputChunk.GetValueObject(property.Name, property.DefaultValue );
         property.CurrentValue = valueObject;
         return true;
     }
     return false;
 }
        public static bool WriteValue( Kc.Chunk outputChunk,Parts.IProperty property)
        {
            if ( property.CurrentValue != null)
            {
                outputChunk.SetValue(property.Name, property.CurrentValue );
                return true;
            }

            return false;
        }
    public void CanOnlyMapCorrespondingTypes()
    {
        var blob = new Parts("o/r1", TreeEntryTargetType.Blob, "b1", "a");
        var tree = new Parts("o/r1", TreeEntryTargetType.Tree, "b1", "c");

        var m = new Mapper();

        Assert.Throws<ArgumentException>(() => m.Add(blob, tree));
        Assert.Throws<ArgumentException>(() => m.Add(tree, blob));
    }
Exemple #7
0
	public float part2 = 8.5f; //Affects grip

	//Makes sure this script is a singleton
	void Awake()
	{
		//Check if instance already exists
		if (instance == null)
			instance = this;
		
		else if (instance != this)	
			//Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a Parts.
			Destroy(gameObject);    
		
		//Sets this to not be destroyed when reloading scene
		DontDestroyOnLoad(gameObject);
	}
Exemple #8
0
    public Mapper GetMapper(List<SyncItem> syncItems)
    {
        var mapper = new Mapper();

        foreach (var syncItem in syncItems)
        {
            var toPart = new Parts("Particular/" + Name, syncItem.Parts.Type, Branch, ApplyTargetPathTemplate(syncItem));

            mapper.Add(syncItem.Parts, toPart);
        }

        return mapper;
    }
    public void CanEscapeOutOfARootTree()
    {
        var parts = new Parts("Particular/NServiceBus", TreeEntryTargetType.Tree, "develop", null);

        Assert.AreEqual("Particular", parts.Owner);
        Assert.AreEqual("NServiceBus", parts.Repository);
        Assert.AreEqual(TreeEntryTargetType.Tree, parts.Type);
        Assert.AreEqual("develop", parts.Branch);
        Assert.AreEqual(null, parts.Path);
        Assert.AreEqual(0, parts.NumberOfPathSegments);
        Assert.AreEqual(null, parts.Name);
        Assert.AreEqual("https://github.com/Particular/NServiceBus/tree/develop", parts.Url);

        Assert.Throws<InvalidOperationException>(() => { var parent = parts.ParentTreePart; });
    }
 public static FlowLayoutPanel ComboBoxFlow(Parts.Attribute attribute, string[] items, ToolTip tooltip = null)
 {
     try
     {
         if (String.IsNullOrWhiteSpace(attribute.Name))
         {
             throw new ArgumentNullException();
         }
         var panel = Container(attribute);
         panel.SuspendLayout();
         panel.Controls.Add(Controls.ComboBox(attribute, items, tooltip));
         panel.ResumeLayout();
         return panel;
     }
     catch (Exception ex)
     {
         return null;
     }
 }
Exemple #11
0
    public void CanDetectBlobCreationWhenTargetTreeFolderDoesNotExist()
    {
        var sourceBlob = new Parts("Particular/SyncOMatic.TestRepository", TreeEntryTargetType.Blob, "blessed-source", "new-file.txt");
        var destinationBlob = new Parts("Particular/SyncOMatic.TestRepository", TreeEntryTargetType.Blob, "consumer-one", "IDoNotExist/MeNeither/new-file.txt");

        var map = new Mapper()
            .Add(sourceBlob, destinationBlob);

        Diff diff;
        using (var som = BuildSUT())
        {
            diff = som.Diff(map);
        }

        Assert.AreEqual(1, diff.Count());
        Assert.NotNull(diff.Single().Key.Sha);
        Assert.AreEqual(1, diff.Single().Value.Count());
        Assert.Null(diff.Single().Value.Single().Sha);
    }
Exemple #12
0
    public void CanDetectTreeCreation()
    {
        var sourceTree = new Parts("Particular/SyncOMatic.TestRepository", TreeEntryTargetType.Tree, "blessed-source", "folder/sub2");
        var destinationTree = new Parts("Particular/SyncOMatic.TestRepository", TreeEntryTargetType.Tree, "consumer-one", "folder/sub2");

        var map = new Mapper()
            .Add(sourceTree, destinationTree);

        Diff diff;
        using (var som = BuildSUT())
        {
            diff = som.Diff(map);
        }

        Assert.AreEqual(1, diff.Count());
        Assert.NotNull(diff.Single().Key.Sha);
        Assert.AreEqual(1, diff.Single().Value.Count());
        Assert.Null(diff.Single().Value.Single().Sha);
    }
        public static ComboBox ComboBox(Parts.Attribute attribute, string[] items, ToolTip tooltip = null)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(attribute.Name) || items.Length == 0)
                {
                    throw new ArgumentNullException();
                }
                var comboBox = new ComboBox();
                comboBox.SuspendLayout();
                comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
                comboBox.ForeColor = System.Drawing.Color.Black;
                comboBox.FlatStyle = FlatStyle.Flat;
                comboBox.Font = Methods.BaseFont;
                comboBox.FormattingEnabled = true;
                comboBox.Name = "cb" + attribute.Name;
                comboBox.Size = new System.Drawing.Size(121, 21);
                comboBox.Items.AddRange(items);
                comboBox.Tag = attribute;

                if (String.IsNullOrWhiteSpace(attribute.Value))
                {
                    comboBox.SelectedIndex = comboBox.Items.IndexOf(attribute.Default);
                }
                else
                {
                    comboBox.SelectedIndex = comboBox.Items.IndexOf(attribute.Value);
                }

                if (tooltip != null)
                {
                    tooltip.SetToolTip(comboBox, attribute.Documentation);
                }

                comboBox.ResumeLayout();
                return comboBox;
            }
            catch (Exception ex)
            {
                log.Debug(ex);
                return null;
            }
        }
Exemple #14
0
        void Add(Parts destination, Parts source, int level)
        {
            var s = destination.SegmentPartsByNestingLevel(level);

            if (destination.NumberOfPathSegments == level + 1)
            {
                var Leaf = new Tuple<Parts, Parts>(destination, source);
                LeavesToCreate.Add(s.Name, Leaf);
                return;
            }

            TargetTree sb;

            if (!SubTreesToUpdate.TryGetValue(s.Name, out sb))
            {
                sb = new TargetTree(s);
                SubTreesToUpdate.Add(s.Name, sb);
            }

            sb.Add(destination, source, ++level);
        }
    public void CanAddAndEnumerate()
    {
        var a = new Parts("o/r1", TreeEntryTargetType.Blob, "b1", "a");
        var c = new Parts("o/r1", TreeEntryTargetType.Tree, "b1", "c");

        var one = new Parts("o/r2", TreeEntryTargetType.Blob, "b1", "a");
        var two = new Parts("o/r3", TreeEntryTargetType.Blob, "b1", "a");
        var three = new Parts("o/r2", TreeEntryTargetType.Tree, "b1", "c");

        var m = new Mapper()
            .Add(a, one)
            .Add(a, two)
            .Add(c, three);

        Assert.AreEqual(2, m.Count());

        Assert.AreEqual(2, m[a].Count());
        Assert.AreEqual(1, m[c].Count());

        var b = new Uri("http://github.com/o/r1/blob/b1/b");
        Assert.AreEqual(0, m[b].Count());
    }
Exemple #16
0
    public void Tree()
    {
        var parts = new Parts("Particular/ServiceInsight", TreeEntryTargetType.Tree, "develop", "buildsupport");

        Assert.AreEqual("Particular", parts.Owner);
        Assert.AreEqual("ServiceInsight", parts.Repository);
        Assert.AreEqual(TreeEntryTargetType.Tree, parts.Type);
        Assert.AreEqual("develop", parts.Branch);
        Assert.AreEqual("buildsupport", parts.Path);
        Assert.AreEqual(1, parts.NumberOfPathSegments);
        Assert.AreEqual("buildsupport", parts.Name);
        Assert.AreEqual("https://github.com/Particular/ServiceInsight/tree/develop/buildsupport", parts.Url);

        var parent = parts.ParentTreePart;

        Assert.AreEqual("Particular", parent.Owner);
        Assert.AreEqual("ServiceInsight", parent.Repository);
        Assert.AreEqual(TreeEntryTargetType.Tree, parent.Type);
        Assert.AreEqual("develop", parent.Branch);
        Assert.AreEqual(null, parent.Path);
        Assert.AreEqual(0, parent.NumberOfPathSegments);
        Assert.AreEqual(null, parent.Name);
        Assert.AreEqual("https://github.com/Particular/ServiceInsight/tree/develop", parent.Url);
    }
Exemple #17
0
    public void Blob()
    {
        var parts = new Parts("Particular/NServiceBus", TreeEntryTargetType.Blob, "develop", "src/NServiceBus.sln.DotSettings");

        Assert.AreEqual("Particular", parts.Owner);
        Assert.AreEqual("NServiceBus", parts.Repository);
        Assert.AreEqual(TreeEntryTargetType.Blob, parts.Type);
        Assert.AreEqual("develop", parts.Branch);
        Assert.AreEqual("src/NServiceBus.sln.DotSettings", parts.Path);
        Assert.AreEqual(2, parts.NumberOfPathSegments);
        Assert.AreEqual("NServiceBus.sln.DotSettings", parts.Name);
        Assert.AreEqual("https://github.com/Particular/NServiceBus/blob/develop/src/NServiceBus.sln.DotSettings", parts.Url);

        var parent = parts.ParentTreePart;

        Assert.AreEqual("Particular", parent.Owner);
        Assert.AreEqual("NServiceBus", parent.Repository);
        Assert.AreEqual(TreeEntryTargetType.Tree, parent.Type);
        Assert.AreEqual("develop", parent.Branch);
        Assert.AreEqual("src", parent.Path);
        Assert.AreEqual(1, parent.NumberOfPathSegments);
        Assert.AreEqual("src", parent.Name);
        Assert.AreEqual("https://github.com/Particular/NServiceBus/tree/develop/src", parent.Url);
    }
        //This code layout aims to have the highest readability level possible. Dialogues are broken into tutorial stages and sections. Magic numbers correspond to the total sections listed above
        //in the StringConstants class.
        public void OnClickAction()
        {
            switch (this.currentTutorialStage) {
                default:
                case Parts.Error:
                    this.currentTutorialStage = Parts.Invalid;
                    Debug.LogError("Current tutorial state has hit error. It will be reset to Invalid state.");
                    break;
                case Parts.Invalid:
                    Debug.LogWarning("Current tutorial state has hit an invalid state. Please check.");
                    break;
                case Parts.Introduction:
                    this.dialogue = StringConstants.Values(this.currentTutorialStage, this.dialogueSectionCounter);
                    if (this.dialogueSectionCounter >= StringConstants.INTRODUCTION_SIZE) {
                        this.ReturnToSections();
                        break;
                    }
                    GameObject img = null;
                    //Image index 0 ~ 5: General Section
                    //ImageManager.Obtain() takes in image index as parameter, to display which specific image to show.
                    //Image index is determined at compile time, while placing images in the Unity editor.
                    switch (this.dialogueSectionCounter) {
                        case 1:
                            img = this.imageManager.Obtain(0);
                            img.SetActive(true);
                            break;
                        case 2:
                            img = this.imageManager.Obtain(0);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(1);
                            img.SetActive(true);
                            break;
                        case 3:
                            img = this.imageManager.Obtain(1);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(2);
                            img.SetActive(true);
                            break;
                        case 4:
                            img = this.imageManager.Obtain(2);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(5);
                            img.SetActive(true);
                            break;
                        case 5:
                            img = this.imageManager.Obtain(5);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(3);
                            img.SetActive(true);
                            break;
                        case 6:
                            img = this.imageManager.Obtain(3);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(4);
                            img.SetActive(true);
                            break;
                        case 7:
                            img = this.imageManager.Obtain(4);
                            img.SetActive(false);
                            break;
                        default:
                            for (int i = 0; i < this.imageManager.images.Count; i++) {
                                img = this.imageManager.Obtain(i);
                                img.SetActive(false);
                            }
                            break;
                    }
                    this.dialogueSectionCounter++;
                    break;
                //Image index 6 ~ 12: Attributes Editor
                case Parts.Attributes_Editor:
                    this.dialogue = StringConstants.Values(this.currentTutorialStage, this.dialogueSectionCounter);
                    if (this.dialogueSectionCounter >= StringConstants.ATTRIBUTES_EDITOR_SIZE) {
                        this.ReturnToSections();
                        break;
                    }
                    switch (this.dialogueSectionCounter) {
                        case 1:
                            img = this.imageManager.Obtain(6);
                            img.SetActive(true);
                            break;
                        case 2:
                            img = this.imageManager.Obtain(6);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(7);
                            img.SetActive(true);
                            break;
                        case 3:
                            img = this.imageManager.Obtain(8);
                            img.SetActive(true);
                            break;
                        case 4:
                            img = this.imageManager.Obtain(7);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(8);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(9);
                            img.SetActive(true);
                            break;
                        case 5:
                            img = this.imageManager.Obtain(9);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(10);
                            img.SetActive(true);
                            break;
                        case 6:
                            img = this.imageManager.Obtain(10);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(11);
                            img.SetActive(true);
                            break;
                        case 7:
                            img = this.imageManager.Obtain(11);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(12);
                            img.SetActive(true);
                            break;
                        case 10:
                            img = this.imageManager.Obtain(12);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(13);
                            img.SetActive(true);
                            break;
                        case 11:
                            img = this.imageManager.Obtain(13);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(14);
                            img.SetActive(true);
                            break;
                        case 12:
                            img = this.imageManager.Obtain(14);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(15);
                            img.SetActive(true);
                            break;
                        case 13:
                            img = this.imageManager.Obtain(15);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(16);
                            img.SetActive(true);
                            break;
                        case 14:
                            img = this.imageManager.Obtain(16);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(17);
                            img.SetActive(true);
                            break;
                        case 15:
                            img = this.imageManager.Obtain(17);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(18);
                            img.SetActive(true);
                            break;
                        case 18:
                            img = this.imageManager.Obtain(18);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(19);
                            img.SetActive(true);
                            break;
                        case 19:
                            img = this.imageManager.Obtain(19);
                            img.SetActive(false);
                            break;
                        default:
                            //for (int i = 0; i < this.imageManager.images.Count; i++) {
                            //	img = this.imageManager.Obtain(i);
                            //	img.SetActive(false);
                            //}
                            break;
                    }
                    this.dialogueSectionCounter++;
                    break;
                case Parts.Camera_Controls:
                    this.dialogue = StringConstants.Values(this.currentTutorialStage, this.dialogueSectionCounter);
                    if (this.dialogueSectionCounter >= StringConstants.CAMERA_CONTROLS_SIZE) {
                        this.ReturnToSections();
                        break;
                    }
                    switch (this.dialogueSectionCounter) {
                        case 1:
                            this.mainCameraPanning.enabled = true;
                            this.uiBorderPanel.gameObject.SetActive(true);
                            break;
                        case 2:
                            this.uiBorderPanel.gameObject.SetActive(false);
                            break;
                        case 3:
                            this.minimapCamera.enabled = true;
                            this.minimap.enabled = true;
                            break;
                        default:
                            for (int i = 0; i < this.imageManager.images.Count; i++) {
                                img = this.imageManager.Obtain(i);
                                img.SetActive(false);
                            }
                            break;
                    }
                    this.dialogueSectionCounter++;
                    break;
                case Parts.Unit_Controls:
                    this.dialogue = StringConstants.Values(this.currentTutorialStage, this.dialogueSectionCounter);
                    if (this.dialogueSectionCounter >= StringConstants.UNIT_CONTROLS_SIZE) {
                        //this.currentTutorialStage = Parts.Unit_Controls;
                        //this.dialogueSectionCounter = StringConstants.UNIT_CONTROLS_SIZE;
                        //this.isTutorialFinished = true;
                        //this.nextStepButton.interactable = false;
                        this.distanceUnitParent.gameObject.SetActive(false);
                        this.ReturnToSections();
                        break;
                    }
                    switch (this.dialogueSectionCounter) {
                        case 0:
                            this.tutorialUnit.gameObject.SetActive(true);
                            this.minimap.enabled = false;
                            this.minimapCamera.enabled = false;
                            this.mainCamera.transform.position = this.cameraOrigin;
                            this.Invoke("DelayTurnOffCameraPanning", 0.1f);
                            break;
                        case 3:
                            //Dragging selection box.
                            this.mainCursor.DragSelectionBox(this.mainCamera, this.GetNextPanning(), CursorButton.Left_Click, this, 3f, "DelayShowSelectionRing");
                            break;
                        case 5:
                            //Splitting
                            GameObject clone = MonoBehaviour.Instantiate(this.tutorialUnit.gameObject) as GameObject;
                            clone.SetActive(true);
                            clone.transform.SetParent(this.tutorialUnitParent);
                            this.splitMergeManager.splitGroupList.Add(new Group(this.tutorialUnit.gameObject, clone));

                            //Stop selecting the unit.
                            this.Invoke("DelayHideSelectionRing", 0.1f);
                            break;
                        case 8:
                            //Dragging selection box.
                            this.mainCursor.DragSelectionBox(this.mainCamera, this.GetNextPanning(), CursorButton.Left_Click, this, 3f, "DelayShowAllSelectionRings");
                            this.Invoke("DelayMergeUnits", 4f);
                            break;
                        case 12:
                            //TODO(Thompson): Show what a non-positive upgrade is for unit customization, via animation.
                            if (this.tutorialUnitParent != null) {
                                this.tutorialUnitParent.gameObject.SetActive(false);
                            }
                            if (this.nonPositiveUnitParent != null) {
                                this.nonPositiveUnitParent.gameObject.SetActive(true);
                            }
                            break;
                        case 14:
                            if (this.nonPositiveUnitParent != null) {
                                this.nonPositiveUnitParent.gameObject.SetActive(false);
                            }
                            break;
                        case 16:
                            //TODO(Thompson): Show how long the line of sight distance will be for LV1 unit and LV2 unit. Compare them via animation.
                            if (this.distanceUnitParent != null) {
                                this.distanceUnitParent.gameObject.SetActive(true);
                            }
                            break;
                        case 17:
                            if (this.distanceUnitParent != null) {
                                this.distanceUnitParent.gameObject.SetActive(false);
                            }
                            img = this.imageManager.Obtain(20);
                            img.SetActive(true);
                            break;
                        case 18:
                            img = this.imageManager.Obtain(20);
                            img.SetActive(false);
                            img = this.imageManager.Obtain(21);
                            img.SetActive(true);
                            break;
                        case 19:
                            img = this.imageManager.Obtain(21);
                            img.SetActive(false);
                            break;
                        default:
                            break;
                    }
                    this.dialogueSectionCounter++;
                    break;
            }
            this.dialogueText.text = "";
            this.stringLetterCounter = 0;
            this.startTextRollingFlag = true;
        }
Exemple #19
0
 public TargetTree(Parts root)
 {
     Current = root;
     SubTreesToUpdate = new Dictionary<string, TargetTree>();
     LeavesToCreate = new Dictionary<string, Tuple<Parts, Parts>>();
 }
Exemple #20
0
 public Stream OpenEntryStream()
 {
     return(new RarStream(Archive.Unpack, FileHeader,
                          new MultiVolumeReadOnlyStream(Parts.Cast <RarFilePart>(), Archive)));
 }
Exemple #21
0
 public void Add(Parts destination, Parts source)
 {
     Add(destination, source, 0);
 }
Exemple #22
0
 public void set(Transform tfm, Parts parts)
 {
     node_list_[(int)parts].set(tfm);
 }
 public void PrepareGeneralSection()
 {
     this.currentTutorialStage = Parts.Introduction;
     this.dialogueSectionCounter = 0;
     this.debugFlag = true;
     this.OnClickAction();
 }
 public void PrepareEditorSection()
 {
     this.currentTutorialStage = Parts.Attributes_Editor;
     this.dialogueSectionCounter = 0;
     this.debugFlag = true;
     this.OnClickAction();
 }
        /// <summary>
        /// Decompose an error or warning message into constituent parts. If the message isn't in the canonical form, return null.
        /// </summary>
        /// <remarks>This method is thread-safe, because the Regex class is thread-safe (per MSDN).</remarks>
        /// <owner>JomoF</owner>
        /// <param name="message"></param>
        /// <returns>Decomposed canonical message, or null.</returns>
        internal static Parts Parse(string message)
        {
            // An unusually long string causes pathologically slow Regex back-tracking.
            // To avoid that, only scan the first 400 characters. That's enough for 
            // the longest possible prefix: MAX_PATH, plus a huge subcategory string, and an error location.
            // After the regex is done, we can append the overflow.
            string messageOverflow = String.Empty;
            if (message.Length > 400)
            {
                messageOverflow = message.Substring(400);
                message = message.Substring(0, 400);
            }

            // If a tool has a large amount of output that isn't an error or warning (eg., "dir /s %hugetree%")
            // the regex below is slow. It's faster to pre-scan for "warning" and "error" 
            // and bail out if neither are present.
            if (message.IndexOf("warning", StringComparison.OrdinalIgnoreCase) == -1 &&
                message.IndexOf("error", StringComparison.OrdinalIgnoreCase) == -1)
            {
                return null;
            }

            Parts parsedMessage = new Parts();

            // First, split the message into three parts--Origin, Category, Code, Text.
            // Example,
            //      Main.cs(17,20):Command line warning CS0168: The variable 'foo' is declared but never used
            //      -------------- ------------ ------- ------  ----------------------------------------------
            //      Origin         SubCategory  Cat.    Code    Text
            // 
            // To accomodate absolute filenames in Origin, tolerate a colon in the second position
            // as long as its preceded by a letter.
            //
            // Localization Note:
            //  Even in foreign-language versions of tools, the category field needs to be in English.
            //  Also, if origin is a tool name, then that needs to be in English.
            //
            //  Here's an example from the Japanese version of CL.EXE:
            //   cl : ???? ??? warning D4024 : ?????????? 'AssemblyInfo.cs' ?????????????????? ???????????
            //
            //  Here's an example from the Japanese version of LINK.EXE:
            //   AssemblyInfo.cpp : fatal error LNK1106: ???????????? ??????????????: 0x6580 ??????????
            //
            Match match = s_originCategoryCodeTextExpression.Match(message);

            if (!match.Success)
            {
                // If no match here, then this message is not an error or warning.
                return null;
            }

            string origin = match.Groups["ORIGIN"].Value.Trim();
            string category = match.Groups["CATEGORY"].Value.Trim();
            parsedMessage.code = match.Groups["CODE"].Value.Trim();
            parsedMessage.text = (match.Groups["TEXT"].Value + messageOverflow).Trim();
            parsedMessage.subcategory = match.Groups["SUBCATEGORY"].Value.Trim();

            // Next, see if category is something that is recognized.
            if (0 == String.Compare(category, "error", StringComparison.OrdinalIgnoreCase))
            {
                parsedMessage.category = Parts.Category.Error;
            }
            else if (0 == String.Compare(category, "warning", StringComparison.OrdinalIgnoreCase))
            {
                parsedMessage.category = Parts.Category.Warning;
            }
            else
            {
                // Not an error\warning message.
                return null;
            }

            // Origin is not a simple file, but it still could be of the form,
            //  foo.cpp(location)
            match = s_filenameLocationFromOrigin.Match(origin);

            if (match.Success)
            {
                // The origin is in the form,
                //  foo.cpp(location)
                // Assume the filename exists, but don't verify it. What else could it be?
                string location = match.Groups["LOCATION"].Value.Trim();
                parsedMessage.origin = match.Groups["FILENAME"].Value.Trim();

                // Now, take apart the location. It can be one of these:
                //      loc:
                //      (line)
                //      (line-line)
                //      (line,col)
                //      (line,col-col)
                //      (line,col,len)
                //      (line,col,line,col)
                if (location.Length > 0)
                {
                    match = s_lineFromLocation.Match(location);
                    if (match.Success)
                    {
                        parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                    }
                    else
                    {
                        match = s_lineLineFromLocation.Match(location);
                        if (match.Success)
                        {
                            parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                            parsedMessage.endLine = ConvertToIntWithDefault(match.Groups["ENDLINE"].Value.Trim());
                        }
                        else
                        {
                            match = s_lineColFromLocation.Match(location);
                            if (match.Success)
                            {
                                parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                                parsedMessage.column = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim());
                            }
                            else
                            {
                                match = s_lineColColFromLocation.Match(location);
                                if (match.Success)
                                {
                                    parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                                    parsedMessage.column = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim());
                                    parsedMessage.endColumn = ConvertToIntWithDefault(match.Groups["ENDCOLUMN"].Value.Trim());
                                }
                                else
                                {
                                    match = s_lineColLineColFromLocation.Match(location);
                                    if (match.Success)
                                    {
                                        parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                                        parsedMessage.column = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim());
                                        parsedMessage.endLine = ConvertToIntWithDefault(match.Groups["ENDLINE"].Value.Trim());
                                        parsedMessage.endColumn = ConvertToIntWithDefault(match.Groups["ENDCOLUMN"].Value.Trim());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                // The origin does not fit the filename(location) pattern.
                parsedMessage.origin = origin;
            }

            return parsedMessage;
        }
Exemple #26
0
 public void fix(Parts parts, float interoplate_ratio)
 {
     node_list_[(int)parts].fixed_        = true;
     node_list_[(int)parts].spring_ratio_ = interoplate_ratio;
 }
Exemple #27
0
 public Node getNode(Parts parts)
 {
     return(node_list_[(int)parts]);
 }
Exemple #28
0
        public ComposedForm(string caption, Parts parts, Parts required)
        {
            InitializeComponent();
            this.Text = caption;
            int startHere = 0;

            Button okButton = new Button();
            int maxWidth = 2 * okButton.Width + 3 * spacing;

            //Add Name textbox
            if ((parts & Parts.Name) == Parts.Name) {
                Label label = new Label();
                label.Text = "Name:";
                label.Top = startHere + spacing;
                label.Left = spacing;
                label.Width = 70;
                label.TextAlign = ContentAlignment.MiddleRight;
                Controls.Add(label);
                nameTextBox = new TextBox();
                nameTextBox.Top = startHere + spacing;
                nameTextBox.Left = label.Right + spacing;

                if ((required & Parts.Name) == Parts.Name) {
                    AddNameChecker(s => !string.IsNullOrEmpty(s));
                }

                EventHandler nameCheckerHandler = (sender, args) => {
                    if (nameChecker == null) return;
                    foreach (Predicate<string> pred in nameChecker.GetInvocationList()) {
                        if (!pred(nameTextBox.Text)) {
                            okButton.Enabled = false;
                            return;
                        }
                        okButton.Enabled = true;
                    }
                };

                nameTextBox.TextChanged += nameCheckerHandler;

                nameCheckerHandler(this, new EventArgs());

                Controls.Add(nameTextBox);
                if ((nameTextBox.Right + spacing) > maxWidth) maxWidth = nameTextBox.Right + spacing;
                startHere = nameTextBox.Bottom + spacing;
            }

            //Add width and height controls
            if ((parts & Parts.Size) == Parts.Size) {
                Label label = new Label();
                label.Text = "Width:";
                label.Top = startHere + spacing;
                label.Left = spacing;
                label.Width = 70;
                label.TextAlign = ContentAlignment.MiddleRight;
                Controls.Add(label);
                widthNum = new NumericUpDown();
                widthNum.Minimum = 1;
                widthNum.Maximum = 99999;
                widthNum.Value = 1;
                widthNum.Top = startHere + spacing;
                widthNum.Left = label.Right + spacing;
                widthNum.Width = 70;
                Controls.Add(widthNum);
                label = new Label();
                label.Text = "Height:";
                label.Top = startHere + spacing;
                label.Left = widthNum.Right + spacing;
                label.Width = 70;
                label.TextAlign = ContentAlignment.MiddleRight;
                Controls.Add(label);
                heightNum = new NumericUpDown();
                heightNum.Minimum = 1;
                heightNum.Maximum = 99999;
                heightNum.Value = 1;
                heightNum.Top = startHere + spacing;
                heightNum.Left = label.Right + spacing;
                heightNum.Width = 70;
                Controls.Add(heightNum);
                if ((heightNum.Right + spacing) > maxWidth) maxWidth = heightNum.Right + spacing;
                startHere = heightNum.Bottom + spacing;
            }

            //Add a direction selector (up, down, left, right)
            if ((parts & Parts.Direction) == Parts.Direction) {
                Label label = new Label();
                label.Text = "Direction:";
                label.Top = startHere + spacing;
                label.Left = spacing;
                label.Width = 70;
                label.TextAlign = ContentAlignment.MiddleRight;
                Controls.Add(label);
                dirList = new ComboBox();
                dirList.Top = startHere + spacing;
                dirList.Left = label.Right + spacing;
                dirList.DropDownStyle = ComboBoxStyle.DropDownList;
                if ((required & Parts.Direction) != Parts.Direction) {
                    dirList.Items.Add("");
                }
                dirList.Items.AddRange(new string[] { "down", "up", "left", "right" });
                dirList.SelectedIndex = 0;
                Controls.Add(dirList);
                if ((dirList.Right + spacing) > maxWidth) maxWidth = dirList.Right + spacing;
                startHere = dirList.Bottom + spacing;
            }

            Button cancelButton = new Button();
            cancelButton.Text = "Cancel";
            cancelButton.DialogResult = DialogResult.Cancel;
            cancelButton.Top = startHere + spacing;
            cancelButton.Left = maxWidth - spacing - cancelButton.Width;
            Controls.Add(cancelButton);
            this.CancelButton = cancelButton;

            okButton.Text = "OK";
            okButton.DialogResult = DialogResult.OK;
            okButton.Top = startHere + spacing;
            okButton.Left = cancelButton.Left - spacing - okButton.Width;
            Controls.Add(okButton);
            this.AcceptButton = okButton;

            this.ClientSize = new Size(maxWidth, cancelButton.Bottom + spacing);
        }
Exemple #29
0
 public void setParams(Parts parts, float damper, float spring_ratio)
 {
     node_list_[(int)parts].setParams(damper, spring_ratio);
 }
        internal static Exception TryParse(string s, DurationType durationType, out XsdDuration result)
        {
            string errorCode;
            int    length;
            int    value, pos, numDigits;
            Parts  parts = Parts.HasNone;

            result = new XsdDuration();

            s      = s.Trim();
            length = s.Length;

            pos       = 0;
            numDigits = 0;

            if (pos >= length)
            {
                goto InvalidFormat;
            }

            if (s[pos] == '-')
            {
                pos++;
                result.nanoseconds = NegativeBit;
            }
            else
            {
                result.nanoseconds = 0;
            }

            if (pos >= length)
            {
                goto InvalidFormat;
            }

            if (s[pos++] != 'P')
            {
                goto InvalidFormat;
            }

            errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits);
            if (errorCode != null)
            {
                goto Error;
            }

            if (pos >= length)
            {
                goto InvalidFormat;
            }

            if (s[pos] == 'Y')
            {
                if (numDigits == 0)
                {
                    goto InvalidFormat;
                }

                parts       |= Parts.HasYears;
                result.years = value;
                if (++pos == length)
                {
                    goto Done;
                }

                errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits);
                if (errorCode != null)
                {
                    goto Error;
                }

                if (pos >= length)
                {
                    goto InvalidFormat;
                }
            }

            if (s[pos] == 'M')
            {
                if (numDigits == 0)
                {
                    goto InvalidFormat;
                }

                parts        |= Parts.HasMonths;
                result.months = value;
                if (++pos == length)
                {
                    goto Done;
                }

                errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits);
                if (errorCode != null)
                {
                    goto Error;
                }

                if (pos >= length)
                {
                    goto InvalidFormat;
                }
            }

            if (s[pos] == 'D')
            {
                if (numDigits == 0)
                {
                    goto InvalidFormat;
                }

                parts      |= Parts.HasDays;
                result.days = value;
                if (++pos == length)
                {
                    goto Done;
                }

                errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits);
                if (errorCode != null)
                {
                    goto Error;
                }

                if (pos >= length)
                {
                    goto InvalidFormat;
                }
            }

            if (s[pos] == 'T')
            {
                if (numDigits != 0)
                {
                    goto InvalidFormat;
                }

                pos++;
                errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits);
                if (errorCode != null)
                {
                    goto Error;
                }

                if (pos >= length)
                {
                    goto InvalidFormat;
                }

                if (s[pos] == 'H')
                {
                    if (numDigits == 0)
                    {
                        goto InvalidFormat;
                    }

                    parts       |= Parts.HasHours;
                    result.hours = value;
                    if (++pos == length)
                    {
                        goto Done;
                    }

                    errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits);
                    if (errorCode != null)
                    {
                        goto Error;
                    }

                    if (pos >= length)
                    {
                        goto InvalidFormat;
                    }
                }

                if (s[pos] == 'M')
                {
                    if (numDigits == 0)
                    {
                        goto InvalidFormat;
                    }

                    parts         |= Parts.HasMinutes;
                    result.minutes = value;
                    if (++pos == length)
                    {
                        goto Done;
                    }

                    errorCode = TryParseDigits(s, ref pos, false, out value, out numDigits);
                    if (errorCode != null)
                    {
                        goto Error;
                    }

                    if (pos >= length)
                    {
                        goto InvalidFormat;
                    }
                }

                if (s[pos] == '.')
                {
                    pos++;

                    parts         |= Parts.HasSeconds;
                    result.seconds = value;

                    errorCode = TryParseDigits(s, ref pos, true, out value, out numDigits);
                    if (errorCode != null)
                    {
                        goto Error;
                    }

                    if (numDigits == 0)   //If there are no digits after the decimal point, assume 0
                    {
                        value = 0;
                    }
                    // Normalize to nanosecond intervals
                    for (; numDigits > 9; numDigits--)
                    {
                        value /= 10;
                    }

                    for (; numDigits < 9; numDigits++)
                    {
                        value *= 10;
                    }

                    result.nanoseconds |= (uint)value;

                    if (pos >= length)
                    {
                        goto InvalidFormat;
                    }

                    if (s[pos] != 'S')
                    {
                        goto InvalidFormat;
                    }
                    if (++pos == length)
                    {
                        goto Done;
                    }
                }
                else if (s[pos] == 'S')
                {
                    if (numDigits == 0)
                    {
                        goto InvalidFormat;
                    }

                    parts         |= Parts.HasSeconds;
                    result.seconds = value;
                    if (++pos == length)
                    {
                        goto Done;
                    }
                }
            }

            // Duration cannot end with digits
            if (numDigits != 0)
            {
                goto InvalidFormat;
            }

            // No further characters are allowed
            if (pos != length)
            {
                goto InvalidFormat;
            }

Done:
            // At least one part must be defined
            if (parts == Parts.HasNone)
            {
                goto InvalidFormat;
            }

            if (durationType == DurationType.DayTimeDuration)
            {
                if ((parts & (Parts.HasYears | Parts.HasMonths)) != 0)
                {
                    goto InvalidFormat;
                }
            }
            else if (durationType == DurationType.YearMonthDuration)
            {
                if ((parts & ~(XsdDuration.Parts.HasYears | XsdDuration.Parts.HasMonths)) != 0)
                {
                    goto InvalidFormat;
                }
            }
            return(null);

InvalidFormat:
            return(new FormatException(Res.GetString(Res.XmlConvert_BadFormat, s, durationType)));

Error:
            return(new OverflowException(Res.GetString(Res.XmlConvert_Overflow, s, durationType)));
        }
 public static string Values(Parts parts, int section)
 {
     switch (parts) {
         case Parts.Introduction:
             switch (section) {
                 case 0:
                     return "Hello there. Welcome to the general introduction for Multiplier, a simulation tool that tweaks game balance, and a real-time strategy game built into this tool.";
                 case 1:
                     return "The premise of the real-time strategy game, made for this tool, is about managing your units by splitting and merging units to create more powerful units, and destroy your opponent's units!";
                 case 2:
                     return "There are 4 simple concepts: Your units are expendable resources. Splitting is to build up your resources for merging. Merging is to upgrade your units to higher levels. When you have no more units, the session ends!";
                 case 3:
                     return "Each concept is important to understand the balance of the game, such as resource management, game unit properties, and other aspects. To see them in action, you can check out the simulation tool provided, and tweak the variables using the Attributes Editor.";
                 case 4:
                     return "With the editor, your units and their attributes will use the leveling rates determined by math equations as results. This simplifies the process of tweaking that is usually done in Excel spreadsheets, and be able to see the immediate results.";
                 case 5:
                     return "You can customize your unit's leveling rates by either selecting the preset default difficulty settings, or choosing the Custom preset.";
                 case 6:
                     return "If you choose the Custom preset, you can then enter a math equation in the input field shown, and the resulting answers will update the leveling rates.";
                 case 7:
                     return "You can decide how weak or powerful your units will be through the use of the Attributes Editor. Creating your balanced units, or really broken units. The sky's the limit!";
                 case 8:
                     return "EMPTY LINE, DO NOT READ";
             }
             break;
         case Parts.Attributes_Editor:
             switch (section) {
                 case 0:
                     return "This lesson is about the Attributes Editor. Here's an overview of what the Attributes Editor looks like, shown below. We'll do a quick rundown of how to control this beast.";
                 case 1:
                     return "When in Versus A.I., Multiplayer, or Simulation Mode, press ESCAPE key to open up the menu if you wished to return to the Main Menu screen.";
                 case 2:
                     return "There are two areas in the Attributes Editor, the Player Configuration Area, and the A.I. Configuration Area.";
                 case 3:
                     return "We'll start with the Player Configuration Area, which is the top part of the Attributes Editor, shown below.";
                 case 4:
                     return "Located at the top is the Presets, or pre-configured defaults the editor has provided you with.";
                 case 5:
                     return "The presets are labeled as simple math equations. They determine the leveling rates of all unit attributes of a unit. The 'Health Heavy' preset means the units will have more health, but less overall stats, which is useful for testing realistic situations.";
                 case 6:
                     return "Speaking of the 'Custom' option in the Presets downdown, this option enables more functionalities of the editor, allowing you to fully customize your unit attributes.";
                 case 7:
                     return "When the preset is set to 'Custom', you will see the Equation Input Field, located at the bottom, is now active. You type the equations in there.";
                 case 8:
                     return "In the equation field, it is okay to type numbers or math equations starting with 'y='. If you input something wrong, it will report back '[Invalid Token]'.";
                 case 9:
                     return "When a correct math equation is entered, the Leveling Rates, above the Equation Input Field, will update all the leveling rates based on your equations. For example, y is equal to 42. Therefore, for each level, the Leveling Rate is 42.";
                 case 10:
                     return "The table below shows what symbols can be typed, which is used in the Equation Input Field. The editor will then read the equation and display the results to each Leveling Rates.";
                 case 11:
                     return "Going back up, the Category toggles allow you to specify which unit attribute you want to modify. As an example shown below, Health is selected, meaning the equation will only modify all Health points leveling rates.";
                 case 12:
                     return "The Leveling Rates shows what unit attributes per level will be applied to your unit. For example, a Level 3 unit will have the Level 3 leveling rates for each attributes, a Level 6 unit will have Level 6 leveling rates, and so on.";
                 case 13:
                     return "Now, this next area, shown below, is the A.I. Configuration Area, where you can customize the A.I. player's units. Because this area is similar to the Player Configuration Area, we'll only introduce the Mode Selection.";
                 case 14:
                     return "This is the Mode Selection. You can choose to leave the A.I. as Default pre-configurations, or use Custom configurations, which will enable the rest of the editor. Difficulty only affects the A.I. player's execution speed.";
                 case 15:
                     return "We now introduce to you the \"Simulation Editor\". Purpose is to run simulations to find if your math equations are balanced for use, especially since the high-level algorithms to determine unit properties can be applied elsewhere outside of this tool.";
                 case 16:
                     return "As shown, you have the Yellow Team and the Blue Team, each with their own Leaderboards. You also have the editor at the bottom, and the session counter in between the Leaderboards. The numbers on the Leaderboards are updated in real-time as the simulations are running.";
                 case 17:
                     return "The bottom editor is very much the same in other modes, with the only difference is the Categories are placed to the right of the Equation Input Field, and are lined up in the same order to save space.";
                 case 18:
                     return "The final part of this tutorial section is the Main Control Panel. You edit the unit attributes of either the Yellow Team or the Blue Team here. \"Generate Report\" is used for logging the statistics of your simulations, as well as your testing sessions. Copy and paste the report somewhere safe!";
                 case 19:
                     return "That is it for this lesson.";
                 case 20:
                     return "EMPTY STRING. PLEASE IGNORE!";
             }
             break;
         case Parts.Camera_Controls:
             switch (section) {
                 case 0:
                     return "This lesson is about Camera Controls, teaching you the basics of moving around the camera when you are playtesting your units against A.I or with human players.";
                 case 1:
                     return "Move your mouse to the edge of the screen boundaries (near the flashing red borders). When you put your mouse at the edge of where you wished to go, the camera will move in that general direction.";
                 case 2:
                     return "You can also move the camera around using the Arrow Keys.";
                 case 3:
                     return "Another method of moving the camera is by using the minimap shown in the lower right screen. Click and drag in the minimap at the lower right of your screen to move the camera around.";
                 case 4:
                     return "This method of control is best suited for quickly panning the camera to where you want to see.";
                 case 5:
                     return "EMPTY LINE, NOTHING OF VALUE IS LOST.";
             }
             break;
         case Parts.Unit_Controls:
             switch (section) {
                 case 0:
                     return "This lesson is about teaching you how to play the real-time strategy game built into this tool. The game unit, Capsule, named for its shape, has a team color painted at the top.";
                 case 1:
                     return "Capsules in the game can be interacted with the mouse and the keyboard. We'll start off with showing what the Capsules can do with the mouse.";
                 case 2:
                     return "The following animation shows what happens when the player controls the mouse, and drag a selection box on the Capsule. (Blue marker is left mouse button click.)";
                 case 3:
                     return "The Capsule will indicate that it has been selected. You can tell by seeing a green selection ring surrounding your selected unit.";
                 case 4:
                     return "Once the Capsule is selected, you may press the \"S\" key on your keyboard to initiate the \"Split\" command. This is what happens.";
                 case 5:
                     return "When a Capsule is split, each new capsule retains all of the unit attributes of the original capsule. The Capsule cannot fight and be controlled while splitting.";
                 case 6:
                     return "The Capsule can also merge with other split Capsules. This can be done using the \"D\" key.";
                 case 7:
                     return "The following animation shows that Capsules can merge to form a stronger unit by selecting and commanding the units with the \"D\" key. This is essentially \"upgrading\" the 2 Capsules to 1 higher-tiered Capsule.";
                 case 8:
                     return "Note that merged Capsules can no longer be split.";
                 case 9:
                     return "As you can see, a higher-tiered Capsule is bigger than it was before the merge.";
                 case 10:
                     return "However, be aware that unit attributes may not correlate with the tiers, since the tool allows you to customize your unit attributes. Your customizations may not always give a net positive upgrade.";
                 case 11:
                     return "The following animation sequence shows what a non-positive upgrade will look like for the unit attribute, \"Speed\", according to the given mathematical equation. You will normally see this when customizing your unit attributes.";
                 case 12:
                     return "The higher the tier level of a Capsule, the less speed it moves from one side to the other.";
                 case 13:
                     return "The speeds of the Capsules are inversely proportional to their tier levels. This is called a non-positive upgrade, in which your unit attributes are nerfed the higher up the tier levels.";
                 case 14:
                     return "Capsules attack automatically if a nearby enemy Capsule is close enough. There is no need for interactions to attack.";
                 case 15:
                     return "How close enough is \"close enough\"? Imagine the diameter of your selected Capsule is 1 unit. You will need 3 units to detect an enemy nearby, and 1 unit to attack the enemy. The following animation will explain this more clearly.";
                 case 16:
                     return "The red colored Capsules are your units. The gray colored Capsules are used to measure the distance. By lining up the gray colored Capsules, you can see how long \"close enough\" really is. Also, the higher the tier level, the longer the distance will be.";
                 case 17:
                     return "When a unit is taking damage from an enemy attack, it will flare up as red, as shown below.";
                 case 18:
                     return "Once the unit takes damage, you can see its health points decreasing. The left number represents the current health points, and the right number represents full health points.";
                 case 19:
                     return "That is it for Unit Controls. Go, have fun, and experiment!";
                 case 20:
                     return "EMPTY LINE, STOP READING ME!";
             }
             break;
     }
     return "";
 }
Exemple #32
0
 public void addParts(Parts parts)
 {
 }
 public void PrepareCameraSection()
 {
     this.currentTutorialStage = Parts.Camera_Controls;
     this.dialogueSectionCounter = 0;
     this.debugFlag = true;
     this.OnClickAction();
 }
Exemple #34
0
 public virtual Stream OpenEntryStream()
 {
     return(Parts.Single().GetCompressedStream());
 }
 public void PrepareGameplaySection()
 {
     this.currentTutorialStage = Parts.Unit_Controls;
     this.dialogueSectionCounter = 0;
     this.debugFlag = false;
     this.OnClickAction();
 }
        public IEnumerable <FluentRouteSetter> GetFluentRouteSetters()
        {
            var setters = new List <FluentRouteSetter>();

            if (!Parts.Any())
            {
                return(setters);
            }

            var alwaysGenerate = new[] { "index" };
            var parts          = Parts
                                 .Where(p => !p.Required || alwaysGenerate.Contains(p.Name))
                                 .Where(p => !string.IsNullOrEmpty(p.Name))
                                 .ToList();
            var returnType = CsharpNames.GenericOrNonGenericDescriptorName;

            foreach (var part in parts)
            {
                var p         = part;
                var paramName = p.Name.ToPascalCase();
                if (paramName.Length > 1)
                {
                    paramName = paramName.Substring(0, 1).ToLowerInvariant() + paramName.Substring(1);
                }
                else
                {
                    paramName = paramName.ToLowerInvariant();
                }

                var routeValue  = "v";
                var routeSetter = p.Required ? "Required" : "Optional";

                var code =
                    $"public {returnType} {p.InterfaceName}({p.HighLevelTypeName} {paramName}) => Assign({paramName}, (a,v)=>a.RouteValues.{routeSetter}(\"{p.Name}\", {routeValue}));";
                var xmlDoc = $"///<summary>{p.Description}</summary>";
                setters.Add(new FluentRouteSetter {
                    Code = code, XmlDoc = xmlDoc
                });
                if (paramName == "index")
                {
                    code   = $"public {returnType} {p.InterfaceName}<TOther>() where TOther : class ";
                    code  += $"=> Assign(typeof(TOther), (a,v)=>a.RouteValues.{routeSetter}(\"{p.Name}\", ({p.HighLevelTypeName})v));";
                    xmlDoc = $"///<summary>a shortcut into calling {p.InterfaceName}(typeof(TOther))</summary>";
                    setters.Add(new FluentRouteSetter {
                        Code = code, XmlDoc = xmlDoc
                    });
                }
                if (paramName == "index" && p.Type == "list")
                {
                    code   = $"public {returnType} AllIndices() => Index(Indices.All);";
                    xmlDoc = $"///<summary>A shortcut into calling Index(Indices.All)</summary>";
                    setters.Add(new FluentRouteSetter {
                        Code = code, XmlDoc = xmlDoc
                    });
                }
                if (paramName == "fields" && p.Type == "list")
                {
                    code   = $"public {returnType} Fields<T>(params Expression<Func<T, object>>[] fields) ";
                    code  += $"=> Assign(fields, (a,v)=>a.RouteValues.{routeSetter}(\"fields\", (Fields)v));";
                    xmlDoc = $"///<summary>{p.Description}</summary>";
                    setters.Add(new FluentRouteSetter {
                        Code = code, XmlDoc = xmlDoc
                    });
                }
            }
            return(setters);
        }
        public void Start()
        {
            TutorialAIManager.Instance = this;

            this.isInitialized = false;

            this.isTutorialFinished = false;
            this.delay = 0f;
            this.delayInterval = 0f;
            this.dialogueSectionCounter = 0;
            this.currentTutorialStage = Parts.Introduction;
            this.dialogue = StringConstants.Values(this.currentTutorialStage, this.dialogueSectionCounter);
            this.dialogueSectionCounter++;
            this.stringLetterCounter = 0;
            this.startTextRollingFlag = true;
            if (this.dialogueText != null) {
                this.dialogueText.text = "";
            }
            if (this.mainCamera == null) {
                Debug.LogError("Cannot obtain main camera. Please check.");
            }
            this.cameraOrigin = this.mainCamera.transform.position;

            this.mainCameraPanning = this.mainCamera.GetComponent<CameraPanning>();
            if (this.mainCameraPanning != null) {
                this.mainCameraPanning.enabled = false;
            }
            this.minimapCamera = this.minimap.GetComponent<Camera>();
            if (this.minimapCamera != null) {
                this.minimapCamera.enabled = false;
            }
            if (this.minimap == null) {
                Debug.LogError("Couldn't obtain minimap stuffs. Please check.");
            }
            if (this.nextStepButton == null) {
                Debug.LogError("The next button isn't set.");
            }
            if (this.dialogueText == null) {
                Debug.LogError("Dialogue text field is not bind to this variable.");
            }
            if (this.tutorialSections == null) {
                Debug.LogError("Tutorial sections are not set.");
            }
            if (this.dialogueBox == null) {
                Debug.LogError("Dialogue box not set.");
            }

            //Cursor setup
            GameObject obj = MonoBehaviour.Instantiate(this.cursorPrefab) as GameObject;
            obj.transform.SetParent(this.mainCanvas.transform);
            this.mainCursor = obj.GetComponent<Cursor>();
            if (this.mainCursor == null) {
                Debug.LogError("Cursor isn't obtained. Please check.");
            }

            InitializeCursorPanGroups();
            InitializeTutorial();
        }
Exemple #38
0
        /// <summary>
        /// Generates the datas.
        /// </summary>
        public override void GenerateDatas()
        {
            BubblePoints.Clear();
            if (!IsPointsGenerated)
            {
                Parts.Clear();
            }
            Point endPoint   = new Point(0, 0);
            Point startPoint = new Point(0, 0);

            if (PointsSource != null)
            {
                SizeValues = this.GetReflectionValues(this.SizePath, PointsSource, SizeValues, false);
            }

            if (this.Points != null && this.SeriesContainer != null && this.Points.Count > 0)
            {
                CalculateMinAndMax();
                ChartPoint oldPoint = new ChartPoint()
                {
                    XValue = double.MinValue, YValue = double.MinValue
                };
                IntializePoints();
                foreach (ChartPoint point in this.Points)
                {
                    if (CheckValuePoint(oldPoint, point))
                    {
                        Point linePoint = NormalizePoint(new Point(point.XValue, point.YValue));
                        BubblePoints.Add(linePoint);
                        oldPoint = point;
                    }
                }
                if (this.RenderingMode == RenderingMode.Default)
                {
                    if (!IsPointsGenerated)
                    {
                        for (int i = 0; i < BubblePoints.Count; i++)
                        {
                            ScatterPart scatterPart = new ScatterPart(BubblePoints[i]);
                            scatterPart.Size = SizeValues[i];
                            SetBindingForStrokeandStrokeThickness(scatterPart);
                            this.Parts.Add(scatterPart);
                        }
                        IsPointsGenerated = true;
                    }
                    else
                    {
                        int i = 0;
                        foreach (ScatterPart part in this.Parts)
                        {
                            part.X1 = BubblePoints[i].X;
                            part.Y1 = BubblePoints[i].Y;
                            part.Refresh();
                            i++;
                        }
                    }
                }
            }
            else
            {
                Parts.Clear();
            }

            if (this.SeriesContainer != null)
            {
                this.SeriesContainer.Invalidate();
            }
            IsRefreshed = false;
        }
Exemple #39
0
 public ComposedForm(string caption, Parts parts)
     : this(caption, parts, parts)
 {
 }
Exemple #40
0
        /// <summary>
        /// Decompose an error or warning message into constituent parts. If the message isn't in the canonical form, return null.
        /// </summary>
        /// <remarks>This method is thread-safe, because the Regex class is thread-safe (per MSDN).</remarks>
        /// <owner>JomoF</owner>
        /// <param name="message"></param>
        /// <returns>Decomposed canonical message, or null.</returns>
        internal static Parts Parse(string message)
        {
            // An unusually long string causes pathologically slow Regex back-tracking.
            // To avoid that, only scan the first 400 characters. That's enough for
            // the longest possible prefix: MAX_PATH, plus a huge subcategory string, and an error location.
            // After the regex is done, we can append the overflow.
            string messageOverflow = String.Empty;

            if (message.Length > 400)
            {
                messageOverflow = message.Substring(400);
                message         = message.Substring(0, 400);
            }

            // If a tool has a large amount of output that isn't an error or warning (eg., "dir /s %hugetree%")
            // the regex below is slow. It's faster to pre-scan for "warning" and "error"
            // and bail out if neither are present.
            if (message.IndexOf("warning", StringComparison.OrdinalIgnoreCase) == -1 &&
                message.IndexOf("error", StringComparison.OrdinalIgnoreCase) == -1)
            {
                return(null);
            }

            Parts parsedMessage = new Parts();

            // First, split the message into three parts--Origin, Category, Code, Text.
            // Example,
            //      Main.cs(17,20):Command line warning CS0168: The variable 'goo' is declared but never used
            //      -------------- ------------ ------- ------  ----------------------------------------------
            //      Origin         SubCategory  Cat.    Code    Text
            //
            // To accommodate absolute filenames in Origin, tolerate a colon in the second position
            // as long as its preceded by a letter.
            //
            // Localization Note:
            //  Even in foreign-language versions of tools, the category field needs to be in English.
            //  Also, if origin is a tool name, then that needs to be in English.
            //
            //  Here's an example from the Japanese version of CL.EXE:
            //   cl : ???? ??? warning D4024 : ?????????? 'AssemblyInfo.cs' ?????????????????? ???????????
            //
            //  Here's an example from the Japanese version of LINK.EXE:
            //   AssemblyInfo.cpp : fatal error LNK1106: ???????????? ??????????????: 0x6580 ??????????
            //
            Match match = s_originCategoryCodeTextExpression.Match(message);

            if (!match.Success)
            {
                // If no match here, then this message is not an error or warning.
                return(null);
            }

            string origin   = match.Groups["ORIGIN"].Value.Trim();
            string category = match.Groups["CATEGORY"].Value.Trim();

            parsedMessage.code        = match.Groups["CODE"].Value.Trim();
            parsedMessage.text        = (match.Groups["TEXT"].Value + messageOverflow).Trim();
            parsedMessage.subcategory = match.Groups["SUBCATEGORY"].Value.Trim();

            // Next, see if category is something that is recognized.
            if (0 == String.Compare(category, "error", StringComparison.OrdinalIgnoreCase))
            {
                parsedMessage.category = Parts.Category.Error;
            }
            else if (0 == String.Compare(category, "warning", StringComparison.OrdinalIgnoreCase))
            {
                parsedMessage.category = Parts.Category.Warning;
            }
            else
            {
                // Not an error\warning message.
                return(null);
            }

            // Origin is not a simple file, but it still could be of the form,
            //  goo.cpp(location)
            match = s_filenameLocationFromOrigin.Match(origin);

            if (match.Success)
            {
                // The origin is in the form,
                //  goo.cpp(location)
                // Assume the filename exists, but don't verify it. What else could it be?
                string location = match.Groups["LOCATION"].Value.Trim();
                parsedMessage.origin = match.Groups["FILENAME"].Value.Trim();

                // Now, take apart the location. It can be one of these:
                //      loc:
                //      (line)
                //      (line-line)
                //      (line,col)
                //      (line,col-col)
                //      (line,col,len)
                //      (line,col,line,col)
                if (location.Length > 0)
                {
                    match = s_lineFromLocation.Match(location);
                    if (match.Success)
                    {
                        parsedMessage.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                    }
                    else
                    {
                        match = s_lineLineFromLocation.Match(location);
                        if (match.Success)
                        {
                            parsedMessage.line    = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                            parsedMessage.endLine = ConvertToIntWithDefault(match.Groups["ENDLINE"].Value.Trim());
                        }
                        else
                        {
                            match = s_lineColFromLocation.Match(location);
                            if (match.Success)
                            {
                                parsedMessage.line   = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                                parsedMessage.column = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim());
                            }
                            else
                            {
                                match = s_lineColColFromLocation.Match(location);
                                if (match.Success)
                                {
                                    parsedMessage.line      = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                                    parsedMessage.column    = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim());
                                    parsedMessage.endColumn = ConvertToIntWithDefault(match.Groups["ENDCOLUMN"].Value.Trim());
                                }
                                else
                                {
                                    match = s_lineColLineColFromLocation.Match(location);
                                    if (match.Success)
                                    {
                                        parsedMessage.line      = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                                        parsedMessage.column    = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim());
                                        parsedMessage.endLine   = ConvertToIntWithDefault(match.Groups["ENDLINE"].Value.Trim());
                                        parsedMessage.endColumn = ConvertToIntWithDefault(match.Groups["ENDCOLUMN"].Value.Trim());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                // The origin does not fit the filename(location) pattern.
                parsedMessage.origin = origin;
            }

            return(parsedMessage);
        }
 internal static Parts Parse(string message)
 {
     Parts parts;
     Match match;
     string str2;
     string str = string.Empty;
     if (message.Length > 400)
     {
         str = message.Substring(400);
         message = message.Substring(0, 400);
     }
     if ((message.IndexOf("warning", StringComparison.OrdinalIgnoreCase) != -1) || (message.IndexOf("error", StringComparison.OrdinalIgnoreCase) != -1))
     {
         parts = new Parts();
         match = originCategoryCodeTextExpression.Match(message);
         if (!match.Success)
         {
             return null;
         }
         str2 = match.Groups["ORIGIN"].Value.Trim();
         string strA = match.Groups["CATEGORY"].Value.Trim();
         parts.code = match.Groups["CODE"].Value.Trim();
         parts.text = match.Groups["TEXT"].Value.Trim() + str;
         parts.subcategory = match.Groups["SUBCATEGORY"].Value.Trim();
         if (string.Compare(strA, "error", StringComparison.OrdinalIgnoreCase) == 0)
         {
             parts.category = Parts.Category.Error;
             goto Label_0138;
         }
         if (string.Compare(strA, "warning", StringComparison.OrdinalIgnoreCase) == 0)
         {
             parts.category = Parts.Category.Warning;
             goto Label_0138;
         }
     }
     return null;
 Label_0138:
     match = filenameLocationFromOrigin.Match(str2);
     if (match.Success)
     {
         string input = match.Groups["LOCATION"].Value.Trim();
         parts.origin = match.Groups["FILENAME"].Value.Trim();
         if (input.Length > 0)
         {
             match = lineFromLocation.Match(input);
             if (match.Success)
             {
                 parts.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                 return parts;
             }
             match = lineLineFromLocation.Match(input);
             if (match.Success)
             {
                 parts.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                 parts.endLine = ConvertToIntWithDefault(match.Groups["ENDLINE"].Value.Trim());
                 return parts;
             }
             match = lineColFromLocation.Match(input);
             if (match.Success)
             {
                 parts.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                 parts.column = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim());
                 return parts;
             }
             match = lineColColFromLocation.Match(input);
             if (match.Success)
             {
                 parts.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                 parts.column = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim());
                 parts.endColumn = ConvertToIntWithDefault(match.Groups["ENDCOLUMN"].Value.Trim());
                 return parts;
             }
             match = lineColLineColFromLocation.Match(input);
             if (match.Success)
             {
                 parts.line = ConvertToIntWithDefault(match.Groups["LINE"].Value.Trim());
                 parts.column = ConvertToIntWithDefault(match.Groups["COLUMN"].Value.Trim());
                 parts.endLine = ConvertToIntWithDefault(match.Groups["ENDLINE"].Value.Trim());
                 parts.endColumn = ConvertToIntWithDefault(match.Groups["ENDCOLUMN"].Value.Trim());
             }
         }
         return parts;
     }
     parts.origin = str2;
     return parts;
 }
Exemple #42
0
            public void renderUpdate(ref DrawBuffer draw_buffer, DrawBuffer.Type type, Parts parts)
            {
                if (!valid_)
                {
                    return;
                }
                var rotation = rigidbody_.transform_.rotation_ * original_rotation_;

                draw_buffer.regist(ref rigidbody_.transform_.position_,
                                   ref rotation,
                                   DrawBuffer.Type.MuscleMotionPlayer, (int)parts);
            }