Esempio n. 1
0
        public static NbtTag CreateTag(IconSource source, NbtTagType type, NbtContainerTag parent, bool bypass_window = false)
        {
            bool has_name = parent is NbtCompound;
            var  tag      = NbtUtil.CreateTag(type);

            if (bypass_window)
            {
                tag.Name = NbtUtil.GetAutomaticName(tag, parent);
                return(tag);
            }
            var window = new EditHexWindow(source, tag, parent, has_name, EditPurpose.Create);

            return(window.ShowDialog() == DialogResult.OK ? tag : null);
        }
Esempio n. 2
0
        public static NbtTag CreateTag(IconSource source, NbtTagType type, NbtContainerTag parent, bool bypass_window = false)
        {
            bool has_name  = parent is NbtCompound;
            bool has_value = NbtUtil.IsValueType(type);

            var tag = NbtUtil.CreateTag(type);

            if (bypass_window)
            {
                tag.Name = NbtUtil.GetAutomaticName(tag, parent);
                return(tag);
            }
            else if (has_name || has_value)
            {
                var window = new EditTagWindow(source, tag, parent, has_name, has_value, EditPurpose.Create);
                return(window.ShowDialog() == DialogResult.OK ? tag : null);
            }
            else
            {
                return(tag); // no customization required, example: adding a compound to a list
            }
        }