Exemple #1
0
        private void ImportTNG(string fileName)
        {
            FableMod.TNG.TNGFile tng = new FableMod.TNG.TNGFile(
                FileDatabase.Instance.TNGDefinitions);

            tng.Load(fileName);

            for (int i = 0; i < tng.SectionCount; ++i)
            {
                for (int j = 0; j < tng.get_Sections(i).Things.Count; ++j)
                {
                    myImports.Add(tng.get_Sections(i).Things[j]);
                }
            }

            // Do some initial setup.

            for (int i = 0; i < myImports.Count; ++i)
            {
                FableMod.TNG.Thing thing = myImports[i];
                thing.UID = FableMod.TNG.UIDManager.Generate();
                thing.Detach();
            }

            tng.Destroy();

            if (myImports.Count == 0)
            {
                FormMain.Instance.ErrorMessage("No things");
                return;
            }

            myView.Mode  = EditorMode.Create;
            myCreateMode = CreateMode.Import;
        }
Exemple #2
0
        private void UpdateComboBoxes(FableMod.TNG.Thing[] things)
        {
            comboBoxSection.Items.Clear();

            if (things == null)
            {
                comboBoxMap.Enabled         = false;
                comboBoxSection.Enabled     = false;
                buttonChangeMap.Enabled     = false;
                buttonChangeSection.Enabled = false;
            }
            else
            {
                comboBoxMap.Enabled         = true;
                comboBoxSection.Enabled     = true;
                buttonChangeMap.Enabled     = myMaps.Count > 1;
                buttonChangeSection.Enabled = true;

                FableMod.TNG.TNGFile tngFile = null;

                FableMod.TNG.TNGFile tng = things[0].Section.TNGFile;

                for (int i = 1; i < things.Length; ++i)
                {
                    if (tng != things[i].Section.TNGFile)
                    {
                        tng = null;
                    }
                }

                comboBoxMap.SelectedIndex = -1;

                for (int i = 0; i < comboBoxMap.Items.Count; ++i)
                {
                    MapComboBoxItem item =
                        (MapComboBoxItem)comboBoxMap.Items[i];

                    if (item.myMap.TNG == tng)
                    {
                        tngFile = tng;
                        comboBoxMap.SelectedIndex = i;
                        break;
                    }
                }

                comboBoxSection.Items.Clear();

                if (tng != null)
                {
                    FableMod.TNG.Section section = things[0].Section;

                    for (int i = 1; i < things.Length; ++i)
                    {
                        if (section != things[i].Section)
                        {
                            section = null;
                        }
                    }

                    for (int i = 0; i < tng.SectionCount; ++i)
                    {
                        SectionComboBoxItem item = new SectionComboBoxItem(
                            tng.get_Sections(i));

                        int index = comboBoxSection.Items.Add(item);

                        if (item.mySection == section)
                        {
                            comboBoxSection.SelectedIndex = index;
                        }
                    }
                }
            }
        }