Beispiel #1
0
        public ParseState Parse(XmlElement element, ParseState parseState)
        {
            string name           = element.Attributes["name"].InnerText;
            string docs           = element.Attributes["docs"].InnerText;
            string superType      = element.Attributes["superType"]?.InnerText;
            bool   isAbstract     = GenericMarshal.StringToBool(element.Attributes["isAbstract"].InnerText);
            bool   isInstantiable = GenericMarshal.StringToBool(element.Attributes["isInstantiable"].InnerText);
            bool   isDisposable   = GenericMarshal.StringToBool(element.Attributes["isDisposable"].InnerText);
            bool   isSingleton    = GenericMarshal.StringToBool(element.Attributes["isSingleton"].InnerText);

            EngineClass engineClass = new EngineClass(name)
            {
                Docs           = docs,
                SuperTypeName  = superType,
                Scope          = parseState.Scope,
                IsAbstract     = isAbstract,
                IsInstantiable = isInstantiable,
                IsDisposable   = isDisposable,
                IsSingleton    = isSingleton
            };

            ParseState functionParseState = new ParseState()
                                            .EnterScope(name);

            foreach (XmlElement childNode in element.ChildNodes)
            {
                if (childNode.Name.Equals("properties"))
                {
                    List <EngineClass.Property> properties = ParseProperties(childNode, null);
                    foreach (EngineClass.Property property in properties)
                    {
                        engineClass.Add(property);
                    }
                }
                else if (childNode.Name.Equals("exports"))
                {
                    foreach (XmlElement funElement in childNode.ChildNodes)
                    {
                        if (funElement.Name.Equals("RegisterObject"))
                        {
                            Debugger.Break();
                        }
                        new FunctionParser().Parse(funElement, functionParseState);
                    }
                }
                else
                {
                }
            }

            foreach (EngineFunction engineFunction in functionParseState.Functions)
            {
                engineClass.Add(engineFunction);
            }

            parseState.Classes.Add(engineClass);

            return(parseState);
        }
Beispiel #2
0
 public static void toggleConsole(string make)
 {
     if (GenericMarshal.StringToBool(make))
     {
         if (Core.Console.Console.ConsoleDlg.isAwake())
         {
             // Deactivate the console
             Core.Canvas.GameCanvas.popDialog(Core.Console.Console.ConsoleDlg);
         }
         else
         {
             Core.Canvas.GameCanvas.pushDialog(Core.Console.Console.ConsoleDlg.Name, 99);
         }
     }
 }
Beispiel #3
0
 public static void toggleNormalsViz(string pEnable)
 {
     if (string.IsNullOrEmpty(pEnable))
     {
         Globals.SetBool("AL_NormalsVisualizeVar", !normalsVisualizer.isEnabled());
         normalsVisualizer.toggle();
     }
     else if (GenericMarshal.StringToBool(pEnable))
     {
         normalsVisualizer.enable();
     }
     else
     {
         normalsVisualizer.disable();
     }
 }
Beispiel #4
0
 public static void toggleBackbufferViz(string pEnable)
 {
     if (string.IsNullOrEmpty(pEnable))
     {
         Globals.SetBool("AL_BackbufferVisualizeVar", DeferredShading.AL_DeferredShading.isEnabled());
         DeferredShading.AL_DeferredShading.toggle();
     }
     else if (GenericMarshal.StringToBool(pEnable))
     {
         DeferredShading.AL_DeferredShading.disable();
     }
     else
     {
         DeferredShading.AL_DeferredShading.enable();
     }
 }
Beispiel #5
0
 public static void toggleLightSpecularViz(string pEnable)
 {
     if (string.IsNullOrEmpty(pEnable))
     {
         Globals.SetBool("AL_LightSpecularVisualizeVar", !lightSpecularVisualizer.isEnabled());
         lightSpecularVisualizer.toggle();
     }
     else if (GenericMarshal.StringToBool(pEnable))
     {
         lightSpecularVisualizer.enable();
     }
     else
     {
         lightSpecularVisualizer.disable();
     }
 }
 public static void toggleSpecMapViz(string enable)
 {
     if (string.IsNullOrEmpty(enable))
     {
         Globals.SetBool("AL_SpecMapShaderVar", !AL_SpecMapVisualize.IsEnabled);
         AL_SpecMapVisualize.toggle();
     }
     else if (GenericMarshal.StringToBool(enable))
     {
         AL_DeferredShading.disable();
         AL_SpecMapVisualize.enable();
     }
     else
     {
         AL_SpecMapVisualize.disable();
         AL_DeferredShading.enable();
     }
 }
