Ejemplo n.º 1
0
        /// <summary>
        /// The swap item_ click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        /// <remarks></remarks>
        private void SwapItem_Click(object sender, EventArgs e)
        {
            if (parsedCheckBox.Checked)
            {
                MessageBox.Show("Turn off parsing first");
                return;
            }

            if (references.SelectedIndices.Count == 0)
            {
                return;
            }

            List<int> idTags = new List<int>();
            List<int> idOffs = new List<int>();

            for (int x = 0; x < references.SelectedIndices.Count; x++)
            {
                int d = references.SelectedIndices[x];
                int tempcount = 0;

                // Tag contains the position value of the item in SelectedMeta.Items
                int selectedIndex = (int)formFuncs.ListItems[d].Tag;

                Meta.Item item = map.SelectedMeta.items[selectedIndex];

                if (item.type == map.DisplayType)
                {
                    switch (item.type)
                    {
                        case Meta.ItemType.Ident:
                            Meta.Ident id = (Meta.Ident)item;
                            IdentSwapper iSwap = new IdentSwapper();
                            int iOffx = map.MetaInfo.Offset[map.SelectedMeta.TagIndex] + id.offset;
                            idTags.Add(id.pointstoTagIndex);
                            idOffs.Add(iOffx);
                            if (x == references.SelectedIndices.Count - 1)
                            {
                                iSwap.LoadStuff(idTags, idOffs, map);

                                iSwap.ShowDialog();
                                iSwap.Dispose();
                                x = references.SelectedIndices.Count;
                            }

                            break;
                        case Meta.ItemType.String:
                            Meta.String str = (Meta.String)item;
                            if (sSwap == null)
                            {
                                sSwap = new MEStringsSelector(map, this);
                            }

                            sSwap.SelectedID = str.id;
                            sSwap.ShowDialog();

                            // this.Enabled = true;

                            if (str.id != sSwap.SelectedID)
                            {
                                str.id = sSwap.SelectedID;
                                str.name = map.Strings.Name[sSwap.SelectedID];

                                // int sOffx = Map.MetaInfo.Offset[Map.SelectedMeta.TagIndex] + str.offset;
                                int sOffx = str.mapOffset;
                                map.OpenMap(MapTypes.Internal);
                                map.BW.BaseStream.Position = sOffx;
                                map.BW.Write((UInt16)str.id);
                                map.BR.ReadByte();
                                map.BW.Write((Byte)map.Strings.Length[sSwap.SelectedID]);
                                map.CloseMap();
                            }

                            break;
                        default:
                            break;
                    }
                }
            }

            map.CloseMap();
            LoadMeta(map.SelectedMeta.TagIndex);
            sortReferences(-1, false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// load strings in another thread with this method,
        /// as loading strings can be sloow
        /// </summary>
        /// <param name="names">The names.</param>
        /// <remarks></remarks>
        private void LoadStringsBackgroundWorker(Map map)
        {
            if (!this.Disposing && !this.IsDisposed)
                try
                {
                    // Wait for up to 10 seconds for map to close (if open) to avoid conflicts)
                    int count = 100;
                    while (map.isOpen)
                    {
                        Thread.Sleep(100);

                        // If time has elapsed, just forget the pre-loading of strings
                        if (count-- <= 0)
                            return;
                    }
                    // Pre-load string data
                    sSwap = new MEStringsSelector(map, this);
                }
                catch
                {
                }
        }
Ejemplo n.º 3
0
 private void StringEditorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (sSwap == null)
         sSwap = new MEStringsSelector(map, this);
     sSwap.ShowDialog();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapForm"/> class.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public MapForm(Map map)
        {
            RTHInfo = new RTHData();
            InitializeComponent();

            this.map = map;
            this.Text = map.filePath;

            // this is here so that we can see the panel in design mode
            // this.splitContainer4.SplitterDistance = this.splitContainer4.Height - 27;
            searchComboBox.SelectedIndex = 0;

            // Set up the delays for the ToolTip.
            toolTip.AutoPopDelay = 5000;
            toolTip.InitialDelay = 1000;
            toolTip.ReshowDelay = 500;

            // Force the ToolTip text to be displayed whether or not the form is active.
            toolTip.ShowAlways = true;

            toolTip.SetToolTip(
                this.recursiveCheckBox,
                "Utilizes all tags listed within the currently selected tag instead of just the root tag");
            toolTip.SetToolTip(
                this.parsedCheckBox, "Calculates tag sizes by reflexives instead of reading tag size from index\nDo NOT check when using meta editors!");
            toolTip.SetToolTip(this.soundsCheckBox, "Adds sounds into map when building");
            toolTip.SetToolTip(
                this.scanbspwithifp, "Scans reflexives, idents & strings using plugins instead of scanning manually");
            toolTip.SetToolTip(this.saveMetaButton, "Exports tag data");

            #region Load Strings Table <not in a background process>
            /*
            ThreadStart ts = delegate { LoadStringsBackgroundWorker(map); };
            Thread thr = new Thread(ts);
            thr.Start();
            */
            //var watch = System.Diagnostics.Stopwatch.StartNew();

            sSwap = new MEStringsSelector(map, this);

            //watch.Stop();
            //MessageBox.Show("String loading took: " + watch.ElapsedMilliseconds.ToString() + "ms");

            // Test results on my slow machine took ~550ms. Not worth the stream errors on faster machines using a seperate thread.

            #endregion

            // attempt to load custom skin
            try
            {
                LoadSkin();
            }
            catch
            {
                // Don't show skin errors EVERY time a map is opened. We perform a check when
                // the main form is loaded and display the error once then.

                // Global.ShowErrorMsg("There was an error while loading the skin",ex);
            }

            // display magic
            primaryMagicBox.Text = map.PrimaryMagic.ToString("X");
            secondaryMagicBox.Text = map.SecondaryMagic.ToString("X");

            // show tags in tree
            formFuncs.AddMetasToTreeView(map, treeView1, metaView, false);

            // Add plugins to menu
            plugins.Plugin.Add(Global.StartupPath + "\\Libraries");
            UpdatePluginsMenu();

            // display map image on form
            if (map.HaloVersion == HaloVersionEnum.Halo2 ||
                map.HaloVersion == HaloVersionEnum.Halo2Vista)
            {
                DisplayMapBitmap();
            }

            // format listview columns
            formFuncs.AddColumnsToListView(references, map.DisplayType);

            // Update the "Visual Editor" button to support multiple BSPs if
            // there are more than one
            if (map.BSP.bspcount > 1)
            {
                int index = toolStrip2.Items.IndexOf(toolStripBSPEditor);
                toolStrip2.Items.RemoveAt(index);
                toolStrip2.Items.Insert(index, toolStripBSPEditorDropDown);

                toolStripBSPEditorDropDown.DropDownItems.Clear();
                for (int x = 0; x < map.BSP.bspcount; x++)
                {
                    // create a dropdown button for each bsp
                    ToolStripMenuItem tsMenuItem = new ToolStripMenuItem();
                    tsMenuItem.Name = "toolStripMenuItem" + x;

                    // tsMenuItem.Size = new System.Drawing.Size(179, 22);
                    tsMenuItem.Text = map.FileNames.Name[map.BSP.sbsp[x].TagIndex];
                    tsMenuItem.Click += this.toolStripBSPEditor_Click;
                    toolStripBSPEditorDropDown.DropDownItems.Add(tsMenuItem);
                }
            }

            foreach (Prefs.CustomPluginMask mask in Prefs .CustomPluginMasks)
            {
                comboBox1.Items.Add(mask.Name);
            }

            // Default to Complete Plugin set
            comboBox1.SelectedItem = comboBox1.Items[0];

            // Set focus to the TAG tree list
            treeView1.Select();
        }