public void SaveEmulatorConfiguration(EmulatorConfiguration emulatorConfiguration)
        {
            string filePath = ArcadeManager.applicationPath + ArcadeManager.emulatorsConfigurationPath;
            var    fileName = emulatorConfiguration.emulator.id + ".json";

            Debug.Log("Save Emulator Configuration " + filePath + fileName);
            FileManager.SaveJSONData(emulatorConfiguration, filePath, fileName);
        }
Esempio n. 2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            ArcadeAttribute arcadeAttribute = attribute as ArcadeAttribute;

            position.width = position.width - arcadeAttribute.width - 16;
            EditorGUI.PropertyField(position, property, label);
            position.x     = position.x + position.width;
            position.width = arcadeAttribute.width + 16;

            if (GUI.Button(position, arcadeAttribute.label))
            {
                ModelSetup obj = property.serializedObject.targetObject as ModelSetup;
                //  if (obj == null) { return; }
                //Debug.Log("I belong to " + obj.descriptiveName);
                if (arcadeAttribute.label == "Model")
                {
                    EditorModelSetupSelectModel.ShowWindow(obj.transform.gameObject);
                }
                if (arcadeAttribute.label == "Emulator")
                {
                    if (ArcadeManager.emulatorsConfigurationList.Count < 1)
                    {
                        if (!ArcadeManager.loadSaveEmulatorConfiguration.LoadEmulatorsConfigurationList())
                        {
                            return;
                        }
                    }
                    EditorModelSetupEmulator.ShowWindow(obj.transform.gameObject);
                }
                if (arcadeAttribute.label == "Game")
                {
                    EmulatorConfiguration emulatorConfiguration = ArcadeManager.loadSaveEmulatorConfiguration.GetEmulatorConfiguration(obj.emulator);
                    if (emulatorConfiguration != null)
                    {
                        List <ModelProperties> gamelist = emulatorConfiguration.masterGamelist;
                        EditorModelSetupGame.ShowWindow(obj.transform.gameObject, gamelist);
                    }
                }
                if (arcadeAttribute.label == "Folder")
                {
                    string folder = FileManager.DialogGetFolderPath(true);
                    if (folder != null)
                    {
                        property.stringValue = folder;
                    }
                }
                if (arcadeAttribute.label == "Exe")
                {
                    string exe = FileManager.DialogGetFilePart("Select LibretroCore Executable", null, FileManager.FilePart.Name_Extension);
                    if (exe != null)
                    {
                        property.stringValue = exe;
                    }
                }
            }
        }
Esempio n. 3
0
        private static void UpdateMasterGamelistMenuOption(MenuCommand menuCommand)
        {
            var emulatorSetup = menuCommand.context as EmulatorSetup;
            EmulatorConfiguration emulatorConfiguration = ArcadeManager.loadSaveEmulatorConfiguration.GetEmulatorConfiguration(emulatorSetup.id);

            if (emulatorConfiguration != null)
            {
                emulatorConfiguration = UpdateMasterGamelists.UpdateMasterGamelistFromEmulatorConfiguration(emulatorConfiguration);
                ArcadeManager.loadSaveEmulatorConfiguration.SaveEmulatorConfiguration(emulatorConfiguration);
            }
        }
Esempio n. 4
0
        private void GetGame()
        {
            EmulatorConfiguration emulatorConfiguration = ArcadeManager.loadSaveEmulatorConfiguration.GetEmulatorConfiguration(emulator);

            if (emulatorConfiguration != null)
            {
                List <ModelProperties> gamelist = emulatorConfiguration.masterGamelist;
                if (ShowSelectEmulatorWindow != null)
                {
                    ShowSelectGameWindow(gameObject, gamelist);
                }
            }
        }
