示例#1
0
        private void OnClickReplace(object sender, EventArgs e)
        {
            if (_selected < 0)
            {
                return;
            }

            using (OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.Multiselect     = false;
                dialog.Title           = "Choose image file to replace";
                dialog.CheckFileExists = true;
                dialog.Filter          = "Image files (*.tif;*.tiff;*.bmp)|*.tif;*.tiff;*.bmp";
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                Bitmap bmp = new Bitmap(dialog.FileName);
                if (dialog.FileName.Contains(".bmp"))
                {
                    bmp = Utils.ConvertBmp(bmp);
                }

                Textures.Replace(_selected, bmp);
                ControlEvents.FireTextureChangeEvent(this, _selected);
                pictureBox.Invalidate();
                Options.ChangedUltimaClass["Texture"] = true;
            }
        }
示例#2
0
        private void CopyAddOnly_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 0x4000; i++)
            {
                if (!SecondTexture.IsValidTexture(i))
                {
                    continue;
                }

                if (Textures.TestTexture(i))
                {
                    continue;
                }

                Bitmap copy = new Bitmap(SecondTexture.GetTexture(i));
                Textures.Replace(i, copy);
                ControlEvents.FireTextureChangeEvent(this, i);
            }

            _mCompare.Clear();
            listBoxOrg.BeginUpdate();
            listBoxOrg.Items.Clear();
            List <object> cache = new List <object>();

            for (int i = 0; i < 0x4000; i++)
            {
                cache.Add(i);
            }
            listBoxOrg.Items.AddRange(cache.ToArray());
            listBoxOrg.EndUpdate();
        }
示例#3
0
        private void OnClickRemove(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }

            int          i      = (int)listView1.SelectedItems[0].Tag;
            DialogResult result =
                MessageBox.Show($"Are you sure to remove 0x{i:X}",
                                "Save",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2);

            if (result != DialogResult.Yes)
            {
                return;
            }

            Textures.Remove(i);
            ControlEvents.FireTextureChangeEvent(this, i);
            i = listView1.SelectedItems[0].Index;
            listView1.SelectedItems[0].Selected = false;
            listView1.Items.RemoveAt(i);
            listView1.Invalidate();
            Options.ChangedUltimaClass["Texture"] = true;
        }
示例#4
0
        private void OnClickRemove(object sender, EventArgs e)
        {
            if (_selected < 0)
            {
                return;
            }

            DialogResult result =
                MessageBox.Show($"Are you sure to remove 0x{_selected:X}",
                                "Save",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2);

            if (result != DialogResult.Yes)
            {
                return;
            }

            Textures.Remove(_selected);
            ControlEvents.FireTextureChangeEvent(this, _selected);
            _textureList.Remove(_selected);
            --_selected;
            pictureBox.Invalidate();
            Options.ChangedUltimaClass["Texture"] = true;
        }
示例#5
0
        private void OnClickCopy(object sender, EventArgs e)
        {
            if (listBoxSec.SelectedIndex == -1)
            {
                return;
            }

            int i = int.Parse(listBoxSec.Items[listBoxSec.SelectedIndex].ToString());

            if (!SecondTexture.IsValidTexture(i))
            {
                return;
            }

            Bitmap copy = new Bitmap(SecondTexture.GetTexture(i));

            Textures.Replace(i, copy);
            Options.ChangedUltimaClass["Texture"] = true;
            ControlEvents.FireTextureChangeEvent(this, i);
            _mCompare[i] = true;
            listBoxOrg.BeginUpdate();
            bool done = false;

            for (int id = 0; id < 0x4000; id++)
            {
                if (id > i)
                {
                    listBoxOrg.Items.Insert(id, i);
                    done = true;
                    break;
                }

                if (id == i)
                {
                    done = true;
                    break;
                }
            }

            if (!done)
            {
                listBoxOrg.Items.Add(i);
            }

            listBoxOrg.EndUpdate();
            listBoxOrg.Invalidate();
            listBoxSec.Invalidate();
            OnIndexChangedOrg(this, null);
        }
示例#6
0
        private void OnClickReplace(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count != 1)
            {
                return;
            }

            using (OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.Multiselect     = false;
                dialog.Title           = "Choose image file to replace";
                dialog.CheckFileExists = true;
                dialog.Filter          = "Image files (*.tif;*.tiff;*.bmp)|*.tif;*.tiff;*.bmp";
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                Bitmap bmp = new Bitmap(dialog.FileName);
                if ((bmp.Width == 64 && bmp.Height == 64) || (bmp.Width == 128 && bmp.Height == 128))
                {
                    if (dialog.FileName.Contains(".bmp"))
                    {
                        bmp = Utils.ConvertBmp(bmp);
                    }

                    int i = (int)listView1.SelectedItems[0].Tag;
                    Textures.Replace(i, bmp);
                    ControlEvents.FireTextureChangeEvent(this, i);
                    listView1.Invalidate();
                    ListView_SelectedIndexChanged(this, null);
                    Options.ChangedUltimaClass["Texture"] = true;
                }
                else
                {
                    MessageBox.Show("Height or Width Invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error,
                                    MessageBoxDefaultButton.Button1);
                }
            }
        }
示例#7
0
        public override void Import(bool direct, ref Dictionary <string, bool> changedClasses)
        {
            if (!Remove)
            {
                Bitmap import = new Bitmap(File);
                if (File.Contains(".bmp"))
                {
                    import = Utils.ConvertBmp(import);
                }
                Ultima.Textures.Replace(Index, import);
            }
            else
            {
                Ultima.Textures.Remove(Index);
            }

            if (!direct)
            {
                ControlEvents.FireTextureChangeEvent(this, Index);
                Options.ChangedUltimaClass["Texture"] = true;
            }

            changedClasses["Texture"] = true;
        }