コード例 #1
0
        private string GetCDefDataID(
            string defName, string cdef)
        {
            BINEntry entry = myGameBin.GetEntryByName(defName);

            if (entry != null)
            {
                DefinitionType def =
                    FileDatabase.Instance.Definitions.GetDefinition(
                        entry.Definition);

                def.ReadIn(entry);

                if (def.CDefs != null)
                {
                    CDefLink link = def.get_CDefLinks(cdef);

                    if (link != null)
                    {
                        return(link.DataID.ToString());
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        private string GetAssetLink(
            string defName, UInt32 control, int element)
        {
            BINEntry entry = GetBINEntry(defName);

            if (entry != null)
            {
                DefinitionType def =
                    FileDatabase.Instance.Definitions.GetDefinition(
                        entry.Definition);

                def.ReadIn(entry);

                FableMod.ContentManagement.Control c =
                    def.FindControl(control);

                if (c != null)
                {
                    Member mbr = (Member)c.Members[element];

                    ContentObject o = ContentManager.Instance.FindEntry(
                        mbr.Link.To, mbr.Value);

                    if (o != null)
                    {
                        return(o.Name);
                    }
                }
            }

            return(null);
        }
コード例 #3
0
        protected override void AddEntries(
            Regex regex, string name, ProgressBar progressBar)
        {
            progressBar.Maximum = myBIN.EntryCount;

            List <string> types = null;

            if (!string.IsNullOrEmpty(myCDef))
            {
                types = new List <string>(myCDef.Split(';'));
            }

            for (int i = 0; i < myBIN.EntryCount; ++i)
            {
                BINEntry entry = myBIN.get_Entries(i);

                if ((regex != null && regex.IsMatch(entry.Name)) ||
                    name == entry.Name)
                {
                    if (types == null || types.IndexOf(entry.Definition) >= 0)
                    {
                        AddEntry(
                            entry.Name,
                            "",
                            entry);
                    }
                }

                progressBar.Value = i;
                progressBar.Update();
            }
        }
コード例 #4
0
        protected TreeNode AddEntry(BINEntry entry)
        {
            TreeNode parent = null;

            for (int i = 0; i < treeView.Nodes.Count; ++i)
            {
                if (treeView.Nodes[i].Text == entry.Definition)
                {
                    parent = treeView.Nodes[i];
                    break;
                }
            }

            if (parent == null)
            {
                parent = new TreeNode();

                parent.Text               = entry.Definition;
                parent.ImageIndex         = 2;
                parent.SelectedImageIndex = 2;

                treeView.Nodes.Add(parent);
            }

            TreeNode node = AddToTree(parent, entry.Name, entry);

            return(node);
        }
コード例 #5
0
        private void DefTypeLink(
            BINEntry entryDst, BINEntry entrySrc, string cdef)
        {
            DefinitionType def =
                FileDatabase.Instance.Definitions.GetDefinition(
                    entryDst.Definition);

            def.ReadIn(entryDst);

            if (def.CDefs == null)
            {
                return;
            }

            CDefLink link = def.get_CDefLinks(cdef);

            if (link != null)
            {
                link.DataID = entrySrc.ID.ToString();

                def.Write(entryDst);

                return;
            }

            def = null;
        }
コード例 #6
0
        private static IEnumerable <string> ProcessBINEntry(BINEntry entry)
        {
            List <string> strings = new List <string>();

            foreach (BINValue value in entry.Values)
            {
                strings.AddRange(ProcessBINValue(value));
            }

            return(strings);
        }
コード例 #7
0
        /// <summary>
        /// Fix the links to self.
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="originalId"></param>
        private void FixMainEntry(BINEntry entry, int originalId)
        {
            DefinitionType def =
                ContentManager.Instance.Definitions.GetDefinition(
                    entry.Definition);

            def.ReadIn(entry);

            def.FixLinks(
                LinkDestination.GameBINEntryID, originalId, entry.ID);

            def.Write(entry);
        }
コード例 #8
0
ファイル: BINProcessor.cs プロジェクト: LoL-Fantome/Railgun
        private static TreeViewItem GenerateEntryNode(BINEntry entry)
        {
            TreeViewItem entryNode = new TreeViewItem()
            {
                Header = entry.GetPath() + " : " + BINGlobal.GetClass(entry.Class)
            };

            foreach (BINValue value in entry.Values)
            {
                entryNode.Items.Add(GenerateValueNode(value));
            }

            return(entryNode);
        }
コード例 #9
0
        public FormBINEntry(BINEntry entry)
        {
            InitializeComponent();

            m_Entry = entry;

            Text = m_Entry.Name;

            txtDefinitionType.Text = m_Entry.Definition;
            txtSymbolName.Text     = m_Entry.Name;
            textBoxId.Text         = m_Entry.ID.ToString();

            RefreshDefinitionDisplay();
        }
コード例 #10
0
        private void addEntryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormNewGameBINEntry form = new FormNewGameBINEntry(myBIN);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                byte[] data = null;

                BINEntry defEntry = myBIN.GetEntryByName(
                    form.Template);

                if (defEntry == null)
                {
                    form.Dispose();
                    form = null;
                    MessageBox.Show(this, "Default entry not found.");
                    return;
                }

                data = defEntry.Data;

                BINEntry entry = myBIN.AddEntry(
                    form.SymbolName, form.Definition, data);

                DefinitionType defType =
                    ContentManager.Instance.Definitions.GetDefinition(
                        form.Definition);

                defType.ReadIn(entry);

                defType.FixLinks(
                    LinkDestination.GameBINEntryID,
                    defEntry.ID,
                    entry.ID);

                defType.Write(entry);

                treeView.SelectedNode = AddEntry(entry);

                data = null;
            }

            form.Dispose();
            form = null;
        }
コード例 #11
0
        protected override void ShowObject(object o)
        {
            BINEntry entry = (BINEntry)o;

            Form form = null;

            if (entry.Definition == "CCutsceneDef")
            {
                form = new FableMod.Content.Forms.FormCutscene(entry);
                // TODO: Ask whether or not user wants this mode?
            }
            else
            {
                form = new FableMod.Content.Forms.FormBINEntry(entry);
            }

            FormMain.Instance.AddMDI(form);
        }
コード例 #12
0
        private void FindModified(BINFile bin, Progress progress)
        {
            progress.Begin(bin.EntryCount);

            for (int i = 0; i < bin.EntryCount; ++i)
            {
                BINEntry entry = bin.get_Entries(i);

                if (entry.Modified)
                {
                    myObjects.Add(
                        FileDatabase.Instance.GetContentObject(entry));
                }

                progress.Update();
            }

            progress.End();
        }
コード例 #13
0
        /// <summary>
        /// Convert the combobox item string into BINEntry.
        /// </summary>
        /// <param name="comboItem"></param>
        /// <returns></returns>
        private BINEntry GetBINEntry(string comboItem)
        {
            BINEntry entry = myGameBin.GetEntryByName(comboItem);

            if (entry == null)
            {
                // CDef might just be the ID.

                try
                {
                    entry = myGameBin.get_Entries(
                        int.Parse(comboItem.ToString()));
                }
                catch (Exception)
                {
                }
            }

            return(entry);
        }
コード例 #14
0
        public override void Run(Progress progress)
        {
            string fileFormat = Settings.GetString(
                "BIN", "DumpFormat", "ID-NAME.dat");

            progress.Begin(myBIN.EntryCount);

            for (int i = 0; i < myBIN.EntryCount; ++i)
            {
                BINEntry entry = myBIN.get_Entries(i);

                string name = "UNTITLED";

                if (entry.Name != "")
                {
                    name = entry.Name;
                }

                string filename = fileFormat;

                filename = filename.Replace("ID",
                                            string.Format("{0:D5}", entry.ID));

                filename = filename.Replace("NAME", name);
                filename = filename.Replace("DEFINITION", entry.Definition);

                progress.Info = filename;

                using (BinaryWriter writer = new BinaryWriter(
                           new FileStream(myFolder + "\\" + filename, FileMode.Create)))
                {
                    writer.Write(entry.Data, 0, entry.Data.Length);
                    writer.Close();
                }

                progress.Update();
            }

            progress.End();
        }
コード例 #15
0
        private void AssetLink(
            BINEntry entryDst,
            AssetTemplate assetItem, UInt32 assetId)
        {
            DefinitionType def =
                ContentManager.Instance.Definitions.GetDefinition(
                    entryDst.Definition);

            def.ReadIn(entryDst);

            FableMod.ContentManagement.Control c =
                def.FindControl(assetItem.ControlID);

            if (c != null)
            {
                ((Member)c.Members[assetItem.Element]).Value =
                    assetId.ToString();

                def.Write(entryDst);
            }

            def = null;
        }
コード例 #16
0
ファイル: FormCutscene.cs プロジェクト: DHunte/chocolate-box
        public FormCutscene(BINEntry cutscene)
        {
            InitializeComponent();

            myCutscene = cutscene;

            Text = "Cutscene: " + myCutscene.Name;

            myDefType = ContentManager.Instance.Definitions.GetDefinition(
                myCutscene.Definition);

            myDefType.ReadIn(myCutscene);

            myMode1 = myDefType.FindControl(0x5A1E6CA9);
            myMode2 = myDefType.FindControl(0xC1CABAFF);
            myMode3 = myDefType.FindControl(0x4FC34512);

            textBox1.Text = GetScript(myMode1);
            textBox2.Text = GetScript(myMode2);
            textBox3.Text = GetScript(myMode3);

            myModified = false;
        }
コード例 #17
0
ファイル: FormEditor.cs プロジェクト: DHunte/chocolate-box
        private bool SetupForTeleporter()
        {
            object obj =
                ContentManager.Instance.SelectEntry(
                    new Link(LinkDestination.GameBINEntryName, "OBJECT"),
                    "OBJECT_GUILD_PEDESTAL_TELEPORT_01");

            if (obj != null)
            {
                ContentObject o = ContentManager.Instance.FindEntry(
                    LinkDestination.GameBINEntryName, obj);

                BINEntry entry = (BINEntry)o.Object;

                if (entry.Definition != "OBJECT")
                {
                    FormMain.Instance.ErrorMessage(
                        "Invalid object selected.");
                    return(false);
                }

                myCreatedThing = new FableMod.TNG.Thing("Object");

                myCreatedThing.Create(
                    FileDatabase.Instance.TNGDefinitions,
                    entry.Name);

                myCreatedThing.UID    = FableMod.TNG.UIDManager.Generate();
                myCreatedThing.Player = 4;
                myCreatedThing.get_Variables("ScriptData").Value =
                    "Teleport?";

                entry = null;
                o     = null;

                CTCBlock block = (CTCBlock)myCreatedThing.ApplyCTC(
                    FileDatabase.Instance.TNGDefinitions,
                    "CTCActionUseScriptedHook");

                block.get_Variables("Usable").Value                   = true;
                block.get_Variables("ForceConfirmation").Value        = true;
                block.get_Variables("TeleportToRegionEntrance").Value =
                    true;

                ElementArray arr = (ElementArray)
                                   myCreatedThing.Find("CreateTC");

                Variable var = (Variable)arr.Add();
                var.Value = "CTCActionUseScriptedHook";

                // Create the teleporter marker.

                FableMod.TNG.Thing marker = new FableMod.TNG.Thing("Marker");

                marker.Create(
                    FileDatabase.Instance.TNGDefinitions,
                    "MARKER_BASIC");

                marker.UID    = FableMod.TNG.UIDManager.Generate();
                marker.Player = 4;

                // Set the teleport connector.
                block.get_Variables("EntranceConnectedToUID").Value =
                    marker.UID;

                // We're creating a teleporter...
                myTeleporter = marker;

                return(true);
            }

            return(false);
        }
コード例 #18
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (textBoxName.Text.Length == 0)
            {
                FormMain.Instance.ErrorMessage(
                    "Invalid base name. It can not be empty.");
                return;
            }

            string name = textBoxName.Text;

            Dictionary <int, BINEntry> binEntries =
                new Dictionary <int, BINEntry>();

            Dictionary <int, AssetEntry> assetEntries =
                new Dictionary <int, AssetEntry>();

            // Build the objects...

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Created objects:");

            for (int i = 0; i < myTemplate.ItemCount; ++i)
            {
                BaseTemplate item = myTemplate.get_Items(i);

                bool isRef = myRefCheckBoxes[item.ID].Checked;

                object selItem = myComboBoxes[item.ID].SelectedItem;

                if (selItem == null)
                {
                    continue;
                }

                if (item.GetType() == typeof(DefTypeTemplate))
                {
                    DefTypeTemplate defItem = item as DefTypeTemplate;

                    BINEntry defEntry = GetBINEntry(selItem.ToString());

                    if (defEntry != null)
                    {
                        string objName = defItem.Type + "_" + name;

                        if (!checkBoxNamed.Checked)
                        {
                            // Not on, so check the item flag.
                            if (!item.Named)
                            {
                                objName = "";
                            }
                        }

                        BINEntry entry = null;

                        if (isRef)
                        {
                            entry = defEntry;
                        }
                        else
                        {
                            entry = myGameBin.AddEntry(
                                objName,
                                defItem.Type,
                                defEntry.Data);

                            entry.Modified = true;

                            if (!string.IsNullOrEmpty(entry.Name))
                            {
                                sb.AppendFormat("  {0}", entry.Name);
                            }
                            else
                            {
                                sb.AppendFormat("  {0}:{1}",
                                                entry.Definition, entry.ID);
                            }

                            sb.AppendLine("");
                        }

                        binEntries.Add(item.ID, entry);
                    }
                    else
                    {
                        FormMain.Instance.ErrorMessage("Entry not found");
                    }
                }
                else
                {
                    AssetEntry defEntry =
                        ((AssetComboBoxItem)selItem).Entry;

                    if (defEntry != null)
                    {
                        AssetEntry entry;

                        if (isRef)
                        {
                            entry = defEntry;
                        }
                        else
                        {
                            AssetTemplate assetItem = item as AssetTemplate;

                            entry = defEntry.Bank.NewEntry(
                                GetAssetName(
                                    defEntry.Bank,
                                    assetItem.Prefix + "_" + name),
                                defEntry.Type);

                            entry.SubHeader = defEntry.SubHeader;
                            entry.Data      = defEntry.Data;

                            sb.AppendFormat("  {0}", entry.DevSymbolName);
                            sb.AppendLine("");
                        }

                        assetEntries.Add(item.ID, entry);
                    }
                }
            }

            // Link objects!

            for (int i = 0; i < myTemplate.ItemCount; ++i)
            {
                BaseTemplate item = myTemplate.get_Items(i);

                if (item.LinkTo == null)
                {
                    continue;
                }

                DefTypeTemplate defLink = item.LinkTo;

                if (item.GetType() == typeof(DefTypeTemplate))
                {
                    DefTypeLink(
                        binEntries[defLink.ID],
                        binEntries[item.ID],
                        item.Name);
                }
                else
                {
                    AssetEntry assetEntry = null;

                    if (assetEntries.TryGetValue(item.ID, out assetEntry))
                    {
                        AssetLink(
                            binEntries[defLink.ID],
                            (AssetTemplate)item,
                            assetEntry.ID);
                    }
                }
            }

            DefTypeTemplate baseItem =
                (DefTypeTemplate)myTemplate.get_Items(0);

            FixMainEntry(binEntries[baseItem.ID], baseItem.OriginalID);

            binEntries   = null;
            assetEntries = null;

            FormMain.Instance.InfoMessage(sb.ToString());
        }
コード例 #19
0
        private void comboBoxTemplate_DropDownClosed(object sender, EventArgs e)
        {
            if (comboBoxTemplate.SelectedIndex < 0)
            {
                panelTemplate.Visible = false;
                buttonCreate.Enabled  = false;
                return;
            }

            BINEntry entry = myGameBin.GetEntryByName(
                comboBoxTemplate.SelectedItem.ToString());

            myTemplate.Build(entry);

            panelProgress.Visible = true;
            panelProgress.Update();

            panelTemplate.Visible = false;
            panelTemplate.Controls.Clear();
            panelTemplate.SuspendLayout();

            myComboBoxes.Clear();
            myRefCheckBoxes.Clear();

            int x      = labelTemplate.Left;
            int y      = 5;
            int width  = 0;
            int height = 0;
            int yspace = 10;

            CheckBox objCheckBox = new CheckBox();

            // This should be the main object type.
            myComboBoxes.Add(
                myTemplate.get_Items(0).ID,
                comboBoxTemplate);

            myRefCheckBoxes.Add(
                myTemplate.get_Items(0).ID,
                objCheckBox);

            comboBoxTemplate.Tag = 0;

            // Start from the child items...
            for (int i = 1; i < myTemplate.ItemCount; ++i)
            {
                Label lbl = new Label();
                lbl.AutoSize = true;

                lbl.Text = myTemplate.get_Items(i).Name + ":";

                panelTemplate.Controls.Add(lbl);

                lbl.Left = x;
                lbl.Top  = y;

                y += lbl.Height + yspace;

                if (lbl.Width > width)
                {
                    width = lbl.Width;
                }

                if (lbl.Height > height)
                {
                    height = lbl.Height;
                }
            }

            y = 5;

            int right = panelTop.Width - comboBoxDefs.Right;

            progressBar.Value   = 0;
            progressBar.Maximum = myTemplate.ItemCount;
            progressBar.Update();

            for (int i = 1; i < myTemplate.ItemCount; ++i)
            {
                BaseTemplate item = myTemplate.get_Items(i);

                ComboBox comboBox = NewComboBox(item.Name);

                panelTemplate.Controls.Add(comboBox);

                comboBox.Left               = width + x + 5;
                comboBox.Top                = y;
                comboBox.Width              = comboBoxDefs.Right - comboBox.Left - 80;
                comboBox.Anchor            |= AnchorStyles.Right;
                comboBox.DropDownStyle      = ComboBoxStyle.DropDownList;
                comboBox.AutoCompleteSource =
                    AutoCompleteSource.ListItems;
                comboBox.AutoCompleteMode =
                    AutoCompleteMode.SuggestAppend;
                comboBox.Tag    = i;
                comboBox.Sorted = true;
                //comboBox.Enabled = string.IsNullOrEmpty(item.LinkTo);

                if (item.GetType() == typeof(DefTypeTemplate))
                {
                    DefTypeTemplate def = item as DefTypeTemplate;

                    if (comboBox.Items.Count == 0)
                    {
                        // Fill it up.

                        BINEntry[] entries =
                            myGameBin.GetEntriesByDefinition(def.Type);

                        foreach (BINEntry ent in entries)
                        {
                            comboBox.Items.Add((ent.Name.Length > 0)
                                ? ent.Name : ent.ID.ToString());
                        }
                    }
                }
                else
                {
                    if (comboBox.Items.Count == 0)
                    {
                        // New combobox.
                        AssetFill(comboBox, (AssetTemplate)item);
                    }
                }

                if (comboBox.Items.Count > 0)
                {
                    comboBox.SelectedIndex = 0;
                }

                comboBox.SelectedIndexChanged +=
                    new EventHandler(itemComboBox_SelectedIndexChanged);

                y += height + yspace;

                // We need to access this later.
                myComboBoxes.Add(item.ID, comboBox);

                progressBar.Value++;
                progressBar.Update();
            }

            // Add ref checkboxes...

            for (int i = 1; i < myTemplate.ItemCount; ++i)
            {
                BaseTemplate item = myTemplate.get_Items(i);

                CheckBox checkBox = new CheckBox();

                panelTemplate.Controls.Add(checkBox);

                checkBox.Left    = myComboBoxes[item.ID].Right + 5;
                checkBox.Top     = myComboBoxes[item.ID].Top;
                checkBox.Text    = "Ref";
                checkBox.Checked = item.Ref;
                checkBox.Anchor  = AnchorStyles.Top | AnchorStyles.Right;
                toolTip.SetToolTip(
                    checkBox, "Use this object as a reference");

                // We need to access this later.
                myRefCheckBoxes.Add(item.ID, checkBox);
            }

            // Add the boxes to the pool, so we can use them later.

            for (int i = 1; i < myTemplate.ItemCount; ++i)
            {
                BaseTemplate item = myTemplate.get_Items(i);
                AddToPool(item.Name, myComboBoxes[item.ID]);
            }

            UpdateLinks(comboBoxTemplate);

            panelTemplate.ResumeLayout();
            panelTemplate.Visible = true;

            panelTemplate.Visible = true;
            buttonCreate.Enabled  = true;

            panelProgress.Visible = false;
            panelProgress.Update();
        }
コード例 #20
0
ファイル: FileDatabase.cs プロジェクト: DHunte/chocolate-box
        /// <summary>
        /// Select a game object.
        /// </summary>
        /// <param name="dst"></param>
        /// <param name="current"></param>
        /// <returns>Returns an object depending on the link type</returns>
        public override object SelectEntry(
            Link link, object current)
        {
            if (link.To == LinkDestination.NamesBINOffset)
            {
                if (AutoLoadNames())
                {
                    NamesBINEntry entry = Names.GetEntryByOffset(
                        uint.Parse(current.ToString()));

                    string curr = "";

                    if (entry != null)
                    {
                        curr = entry.Name;
                    }

                    FormSelectNamesEntry form = new FormSelectNamesEntry(
                        Names, curr, link.Restriction);

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        entry = form.Selected;

                        form.Dispose();

                        return(entry.Offset);
                    }

                    form.Dispose();
                }
            }
            else if (link.To == LinkDestination.NamesBINEnum)
            {
                if (AutoLoadNames())
                {
                    NamesBINEntry entry = Names.GetEntryByEnum(
                        uint.Parse(current.ToString()));

                    string curr = "";

                    if (entry != null)
                    {
                        curr = entry.Name;
                    }

                    FormSelectNamesEntry form = new FormSelectNamesEntry(
                        Names, curr, link.Restriction);

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        entry = form.Selected;

                        form.Dispose();

                        return(entry.Enum);
                    }

                    form.Dispose();
                }
            }
            else if (link.To == LinkDestination.GameBINEntryName)
            {
                if (AutoLoadObjects())
                {
                    FormSelectBINEntry form = new FormSelectBINEntry(
                        Objects,
                        current.ToString());

                    form.CDefType = link.Restriction;

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        BINEntry entry = form.Selected;

                        form.Dispose();

                        return(entry.Name);
                    }

                    form.Dispose();
                }
            }
            else if (link.To == LinkDestination.GameBINEntryID)
            {
                if (AutoLoadObjects())
                {
                    ContentObject o = FindEntry(
                        link.To, UInt32.Parse(current.ToString()));

                    FormSelectBINEntry form = new FormSelectBINEntry(
                        Objects, o.Name);

                    form.CDefType = link.Restriction;

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        BINEntry entry = form.Selected;

                        form.Dispose();

                        return(entry.ID);
                    }

                    form.Dispose();
                }
            }
            else if (link.To == LinkDestination.ModelID)
            {
                if (AutoLoadGraphics())
                {
                    ContentObject o = FindEntry(
                        link.To, UInt32.Parse(current.ToString()));

                    FormSelectBIGEntry form = null;

                    if (o != null)
                    {
                        form = new FormSelectBIGEntry(
                            GraphicsBank, link.To, o.Name);
                    }
                    else
                    {
                        form = new FormSelectBIGEntry(
                            GraphicsBank, link.To, null);
                    }

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        AssetEntry entry = form.Selected;

                        form.Dispose();

                        return(entry.ID);
                    }

                    form.Dispose();
                }
            }
            else if (link.To == LinkDestination.MainTextureID)
            {
                if (AutoLoadTextures())
                {
                    ContentObject o = FindEntry(
                        link.To, UInt32.Parse(current.ToString()));

                    FormSelectBIGEntry form = null;

                    if (o != null)
                    {
                        form = new FormSelectBIGEntry(
                            MainTextureBank, link.To, o.Name);
                    }
                    else
                    {
                        form = new FormSelectBIGEntry(
                            MainTextureBank, link.To, null);
                    }

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        AssetEntry entry = form.Selected;

                        form.Dispose();

                        return(entry.ID);
                    }

                    form.Dispose();
                }
            }
            else if (link.To == LinkDestination.GUITextureID)
            {
                if (AutoLoadTextures())
                {
                    ContentObject o = FindEntry(
                        link.To, UInt32.Parse(current.ToString()));

                    FormSelectBIGEntry form = null;

                    if (o != null)
                    {
                        form = new FormSelectBIGEntry(
                            GUITextureBank, link.To, o.Name);
                    }
                    else
                    {
                        form = new FormSelectBIGEntry(
                            GUITextureBank, link.To, null);
                    }

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        AssetEntry entry = form.Selected;

                        form.Dispose();

                        return(entry.ID);
                    }

                    form.Dispose();
                }
            }
            else if (link.To == LinkDestination.FrontEndTextureID)
            {
                if (AutoLoadFrontEndTextures())
                {
                    ContentObject o = FindEntry(
                        link.To, UInt32.Parse(current.ToString()));

                    FormSelectBIGEntry form = null;

                    if (o != null)
                    {
                        form = new FormSelectBIGEntry(
                            FrontEndTextureBank, link.To, o.Name);
                    }
                    else
                    {
                        form = new FormSelectBIGEntry(
                            FrontEndTextureBank, link.To, null);
                    }

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        AssetEntry entry = form.Selected;

                        form.Dispose();

                        return(entry.ID);
                    }

                    form.Dispose();
                }
            }
            else if (link.To == LinkDestination.ModelName)
            {
                if (AutoLoadGraphics())
                {
                    FormSelectBIGEntry form = new FormSelectBIGEntry(
                        GraphicsBank, link.To, current.ToString());

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        AssetEntry entry = form.Selected;

                        form.Dispose();

                        return(entry.DevSymbolName);
                    }

                    form.Dispose();
                }
            }
            return(null);
        }