Esempio n. 5
0
        private static void SaveEmulatorConfigurationMenuOption(MenuCommand menuCommand)
        {
            var emulatorSetup = menuCommand.context as EmulatorSetup;
            EmulatorConfiguration emulatorConfiguration = ArcadeManager.loadSaveEmulatorConfiguration.GetEmulatorConfiguration(emulatorSetup.id);

            if (emulatorConfiguration == null)
            {
                emulatorConfiguration = new EmulatorConfiguration();
            }
            emulatorConfiguration.emulator = emulatorSetup.GetEmulatorSetup();
            ArcadeManager.loadSaveEmulatorConfiguration.SaveEmulatorConfiguration(emulatorConfiguration);
            //TODO: Change so that we update ArcadeManager.EmulatorsConfigurationList for save cfg instead of reloading all
            ArcadeManager.loadSaveEmulatorConfiguration.LoadEmulatorsConfigurationList();
        }
        public void DeleteEmulatorConfiguration(EmulatorConfiguration emulatorConfiguration)
        {
            string filePath = ArcadeManager.applicationPath + ArcadeManager.emulatorsConfigurationPath;

            Debug.Log("Delete! " + emulatorConfiguration.emulator.id);
            var fileName = emulatorConfiguration.emulator.id + ".json";

            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".json.meta";
            FileManager.DeleteFile(filePath, fileName);
            filePath = ArcadeManager.applicationPath + "/3darcade~/Configuration/MasterGamelists/mame/";
            fileName = emulatorConfiguration.emulator.id + ".xml";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".ini";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".dat";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".xml.meta";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".ini.meta";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".dat.meta";
            FileManager.DeleteFile(filePath, fileName);
            filePath = ArcadeManager.applicationPath + "/3darcade~/Configuration/MasterGamelists/hyperspin/";
            fileName = emulatorConfiguration.emulator.id + ".xml";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".ini";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".dat";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".xml.meta";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".ini.meta";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".dat.meta";
            FileManager.DeleteFile(filePath, fileName);
            filePath = ArcadeManager.applicationPath + "/3darcade~/Configuration/MasterGamelists/atf/";
            fileName = emulatorConfiguration.emulator.id + ".atf";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".ini";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".dat";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".atf.meta";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".ini.meta";
            FileManager.DeleteFile(filePath, fileName);
            fileName = emulatorConfiguration.emulator.id + ".dat.meta";
            FileManager.DeleteFile(filePath, fileName);
        }
Esempio n. 7
0
        private void DropdownValueChangedHandler(Dropdown target)
        {
            Debug.Log("selected: " + target.name + " " + target.value);

            if (target == emulators)
            {
                UpdateEmulatorConfiguration();
                var list = ArcadeManager.emulatorsConfigurationList.Where(x => x.emulator.descriptiveName.ToLower() == target.options[target.value].text.ToLower()).ToList <EmulatorConfiguration>();
                if (list.Count > 0)
                {
                    emulatorConfiguration = ArcadeManager.emulatorsConfigurationList[target.value];
                    emulatorsIndex        = target.value;
                    SetupList();
                }
            }
        }
Esempio n. 8
0
 public static void UpdateAll()
 {
     if (ArcadeManager.emulatorsConfigurationList.Count < 1)
     {
         ArcadeManager.loadSaveEmulatorConfiguration.LoadEmulatorsConfigurationList();
     }
     if (ArcadeManager.emulatorsConfigurationList.Count > 0)
     {
         for (int i = 0; i < ArcadeManager.emulatorsConfigurationList.Count; i++)
         {
             EmulatorConfiguration emulatorConfiguration = ArcadeManager.emulatorsConfigurationList[i];
             emulatorConfiguration = UpdateMasterGamelistFromEmulatorConfiguration(emulatorConfiguration);
             ArcadeManager.emulatorsConfigurationList[i] = emulatorConfiguration;
         }
         ArcadeManager.loadSaveEmulatorConfiguration.SaveEmulatorsConfigurationList();
     }
 }
        public bool LoadEmulatorsConfigurationList()
        {
            string filePath = ArcadeManager.applicationPath + ArcadeManager.emulatorsConfigurationPath;

            ArcadeManager.emulatorsConfigurationList = new List <EmulatorConfiguration>();
            var files = FileManager.FilesFromDirectory(ArcadeManager.applicationPath + ArcadeManager.emulatorsConfigurationPath, "*.json", SearchOption.AllDirectories);

            if (files != null)
            {
                foreach (FileInfo file in files)
                {
                    EmulatorConfiguration cfg = FileManager.LoadJSONData <EmulatorConfiguration>(file.FullName);
                    ArcadeManager.emulatorsConfigurationList.Add(cfg);
                }
                return(true);
            }
            return(false);
        }
        // This saves Emulators Configuration from the loaded gameobjects, not from ArcadeManager's static property. Only useful if we support making changes in the editor!
        public void SaveEmulators()
        {
            List <EmulatorProperties> emulatorsList = GetListOfEmulatorProperties();

            if (emulatorsList == null)
            {
                return;
            }
            List <EmulatorConfiguration> tempEmulatorsConfigurationList = new List <EmulatorConfiguration>();

            foreach (EmulatorProperties emulatorProperties in emulatorsList)
            {
                EmulatorConfiguration cfg = GetEmulatorConfiguration(emulatorProperties.id);
                if (cfg == null)
                {
                    cfg = new EmulatorConfiguration();
                }
                cfg.emulator = emulatorProperties;
                tempEmulatorsConfigurationList.Add(cfg);
            }
            ArcadeManager.emulatorsConfigurationList = tempEmulatorsConfigurationList;
            SaveEmulatorsConfigurationList();

            List <EmulatorProperties> GetListOfEmulatorProperties()
            {
                GameObject objParent           = GameObject.Find("Emulators"); // TODO: Ugly fix this!
                List <EmulatorProperties> list = new List <EmulatorProperties>();

                if (objParent == null)
                {
                    Debug.Log("no items found");
                    return(null);
                }
                var obj = objParent.GetComponents <EmulatorSetup>();

                foreach (EmulatorSetup item in obj)
                {
                    EmulatorProperties emulator = item.GetEmulatorSetup();
                    list.Add(emulator);
                }
                return(list);
            }
        }
