private void FindEntity() { try { var dlgResult = GameFinder.ShowDialog(); if (dlgResult == true) { ApplyFindGameFilter(); IsGamesReadOnly = true; IsShowAllGamesEnabled = true; if (Games.Count == 0) { SelectedGame = null; } AddGameControlVisibility = Visibility.Hidden; } } catch (Exception ex) { _sharedService.ShowExceptionMessage(ex); } }
/// <summary> /// Determine what game is contained within a directory. /// </summary> /// <param name="path"></param> /// <returns></returns> public static NFSGame GetGameFromPath(string path) { foreach (var game in GameDatabase.SupportedGames) { var fileName = game.ExectuableFileName; var final = Path.Combine(path, fileName); if (File.Exists(final)) { return(GameFinder.GetGame(final)); } } return(NFSGame.Unknown); }
public ulong GetUploadedId() { string checkPath = Path.Combine(GameFinder.GetModsDir(), "SteamWorkshop.ini"); Debug.WriteLine(checkPath); if (File.Exists(checkPath)) { IniData info = Parser.Parse(File.ReadAllText(checkPath)); var i = info[GetDirectoryName()]; return(ulong.Parse(TryGet(i, "WorkshopIdLong", TryGet(i, "WorkshopId", "0")))); } else { return(0); } }
public MainWindow() { if (!DesignMode) { Utils.CleanUpTrash(GameFinder.FindGameDir()); } Instance = this; InitializeComponent(); this.Text = "OPEN MOD MANAGER - FOR A HAT IN TIME [" + FunnyTexts[new Random().Next(FunnyTexts.Length)] + "]"; modListControl1 = new ModListControl(); processRunner1 = new ProcessRunner(); cardController1.AddCard("mods", modListControl1); cardController1.AddCard("console", processRunner1); contextMenuStrip1.Renderer = new ToolStripProfessionalRenderer(new MenuColorTable()); }
private void MainWindow_Load(object z, EventArgs x) { modListControl1.SetWorker("Loading..."); ToggleConsole(false); UpdateChk = new UpdateChecker(BuildData.CurrentVersion, BuildData.UpdateUrl, new Action(() => { this.Invoke(new MethodInvoker(() => { var dialog = GUI.MessageBox.Show(this, "New version of OpenModManager is avaiable!\nDo you want to download it?", "Update checker", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialog == DialogResult.Yes) { Process.Start(BuildData.ReleasesPage); } })); })); modListControl1.AddModSource(new ModDirectorySource("Mods directory", Path.Combine(Program.ProcFactory.GetGamePath(), @"HatinTimeGame\Mods"), true)); modListControl1.AddModSource(new ModDirectorySource("Mods directory (disabled)", Path.Combine(Program.ProcFactory.GetGamePath(), @"HatinTimeGame\Mods\Disabled"), true, true, true)); var autoLoad = Properties.Settings.Default.AutoScanDownloadedMods; modListControl1.AddModSource(new ModDirectorySource("Downloaded mods", GameFinder.GetWorkshopDir(), autoLoad, false, true)); modListControl1.AddModSource(new ModDirectorySource("Downloaded mods (disabled)", Path.Combine(GameFinder.GetWorkshopDir(), "Disabled"), autoLoad, false, true)); modListControl1.ReloadList(); SetModListState(null); Automation.AddAutomationEventHandler( WindowPattern.WindowOpenedEvent, AutomationElement.RootElement, TreeScope.Children, (sender, e) => { var element = sender as AutomationElement; Console.WriteLine("new window opened"); }); UpdateChk.CheckForUpdatesAsync(); }
private void IterateContent(TreeNodeCollection root, ModObject mod, string currPath, string acceptExt, bool isBase = false) { if (!Directory.Exists(currPath)) { return; } if (isBase) { var node = root.Add("folder", Path.GetFileName(currPath), "folder", "folder"); IterateContent(node.Nodes, mod, currPath, acceptExt); return; } foreach (string path in Directory.GetFiles(currPath, "*.*")) { Debug.WriteLine(GameFinder.GetCookedPcDir()); var exts = acceptExt.Split('|'); var extension = Path.GetExtension(path); var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path); if (!exts.Contains(acceptExt)) { var treeNode = root.Add("", Path.GetFileName(path), "error", "error"); var text = "This asset does not belong here."; foreach (var a in Adict) { if (exts.Contains(a.Key)) { text += Environment.NewLine + a.Value; } } foreach (var b in BDict) { if (extension == b.Key) { text += Environment.NewLine + b.Value; } } treeNode.Tag = new ContentTreeViewInfo(Path.GetFileName(path), text); HasContentError = true; } else if (fileNameWithoutExtension.ToLower() == mod.GetDirectoryName().ToLower() && !exts.Contains(".int") && !exts.Contains(".umap")) { var treeNode = root.Add("", Path.GetFileName(path), "error", "error"); treeNode.Tag = new ContentTreeViewInfo(Path.GetFileName(path), "Packages can't have the same name as your mod folder.\nAdd a _Content suffix or something. Example:\n" + fileNameWithoutExtension + "_Content" + extension); HasContentError = true; } else if (Utils.FileExists(GameFinder.GetCookedPcDir(), Path.GetFileName(path))) { var treeNode = root.Add("", Path.GetFileName(path), "error", "error"); treeNode.Tag = new ContentTreeViewInfo(Path.GetFileName(path), "There's an asset with an identical name in CookedPC.\nPlease give your asset another name.\n(btw don't put your own stuff in CookedPC. Keep it to the mods folder.)"); HasContentError = true; } else { var ext = exts.Contains(".int") ? "localization" : "package"; var treeNode = root.Add("", Path.GetFileName(path), ext, ext); treeNode.Tag = new ContentTreeViewInfo(Path.GetFileName(path), ""); } } foreach (var file in Directory.GetDirectories(currPath)) { var node = root.Add("", Path.GetFileName(file), "folder", "folder"); IterateContent(node.Nodes, mod, file, acceptExt); } }