private static string GetPagePath(string pageName) { string path = Path.Combine( Toolbox.CalcCitrusDirectory(), "Tangerine", "Documentation", Path.Combine(pageName.Split('.'))); return(path + ".md"); }
public static void GenerateBinaryDeserializers() { var jd = new BinaryDeserializerGenerator("GeneratedDeserializersBIN"); using (var ms = new MemoryStream()) using (var sw = new StreamWriter(ms)) { jd.GenWriter = sw; jd.GenerateHeader(); var types = new List <Type>(); var assembly = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.StartsWith("Lime", StringComparison.OrdinalIgnoreCase)).First(); foreach (var t in assembly.GetTypes()) { if (t.GetCustomAttribute <YuzuDontGenerateDeserializerAttribute>(false) != null) { continue; } if (t.IsGenericType) { if (t == typeof(Keyframe <>) || t == typeof(Animator <>)) { foreach (var specializationType in AnimatorRegistry.Instance.EnumerateRegisteredTypes()) { var specializedType = t.MakeGenericType(new[] { specializationType }); types.Add(specializedType); } } else { foreach (var specializationType in t.GetCustomAttributes <YuzuSpecializeWithAttribute>().Select(a => a.Type)) { var specializedType = t.MakeGenericType(new[] { specializationType }); types.Add(specializedType); } } } else { var meta = Yuzu.Metadata.Meta.Get(t, Serialization.YuzuCommonOptions); if (meta.Items.Count != 0) { types.Add(t); } } } types.Sort((a, b) => a.FullName.CompareTo(b.FullName)); foreach (var t in types) { jd.Generate(t); Console.WriteLine(t.FullName); } jd.GenerateFooter(); sw.Flush(); ms.WriteTo(new FileStream(Path.Combine(Toolbox.CalcCitrusDirectory(), "Lime", "Source", "GeneratedDeserializersBIN.cs"), FileMode.Create)); } }
public static string RunTangerine() { const string projectName = "Tangerine"; var projectDirectory = Path.Combine(Toolbox.CalcCitrusDirectory(), projectName); #if WIN var solutionPath = Path.Combine(projectDirectory, projectName + ".Win.sln"); MSBuild.TryGetMSBuildPath(out var msbuildPath); Nuget.Restore(solutionPath, msbuildPath); var solutionBuilder = new SolutionBuilder( TargetPlatform.Win, solutionPath, BuildConfiguration.Release); #elif MAC var solutionPath = Path.Combine(projectDirectory, projectName + ".Win.sln"); Nuget.Restore(solutionPath); var solutionBuilder = new SolutionBuilder( TargetPlatform.Mac, solutionPath, BuildConfiguration.Debug); // RELEASE requires code signing, use debug for a while. #endif if (!solutionBuilder.Build()) { return("Build system has returned error"); } var p = new System.Diagnostics.Process(); #if WIN p.StartInfo.FileName = Path.Combine( projectDirectory, "Tangerine", "bin", BuildConfiguration.Release, "Tangerine.exe"); #elif MAC p.StartInfo.FileName = Path.Combine( projectDirectory, "Tangerine", "bin", BuildConfiguration.Debug, "Tangerine.app/Contents/MacOS/Tangerine"); p.StartInfo.UseShellExecute = false; p.StartInfo.EnvironmentVariables.Clear(); p.StartInfo.EnvironmentVariables.Add("PATH", "/usr/bin"); #endif p.Start(); return(null); }
public static void GenerateBinaryDeserializersAndCloners() { var assembly = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.StartsWith("Lime", StringComparison.OrdinalIgnoreCase)).First(); Generate(Path.Combine(Toolbox.CalcCitrusDirectory(), "Lime", "Source", "YuzuGeneratedBinaryDeserializer.cs"), new BinaryDeserializerGenerator("YuzuGenerated", InternalPersistence.Instance.YuzuCommonOptions, "LimeDeserializer") { LineSeparator = "\n", }, GenerateForAssemblies(new[] { assembly }) ); Generate(Path.Combine(Toolbox.CalcCitrusDirectory(), "Lime", "Source", "YuzuGeneratedCloners.cs"), new ClonerGenerator("YuzuGenerated", InternalPersistence.Instance.YuzuCommonOptions, "LimeCloner") { LineSeparator = "\n", }, GenerateForAssemblies(new[] { assembly }) ); }
static Nuget() { #if MAC nugetPath = Path.Combine(Toolbox.GetApplicationDirectory(), "nuget.exe"); #else nugetPath = Path.Combine(Toolbox.GetApplicationDirectory(), "Toolchain.Win", "nuget.exe"); #endif if (!File.Exists(nugetPath)) { nugetPath = Path.Combine(Toolbox.CalcCitrusDirectory(), "Orange", "Toolchain.Win", "nuget.exe"); } if (!File.Exists(nugetPath)) { throw new InvalidOperationException($"Can't find nuget.exe."); } #if MAC var chmodResult = Process.Start("chmod", $"+x {nugetPath}"); monoPath = Toolbox.GetMonoPath(); #endif }
public void Load() { var config = WorkspaceConfig.Load(); var citrusDirectory = Toolbox.CalcCitrusDirectory(); { // heuristic behavior: always try to go up and search for a citproj file // if found, ignore the one saved in app data, since we're opening citrus directory // related to found game project as a submodule var directoryInfo = (new DirectoryInfo(citrusDirectory)).Parent; while (directoryInfo != null) { var citprojFiles = directoryInfo.EnumerateFiles("*.citproj"); if (citprojFiles.Any()) { config.CitrusProject = citprojFiles.First().FullName; break; } directoryInfo = directoryInfo.Parent; } } Open(config.CitrusProject); The.UI.LoadFromWorkspaceConfig(config); var citrusVersion = CitrusVersion.Load(); if (citrusVersion.IsStandalone) { Console.WriteLine($"Welcome to Citrus. Version {citrusVersion.Version}, build number: {citrusVersion.BuildNumber}"); } BenchmarkEnabled = config.BenchmarkEnabled; BundlePickerVisible = config.BundlePickerVisible; #pragma warning disable CS4014 Orange.Updater.CheckForUpdates(); #pragma warning restore CS4014 LoadCacheSettings(); }
public static void Save(CitrusVersion citrusVersion) { using (var stream = File.Open(Path.Combine(Toolbox.CalcCitrusDirectory(), Filename), FileMode.Open)) { Save(citrusVersion, stream); } }
public static CitrusVersion Load() { using (var stream = File.Open(Path.Combine(Toolbox.CalcCitrusDirectory(), Filename), FileMode.Open)) { return(Load(stream)); } }
public static void NewProjectAction(Func <string, bool> projectOpened) { Application.InvokeOnMainThread(() => { var citrusPath = Toolbox.CalcCitrusDirectory(); var dlg = new FileDialog { AllowedFileTypes = new string[] { "" }, Mode = FileDialogMode.SelectFolder }; if (dlg.RunModal()) { targetDirectory = dlg.FileName; newCitrusDirectory = Path.Combine(dlg.FileName, "Citrus"); var projectName = Path.GetFileName(dlg.FileName); if (char.IsDigit(projectName[0])) { throw new System.Exception($"Project name '{projectName}' cannot start with a digit"); } foreach (char c in projectName) { if (!ValidChars.Contains(c)) { throw new System.Exception($"Project name '{projectName}' must contain only latin letters and digits"); } } var newProjectApplicationName = String.Join(" ", Regex.Split(projectName, @"(?<!^)(?=[A-Z])")); Console.WriteLine($"New project name is \"{projectName}\""); HashSet <string> textfileExtensions = new HashSet <string> { ".cs", ".xml", ".csproj", ".sln", ".citproj", ".projitems", ".shproj", ".txt", ".plist", ".strings", ".gitignore", }; using (var dc = new DirectoryChanger($"{citrusPath}/Samples/EmptyProject/")) { var fe = new FileEnumerator("."); foreach (var f in fe.Enumerate()) { var targetPath = Path.Combine(dlg.FileName, f.Path.Replace("EmptyProject", projectName)); Console.WriteLine($"Copying: {f.Path} => {targetPath}"); Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); System.IO.File.Copy(f.Path, targetPath); if (textfileExtensions.Contains(Path.GetExtension(targetPath).ToLower(CultureInfo.InvariantCulture))) { string text = File.ReadAllText(targetPath); text = text.Replace("EmptyProject", projectName); text = text.Replace("Empty Project", newProjectApplicationName); text = text.Replace("emptyproject", projectName.ToLower()); var citrusUri = new Uri(newCitrusDirectory); var fileUri = new Uri(targetPath); var relativeUri = fileUri.MakeRelativeUri(citrusUri); // TODO: apply only to .sln and .csproj file text = text.Replace("..\\..\\..", relativeUri.ToString()); if (targetPath.EndsWith(".citproj", StringComparison.OrdinalIgnoreCase)) { text = text.Replace("CitrusLocation: \"..\",", $"CitrusLocation: \"{relativeUri}\","); newProjectCitprojPath = targetPath; } File.WriteAllText(targetPath, text); } } } #if WIN // TODO: fix unresponsiveness on mac Git("init"); Git("add -A"); Git("submodule add https://gitlab.game-forest.com:8888/Common/Citrus.git Citrus"); Git("submodule update --init --recursive"); Git("commit -m\"Initial commit.\""); #endif // WIN } }); if (projectOpened != null) { projectOpened?.Invoke(newProjectCitprojPath); } }