Esempio n. 1
0
 private void ImportScriptModule(string fileName)
 {
     try
     {
         string        destFileName = FindFirstAvailableFileName(Path.GetFileNameWithoutExtension(fileName));
         List <Script> newScripts   = ImportExport.ImportScriptModule(fileName, _agsEditor.CurrentGame.TextEncoding);
         newScripts[0].FileName = destFileName + ".ash";
         newScripts[1].FileName = destFileName + ".asc";
         newScripts[0].Modified = true;
         newScripts[1].Modified = true;
         newScripts[0].SaveToDisk();
         newScripts[1].SaveToDisk();
         ScriptAndHeader scripts = new ScriptAndHeader(newScripts[0], newScripts[1]);
         AddSingleItem(scripts);
         _agsEditor.CurrentGame.FilesAddedOrRemoved = true;
         RePopulateTreeView(GetNodeID(scripts));
         foreach (Script script in newScripts)
         {
             AutoComplete.ConstructCache(script, _agsEditor.GetImportedScriptHeaders(script));
         }
     }
     catch (Exception ex)
     {
         _guiController.ShowMessage("An error occurred trying to import the script module. The error details are below." + Environment.NewLine + Environment.NewLine + ex.ToString(), MessageBoxIcon.Warning);
     }
 }
        private void UpdateScriptHeader()
        {
            StringBuilder sb = new StringBuilder();

            foreach (GlobalVariable variable in _agsEditor.CurrentGame.GlobalVariables.ToList())
            {
                sb.AppendLine("import " + variable.Type + " " + variable.Name + ";");
            }
            _scriptHeader.Text = sb.ToString();
            AutoComplete.ConstructCache(_scriptHeader);
        }