예제 #1
0
        protected virtual bool ExecutePerInterface(InterfaceWithAttributeResult a)
        {
            // Load Macro
            var macroname = GetMacroName(a.TypeName, a.Attribute, out var args, out var outputname);
            var macro     = MacroFactory.GetMacro <MacroTypeVariables>(macroname, a.FsPath, out var errores);

            // Check for errors in macro
            if (macro == null)
            {
                OutputEngine.LogConsoleErrorWrite($"{a.TypeName} : {macroname}");
                foreach (var e in errores)
                {
                    OutputEngine.LogConsoleErrorWrite(e);
                }
                return(false);
            }

            // Execute macro
            var refinterface = args[0].StartsWith("I") ? args[0] : "";
            var refdata      = Engine.GetRecordForSymbol(refinterface);
            var variables    = CreateVariables(a, outputname, a.AttributeList, refdata);
            var res          = macro.Execute(variables, out var error);

            // Check for errors
            if (!res)
            {
                OutputEngine.LogConsoleErrorWrite(error);
            }

            // Write Results

            CurrentProject.WriteResults(variables);
            return(res);
        }
예제 #2
0
 public void DoCommand(String s, bool output = true)
 {
     try
     {
         vm.Execute(s);
     }
     catch (Exception e)
     {
         OutputEngine.WriteLine(e.Message);
     }
 }
예제 #3
0
        internal static void Initialize()
        {
            OutputEngine.WriteLine("Total mods registered: " + registeredMods.Count);
            IO.Log.Write("  Total mods registered: " + registeredMods.Count);

            for (int i = 0; i < registeredMods.Count; i++)
            {
                Graphics.GUI.Scene.Console.vm.RegisterAssembly(registeredMods[i].GetType().Assembly);
                registeredMods[i].Initialize();
            }
        }
예제 #4
0
        private bool ExecutePerClass(ClassWithAttributeResult a)
        {
            // Load Macro
            var macroname = GetMacroName(a.ClassName, a.Attribute, out var args, out var outputname);
            var macro     = MacroFactory.GetMacro <MacroTypeVariables>(macroname, a.FsPath, out var errores);

            // Check for errors in macro
            if (macro == null)
            {
                OutputEngine.LogConsoleErrorWrite($"{a.ClassName} : {macroname}");
                foreach (var e in errores)
                {
                    OutputEngine.LogConsoleErrorWrite(e);
                }
                return(false);
            }

            // Execute macro
            //var refinterface = args[0].StartsWith("I") ? args[0] : "";
            var reftype = args[0] ?? "";
            var refdata = Engine.GetRecordForSymbol(reftype);

            if (refdata == null)
            {
                OutputEngine.ConsoleWrite($"{reftype} is defined outside project. @REFINTERFACE/@REFCLASS will be null.");
            }
            var variables = CreateVariables(a, outputname, a.AttributeList, refdata);
            var res       = macro.Execute(variables, out var error);

            // Check for errors
            if (!res)
            {
                OutputEngine.LogConsoleErrorWrite(error);
            }

            // Write Results

            CurrentProject.WriteResults(variables);
            return(res);
        }
예제 #5
0
 public void DoFileAsync(String fn)
 {
     if (AsyncThread != null)
     {
         AsyncThread.Abort();
     }
     AsyncThread = new System.Threading.Thread(delegate()
     {
         String s = "";
         System.IO.StreamReader tsr = new System.IO.StreamReader(fn);
         if (tsr.Peek() == 8)
         {
             tsr.Read();
             tsr.Close();
             IO.SaveReader sr = new IO.SaveReader(fn);
             s = sr.ReadToEnd();
             sr.Close();
         }
         else
         {
             //tsr.Read();
             s = tsr.ReadToEnd();
             tsr.Close();
         }
         //pLuaVM.DoFile(fn);
         try
         {
             pLuaVM.DoString(s);
         }
         catch (Exception e)
         {
             IO.Log.Write("Exception in LUA engine at DoFileAsync");
             IO.Log.Write(e.Message);
             IO.Log.Write(e.Source);
             OutputEngine.WriteLine("LUA error: " + e.Message);
         }
     });
     AsyncThread.Start();
 }
