Ejemplo n.º 1
0
        public WndConsole() : base(L["Console"], 400, useLayout: true)
        {
            var cb = new ChatBox()
            {
                SizeLayout = new Layout2d("parent.iw", "parent.ih")
            };

            cb.SizeLayout = new Layout2d("parent.iw - 2 * x", "400");
            cb.Position   = new Vector2f(4, 2);
            Add(cb, "cb");
            var w = new Group();

            Field = new EditBox();
            Field.Renderer.Font = Ui.FontMono;
            cb.Renderer.Font    = Ui.FontMono;
            var btn = new BitmapButton()
            {
                Image = new Texture("icons/small/accept.png")
            };

            w.Add(Field, "txt");
            w.Add(btn, "btn");
            btn.Size           = new Vector2f(22, 22);
            w.SizeLayout       = new Layout2d("parent.iw", "btn.h");
            Field.SizeLayout   = new Layout2d("btn.left - 5", "btn.h");
            btn.PositionLayout = new Layout2d("parent.iw - w - 10", "0");
            w.PositionLayout   = new Layout2d("5", "cb.bottom + 5");
            Add(w, "cont");

            var commandHistory = new List <string>();
            var historyPos     = 0;

            var numAutocompleteLines = 0;

            ScriptState <object?> state = null !;

            void ProcessCommand()
            {
                Task.Run(async() =>
                {
                    RemoveAutocompleteLines();

                    var code   = Field.Text;
                    Field.Text = "";

                    cb.AddLine("> " + code);
                    var ncode = code;
                    if (ncode.EndsWith('#'))
                    {
                        ncode = $"Doc(()=>({ncode[..^1]}))";
                    }
        void R_ChatItem(NetConnection server, NetBuffer data, ushort numArgs)
        {
            string message = data.ReadString();

            chat.AddLine(message);
        }