private void InitForm_Load(object sender, EventArgs e) { AppIniFile = new INI.Ini(yamecst.Ininame, true); AppIniFile["MODS FOLDER", "Name"] = yamecst.Defaultmoddir; TextBox tb = new TextBox(); tb.KeyDown += new KeyEventHandler(tb_KeyDown); }
private static bool isFirstCall() { Constantes yamecst = new Constantes(); INI.Ini AppIniFile = new INI.Ini(yamecst.Ininame, true); string modpath; if ((modpath = AppIniFile["MODS FOLDER", "Name"]) == "") return true; return false; }
private void MainForm_Load(object sender, EventArgs e) { // Read the Windows Form location from properties if ((ModifierKeys & Keys.Shift) == 0) { string initLocation = Properties.Settings.Default.InitialLocation; Point il = new Point(0, 0); Size sz = Size; if (!string.IsNullOrWhiteSpace(initLocation)) { string[] parts = initLocation.Split(','); if (parts.Length >= 2) { il = new Point(int.Parse(parts[0]), int.Parse(parts[1])); } if (parts.Length >= 4) { sz = new Size(int.Parse(parts[2]), int.Parse(parts[3])); } } Size = sz; Location = il; } /* Start Init */ KeyPreview = true; this.labelVersion.Text = _YameConst.Version; progressBar1.Minimum = 0; progressBar1.Visible = false; tbRenameMod.Hide(); tbCreateMod.Hide(); // absolute path of start in path in shortcut _StartPath = Directory.GetCurrentDirectory(); if (_StartPath.EndsWith("\\")) _StartPath = _StartPath.Substring(0,_StartPath.Length - 1); // load mods folders from ini AppIniFile = new INI.Ini(_YameConst.Ininame, true); _RelModFolder = AppIniFile["MODS FOLDER", "Name"]; _AbsModFolder = Path.GetFullPath(_RelModFolder); // load activated mods from ini loadModsFromIni(); labelModPath.Text = "[ " + _AbsModFolder + " ]"; try { string[] dirs = Directory.GetDirectories(_AbsModFolder); foreach (string dir in dirs) { // Don't list hidden directory DirectoryInfo directory = new DirectoryInfo(dir); if ((directory.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { String[] modname = dir.Split('\\'); // if mod not in activatedModsList add to listBoxModfound if (!_ActivatedModsList.Any(mod => mod.ModName == modname[modname.Length - 1])) { listBoxModFound.Items.Add(modname[modname.Length - 1]); } } } if (_TotalModActivated > 0) // otherwise add to listBoxModActivated foreach (ModObject mod in _ActivatedModsList) { listBoxModActivated.Items.Add(mod.ModName); } modsCalculate(true); buttonModPlus.Enabled = false; buttonModPlus.BackgroundImage = Properties.Resources.ButtonPlus_d; buttonModMoins.Enabled = false; buttonModMoins.BackgroundImage = Properties.Resources.ButtonMoins_d; listBoxModFound.MouseDown += new MouseEventHandler(listBoxModFound_MouseDown); listBoxModActivated.MouseDown += new MouseEventHandler(listBoxModActivated_MouseDown); } catch (Exception) { MessageBox.Show("No mod folder called " + _AbsModFolder); } }
private void loadModsFromIni() { ModIniFile = new INI.Ini(PathCombine(_AbsModFolder, _YameConst.Ininame), true); List<string> ListMods = ModIniFile["MODS", true]; foreach (string mod in ListMods) { var num = mod.Split('='); string splitModName = num[0]; int splitModNum = Int32.Parse(num[1]); // add objectmod string modlogpath = PathCombine(_AbsModFolder, _YameConst.Modlogsdir, splitModName + ".log"); // add mod to activatedModsList List ModObject ModObject thismod = new ModObject(splitModName); thismod.ModNumber = splitModNum; // find files in mod.log if (File.Exists(modlogpath)) { var logFile = File.ReadAllLines(modlogpath); thismod.FilesList = new List<string>(logFile); } ModIniFile = new INI.Ini(PathCombine(_AbsModFolder, _YameConst.Ininame), true); string dependancies = ModIniFile["DEPENDANCIES", splitModName]; if (dependancies != String.Empty) { thismod.IsDisabled = true; thismod.DependanciesList = dependancies.Split('|').ToList(); if (thismod.DependanciesList[thismod.DependanciesList.Count - 1] == String.Empty) thismod.DependanciesList.RemoveAt(thismod.DependanciesList.Count - 1); } _ActivatedModsList.Add(thismod); } _ActivatedModsList = _ActivatedModsList.OrderBy(o => o.ModNumber).ToList(); _TotalModActivated = _ActivatedModsList.Count(); if (_TotalModActivated < 1) { buttonModAllMoins.Enabled = false; buttonModAllMoins.BackgroundImage = Properties.Resources.ButtonCroix_d; } }