public static void AddCameraSetupCall(string gameFileName, bool whetherToCall) { string contents = null; if (!string.IsNullOrEmpty(gameFileName)) { GlueCommands.Self.TryMultipleTimes(() => contents = FileManager.FromFileText(GlueState.Self.CurrentGlueProjectDirectory + gameFileName)); } if (!string.IsNullOrEmpty(contents)) { string whatToLookFor = "CameraSetup.SetupCamera(SpriteManager.Camera, graphics"; string lineToReplaceWith = "CameraSetup.SetupCamera(SpriteManager.Camera, graphics);"; if (whetherToCall) { lineToReplaceWith = "\t\t\t" + lineToReplaceWith; } else { lineToReplaceWith = "\t\t\t//" + lineToReplaceWith; } if (contents.Contains(whatToLookFor)) { // Only replace this if it's commented out: int startOfLine; int endOfLine; StringFunctions.GetStartAndEndOfLineContaining(contents, "CameraSetup.SetupCamera", out startOfLine, out endOfLine); string line = contents.Substring(startOfLine, endOfLine - startOfLine); bool shouldReplace = line.Trim().StartsWith("//"); if (shouldReplace) { StringFunctions.ReplaceLine(ref contents, "CameraSetup.SetupCamera", lineToReplaceWith); } } else { // We gotta find where to put the start call. This should be after // FlatRedBallServices.InitializeFlatRedBall int index = CodeParser.GetIndexAfterFlatRedBallInitialize(contents); if (index == -1) { GlueCommands.Self.PrintError("Could not find code in Game1.cs to add camera setup"); } else { contents = contents.Insert(index, lineToReplaceWith + Environment.NewLine); } } GlueCommands.Self.TryMultipleTimes(() => FileManager.SaveText(contents, FileManager.RelativeDirectory + gameFileName), 5); } }