示例#1
0
        static void InitConsole()
        {
            Engine.GamePath = ConVar.Register("game", "basegame", ConVarType.Replicated | ConVarType.Init);
            //Engine.GamePath = ConVar.Register("game", "legprocessor", ConVarType.Replicated | ConVarType.Init);

            Engine.MaxFPS       = ConVar.Register("maxfps", 60, ConVarType.Archive);
            Engine.WindowWidth  = ConVar.Register("width", 1366, ConVarType.Archive);
            Engine.WindowHeight = ConVar.Register("height", 768, ConVarType.Archive);

            //Engine.WindowWidth = CVar.Register("width", 800, CVarType.Archive);
            //Engine.WindowHeight = CVar.Register("height", 600, CVarType.Archive);

            Engine.WindowBorderless = ConVar.Register("borderless", false, ConVarType.Archive);
            Engine.WindowResizable  = ConVar.Register("resizable", false, ConVarType.Archive);
            Engine.ShowFPS          = ConVar.Register("showfps", true, ConVarType.Archive);

            Engine.MSAA = ConVar.Register("msaa", 32, ConVarType.Archive);

            Engine.SourceGameDirs = ConVar.Register("source_game_dirs", "C:/Program Files (x86)/Steam/steamapps/common/GarrysMod", ConVarType.Archive);
            Engine.DebugDraw      = ConVar.Register("debugdraw", true, ConVarType.Cheat);

            // Parse all arguments and set CVars
            foreach (var Arg in ArgumentParser.All)
            {
                switch (Arg.Key)
                {
                case "console":
                    GConsole.Open = true;
                    break;

                case "game":
                    Engine.GamePath.Value = Arg.Value.Last();
                    break;

                default:
                    GConsole.Error("Invalid switch '{0}' with value '{1}'", Arg.Key, Arg.Value);
                    break;
                }
            }

            foreach (var CVar in ConVar.GetAll())
            {
                GConsole.WriteLine(CVar);
            }

            ConCmd.Register("exit", (Argv) => Environment.Exit(0));
            GConsole.RegisterAlias("quit", "exit");
        }
示例#2
0
        public override void Load()
        {
            AddButton("Exit", () => Engine.CreateYesNoPrompt("Exit Program?", () => Environment.Exit(0)).Center((Engine.Window.WindowSize / 2)));
            AddButton("Stop", RealSenseCamera.Stop);
            AddButton("Start", RealSenseCamera.Start);

            Engine.Camera3D.SetPerspective(Engine.Window.WindowSize, (90.0f).ToRad(), NearClip, 100);

            LegShader = new ShaderProgram(new ShaderStage(ShaderType.VertexShader, "content/shaders/leg.vert"),
                                          new ShaderStage(ShaderType.FragmentShader, "content/shaders/leg.frag"));

            VertsMesh = new Mesh3D();
            VertsMesh.PrimitiveType = PrimitiveType.Points;
            VertsMesh.SetVertices(new Vertex3());

            // Variables
            Sparse        = ConVar.Register(nameof(Sparse).ToLower(), 0);         // 3
            LegLength     = ConVar.Register(nameof(LegLength).ToLower(), 100.0f); // 1.0f
            LegWidth      = ConVar.Register(nameof(LegWidth).ToLower(), 100.0f);  // 0.5f
            PickDistance  = ConVar.Register(nameof(PickDistance).ToLower(), 1.0f);
            PickSize      = ConVar.Register(nameof(PickSize).ToLower(), 0.01f);   // 0.025f
            PickSampleNum = ConVar.Register(nameof(PickSampleNum).ToLower(), 10); // 10

            ConCmd.Register("list", (Argv) => {
                GConsole.WriteLine(Sparse);
                GConsole.WriteLine(LegLength);
                GConsole.WriteLine(LegWidth);
                GConsole.WriteLine(PickDistance);
                GConsole.WriteLine(PickSize);
                GConsole.WriteLine(PickSampleNum);
            });

            Thread PollingThread = new Thread(() => {
                while (true)
                {
                    RealSenseCamera.PollForFrames(OnPointCloud: OnPointCloud);
                    Thread.Sleep(0);
                }
            });

            PollingThread.IsBackground = true;
            PollingThread.Start();

            Engine.Camera3D.Position = new Vector3(0, 0, -1);
            Engine.Camera3D.LookAt(Vector3.Zero);
            Engine.Camera3D.Position = new Vector3(0, 0, -NearClip);
        }
示例#3
0
        static void InitConsole()
        {
            Engine.GamePath = ConVar.Register("game", "basegame", ConVarType.Replicated | ConVarType.Init);
            //Engine.GamePath = ConVar.Register("game", "legprocessor", ConVarType.Replicated | ConVarType.Init);

            Engine.WindowWidth  = ConVar.Register("width", 1366, ConVarType.Archive);
            Engine.WindowHeight = ConVar.Register("height", 768, ConVarType.Archive);

            //Engine.WindowWidth = CVar.Register("width", 800, CVarType.Archive);
            //Engine.WindowHeight = CVar.Register("height", 600, CVarType.Archive);

            Engine.WindowBorderless = ConVar.Register("borderless", false, ConVarType.Archive);
            Engine.WindowResizable  = ConVar.Register("resizable", false, ConVarType.Archive);

            // Parse all arguments and set CVars
            foreach (var Arg in ArgumentParser.All)
            {
                switch (Arg.Key)
                {
                case "console":
                    GConsole.Open = true;
                    break;

                case "game":
                    Engine.GamePath.Value = Arg.Value.Last();
                    break;

                default:
                    GConsole.Error("Invalid switch '{0}' with value '{1}'", Arg.Key, Arg.Value);
                    break;
                }
            }

            foreach (var CVar in ConVar.GetAll())
            {
                GConsole.WriteLine(CVar);
            }

            ConCmd.Register("exit", (Argv) => Environment.Exit(0));
            GConsole.RegisterAlias("quit", "exit");
        }
示例#4
0
        internal static void Init()
        {
            /*ConsoleWindow = new Window();
             * ConsoleWindow.ResizableHorizontal = false;
             * ConsoleWindow.Movable = false;
             * ConsoleWindow.Color = new Color(255, 255, 255, 200);
             * ConsoleWindow.MinimumSize = new Vector2(0, 100);
             *
             * Input = ConsoleWindow.AddChild(new InputBox(DefaultFonts.ConsoleFont));
             * Input.OnTextEntered += (In, Txt) => {
             *      In.String = "";
             *      SendInput(Txt);
             * };
             *
             * Output = ConsoleWindow.AddChild(new Label(DefaultFonts.ConsoleFont));
             * Output.Multiline = true;
             * ConsoleWindow.OnResize += (Wnd, Sz) => {
             *      float SpacingOffset = 1.5f;
             *      Output.Position = new Vector2(0, DefaultFonts.ConsoleFont.LineSpacing * SpacingOffset);
             *      Output.DrawRegion = new AABB(new Vector2(Sz.X, Sz.Y - DefaultFonts.ConsoleFont.LineSpacing * SpacingOffset));
             *
             *      Input.DrawRegion = new AABB(new Vector2(Sz.X, DefaultFonts.ConsoleFont.LineSpacing));
             * };
             *
             * if (TempBuffer.Length > 0) {
             *      Output.AppendString(TempBuffer.ToString());
             *      TempBuffer.Clear();
             * }//*/

            ConVar <float> ConHeight = ConVar.Register("con_height", 0.4f, ConVarType.Archive);

            //const float Padding = 10;

            //ConsoleWindow.Position = new Vector2(Padding, (int)(Engine.WindowHeight * ConHeight) + Padding);
            //ConsoleWindow.Size = new Vector2(Engine.WindowWidth - Padding * 2, (int)(Engine.WindowHeight * (1.0f - ConHeight)) - Padding * 2);


            ConCmd.Register("clear", (Argv) => {
                Clear();
            });

            ConCmd.Register("rainbow", (Argv) => {
                string Rnd = Utils.RandomString(40, 60);

                Color Clr = Color;
                foreach (var Char in Rnd)
                {
                    Color = Utils.RandomColor();
                    Write(Char.ToString());
                }
                Write("\n");

                Color = Clr;
            });

            ConCmd.Register("echo", (Argv) => {
                for (int i = 1; i < Argv.Length; i++)
                {
                    string Arg = Argv[i];

                    /*if (Arg.StartsWith("$")) {
                     *      if (ConVar.TryFind(Arg.Substring(1), out ConVar Var))
                     *              Write(Var.ObjectValue);
                     *      else
                     *              Write("null");
                     * } else*/
                    Write(Arg);
                }
                Write("\n");
            });

            ConCmd.Register("alias", (Argv) => {
                if (Argv.Length == 1)
                {
                    foreach (var Alias in GetAliases())
                    {
                        WriteLine("{0} -> {1}", Alias.Item1, Alias.Item2);
                    }
                }
                else if (Argv.Length == 2)
                {
                    foreach (var Alias in GetAliases())
                    {
                        if (Alias.Item1.StartsWith(Argv[1]))
                        {
                            WriteLine("{0} -> {1}", Alias.Item1, Alias.Item2);
                        }
                    }
                }
                else if (Argv.Length == 3)
                {
                    WriteLine("{0} -> {1}", Argv[1], Argv[2]);
                    RegisterAlias(Argv[1], Argv[2]);
                }
                else
                {
                    Error("alias\nalias <command_alias>\nalias <command_alias> <command>");
                }
            });

            ConCmd.Register("var", (Argv) => {
                if (Argv.Length != 2)
                {
                    Error("var <variable_name>");
                    return;
                }

                ConVar.Register(Argv[1], 0);
            });

            ConCmd.Register("inc", (Argv) => {
                if (Argv.Length != 2)
                {
                    Error("inc <variable_name>");
                    return;
                }

                if (ConVar.TryFind(Argv[1], out ConVar Var))
                {
                    ((ConVar <int>)Var).Value++;
                }
            });

            ConCmd.Register("dec", (Argv) => {
                if (Argv.Length != 2)
                {
                    Error("dec <variable_name>");
                    return;
                }

                if (ConVar.TryFind(Argv[1], out ConVar Var))
                {
                    ((ConVar <int>)Var).Value--;
                }
            });

            ConCmd.Register("toggle", (Argv) => {
                if (Argv.Length != 2)
                {
                    Error("toggle <variable_name>");
                    return;
                }

                if (ConVar.TryFind(Argv[1], out ConVar Var))
                {
                    ConVar <int> IntVar = (ConVar <int>)Var;

                    if (IntVar.Value == 0)
                    {
                        IntVar.Value = 1;
                    }
                    else
                    {
                        IntVar.Value = 0;
                    }
                }
            });

            ConCmd.Register("cvarlist", (Argv) => {
                foreach (var CVar in ConVar.GetAll())
                {
                    WriteLine(CVar);
                }
            });

            ConCmd.Register("cmdlist", (Argv) => {
                foreach (var Cmd in ConCmd.GetAll())
                {
                    WriteLine(Cmd);
                }
            });

            ConCmd.Register("eval", (Argv) => {
                SendInputQuiet(string.Join("", Argv.Skip(1)));
            });

            ConCmd.Register("mousepos", (Argv) => {
                GConsole.WriteLine((Engine.Window.WindowSize.GetHeight() - Engine.Window.MousePos).Abs());
            });

            ConCmd.Register("crash", (Argv) => {
                throw new InvalidOperationException("Crashing the program!");
            });
        }