public void SetupList() { descriptiveName.text = emulatorConfiguration.emulator.descriptiveName; id.text = emulatorConfiguration.emulator.id; SetupDropDownList(gameLauncherMethod, Enum.GetNames(typeof(GameLauncherMethod)).ToList()); gameLauncherMethod.value = gameLauncherMethod.options.FindIndex(option => option.text == emulatorConfiguration.emulator.gameLauncherMethod); selectedModelList = emulatorConfiguration.masterGamelist != null ? emulatorConfiguration.masterGamelist : new List <ModelProperties>(); selectedModelList = selectedModelList.OrderBy(x => x.descriptiveName).ToList(); executable.text = emulatorConfiguration.emulator.executable; libretroCore.text = emulatorConfiguration.emulator.libretroCore; extension.text = emulatorConfiguration.emulator.extension; arguments.text = emulatorConfiguration.emulator.arguments; options.text = emulatorConfiguration.emulator.options; emulatorPath.text = FileManager.CorrectFilePath(emulatorConfiguration.emulator.emulatorPath); gamePath.text = FileManager.CorrectFilePath(emulatorConfiguration.emulator.gamePath); workingDir.text = FileManager.CorrectFilePath(emulatorConfiguration.emulator.workingDir); marqueePath.text = FileManager.CorrectFilePath(emulatorConfiguration.emulator.marqueePath); screenPath.text = FileManager.CorrectFilePath(emulatorConfiguration.emulator.screenPath); screenVideoPath.text = FileManager.CorrectFilePath(emulatorConfiguration.emulator.screenVideoPath); genericPath.text = FileManager.CorrectFilePath(emulatorConfiguration.emulator.genericPath); titlePath.text = FileManager.CorrectFilePath(emulatorConfiguration.emulator.titlePath); infoPath.text = FileManager.CorrectFilePath(emulatorConfiguration.emulator.infoPath); UpdateModelList(); }
public void UpdateEmulatorConfiguration() { emulatorConfiguration.emulator.descriptiveName = descriptiveName.text; emulatorConfiguration.emulator.id = id.text; emulatorConfiguration.emulator.gameLauncherMethod = gameLauncherMethod.options[gameLauncherMethod.value].text; if (filteredSelectedModelList.Count > 0) { filteredSelectedModelList[listIndex] = modelProperties.GetModelProperties(); // Get last changes made to the currently selected model emulatorConfiguration.masterGamelist = filteredSelectedModelList; } emulatorConfiguration.emulator.executable = executable.text; emulatorConfiguration.emulator.libretroCore = libretroCore.text; emulatorConfiguration.emulator.extension = extension.text; emulatorConfiguration.emulator.arguments = arguments.text; emulatorConfiguration.emulator.options = options.text; emulatorConfiguration.emulator.emulatorPath = FileManager.CorrectFilePath(emulatorPath.text); emulatorConfiguration.emulator.gamePath = FileManager.CorrectFilePath(gamePath.text); emulatorConfiguration.emulator.workingDir = FileManager.CorrectFilePath(workingDir.text); emulatorConfiguration.emulator.marqueePath = FileManager.CorrectFilePath(marqueePath.text); emulatorConfiguration.emulator.screenPath = FileManager.CorrectFilePath(screenPath.text); emulatorConfiguration.emulator.screenVideoPath = FileManager.CorrectFilePath(screenVideoPath.text); emulatorConfiguration.emulator.genericPath = FileManager.CorrectFilePath(genericPath.text); emulatorConfiguration.emulator.titlePath = FileManager.CorrectFilePath(titlePath.text); emulatorConfiguration.emulator.infoPath = FileManager.CorrectFilePath(infoPath.text); ArcadeManager.emulatorsConfigurationList[emulatorsIndex] = emulatorConfiguration; }
public void Setup(ModelProperties modelProperties, ModelSharedProperties modelSharedProperties) { this.modelSharedProperties = modelSharedProperties; SetModelProperties(modelProperties); List <GameObject> thisChildren = new List <GameObject>(); if (!Application.isPlaying) { foreach (Transform child in transform) { if (child.gameObject != null) { thisChildren.Add(child.gameObject); } } } else { thisChildren = new List <GameObject>(); transform.GetChild(0).transform.tag = transform.tag; foreach (Transform child in transform.GetChild(0).transform) { if (child.gameObject != null) { thisChildren.Add(child.gameObject); } } } List <EmulatorConfiguration> emulatorList = new List <EmulatorConfiguration>(); emulatorList = ArcadeManager.emulatorsConfigurationList.Where(x => x.emulator.id == emulator).ToList(); if (emulatorList.Count < 1) { return; } EmulatorProperties emulatorSelected = emulatorList[0].emulator; if (emulatorSelected == null) { return; } // TODO: setup some default paths for marquees, screenshots and generics. // Marquee setup if (thisChildren.Count > 0) { Texture2D tex = null; List <Texture2D> textureList = new List <Texture2D>(); string url = null; // image and image cylcing (cycling with id_*.ext) textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.marqueePath), id); if (textureList.Count < 1) { textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.marqueePath), idParent); } // video url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.marqueePath), id); if (url == null) { url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.marqueePath), idParent); } // if we only have one or zero images we dont have to setup videoplayer/image cycling if (url == null && textureList.Count <= 1) { var marquee = thisChildren[0].GetComponent <ModelImageSetup>(); if (marquee == null) { marquee = thisChildren[0].AddComponent <ModelImageSetup>(); } if (textureList.Count > 0) { tex = textureList[0]; } marquee.Setup(tex, modelSharedProperties.renderSettings, modelProperties, (gameObject.CompareTag("gamemodel") || gameObject.CompareTag("propmodel") ? ModelComponentType.Marquee : ModelComponentType.Generic)); } else { SetupVideo(thisChildren[0], textureList, url, (gameObject.CompareTag("gamemodel") || gameObject.CompareTag("propmodel") ? ModelComponentType.Marquee : ModelComponentType.Generic), modelSharedProperties); } } // Screen setup if (thisChildren.Count > 1) { List <Texture2D> textureList = new List <Texture2D>(); string url = null; // image and image cycling (cycling with id_*.ext) textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenPath), id); if (textureList.Count < 1) { textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenPath), idParent); } if (textureList.Count <= 1) { var tList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.titlePath), id); if (tList.Count < 1) { tList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.titlePath), idParent); } if (tList.Count > 0) { textureList.AddRange(tList); } } // video url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenPath), id); if (url == null) { url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenPath), idParent); } if (url == null) { url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenVideoPath), id); } if (url == null) { url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.screenVideoPath), idParent); } SetupVideo(thisChildren[1], textureList, url, ModelComponentType.Screen, modelSharedProperties); } // Generic Texture setup if (thisChildren.Count > 2) { List <Texture2D> textureList = new List <Texture2D>(); string url = null; // image and image cycling (cycling with id_*.ext) textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.genericPath), id); if (textureList.Count < 1) { textureList = FileManager.LoadImagesFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.genericPath), idParent); } // video url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.genericPath), id); if (url == null) { url = FileManager.GetVideoPathFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(emulatorSelected.genericPath), idParent); } // if we only have one or zero images we dont have to setup videoplayer/image cycling if (url == null && textureList.Count == 1) { var generic = thisChildren[2].GetComponent <ModelImageSetup>(); if (generic == null) { generic = thisChildren[2].AddComponent <ModelImageSetup>(); } var tex = textureList[0]; generic.Setup(tex, modelSharedProperties.renderSettings, modelProperties, ModelComponentType.Generic); } else if (url != null || textureList.Count > 1) { SetupVideo(thisChildren[2], textureList, url, ModelComponentType.Generic, modelSharedProperties); } } }
public static void LoadGame(ModelSetup game, ModelSetup selected) { TriggerManager.SendEvent(Event.GameStarted); selectedModelSetup = selected; // The model not its dummy node gameModelSetup = game; // Different from selected when game was choosen in CylMenu or FpsMenu. if (gameModelSetup == null) { UnityEngine.Debug.Log("Launcher: model setup not found"); return; } else { UnityEngine.Debug.Log("Launcher: launching " + gameModelSetup.id); } if (selectedModelSetup == null) { UnityEngine.Debug.Log("Launcher: selectedmodel setup not found"); return; } else { UnityEngine.Debug.Log("Launcher: launchingselected " + selectedModelSetup.id); } List <EmulatorConfiguration> emulatorConfiguration = ArcadeManager.emulatorsConfigurationList.Where(x => x.emulator.id == gameModelSetup.emulator).ToList(); if (emulatorConfiguration.Count < 1) { UnityEngine.Debug.Log("Launcher: no emulator configuration found"); return; } selectedModelSetup.isPlaying = true; var launcherMethod = GameLauncherMethod.None; launcherMethod = gameModelSetup.gameLauncherMethod; if (launcherMethod == GameLauncherMethod.None) { System.Enum.TryParse(emulatorConfiguration[0].emulator.gameLauncherMethod, true, out launcherMethod); } if (launcherMethod == GameLauncherMethod.None) { System.Enum.TryParse(selectedModelSetup == gameModelSetup ? ArcadeManager.arcadeConfiguration.gameLauncherMethod : ArcadeManager.menuConfiguration.gameLauncherMethod, true, out launcherMethod); } switch (launcherMethod) { case GameLauncherMethod.Internal: LoadInternalGame(emulatorConfiguration[0].emulator); break; case GameLauncherMethod.External: LoadExternalGame(emulatorConfiguration[0].emulator); break; case GameLauncherMethod.URL: LoadURLGame(emulatorConfiguration[0].emulator); break; default: UnityEngine.Debug.Log("Launcher: no launcher method found"); break; } void LoadExternalGame(EmulatorProperties emulator) { // Application.OpenURL("mameios://"); // TODO: Damn this works, but ugly! You know better! string path = ArcadeManager.applicationPath; string executable = emulator.executable.Trim(); string extension = emulator.extension != null?emulator.extension.Trim() : ""; // TODO: Implement commandline arguments //string arguments = emulator.arguments.Trim(); string options = emulator.options.TrimStart(); string emulatorPath = FileManager.CorrectFilePath(emulator.emulatorPath); if (emulatorPath != "") { emulatorPath = path + emulatorPath; } string gamePath = FileManager.CorrectFilePath(emulator.gamePath); if (gamePath != "") { gamePath = path + gamePath; } string workingDir = FileManager.CorrectFilePath(emulator.workingDir); if (workingDir != "") { workingDir = path + workingDir; } ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = emulatorPath + executable; startInfo.Arguments = options + gamePath + gameModelSetup.id.Trim() + extension; // space char after -File if (workingDir != "") { startInfo.WorkingDirectory = workingDir; } startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.CreateNoWindow = true; startInfo.UseShellExecute = false; bool started = false; Process process = new Process(); process.StartInfo = startInfo; started = process.Start(); try { int procId = process.Id; } catch (InvalidOperationException) { started = false; } catch (Exception ex) { UnityEngine.Debug.Log("Error: " + ex.Message + " " + ex.InnerException); started = false; } if (started) { UnityEngine.Debug.Log("game started"); ArcadeManager.arcadeState = ArcadeStates.Game; } } void LoadInternalGame(EmulatorProperties emulator) { UnityEngine.Debug.Log("Launcher: start internal launcher " + selectedModelSetup.transform.gameObject.name); GameObject screen = selectedModelSetup.transform.GetChild(0).GetChild(1).gameObject; UnityEngine.Debug.Log("selected obj " + selectedModelSetup.name); ModelVideoSetup video = screen.GetComponent <ModelVideoSetup>(); video.ReleasePlayer(false); UnityEngine.Debug.Log("selected video " + video); RigidbodyFirstPersonController arcadeRigidbodyFirstPersonController = ArcadeManager.arcadeControls[ArcadeType.FpsArcade].GetComponent <RigidbodyFirstPersonController>(); if (arcadeRigidbodyFirstPersonController != null) { arcadeRigidbodyFirstPersonController.pause = true; } // TODO: Damn this works, but ugly! string path = ArcadeManager.applicationPath; string executable = emulator.libretroCore.Trim(); string extension = emulator.extension != null?emulator.extension.Trim() : ""; string arguments = emulator.arguments.Trim(); string options = emulator.options.TrimStart(); string emulatorPath = FileManager.CorrectFilePath(emulator.emulatorPath); if (emulatorPath != "") { emulatorPath = Path.Combine(path + emulatorPath); } string gamePath = FileManager.CorrectFilePath(emulator.gamePath); if (gamePath != "") { gamePath = Path.Combine(path + gamePath); } string workingDir = FileManager.CorrectFilePath(emulator.workingDir); if (workingDir != "") { workingDir = Path.Combine(path + workingDir); } //UnityEngine.Debug.Log("is path" + gamePath ); //UnityEngine.Debug.Log("is game" + gameModelSetup.id); ModelLibretroGameSetup libretroGame; libretroGame = selectedModelSetup.gameObject.GetComponent <ModelLibretroGameSetup>(); if (libretroGame == null) { libretroGame = selectedModelSetup.gameObject.AddComponent <ModelLibretroGameSetup>(); modelLibretroGameSetupsList.Add(libretroGame); libretroGame.StartGame(executable, gamePath, gameModelSetup.id); } else { libretroGame.ResumeGame(); } // Increase 1 to support more then one game at once if (modelLibretroGameSetupsList.Count > 1) { libretroGame = modelLibretroGameSetupsList[0]; if (libretroGame != null) { libretroGame.StopGame(); modelLibretroGameSetupsList.RemoveAt(0); } } ArcadeManager.arcadeState = ArcadeStates.Game; } void LoadURLGame(EmulatorProperties emulator) { Application.OpenURL(emulator.executable.Trim() + emulator.options.Trim() + gameModelSetup.id.Trim() + emulator.arguments.Trim()); ArcadeManager.arcadeState = ArcadeStates.Game; } }
public void Setup(AudioProperties audioProperties) { if (audioProperties == null || !Application.isPlaying) { return; } // Resume if not null if (this.audioProperties != null) { if (audioProperties.Equals(this.audioProperties)) { //print("equals"); audioSource.Play(); JukeboxEnabled = true; } } else { //print("setupaudio"); clips = new List <string>(); this.audioProperties = audioProperties; audioSource = gameObject.GetComponent <UnityEngine.AudioSource>(); if (audioSource == null) { audioSource = gameObject.AddComponent <UnityEngine.AudioSource>(); } audioSource.priority = audioProperties.priority; audioSource.volume = audioProperties.volume; audioSource.playOnAwake = audioProperties.playOnAwake; audioSource.spatialBlend = audioProperties.spatialBlend; audioSource.spatialize = audioProperties.spatialize; audioSource.minDistance = audioProperties.minDistance; audioSource.maxDistance = audioProperties.maxDistance; audioSource.loop = audioProperties.loop; foreach (AudioFile audioFile in audioProperties.audioFiles) { var file = FileManager.FileExists(ArcadeManager.applicationPath + FileManager.CorrectFilePath(audioFile.path.Trim()), audioFile.file.Trim()); if (file != null) { clips.Add("file://" + file); } else { var files = FileManager.GetAudioPathsFromFolder(ArcadeManager.applicationPath + FileManager.CorrectFilePath(audioFile.path.Trim())); //print(files[0]); foreach (string i in files) { clips.Add("file://" + i); } } if (clips.Count > 0) { if (clips.Count == 1) { audioSource.loop = audioProperties.loop; } else { audioSource.loop = false; } loop = audioProperties.loop; if (audioProperties.Randomize) { clips.Shuffle(); } clipIndex = -1; JukeboxEnabled = true; } } } }