public BackupFile BackupFile(GenericGameInfo game, string path) { string appData = GetAppContentPath(); string gamePath = Path.Combine(appData, game.GUID); string destination = Path.Combine(gamePath, Path.GetFileName(path)); if (!File.Exists(path)) { if (File.Exists(destination)) { // we f****d up and the backup exists? maybe, so restore File.Copy(destination, path); } } else { if (File.Exists(destination)) { File.Delete(destination); } File.Copy(path, destination); } BackupFile bkp = new BackupFile(path, destination); backupFiles.Add(bkp); return(bkp); }
public bool Initialize(UserGameInfo game, GameProfile profile) { this.userGame = game; this.profile = profile; // see if we have any save game to backup gen = game.Game as GenericGameInfo; if (gen == null) { // you f****d up return false; } engine = new Engine(); engine.SetValue("Options", profile.Options); data = new Dictionary<string, string>(); data.Add(NucleusFolderEnum.GameFolder.ToString(), Path.GetDirectoryName(game.ExePath)); if (gen.SaveType == GenericGameSaveType.None) { return true; } string saveFile = ProcessPath(gen.SavePath); GameManager.Instance.BeginBackup(game.Game); GameManager.Instance.BackupFile(game.Game, saveFile); return true; }
public bool Initialize(UserGameInfo game, GameProfile profile) { this.userGame = game; this.profile = profile; // see if we have any save game to backup gen = game.Game as GenericGameInfo; if (gen == null) { // you f****d up return(false); } if (gen.LockMouse) { _cursorModule = new CursorModule(); } jsData = new Dictionary <string, string>(); jsData.Add(Folder.Documents.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); jsData.Add(Folder.MainGameFolder.ToString(), Path.GetDirectoryName(game.ExePath)); jsData.Add(Folder.InstancedGameFolder.ToString(), Path.GetDirectoryName(game.ExePath)); timerInterval = gen.HandlerInterval; Log.RegisterForLogCallback(this); return(true); }
public bool Initialize(UserGameInfo game, GameProfile profile) { this.userGame = game; this.profile = profile; // see if we have any save game to backup gen = game.Game as GenericGameInfo; if (gen == null) { // you f****d up return(false); } engine = new Engine(); engine.SetValue("Options", profile.Options); data = new Dictionary <string, string>(); data.Add(NucleusFolderEnum.GameFolder.ToString(), Path.GetDirectoryName(game.ExePath)); if (gen.SaveType == GenericGameSaveType.None) { return(true); } string saveFile = ProcessPath(gen.SavePath); GameManager.Instance.BeginBackup(game.Game); GameManager.Instance.BackupFile(game.Game, saveFile); return(true); }
private void Initialize() { // Type we are looking for (GameInfo) Type infoType = typeof(IGameInfo); Assembly ass = Assembly.Load(new AssemblyName("Nucleus.Coop.Games")); // I used to hate working with assembly, and that's why it has that name :D Type objType = typeof(object); if (ass == null) { // shit's null yo } else { Type[] t = ass.GetTypes(); for (int x = 0; x < t.Length; x++) { Type ty = t[x]; Type lastParent = ty.BaseType; Type parent = ty.BaseType; while (parent != objType) { lastParent = parent; parent = parent.BaseType; } if (ty.GetInterface("IGameInfo") != null) { // Found! IGameInfo info = (IGameInfo)Activator.CreateInstance(ty); LogManager.Log("Found game info: " + info.GameName); games.Add(info.GUID, info); gameInfos.Add(info.ExecutableName, info); } } } // search for JS games string jsfolder = GetJsGamesPath(); DirectoryInfo jsFolder = new DirectoryInfo(jsfolder); FileInfo[] files = jsFolder.GetFiles("*.js"); for (int i = 0; i < files.Length; i++) { FileInfo f = files[i]; using (Stream str = f.OpenRead()) { GenericGameInfo info = new GenericGameInfo(str); LogManager.Log("Found game info: " + info.GameName); games.Add(info.GUID, info); gameInfos.Add(info.ExecutableName, info); } } }
public void InitializeDefault(GenericGameInfo game, string exePath) { this.game = game; gameGuid = game.GUID; this.exePath = exePath; this.profiles = new List <GameProfile>(); }
public ContentManager(GenericGameInfo game) { this.game = game; loadedImages = new Dictionary <string, Image>(); gamesFolder = GameManager.Instance.GetJsGamesPath(); pkgFolder = Path.Combine(gamesFolder, Path.GetFileNameWithoutExtension(game.JsFileName)); }
public void BeginBackup(GenericGameInfo game) { string appData = GetAppContentPath(); string gamePath = Path.Combine(appData, game.GUID); Directory.CreateDirectory(gamePath); backupFiles = new List <BackupFile>(); }
public UserGameInfo AddGame(GenericGameInfo game, string exePath) { UserGameInfo gInfo = new UserGameInfo(); gInfo.InitializeDefault(game, exePath); user.Games.Add(gInfo); SaveUserProfile(); return(gInfo); }
private void Initialize() { // Search for Javascript games-infos string jsfolder = GetJsScriptsPath(); DirectoryInfo jsFolder = new DirectoryInfo(jsfolder); FileInfo[] files = jsFolder.GetFiles("*.js"); for (int i = 0; i < files.Length; i++) { FileInfo f = files[i]; try { using (Stream str = f.OpenRead()) { string ext = Path.GetFileNameWithoutExtension(f.Name); string pathBlock = Path.Combine(f.Directory.FullName, ext); GenericGameInfo info = new GenericGameInfo(f.Name, pathBlock, str); //LogManager.Log("Found game info: " + info.GameName); if (games.Any(c => c.Value.GUID == info.GUID)) { games.Remove(info.GUID); } games.Add(info.GUID, info); if (gameInfos.Any(c => c.Value.GUID == info.GUID)) { gameInfos.Remove(info.GUID); } gameInfos.Add(info.GUID, info); } } catch (ArgumentNullException) { continue; // Issue with content of script, ignore this as error prompt is already displayed } catch (ArgumentException ex) { MessageBox.Show(ex.InnerException + ": " + ex.Message, "Error with script " + f.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } } }
public bool Initialize(UserGameInfo game, GameProfile profile) { this.userGame = game; this.profile = profile; // see if we have any save game to backup gen = game.Game as GenericGameInfo; if (gen == null) { // you f****d up return(false); } data = new Dictionary <string, string>(); data.Add(Folder.Documents.ToString(), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); data.Add(Folder.GameFolder.ToString(), Path.GetDirectoryName(game.ExePath)); return(true); }
/// <summary> /// Tries adding a game to the collection with the provided IGameInfo /// </summary> /// <param name="exePath"></param> /// <returns></returns> public UserGameInfo TryAddGame(string exePath, GenericGameInfo game) { string lower = exePath.ToLower(); // search for the same exe on the user profile if (GameManager.Instance.User.Games.Any(c => c.ExePath.ToLower() == lower)) { return(null); } LogManager.Log("Found game: {0}, full path: {1}", game.GameName, exePath); UserGameInfo uinfo = new UserGameInfo(); uinfo.InitializeDefault(game, exePath); GameManager.Instance.User.Games.Add(uinfo); GameManager.Instance.SaveUserProfile(); return(uinfo); }
private void Initialize() { // Search for Javascript games-infos string jsfolder = GetJsGamesPath(); DirectoryInfo jsFolder = new DirectoryInfo(jsfolder); FileInfo[] files = jsFolder.GetFiles("*.js"); for (int i = 0; i < files.Length; i++) { FileInfo f = files[i]; using (Stream str = f.OpenRead()) { GenericGameInfo info = new GenericGameInfo(f.Name, str); LogManager.Log("Found game info: " + info.GameName); games.Add(info.GUID, info); gameInfos.Add(info.ExecutableName, info); } } }
public void ExecuteBackup(GenericGameInfo game) { // we didnt backup anything if (backupFiles == null) { return; } string appData = GetAppContentPath(); string gamePath = Path.Combine(appData, game.GUID); for (int i = 0; i < backupFiles.Count; i++) { BackupFile bkp = backupFiles[i]; if (File.Exists(bkp.BackupPath)) { File.Delete(bkp.Source); File.Move(bkp.BackupPath, bkp.Source); } } }
public void AddScript(string handlerName) { string jsfolder = GetJsScriptsPath(); DirectoryInfo jsFolder = new DirectoryInfo(jsfolder); FileInfo f = new FileInfo(Path.Combine(jsFolder.FullName, handlerName + ".js")); try { using (Stream str = f.OpenRead()) { string ext = Path.GetFileNameWithoutExtension(f.Name); string pathBlock = Path.Combine(f.Directory.FullName, ext); GenericGameInfo info = new GenericGameInfo(f.Name, pathBlock, str); LogManager.Log("Found game info: " + info.GameName); if (games.Any(c => c.Value.GUID == info.GUID)) { games.Remove(info.GUID); } games.Add(info.GUID, info); if (gameInfos.Any(c => c.Value.GUID == info.GUID)) { gameInfos.Remove(info.GUID); } gameInfos.Add(info.GUID, info); } } catch (ArgumentNullException) { //continue; // Issue with content of script, ignore this as error prompt is already displayed } catch (ArgumentException ex) { MessageBox.Show(ex.InnerException + ": " + ex.Message, "Error with script " + f.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); //continue; } }
public void InitializeDefault(GenericGameInfo game) { if (playerData == null) { playerData = new List <PlayerInfo>(); } if (screens == null) { screens = new List <UserScreen>(); } if (options == null) { options = new Dictionary <string, object>(); foreach (var opt in game.Options) { options.Add(opt.Key, opt.Value); } } }
/// <summary> /// Tries adding a game to the collection with the provided IGameInfo /// </summary> /// <param name="exePath"></param> /// <returns></returns> public UserGameInfo TryAddGame(string exePath, GenericGameInfo game) { string lower = exePath.ToLower(); // search for the same exe on the user profile if (GameManager.Instance.User.Games.Any(c => c.ExePath.ToLower() == lower)) { DialogResult dialogResult = MessageBox.Show("This game's executable is already in your library. Do you wish to add it anyway?\n\nExecutable Path: " + exePath, "Already exists", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.No) { return(null); } } LogManager.Log("Found game: {0}, full path: {1}", game.GameName, exePath); UserGameInfo uinfo = new UserGameInfo(); uinfo.InitializeDefault(game, exePath); GameManager.Instance.User.Games.Add(uinfo); GameManager.Instance.SaveUserProfile(); return(uinfo); }
private void Initialize() { // Search for Javascript games-infos string jsfolder = GetJsGamesPath(); DirectoryInfo jsFolder = new DirectoryInfo(jsfolder); FileInfo[] files = jsFolder.GetFiles("*.js"); for (int i = 0; i < files.Length; i++) { FileInfo f = files[i]; using (Stream str = f.OpenRead()) { string ext = Path.GetFileNameWithoutExtension(f.Name); string pathBlock = Path.Combine(f.Directory.FullName, ext); GenericGameInfo info = new GenericGameInfo(f.Name, pathBlock, str); LogManager.Log("Found game info: " + info.GameName); games.Add(info.GUID, info); //breaks anything? idk //gameInfos.Add(info.ExecutableName, info); } } }
public string GempTempFolder(GenericGameInfo game) { string appData = GetAppContentPath(); return(Path.Combine(appData, game.GUID)); }
public IGameHandler MakeHandler(GenericGameInfo game) { return((IGameHandler)Activator.CreateInstance(game.HandlerType)); }