Program.cs (4549B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // The Command & Conquer Map Editor and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // The Command & Conquer Map Editor and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 using MobiusEditor.Dialogs; 16 using MobiusEditor.Utility; 17 using System; 18 using System.Globalization; 19 using System.IO; 20 using System.Threading; 21 using System.Windows.Forms; 22 23 namespace MobiusEditor 24 { 25 static class Program 26 { 27 /// <summary> 28 /// The main entry point for the application. 29 /// </summary> 30 [STAThread] 31 static void Main() 32 { 33 // Change current culture to en-US 34 if (Thread.CurrentThread.CurrentCulture.Name != "en-US") 35 { 36 Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); 37 } 38 39 // Initialize megafiles 40 var runPath = Environment.CurrentDirectory; 41 Globals.TheMegafileManager = new MegafileManager(runPath); 42 43 var megafilesLoaded = true; 44 var megafilePath = Path.Combine(runPath, "DATA"); 45 megafilesLoaded &= Globals.TheMegafileManager.Load(Path.Combine(megafilePath, "CONFIG.MEG")); 46 megafilesLoaded &= Globals.TheMegafileManager.Load(Path.Combine(megafilePath, "TEXTURES_COMMON_SRGB.MEG")); 47 megafilesLoaded &= Globals.TheMegafileManager.Load(Path.Combine(megafilePath, "TEXTURES_RA_SRGB.MEG")); 48 megafilesLoaded &= Globals.TheMegafileManager.Load(Path.Combine(megafilePath, "TEXTURES_SRGB.MEG")); 49 megafilesLoaded &= Globals.TheMegafileManager.Load(Path.Combine(megafilePath, "TEXTURES_TD_SRGB.MEG")); 50 #if !DEVELOPER 51 if (!megafilesLoaded) 52 { 53 MessageBox.Show("Required data is missing or corrupt, please validate your installation.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 54 return; 55 } 56 #endif 57 58 // Initialize texture, tileset, team color, and game text managers 59 Globals.TheTextureManager = new TextureManager(Globals.TheMegafileManager); 60 Globals.TheTilesetManager = new TilesetManager(Globals.TheMegafileManager, Globals.TheTextureManager, Globals.TilesetsXMLPath, Globals.TexturesPath); 61 Globals.TheTeamColorManager = new TeamColorManager(Globals.TheMegafileManager); 62 63 var cultureName = CultureInfo.CurrentUICulture.Name; 64 var gameTextFilename = string.Format(Globals.GameTextFilenameFormat, cultureName.ToUpper()); 65 if (!Globals.TheMegafileManager.Exists(gameTextFilename)) 66 { 67 gameTextFilename = string.Format(Globals.GameTextFilenameFormat, "EN-US"); 68 } 69 Globals.TheGameTextManager = new GameTextManager(Globals.TheMegafileManager, gameTextFilename); 70 71 // Initialize Steam if this is a Steam build 72 if (SteamworksUGC.IsSteamBuild) 73 { 74 if (!SteamworksUGC.Init()) 75 { 76 #if !DEVELOPER 77 MessageBox.Show("Unable to initialize Steam interface.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 78 return; 79 #endif 80 } 81 } 82 83 Application.EnableVisualStyles(); 84 Application.SetCompatibleTextRenderingDefault(false); 85 86 if (Properties.Settings.Default.ShowInviteWarning) 87 { 88 var inviteMessageBox = new InviteMessageBox(); 89 inviteMessageBox.ShowDialog(); 90 91 Properties.Settings.Default.ShowInviteWarning = !inviteMessageBox.DontShowAgain; 92 Properties.Settings.Default.Save(); 93 } 94 95 Application.Run(new MainForm()); 96 97 if (SteamworksUGC.IsSteamBuild) 98 { 99 SteamworksUGC.Shutdown(); 100 } 101 102 Globals.TheMegafileManager.Dispose(); 103 } 104 } 105 }