Ejemplo n.º 1
0
        public void LoadUserKeywords(IModuleData Data)
        {
            if (Data != null && Data.ModuleSettings != null)
            {
                if (File.Exists(Data.ModuleSettings.UserKeywordsFile))
                {
                    LoadUserKeywords(Data, Data.ModuleSettings.UserKeywordsFile);
                }
                else
                {
                    if (File.Exists(DefaultPaths.ModuleKeywordsFile(Data)))
                    {
                        LoadUserKeywords(Data, DefaultPaths.ModuleKeywordsFile(Data));
                    }
                    else
                    {
                        if (Data.UserKeywords == null)
                        {
                            Data.UserKeywords = new UserKeywordData();
                            Data.UserKeywords.ResetToDefault();

                            FileCommands.Save.SaveUserKeywords(Data);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void button_Reset_Click(object sender, EventArgs e)
        {
            DialogResult result = DarkMessageBox.Show(this, "Are you sure you want to restore the default image?", "Are you sure?",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                try
                {
                    string sourcePakPath = string.Empty;

                    if (_ide.Project.GameVersion == TRVersion.Game.TR4 || _ide.Project.GameVersion == TRVersion.Game.TRNG)
                    {
                        sourcePakPath = Path.Combine(DefaultPaths.GetDefaultTemplatesPath(_ide.Project.GameVersion), "uklogo.pak");
                    }
                    else if (_ide.Project.GameVersion == TRVersion.Game.TR5Main)
                    {
                        sourcePakPath = Path.Combine(DefaultPaths.GetDefaultTemplatesPath(_ide.Project.GameVersion), "uklogo.pak");
                    }

                    string destPakPath = Path.Combine(_ide.Project.EnginePath, @"data\uklogo.pak");

                    File.Copy(sourcePakPath, destPakPath, true);
                    UpdatePreview();
                }
                catch (Exception ex)
                {
                    DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 3
0
        private void UpdateDataGrid()
        {
            dataGrid.Columns.Clear();

            try
            {
                string xmlPath = Path.Combine(DefaultPaths.GetReferencesPath(), comboBox_References.SelectedItem + ".xml");

                using (XmlReader reader = XmlReader.Create(xmlPath))
                    using (DataSet dataSet = new DataSet())
                    {
                        dataSet.ReadXml(reader);

                        DataTable dataTable = dataSet.Tables[0];

                        if (comboBox_References.SelectedIndex == 0)
                        {
                            DataTable pluginMnemonicTable = GetPluginMnemonicTable();

                            foreach (DataRow row in pluginMnemonicTable.Rows)
                            {
                                dataTable.Rows.Add(row.ItemArray[0].ToString(), row.ItemArray[1].ToString(), row.ItemArray[2].ToString());
                            }
                        }

                        DataColumn dcRowString = dataTable.Columns.Add("_RowString", typeof(string));

                        foreach (DataRow dataRow in dataTable.Rows)
                        {
                            StringBuilder builder = new StringBuilder();

                            for (int i = 0; i < dataTable.Columns.Count - 1; i++)
                            {
                                builder.Append(dataRow[i].ToString());
                                builder.Append("\t");
                            }

                            dataRow[dcRowString] = builder.ToString();
                        }

                        string filter = string.Empty;

                        if (!string.IsNullOrWhiteSpace(textBox_Search.Text) && textBox_Search.Text != "Search references...")
                        {
                            filter = textBox_Search.Text.Trim();
                        }

                        dataTable.DefaultView.RowFilter = "[_RowString] LIKE '%" + filter + "%'";

                        dataGrid.DataSource = dataTable;
                        dataGrid.Columns["_RowString"].Visible = false;

                        SetFriendlyColumnHeaders();
                    }
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public string SaveTextGeneratorData()
        {
            var outputDataPath = Path.Combine(DefaultPaths.RootFolder, "Default", "TextGenerator", "TextGenerator.json");

            try
            {
                var json = JsonConvert.SerializeObject(MainWindow.TextGeneratorWindow.Data, Newtonsoft.Json.Formatting.Indented);

                if (CurrentModule != null)
                {
                    outputDataPath = DefaultPaths.ModuleTextGeneratorDataFile(CurrentModule.ModuleData);
                }

                if (FileCommands.WriteToFile(outputDataPath, json))
                {
                    string msg = $"TextGenerator settings were saved to '{outputDataPath}'.";
                    Log.Here().Activity(msg);
                    return(msg);
                }
                else
                {
                    string msg = $"Error saving TextGenerator settings to '{outputDataPath}'.";
                    Log.Here().Error(msg);
                    return(msg);
                }
            }
            catch (Exception ex)
            {
                Log.Here().Error($"Error loading TextGenerator data file: {ex.ToString()}");
                return($"Error saving TextGenerator settings to '{outputDataPath}'. Check the log.");
            }
        }
        private void button_BatchBuild_Click(object sender, EventArgs e)
        {
            BatchCompileList batchList = new BatchCompileList();

            foreach (ProjectLevel level in _ide.Project.Levels)
            {
                string prj2Path;

                if (level.SpecificFile == "$(LatestFile)")
                {
                    prj2Path = Path.Combine(level.FolderPath, level.GetLatestPrj2File());
                }
                else
                {
                    prj2Path = Path.Combine(level.FolderPath, level.SpecificFile);
                }

                batchList.Files.Add(prj2Path);
            }

            string batchListFilePath = Path.Combine(Path.GetTempPath(), "tide_batch.xml");

            BatchCompileList.SaveToXml(batchListFilePath, batchList);

            ProcessStartInfo startInfo = new ProcessStartInfo
            {
                FileName  = Path.Combine(DefaultPaths.GetProgramDirectory(), "TombEditor.exe"),
                Arguments = "\"" + batchListFilePath + "\""
            };

            Process.Start(startInfo);
        }
Ejemplo n.º 6
0
        private void button_Reset_Click(object sender, EventArgs e)
        {
            DialogResult result = DarkMessageBox.Show(this, "Are you sure you want to restore the default icon?", "Are you sure?",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                string icoFilePath = string.Empty;

                if (_ide.Project.GameVersion == TRVersion.Game.TR4 || _ide.Project.GameVersion == TRVersion.Game.TRNG)
                {
                    if (_ide.Project.GameVersion == TRVersion.Game.TRNG && File.Exists(Path.Combine(_ide.Project.EnginePath, "flep.exe")))
                    {
                        icoFilePath = Path.Combine(DefaultPaths.GetDefaultTemplatesPath(_ide.Project.GameVersion), "FLEP.ico");
                    }
                    else
                    {
                        icoFilePath = Path.Combine(DefaultPaths.GetDefaultTemplatesPath(_ide.Project.GameVersion), _ide.Project.GameVersion + ".ico");
                    }
                }
                else if (_ide.Project.GameVersion == TRVersion.Game.TR5Main)
                {
                    icoFilePath = Path.Combine(DefaultPaths.GetDefaultTemplatesPath(_ide.Project.GameVersion), _ide.Project.GameVersion + ".ico");
                }

                ApplyIconToExe(icoFilePath);
            }
        }
Ejemplo n.º 7
0
        private void HandleScriptReferenceFiles()
        {
            string[] referenceFiles = Directory.GetFiles(DefaultPaths.GetInternalNGCPath(), "plugin_*.script", SearchOption.TopDirectoryOnly);

            // Delete all .script files from the internal /NGC/ folder
            foreach (string file in referenceFiles)
            {
                File.Delete(file);
            }

            // Only copy .script files of plugins which are actually used in the current project
            foreach (Plugin plugin in _ide.Project.InstalledPlugins)
            {
                if (string.IsNullOrEmpty(plugin.InternalDllPath))
                {
                    continue;
                }

                string scriptFilePath = Path.Combine(Path.GetDirectoryName(plugin.InternalDllPath), Path.GetFileNameWithoutExtension(plugin.InternalDllPath) + ".script");

                if (File.Exists(scriptFilePath))
                {
                    string destPath = Path.Combine(DefaultPaths.GetInternalNGCPath(), Path.GetFileName(scriptFilePath));
                    File.Copy(scriptFilePath, destPath, true);
                }
            }
        }
        private void OpenSelectedResource()
        {
            if (treeView_Resources.SelectedNodes.Count == 0)
            {
                return;
            }

            // Check if the clicked node is not a default node
            if (treeView_Resources.Nodes.Contains(treeView_Resources.SelectedNodes[0]))
            {
                return;
            }

            try
            {
                ProcessStartInfo startInfo = new ProcessStartInfo();

                if (treeView_Resources.SelectedNodes[0].ParentNode == treeView_Resources.Nodes[1])                 // Wad handling
                {
                    startInfo.FileName  = Path.Combine(DefaultPaths.GetProgramDirectory(), "WadTool.exe");
                    startInfo.Arguments = "\"" + treeView_Resources.SelectedNodes[0].Text + "\"";
                }
                else
                {
                    startInfo.FileName = treeView_Resources.SelectedNodes[0].Text;
                }

                Process.Start(startInfo);
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 9
0
        private void InstallEngine(Project project)
        {
            string engineBasePath = DefaultPaths.GetEngineTemplatesPath();

            switch (comboBox_EngineType.SelectedIndex)
            {
            case 1:
                engineBasePath = Path.Combine(engineBasePath, "TRNG.zip");
                break;

            case 2:
                engineBasePath = Path.Combine(engineBasePath, "TRNG + FLEP.zip");
                break;
            }

            string sharedArchivePath = Path.Combine(DefaultPaths.GetSharedTemplatesPath(project.GameVersion), "Shared.zip");

            // Extract the engine base into the ProjectPath folder
            using (ZipArchive engineArchive = new ZipArchive(File.OpenRead(engineBasePath)))
            {
                using (ZipArchive sharedArchive = new ZipArchive(File.OpenRead(sharedArchivePath)))
                {
                    progressBar.Maximum = engineArchive.Entries.Count + sharedArchive.Entries.Count + 1;

                    foreach (ZipArchiveEntry entry in engineArchive.Entries)
                    {
                        if (entry.FullName.EndsWith("/"))
                        {
                            Directory.CreateDirectory(Path.Combine(project.ProjectPath, entry.FullName));
                        }
                        else
                        {
                            entry.ExtractToFile(Path.Combine(project.ProjectPath, entry.FullName));
                        }

                        progressBar.Increment(1);
                    }

                    foreach (ZipArchiveEntry entry in sharedArchive.Entries)
                    {
                        if (entry.FullName.EndsWith("/"))
                        {
                            Directory.CreateDirectory(Path.Combine(project.ProjectPath, entry.FullName));
                        }
                        else
                        {
                            entry.ExtractToFile(Path.Combine(project.ProjectPath, entry.FullName));
                        }

                        progressBar.Increment(1);
                    }
                }
            }

            // Save the .trproj file
            project.Save();             // .trproj = .xml but .trproj can be opened with TombIDE

            progressBar.Increment(1);   // 100%
        }
Ejemplo n.º 10
0
        public ClassicScriptEditorConfiguration()
        {
            DefaultPath = Path.Combine(DefaultPaths.GetTextEditorConfigsPath(), ClassicScriptEditorDefaults.ConfigurationFileName);

            // These type of brackets aren't being used while writing in Classic Script, therefore auto closing should be disabled for them
            AutoCloseParentheses = false;
            AutoCloseBraces      = false;
        }
Ejemplo n.º 11
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            try
            {
                string newName = RemoveIllegalPathSymbols(textBox_Name.Text).Trim();

                if (string.IsNullOrWhiteSpace(newName))
                {
                    throw new ArgumentException("Invalid name.");
                }

                string schemeFilePath = null;

                switch (_schemeType)
                {
                case ColorSchemeType.ClassicScript:
                {
                    string schemeFolderPath = DefaultPaths.GetClassicScriptColorConfigsPath();

                    foreach (string file in Directory.GetFiles(schemeFolderPath, "*.cssch", SearchOption.TopDirectoryOnly))
                    {
                        if (Path.GetFileNameWithoutExtension(file).Equals(newName, StringComparison.OrdinalIgnoreCase))
                        {
                            throw new ArgumentException("A scheme with the same name already exists.");
                        }
                    }

                    schemeFilePath = Path.Combine(schemeFolderPath, newName + ".cssch");
                    break;
                }

                case ColorSchemeType.Lua:
                {
                    string schemeFolderPath = DefaultPaths.GetLuaColorConfigsPath();

                    foreach (string file in Directory.GetFiles(schemeFolderPath, "*.luasch", SearchOption.TopDirectoryOnly))
                    {
                        if (Path.GetFileNameWithoutExtension(file).Equals(newName, StringComparison.OrdinalIgnoreCase))
                        {
                            throw new ArgumentException("A scheme with the same name already exists.");
                        }
                    }

                    schemeFilePath = Path.Combine(schemeFolderPath, newName + ".luasch");
                    break;
                }
                }

                // // // //
                SchemeFilePath = schemeFilePath;
                // // // //
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
        }
Ejemplo n.º 12
0
        private void button_OpenSchemesFolder_Click(object sender, EventArgs e)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo
            {
                FileName  = "explorer.exe",
                Arguments = DefaultPaths.GetClassicScriptColorConfigsPath()
            };

            Process.Start(startInfo);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Initialiazes the config
 /// </summary>
 private static void InitConfig()
 {
     _config       = new Config();
     _config.Paths = new ObservableCollection <Path>(DefaultPaths.GetDefault());
     _config.DefaultFileExtensions.AddRange(HelperClasses.DefaultFileExtensions.GetDefault());
     _config.ShortcutManagerSettings = new ShortcutManagerSettings();
     _config.Persist();
     RegistryHelper.AssociateFileExtension();
     RegistryHelper.RegisterCustomProtocol();
 }
Ejemplo n.º 14
0
 public virtual void SetToDefault(IModuleData Data)
 {
     BackupRootDirectory  = DefaultPaths.ModuleBackupsFolder(Data);
     GitRootDirectory     = DefaultPaths.ModuleProjectsFolder(Data);
     AddedProjectsFile    = DefaultPaths.ModuleAddedProjectsFile(Data);
     TemplateSettingsFile = DefaultPaths.ModuleTemplateSettingsFile(Data);
     UserKeywordsFile     = DefaultPaths.ModuleKeywordsFile(Data);
     GitGenSettingsFile   = DefaultPaths.ModuleGitGenSettingsFile(Data);
     //BackupMode = BackupMode.Zip;
 }
        public void SaveModuleSettings(IModuleData Data)
        {
            Log.Here().Activity("Saving module settings to {0}", Path.GetFullPath(DefaultPaths.ModuleSettingsFile(Data)));

            if (Data.ModuleSettings != null)
            {
                SaveTemplates(Data);
                string json = JsonConvert.SerializeObject(Data.ModuleSettings, Newtonsoft.Json.Formatting.Indented);
                FileCommands.WriteToFile(DefaultPaths.ModuleSettingsFile(Data), json);
            }
        }
Ejemplo n.º 16
0
        private static void UpdateNGCompilerPaths()
        {
            try
            {
                string programPath = DefaultPaths.GetProgramDirectory();

                if (IsUnicodePath(programPath))
                {
                    throw new ArgumentException(
                              "Your executing path contains non-ASCII symbols. This will not allow the compilers to work correctly.\n" +
                              "Please consider removing all non-ASCII symbols from the executing path before launching TombIDE.");
                }

                string virtualEnginePath = DefaultPaths.GetVGEPath();

                if (virtualEnginePath.Length > 255)
                {
                    throw new PathTooLongException(
                              "Your executing path is too long. Please consider shortening your executing path " +
                              "to a maximum of 244 symbols before launching TombIDE.");
                }

                byte[] stringBytes = Encoding.ASCII.GetBytes(virtualEnginePath);

                byte[] bytesToWrite_01 = Enumerable.Repeat((byte)0x20, 2560).ToArray();
                // Make room for the VGE path in the bytesToWrite_01 array
                bytesToWrite_01 = bytesToWrite_01.Skip(stringBytes.Length).ToArray();
                // Merge the stringBytes array with the leftover items from the bytesToWrite_01 array, so the full array size is still 2560
                bytesToWrite_01 = stringBytes.Concat(bytesToWrite_01).ToArray();

                byte[] bytesToWrite_02 = Enumerable.Repeat((byte)0x20, 256).ToArray();
                // Make room for the VGE path in the bytesToWrite_02 array
                bytesToWrite_02 = bytesToWrite_02.Skip(stringBytes.Length).ToArray();
                // Merge the stringBytes array with the leftover items from the bytesToWrite_02 array, so the full array size is still 256
                bytesToWrite_02 = stringBytes.Concat(bytesToWrite_02).ToArray();

                string centerSettingsFilePath = Path.Combine(programPath, "TIDE", "NGC", "center_settings.bin");

                using (FileStream stream = File.OpenWrite(centerSettingsFilePath))
                {
                    stream.Position = 4;                     // First game path offset
                    stream.Write(bytesToWrite_01, 0, bytesToWrite_01.Length);

                    stream.Position = 2820;                     // Second game path offset
                    stream.Write(bytesToWrite_02, 0, bytesToWrite_02.Length);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }
        }
Ejemplo n.º 17
0
        private void InstallPluginIntoTombIDE(string path)
        {
            try
            {
                string pluginsFolderPath = DefaultPaths.GetTRNGPluginsPath();                 // Internal TombIDE folder

                if (!Directory.Exists(pluginsFolderPath))
                {
                    Directory.CreateDirectory(pluginsFolderPath);
                }

                // Check for plugin directory name duplicates
                foreach (string directory in Directory.GetDirectories(pluginsFolderPath))
                {
                    if (Path.GetFileName(directory).ToLower() == Path.GetFileNameWithoutExtension(path).ToLower())
                    {
                        throw new ArgumentException("Plugin already installed.");
                    }
                }

                string extractionPath = Path.Combine(pluginsFolderPath, Path.GetFileNameWithoutExtension(path));

                // Check if the path is for a folder
                if ((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    InstallPluginFromFolder(path, extractionPath);
                }
                else
                {
                    InstallPluginArchive(path, extractionPath);
                }

                Plugin plugin = Plugin.InstallPluginFolder(extractionPath);

                // Check for name duplicates
                foreach (Plugin availablePlugin in _ide.AvailablePlugins)
                {
                    if (availablePlugin.Name.ToLower() == plugin.Name.ToLower())
                    {
                        Directory.Delete(extractionPath, true);
                        throw new ArgumentException("A plugin with the same name already exists on the list.");
                    }
                }

                _ide.RefreshPluginLists();
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 18
0
        public void Initialize(IDE ide)
        {
            _ide = ide;
            _ide.IDEEventRaised += OnIDEEventRaised;

            // Initialize the watchers
            prj2FileWatcher.Path    = _ide.Project.LevelsPath;
            levelFolderWatcher.Path = _ide.Project.LevelsPath;

            string pluginsFolderPath = DefaultPaths.GetTRNGPluginsPath();

            if (!Directory.Exists(pluginsFolderPath))
            {
                Directory.CreateDirectory(pluginsFolderPath);
            }

            projectDLLFileWatcher.Path       = _ide.Project.EnginePath;
            internalDLLFileWatcher.Path      = pluginsFolderPath;
            internalPluginFolderWatcher.Path = pluginsFolderPath;

            // Initialize the sections
            section_LevelList.Initialize(_ide);
            section_LevelProperties.Initialize(_ide);
            section_ProjectInfo.Initialize(_ide);
            section_PluginList.Initialize(_ide);

            if (_ide.Project.GameVersion == TRVersion.Game.TR4)
            {
                button_ShowPlugins.Enabled = false;
                button_ShowPlugins.Visible = false;

                splitContainer_Info.Panel2Collapsed = true;
            }
            else if (_ide.IDEConfiguration.PluginsPanelHidden)
            {
                button_ShowPlugins.Enabled = true;
                button_ShowPlugins.Visible = true;

                splitContainer_Info.Panel2Collapsed = true;
            }
            else if (!_ide.IDEConfiguration.PluginsPanelHidden)
            {
                button_ShowPlugins.Enabled = false;
                button_ShowPlugins.Visible = false;

                splitContainer_Info.Panel2Collapsed = false;
            }

            CheckPlugins();
        }
Ejemplo n.º 19
0
 public void LoadModuleSettings(IModuleData Data)
 {
     if (File.Exists(DefaultPaths.ModuleSettingsFile(Data)))
     {
         Log.Here().Activity("Loading settings from {0}", DefaultPaths.ModuleSettingsFile(Data));
         Data.LoadSettings();
     }
     else
     {
         Log.Here().Warning("settings file at {0} not found. Creating new file.", DefaultPaths.ModuleSettingsFile(Data));
         Data.InitializeSettings();
         SaveAppSettings = true;
     }
 }
Ejemplo n.º 20
0
        private void comboBox_ColorSchemes_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox_ColorSchemes.Items.Count == 1)
            {
                button_DeleteScheme.Enabled = false;                 // Disallow deleting the last available scheme
            }
            ToggleSaveSchemeButton();

            string fullSchemePath = Path.Combine(DefaultPaths.GetClassicScriptColorConfigsPath(), comboBox_ColorSchemes.SelectedItem.ToString() + ".cssch");
            ClassicScriptColorScheme selectedScheme = XmlHandling.ReadXmlFile <ClassicScriptColorScheme>(fullSchemePath);

            UpdateColorButtons(selectedScheme);
            UpdatePreviewColors(selectedScheme);
        }
Ejemplo n.º 21
0
        private void button_ImportScheme_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.Filter = "Classic Script Scheme|*.cssch";

                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    File.Copy(dialog.FileName, Path.Combine(DefaultPaths.GetClassicScriptColorConfigsPath(), Path.GetFileName(dialog.FileName)), true);
                    UpdateSchemeList();

                    comboBox_ColorSchemes.SelectedItem = Path.GetFileNameWithoutExtension(dialog.FileName);
                }
            }
        }
Ejemplo n.º 22
0
        public void LoadTemplates(IModuleData Data)
        {
            string templateFilePath = DefaultPaths.ModuleTemplateSettingsFile(Data);

            if (File.Exists(Data.ModuleSettings.TemplateSettingsFile))
            {
                templateFilePath = Data.ModuleSettings.TemplateSettingsFile;
            }
            else if (!File.Exists(templateFilePath))
            {
                FileCommands.WriteToFile(templateFilePath, Properties.Resources.Templates);
            }

            XDocument templateXml = null;

            try
            {
                templateXml = XDocument.Load(templateFilePath);

                foreach (var template in templateXml.Descendants("Template"))
                {
                    TemplateEditorData templateData = TemplateEditorData.LoadFromXml(Data, template);
                    Data.Templates.Add(templateData);
                }
            }
            catch (Exception ex)
            {
                Log.Here().Error(Message: $"Error loading template file {templateFilePath}: {ex.ToString()}");
            }

            if (Data.ModuleSettings.TemplateFiles != null)
            {
                foreach (var templateFile in Data.ModuleSettings.TemplateFiles)
                {
                    var data = Data.Templates.FirstOrDefault(t => t.ID == templateFile.ID);
                    if (data != null)
                    {
                        data.FilePath = templateFile.FilePath;
                    }
                }
            }

            for (int i = 0; i < Data.Templates.Count; i++)
            {
                var template = Data.Templates[i];
                template.Init(Data);
            }
        }
Ejemplo n.º 23
0
        private void UpdatePreview()
        {
            ClassicScriptColorScheme currentScheme = new ClassicScriptColorScheme
            {
                Sections         = (HighlightingObject)colorButton_Sections.Tag,
                Values           = (HighlightingObject)colorButton_Values.Tag,
                References       = (HighlightingObject)colorButton_References.Tag,
                StandardCommands = (HighlightingObject)colorButton_StandardCommands.Tag,
                NewCommands      = (HighlightingObject)colorButton_NewCommands.Tag,
                Comments         = (HighlightingObject)colorButton_Comments.Tag,
                Background       = ColorTranslator.ToHtml(colorButton_Background.BackColor),
                Foreground       = ColorTranslator.ToHtml(colorButton_Foreground.BackColor)
            };

            bool itemFound = false;

            foreach (string item in comboBox_ColorSchemes.Items)
            {
                if (item == "~UNTITLED")
                {
                    continue;
                }

                ClassicScriptColorScheme itemScheme = XmlHandling.ReadXmlFile <ClassicScriptColorScheme>(Path.Combine(DefaultPaths.GetClassicScriptColorConfigsPath(), item + ".cssch"));

                if (currentScheme == itemScheme)
                {
                    comboBox_ColorSchemes.SelectedItem = item;
                    itemFound = true;
                    break;
                }
            }

            if (!itemFound)
            {
                if (!comboBox_ColorSchemes.Items.Contains("~UNTITLED"))
                {
                    comboBox_ColorSchemes.Items.Add("~UNTITLED");
                }

                XmlHandling.SaveXmlFile(Path.Combine(DefaultPaths.GetClassicScriptColorConfigsPath(), "~UNTITLED.cssch"), currentScheme);

                comboBox_ColorSchemes.SelectedItem = "~UNTITLED";
            }

            UpdatePreviewColors(currentScheme);
        }
Ejemplo n.º 24
0
        private static void RegisterNGCenterLibraries()
        {
            string systemDirectory = DefaultPaths.GetSystemDirectory();

            string MSCOMCTL    = Path.Combine(systemDirectory, "Mscomctl.ocx");
            string RICHTX32    = Path.Combine(systemDirectory, "Richtx32.ocx");
            string PICFORMAT32 = Path.Combine(systemDirectory, "PicFormat32.ocx");
            string COMDLG32    = Path.Combine(systemDirectory, "Comdlg32.ocx");

            using (FileStream fileStream = File.Create(MSCOMCTL))
                Assembly.GetExecutingAssembly().GetManifestResourceStream("TombIDE.REGSVR.COM.Mscomctl.ocx").CopyTo(fileStream);

            using (FileStream fileStream = File.Create(RICHTX32))
                Assembly.GetExecutingAssembly().GetManifestResourceStream("TombIDE.REGSVR.COM.Richtx32.ocx").CopyTo(fileStream);

            using (FileStream fileStream = File.Create(PICFORMAT32))
                Assembly.GetExecutingAssembly().GetManifestResourceStream("TombIDE.REGSVR.COM.PicFormat32.ocx").CopyTo(fileStream);

            using (FileStream fileStream = File.Create(COMDLG32))
                Assembly.GetExecutingAssembly().GetManifestResourceStream("TombIDE.REGSVR.COM.Comdlg32.ocx").CopyTo(fileStream);

            RegisterCom(MSCOMCTL);

            // The code below is soo fake but people wanted it like that

            Console.WriteLine("Finished installing the MSCOMCTL.OCX library.");
            Thread.Sleep(10);

            RegisterCom(RICHTX32);

            Console.WriteLine("Finished installing the RICHTX32.OCX library.");
            Thread.Sleep(10);

            RegisterCom(PICFORMAT32);

            Console.WriteLine("Finished installing the PICFORMAT32.OCX library.");
            Thread.Sleep(10);

            RegisterCom(COMDLG32);

            Console.WriteLine("Finished installing the COMDLG32.OCX library.");
            Thread.Sleep(10);

            Console.WriteLine("\nAll libraries were installed and registered successfully!");

            Thread.Sleep(1000);
        }
Ejemplo n.º 25
0
        public MarkdownConverterViewData LoadModuleMarkdownConverterSettings(IModuleData Data)
        {
            var filePath = DefaultPaths.ModuleMarkdownConverterSettingsFile(Data);

            if (File.Exists(filePath))
            {
                Log.Here().Activity("Loading markdown converter settings from {0}", DefaultPaths.ModuleMarkdownConverterSettingsFile(Data));
                try
                {
                    return(JsonConvert.DeserializeObject <MarkdownConverterViewData>(File.ReadAllText(filePath)));
                }
                catch (Exception ex)
                {
                    Log.Here().Error($"Error loading markdown converter settings: {ex.ToString()}");
                }
            }
            return(null);
        }
Ejemplo n.º 26
0
        private string GetDescriptionFromRDDA(string flag, ReferenceType type)
        {
            string archivePath             = Path.Combine(DefaultPaths.GetReferenceDescriptionsPath(), GetRDDAFileName(type));
            string flagDescriptionFileName = "info_" + flag.TrimStart('_').Replace(" ", "_").Replace("/", string.Empty) + ".txt";

            using (FileStream file = File.OpenRead(archivePath))
                using (ZipArchive archive = new ZipArchive(file))
                    foreach (ZipArchiveEntry entry in archive.Entries)
                    {
                        if (entry.Name.Equals(flagDescriptionFileName, StringComparison.OrdinalIgnoreCase))
                        {
                            using (Stream stream = entry.Open())
                                using (StreamReader reader = new StreamReader(stream))
                                    return(reader.ReadToEnd());
                        }
                    }

            return(string.Empty);
        }
Ejemplo n.º 27
0
        public static IDEConfiguration Load(string filePath)
        {
            try
            {
                using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    return(Load(stream));
            }
            catch (IOException)
            {
                if (!Directory.Exists(DefaultPaths.GetConfigsPath()))
                {
                    Directory.CreateDirectory(DefaultPaths.GetConfigsPath());
                }

                using (XmlWriter writer = XmlWriter.Create(filePath))
                    new XmlSerializer(typeof(IDEConfiguration)).Serialize(writer, new IDEConfiguration());

                return(Load(filePath));
            }
        }
Ejemplo n.º 28
0
        public void Save(string path)
        {
            try
            {
                using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
                    Save(stream);
            }
            catch (IOException)
            {
                if (!Directory.Exists(DefaultPaths.GetConfigsPath()))
                {
                    Directory.CreateDirectory(DefaultPaths.GetConfigsPath());
                }

                using (XmlWriter writer = XmlWriter.Create(path))
                    new XmlSerializer(typeof(IDEConfiguration)).Serialize(writer, new IDEConfiguration());

                Save(path);
            }
        }
Ejemplo n.º 29
0
        private void button_DeleteScheme_Click(object sender, EventArgs e)
        {
            DialogResult result = DarkMessageBox.Show(this,
                                                      "Are you sure you want to delete the \"" + comboBox_ColorSchemes.SelectedItem + "\" color scheme?", "Are you sure?",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                string selectedSchemeFilePath = Path.Combine(DefaultPaths.GetClassicScriptColorConfigsPath(), comboBox_ColorSchemes.SelectedItem + ".cssch");

                if (File.Exists(selectedSchemeFilePath))
                {
                    Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(selectedSchemeFilePath,
                                                                       Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);

                    comboBox_ColorSchemes.Items.Remove(comboBox_ColorSchemes.SelectedItem);
                    comboBox_ColorSchemes.SelectedIndex = 0;
                }
            }
        }
Ejemplo n.º 30
0
        private void AddPinnedPrograms()
        {
            if (_ide.IDEConfiguration.PinnedProgramPaths.Count > 0)             // If there are any pinned program paths in the config
            {
                foreach (string programPath in _ide.IDEConfiguration.PinnedProgramPaths)
                {
                    AddProgramButton(programPath, false);
                }
            }
            else
            {
                // Add the default buttons
                AddProgramButton(Path.Combine(DefaultPaths.GetProgramDirectory(), "TombEditor.exe"), false);
                AddProgramButton(Path.Combine(DefaultPaths.GetProgramDirectory(), "WadTool.exe"), false);
                AddProgramButton(Path.Combine(DefaultPaths.GetProgramDirectory(), "SoundTool.exe"), false);
            }

            // Update the list with only valid programs
            SavePinnedPrograms();
        }