Esempio n. 1
0
        static void Main(string[] args)
        {
            if (!ExtractParams(args))
            {
                ShowMessage();
                return;
            }
            else
            {
                CompileEngine engine        = new CompileEngine();
                ArtifactsType artifactsType = ArtifactsType.Console;
                if (_writeFile)
                {
                    if (_singleFile)
                    {
                        artifactsType = ArtifactsType.SingleFile;
                    }
                    else
                    {
                        artifactsType = ArtifactsType.MultipleFile;
                    }
                }

                if ((!string.IsNullOrEmpty(_config)) && _config.ToUpper() == "RELEASE")
                {
                    _config = CompileOptions.RELEASE_ANY_CPU;
                }
                else
                {
                    _config = CompileOptions.DEBUG_ANY_CPU;
                }


                CompileOptions opts = new CompileOptions(artifactsType, _config);
                opts.GenerateSourceMap = _generateSourceMap;

                engine.InitializeCompiler(_csprojFile, opts, _suppressWarnings);
                var errors = engine.Compile();
                errors.WriteToStdErr(opts.StdError);
            }
            System.Console.ReadLine();
        }
Esempio n. 2
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            Log.Info("Mud Designer Toolkit Editor starting.");
            Log.Info("Loading script references.");


            //Loop through each reference mentioned in the engines properties and add them.
            //This provides support for 3rd party pre-compiled *mods* scripts
            foreach (var path in from string reference in EngineSettings.Default.ScriptLibrary select Path.Combine(System.Environment.CurrentDirectory, reference))
            {
                CompileEngine.AddAssemblyReference(path);
                Log.Info(string.Format("Adding assembly reference {0}", path));
            }

            //Compile the scripts.
            bool result = CompileEngine.Compile(EngineSettings.Default.ScriptsPath);

            if (!result)
            {
                this.mainTxtServerInfo.Text = CompileEngine.Errors;
            }

            //Add the compiled script assembly to the script factory.
            ScriptFactory.AddAssembly(CompileEngine.CompiledAssembly);

            //Add the third party references.
            foreach (string reference in EngineSettings.Default.ScriptLibrary)
            {
                ScriptFactory.AddAssembly(reference);
            }

            if (File.Exists("MudDesigner.Scripts.dll"))
            {
                string path = Path.Combine(System.Environment.CurrentDirectory, "MudDesigner.Scripts.dll");
                ScriptFactory.AddAssembly(Assembly.LoadFile(path));
            }

            //Get a reference to a scripted instance of IGame.
            var game = (IGame)ScriptFactory.GetScript(EngineSettings.Default.GameScript, null);

            //In the event that the scripted Game class specified as the default is missing,
            //just search the engine for another one.
            if (game == null)
            {
                game = (IGame)ScriptFactory.FindInheritedScript("MudDesigner.Engine.Core.Game", null);

                if (game == null) //still could not find anything
                {
                    MessageBox.Show("Critical error: Could not locate a Game script to use. This can cause instability in the editor.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Log.Error(string.Format("{0}", CompileEngine.Errors));
                    //Logger.WriteLine(CompileEngine.Errors, Logger.Importance.Critical);

                    menuWorld.Enabled = false;
                    menuGame.Enabled  = false;
                    menuSave.Enabled  = false;

                    return;
                }
            }
            IServer server = new Server(4000);

            //Initialize the Game. Null reference to a server is passed because we don't need a server.
            game.Initialize(server);

            //Load the save game file.
            game.RestoreWorld();

            //Store a reference to the current game to the static Editor Type
            Editor.Game = game;

            //Update the GUI
            mainPropertyGame.SelectedObject   = Editor.Game;
            mainPropertyServer.SelectedObject = Editor.Game.Server;
            RefreshUI();
        }