Пример #1
0
        public static void Shutdown()
        {
            ResourceUpdate.Shutdown();

            //!!!!!еще раз. тут?
            ResourceManager.Shutdown();

            VirtualFileWatcher.Shutdown();

            //!!!!!
            //PackageManager.Shutdown();
            //ResourceTypes.Shutdown();
            initialized = false;
        }
Пример #2
0
        public static bool Init(string logFileName, bool setCurrentDirectory, string projectDirectory,
                                string userSettingsDirectory, string overrideBinariesDirectory = null)
        {
            if (initialized)
            {
                Log.Fatal("VirtualFileSystem: Init: File system is already initialized.");
                return(false);
            }

            //it can be already started
            StartupTiming.TotalStart();

            StartupTiming.CounterStart("Initialize virtual file system");
            try
            {
                mainThread = Thread.CurrentThread;

                //init directories
                {
                    if (string.IsNullOrEmpty(projectDirectory))
                    {
                        Log.Fatal("VirtualFileSystem: Init: Project directory must be specified.");
                    }
                    if (!Directory.Exists(projectDirectory))
                    {
                        Log.Fatal("VirtualFileSystem: Init: Specified project directory is not exists.");
                    }
                    projectDirectory    = VirtualPathUtility.NormalizePath(projectDirectory);
                    Directories.project = projectDirectory;
                    if (!Path.IsPathRooted(Directories.project))
                    {
                        Log.Fatal("VirtualFileSystem: Init: Project directory path must be rooted.");
                        return(false);
                    }

                    Directories.assets = Path.Combine(Directories.project, "Assets");
                    if (string.IsNullOrEmpty(Directories.assets))
                    {
                        Log.Fatal("VirtualFileSystem: Init: Project Assets directory must be specified.");
                    }
                    if (!Directory.Exists(Directories.assets))
                    {
                        Log.Fatal("VirtualFileSystem: Init: Specified project Assets directory is not exists.");
                    }

                    if (string.IsNullOrEmpty(userSettingsDirectory))
                    {
                        Log.Fatal("VirtualFileSystem: Init: User settings directory must be specified.");
                    }
                    if (!Path.IsPathRooted(userSettingsDirectory))
                    {
                        Log.Fatal("VirtualFileSystem: Init: User settings directory path must be rooted.");
                        return(false);
                    }
                    //if( !Directory.Exists( userSettingsDirectory ) )
                    //	Log.Fatal( "VirtualFileSystem: Init: Specified User settijngs directory is not exists." );
                    userSettingsDirectory    = VirtualPathUtility.NormalizePath(userSettingsDirectory);
                    Directories.userSettings = userSettingsDirectory;

                    if (!string.IsNullOrEmpty(overrideBinariesDirectory) && !Directory.Exists(overrideBinariesDirectory))
                    {
                        Log.Fatal("VirtualFileSystem: Init: Specified binaries directory is not exists.");
                    }
                    if (string.IsNullOrEmpty(overrideBinariesDirectory))
                    {
                        Directories.binaries = PlatformSpecificUtility.Instance.GetExecutableDirectoryPath();
                    }
                    else
                    {
                        Directories.binaries = overrideBinariesDirectory;
                    }
                    Directories.binaries = VirtualPathUtility.NormalizePath(Directories.binaries);
                    if (!Path.IsPathRooted(Directories.binaries))
                    {
                        Log.Fatal("VirtualFileSystem: Init: Executables directory path must be rooted.");
                        return(false);
                    }

                    //// UWP works with relative paths.
                    // should Directories.engineInternal and Directories.platformSpecific be relative for UWP ?
                    //if( SystemSettings.CurrentPlatform == SystemSettings.Platform.UWP )
                    //	Directories.engineInternal = "NeoAxis.Internal";
                    //else
                    Directories.engineInternal = Path.Combine(Directories.binaries, "NeoAxis.Internal");

                    Directories.platformSpecific = Path.Combine(Directories.engineInternal, Path.Combine("Platforms", SystemSettings.CurrentPlatform.ToString()));

                    //!!!!
                    //!!!!ARM
                    if (SystemSettings.CurrentPlatform == SystemSettings.Platform.UWP)
                    {
                        Directories.platformSpecific = Path.Combine(Directories.platformSpecific, "x64");
                    }
                }

                //!!!!new
                CultureInfo.CurrentCulture = new CultureInfo("en-US");
                try
                {
                    //!!!! deprecated. use CultureInfo.CurrentCulture https://github.com/dotnet/platform-compat/blob/master/docs/DE0008.md
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
                }
                catch { }

                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
                //bool monoRuntime = Type.GetType( "Mono.Runtime", false ) != null;
                //if( monoRuntime )
                //	AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

                if (setCurrentDirectory)
                {
                    CorrectCurrentDirectory();
                }

                if (EngineApp.ApplicationType == EngineApp.ApplicationTypeEnum.Editor)
                {
                    Editor.PackageManager.DeleteFilesAsStartup();
                }

                NativeLibraryManager.PreLoadLibrary("NeoAxisCoreNative");

                InitDefaultSettingsConfig();

                ArchiveManager.Init();
                //if( !ArchiveManager.Init() )
                //{
                //	//ArchiveManager.Shutdown();
                //	return false;
                //}

                initialized = true;

                //InitDeploymentInfoAndUserDirectory();

                string realPath = null;
                if (!string.IsNullOrEmpty(logFileName))
                {
                    realPath = VirtualPathUtility.GetRealPathByVirtual(logFileName);
                }
                Log.Init(Thread.CurrentThread, realPath);

                //!!!!
                //InitFileTypesThatCanBeCached();

                ResourceManager.Init();
                //RegisterAssemblies_IncludingFromDefaultSettingConfig();
                ParseSettingsFromDefaultSettingsConfig();
                //ResourceTypes.Init();

                //!!!!тут?
                VirtualFileWatcher.Init();

                ResourceUpdate.Init();
            }
            finally
            {
                StartupTiming.CounterEnd("Initialize virtual file system");
            }

            return(true);
        }