BenVlodgi

Particle Installer for Sprowl

Feb 9th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3.  
  4. namespace ParticleInstaller
  5. {
  6.     class Program
  7.     {
  8.         private const string PARTICLE_PATH = "particles/sprowl_particles.pcf";
  9.         private const string PARTICLE_MANIFEST_PATH = "particles_manifest.txt";
  10.  
  11.         static void Main(string[] args)
  12.         {
  13.             if (IsPortal2Running())
  14.             {
  15.                 Console.Write("Portal 2 is running, you will need to restart portal 2 after this installation.\n Press any key to contine...");
  16.                 Console.ReadKey(true);
  17.             }
  18.  
  19.             if (!File.Exists(PARTICLE_MANIFEST_PATH))
  20.             {
  21.                 Console.Write("Cannot locate '" + PARTICLE_MANIFEST_PATH + "' ensure that it is in the same folder as\nthis executable before running.\nPress Any key to close...");
  22.                 Console.ReadKey(true);
  23.                 return;
  24.             }
  25.  
  26.             string filecontents = File.ReadAllText(PARTICLE_MANIFEST_PATH);
  27.             if (filecontents.Contains(PARTICLE_PATH))
  28.             {
  29.                 Console.Write("There is already a refrence to these particles in the manifest, if you are\nexperienceing issues with the particles, verify your game cache, and re-run this\nexecutable.\n Press any key to close...");
  30.                 Console.ReadKey(true);
  31.                 return;
  32.             }
  33.             File.WriteAllText(PARTICLE_MANIFEST_PATH, filecontents.Insert(filecontents.IndexOf('}'), "\t\"file\"\t\"" + PARTICLE_PATH + "\"" + Environment.NewLine));
  34.             Console.Write("The refrenece to the " + PARTICLE_PATH + "' has been added, you may now run\nPortal 2.\n Press any key to close...");
  35.             Console.ReadKey(true);
  36.         }
  37.  
  38.         public static bool IsPortal2Running()
  39.         {
  40.             return System.Diagnostics.Process.GetProcessesByName("portal2").Length != 0;
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment