Exemple #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="Rift.ShopDialog"/> class
        /// from the specified user account and shop items data
        /// </summary>
        /// <param name="account">A user account data.</param>
        /// <param name="shop">An in-game shop items data.</param>
        public ShopDialog(GameAccount account, GameShop shop)
        {
            InitializeComponent();

            this.account = account;
            this.shop = shop;

            onLoading = false;
            updateEnabled = true;

            characters = new Queue<string>();
            itemPanels = new Dictionary<int, ShopItemPanel>();
            comboBoxCategory.Items.Add(Resources.ShopCategorySearch);

            if (account != null)
                labelUser.Text = account.Name;
            else
            {
                labelUser.Visible = false;
                labelPoints.Visible = false;
            }

            if (shop == null) return;

            foreach (var category in shop.CategoryNames)
                comboBoxCategory.Items.Add(category);

            flowPanel.ChildCount = shop.ItemsCount;
            comboBoxCategory.SelectedIndex = comboBoxCategory.Items.Count > 1 ? 1 : 0;
        }
Exemple #2
0
        private static GameShop ReadPriceList(string path)
        {
            XDocument xdoc = null;

            try
            {
                xdoc = XDocument.Load(path);
            }
            catch (XmlException) { }

            if (xdoc == null || xdoc.Root == null) return null;

            var xNameCategories = XName.Get("categories", DefaultNamespace);
            var xNameCategory = XName.Get("category", DefaultNamespace);
            var xNameItem = XName.Get("item", DefaultNamespace);

            var result = new GameShop();
            var categoriesRoot = xdoc.Root.Element(xNameCategories);

            if (categoriesRoot == null)
                return null;

            foreach (var xcat in categoriesRoot.Elements(xNameCategory))
            {
                var catAttr = xcat.Attribute("name");
                if (catAttr == null || string.IsNullOrEmpty(catAttr.Value)) return null;

                var category = new ShopItemCollection(catAttr.Value.Trim());

                foreach (var xitem in xcat.Elements(xNameItem))
                {
                    var idAttr = xitem.Attribute("id");
                    var titleAttr = xitem.Attribute("title");
                    var qualityAttr = xitem.Attribute("quality");
                    var raceAttr = xitem.Attribute("race");
                    var iconAttr = xitem.Attribute("icon");
                    var countAttr = xitem.Attribute("count");
                    var priceAttr = xitem.Attribute("price");

                    if (idAttr == null || string.IsNullOrEmpty(idAttr.Value)) continue;
                    if (titleAttr == null || string.IsNullOrEmpty(titleAttr.Value)) continue;
                    if (priceAttr == null || string.IsNullOrEmpty(priceAttr.Value)) continue;

                    uint id;
                    uint price;
                    uint count;

                    var idTest = uint.TryParse(idAttr.Value, out id);
                    var priceTest = uint.TryParse(priceAttr.Value, out price);

                    if (!idTest || !priceTest) continue;

                    if (countAttr != null)
                    {
                        var countTest = uint.TryParse(countAttr.Value, out count);

                        if (!countTest)
                            count = 1;
                    }
                    else
                        count = 1;

                    var quality = ItemQuality.Common;

                    if (qualityAttr != null &&
                        !string.IsNullOrEmpty(qualityAttr.Value))
                    {
                        ItemQuality temp;

                        var qualityTest = Enum.TryParse(qualityAttr.Value, true, out temp);

                        if (qualityTest)
                            quality = temp;
                    }

                    var race = ItemRaceRestriction.Universal;

                    if (raceAttr != null &&
                        !string.IsNullOrEmpty(raceAttr.Value))
                    {
                        ItemRaceRestriction temp;

                        var raceTest = Enum.TryParse(raceAttr.Value, true, out temp);

                        if (raceTest)
                            race = temp;
                    }

                    string icon = null;

                    if (iconAttr != null &&
                        !string.IsNullOrEmpty(iconAttr.Value))
                        icon = iconAttr.Value.Trim();

                    category.Add(new ShopItem(id, titleAttr.Value.Trim(), quality, race, icon, count, price));
                }

                if (category.Count > 0)
                    result.Add(category);
            }

            return result.Count == 0 ? null : result;
        }
Exemple #3
0
 private void OnPriceListReady(GameShop priceList)
 {
     if (PriceListReady != null)
         PriceListReady(this, new PriceListReadyEventArgs(priceList));
 }
Exemple #4
0
 /// <summary>
 /// Creates a new instance of the <see cref="Rift.Services.PriceListReadyEventArgs"/> class
 /// from the specified price list.
 /// </summary>
 /// <param name="priceList">A collection of named <see cref="Rift.Data.ShopItemCollection"/>.</param>
 public PriceListReadyEventArgs(GameShop priceList)
 {
     PriceList = priceList;
 }
