Exemplo n.º 1
0
        private void mSaveScriptChangesButton_Click(object sender, EventArgs e)
        {
            string        newFileName = null;
            AssetListItem item        = mAssetListBox.SelectedItem as AssetListItem;

            if (item != null)
            {
                newFileName = item.SpliceInNewCode(mScriptTextBox.Text);
            }
            if (newFileName != null)
            {
                int index = mAssetListBox.SelectedIndex;
                PopulateListBox(newFileName);
                mAssetListBox.TopIndex = index;
            }
        }
Exemplo n.º 2
0
        private void mExtractAssetButton_Click(object sender, EventArgs e)
        {
            string fileName = StringInputDlg.GetString("Extract to File", "File name");

            if (fileName != null)
            {
                try
                {
                    AssetListItem item = mAssetListBox.SelectedItem as AssetListItem;
                    File.WriteAllBytes(fileName, item.GetAssetData());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error saving file!", ex.Message);
                }
            }
        }
Exemplo n.º 3
0
 private void UpdateLuaDetails()
 {
     if (mAssetListBox.SelectedIndex > -1)
     {
         AssetListItem item = mAssetListBox.Items[mAssetListBox.SelectedIndex] as AssetListItem;
         mScriptTextBox.Text = item.GetDisplayData();
         if (item.IsLuaCode)
         {
             ShowCodeSize();
         }
         else
         {
             mLuacCodeSizeTextBox.Text = "";
         }
         mScriptTextBox.SelectionStart = 0;
         mScriptTextBox.ScrollToCaret();
         if (ShowDecompiledLuaCode || ShowPcLuaCode)
         {
             ColorizeText();
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns AssetList items matching the search criteria
        /// </summary>
        /// <param name="data">The file bytes; something like 'File.ReadAllBytes(fileName);'</param>
        /// <param name="searchBytes">asset type; should be something like 'src_', 'tex_' or 'fx__'; but "LuaP" also works;
        ///  I use  'ASCIIEncoding.ASCII.GetBytes("LuaP")' often.
        ///  1-line usage:
        ///    'GetItems(File.ReadAllBytes(fileName),ASCIIEncoding.ASCII.GetBytes("LuaP"));'
        /// </param>
        /// <returns></returns>
        public static List <AssetListItem> GetItems(byte[] data, byte[] searchBytes)
        {
            List <long>          locations = BinSearch.GetLocationsOfGivenBytes(0L, searchBytes, data);
            List <AssetListItem> retVal    = new List <AssetListItem>();
            AssetListItem        item      = null;

            foreach (long loc in locations)
            {
                item = new AssetListItem(loc, data, searchBytes);
                if (BinSearch.GetLocationOfGivenBytes(loc, BodyBytes, data, 80L) > 0)
                {
                    retVal.Add(item);
                }
                else
                {
                    // NEED TO FIND OUT WHAT SOME OF THESE ARE!!!
                    // System.Diagnostics.Debugger.Log(1, "INFO", "Not adding item:" + item.ToString());
                    Console.Error.WriteLine("I don't know how to classify this item: " + item.ToString());
                    retVal.Add(item);
                }
            }
            return(retVal);
        }