Beispiel #7
0
        public static void _setShadowVizLight(string light, string force = "false")
        {
            if (!Global.isObject("AL_ShadowVizOverlayCtrl"))
            {
                return;
            }
            GuiControl AL_ShadowVizOverlayCtrl = Sim.FindObject <GuiControl>("AL_ShadowVizOverlayCtrl");

            bool _force = GenericMarshal.StringToBool(force);

            if (!AL_ShadowVizOverlayCtrl.isAwake())
            {
                return;
            }
            if (!GenericMarshal.StringToBool(AL_ShadowVizOverlayCtrl.getFieldValue("isLocked")) && !_force)
            {
                return;
            }

            string sizeAndAspect = null;

            // Resolve the object to the client side.
            if (Global.isObject("light"))
            {
                SimObject obj         = Sim.FindObject <SimObject>(light);
                int       clientLight = HelperFunctions.serverToClientObject(obj);
                sizeAndAspect = Global.setShadowVizLight(clientLight.ToString());
            }

            AL_ShadowVizOverlayCtrl.findObjectByInternalName("MatCtrl", true)
            .call("setMaterial", "AL_ShadowVisualizeMaterial");

            string text = "ShadowViz";

            if (Global.isObject(light))
            {
                text += " : " + Global.getWord(sizeAndAspect, 0) + " x " + Global.getWord(sizeAndAspect, 1);
            }

            AL_ShadowVizOverlayCtrl.findObjectByInternalName("WindowCtrl").As <GuiWindowCtrl>().Text = text;
        }
Beispiel #8
0
        public ParseState Parse(XmlElement element, ParseState parseState)
        {
            string name       = element.Attributes["name"].InnerText;
            string docs       = element.Attributes["docs"].InnerText;
            string returnType = element.Attributes["returnType"].InnerText;
            string symbol     = element.Attributes["symbol"].InnerText;
            bool   isCallback = GenericMarshal.StringToBool(element.Attributes["isCallback"].InnerText);
            bool   isVariadic = GenericMarshal.StringToBool(element.Attributes["isVariadic"].InnerText);


            EngineFunction engineFunction = new EngineFunction(name)
            {
                Docs           = docs,
                ReturnTypeName = returnType,
                Symbol         = symbol,
                IsCallback     = isCallback,
                IsVariadic     = isVariadic,
                Scope          = parseState.Scope
            };

            foreach (XmlElement childNode in element.ChildNodes[0].ChildNodes)
            {
                engineFunction.Add(new EngineFunction.Argument()
                {
                    Name         = childNode.Attributes["name"].InnerText,
                    TypeName     = childNode.Attributes["type"].InnerText,
                    DefaultValue = childNode.Attributes["defaultValue"]?.InnerText
                });
            }

            // Assume that functions that take a first parameter named "this"
            // and with the same type as the current Scope (class), are methods.
            if (engineFunction.Arguments.Count >= 1 &&
                engineFunction.Arguments[0].Name.Equals("this"))
            {
                string arg0             = engineFunction.Arguments[0].TypeName;
                int    lastIndexOfColon = arg0.LastIndexOf(':');
                if (lastIndexOfColon > 0)
                {
                    arg0 = arg0.Remove(0, lastIndexOfColon + 1);
                }
                engineFunction.IsStatic = !parseState.Scope.EndsWith(arg0);
            }

            int firstArgIndex = 0;

            if (!engineFunction.IsStatic)
            {
                firstArgIndex = 1;
            }

            // TODO special-handling of argc, argv parameters to mark them as variadic. This is an assumption.
            if (engineFunction.Arguments.Count == 2 &&
                engineFunction.Arguments[0].Name.Equals("argc") &&
                engineFunction.Arguments[1].Name.Equals("argv"))
            {
                engineFunction.IsVariadic = true;
            }
            else if (engineFunction.Arguments.Count == firstArgIndex + 1 &&
                     engineFunction.Arguments[firstArgIndex].Name.Equals("args") &&
                     engineFunction.Arguments[firstArgIndex].TypeName.Equals("StringVector"))
            {
                engineFunction.IsVariadic = true;
            }

            // False by default, only class can set this to true.
            engineFunction.IsOverride = false;

            parseState.Functions.Add(engineFunction);

            return(parseState);
        }
        public void initialControlSet()
        {
            Global.echo("*** Initial Control Object");

            // The first control object has been set by the server
            // and we are now ready to go.

            // first check if the editor is active
            if (!Global.isToolBuild() || !Global.isMethod("Editor", "checkActiveLoadDone") || !GenericMarshal.StringToBool(Global.call("Editor::checkActiveLoadDone")))
            {
                GuiTSCtrl PlayGui = Sim.FindObject <GuiTSCtrl>("PlayGui");
                if (Core.Canvas.GameCanvas.getContent() != PlayGui.getId())
                {
                    Core.Canvas.GameCanvas.setContent(PlayGui);
                }
            }
        }