Esempio n. 11
0
        public void Set(string descriptiveName, bool updateEmulatorsConfigurationList = true)
        {
            if (updateEmulatorsConfigurationList)
            {
                // Emulators
                ArcadeManager.emulatorsConfigurationList.Clear();
                if (ArcadeManager.emulatorsConfigurationList.Count < 1)
                {
                    if (!(ArcadeManager.loadSaveEmulatorConfiguration.LoadEmulatorsConfigurationList()))
                    {
                        print("Warning no emulator configuration list found when setting up EmulatorsConfigurationModelProperties");
                        return;
                    }
                }
            }

            selectedName = descriptiveName;
            if (ArcadeManager.emulatorsConfigurationList.Count > 0)
            {
                emulators.options.Clear();
                foreach (EmulatorConfiguration item in ArcadeManager.emulatorsConfigurationList)
                {
                    emulators.options.Add(new Dropdown.OptionData(item.emulator.descriptiveName));
                    if (item.emulator.id == "mame" && selectedName == "")
                    {
                        selectedName = item.emulator.descriptiveName;
                    }
                }
                emulators.value = emulators.options.FindIndex(option => option.text == selectedName);
                emulators.RefreshShownValue();
                emulatorsIndex        = emulators.value;
                emulatorConfiguration = ArcadeManager.emulatorsConfigurationList[emulators.value];
                emulators.onValueChanged.AddListener(delegate { DropdownValueChangedHandler(emulators); });

                if (emulatorConfiguration != null)
                {
                    SetupList();
                }
            }
        }
