Ejemplo n.º 1
0
        /// <summary>Generates a PluginSettings.Data instance with runtime defaults.</summary>
        public static PluginSettings.Data GenerateDefaultData()
        {
            PluginSettings.Data data = new PluginSettings.Data()
            {
                apiURL         = APIClient.API_URL_PRODUCTIONSERVER + APIClient.API_VERSION,
                gameId         = GameProfile.NULL_ID,
                gameAPIKey     = string.Empty,
                requestLogging = new RequestLoggingOptions()
                {
                    errorsAsWarnings = true,
                    logAllResponses  = false,
                    logOnSend        = false,
                },

                installationDirectory = IOUtilities.CombinePath("$DATA_PATH$", "mod.io", "mods"),
                cacheDirectory        = IOUtilities.CombinePath("$DATA_PATH$", "mod.io", "cache"),
                userDirectory         = IOUtilities.CombinePath("$PERSISTENT_DATA_PATH$", "mod.io-$GAME_ID$"),

                installationDirectoryEditor = IOUtilities.CombinePath("$CURRENT_DIRECTORY$", "mod.io", "editor", "$GAME_ID$", "mods"),
                cacheDirectoryEditor        = IOUtilities.CombinePath("$CURRENT_DIRECTORY$", "mod.io", "editor", "$GAME_ID$", "cache"),
                userDirectoryEditor         = IOUtilities.CombinePath("$CURRENT_DIRECTORY$", "mod.io", "editor", "$GAME_ID$", "user"),
            };

            return(data);
        }
Ejemplo n.º 2
0
        public static void FocusAsset()
        {
            PluginSettings settings = Resources.Load <PluginSettings>(PluginSettings.FILE_PATH);

            if (settings == null)
            {
                PluginSettings.Data defaultData = PluginSettings.GenerateDefaultData();
                settings = PluginSettings.SetRuntimeData(defaultData);
            }

            UnityEditor.EditorGUIUtility.PingObject(settings);
            UnityEditor.Selection.activeObject = settings;
        }
Ejemplo n.º 3
0
        /// <summary>Creates the asset instance that the plugin will use.</summary>
        private static PluginSettings InitializeAsset()
        {
            PluginSettings.Data data = new PluginSettings.Data()
            {
                apiURL                = APIClient.API_URL_PRODUCTIONSERVER + APIClient.API_VERSION,
                gameId                = 0,
                gameAPIKey            = string.Empty,
                cacheDirectory        = "$PERSISTENT_DATA_PATH$/modio-$GAME_ID$",
                installationDirectory = "$PERSISTENT_DATA_PATH$/modio-$GAME_ID$/_installedMods",
                logAllRequests        = false,
            };

            return(SetGlobalValues(data));
        }
Ejemplo n.º 4
0
        /// <summary>Sets the values of the Plugin Settings.</summary>
        public static PluginSettings SetGlobalValues(PluginSettings.Data data)
        {
            string         assetPath = "Assets/Resources/" + PluginSettings.FILE_PATH + ".asset";
            PluginSettings settings  = ScriptableObject.CreateInstance <PluginSettings>();

            if (!UnityEditor.AssetDatabase.IsValidFolder("Assets/Resources"))
            {
                UnityEditor.AssetDatabase.CreateFolder("Assets", "Resources");
            }

            settings.m_data = data;

            UnityEditor.AssetDatabase.CreateAsset(settings, assetPath);
            UnityEditor.AssetDatabase.SaveAssets();
            UnityEditor.AssetDatabase.Refresh();

            return(settings);
        }
Ejemplo n.º 5
0
        /// <summary>Sets/saves the settings for the runtime instance.</summary>
        public static PluginSettings SaveToAsset(string path,
                                                 PluginSettings.Data data)
        {
            string assetPath = IOUtilities.CombinePath("Assets", "Resources", path + ".asset");

            // creates the containing folder
            string assetFolder = Path.GetDirectoryName(assetPath);

            System.IO.Directory.CreateDirectory(assetFolder);

            // create asset
            PluginSettings settings = ScriptableObject.CreateInstance <PluginSettings>();

            settings.m_data = data;

            // save
            UnityEditor.AssetDatabase.CreateAsset(settings, assetPath);
            UnityEditor.AssetDatabase.SaveAssets();
            UnityEditor.AssetDatabase.Refresh();

            return(settings);
        }
Ejemplo n.º 6
0
 private static PluginSettings InitializeAsset()
 {
     PluginSettings.Data data = PluginSettings.GenerateDefaultData();
     return(PluginSettings.SetRuntimeData(data));
 }
Ejemplo n.º 7
0
 public static PluginSettings SetGlobalValues(PluginSettings.Data data)
 {
     return(PluginSettings.SetRuntimeData(data));
 }
Ejemplo n.º 8
0
 /// <summary>Stores the given values to the Runtime asset.</summary>
 public static PluginSettings SetRuntimeData(PluginSettings.Data data)
 {
     return(PluginSettings.SaveToAsset(PluginSettings.FILE_PATH, data));
 }
Ejemplo n.º 9
0
 // ---------[ INITIALIZATION ]---------
 /// <summary>Initializes the CacheClient settings.</summary>
 static CacheClient()
 {
     PluginSettings.Data settings = PluginSettings.data;
     CacheClient.cacheDirectory = settings.CacheDirectory;
 }