コード例 #21
0
ファイル: FileDatabase.cs プロジェクト: DHunte/chocolate-box
        /// <summary>
        /// Convert a game asset into a ContentObject.
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public ContentObject GetContentObject(object o)
        {
            if (o.GetType() == typeof(AssetEntry))
            {
                AssetEntry entry = (AssetEntry)o;

                ContentType ctype = ContentType.Unknown;

                if (entry.Bank.GetType() == typeof(BIGBank))
                {
                    BIGBank b = (BIGBank)entry.Bank;

                    if (b.Name ==
                        Settings.GetString("Banks", "Graphics"))
                    {
                        ctype = ContentType.Graphics;
                    }
                    else if (b.Name ==
                             Settings.GetString("Banks", "Text"))
                    {
                        ctype = ContentType.Text;
                    }
                    else if (b.Name ==
                             Settings.GetString("Banks", "Textures"))
                    {
                        ctype = ContentType.MainTextures;
                    }
                    else if (b.Name ==
                             Settings.GetString("Banks", "GUITextures"))
                    {
                        ctype = ContentType.GUITextures;
                    }
                    else if (b.Name ==
                             Settings.GetString("Banks", "FrontEndTextures"))
                    {
                        ctype = ContentType.FrontEndTextures;
                    }
                }

                return(new ContentObject(
                           entry.DevSymbolName,
                           entry,
                           ctype));
            }
            else if (o.GetType() == typeof(BINEntry))
            {
                if (!AutoLoadObjects())
                {
                    return(null);
                }

                BINEntry entry = (BINEntry)o;

                ContentType ctype = ContentType.Objects;

                if (Objects.GetEntryByName(entry.Name) != null)
                {
                    ctype = ContentType.Objects;
                }
                else if (entry.Definition == "CCutsceneDef")
                {
                    ctype = ContentType.Scripts;
                }

                return(new ContentObject(
                           entry.Name,
                           entry,
                           ctype));
            }

            return(null);
        }
