Esempio n. 1
0
 public static void UnpackVariables(Cache loaded_cache, DataBuffer data_file)
 {
     int cacheSize = data_file.ReadShort();
     if (cache == null)
         cache = new VarBit[cacheSize];
     Count = cacheSize;
     for (int j = 0; j < cacheSize; j++)
     {
         if (cache[j] == null)
             cache[j] = new VarBit();
         cache[j].ReadVariable(data_file);
         //if (cache[j].aBoolean651)
         //	Varp.cache[cache[j].anInt648].aBoolean713 = true;
     }
 }
Esempio n. 2
0
        public BatchExport(Cache cache, PluginContainer container)
        {
            InitializeComponent();
            Cache = cache;
            folder = new FolderBrowserDialog();

            foreach (string s in Cache.ArchiveNames)
                cboArchive.Items.Add(s);
            foreach (string s in Cache.SubNames)
                cboSub.Items.Add(s);
            cboSub.SelectedIndex = 0;
            cboArchive.SelectedIndex = 0;

            c_plugins = new List<PluginSelection>();
            foreach (IPlugin p in container.Plugins)
            {
                if (p.Classifications != null && (p.Classifications.Filenames.Length != 0 || p.Classifications.FileExtensions.Length != 0))
                    continue;
                string[] tes = p.StaticFileExtensions.Split('|');
                for (int i = 0; i < tes.Length; i += 2)
                {
                    if (tes[i] != "")
                    {
                        cboType.Items.Add(tes[i] + " [" + p.Name + "]");
                        c_plugins.Add(new PluginSelection(p, tes[i + 1]));
                    }
                }
            }

            if (cboType.Items.Count == 0)
            {
                MessageBox.Show("No suitable plugins for exporting data found.", "Cannot Export Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            cboType.SelectedIndex = 0;
        }
Esempio n. 3
0
        public bool Write(Cache cache, CacheItemNode node, DataBuffer original)
        {
            try
            {
                DataBuffer index_data = cache.SubArchives[node.SubArchive].ExtractFile("index.dat");
                original.Location = 0;
                index_data.Location = original.ReadShort() + 4;
                byte pcount = index_data.ReadByte();
                if (pcount >= Palette.Length)
                    index_data.Location -= 5;
                else //move to back
                {
                    index_data.Location = index_data.Buffer.Length;
                    byte[] temp = new byte[index_data.Buffer.Length + 12 + Palette.Length * 3];
                    Array.Copy(index_data.Buffer, temp, index_data.Buffer.Length);
                    index_data.Buffer = temp;
                }
                IndexLocation = index_data.Location;
                index_data.WriteShort(WholeWidth);
                index_data.WriteShort(WholeHeight);
                index_data.WriteByte((byte)Palette.Length);
                for (int i = 0; i < Palette.Length - 1; i++)
                {
                    index_data.WriteByte(Palette[i].R);
                    index_data.WriteByte(Palette[i].G);
                    index_data.WriteByte(Palette[i].B);
                }
                index_data.WriteByte((byte)XOffset);
                index_data.WriteByte((byte)YOffset);
                index_data.WriteShort(Width);
                index_data.WriteShort(Height);

                index_data.WriteByte(0); //x, y (1 is y, x)
                byte[] data = new byte[Width * Height + 2];
                data[0] = (byte)(IndexLocation >> 8);
                data[1] = (byte)IndexLocation;
                for (int i = 0; i < Width * Height; i++)
                {
                    //todo: optimize
                    Color c = Pixels[i];
                    for (int k = 0; k < Palette.Length; k++)
                    {
                        if (Palette[k].R == c.R && Palette[k].G == c.G && Palette[k].B == c.B && Palette[k].A == c.A)
                        {
                            if (c.A == 0)
                                data[i + 2] = 0;
                            else
                                data[i + 2] = (byte)(k + 1);
                        }
                    }
                }

                cache.SubArchives[node.SubArchive].WriteFile("index.dat", index_data.Buffer);
                cache.SubArchives[node.SubArchive].WriteFile(node.FileIndex, data);
                cache.SubArchives[node.SubArchive].RewriteArchive();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Esempio n. 4
0
 public RSImage(Cache cache, CacheItemNode node, DataBuffer image_data, int sprite_index = 0)
     : this(cache.SubArchives[node.SubArchive], image_data, sprite_index)
 {
 }
Esempio n. 5
0
 public static void LoadTextures(Cache cache)
 {
     loaded_texture_count = 0;
     for (int j = 0; j < 50; j++)
         try
         {
             textures[j] = new RSImage(cache.SubArchives[6], j);
             textures[j].ResizeToWhole();
             //texture_cache[j] = textures[j].;
             //if (low_memory && textures[j].WholeWidth == 128)
             //	textures[j].LoadHalf();
             //else
             //	textures[j].LoadFull();
             loaded_texture_count++;
         }
         catch (Exception) { }
 }
Esempio n. 6
0
        public static void UnpackObjects(Cache loaded_cache, DataBuffer data_file, DataBuffer index_file)
        {
            LoadedCache = loaded_cache;
            stream = data_file;
            DataBuffer index_stream = index_file;
            int totalObjects = index_stream.ReadShort();
            streamIndices = new int[totalObjects];
            int i = 2;
            for (int j = 0; j < totalObjects; j++)
            {
                streamIndices[j] = i;
                i += index_stream.ReadShort();
            }

            cache = new ObjectDefinition[20];
            for (int k = 0; k < 20; k++)
                cache[k] = new ObjectDefinition();
        }
Esempio n. 7
0
        private void openCacheFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog f = new FolderBrowserDialog();
            f.SelectedPath = "C:\\rscache\\";
            if (f.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                return;

            tbPlugins.TabPages.Clear();
            if (Cache != null)
                Cache.Close();
            Cache = new Cache();

            try
            {
                Cache.LoadCache(f.SelectedPath + Path.DirectorySeparatorChar);
                SetBLE(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading cache.\n\n" + ex.Message + "\n\n" + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SetBLE(false);
                return;
            }

            PopulateFileBrowser();
        }