public UserWorkspaceSettings FindOrAddWorkspace(string ClientBranchPath) { // Update the current workspace string CurrentWorkspaceKey = ClientBranchPath.Trim('/'); UserWorkspaceSettings CurrentWorkspace; if (!WorkspaceKeyToSettings.TryGetValue(CurrentWorkspaceKey, out CurrentWorkspace)) { // Create a new workspace settings object CurrentWorkspace = new UserWorkspaceSettings(); WorkspaceKeyToSettings.Add(CurrentWorkspaceKey, CurrentWorkspace); // Read the workspace settings ConfigSection WorkspaceSection = ConfigFile.FindSection(CurrentWorkspaceKey); if (WorkspaceSection == null) { string LegacyBranchAndClientKey = ClientBranchPath.Trim('/'); int SlashIdx = LegacyBranchAndClientKey.IndexOf('/'); if (SlashIdx != -1) { LegacyBranchAndClientKey = LegacyBranchAndClientKey.Substring(0, SlashIdx) + "$" + LegacyBranchAndClientKey.Substring(SlashIdx + 1); } string CurrentSync = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey, null); if (CurrentSync != null) { int AtIdx = CurrentSync.LastIndexOf('@'); if (AtIdx != -1) { int ChangeNumber; if (int.TryParse(CurrentSync.Substring(AtIdx + 1), out ChangeNumber)) { CurrentWorkspace.CurrentProjectIdentifier = CurrentSync.Substring(0, AtIdx); CurrentWorkspace.CurrentChangeNumber = ChangeNumber; } } } string LastUpdateResultText = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey + "$LastUpdate", null); if (LastUpdateResultText != null) { int ColonIdx = LastUpdateResultText.LastIndexOf(':'); if (ColonIdx != -1) { int ChangeNumber; if (int.TryParse(LastUpdateResultText.Substring(0, ColonIdx), out ChangeNumber)) { WorkspaceUpdateResult Result; if (Enum.TryParse(LastUpdateResultText.Substring(ColonIdx + 1), out Result)) { CurrentWorkspace.LastSyncChangeNumber = ChangeNumber; CurrentWorkspace.LastSyncResult = Result; } } } } CurrentWorkspace.SyncView = new string[0]; CurrentWorkspace.SyncIncludedCategories = new Guid[0]; CurrentWorkspace.SyncExcludedCategories = new Guid[0]; CurrentWorkspace.bSyncAllProjects = null; CurrentWorkspace.bIncludeAllProjectsInSolution = null; } else { CurrentWorkspace.CurrentProjectIdentifier = WorkspaceSection.GetValue("CurrentProjectPath"); CurrentWorkspace.CurrentChangeNumber = WorkspaceSection.GetValue("CurrentChangeNumber", -1); CurrentWorkspace.CurrentSyncFilterHash = WorkspaceSection.GetValue("CurrentSyncFilterHash", null); foreach (string AdditionalChangeNumberString in WorkspaceSection.GetValues("AdditionalChangeNumbers", new string[0])) { int AdditionalChangeNumber; if (int.TryParse(AdditionalChangeNumberString, out AdditionalChangeNumber)) { CurrentWorkspace.AdditionalChangeNumbers.Add(AdditionalChangeNumber); } } Enum.TryParse(WorkspaceSection.GetValue("LastSyncResult", ""), out CurrentWorkspace.LastSyncResult); CurrentWorkspace.LastSyncResultMessage = UnescapeText(WorkspaceSection.GetValue("LastSyncResultMessage")); CurrentWorkspace.LastSyncChangeNumber = WorkspaceSection.GetValue("LastSyncChangeNumber", -1); DateTime LastSyncTime; if (DateTime.TryParse(WorkspaceSection.GetValue("LastSyncTime", ""), out LastSyncTime)) { CurrentWorkspace.LastSyncTime = LastSyncTime; } CurrentWorkspace.LastSyncDurationSeconds = WorkspaceSection.GetValue("LastSyncDuration", 0); CurrentWorkspace.LastBuiltChangeNumber = WorkspaceSection.GetValue("LastBuiltChangeNumber", 0); CurrentWorkspace.ExpandedArchiveTypes = WorkspaceSection.GetValues("ExpandedArchiveName", new string[0]); CurrentWorkspace.SyncView = WorkspaceSection.GetValues("SyncFilter", new string[0]); CurrentWorkspace.SyncIncludedCategories = WorkspaceSection.GetValues("SyncIncludedCategories", new Guid[0]); CurrentWorkspace.SyncExcludedCategories = WorkspaceSection.GetValues("SyncExcludedCategories", new Guid[0]); int SyncAllProjects = WorkspaceSection.GetValue("SyncAllProjects", -1); CurrentWorkspace.bSyncAllProjects = (SyncAllProjects == 0)? (bool?)false : (SyncAllProjects == 1)? (bool?)true : (bool?)null; int IncludeAllProjectsInSolution = WorkspaceSection.GetValue("IncludeAllProjectsInSolution", -1); CurrentWorkspace.bIncludeAllProjectsInSolution = (IncludeAllProjectsInSolution == 0)? (bool?)false : (IncludeAllProjectsInSolution == 1)? (bool?)true : (bool?)null; string[] BisectEntries = WorkspaceSection.GetValues("Bisect", new string[0]); foreach (string BisectEntry in BisectEntries) { ConfigObject BisectEntryObject = new ConfigObject(BisectEntry); int ChangeNumber = BisectEntryObject.GetValue("Change", -1); if (ChangeNumber != -1) { BisectState State; if (Enum.TryParse(BisectEntryObject.GetValue("State", ""), out State)) { CurrentWorkspace.ChangeNumberToBisectState[ChangeNumber] = State; } } } } } return(CurrentWorkspace); }
public UserSettings(string InFileName) { FileName = InFileName; if (File.Exists(FileName)) { ConfigFile.Load(FileName); } // General settings bBuildAfterSync = (ConfigFile.GetValue("General.BuildAfterSync", "1") != "0"); bRunAfterSync = (ConfigFile.GetValue("General.RunAfterSync", "1") != "0"); bSyncPrecompiledEditor = (ConfigFile.GetValue("General.SyncPrecompiledEditor", "0") != "0"); bOpenSolutionAfterSync = (ConfigFile.GetValue("General.OpenSolutionAfterSync", "0") != "0"); bShowLogWindow = (ConfigFile.GetValue("General.ShowLogWindow", false)); bAutoResolveConflicts = (ConfigFile.GetValue("General.AutoResolveConflicts", "1") != "0"); bUseIncrementalBuilds = ConfigFile.GetValue("General.IncrementalBuilds", true); bShowLocalTimes = ConfigFile.GetValue("General.ShowLocalTimes", false); bShowAllStreams = ConfigFile.GetValue("General.ShowAllStreams", false); bKeepInTray = ConfigFile.GetValue("General.KeepInTray", true); int.TryParse(ConfigFile.GetValue("General.FilterIndex", "0"), out FilterIndex); LastProjectFileName = ConfigFile.GetValue("General.LastProjectFileName", null); OpenProjectFileNames = ConfigFile.GetValues("General.OpenProjectFileNames", new string[0]); if (LastProjectFileName != null && !OpenProjectFileNames.Any(x => x.Equals(LastProjectFileName, StringComparison.InvariantCultureIgnoreCase))) { OpenProjectFileNames = OpenProjectFileNames.Concat(new string[] { LastProjectFileName }).ToArray(); } OtherProjectFileNames = ConfigFile.GetValues("General.OtherProjectFileNames", new string[0]); SyncView = ConfigFile.GetValues("General.SyncFilter", new string[0]); SyncExcludedCategories = ConfigFile.GetGuidValues("General.SyncExcludedCategories", new Guid[0]); if (!Enum.TryParse(ConfigFile.GetValue("General.SyncType", ""), out SyncType)) { SyncType = LatestChangeType.Good; } // Build configuration string CompiledEditorBuildConfigName = ConfigFile.GetValue("General.BuildConfig", ""); if (!Enum.TryParse(CompiledEditorBuildConfigName, true, out CompiledEditorBuildConfig)) { CompiledEditorBuildConfig = BuildConfig.DebugGame; } // Tab names string TabNamesValue = ConfigFile.GetValue("General.TabNames", ""); if (!Enum.TryParse(TabNamesValue, true, out TabLabels)) { TabLabels = TabLabels.ProjectFile; } // Editor arguments string[] Arguments = ConfigFile.GetValues("General.EditorArguments", new string[] { "0:-log", "0:-fastload" }); foreach (string Argument in Arguments) { if (Argument.StartsWith("0:")) { EditorArguments.Add(new Tuple <string, bool>(Argument.Substring(2), false)); } else if (Argument.StartsWith("1:")) { EditorArguments.Add(new Tuple <string, bool>(Argument.Substring(2), true)); } else { EditorArguments.Add(new Tuple <string, bool>(Argument, true)); } } // Window settings ConfigSection WindowSection = ConfigFile.FindSection("Window"); if (WindowSection != null) { bHasWindowSettings = true; int X = WindowSection.GetValue("X", -1); int Y = WindowSection.GetValue("Y", -1); int Width = WindowSection.GetValue("Width", -1); int Height = WindowSection.GetValue("Height", -1); WindowRectangle = new Rectangle(X, Y, Width, Height); ConfigObject ColumnWidthObject = new ConfigObject(WindowSection.GetValue("ColumnWidths", "")); foreach (KeyValuePair <string, string> ColumnWidthPair in ColumnWidthObject.Pairs) { int Value; if (int.TryParse(ColumnWidthPair.Value, out Value)) { ColumnWidths[ColumnWidthPair.Key] = Value; } } bWindowVisible = WindowSection.GetValue("Visible", true); } // Schedule settings bScheduleEnabled = ConfigFile.GetValue("Schedule.Enabled", false); if (!TimeSpan.TryParse(ConfigFile.GetValue("Schedule.Time", ""), out ScheduleTime)) { ScheduleTime = new TimeSpan(6, 0, 0); } if (!Enum.TryParse(ConfigFile.GetValue("Schedule.Change", ""), out ScheduleChange)) { ScheduleChange = LatestChangeType.Good; } // Perforce settings if (!int.TryParse(ConfigFile.GetValue("Perforce.NumRetries", "0"), out SyncOptions.NumRetries)) { SyncOptions.NumRetries = 0; } if (!int.TryParse(ConfigFile.GetValue("Perforce.NumThreads", "0"), out SyncOptions.NumThreads)) { SyncOptions.NumThreads = 0; } if (!int.TryParse(ConfigFile.GetValue("Perforce.TcpBufferSize", "0"), out SyncOptions.TcpBufferSize)) { SyncOptions.TcpBufferSize = 0; } }
public UserSettings(string InFileName) { FileName = InFileName; if (File.Exists(FileName)) { ConfigFile.Load(FileName); } // General settings bBuildAfterSync = (ConfigFile.GetValue("General.BuildAfterSync", "1") != "0"); bRunAfterSync = (ConfigFile.GetValue("General.RunAfterSync", "1") != "0"); bSyncPrecompiledEditor = (ConfigFile.GetValue("General.SyncPrecompiledEditor", "0") != "0"); bOpenSolutionAfterSync = (ConfigFile.GetValue("General.OpenSolutionAfterSync", "0") != "0"); bShowLogWindow = (ConfigFile.GetValue("General.ShowLogWindow", false)); bAutoResolveConflicts = (ConfigFile.GetValue("General.AutoResolveConflicts", "1") != "0"); bUseIncrementalBuilds = ConfigFile.GetValue("General.IncrementalBuilds", true); bShowLocalTimes = ConfigFile.GetValue("General.ShowLocalTimes", false); bKeepInTray = ConfigFile.GetValue("General.KeepInTray", true); LastProjectFileName = ConfigFile.GetValue("General.LastProjectFileName", null); OtherProjectFileNames = ConfigFile.GetValues("General.OtherProjectFileNames", new string[0]); SyncFilter = ConfigFile.GetValues("General.SyncFilter", new string[0]); if (!Enum.TryParse(ConfigFile.GetValue("General.SyncType", ""), out SyncType)) { SyncType = LatestChangeType.Good; } // Build configuration string CompiledEditorBuildConfigName = ConfigFile.GetValue("General.BuildConfig", ""); if (!Enum.TryParse(CompiledEditorBuildConfigName, true, out CompiledEditorBuildConfig)) { CompiledEditorBuildConfig = BuildConfig.DebugGame; } // Editor arguments string[] Arguments = ConfigFile.GetValues("General.EditorArguments", new string[] { "0:-log", "0:-fastload" }); foreach (string Argument in Arguments) { if (Argument.StartsWith("0:")) { EditorArguments.Add(new Tuple <string, bool>(Argument.Substring(2), false)); } else if (Argument.StartsWith("1:")) { EditorArguments.Add(new Tuple <string, bool>(Argument.Substring(2), true)); } else { EditorArguments.Add(new Tuple <string, bool>(Argument, true)); } } // Window settings ConfigSection WindowSection = ConfigFile.FindSection("Window"); if (WindowSection != null) { bHasWindowSettings = true; int X = WindowSection.GetValue("X", -1); int Y = WindowSection.GetValue("Y", -1); int Width = WindowSection.GetValue("Width", -1); int Height = WindowSection.GetValue("Height", -1); WindowRectangle = new Rectangle(X, Y, Width, Height); ConfigObject ColumnWidthObject = new ConfigObject(WindowSection.GetValue("ColumnWidths", "")); foreach (KeyValuePair <string, string> ColumnWidthPair in ColumnWidthObject.Pairs) { int Value; if (int.TryParse(ColumnWidthPair.Value, out Value)) { ColumnWidths[ColumnWidthPair.Key] = Value; } } bWindowVisible = WindowSection.GetValue("Visible", true); } // Schedule settings bScheduleEnabled = ConfigFile.GetValue("Schedule.Enabled", false); if (!TimeSpan.TryParse(ConfigFile.GetValue("Schedule.Time", ""), out ScheduleTime)) { ScheduleTime = new TimeSpan(6, 0, 0); } if (!Enum.TryParse(ConfigFile.GetValue("Schedule.Change", ""), out ScheduleChange)) { ScheduleChange = LatestChangeType.Good; } }
bool UpdateZippedBinaries() { // Get the path to the config file string ClientConfigFileName = PerforceUtils.GetClientOrDepotDirectoryName(SelectedClientFileName) + "/Build/UnrealGameSync.ini"; // Find the most recent change to that file (if the file doesn't exist, we succeed and just get 0 changes). List <PerforceChangeSummary> ConfigFileChanges; if (!Perforce.FindChanges(ClientConfigFileName, 1, out ConfigFileChanges, LogWriter)) { return(false); } // Update the zipped binaries path if it's changed int NewZippedBinariesConfigChangeNumber = (ConfigFileChanges.Count > 0)? ConfigFileChanges[0].Number : 0; if (NewZippedBinariesConfigChangeNumber != ZippedBinariesConfigChangeNumber) { string NewZippedBinariesPath = null; if (NewZippedBinariesConfigChangeNumber != 0) { List <string> Lines; if (!Perforce.Print(ClientConfigFileName, out Lines, LogWriter)) { return(false); } ConfigFile NewConfigFile = new ConfigFile(); NewConfigFile.Parse(Lines.ToArray()); ConfigSection ProjectSection = NewConfigFile.FindSection(SelectedProjectIdentifier); if (ProjectSection != null) { NewZippedBinariesPath = ProjectSection.GetValue("ZippedBinariesPath", null); } } ZippedBinariesPath = NewZippedBinariesPath; ZippedBinariesConfigChangeNumber = NewZippedBinariesConfigChangeNumber; } SortedList <int, string> NewChangeNumberToZippedBinaries = new SortedList <int, string>(); if (ZippedBinariesPath != null) { List <PerforceFileChangeSummary> Changes; if (!Perforce.FindFileChanges(ZippedBinariesPath, 100, out Changes, LogWriter)) { return(false); } foreach (PerforceFileChangeSummary Change in Changes) { if (Change.Action != "purge") { string[] Tokens = Change.Description.Split(' '); if (Tokens[0].StartsWith("[CL") && Tokens[1].EndsWith("]")) { int OriginalChangeNumber; if (int.TryParse(Tokens[1].Substring(0, Tokens[1].Length - 1), out OriginalChangeNumber) && !NewChangeNumberToZippedBinaries.ContainsKey(OriginalChangeNumber)) { NewChangeNumberToZippedBinaries[OriginalChangeNumber] = String.Format("{0}#{1}", ZippedBinariesPath, Change.Revision); } } } } } if (!ChangeNumberToZippedBinaries.SequenceEqual(NewChangeNumberToZippedBinaries)) { ChangeNumberToZippedBinaries = NewChangeNumberToZippedBinaries; if (OnUpdateMetadata != null && Changes.Count > 0) { OnUpdateMetadata(); } } return(true); }
public UserSettings(string InFileName) { FileName = InFileName; if (File.Exists(FileName)) { ConfigFile.Load(FileName); } // General settings Version = (UserSettingsVersion)ConfigFile.GetValue("General.Version", (int)UserSettingsVersion.Initial); bBuildAfterSync = (ConfigFile.GetValue("General.BuildAfterSync", "1") != "0"); bRunAfterSync = (ConfigFile.GetValue("General.RunAfterSync", "1") != "0"); bool bSyncPrecompiledEditor = (ConfigFile.GetValue("General.SyncPrecompiledEditor", "0") != "0"); bOpenSolutionAfterSync = (ConfigFile.GetValue("General.OpenSolutionAfterSync", "0") != "0"); bShowLogWindow = (ConfigFile.GetValue("General.ShowLogWindow", false)); bAutoResolveConflicts = (ConfigFile.GetValue("General.AutoResolveConflicts", "1") != "0"); bShowUnreviewedChanges = ConfigFile.GetValue("General.ShowUnreviewed", true); bShowAutomatedChanges = ConfigFile.GetValue("General.ShowAutomated", false); bShowLocalTimes = ConfigFile.GetValue("General.ShowLocalTimes", false); bKeepInTray = ConfigFile.GetValue("General.KeepInTray", true); int.TryParse(ConfigFile.GetValue("General.FilterIndex", "0"), out FilterIndex); string LastProjectString = ConfigFile.GetValue("General.LastProject", null); if (LastProjectString != null) { UserSelectedProjectSettings.TryParseConfigEntry(LastProjectString, out LastProject); } else { string LastProjectFileName = ConfigFile.GetValue("General.LastProjectFileName", null); if (LastProjectFileName != null) { LastProject = new UserSelectedProjectSettings(null, null, UserSelectedProjectType.Local, null, LastProjectFileName); } } OpenProjects = ReadProjectList("General.OpenProjects", "General.OpenProjectFileNames"); RecentProjects = ReadProjectList("General.RecentProjects", "General.OtherProjectFileNames"); SyncView = ConfigFile.GetValues("General.SyncFilter", new string[0]); SyncCategories = GetCategorySettings(ConfigFile.FindSection("General"), "SyncIncludedCategories", "SyncExcludedCategories"); bSyncAllProjects = ConfigFile.GetValue("General.SyncAllProjects", false); bIncludeAllProjectsInSolution = ConfigFile.GetValue("General.IncludeAllProjectsInSolution", false); if (!Enum.TryParse(ConfigFile.GetValue("General.SyncType", ""), out SyncType)) { SyncType = LatestChangeType.Good; } // Build configuration string CompiledEditorBuildConfigName = ConfigFile.GetValue("General.BuildConfig", ""); if (!Enum.TryParse(CompiledEditorBuildConfigName, true, out CompiledEditorBuildConfig)) { CompiledEditorBuildConfig = BuildConfig.DebugGame; } // Tab names string TabLabelsValue = ConfigFile.GetValue("General.TabLabels", ""); if (!Enum.TryParse(TabLabelsValue, true, out TabLabels)) { TabLabels = TabLabels.Stream; } // Editor arguments string[] Arguments = ConfigFile.GetValues("General.EditorArguments", new string[] { "0:-log", "0:-fastload" }); if (Version < UserSettingsVersion.XgeShaderCompilation) { Arguments = Enumerable.Concat(Arguments, new string[] { "0:-noxgeshadercompile" }).ToArray(); } foreach (string Argument in Arguments) { if (Argument.StartsWith("0:")) { EditorArguments.Add(new Tuple <string, bool>(Argument.Substring(2), false)); } else if (Argument.StartsWith("1:")) { EditorArguments.Add(new Tuple <string, bool>(Argument.Substring(2), true)); } else { EditorArguments.Add(new Tuple <string, bool>(Argument, true)); } } bEditorArgumentsPrompt = ConfigFile.GetValue("General.EditorArgumentsPrompt", false); // Precompiled binaries string[] ArchiveValues = ConfigFile.GetValues("PrecompiledBinaries.Archives", new string[0]); foreach (string ArchiveValue in ArchiveValues) { ArchiveSettings Settings; if (ArchiveSettings.TryParseConfigEntry(ArchiveValue, out Settings)) { Archives.Add(Settings); } } if (bSyncPrecompiledEditor) { Archives.Add(new ArchiveSettings(true, "Editor", new string[0])); } // Window settings bWindowVisible = ConfigFile.GetValue("Window.Visible", true); if (!Enum.TryParse(ConfigFile.GetValue("Window.State", ""), true, out WindowState)) { WindowState = FormWindowState.Normal; } WindowBounds = ParseRectangleValue(ConfigFile.GetValue("Window.Bounds", "")); // Schedule settings bScheduleEnabled = ConfigFile.GetValue("Schedule.Enabled", false); if (!TimeSpan.TryParse(ConfigFile.GetValue("Schedule.Time", ""), out ScheduleTime)) { ScheduleTime = new TimeSpan(6, 0, 0); } if (!Enum.TryParse(ConfigFile.GetValue("Schedule.Change", ""), out ScheduleChange)) { ScheduleChange = LatestChangeType.Good; } ScheduleAnyOpenProject = ConfigFile.GetValue("Schedule.AnyOpenProject", true); ScheduleProjects = ReadProjectList("Schedule.Projects", "Schedule.ProjectFileNames"); // Notification settings NotifyUnassignedMinutes = ConfigFile.GetValue("Notifications.NotifyUnassignedMinutes", -1); NotifyUnacknowledgedMinutes = ConfigFile.GetValue("Notifications.NotifyUnacknowledgedMinutes", -1); NotifyUnresolvedMinutes = ConfigFile.GetValue("Notifications.NotifyUnresolvedMinutes", -1); // Perforce settings if (!int.TryParse(ConfigFile.GetValue("Perforce.NumRetries", "0"), out SyncOptions.NumRetries)) { SyncOptions.NumRetries = 0; } int NumThreads; if (int.TryParse(ConfigFile.GetValue("Perforce.NumThreads", "0"), out NumThreads) && NumThreads > 0) { if (Version >= UserSettingsVersion.DefaultNumberOfThreads || NumThreads > 1) { SyncOptions.NumThreads = NumThreads; } } if (!int.TryParse(ConfigFile.GetValue("Perforce.TcpBufferSize", "0"), out SyncOptions.TcpBufferSize)) { SyncOptions.TcpBufferSize = 0; } }