コード例 #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
ファイル: LegProcessor.cs プロジェクト: yarligayan/libTech
        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
ファイル: GConsole.cs プロジェクト: yarligayan/libTech
        public static void SendInput(string Line)
        {
            // Ignore empty
            Line = Line.Trim();
            if (Line.Length == 0 || Line.StartsWith("//"))
            {
                return;
            }

            Color = Color.White;
            if (Echo)
            {
                WriteLine("> {0}", Line);
            }
            string[] ArgvLine = ParseLine(Line).ToArray();

            foreach (var Argv in ArgvLine.Split(";"))
            {
                ConVar Var;

                for (int i = 0; i < Argv.Length; i++)
                {
                    if (Argv[i].StartsWith("$") && ConVar.TryFind(Argv[i].Substring(1), out Var))
                    {
                        Argv[i] = Var.StringValue;
                    }
                }

                if (Argv.Length == 1 && Aliases.ContainsKey(Argv[0]))
                {
                    bool OldEcho = Echo;
                    Echo = false;
                    SendInput(Aliases[Argv[0]]);
                    Echo = OldEcho;
                    return;
                }

                try {
                    if (Argv.Length == 2 && (Argv[0] == "+" || Argv[0] == "-"))
                    {
                        if (ConVar.TryFind(Argv[1], out Var))
                        {
                            if (Var is ConVar <int> )
                            {
                                ((ConVar <int>)Var).Value = Argv[0] == "+" ? 1 : 0;
                            }
                            else if (Var is ConVar <bool> )
                            {
                                ((ConVar <bool>)Var).Value = Argv[0] == "+" ? true : false;
                            }
                            else
                            {
                                Error("Unknown variable type '{0}'", Var.ObjectValue.GetType().Name);
                            }
                        }
                        else
                        {
                            Error("Cannot toggle non existing variable '{0}'", Argv[1]);
                        }
                    }
                    else if ((Argv.Length == 1 || Argv.Length == 2) && ConVar.TryFind(Argv[0], out Var))
                    {
                        if (Argv.Length == 2)
                        {
                            Var.StringValue = Argv[1];
                        }

                        if (Echo)
                        {
                            WriteLine(Var);
                        }
                    }
                    else if (Argv.Length == 3 && Argv[1] == "=" && ConVar.TryFind(Argv[0], out Var))
                    {
                        Var.StringValue = Argv[2];

                        if (Echo && Argv.Length != 3)
                        {
                            WriteLine(Var);
                        }
                    }
                    else if (Argv.Length > 0 && ConCmd.TryFind(Argv[0], out ConCmd Cmd))
                    {
                        Cmd.Command(Argv);
                    }
                    else
                    {
                        Error("Unknown command/variable '{0}'", Argv[0]);
                    }
                } catch (Exception E) {
                    Engine.LogFatal(E);

                    Error("{0}: {1}", E.GetType().Name, E.Message);
                }
            }
        }
コード例 #5
0
ファイル: GConsole.cs プロジェクト: yarligayan/libTech
        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!");
            });
        }
コード例 #6
0
 /**
  * Creates a console command as an administrative command.  If the command does not exist,
  * it is created.  When this command is invoked, the access rights of the player are
  * automatically checked before allowing it to continue.
  *
  * Admin commands are case sensitive from both the client and server.
  *
  * @param cmd           String containing command to register.
  * @param callback      A function to use as a callback for when the command is invoked.
  * @param adminflags    Administrative flags (bitstring) to use for permissions.
  * @param description   Optional description to use for help.
  * @param group         String containing the command group to use.  If empty,
  *                      the plugin's filename will be used instead.
  * @param flags         Optional console flags.
  * @error               Command name is the same as an existing convar.
  */
 public static void RegAdminCmd(string cmd, ConCmd callback, int adminflags, string description = "", string group = "", int flags = 0)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 /**
  * Creates a console command, or hooks an already existing one.
  *
  * Console commands are case sensitive.  However, if the command already exists in the game,
  * a client may enter the command in any case.  SourceMod corrects for this automatically,
  * and you should only hook the "real" version of the command.
  *
  * @param cmd           Name of the command to hook or create.
  * @param callback      A function to use as a callback for when the command is invoked.
  * @param description   Optional description to use for command creation.
  * @param flags         Optional flags to use for command creation.
  * @error               Command name is the same as an existing convar.
  */
 public static void RegConsoleCmd(string cmd, ConCmd callback, string description = "", int flags = 0)
 {
     throw new NotImplementedException();
 }