Ejemplo n.º 1
0
        private void RetrieveCharacter()
        {
            bool lvInvoke = false;

            try
            {
                foreach (Control lvControl in this.Controls)
                {
                    Invoke((MethodInvoker) delegate()
                    {
                        this.Controls.Remove(lvControl);
                    });
                    lvInvoke = true;
                }
            }
            catch (Exception ex) { }

            XPathDocument     lvActiveCharXml  = new XPathDocument(Global.ActiveCharacterXml);
            XPathNavigator    lvActiveNav      = lvActiveCharXml.CreateNavigator();
            XPathNodeIterator lvActiveNodeIter = lvActiveNav.Select("Characters/Character");

            int yPosition = 0;

            while (lvActiveNodeIter.MoveNext())
            {
                while (IsFileLocked(Global.CharacterFolder + String.Format(@"{0}.xml", lvActiveNodeIter.Current.SelectSingleNode("@Name").Value)))
                {
                    Thread.Sleep(1000);
                }
                XPathDocument     lvCharXml = new XPathDocument(Global.CharacterFolder + String.Format(@"{0}.xml", lvActiveNodeIter.Current.SelectSingleNode("@Name").Value));
                XPathNavigator    nav       = lvCharXml.CreateNavigator();
                XPathNodeIterator nodeIter;

                CharDisplay.CharName         = nav.SelectSingleNode("Character/Background/Name").Value;
                CharDisplay.Type             = nav.SelectSingleNode("Character/Background/Type").Value;
                CharDisplay.Health           = nav.SelectSingleNode("Character/Attributes/Health/Max").ValueAsInt;
                CharDisplay.Bash             = nav.SelectSingleNode("Character/Attributes/Health/Bash").ValueAsInt;
                CharDisplay.Lethal           = nav.SelectSingleNode("Character/Attributes/Health/Lethal").ValueAsInt;
                CharDisplay.Aggravated       = nav.SelectSingleNode("Character/Attributes/Health/Aggravated").ValueAsInt;
                CharDisplay.WillpowerMax     = nav.SelectSingleNode("Character/Attributes/Willpower/Max").ValueAsInt;
                CharDisplay.WillpowerCurrent = nav.SelectSingleNode("Character/Attributes/Willpower/Current").ValueAsInt;
                CharDisplay.Image            = nav.SelectSingleNode("Character/Image").Value;
                CharDisplay.DisplayType      = Global.CharType.Character;

                nodeIter = nav.Select("Character/Statuses/Status");

                while (nodeIter.MoveNext())
                {
                    CharDisplay.Status.Add(nodeIter.Current.Value);
                }

                CharDisplay lvChar = new CharDisplay();
                lvChar.Location = new Point(10, yPosition);

                yPosition += 276;

                if (lvInvoke)
                {
                    Invoke((MethodInvoker) delegate()
                    {
                        this.Controls.Add(lvChar);
                    });
                }
                else
                {
                    this.Controls.Add(lvChar);
                }
            }

            //string[] files = Directory.GetFiles(Global.CharacterFolder, "*.xml");
            //int yPosition = 0;

            //foreach (string file in files)
            //{
            //    XPathDocument lvCharXml = new XPathDocument(file);
            //    XPathNavigator nav = lvCharXml.CreateNavigator();
            //    XPathNodeIterator nodeIter;

            //    CharDisplay.CharName = nav.SelectSingleNode("Character/Background/Name").Value;
            //    CharDisplay.Type = nav.SelectSingleNode("Character/Background/Type").Value;
            //    CharDisplay.Health = nav.SelectSingleNode("Character/Attributes/Health/Max").ValueAsInt;
            //    CharDisplay.Bash = nav.SelectSingleNode("Character/Attributes/Health/Bash").ValueAsInt;
            //    CharDisplay.Lethal = nav.SelectSingleNode("Character/Attributes/Health/Lethal").ValueAsInt;
            //    CharDisplay.Aggravated = nav.SelectSingleNode("Character/Attributes/Health/Aggravated").ValueAsInt;
            //    CharDisplay.Willpower = nav.SelectSingleNode("Character/Attributes/Willpower/Max").ValueAsInt;
            //    CharDisplay.Image = nav.SelectSingleNode("Character/Image").Value;
            //    CharDisplay.DisplayType = Global.CharType.Character;

            //    nodeIter = nav.Select("Character/Statuses/Status");

            //    while (nodeIter.MoveNext())
            //    {
            //        CharDisplay.Status.Add(nodeIter.Current.Value);
            //    }

            //    CharDisplay lvChar = new CharDisplay();
            //    lvChar.Location = new Point(10, yPosition);

            //    yPosition += 180;

            //    if (lvInvoke)
            //    {
            //        Invoke((MethodInvoker)delegate()
            //        {
            //            this.Controls.Add(lvChar);
            //        });
            //    }
            //    else
            //    {
            //        this.Controls.Add(lvChar);
            //    }
            //}
        }
