Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Diagnostics;
- using System.Windows.Forms;
- using Nanook.QueenBee.Parser;
- using static IniFile;
- using System.Net;
- using Ionic.Zip;
- using System.Runtime.InteropServices;
- using System.Threading;
- using FastGH3;
- namespace FastGH3
- {
- class Program
- {
- [DllImport("USER32.DLL")]
- public static extern bool SetForegroundWindow(IntPtr hWnd);
- [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
- public static extern IntPtr FindWindow(string lpClassName,
- string lpWindowName);
- [DllImport("user32.dll")]
- static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
- private static string currentchart;
- private static string chart;
- private static string guitar_audio;
- private static string rhythm_audio;
- private static string song_audio;
- private static string[] chartiniexpert;
- private static bool vsync;
- private static int maxnotes;
- private static uint pushinteger;
- private static int notecolor;
- private static string[] parameters;
- private static OpenFileDialog openchart = new OpenFileDialog() { AddExtension = true, CheckFileExists = true, CheckPathExists = true, Filter = "All chart types|*.mid;*.chart|FastGH3 Song Package|*.fsp;*.zip|Any type|*.*", RestoreDirectory = true, Title = "Select chart" };
- private static IniFile chartini = new IniFile();
- static string Reverse(string s)
- {
- char[] charArray = s.ToCharArray();
- Array.Reverse(charArray);
- return new string(charArray);
- }
- static void disallowGameStartup()
- {
- try
- {
- foreach (Process proc in Process.GetProcessesByName("GH3"))
- {
- proc.Kill();
- }
- foreach (Process proc2 in Process.GetProcessesByName("DxWnd"))
- {
- proc2.Kill();
- }
- }
- catch (Exception ex)
- {
- Console.Write("ERROR! :(\n" + ex.Message);
- }
- }
- /*static bool IsOneOf<T>(this T value, params T[] items)
- {
- for (int i = 0; i < items.Length; ++i)
- {
- if (items[i].Equals(value))
- {
- return true;
- }
- }
- return false;
- }*/
- [STAThread]
- static void Main(string[] args)
- {
- Console.Title = "FastGH3";
- Console.CursorVisible = false;
- Console.WindowWidth = 41;
- Console.WindowHeight = 19;
- Console.BufferWidth = 41;
- Console.BufferHeight = Int16.MaxValue - 1;
- parameters = Environment.GetCommandLineArgs();
- if (args.Length == 0)
- {
- if (File.Exists(@"C:\Windows\fastgh3\CONFIGS\startupmsg"))
- {
- if (File.ReadAllText(@"C:\Windows\fastgh3\CONFIGS\startupmsg").ToString() == "on")
- {
- Console.CursorVisible = false;
- Console.WriteLine(@"
- FastGH3 is an advanced mod of
- Guitar Hero 3 designed to be played
- as fast as possible. With this mod, you
- can play customs without any technical
- setup and even associate chart or mid
- files with the game so you can access
- your charts quickly.
- To access settings,
- use -settings in parameters.
- If you want to disable this welcome
- message, you can do so by using
- these parameters:
- -startupmsg off
- Press any key to load a chart.");
- Console.ReadKey();
- }
- }
- else
- {
- Directory.CreateDirectory(@"C:\Windows\fastgh3\CONFIGS\");
- File.WriteAllText(@"C:\Windows\fastgh3\CONFIGS\startupmsg", "on");
- }
- if (openchart.ShowDialog() == DialogResult.OK)
- {
- Process.Start("C:\\Windows\\FastGH3\\FastGH3.exe", SubstringExtensions.EncloseWithQuoteMarks(openchart.FileName));
- }
- }
- try
- {
- if (parameters.Length > 0)
- {
- if (parameters[1] == "-startupmsg" && parameters[2] == "off")
- {
- File.WriteAllText(@"C:\Windows\fastgh3\CONFIGS\startupmsg", "off");
- }
- if (parameters[1] == "-startupmsg" && parameters[2] == "on")
- {
- File.WriteAllText(@"C:\Windows\fastgh3\CONFIGS\startupmsg", "on");
- }
- if (parameters[1] == "-settings")
- {
- Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.NoneEnabled;
- settings options = new settings();
- options.ShowDialog();
- }
- if (parameters[1] == "dl" && (parameters[2] != "" || parameters[2] != null))
- {
- Console.WriteLine("FastGH3 by donnaken15");
- Console.WriteLine("Downloading song package...");
- WebClient fsp = new WebClient();
- Uri fsplink = new Uri(parameters[2].Replace("fastgh3://", "http://"));
- try
- {
- fsp.DownloadFile(fsplink, "C:\\Windows\\FastGH3\\DATA\\TEMP\\DOWNLOAD.FSP");
- }
- catch (Exception ex)
- {
- Console.Write("ERROR! :(\n" + ex.Message);
- }
- Console.WriteLine("Adding song to game.");
- using (ZipFile file = ZipFile.Read(@"C:\Windows\FastGH3\DATA\TEMP\DOWNLOAD.FSP"))
- {
- file.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
- foreach (ZipEntry data in file)
- {
- if (data.FileName.Contains(".pak"))
- {
- data.Extract("C:\\Windows\\FastGH3\\DATA\\SONGS\\");
- File.Delete("C:\\Windows\\FastGH3\\DATA\\SONGS\\song_song.pak.xen");
- File.Move("C:\\Windows\\FastGH3\\DATA\\SONGS\\" + data.FileName, "C:\\Windows\\FastGH3\\DATA\\SONGS\\song_song.pak.xen");
- }
- if (data.FileName.Contains(".fsb"))
- {
- data.Extract("C:\\Windows\\FastGH3\\DATA\\MUSIC\\");
- File.Delete("C:\\Windows\\FastGH3\\DATA\\MUSIC\\song.fsb.xen");
- File.Move("C:\\Windows\\FastGH3\\DATA\\MUSIC\\" + data.FileName, "C:\\Windows\\FastGH3\\DATA\\MUSIC\\song.fsb.xen");
- }
- }
- }
- Console.WriteLine("Speeding up.");
- Process dxwnd = new Process();
- dxwnd.StartInfo.FileName = "C:\\Windows\\FastGH3\\WINDOWED\\dxwnd.exe";
- dxwnd.StartInfo.Arguments = "/q";
- dxwnd.StartInfo.WorkingDirectory = "C:\\Windows\\FastGH3\\WINDOWED\\";
- dxwnd.StartInfo.CreateNoWindow = false;
- dxwnd.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
- dxwnd.Start();
- Process gh3 = new Process();
- if (File.ReadAllText("C:\\Windows\\FastGH3\\CONFIGS\\vsync") == "True")
- {
- gh3.StartInfo.FileName = "C:\\Program Files\\3da\\3DAnalyze.exe";
- gh3.StartInfo.Arguments = "/EXE=C:\\Windows\\FastGH3\\gh3.exe";
- }
- else
- {
- gh3.StartInfo.FileName = "C:\\Windows\\FastGH3\\gh3.exe";
- gh3.StartInfo.Arguments = "";
- }
- gh3.Start();
- gh3.WaitForInputIdle();
- if (gh3.StartInfo.FileName == "C:\\Program Files\\3da\\3DAnalyze.exe")
- {
- Thread.Sleep(2500);
- gh3.Kill();
- }
- }
- if (File.Exists(parameters[1]))
- {
- Console.WriteLine("FASTGH3 by donnaken15");
- if (Path.GetFileName(parameters[1]).Contains(".chart") || Path.GetFileName(parameters[1]).Contains(".mid"))
- {
- Process chart2mid = new Process();
- Console.WriteLine("Checking file extension...");
- File.Delete("C:\\Windows\\FastGH3\\DATA\\SONGS\\song.mid");
- if (Path.GetFileName(parameters[1]).Contains(".chart"))
- {
- Console.WriteLine("Detected chart file. ");
- chart2mid.StartInfo.FileName = "C:\\Windows\\FastGH3\\chart2mid.exe";
- chart2mid.Start();
- chart2mid.WaitForInputIdle();
- try
- {
- File.Move(parameters[0].Replace(".chart", ".mid"), parameters[0].Replace(".chart", ".mid") + ".bak");
- }
- catch { }
- Thread.Sleep(1000);
- SetForegroundWindow(chart2mid.MainWindowHandle);
- SendKeys.SendWait("{TAB}");
- Thread.Sleep(125);
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(125);
- SendKeys.SendWait(parameters[1].Replace("(", "{(}").Replace(")", "{)}"));
- Thread.Sleep(125);
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(125);
- SendKeys.SendWait("{TAB 3}");
- Thread.Sleep(125);
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(100);
- SendKeys.SendWait("%{F4}");
- chart2mid.WaitForInputIdle();
- Thread.Sleep(500);
- File.Copy(parameters[1].Replace(".chart", ".mid"), "C:\\Windows\\FastGH3\\DATA\\SONGS\\song.mid", true);
- chart = File.ReadAllText(parameters[1]).Replace("}", "").Replace("{", "");
- File.WriteAllText("C:\\Windows\\FastGH3\\DATA\\SONGS\\song.chart", chart);
- }
- else if (Path.GetFileName(parameters[1]).Contains(".mid"))
- {
- Console.WriteLine("Detected midi file.");
- File.Copy(parameters[1], "C:\\Windows\\FastGH3\\DATA\\SONGS\\song.mid", true);
- }
- chartini.Load("C:\\Windows\\FastGH3\\DATA\\SONGS\\song.chart");
- Console.WriteLine("\n NOTE/WARNING:");
- Console.WriteLine(" Don't press anything,");
- Console.WriteLine(" the chart is processing.");
- Console.WriteLine(" Currently, the program");
- Console.WriteLine(" is using an alternative");
- Console.WriteLine(" method for now until");
- Console.WriteLine(" FastGH3's own chart");
- Console.WriteLine(" parser gets fixed.");
- Thread.Sleep(100);
- File.Delete("C:\\Windows\\FastGH3\\DATA\\TEMP\\MUSIC\\song.fsb.xen");
- File.Delete("C:\\Windows\\FastGH3\\DATA\\TEMP\\MUSIC\\song.dat.xen");
- File.Delete("C:\\Windows\\FastGH3\\DATA\\TEMP\\SONGS\\song_song.pak.xen");
- Process sox = new Process();
- sox.StartInfo.FileName = "C:\\Windows\\FastGH3\\sox.exe";
- if (File.Exists(Path.GetFullPath(parameters[1]).Replace(Path.GetFileName(parameters[1]), "song.ogg")))
- {
- try
- {
- sox.StartInfo.Arguments = Path.GetFullPath(parameters[1]).Replace(Path.GetFileName(parameters[1]), "song.ogg") + @" C:\Windows\FastGH3\DATA\MUSIC\audio\song.ogg";
- if (File.Exists(Path.GetFullPath(parameters[1]).Replace(Path.GetFileName(parameters[1]), "guitar.ogg")))
- {
- sox.Start();
- sox.StartInfo.Arguments = "−r 44100 −b 16" + Path.GetFullPath(parameters[1]).Replace(Path.GetFileName(parameters[1]), "song.ogg").EncloseWithQuoteMarks() + @" C:\Windows\FastGH3\DATA\MUSIC\audio\guitar.ogg";
- if (File.Exists(Path.GetFullPath(parameters[1]).Replace(Path.GetFileName(parameters[1]), "rhythm.ogg")))
- {
- sox.Start();
- sox.StartInfo.Arguments = "−r 44100 −b 16" + Path.GetFullPath(parameters[1]).Replace(Path.GetFileName(parameters[1]), "rhythm.ogg").EncloseWithQuoteMarks() + @" C:\Windows\FastGH3\DATA\MUSIC\audio\rhythm.ogg";
- }
- }
- }
- catch { }
- }
- else if (Path.GetFileName(parameters[1]).Contains(".chart"))
- {
- try
- {
- if (chart.Contains("GuitarStream = \""))
- {
- try
- {
- sox.StartInfo.Arguments = SubstringExtensions.EncloseWithQuoteMarks(Path.GetFullPath(parameters[1]).Replace(Path.GetFileName(parameters[1]), chartini.GetSection("Song").GetKey("GuitarStream").Value.Replace(" \"", "").Replace("\"", ""))) + @" C:\Windows\FastGH3\DATA\MUSIC\audio\guitar.ogg";
- sox.Start();
- }
- catch { }
- }
- if (chart.Contains("BassStream = \""))
- {
- try
- {
- sox.StartInfo.Arguments = SubstringExtensions.EncloseWithQuoteMarks(Path.GetFullPath(parameters[1]).Replace(Path.GetFileName(parameters[1]), chartini.GetSection("Song").GetKey("BassStream").Value.Replace(" \"", "").Replace("\"", ""))) + @" C:\Windows\FastGH3\DATA\MUSIC\audio\rhythm.ogg";
- sox.Start();
- }
- catch { }
- }
- sox.StartInfo.Arguments = SubstringExtensions.EncloseWithQuoteMarks(Path.GetFullPath(parameters[1]).Replace(Path.GetFileName(parameters[1]), chartini.GetSection("Song").GetKey("MusicStream").Value.Replace(" \"", "").Replace("\"", ""))) + @" C:\Windows\FastGH3\DATA\MUSIC\audio\song.ogg";
- }
- catch { }
- }
- else if (File.Exists(Path.GetFullPath(parameters[1]).Replace(".mid", ".ogg").Replace(".chart", ".ogg")))
- {
- try
- {
- sox.StartInfo.Arguments = Path.GetFullPath(parameters[1]).Replace(".mid", ".ogg").Replace(".chart", ".ogg").EncloseWithQuoteMarks() + @" C:\Windows\FastGH3\DATA\MUSIC\audio\song.ogg";
- }
- catch { }
- }
- else if (File.Exists(Path.GetFullPath(parameters[1]).Replace(".mid", ".mp3").Replace(".chart", ".mp3")))
- {
- try
- {
- sox.StartInfo.Arguments = Path.GetFullPath(parameters[1]).Replace(".mid", ".mp3").Replace(".chart", ".mp3").EncloseWithQuoteMarks() + @" C:\Windows\FastGH3\DATA\MUSIC\audio\song.ogg";
- }
- catch { }
- }
- else if (File.Exists(Path.GetFullPath(parameters[1]).Replace(".mid", ".wav").Replace(".chart", ".wav")))
- {
- try
- {
- sox.StartInfo.Arguments = Path.GetFullPath(parameters[1]).Replace(".mid", ".wav").Replace(".chart", ".wav").EncloseWithQuoteMarks() + @" C:\Windows\FastGH3\DATA\MUSIC\audio\song.ogg";
- }
- catch { }
- }
- else
- {
- DialogResult audiolost = MessageBox.Show("No audio files can be found?\nDo you want to search for it?", "Broken chart?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- DialogResult playsilent = MessageBox.Show("Want to play without audio?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (audiolost == DialogResult.Yes)
- {
- OpenFileDialog searchaudio = new OpenFileDialog() { CheckFileExists = true, CheckPathExists = true, InitialDirectory = Path.GetFullPath(parameters[1]).Replace(Path.GetFileName(parameters[1]), ""), Filter = "Audio files|*.mp3;*.wav;*.ogg|Any type|*.*" };
- }
- else if (audiolost == DialogResult.No)
- {
- if (playsilent == DialogResult.Yes)
- {
- sox.StartInfo.Arguments = "C:\\Windows\\FastGH3\\DATA\\TEMP\\MUSIC\\blank C:\\Windows\\FastGH3\\DATA\\MUSIC\\audio\\song_song.mp3";
- }
- else if (playsilent == DialogResult.No)
- {
- Application.Exit();
- }
- }
- }
- sox.Start();
- sox.WaitForExit();
- try
- {
- if (Path.GetFileName(parameters[1]).Contains(".chart"))
- {
- File.Copy(parameters[1].Replace(".chart", ".mid"), "C:\\Windows\\FastGH3\\DATA\\SONGS\\song.mid", true);
- chart2mid.Kill();
- }
- }
- catch { }
- Process songlist_editor = new Process();
- songlist_editor.StartInfo.FileName = "C:\\Windows\\FastGH3\\DATA\\TEMP\\songlist_editor.exe";
- songlist_editor.StartInfo.WorkingDirectory = "C:\\Windows\\FastGH3\\DATA\\TEMP\\";
- songlist_editor.Start();
- Thread.Sleep(250);
- SetForegroundWindow(songlist_editor.MainWindowHandle);
- Thread.Sleep(250);
- SendKeys.SendWait("%{F}");
- SendKeys.SendWait("{ENTER}");
- SendKeys.SendWait("{TAB 3}");
- SendKeys.SendWait("{BS 32}");
- SendKeys.SendWait("{DEL 32}");
- SendKeys.SendWait(@"C:\Windows\FastGH3\DATA\TEMP\");
- SendKeys.SendWait("{ENTER}");
- SendKeys.SendWait("{TAB 2}");
- SendKeys.SendWait("{ENTER}");
- SendKeys.SendWait("song");
- SendKeys.SendWait("{TAB}");
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(200);
- if (chart.Contains("GuitarStream = \""))
- {
- SendKeys.SendWait(@" C:\Windows\FastGH3\DATA\MUSIC\audio\guitar.ogg");
- }
- else
- {
- SendKeys.SendWait(" C:\\Windows\\FastGH3\\DATA\\MUSIC\\audio\\song.ogg");
- }
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(200);
- SendKeys.SendWait("{TAB 2}");
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(200);
- try
- {
- if (chart.Contains("BassStream = \""))
- {
- SendKeys.SendWait(@" C:\Windows\FastGH3\DATA\MUSIC\audio\rhythm.ogg");
- }
- else
- {
- SendKeys.SendWait(" C:\\Windows\\FastGH3\\DATA\\MUSIC\\audio\\song.ogg");
- }
- }
- catch
- { }
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(200);
- SendKeys.SendWait("{TAB 2}");
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(200);
- SendKeys.SendWait(" C:\\Windows\\FastGH3\\DATA\\MUSIC\\audio\\song.ogg");
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(200);
- SendKeys.SendWait("{TAB 4}");
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(200);
- SendKeys.SendWait(" C:\\Windows\\FastGH3\\DATA\\SONGS\\song.mid");
- SendKeys.SendWait("{ENTER}");
- Thread.Sleep(200);
- SendKeys.SendWait("{TAB}");
- SendKeys.SendWait("{ENTER}");
- SendKeys.SendWait("%{F4}");
- Thread.Sleep(4000);
- songlist_editor.WaitForExit();
- File.Delete(@"C:\Windows\fastgh3\DATA\SONGS\song_song.pak.xen");
- File.Copy(@"C:\Windows\fastgh3\DATA\TEMP\SONGS\song_song.pak.xen", @"C:\Windows\FastGH3\DATA\SONGS\song_song.pak.xen", true);
- Process dxwnd = new Process();
- dxwnd.StartInfo.FileName = "C:\\Windows\\FastGH3\\WINDOWED\\dxwnd.exe";
- dxwnd.StartInfo.WorkingDirectory = "C:\\Windows\\FastGH3\\WINDOWED\\";
- dxwnd.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
- dxwnd.StartInfo.Arguments = "/q";
- dxwnd.Start();
- Process gh3 = new Process();
- if (File.ReadAllText("C:\\Windows\\FastGH3\\CONFIGS\\vsync") == "True")
- {
- gh3.StartInfo.FileName = "C:\\Program Files\\3da\\3DAnalyze.exe";
- gh3.StartInfo.Arguments = "/EXE=C:\\Windows\\FastGH3\\gh3.exe";
- }
- else
- {
- gh3.StartInfo.FileName = "C:\\Windows\\FastGH3\\gh3.exe";
- gh3.StartInfo.Arguments = "";
- }
- gh3.Start();
- if (gh3.StartInfo.FileName == "C:\\Program Files\\3da\\3DAnalyze.exe")
- {
- Thread.Sleep(2500);
- gh3.Kill();
- }
- Thread.Sleep(3000);
- File.Delete(@"C:\Windows\FastGH3\DATA\MUSIC\song.fsb.xen");
- File.Delete(@"C:\Windows\FastGH3\DATA\MUSIC\song.dat.xen");
- File.Copy(@"C:\Windows\fastgh3\DATA\TEMP\MUSIC\song.dat.xen", @"C:\Windows\FastGH3\DATA\MUSIC\song.dat.xen", true);
- File.Copy(@"C:\Windows\fastgh3\DATA\TEMP\MUSIC\song.fsb.xen", @"C:\Windows\FastGH3\DATA\MUSIC\song.fsb.xen", true);
- }
- }
- }
- }
- catch { }
- GC.Collect();
- try
- {
- if (File.Exists(parameters[1]) && parameters[1].Contains(".fsp"))
- {
- Console.WriteLine("FastGH3 by donnaken15");
- Console.WriteLine("Downloading song package...");
- Console.WriteLine("Adding song to game.");
- using (ZipFile file = ZipFile.Read(parameters[1]))
- {
- file.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;
- foreach (ZipEntry data in file)
- {
- if (data.FileName.Contains(".pak"))
- {
- data.Extract("C:\\Windows\\FastGH3\\DATA\\SONGS\\");
- File.Delete("C:\\Windows\\FastGH3\\DATA\\SONGS\\song_song.pak.xen");
- File.Move("C:\\Windows\\FastGH3\\DATA\\SONGS\\" + data.FileName, "C:\\Windows\\FastGH3\\DATA\\SONGS\\song_song.pak.xen");
- }
- if (data.FileName.Contains(".fsb"))
- {
- data.Extract("C:\\Windows\\FastGH3\\DATA\\MUSIC\\");
- File.Delete("C:\\Windows\\FastGH3\\DATA\\MUSIC\\song.fsb.xen");
- File.Move("C:\\Windows\\FastGH3\\DATA\\MUSIC\\" + data.FileName, "C:\\Windows\\FastGH3\\DATA\\MUSIC\\song.fsb.xen");
- }
- }
- }
- Console.WriteLine("Speeding up.");
- Process dxwnd = new Process();
- dxwnd.StartInfo.FileName = "C:\\Windows\\FastGH3\\WINDOWED\\dxwnd.exe";
- dxwnd.StartInfo.Arguments = "/q";
- dxwnd.StartInfo.WorkingDirectory = "C:\\Windows\\FastGH3\\WINDOWED\\";
- dxwnd.StartInfo.CreateNoWindow = false;
- dxwnd.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
- dxwnd.Start();
- Process gh3 = new Process();
- if (File.ReadAllText("C:\\Windows\\FastGH3\\CONFIGS\\vsync") == "True")
- {
- gh3.StartInfo.FileName = "C:\\Program Files\\3da\\3DAnalyze.exe";
- gh3.StartInfo.Arguments = "/EXE=C:\\Windows\\FastGH3\\gh3.exe";
- }
- else
- {
- gh3.StartInfo.FileName = "C:\\Windows\\FastGH3\\gh3.exe";
- gh3.StartInfo.Arguments = "";
- }
- gh3.Start();
- if (gh3.StartInfo.FileName == "C:\\Program Files\\3da\\3DAnalyze.exe")
- {
- Thread.Sleep(2500);
- gh3.Kill();
- }
- }
- }
- catch { }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment