Beispiel #1
0
        public static void Main(string[] args)
        {
            var assemblies = new List <string>();
            var platforms  = new List <string>();
            var output     = string.Empty;
            var operation  = string.Empty;

            var options = new OptionSet
            {
                { "a|assembly=", "Load an assembly.", v => assemblies.Add(v) },
                { "p|platform=", "Specify one or more platforms to target.", v => platforms.Add(v) },
                { "o|output=", "Specify the output folder for the compiled assets.", v => output = v },
                { "m|operation=", "Specify the mode of operation (either 'bulk', 'remote' or 'builtin', default is 'bulk').", v => operation = v }
            };

            try
            {
                options.Parse(args);
            }
            catch (OptionException ex)
            {
                Console.Write("ProtogameAssetTool.exe: ");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try `ProtogameAssetTool.exe --help` for more information.");
                Environment.Exit(1);
                return;
            }

            if (IntPtr.Size != 8)
            {
                Console.Error.WriteLine("ERROR: Asset compilation is only supported on 64-bit machines.");
                Environment.Exit(1);
            }

            // Deploy the correct MojoShader DLL.
            MojoShaderDeploy.Deploy();

            switch (operation)
            {
            case "remote":
                RemoteCompileService();
                break;

            case "builtin":
                BuiltinCompile();
                break;

            default:
                BulkCompile(assemblies, platforms, output);
                break;
            }
        }
Beispiel #2
0
        internal static void Main(string[] args)
        {
            var connectToRunningGame = false;
            var options = new OptionSet
            {
                { "connect", "Internal use only (used by the game client).", v => connectToRunningGame = true }
            };

            try
            {
                options.Parse(args);
            }
            catch (OptionException ex)
            {
                Console.Write("ProtogameAssetManager.exe: ");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try `ProtogameAssetManager.exe --help` for more information.");
                return;
            }

            // Deploy the correct MojoShader DLL.
            MojoShaderDeploy.Deploy();

            var kernel = new StandardKernel();

            kernel.Load <Protogame2DIoCModule>();
            kernel.Load <ProtogameAssetIoCModule>();
            kernel.Load <ProtogameEventsIoCModule>();
            kernel.Load <ProtogamePlatformingIoCModule>();
            kernel.Load <AssetManagerIoCModule>();

            // Only allow the source load strategies.
            kernel.Unbind <ILoadStrategy>();
            kernel.Bind <ILoadStrategy>().To <RawTextureLoadStrategy>();
            kernel.Bind <ILoadStrategy>().To <RawModelLoadStrategy>();
            kernel.Bind <ILoadStrategy>().To <RawEffectLoadStrategy>();
            kernel.Bind <ILoadStrategy>().To <LocalSourceLoadStrategy>();
            kernel.Bind <ILoadStrategy>().To <EmbeddedSourceLoadStrategy>();
            kernel.Bind <ILoadStrategy>().To <EmbeddedCompiledLoadStrategy>();

            var runningFile          = new FileInfo(Assembly.GetExecutingAssembly().Location);
            var workingDirectoryInfo = new DirectoryInfo(Environment.CurrentDirectory);
            var scannedUnique        = new List <string>();

            foreach (var file in runningFile.Directory.GetFiles("*.dll"))
            {
                if (scannedUnique.Contains(file.FullName))
                {
                    continue;
                }
                Console.WriteLine("Scanning " + file.Name);
                try
                {
                    RegisterEditorsFromAssembly(Assembly.LoadFrom(file.FullName), kernel);
                    scannedUnique.Add(file.FullName);
                }
                catch (BadImageFormatException) { }
                catch (FileLoadException) { }
            }
            foreach (var file in runningFile.Directory.GetFiles("*.exe"))
            {
                if (scannedUnique.Contains(file.FullName))
                {
                    continue;
                }
                Console.WriteLine("Scanning " + file.Name);
                try
                {
                    RegisterEditorsFromAssembly(Assembly.LoadFrom(file.FullName), kernel);
                    scannedUnique.Add(file.FullName);
                }
                catch (BadImageFormatException) { }
                catch (FileLoadException) { }
            }
            foreach (var file in workingDirectoryInfo.GetFiles("*.dll"))
            {
                if (scannedUnique.Contains(file.FullName))
                {
                    continue;
                }
                Console.WriteLine("Scanning " + file.Name);
                try
                {
                    RegisterEditorsFromAssembly(Assembly.LoadFrom(file.FullName), kernel);
                    scannedUnique.Add(file.FullName);
                }
                catch (BadImageFormatException) { }
                catch (FileLoadException) { }
            }
            foreach (var file in workingDirectoryInfo.GetFiles("*.exe"))
            {
                if (scannedUnique.Contains(file.FullName))
                {
                    continue;
                }
                Console.WriteLine("Scanning " + file.Name);
                try
                {
                    RegisterEditorsFromAssembly(Assembly.LoadFrom(file.FullName), kernel);
                    scannedUnique.Add(file.FullName);
                }
                catch (BadImageFormatException) { }
                catch (FileLoadException) { }
            }

#if FALSE
            if (connectToRunningGame)
            {
                var node = new LocalNode(Architecture.ServerClient, Caching.PushOnChange);
                node.Bind(IPAddress.Loopback, 9837);
                node.GetService <IClientConnector>().Connect(IPAddress.Loopback, 9838);
                var assetManagerProvider = new NetworkedAssetManagerProvider(node, kernel);
                kernel.Bind <IAssetManagerProvider>().ToMethod(x => assetManagerProvider);
            }
            else
#endif
            kernel.Bind <IAssetManagerProvider>().To <LocalAssetManagerProvider>().InSingletonScope();

            using (var game = new AssetManagerGame(kernel))
            {
                game.Run();
            }
        }