コード例 #22
0
ファイル: FormEditor.cs プロジェクト: DHunte/chocolate-box
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object obj =
                ContentManager.Instance.SelectEntry(
                    new Link(
                        LinkDestination.GameBINEntryName,
                        null),
                    myLastNewEntry);

            if (obj != null)
            {
                ContentObject o = ContentManager.Instance.FindEntry(
                    LinkDestination.GameBINEntryName, obj);

                if (o == null)
                {
                    FormMain.Instance.ErrorMessage(
                        "Object could not be retrieved");
                    return;
                }

                BINEntry entry = (BINEntry)o.Object;

                string thingName = "Object";

                if (entry.Definition == "BUILDING")
                {
                    thingName = "Building";
                }
                else if (entry.Definition == "CREATURE")
                {
                    thingName = "AICreature";
                }
                else if (entry.Definition == "MARKER")
                {
                    thingName = "Marker";
                }
                else if (entry.Definition == "HOLY_SITE")
                {
                    thingName = "Holy Site";
                }
                else if (entry.Definition == "VILLAGE")
                {
                    thingName = "Village";
                }

                myCreatedThing = new FableMod.TNG.Thing(thingName);

                myCreatedThing.Create(
                    FileDatabase.Instance.TNGDefinitions,
                    entry.Name);

                myLastNewEntry = entry.Name;

                myCreatedThing.UID    = FableMod.TNG.UIDManager.Generate();
                myCreatedThing.Player = 4;

                entry = null;
                o     = null;

                // Change to creation mode.
                myView.Mode  = EditorMode.Create;
                myCreateMode = CreateMode.CreateNew;
            }
        }