Пример #1
0
        private void InventoryIcon_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DrawablesGenerator generator = new DrawablesGenerator(imagePath);

                generator = DrawableUtilities.SetUpGenerator(generator, "0", "0", tbxIgnoreColor.Text);

                DrawablesOutput output = generator.Generate();

                (new OutputWindow("Inventory Icon:", DrawableUtilities.GenerateInventoryIcon(output))).Show();
            }
            catch (FormatException)
            {
                MessageBox.Show("Invalid format. Did you provide a correct ignore color code? (hexadecimal RRGGBB or RRGGBBAA)");
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("Argument may not be null. Did you select a valid image?");
            }
            catch (DrawableException exc)
            {
                MessageBox.Show(exc.Message);
                return;
            }
        }
Пример #2
0
        protected JObject CreateDescriptor(string template, string group = "weapon", bool addInventoryIcon = false)
        {
            JObject descriptor = JObject.Parse(template);

            if (descriptor["name"] == null)
            {
                descriptor["name"] = "perfectlygenericitem";
            }

            if (descriptor["count"] == null)
            {
                descriptor["count"] = 1;
            }

            if (descriptor["parameters"] == null)
            {
                descriptor["parameters"] = new JObject();
            }

            JObject parameters = (JObject)descriptor["parameters"];

            if (parameters == null)
            {
                parameters = new JObject();
            }
            if (parameters["animationCustom"] == null)
            {
                parameters["animationCustom"] = new JObject();
            }
            if (parameters["animationCustom"]["animatedParts"] == null)
            {
                parameters["animationCustom"]["animatedParts"] = new JObject();
            }
            if (parameters["animationCustom"]["animatedParts"]["parts"] == null)
            {
                parameters["animationCustom"]["animatedParts"]["parts"] = new JObject();
            }

            JToken parts = parameters["animationCustom"]["animatedParts"]["parts"];

            string prefix = "D_";
            int    i      = 1;

            JArray groups = new JArray();

            if (!string.IsNullOrEmpty(group))
            {
                groups.Add(group);
            }

            foreach (Drawable item in output.Drawables)
            {
                if (item == null)
                {
                    continue;
                }
                JObject part = JObject.Parse("{'properties':{'centered':false,'offset':[0,0]}}");
                part["properties"]["image"]                = item.ResultImage;
                part["properties"]["offset"][0]            = item.BlockX + Math.Round(output.OffsetX / 8d, 3);
                part["properties"]["offset"][1]            = item.BlockY + Math.Round(output.OffsetY / 8d, 3);
                part["properties"]["transformationGroups"] = groups;

                parts[prefix + i++] = part;
            }

            if (addInventoryIcon)
            {
                parameters["inventoryIcon"] = DrawableUtilities.GenerateInventoryIcon(output);
            }

            return(descriptor);
        }