Ejemplo n.º 2
0
        private void treeCompendium_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Text == "Cash")
            {
                CashControl cControl = new CashControl();
                GMForm.setPanelSelectedCash(cControl);
            }
            else if (e.Node.Parent != null)
            {
                switch (e.Node.Parent.Text)
                {
                case "Item":
                    XPathNavigator itemNav = cvItemXml.CreateNavigator().SelectSingleNode("Items/Item[@Name = '" + e.Node.Text + "']");

                    ItemDisplay.ItemName      = e.Node.Text;
                    ItemDisplay.Image         = itemNav.SelectSingleNode("Image").Value;
                    ItemDisplay.Cost          = itemNav.SelectSingleNode("Cost").ValueAsInt;
                    ItemDisplay.ItemSize      = itemNav.SelectSingleNode("Size").ValueAsInt;
                    ItemDisplay.Durability    = itemNav.SelectSingleNode("Durability").ValueAsInt;
                    ItemDisplay.Structure     = itemNav.SelectSingleNode("Structure").ValueAsInt;
                    ItemDisplay.Description   = itemNav.SelectSingleNode("Description").Value;
                    ItemDisplay.Scope         = null;
                    ItemDisplay.Damage_Prim   = null;
                    ItemDisplay.Damage_Sec    = null;
                    ItemDisplay.Capacity      = null;
                    ItemDisplay.Def_General   = 0;
                    ItemDisplay.Def_Ballistic = 0;
                    ItemDisplay.Range         = null;

                    ItemDisplay iDisplay = new ItemDisplay();
                    GMForm.setPanelSelectedItem(iDisplay);
                    break;

                case "Weapon":
                    XPathNavigator weaponNav = cvItemXml.CreateNavigator().SelectSingleNode("Items/Item[@Name = '" + e.Node.Text + "']");

                    ItemDisplay.ItemName    = e.Node.Text;
                    ItemDisplay.Scope       = weaponNav.SelectSingleNode("Scope").Value;
                    ItemDisplay.Image       = weaponNav.SelectSingleNode("Image").Value;
                    ItemDisplay.Cost        = weaponNav.SelectSingleNode("Cost").ValueAsInt;
                    ItemDisplay.ItemSize    = weaponNav.SelectSingleNode("Size").ValueAsInt;
                    ItemDisplay.Damage_Prim = weaponNav.SelectSingleNode("Primary/Damage").Value + "(" + weaponNav.SelectSingleNode("Primary/Threat").Value + ")";;

                    XPathNavigator secNav = weaponNav.SelectSingleNode("Secondary/Damage");
                    if (secNav != null)
                    {
                        ItemDisplay.Damage_Sec = weaponNav.SelectSingleNode("Secondary/Damage").Value + "(" + weaponNav.SelectSingleNode("Secondary/Threat").Value + ")";
                    }
                    else
                    {
                        ItemDisplay.Damage_Sec = null;
                    }

                    XPathNavigator mediumNav = weaponNav.SelectSingleNode("Range/Medium");
                    XPathNavigator longNav   = weaponNav.SelectSingleNode("Range/Long");

                    ItemDisplay.Range = weaponNav.SelectSingleNode("Range/Short").Value;
                    if (mediumNav != null)
                    {
                        ItemDisplay.Range += @"/" + mediumNav.Value;
                    }
                    if (longNav != null)
                    {
                        ItemDisplay.Range += @"/" + longNav.Value;
                    }

                    ItemDisplay.Durability    = 0;
                    ItemDisplay.Structure     = 0;
                    ItemDisplay.Def_General   = 0;
                    ItemDisplay.Def_Ballistic = 0;

                    ItemDisplay.Description = weaponNav.SelectSingleNode("Description").Value;

                    ItemDisplay wDisplay = new ItemDisplay();
                    GMForm.setPanelSelectedItem(wDisplay);
                    break;

                case "Armor":
                    XPathNavigator armorNav = cvItemXml.CreateNavigator().SelectSingleNode("Items/Item[@Name = '" + e.Node.Text + "']");

                    ItemDisplay.ItemName      = e.Node.Text;
                    ItemDisplay.Image         = armorNav.SelectSingleNode("Image").Value;
                    ItemDisplay.Cost          = armorNav.SelectSingleNode("Cost").ValueAsInt;
                    ItemDisplay.Def_General   = armorNav.SelectSingleNode("General").ValueAsInt;
                    ItemDisplay.Def_Ballistic = armorNav.SelectSingleNode("Ballistic").ValueAsInt;
                    ItemDisplay.Description   = armorNav.SelectSingleNode("Description").Value;
                    ItemDisplay.Durability    = 0;
                    ItemDisplay.Structure     = 0;
                    ItemDisplay.Scope         = null;
                    ItemDisplay.Damage_Prim   = null;
                    ItemDisplay.Damage_Sec    = null;
                    ItemDisplay.Capacity      = null;
                    ItemDisplay.Range         = null;

                    ItemDisplay aDisplay = new ItemDisplay();
                    GMForm.setPanelSelectedItem(aDisplay);
                    break;

                case "Vehicle":
                    XPathNavigator vehicleNav = cvVehicleXml.CreateNavigator().SelectSingleNode("Vehicles/Vehicle[@Name = '" + e.Node.Text + "']");

                    VehicleDisplay.VehicleName  = e.Node.Text;
                    VehicleDisplay.Image        = vehicleNav.SelectSingleNode("Image").Value;
                    VehicleDisplay.Cost         = vehicleNav.SelectSingleNode("Cost").ValueAsInt;
                    VehicleDisplay.ItemSize     = vehicleNav.SelectSingleNode("Size").ValueAsInt;
                    VehicleDisplay.Durability   = vehicleNav.SelectSingleNode("Durability").ValueAsInt;
                    VehicleDisplay.Structure    = vehicleNav.SelectSingleNode("Structure").ValueAsInt;
                    VehicleDisplay.Acceleration = vehicleNav.SelectSingleNode("Acceleration").ValueAsInt;
                    VehicleDisplay.Speed        = vehicleNav.SelectSingleNode("Speed").ValueAsInt;
                    VehicleDisplay.Safe_Speed   = vehicleNav.SelectSingleNode("Safe_Speed").ValueAsInt;
                    VehicleDisplay.Handling     = vehicleNav.SelectSingleNode("Handling").ValueAsInt;
                    VehicleDisplay.Occupancy    = vehicleNav.SelectSingleNode("Occupancy").ValueAsInt;
                    VehicleDisplay.Capacity     = vehicleNav.SelectSingleNode("Capacity").ValueAsInt;
                    VehicleDisplay.Description  = vehicleNav.SelectSingleNode("Description").Value;

                    VehicleDisplay vDisplay = new VehicleDisplay();
                    GMForm.setPanelSelectedVehicle(vDisplay);
                    break;

                case "NPC":
                    XPathDocument  lvNPCxml = new XPathDocument(Properties.Settings.Default.DataLocation + @"NPC/" + e.Node.Text + ".xml");
                    XPathNavigator npcNav   = lvNPCxml.CreateNavigator();

                    CharDisplay.CharName         = npcNav.SelectSingleNode("Character/Background/Name").Value;
                    CharDisplay.Type             = npcNav.SelectSingleNode("Character/Background/Type").Value;
                    CharDisplay.Health           = npcNav.SelectSingleNode("Character/Attributes/Health/Max").ValueAsInt;
                    CharDisplay.Bash             = npcNav.SelectSingleNode("Character/Attributes/Health/Bash").ValueAsInt;
                    CharDisplay.Lethal           = npcNav.SelectSingleNode("Character/Attributes/Health/Lethal").ValueAsInt;
                    CharDisplay.Aggravated       = npcNav.SelectSingleNode("Character/Attributes/Health/Aggravated").ValueAsInt;
                    CharDisplay.WillpowerMax     = npcNav.SelectSingleNode("Character/Attributes/Willpower/Max").ValueAsInt;
                    CharDisplay.WillpowerCurrent = npcNav.SelectSingleNode("Character/Attributes/Willpower/Current").ValueAsInt;
                    CharDisplay.Image            = npcNav.SelectSingleNode("Character/Image").Value;
                    CharDisplay.DisplayType      = Global.CharType.NPC;
                    CharDisplay lvChar = new CharDisplay();

                    CharDisplay cDisplay = new CharDisplay();
                    GMForm.setPanelSelectedChar(cDisplay);
                    break;

                default:
                    break;
                }
            }
        }