Exemplo n.º 1
0
#pragma warning restore 649

        public override void PreInit()
        {
            IoCManager.InjectDependencies(this);

            // Default to en-US.
            _localizationManager.LoadCulture(new CultureInfo(Culture));
        }
Exemplo n.º 2
0
        public override void PreInit()
        {
            IoCManager.InjectDependencies(this);

            var textMacroFactory = IoCManager.Resolve <ITextMacroFactory>();

            textMacroFactory.DoAutoRegistrations();

            // Default to en-US.
            _localizationManager.LoadCulture(new CultureInfo(Culture));
        }
Exemplo n.º 3
0
        public void Startup(InitialWindowParameters windowParameters)
        {
            _logManager.RootSawmill.AddHandler(new ConsoleLogHandler());

            _taskManager.Initialize();

            _signalHandler.MaybeStart();

            _taskManager.Initialize();

            // TODO: Init user data maybe?
            _resourceCache.Initialize(null);

#if FULL_RELEASE
            _resourceCache.MountContentDirectory(@"Resources/");
#else
            _resourceCache.MountContentDirectory($@"../../RobustToolbox/Resources");
            _resourceCache.MountContentDirectory($@"../../Resources");
#endif

            _localizationManager.LoadCulture(CultureInfo.CurrentCulture);

            if (windowParameters?.Size != null)
            {
                var(w, h) = windowParameters.Size.Value;
                _configurationManager.SetCVar("display.width", w);
                _configurationManager.SetCVar("display.height", h);
            }

            _clyde.Initialize(true);
            if (windowParameters?.WindowTitle != null)
            {
                _clyde.SetWindowTitle(_localizationManager.GetString(windowParameters.WindowTitle));
            }

            _fontManager.Initialize();
            _clipboardManager.Initialize();

            _eyeManager.Initialize();

            _userInterfaceManager.Initialize();

            _inputManager.Initialize();

            _inputManager.AddClickBind();

            _clyde.Ready();
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        public bool Start()
        {
            // Sets up the configMgr
            // If a config file path was passed, use it literally.
            // This ensures it's working-directory relative
            // (for people passing config file through the terminal or something).
            // Otherwise use the one next to the executable.
            if (_commandLineArgs?.ConfigFile != null)
            {
                _config.LoadFromFile(_commandLineArgs.ConfigFile);
            }
            else
            {
                var path = PathHelpers.ExecutableRelativeFile("server_config.toml");
                if (File.Exists(path))
                {
                    _config.LoadFromFile(path);
                }
                else
                {
                    _config.SetSaveFile(path);
                }
            }

            if (_commandLineArgs != null)
            {
                _config.OverrideConVars(_commandLineArgs.CVars);
            }


            //Sets up Logging
            _config.RegisterCVar("log.path", "logs", CVar.ARCHIVE);
            _config.RegisterCVar("log.format", "log_%(date)s-%(time)s.txt", CVar.ARCHIVE);
            _config.RegisterCVar("log.level", LogLevel.Info, CVar.ARCHIVE);

            var logPath     = _config.GetCVar <string>("log.path");
            var logFormat   = _config.GetCVar <string>("log.format");
            var logFilename = logFormat.Replace("%(date)s", DateTime.Now.ToString("yyyyMMdd"))
                              .Replace("%(time)s", DateTime.Now.ToString("hhmmss"));
            var fullPath = Path.Combine(logPath, logFilename);

            if (!Path.IsPathRooted(fullPath))
            {
                logPath = PathHelpers.ExecutableRelativeFile(fullPath);
            }

            fileLogHandler         = new FileLogHandler(logPath);
            _log.RootSawmill.Level = _config.GetCVar <LogLevel>("log.level");
            _log.RootSawmill.AddHandler(fileLogHandler);

            // Has to be done early because this guy's in charge of the main thread Synchronization Context.
            _taskManager.Initialize();

            LoadSettings();

            var netMan = IoCManager.Resolve <IServerNetManager>();

            try
            {
                netMan.Initialize(true);
                netMan.StartServer();
            }
            catch (Exception e)
            {
                var port = netMan.Port;
                Logger.Fatal(
                    "Unable to setup networking manager. Check port {0} is not already in use and that all binding addresses are correct!\n{1}",
                    port, e);
                return(true);
            }

            var dataDir = _commandLineArgs?.DataDir ?? PathHelpers.ExecutableRelativeFile("data");

            // Set up the VFS
            _resources.Initialize(dataDir);

#if FULL_RELEASE
            _resources.MountContentDirectory(@"./Resources/");
#else
            // Load from the resources dir in the repo root instead.
            // It's a debug build so this is fine.
            var contentRootDir = ProgramShared.FindContentRootDir();
            _resources.MountContentDirectory($@"{contentRootDir}RobustToolbox/Resources/");
            _resources.MountContentDirectory($@"{contentRootDir}bin/Content.Server/", new ResourcePath("/Assemblies/"));
            _resources.MountContentDirectory($@"{contentRootDir}Resources/");
#endif

            // Default to en-US.
            // Perhaps in the future we could make a command line arg or something to change this default.
            _localizationManager.LoadCulture(new CultureInfo("en-US"));

            //identical code in game controller for client
            if (!_modLoader.TryLoadAssembly <GameShared>(_resources, $"Content.Shared"))
            {
                Logger.FatalS("eng", "Could not load any Shared DLL.");
                return(true);
            }

            if (!_modLoader.TryLoadAssembly <GameServer>(_resources, $"Content.Server"))
            {
                Logger.FatalS("eng", "Could not load any Server DLL.");
                return(true);
            }

            // HAS to happen after content gets loaded.
            // Else the content types won't be included.
            // TODO: solve this properly.
            _serializer.Initialize();

            // Initialize Tier 2 services
            IoCManager.Resolve <IGameTiming>().InSimulation = true;

            _stateManager.Initialize();
            _entities.Initialize();
            IoCManager.Resolve <IPlayerManager>().Initialize(MaxPlayers);
            _mapManager.Initialize();
            _mapManager.Startup();
            IoCManager.Resolve <IPlacementManager>().Initialize();
            IoCManager.Resolve <IViewVariablesHost>().Initialize();
            IoCManager.Resolve <IDebugDrawingManager>().Initialize();

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            // because of 'reasons' this has to be called after the last assembly is loaded
            // otherwise the prototypes will be cleared
            var prototypeManager = IoCManager.Resolve <IPrototypeManager>();
            prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes"));
            prototypeManager.Resync();

            IoCManager.Resolve <IConsoleShell>().Initialize();
            IoCManager.Resolve <IConGroupController>().Initialize();
            _entities.Startup();

            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            IoCManager.Resolve <IStatusHost>().Start();

            AppDomain.CurrentDomain.ProcessExit += ProcessExiting;

            return(false);
        }
Exemplo n.º 5
0
        public bool Startup()
        {
            SetupLogging(_logManager);

            _taskManager.Initialize();

            // Figure out user data directory.
            var userDataDir = GetUserDataDir();

            if (LoadConfigAndUserData)
            {
                var configFile = Path.Combine(userDataDir, "client_config.toml");
                if (File.Exists(configFile))
                {
                    // Load config from user data if available.
                    _configurationManager.LoadFromFile(configFile);
                }
                else
                {
                    // Else we just use code-defined defaults and let it save to file when the user changes things.
                    _configurationManager.SetSaveFile(configFile);
                }
            }

            if (_commandLineArgs != null)
            {
                _configurationManager.OverrideConVars(_commandLineArgs.CVars);
            }

            _signalHandler.MaybeStart();

            _resourceCache.Initialize(LoadConfigAndUserData ? userDataDir : null);

#if FULL_RELEASE
            _resourceCache.MountContentDirectory(@"Resources/");
#else
            var contentRootDir = ProgramShared.FindContentRootDir();
            _resourceCache.MountContentDirectory($@"{contentRootDir}RobustToolbox/Resources/");
            _resourceCache.MountContentDirectory($@"{contentRootDir}bin/Content.Client/",
                                                 new ResourcePath("/Assemblies/"));
            _resourceCache.MountContentDirectory($@"{contentRootDir}Resources/");
#endif

            // Default to en-US.
            // Perhaps in the future we could make a command line arg or something to change this default.
            _localizationManager.LoadCulture(new CultureInfo("en-US"));

            // Bring display up as soon as resources are mounted.
            if (!_clyde.Initialize())
            {
                return(false);
            }

            _clyde.SetWindowTitle("Space Station 14");

            _fontManager.Initialize();

            //identical code for server in baseserver
            if (!_modLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared"))
            {
                Logger.FatalS("eng", "Could not load any Shared DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            if (!_modLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client"))
            {
                Logger.FatalS("eng", "Could not load any Client DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            _eyeManager.Initialize();
            _serializer.Initialize();
            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            _inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _mapManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _placementManager.Initialize();
            _viewVariablesManager.Initialize();
            _conGroupController.Initialize();

            _client.Initialize();
            _discord.Initialize();
            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            if (_commandLineArgs?.Launcher == true)
            {
                _stateManager.RequestStateChange <LauncherConnecting>();
            }
            else
            {
                _stateManager.RequestStateChange <MainScreen>();
            }

            if (_commandLineArgs?.Username != null)
            {
                _client.PlayerNameOverride = _commandLineArgs.Username;
            }

            _clyde.Ready();

            if (_commandLineArgs?.Connect == true || _commandLineArgs?.Launcher == true)
            {
                var addr = _commandLineArgs.ConnectAddress;
                if (!addr.Contains("://"))
                {
                    addr = "udp://" + addr;
                }

                var uri = new Uri(addr);

                if (uri.Scheme != "udp")
                {
                    Logger.Warning($"connect-address '{uri}' does not have URI scheme of udp://..");
                }

                _client.ConnectToServer(uri.Host, (ushort)(uri.IsDefaultPort ? 1212 : uri.Port));
            }

            _checkOpenGLVersion();
            return(true);
        }
Exemplo n.º 6
0
        public void Startup()
        {
            SetupLogging(_logManager);

            var args = GetCommandLineArgs();

            // Set up custom synchronization context.
            // Sorry Godot.
            _taskManager.Initialize();

            // Figure out user data directory.
            var userDataDir = _getUserDataDir(args);

            if (LoadConfigAndUserData)
            {
                var configFile = Path.Combine(userDataDir, "client_config.toml");
                if (File.Exists(configFile))
                {
                    // Load config from user data if available.
                    _configurationManager.LoadFromFile(configFile);
                }
                else
                {
                    // Else we just use code-defined defaults and let it save to file when the user changes things.
                    _configurationManager.SetSaveFile(configFile);
                }
            }

            _signalHandler.MaybeStart();

            _resourceCache.Initialize(LoadConfigAndUserData ? userDataDir : null);

#if FULL_RELEASE
            _resourceCache.MountContentDirectory(@"Resources/");
#else
            _resourceCache.MountContentDirectory($@"{ContentRootDir}RobustToolbox/Resources/");
            _resourceCache.MountContentDirectory($@"{ContentRootDir}bin/Content.Client/", new ResourcePath("/Assemblies/"));
            _resourceCache.MountContentDirectory($@"{ContentRootDir}Resources/");
#endif

            // Default to en-US.
            // Perhaps in the future we could make a command line arg or something to change this default.
            _localizationManager.LoadCulture(new CultureInfo("en-US"));

            // Bring display up as soon as resources are mounted.
            _displayManager.Initialize();
            _displayManager.SetWindowTitle("Space Station 14");

            _fontManager.Initialize();

            //identical code for server in baseserver
            if (!_modLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared"))
            {
                Logger.FatalS("eng", "Could not load any Shared DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            if (!_modLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client"))
            {
                Logger.FatalS("eng", "Could not load any Client DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            _eyeManager.Initialize();
            _serializer.Initialize();
            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            _inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _mapManager.Initialize();
            _lightManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _placementManager.Initialize();
            _viewVariablesManager.Initialize();

            _client.Initialize();
            _discord.Initialize();
            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            _stateManager.RequestStateChange <MainScreen>();

            _clyde?.Ready();

            if (args.Contains("--connect"))
            {
                _client.ConnectToServer("127.0.0.1", 1212);
            }
        }
Exemplo n.º 7
0
        /// <inheritdoc />
        public bool Start()
        {
            //Sets up the configMgr
            _config.LoadFromFile(_commandLine.ConfigFile);

            //Sets up Logging
            _config.RegisterCVar("log.path", "logs", CVar.ARCHIVE);
            _config.RegisterCVar("log.format", "log_%(date)s-%(time)s.txt", CVar.ARCHIVE);
            _config.RegisterCVar("log.level", LogLevel.Info, CVar.ARCHIVE);

            var logPath     = _config.GetCVar <string>("log.path");
            var logFormat   = _config.GetCVar <string>("log.format");
            var logFilename = logFormat.Replace("%(date)s", DateTime.Now.ToString("yyyyMMdd")).Replace("%(time)s", DateTime.Now.ToString("hhmmss"));
            var fullPath    = Path.Combine(logPath, logFilename);

            if (!Path.IsPathRooted(fullPath))
            {
                logPath = PathHelpers.ExecutableRelativeFile(fullPath);
            }

            fileLogHandler         = new FileLogHandler(logPath);
            _log.RootSawmill.Level = _config.GetCVar <LogLevel>("log.level");
            _log.RootSawmill.AddHandler(fileLogHandler);

            // Has to be done early because this guy's in charge of the main thread Synchronization Context.
            _taskManager.Initialize();

            LoadSettings();

            var netMan = IoCManager.Resolve <IServerNetManager>();

            try
            {
                netMan.Initialize(true);
                netMan.StartServer();
            }
            catch (Exception e)
            {
                var port = netMan.Port;
                Logger.Fatal("Unable to setup networking manager. Check port {0} is not already in use and that all binding addresses are correct!\n{1}", port, e);
                return(true);
            }

            var exeDir = Assembly.GetExecutingAssembly().Location;

            if (string.IsNullOrEmpty(exeDir))
            {
                throw new Exception("Unable to locate client exe");
            }

            exeDir = Path.GetDirectoryName(exeDir);
            var dataDir = _commandLine.DataDir;

            // Set up the VFS
            _resources.Initialize(dataDir);

#if FULL_RELEASE
            _resources.MountContentDirectory(@"./Resources/");
#else
            // Load from the resources dir in the repo root instead.
            // It's a debug build so this is fine.
            _resources.MountContentDirectory($@"{ContentRootDir}RobustToolbox/Resources/");
            _resources.MountContentDirectory($@"{ContentRootDir}bin/Content.Server/", new ResourcePath("/Assemblies/"));
            _resources.MountContentDirectory($@"{ContentRootDir}Resources/");
#endif

            // Default to en-US.
            // Perhaps in the future we could make a command line arg or something to change this default.
            _localizationManager.LoadCulture(new CultureInfo("en-US"));


            //mount the engine content pack
            // _resources.MountContentPack(@"EngineContentPack.zip");

            //mount the default game ContentPack defined in config
            // _resources.MountDefaultContentPack();

            //identical code in game controller for client
            if (!_modLoader.TryLoadAssembly <GameShared>(_resources, $"Content.Shared"))
            {
                Logger.FatalS("eng", "Could not load any Shared DLL.");
                return(true);
            }

            if (!_modLoader.TryLoadAssembly <GameServer>(_resources, $"Content.Server"))
            {
                Logger.FatalS("eng", "Could not load any Server DLL.");
                return(true);
            }

            // HAS to happen after content gets loaded.
            // Else the content types won't be included.
            // TODO: solve this properly.
            _serializer.Initialize();

            // Initialize Tier 2 services
            _stateManager.Initialize();
            _entities.Initialize();
            IoCManager.Resolve <IPlayerManager>().Initialize(MaxPlayers);
            _mapManager.Initialize();
            IoCManager.Resolve <IPlacementManager>().Initialize();
            IoCManager.Resolve <IViewVariablesHost>().Initialize();

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            // because of 'reasons' this has to be called after the last assembly is loaded
            // otherwise the prototypes will be cleared
            var prototypeManager = IoCManager.Resolve <IPrototypeManager>();
            prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes"));
            prototypeManager.Resync();

            IoCManager.Resolve <IConsoleShell>().Initialize();
            IoCManager.Resolve <IConGroupController>().Initialize();
            _entities.Startup();

            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            IoCManager.Resolve <IStatusHost>().Start();

            return(false);
        }
Exemplo n.º 8
0
        public bool Startup()
        {
            ReadInitialLaunchState();

            SetupLogging(_logManager);

            _taskManager.Initialize();

            // Figure out user data directory.
            var userDataDir = GetUserDataDir();

            if (LoadConfigAndUserData)
            {
                var configFile = Path.Combine(userDataDir, "client_config.toml");
                if (File.Exists(configFile))
                {
                    // Load config from user data if available.
                    _configurationManager.LoadFromFile(configFile);
                }
                else
                {
                    // Else we just use code-defined defaults and let it save to file when the user changes things.
                    _configurationManager.SetSaveFile(configFile);
                }
            }

            if (_commandLineArgs != null)
            {
                _configurationManager.OverrideConVars(_commandLineArgs.CVars);
            }

            _signalHandler.MaybeStart();

            _resourceCache.Initialize(LoadConfigAndUserData ? userDataDir : null);

#if FULL_RELEASE
            _resourceCache.MountContentDirectory(@"Resources/");
#else
            var contentRootDir = ProgramShared.FindContentRootDir();
            _resourceCache.MountContentDirectory($@"{contentRootDir}RobustToolbox/Resources/");
            _resourceCache.MountContentDirectory($@"{contentRootDir}bin/Content.Client/",
                                                 new ResourcePath("/Assemblies/"));
            _resourceCache.MountContentDirectory($@"{contentRootDir}Resources/");
#endif

            // Default to en-US.
            // Perhaps in the future we could make a command line arg or something to change this default.
            _localizationManager.LoadCulture(new CultureInfo("en-US"));

            // Bring display up as soon as resources are mounted.
            if (!_clyde.Initialize())
            {
                return(false);
            }

            _clyde.SetWindowTitle("Space Station 14");

            _fontManager.Initialize();

            // Disable load context usage on content start.
            // This prevents Content.Client being loaded twice and things like csi blowing up because of it.
            _modLoader.SetUseLoadContext(!_disableAssemblyLoadContext);

            //identical code for server in baseserver
            if (!_modLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared"))
            {
                Logger.FatalS("eng", "Could not load any Shared DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            if (!_modLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client"))
            {
                Logger.FatalS("eng", "Could not load any Client DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            _serializer.Initialize();
            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            _inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _mapManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _placementManager.Initialize();
            _viewVariablesManager.Initialize();
            _conGroupController.Initialize();
            _scriptClient.Initialize();

            _client.Initialize();
            _discord.Initialize();
            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            if (_commandLineArgs?.Username != null)
            {
                _client.PlayerNameOverride = _commandLineArgs.Username;
            }

            _clyde.Ready();

            if (_commandLineArgs?.Connect == true || _commandLineArgs?.Launcher == true)
            {
                _client.ConnectToServer(LaunchState.ConnectEndpoint);
            }

            _checkOpenGLVersion();
            return(true);
        }