using System.Reflection; using System; using System.Text.RegularExpressions; using UnityEngine; using Perforce.P4; namespace P4Connect { /// /// Version wrappers for P4Connect /// public static class Version { public static string appName = "p4connect"; public static string perforceRelease = "2015.2.0.0"; private static string changeIdStr; #if DEBUG public static string build = "Debug"; #else public static string build = "Release"; #endif public static string ChangeId { get { string change = " $Change: 15266 $"; // File must be stored +k so the RCS Keyword expands if (String.IsNullOrEmpty(changeIdStr)) { changeIdStr = Regex.Match(change, @"\d+").Value; } return changeIdStr; } } // Cache _PerforceReleaseString for re-use private static string _PerforceReleaseString = null; public static string PerforceReleaseString { get { if (_PerforceReleaseString != null) return _PerforceReleaseString; char[] delims = { '.' }; string[] fields = perforceRelease.Split(delims); // If UpdateVersion.exe is missing we need to generate the last two version fields if (fields[2].Equals("0") && fields[3].Equals("0")) { // Convert change ID into last two fields of version string. each field is limited to 16 bits, so we split values so they look appropriate in decimal. int changeId = Convert.ToInt32(ChangeId); fields[2] = (changeId / 10000).ToString(); fields[3] = (changeId % 10000).ToString(); } _PerforceReleaseString = string.Join(".",fields); return _PerforceReleaseString; } } static Options NameVerOpts = null; // Create an Array of options for the Connect call. You can see these in the Perforce server log public static Options ConnectOptions { get { if (NameVerOpts == null) { NameVerOpts = new Options(); NameVerOpts.Add("ProgramName", appName); NameVerOpts.Add("ProgramVersion", PerforceReleaseString); } return NameVerOpts; } } } }