private void listArchiveRoots() { string archiveListString = i.IniReadValue(secOptions, kArchive_root_extra); string[] split = archiveListString.Split(';'); foreach (string s in split) { if (s != "") { lbFMArchivePaths.Items.Add(s); } } }
/// <summary> /// Updates the date in NewDarkLoader.ini with the date from Darkloader.ini if they are not the same. Assumes latter is correct. /// </summary> private void oldDateToNewDate(INIFile oldINI, INIFile newINI, string oldSectionName, string newSectionName, DateType relPlay, bool fmTypeArchive) { string oldINIDate; string newINIDate; if (relPlay == DateType.Release) { if (fmTypeArchive) { oldINIDate = oldINI.IniReadValue(oldSectionName, "misdate"); } else { oldINIDate = oldINI.INIReadValueNoSize(oldSectionName, "misdate"); } newINIDate = newINI.IniReadValue(newSectionName, nKeys.ReleaseDateInt); } else { if (fmTypeArchive) { oldINIDate = oldINI.IniReadValue(oldSectionName, "date"); } else { oldINIDate = oldINI.INIReadValueNoSize(oldSectionName, "date"); } newINIDate = newINI.IniReadValue(newSectionName, nKeys.LastPlayedInt); } if (oldINIDate != "") { DateTime oldDateTime = DateIntConverter.oldDateIntToDateTime(oldINIDate); if (newINIDate != "") { DateTime newDateTime = DateIntConverter.dateFromHexString(newINIDate); if (oldDateTime != newDateTime) { string hexDate = DateIntConverter.dateToHexString(oldDateTime); writeDateToINI(newINI, newSectionName, relPlay, hexDate); } } else { string hexDate = DateIntConverter.dateToHexString(oldDateTime); writeDateToINI(newINI, newSectionName, relPlay, hexDate); } } }
public DblClickFM(INIFile langIni, string boxTitle, string question, string always) { InitializeComponent(); if (langIni != null) { string secSaveImport = "DLSaveImport"; this.Text = boxTitle; label1.Text = question; chkAlwaysPlay.Text = always; btnYes.Text = langIni.IniReadValue(secSaveImport, "Yes"); btnNo.Text = langIni.IniReadValue(secSaveImport, "No"); } }
/// <summary> /// New window allowing a new FM folder to be created. /// </summary> /// <param name="langIni">'language.ini' data object.</param> /// <param name="installedFMsPath">Full path to "FMs" folder. Does not end with \\</param> public NewFMFolder(INIFile langIni, string installedFMsPath) { InitializeComponent(); if (langIni != null) { string newTitle = langIni.IniReadValue("FMTable", "NewFMButton"); if (newTitle != "") { Text = newTitle; } string newLalel = langIni.IniReadValue("FMTable", "NewFMName"); if (newLalel != "") { label1.Text = newLalel; } FMsPath = installedFMsPath; } }
public TagFilter(List <catItem> globalCIList, List <string> globalCatList, List <catItem> restoreInclude, List <catItem> restoreExclude, INIFile langIni) { InitializeComponent(); foreach (catItem cI in globalCIList) { globalCatItems.Add(cI); } foreach (string s in globalCatList) { globalCats.Add(s); } allTags.Nodes.AddRange(FillTree.generateNodes(globalCatItems, globalCats)); allTags.ExpandAll(); //restore existing tag filter and get unique cat list from restored filters foreach (catItem cI in restoreInclude) { includeList.Add(cI); if (!includeCats.Contains(cI.cat)) { includeCats.Add(cI.cat); } } foreach (catItem cI in restoreExclude) { excludeList.Add(cI); if (!excludeCats.Contains(cI.cat)) { excludeCats.Add(cI.cat); } } addToList(includeList, tvInclude, includeCats); addToList(excludeList, tvExclude, excludeCats); //Set interface text if (langIni != null) { string secTagFilter = "TagFilterWindow"; Text = langIni.IniReadValue(secTagFilter, "WindowTitle"); lblAvailTags.Text = langIni.IniReadValue(secTagFilter, "AvailTags"); lblInc.Text = langIni.IniReadValue(secTagFilter, "IncludeTags"); lblExc.Text = langIni.IniReadValue(secTagFilter, "ExcludeTags"); btnInclude.Text = langIni.IniReadValue(secTagFilter, "IncludeBtn"); btnExclude.Text = langIni.IniReadValue(secTagFilter, "ExcludeBtn"); btnRemove.Text = langIni.IniReadValue(secTagFilter, "RemoveTag"); btnRemoveAll.Text = langIni.IniReadValue(secTagFilter, "RemoveAll"); btnOK.Text = langIni.IniReadValue(secTagFilter, "OK"); btnCancel.Text = langIni.IniReadValue(secTagFilter, "Cancel"); removeAllMessage = langIni.IniReadValue(secTagFilter, "RemoveAllMsg"); removeAllMsgTitle = langIni.IniReadValue(secTagFilter, "RemoveAllMsgTitle"); miscTagCat = langIni.IniReadValue("Tags", "MiscTagName"); } }
/// <summary> /// Initialized using strings read from the table. /// </summary> public EditFM( INIFile langIni, string _fmTitle, int _rating, int _finished, string _comment, string _disabledMods, string _hexRelDate, string _hexLastPlayed, List <string> _textFiles, string currentReadme, bool _gameIsT3, string _savegameFilePath, string _fmInstPath, string notPlayedText) { InitializeComponent(); tbTitle.Text = _fmTitle; selectRating(_rating); setFinishedCheckboxes(_finished); setReleaseDate(_hexRelDate); setLastPlayed(_hexLastPlayed); tbComment.Text = _comment; tbDisabledMods.Text = _disabledMods; textFiles = _textFiles; savegameFilePath = _savegameFilePath; fmSavesPath = ""; gameIsT3 = _gameIsT3; foreach (string file in textFiles) { cbReadme.Items.Add(file); } if (cbReadme.Items.Count > 0) { if (currentReadme != "") { for (int i = 0; i < cbReadme.Items.Count; i++) { if (textFiles[i] == currentReadme) { cbReadme.SelectedIndex = i; break; } } } else { cbReadme.SelectedIndex = 0; } } fmInstalledPath = _fmInstPath; string secCols = "Columns"; //Set interface text from lang ini if (langIni != null) { Text = langIni.IniReadValue("EditFM", "EditDetailsTitle"); lblReadme.Text = langIni.IniReadValue(secCols, "Readme"); lblTitle.Text = langIni.IniReadValue(secCols, "Title"); lblRating.Text = langIni.IniReadValue(secCols, "Rating"); gbFinished.Text = langIni.IniReadValue(secCols, "Finished"); if (gameIsT3) { chkNormal.Text = langIni.IniReadValue(secCols, "T3Easy"); chkHard.Text = langIni.IniReadValue(secCols, "Normal"); chkExpert.Text = langIni.IniReadValue(secCols, "Hard"); chkExtreme.Text = langIni.IniReadValue(secCols, "Expert"); fmSavesPath = _fmInstPath + "\\savegames"; } else { chkNormal.Text = langIni.IniReadValue(secCols, "Normal"); chkHard.Text = langIni.IniReadValue(secCols, "Hard"); chkExpert.Text = langIni.IniReadValue(secCols, "Expert"); chkExtreme.Text = langIni.IniReadValue(secCols, "Expert"); fmSavesPath = _fmInstPath + "\\saves"; } lblRelDate.Text = langIni.IniReadValue(secCols, "ReleaseDate"); lblLastPlayed.Text = langIni.IniReadValue(secCols, "LastPlayed"); chkNotPlayed.Text = notPlayedText; btnGetLastSaveDate.Text = langIni.IniReadValue(secCols, "GetFromSaves"); lblComment.Text = langIni.IniReadValue(secCols, "Comment"); lblDisMods.Text = langIni.IniReadValue(secCols, "DisabledMods"); btnOK.Text = langIni.IniReadValue("TagFilterWindow", "OK"); btnCancel.Text = langIni.IniReadValue("TagFilterWindow", "Cancel"); } checkForSaves(); }
private void btnImportINI_Click(object sender, EventArgs e) { DialogResult dR = openDarkloaderINI.ShowDialog(); if (dR == DialogResult.OK) { //ini files INIFile oldINI = new INIFile(openDarkloaderINI.FileName); //Get sizes in bytes of each FM file List <string> foundFilesInArchivePaths = new List <string>(); foreach (string path in fmArchiveFullPaths) { foundFilesInArchivePaths.AddRange(Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)); } foreach (string file in foundFilesInArchivePaths) { FileInfo fI = new FileInfo(file); long sizeBytes = fI.Length; string ext = fI.Extension; string simpleFilename = fI.Name; string oldSectionName = simpleFilename; bool fmIsArchive = false; if (ext.Length != 0) { simpleFilename = fI.Name.Replace(ext, ""); oldSectionName = simpleFilename + "." + sizeBytes; fmIsArchive = true; } string newSectionName = "FM=" + ArchiveExtract.ArchiveExtracedFolderName(simpleFilename); string newNiceName = newINI.IniReadValue(newSectionName, nKeys.FMTitle); if (newNiceName == simpleFilename || newNiceName == "") { string oldNiceName = oldINI.IniReadValue(oldSectionName, "title").Replace("\"", ""); if (oldNiceName != "") { newINI.IniWriteValue(newSectionName, nKeys.FMTitle, oldNiceName); } } string newFinished = newINI.IniReadValue(newSectionName, nKeys.FinishedID); if (newFinished == "") { string oldFinished; if (fmIsArchive) { oldFinished = oldINI.IniReadValue(oldSectionName, "finished"); } else { oldFinished = oldINI.INIReadValueNoSize(oldSectionName, "finished"); } if (oldFinished != "") { newINI.IniWriteValue(newSectionName, nKeys.FinishedID, oldFinished); } } oldDateToNewDate(oldINI, newINI, oldSectionName, newSectionName, DateType.Release, fmIsArchive); oldDateToNewDate(oldINI, newINI, oldSectionName, newSectionName, DateType.LastPlayed, fmIsArchive); string newComment = newINI.IniReadValue(newSectionName, nKeys.Comment); if (newComment == "") { string oldComment; if (fmIsArchive) { oldComment = oldINI.IniReadValue(oldSectionName, "comment").Replace("\"", ""); } else { oldComment = oldINI.INIReadValueNoSize(oldSectionName, "comment").Replace("\"", ""); } if (oldComment != "") { newINI.IniWriteValue(newSectionName, nKeys.Comment, oldComment); } } } iniImported = true; //allows a property to report that the ini was imported so the main form can refresh the table. } }
/// <summary> /// Import Darkloader saves and ini settings. /// </summary> /// <param name="gameFullPath">Location of .exe file's folder (not file itself).</param> /// <param name="fmArchivePaths">Locations of FM zip files.</param> /// <param name="sevenZipGExePath">7zG.exe location (the file itself).</param> /// <param name="tempPath">User's temp path. Ends with \\</param> /// <param name="archiveNames">Filenames of FM archives, extension, no path.</param> /// <param name="archiveExts">List of valid FM archive extensions, initially read from the .ini file.</param> public Tools(string gameFullPath, List <string> fmArchivePaths, string sevenZipGExePath, string tempPath, List <DarkLoaderFMData> dataList, newKeyNames keyNames, INIFile ndlINI, INIFile langIni, List <string> archiveExts, bool gameIsShock2) { InitializeComponent(); gamePath = gameFullPath; fmArchiveFullPaths = fmArchivePaths; sevenZipGPath = sevenZipGExePath; userTempPath = tempPath; foreach (DarkLoaderFMData datum in dataList) { dlFMData.Add(datum); } nKeys = keyNames; if (langIni != null) { string secOldDLTools = "OldDarkloaderTools"; string secSaveImport = "DLSaveImport"; Text = langIni.IniReadValue(secOldDLTools, "DLToolsTitle"); label1.Text = langIni.IniReadValue(secOldDLTools, "GamePath"); lblGamePath.Text = gamePath; btnImportSaves.Text = langIni.IniReadValue(secOldDLTools, "ImportDLSaves"); btnImportINI.Text = langIni.IniReadValue(secOldDLTools, "ImportDLFMData"); btnClose.Text = langIni.IniReadValue(secOldDLTools, "DLToolsClose"); overWarnTitle = langIni.IniReadValue(secSaveImport, "OverwriteTitle"); overMsg1 = langIni.IniReadValue(secSaveImport, "OverwriteLn1"); overMsg2 = langIni.IniReadValue(secSaveImport, "OverwriteLn2"); overMsg3 = langIni.IniReadValue(secSaveImport, "OverwriteLn3"); overMsg4 = langIni.IniReadValue(secSaveImport, "OverwriteLn4"); overMsg5 = langIni.IniReadValue(secSaveImport, "OverwriteLn5"); overMsg6 = langIni.IniReadValue(secSaveImport, "OverwriteLn6"); yBtn = langIni.IniReadValue(secSaveImport, "Yes"); yToAllBtn = langIni.IniReadValue(secSaveImport, "YesToAll"); nBtn = langIni.IniReadValue(secSaveImport, "No"); nToAllBtn = langIni.IniReadValue(secSaveImport, "NoToAll"); shock2 = gameIsShock2; } newINI = ndlINI; }
/// <summary> /// Sets the interface text from the optional language ini file. /// </summary> /// <param name="langIni"></param> private void readLangINI(INIFile langIni) { if (langIni != null) { string secSetup = "Setup"; Text = langIni.IniReadValue(secSetup, "SetupTitle"); string readTabStandard = langIni.IniReadValue(secSetup, "StandardTab"); if (readTabStandard != "") { tabStandard.Text = readTabStandard; } string readTabExtra = langIni.IniReadValue(secSetup, "ExtraTab"); if (readTabExtra != "") { tabExtra.Text = readTabExtra; } gbFMArchive.Text = langIni.IniReadValue(secSetup, "FmArchFolderBox"); archIsFMsWarning = langIni.IniReadValue(secSetup, "FolderIsFMsWarning"); gbLang.Text = langIni.IniReadValue(secSetup, "LangBox"); gbDateFormat.Text = langIni.IniReadValue(secSetup, "DateFormatBox"); rdoDMY.Text = langIni.IniReadValue(secSetup, "DmyChk"); rdoMDY.Text = langIni.IniReadValue(secSetup, "MdyChk"); gbSaveBackup.Text = langIni.IniReadValue(secSetup, "SaveBackupBox"); rdoBkAsk.Text = langIni.IniReadValue(secSetup, "BackupTypeAsk"); rdoBkAlways.Text = langIni.IniReadValue(secSetup, "BackupTypeAlways"); gbDblClick.Text = langIni.IniReadValue(secSetup, "DblClickFMBox"); chkDblClickDontAsk.Text = langIni.IniReadValue(secSetup, "DblClChk"); gbReturn.Text = langIni.IniReadValue(secSetup, "ReturnAfterBox"); rdoRetNever.Text = langIni.IniReadValue(secSetup, "RetNever"); rdoRetAfterFM.Text = langIni.IniReadValue(secSetup, "RetAfterFM"); rdoRetAlways.Text = langIni.IniReadValue(secSetup, "RetAlways"); gb7z.Text = langIni.IniReadValue(secSetup, "OptLocate7zBox"); btnBr7zGexe.Text = langIni.IniReadValue(secSetup, "BrowseButton"); StringBuilder help7zBld = new StringBuilder(); help7zBld.AppendLine(langIni.IniReadValue(secSetup, "Help7z1")); help7zBld.AppendLine(langIni.IniReadValue(secSetup, "Help7z2")); lbl7zHelp.Text = help7zBld.ToString(); StringBuilder use7zeBld = new StringBuilder(); use7zeBld.AppendLine(langIni.IniReadValue(secSetup, "Use7zeChk1")); use7zeBld.AppendLine(langIni.IniReadValue(secSetup, "Use7zeChk2")); chkUseNoWinExe.Text = use7zeBld.ToString(); string secTagFilter = "TagFilterWindow"; //this is just done to prevent duplicate button text entries. btnOK.Text = langIni.IniReadValue(secTagFilter, "OK"); btnCancel.Text = langIni.IniReadValue(secTagFilter, "Cancel"); folderRequired = langIni.IniReadValue(secSetup, "FolderRequired"); fldrRequiredTitle = langIni.IniReadValue(secSetup, "FldrRequiredTitle"); gbWebSearch.Text = langIni.IniReadValue(secSetup, "WebSearchSite"); lblSpecialWords.Text = langIni.IniReadValue(secSetup, "ArticleLabel"); toolTip1.SetToolTip(tbSpecialWords, langIni.IniReadValue(secSetup, "ArticleTip")); lblNoSite.Text = langIni.IniReadValue(secSetup, "NoSiteLabel"); } }