Esempio n. 12
0
        public override void OnInspectorGUI()
        {
            GUILayout.Space(8f);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("EMULATOR PROPERTIES", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(8f);

            DrawDefaultInspector();

            GUILayout.Space(8f);
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Delete Emulator Configuration", GUILayout.Width(200), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
            {
                DestroyImmediate(EmulatorSetupScript);
                ArcadeManager.loadSaveEmulatorConfiguration.SaveEmulators();
                ArcadeManager.loadSaveEmulatorConfiguration.LoadEmulators();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(8f);
            EditorGUILayout.BeginHorizontal();
            GUIStyle guiStyle = new GUIStyle();

            guiStyle.wordWrap = true;
            GUILayout.Label("Load, Save and Add Emulator Configurations from the 3DArcade Menu.", guiStyle);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(16f);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("MASTER GAMELIST", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(8f);
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Select", GUILayout.Width(80), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
            {
                EditorEmulatorSetupSelectMasterGamelist.ShowWindow(EmulatorSetupScript);
            }
            if (GUILayout.Button("Update", GUILayout.Width(80), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
            {
                EmulatorConfiguration emulatorConfiguration = ArcadeManager.loadSaveEmulatorConfiguration.GetEmulatorConfiguration(EmulatorSetupScript.id);
                if (emulatorConfiguration != null)
                {
                    emulatorConfiguration = UpdateMasterGamelists.UpdateMasterGamelistFromEmulatorConfiguration(emulatorConfiguration);
                    ArcadeManager.loadSaveEmulatorConfiguration.SaveEmulatorConfiguration(emulatorConfiguration);
                }
            }
            if (GUILayout.Button("Show", GUILayout.Width(80), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
            {
                EmulatorConfiguration emulatorConfiguration = ArcadeManager.loadSaveEmulatorConfiguration.GetEmulatorConfiguration(EmulatorSetupScript.id);
                if (emulatorConfiguration != null)
                {
                    List <ModelProperties> gamelist = emulatorConfiguration.masterGamelist;
                    EditorModelSetupGame.ShowWindow(EmulatorSetupScript.transform.gameObject, gamelist);
                }
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 13
0
        public static EmulatorConfiguration UpdateMasterGamelistFromEmulatorConfiguration(EmulatorConfiguration emulatorConfiguration, UnityEngine.UI.Slider slider = null)
        {
            List<ModelProperties> masterGamelist;
            Debug.Log("Updating emulator configuration " + emulatorConfiguration.emulator.descriptiveName + " with id " + emulatorConfiguration.emulator.id);
            // Mame xml?
            string fileName = emulatorConfiguration.emulator.id + ".xml";
            string filePath = ArcadeManager.applicationPath + "/3darcade~/Configuration/MasterGamelists/mame/";
            if (FileManager.FileExists(filePath, fileName) != null)
            {
                var md5 = FileManager.FileMD5Changed(emulatorConfiguration.md5MasterGamelist, filePath, fileName);
                if (md5 != null)
                {
                    masterGamelist = GetGamelistFromMameXML(filePath, fileName, emulatorConfiguration.emulator, slider);
                    if (masterGamelist != null)
                    {
                        emulatorConfiguration.lastMasterGamelistUpdate = DateTime.Now.ToString();
                        emulatorConfiguration.masterGamelist = masterGamelist;
                        emulatorConfiguration.md5MasterGamelist = md5;
                        Debug.Log("MasterGamelist updated from mame xml");
                    }
                    else
                    {
                        Debug.Log("MasterGamelist update failed from mame xml");
                    }
                }
                else
                {
                    Debug.Log("MasterGamelist is current, updated from mame xml is not needed");
                }
                return emulatorConfiguration;
            }

            // Hyperspin xml?
            fileName = emulatorConfiguration.emulator.id + ".xml";
            filePath = ArcadeManager.applicationPath + "/3darcade~/Configuration/MasterGamelists/hyperspin/";
            if (FileManager.FileExists(filePath, fileName) != null)
            {
                var md5 = FileManager.FileMD5Changed(emulatorConfiguration.md5MasterGamelist, filePath, fileName);
                if (md5 != null)
                {
                    masterGamelist = GetGamelistFromHyperspinXML(filePath, fileName, emulatorConfiguration.emulator, slider);
                    if (masterGamelist != null)
                    {
                        emulatorConfiguration.lastMasterGamelistUpdate = DateTime.Now.ToString();
                        emulatorConfiguration.masterGamelist = masterGamelist;
                        emulatorConfiguration.md5MasterGamelist = md5;
                        Debug.Log("MasterGamelist updated from atf");
                    }
                    else
                    {
                        Debug.Log("MasterGamelist update failed from hyperpsin xml");
                    }
                }
                else
                {
                    Debug.Log("MasterGamelist is current, updated from hyperspin xml is not needed");
                }
                return emulatorConfiguration;
            }

            // 3darcade atf?
            fileName = emulatorConfiguration.emulator.id + ".atf";
            filePath = ArcadeManager.applicationPath + "/3darcade~/Configuration/MasterGamelists/atf/";
            if (FileManager.FileExists(filePath, fileName) != null)
            {
                var md5 = FileManager.FileMD5Changed(emulatorConfiguration.md5MasterGamelist, filePath, fileName);
                if (md5 != null)
                {
                    masterGamelist = GetGamelistFrom3DArcadeATF(filePath, fileName, emulatorConfiguration.emulator, slider);
                    if (masterGamelist != null)
                    {
                        emulatorConfiguration.lastMasterGamelistUpdate = DateTime.Now.ToString();
                        emulatorConfiguration.masterGamelist = masterGamelist;
                        emulatorConfiguration.md5MasterGamelist = md5;
                        Debug.Log("MasterGamelist updated from 3darcade atf");
                    }
                    else
                    {
                        Debug.Log("MasterGamelist update failed from 3darcade atf");
                    }
                }
                else
                {
                    Debug.Log("MasterGamelist is current, updated from 3darcade atf is not needed");
                }
                return emulatorConfiguration;
            }

            // from folder?
            string gamePath = emulatorConfiguration.emulator.gamePath.Trim();
            filePath = ArcadeManager.applicationPath + gamePath;
           
          
            // if (FileManager.DirectoryExists(filePath) != null)
            //  {
            masterGamelist = GetGamelistFromGamePath(filePath, emulatorConfiguration.emulator, slider);
                if (masterGamelist != null)
                {
                    emulatorConfiguration.lastMasterGamelistUpdate = DateTime.Now.ToString();
                    emulatorConfiguration.masterGamelist = masterGamelist;
                    emulatorConfiguration.md5MasterGamelist = "";
                    Debug.Log("MasterGamelist updated from game path");
                    return emulatorConfiguration;
                }
                else
                {
                    Debug.Log("MasterGamelist update failed from game path");
                }
          //  }
            Debug.Log("MasterGamelist not found");
            return emulatorConfiguration;
        }