Exemple #5
0
 /// <summary>
 /// Creates a new instance of the <see cref="Rift.Services.PriceListReadyEventArgs"/> class
 /// from the specified price list.
 /// </summary>
 /// <param name="priceList">A collection of named <see cref="Rift.Data.ShopItemCollection"/>.</param>
 public PriceListReadyEventArgs(GameShop priceList)
 {
     PriceList = priceList;
 }
Exemple #6
0
        private static GameShop ReadPriceList(string path)
        {
            XDocument xdoc = null;

            try
            {
                xdoc = XDocument.Load(path);
            }
            catch (XmlException) { }

            if (xdoc == null || xdoc.Root == null)
            {
                return(null);
            }

            var xNameCategories = XName.Get("categories", DefaultNamespace);
            var xNameCategory   = XName.Get("category", DefaultNamespace);
            var xNameItem       = XName.Get("item", DefaultNamespace);

            var result         = new GameShop();
            var categoriesRoot = xdoc.Root.Element(xNameCategories);

            if (categoriesRoot == null)
            {
                return(null);
            }

            foreach (var xcat in categoriesRoot.Elements(xNameCategory))
            {
                var catAttr = xcat.Attribute("name");
                if (catAttr == null || string.IsNullOrEmpty(catAttr.Value))
                {
                    return(null);
                }

                var category = new ShopItemCollection(catAttr.Value.Trim());

                foreach (var xitem in xcat.Elements(xNameItem))
                {
                    var idAttr      = xitem.Attribute("id");
                    var titleAttr   = xitem.Attribute("title");
                    var qualityAttr = xitem.Attribute("quality");
                    var raceAttr    = xitem.Attribute("race");
                    var iconAttr    = xitem.Attribute("icon");
                    var countAttr   = xitem.Attribute("count");
                    var priceAttr   = xitem.Attribute("price");

                    if (idAttr == null || string.IsNullOrEmpty(idAttr.Value))
                    {
                        continue;
                    }
                    if (titleAttr == null || string.IsNullOrEmpty(titleAttr.Value))
                    {
                        continue;
                    }
                    if (priceAttr == null || string.IsNullOrEmpty(priceAttr.Value))
                    {
                        continue;
                    }

                    uint id;
                    uint price;
                    uint count;

                    var idTest    = uint.TryParse(idAttr.Value, out id);
                    var priceTest = uint.TryParse(priceAttr.Value, out price);

                    if (!idTest || !priceTest)
                    {
                        continue;
                    }

                    if (countAttr != null)
                    {
                        var countTest = uint.TryParse(countAttr.Value, out count);

                        if (!countTest)
                        {
                            count = 1;
                        }
                    }
                    else
                    {
                        count = 1;
                    }

                    var quality = ItemQuality.Common;

                    if (qualityAttr != null &&
                        !string.IsNullOrEmpty(qualityAttr.Value))
                    {
                        ItemQuality temp;

                        var qualityTest = Enum.TryParse(qualityAttr.Value, true, out temp);

                        if (qualityTest)
                        {
                            quality = temp;
                        }
                    }

                    var race = ItemRaceRestriction.Universal;

                    if (raceAttr != null &&
                        !string.IsNullOrEmpty(raceAttr.Value))
                    {
                        ItemRaceRestriction temp;

                        var raceTest = Enum.TryParse(raceAttr.Value, true, out temp);

                        if (raceTest)
                        {
                            race = temp;
                        }
                    }

                    string icon = null;

                    if (iconAttr != null &&
                        !string.IsNullOrEmpty(iconAttr.Value))
                    {
                        icon = iconAttr.Value.Trim();
                    }

                    category.Add(new ShopItem(id, titleAttr.Value.Trim(), quality, race, icon, count, price));
                }

                if (category.Count > 0)
                {
                    result.Add(category);
                }
            }

            return(result.Count == 0 ? null : result);
        }
Exemple #7
0
        private void ShopManager_PriceListReady(object sender, PriceListReadyEventArgs e)
        {
            shop = e.PriceList;

            this.InvokeAction(() => UpdateShopButton(0, shop != null));
        }
Exemple #8
0
        /// <summary>
        /// Creates a new instance of the <see cref="Rift.MainForm"/> class.
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            shop = null;
        }
Exemple #9
0
        /// <summary>
        /// Creates a new instance of the <see cref="Rift.MainForm"/> class.
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            shop = null;
        }
Exemple #10
0
        private void ShopManager_PriceListReady(object sender, PriceListReadyEventArgs e)
        {
            shop = e.PriceList;

            this.InvokeAction(() => UpdateShopButton(0, shop != null));
        }