private void typeComboBox_TextChanged(object sender, EventArgs e)
        {
            //HACK:
            if (WinformsUtil.Resetting > 0 && typeComboBox.Text.Equals(""))
            {
                return;
            }

            //Swap out extra boxes
            FormMain.Instance.HideItemExtensions();
            foreach (Control c in FormMain.Instance.Controls)
            {
                if (c.Tag is ItemExtensionFormTag &&
                    ((ItemExtensionFormTag)c.Tag).itemType.Equals(
                        typeComboBox.Text, StringComparison.InvariantCultureIgnoreCase))
                {
                    c.Visible = true;
                    WinformsUtil.ControlsLoadItem(c, Storage.CurrentItemData);
                }
            }

            //Fill defaults for missing keys
            foreach (Control c in FormMain.Instance.Controls)
            {
                if (c.Tag is DataFormTag && c.Visible)
                {
                    ControlSetDefaults(c);
                }
            }
        }
Beispiel #2
0
 public static void TestAllItems()
 {
     for (int c = 0; c < openFiles.Length; c++)
     {
         CataFile fileDef = GetFileDefForOpenFile(c);
         if (fileDef != null && fileDef.control != null)
         {
             for (int d = 0; d < openItems[c].Count; d++)
             {
                 WinformsUtil.ControlsLoadItem(fileDef.control, openItems[c][d].data);
             }
         }
     }
     MessageBox.Show("Done");
 }
Beispiel #3
0
        /// <summary>
        /// Load up one item from current file's JSON.
        /// </summary>
        /// <param name="id"></param>
        public static void LoadItem(int index)
        {
            if (index < 0)
            {
                return;
            }

            currentItemIndex = index;

            CataFile fileDef = GetFileDefForOpenFile(currentFileIndex);

            if (fileDef != null && fileDef.control != null)
            {
                WinformsUtil.ControlsLoadItem(fileDef.control, CurrentItemData);
            }
        }
        private void typeComboBox_TextChanged(object sender, EventArgs e)
        {
            //HACK:
            if (WinformsUtil.Resetting > 0 && typeComboBox.Text.Equals(""))
            {
                return;
            }

            //Swap out extra boxes
            Form1.Instance.HideItemExtensions();
            foreach (Control c in Form1.Instance.Controls)
            {
                if (c.Tag is ItemExtensionFormTag &&
                    ((ItemExtensionFormTag)c.Tag).itemType.Equals(
                        typeComboBox.Text, StringComparison.InvariantCultureIgnoreCase))
                {
                    c.Visible = true;
                    WinformsUtil.ControlsLoadItem(c.Controls[0], Storage.CurrentItemData);
                }
            }

            //Fill defaults for missing keys
            foreach (Control c in Form1.Instance.Controls)
            {
                if (c.Tag is DataFormTag && c.Visible)
                {
                    foreach (Control d in c.Controls[0].Controls)
                    {
                        if (d.Tag is JsonFormTag)
                        {
                            string key = ((JsonFormTag)d.Tag).key;
                            if (!string.IsNullOrEmpty(key) &&
                                !Storage.CurrentItemData.ContainsKey(key) &&
                                ((JsonFormTag)d.Tag).mandatory)
                            {
                                Storage.CurrentItemData[key] = ((JsonFormTag)d.Tag).def;
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Load up one item from current file's JSON.
        /// </summary>
        /// <param name="id"></param>
        public static void LoadItem(int index)
        {
            if (index < 0)
            {
                return;
            }

            currentItemIndex = index;

            string ffilename = Path.GetFileName(CurrentFileName);

            if (CurrentFileIsItems)
            {
                WinformsUtil.ControlsLoadItem(Form1.Instance.GenericItemControl.Controls[0], CurrentItemData);
            }
            else if (ffilename.Equals("item_groups.json"))
            {
                WinformsUtil.ControlsLoadItem(Form1.Instance.ItemGroupControl.Controls[0], CurrentItemData);
            }
            else if (ffilename.Equals("recipes.json"))
            {
                WinformsUtil.ControlsLoadItem(Form1.Instance.RecipeControl.Controls[0], CurrentItemData);
            }
        }