static void Main(string[] args) { log.Info("Starting editor..."); ThreadAsserts.IsMainThread(); #if DEBUG WinFormExceptionHelper.AddUnhandledExceptionHooks(); #endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Check for a valid path to the development content if (ContentPaths.Dev == null) { const string errmsg = @"Could not find the path to the development content (ContentPaths.Dev). The file containing this path should be located at: \Content\Data\devpath.txt The path to the development content is required by the editor. See the file mentioned above for details."; MessageBox.Show(errmsg, "Error finding content path", MessageBoxButtons.OK); return; } // Ensure the content is copied over if (!ContentPaths.TryCopyContent(userArgs: CommonConfig.TryCopyContentArgs)) { const string errmsg = "Failed to copy the content from the dev to build path." + " Content in the build path will likely not update to reflect changes made in the content in the dev path."; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg); } Debug.Fail(errmsg); } // Initialize stuff EngineSettingsInitializer.Initialize(); try { GlobalState.Initialize(); // Get the command-line switches var switches = CommandLineSwitchHelper.GetCommandsUsingEnum <CommandLineSwitch>(args).ToArray(); var showEditor = !HandleSwitches(switches); if (showEditor) { // Start up the application Application.Run(new MainForm()); } } finally { GlobalState.Destroy(); } }
/// <summary> /// Initializes a new instance of the <see cref="DemoGame"/> class. /// </summary> public DemoGame() : base( new Point((int)GameData.ScreenSize.X, (int)GameData.ScreenSize.Y), new Point((int)GameData.ScreenSize.X, (int)GameData.ScreenSize.Y), "NetGore") { EngineSettingsInitializer.Initialize(); // Create the screen manager var skinManager = new SkinManager("Default"); _screenManager = new ScreenManager(this, skinManager, "Font/Arial", 24); // Initialize the socket manager ClientSockets.Initialize(ScreenManager); _sockets = ClientSockets.Instance; // Read the GrhInfo LoadGrhInfo(); var lightGD = GrhInfo.GetData("Effect", "light"); _screenManager.DrawingManager.LightManager.DefaultSprite = new Grh(lightGD); // Set up our custom chat bubbles ChatBubble.CreateChatBubbleInstance = CreateChatBubbleInstanceHandler; // Create the screens new OptionsScreen(ScreenManager); new GameplayScreen(ScreenManager); new MainMenuScreen(ScreenManager); new LoginScreen(ScreenManager); new CharacterSelectionScreen(ScreenManager); new CreateCharacterScreen(ScreenManager); new NewAccountScreen(ScreenManager); ScreenManager.ConsoleScreen = new ConsoleScreen(ScreenManager); ScreenManager.SetScreen <MainMenuScreen>(); ShowMouseCursor = true; KeyPressed -= DemoGame_KeyPressed; KeyPressed += DemoGame_KeyPressed; var clientSettings = ClientSettings.Default; // Apply some of the initial settings ScreenManager.AudioManager.SoundManager.Volume = clientSettings.Audio_SoundVolume; ScreenManager.AudioManager.MusicManager.Volume = clientSettings.Audio_MusicVolume; UseVerticalSync = clientSettings.Graphics_VSync; IsFullscreen = clientSettings.Graphics_Fullscreen; // Listen for changes to the settings clientSettings.PropertyChanged -= Default_PropertyChanged; clientSettings.PropertyChanged += Default_PropertyChanged; }
/// <summary> /// Initializes a new instance of the <see cref="Server"/> class. /// </summary> /// <exception cref="NotSupportedException">NetGore does not support systems that are not in Little Endian mode!</exception> public Server() { ThreadAsserts.IsMainThread(); // Check for some system settings if (!BitConverter.IsLittleEndian) { const string errmsg = "NetGore does not support systems that are not in Little Endian mode!"; log.Fatal(errmsg); throw new NotSupportedException(errmsg); } // Check if patching is needed int numMissingPatches = -1; try { numMissingPatches = ServerDbPatcher.GetMissingPatches().Length; } catch (Exception ex) { log.WarnFormat("Failed to find DbPatches directory, so could not check if patching is required. Exception: {0}", ex); } if (numMissingPatches > 0) { log.ErrorFormat("There are `{0}` NetGore db patches not applied. Please backup your database then run /DemoGame.Server/DbPatches/Patch.bat.", numMissingPatches); log.ErrorFormat("Server will auto-close after 10 seconds, and will keep doing this until you patch."); Thread.Sleep(10 * 1000); return; } // Initialize the engine settings EngineSettingsInitializer.Initialize(); // Create the DbController _dbController = CreateDbController(); // Add the query stats tracker var queryStats = new BasicQueryStatsTracker { LogFilePath = ContentPaths.Build.Root.Join("querystats.txt") }; queryStats.LogFileFrequency = 1000 * 5; _dbController.ConnectionPool.QueryStats = queryStats; // Validate the database DbTableValidator.ValidateTables(_dbController); ValidateDbControllerQueryAttributes(); // Clean-up var cleaner = new ServerCleaner(this); cleaner.Run(); // Create some objects _consoleCommands = new ConsoleCommands(this); _groupManager = new GroupManager((gm, x) => new Group(x)); _userAccountManager = new UserAccountManager(DbController); _world = new World(this); _sockets = new ServerSockets(this); WorldStatsTracker.Instance.NetPeerToTrack = _sockets.GetNetServer(); // Check for the password salt if (string.IsNullOrEmpty(ServerSettings.Default.PasswordSalt)) { const string errmsg = "No password salt has been defined in the server settings file. Make sure you define one before releasing."; if (log.IsWarnEnabled) { log.WarnFormat(errmsg); } } // Set the thread priority SetThreadPriority(ServerSettings.Default.ThreadPriority); // Validate the server's settings var ssv = new ServerSettingsValidator(); ssv.Check(this); if (log.IsInfoEnabled) { log.Info("Server loaded."); } }
/// <summary> /// Initializes a new instance of the <see cref="Server"/> class. /// </summary> /// <exception cref="NotSupportedException">NetGore does not support systems that are not in Little Endian mode!</exception> public Server() { // Check for some system settings if (!BitConverter.IsLittleEndian) { const string errmsg = "NetGore does not support systems that are not in Little Endian mode!"; log.Fatal(errmsg); throw new NotSupportedException(errmsg); } // Initialize the engine settings EngineSettingsInitializer.Initialize(); // Create the DbController var settings = new DbConnectionSettings(); _dbController = settings.CreateDbControllerPromptEditWhenInvalid(x => new ServerDbController(x.GetMySqlConnectionString()), x => PromptEditDbSettingsFile(settings, x)); if (_dbController == null) { return; } // Add the query stats tracker var queryStats = new BasicQueryStatsTracker { LogFilePath = ContentPaths.Build.Root.Join("querystats.txt") }; queryStats.LogFileFrequency = 1000 * 5; _dbController.ConnectionPool.QueryStats = queryStats; // Validate the database DbTableValidator.ValidateTables(_dbController); ValidateDbControllerQueryAttributes(); // Clean-up var cleaner = new ServerCleaner(this); cleaner.Run(); // Load the game data and such InitializeScripts(); // Create some objects _consoleCommands = new ConsoleCommands(this); _groupManager = new GroupManager((gm, x) => new Group(x)); _userAccountManager = new UserAccountManager(DbController); _world = new World(this); _sockets = new ServerSockets(this); WorldStatsTracker.Instance.NetPeerToTrack = _sockets.GetNetServer(); // Check for the password salt if (string.IsNullOrEmpty(ServerSettings.Default.PasswordSalt)) { const string errmsg = "No password salt has been defined in the server settings file. Make sure you define one before releasing."; if (log.IsWarnEnabled) { log.WarnFormat(errmsg); } } // Set the thread priority SetThreadPriority(ServerSettings.Default.ThreadPriority); // Validate the server's settings var ssv = new ServerSettingsValidator(); ssv.Check(this); if (log.IsInfoEnabled) { log.Info("Server loaded."); } }