예제 #6
0
 protected virtual string ReadLine(string hint)
 {
     OutputEngine.WriteHint(hint + ": ");
     return(HostInput.ReadLine());
 }
예제 #7
0
 protected virtual void ReportWarning(string message)
 {
     OutputEngine.WriteWarning(message);
 }
예제 #8
0
        public static void LoadDLLs()
        {
            IO.Log.Write("    Loading Component DLLs");
            if (!System.IO.Directory.Exists("Components"))
            {
                IO.Log.Write("        Components direction not found");
                System.IO.Directory.CreateDirectory("Components");
                return;
            }
            String[] files = System.IO.Directory.GetFiles("Components/", "*.dll", System.IO.SearchOption.AllDirectories);
            OutputEngine.WriteLine("Attempting to load components. " + files.Length.ToString() + " located");
            IO.Log.Write("        " + files.Length.ToString() + " file(s) found");
            if (files.Length != 0)
            {
                for (int i = 0; i < files.Length; i++)
                {
                    OutputEngine.WriteLine("Attemting to load from /" + files[i]);
                    IO.Log.Write("        Attempting to load " + files[i]);
                    try
                    {
                        System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom(files[i]);
                        Type[] types         = a.GetTypes();
                        bool   hasComponents = false;
                        for (int j = 0; j < types.Length; j++)
                        {
                            if (types[j].ToString().StartsWith("MicroWorld.Components.") &&
                                !types[j].ToString().StartsWith("MicroWorld.Components.GUI") &&
                                !types[j].ToString().StartsWith("MicroWorld.Components.Graphics") &&
                                !types[j].ToString().StartsWith("MicroWorld.Components.Logics"))
                            {
                                String name = types[j].ToString().Substring(22);
                                if (name != "Component" && name != "ComponentsManager" && name.IndexOf(".") == -1 && //name check
                                    Activator.CreateInstance(types[j]) is Components.Component)                      //actual type check
                                {
                                    hasComponents = true;
                                    OutputEngine.WriteLine("Found component: " + name);
                                    IO.Log.Write("            Component found: " + name);
                                    Main.LoadingDetails = "Found component: " + name;
                                    RegisteredComponents.Add(types[j]);
                                }
                            }
                            //TODO MOVE!!!
                            if (types[j].IsSubclassOf(typeof(Modding.BaseMod)))
                            {
                                OutputEngine.WriteLine("Found mod: " + types[j].ToString());
                                IO.Log.Write("            Mod found: " + types[j].ToString());
                                Modding.ModdingLogics.registeredMods.Add(Activator.CreateInstance(types[j]) as Modding.BaseMod);
                                OutputEngine.WriteLine("Mod registered successfully!");
                                IO.Log.Write("            Mod registered successfully!");
                            }
                        }

                        if (!hasComponents)
                        {
                            OutputEngine.WriteLine("File /" + files[i] + " contains no components");
                            IO.Log.Write("        No components found");
                        }
                        else
                        {
                            Utilities.Reflection.RegisterAssembly(a);
                            OutputEngine.WriteLine("Successfully loaded /" + files[i]);
                            IO.Log.Write("        Succressfully loaded from " + files[i]);
                        }
                    }
                    catch (Exception e)
                    {
                        OutputEngine.WriteLine("Error while loading /" + files[i]);
                        IO.Log.Write("        Error while loading " + files[i]);
                        IO.Log.Write(IO.Log.State.ERROR, "       \r\n" + e.Message);
                        IO.Log.Write(IO.Log.State.ERROR, "       \r\n" + e.StackTrace);
                        Console.WriteLine(e.Message);
                    }
                    OutputEngine.WriteLine("");
                }
            }
        }
예제 #9
0
 public void ClearConsole()
 {
     OutputEngine.Clear();
 }
예제 #10
0
 public void writeln(String strCmd)
 {
     OutputEngine.WriteLine("[LUA]: " + strCmd);
 }
예제 #11
0
 public static void writeln(object o)
 {
     OutputEngine.WriteLine(">> " + o == null ? "null" : o.ToString());
 }
예제 #12
0
 public void writeln(String strCmd)
 {
     OutputEngine.WriteLine(strCmd);
     OutputEngine.WriteLine();
 }