/// <summary> /// Initializes the program and checks for existance of necessary directories. /// </summary> /// <returns>True if successfully initialized, false otherwise.</returns> private static bool Init() { Console.WriteLine("Initializing..."); // Create the directory Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\"); Config = new ConfigXml(); // Create music mood directories Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\battle_defeat\"); Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\battle_victory\"); Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\economic\"); Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\lose\"); Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\win\"); riseOfMusicCurrentGameDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\current_game\"; // If a players dir exists if (Directory.Exists(riseOfMusicCurrentGameDirPath)) { // Delete everything Directory.Delete(riseOfMusicCurrentGameDirPath, true); } // Create current game directories Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\1\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\2\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\3\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\4\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\5\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\6\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\7\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\8\"); // Get the current user in Rise of Nations String currentUser = GetCurrentUsername(); // Check that the user's dat file exists String datFilePath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\playerprofile\" + currentUser.ToLower() + ".dat"; if (File.Exists(datFilePath)) { // Set the DAT file path currentUserDatFilePath = datFilePath; } else { Console.WriteLine("Current user DAT file does not exists (" + datFilePath + ")"); return false; } InterceptKeys.OnTildePressedThreeTimesFast += InterceptKeys_OnTildePressedThreeTimesFast; InterceptKeys.OnRightControlPressedThreeTimesFast += InterceptKeys_OnRightControlPressedThreeTimesFast; String battleDefeatDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\battle_defeat\"; String battleVictoryDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\battle_victory\"; String economicDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\economic\"; String loseDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\lose\"; String winDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\win\"; // Check the existance of these directories bool battleDefeatDirExists = Directory.Exists(battleDefeatDirPath); bool battleVictoryDirExists = Directory.Exists(battleVictoryDirPath); bool economicDirExists = Directory.Exists(economicDirPath); bool loseDirExists = Directory.Exists(loseDirPath); bool winDirExists = Directory.Exists(winDirPath); // Set the current date modified for the current user DAT file currentUserDatFileLastWriteTime = File.GetLastWriteTime(currentUserDatFilePath); // Create the MusicPlayer object musicPlayer = new MusicPlayer(); // Returns true if all directories exist, false if even one does not exist return (battleDefeatDirExists && battleVictoryDirExists && economicDirExists && loseDirExists && winDirExists); }
/// <summary> /// Initializes the program and checks for existance of necessary directories. /// </summary> /// <returns>True if successfully initialized, false otherwise.</returns> private static bool Init() { Console.WriteLine("Initializing..."); // Create the directory Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\"); Config = new ConfigXml(); // Create music mood directories Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\battle_defeat\"); Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\battle_victory\"); Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\economic\"); Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\lose\"); Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\win\"); riseOfMusicCurrentGameDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\current_game\"; // If a players dir exists if (Directory.Exists(riseOfMusicCurrentGameDirPath)) { // Delete everything Directory.Delete(riseOfMusicCurrentGameDirPath, true); } // Create current game directories Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\1\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\2\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\3\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\4\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\5\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\6\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\7\"); Directory.CreateDirectory(riseOfMusicCurrentGameDirPath + @"players\8\"); // Get the current user in Rise of Nations String currentUser = GetCurrentUsername(); // Check that the user's dat file exists String datFilePath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\playerprofile\" + currentUser.ToLower() + ".dat"; if (File.Exists(datFilePath)) { // Set the DAT file path currentUserDatFilePath = datFilePath; } else { Console.WriteLine("Current user DAT file does not exists (" + datFilePath + ")"); return(false); } InterceptKeys.OnTildePressedThreeTimesFast += InterceptKeys_OnTildePressedThreeTimesFast; InterceptKeys.OnRightControlPressedThreeTimesFast += InterceptKeys_OnRightControlPressedThreeTimesFast; String battleDefeatDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\battle_defeat\"; String battleVictoryDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\battle_victory\"; String economicDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\economic\"; String loseDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\lose\"; String winDirPath = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\microsoft games\rise of nations\Rise_of_Music\sounds\tracks\win\"; // Check the existance of these directories bool battleDefeatDirExists = Directory.Exists(battleDefeatDirPath); bool battleVictoryDirExists = Directory.Exists(battleVictoryDirPath); bool economicDirExists = Directory.Exists(economicDirPath); bool loseDirExists = Directory.Exists(loseDirPath); bool winDirExists = Directory.Exists(winDirPath); // Set the current date modified for the current user DAT file currentUserDatFileLastWriteTime = File.GetLastWriteTime(currentUserDatFilePath); // Create the MusicPlayer object musicPlayer = new MusicPlayer(); // Returns true if all directories exist, false if even one does not exist return(battleDefeatDirExists && battleVictoryDirExists && economicDirExists && loseDirExists && winDirExists); }