Beispiel #1
0
 void ResetTable(TableWidget widget)
 {
     widget.SetEntries(game.Servers);
     widget.SetDrawData(drawer, tableFont, textFont,
                        Anchor.Min, Anchor.Min, tableX, tableY);
     widget.SortDefault();
 }
 void InitTableWidget()
 {
     table                = new TableWidget(game);
     table.font           = font;
     table.ElementsPerRow = game.PureClassic ? 9 : 10;
     table.Init();
 }
        protected override void MouseWheelChanged(object sender, MouseWheelEventArgs e)
        {
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            table.CurrentIndex -= e.Delta;
            MarkPendingRedraw();
        }
        protected override void KeyDown(object sender, KeyboardKeyEventArgs e)
        {
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            if (e.Key == Key.Enter)
            {
                string curServer = Get(view.hashIndex) ?? "";
                if (table.Count >= 1 && curServer == "")
                {
                    widgets[view.hashIndex].Text = table.Get(0).Hash;
                    ConnectToServer(0, 0);
                }
                else if (curServer != "" &&
                         (selectedWidget == null || selectedWidget == widgets[view.tableIndex]))
                {
                    ConnectToServer(0, 0);
                }
            }
            else if (e.Key == Key.Up)
            {
                table.SetSelected(table.SelectedIndex - 1);
                table.NeedRedraw();
            }
            else if (e.Key == Key.Down)
            {
                table.SetSelected(table.SelectedIndex + 1);
                table.NeedRedraw();
            }
            else
            {
                base.KeyDown(sender, e);
            }
        }
        public override void Tick()
        {
            base.Tick();
            if (fetchTask != null)
            {
                CheckFetchStatus();
            }
            flagsTask.Tick();

            TableWidget table = (TableWidget)widgets[view.tableIndex];

            if (!game.Window.Mouse[MouseButton.Left])
            {
                table.DraggingColumn    = -1;
                table.DraggingScrollbar = false;
                table.mouseOffset       = 0;
            }

            if (flagsTask.PendingRedraw)
            {
                table.RedrawFlags();
                game.Dirty = true;
                flagsTask.PendingRedraw = false;
            }
        }
        void MouseButtonUp(object sender, MouseButtonEventArgs e)
        {
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            table.DraggingColumn    = -1;
            table.DraggingScrollbar = false;
            table.mouseOffset       = 0;
        }
        protected override void MouseWheelChanged(object sender, MouseWheelEventArgs e)
        {
            TableWidget table = (TableWidget)widgets[view.tableIndex];
            int         steps = Utils.AccumulateWheelDelta(ref tableAcc, e.Delta);

            table.CurrentIndex -= steps;
            MarkPendingRedraw();
        }
Beispiel #8
0
        void MouseButtonUp(MouseButton btn)
        {
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            table.DraggingColumn    = -1;
            table.DraggingScrollbar = false;
            table.mouseOffset       = 0;
        }
 protected override void MouseMove(int x, int y, int xDelta, int yDelta)
 {
     base.MouseMove(x, y, xDelta, yDelta);
     if (selectedWidget != null && selectedWidget == widgets[view.tableIndex])
     {
         TableWidget table = (TableWidget)widgets[view.tableIndex];
         table.MouseMove(x, y, xDelta, yDelta);
     }
 }
        void MarkPendingRedraw()
        {
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            table.ClampIndex();
            table.RecalculateDrawData();
            pendingRedraw = true;
            game.Dirty    = true;
        }
Beispiel #11
0
        public override void DrawAll()
        {
            DrawBackground();
            TableWidget table = (TableWidget)widgets[tableIndex];

            if (table != null)
            {
                table.ClampIndex();
            }
            base.DrawAll();
        }
        void FilterList()
        {
            if (curInput != widgets[view.searchIndex])
            {
                return;
            }
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            table.FilterEntries(curInput.Text);
            MarkPendingRedraw();
        }
        protected override void RedrawLastInput()
        {
            base.RedrawLastInput();
            if (curInput != widgets[view.hashIndex])
            {
                return;
            }
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            table.SetSelected(widgets[view.hashIndex].Text);
            MarkPendingRedraw();
        }
        public override void Tick()
        {
            base.Tick();
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            if (!game.Window.Mouse[MouseButton.Left])
            {
                table.DraggingColumn    = -1;
                table.DraggingScrollbar = false;
                table.mouseOffset       = 0;
            }
        }
        public override void Dispose()
        {
            base.Dispose();
            view.Dispose();

            TableWidget table = widgets[view.tableIndex] as TableWidget;

            if (table != null)
            {
                table.DraggingColumn    = -1;
                table.DraggingScrollbar = false;
            }
        }
Beispiel #16
0
        internal void RedrawTable()
        {
            using (FastBitmap dst = game.LockBits())
                DrawTableBackground(dst);
            TableWidget table = (TableWidget)widgets[tableIndex];

            table.ClampIndex();

            int tableHeight = Math.Max(game.Height - tableY - 50, 1);

            table.Height = tableHeight;
            using (drawer) {
                drawer.SetBitmap(game.Framebuffer);
                table.RedrawData(drawer);
            }
        }
        void SetupWidgetHandlers()
        {
            InputWidget hashWidget = (InputWidget)widgets[view.hashIndex];

            hashWidget.Chars.ClipboardFilter = HashFilter;

            widgets[view.backIndex].OnClick    = SwitchToMain;
            widgets[view.connectIndex].OnClick = ConnectToServer;
            widgets[view.refreshIndex].OnClick = RefreshList;

            TableWidget widget = (TableWidget)widgets[view.tableIndex];

            widget.NeedRedraw      = MarkPendingRedraw;
            widget.SelectedChanged = SelectedChanged;
            SetupInputHandlers();
        }
        void SetupWidgetHandlers()
        {
            InputWidget hashWidget = (InputWidget)widgets[view.hashIndex];

            hashWidget.Chars.ClipboardFilter = HashFilter;

            widgets[view.backIndex].OnClick =
                (x, y) => game.SetScreen(new MainScreen(game));
            widgets[view.connectIndex].OnClick = ConnectToServer;

            TableWidget widget = (TableWidget)widgets[view.tableIndex];

            widget.NeedRedraw      = MarkPendingRedraw;
            widget.SelectedChanged = SelectedChanged;
            SetupInputHandlers();
        }
Beispiel #19
0
        void CheckFetchStatus()
        {
            if (!game.Session.Done)
            {
                return;
            }
            fetchingList = false;

            view.RefreshText = game.Session.Exception == null ? "Refresh" : "&cFailed";
            Resize();

            // needed to ensure 'highlighted server hash' is over right entry after refresh
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            table.SetSelected(widgets[view.hashIndex].Text);
            MarkPendingRedraw();
        }
        public override void Init()
        {
            table                = new TableWidget(game);
            table.font           = font;
            table.ElementsPerRow = game.PureClassic ? 9 : 10;
            table.Init();

            // Can't immediately move to selected here, because cursor visibility
            // might be toggled after Init() is called. This causes the cursor to
            // be moved back to the middle of the window.
            deferredSelect = true;

            game.Events.BlockPermissionsChanged += OnBlockChanged;
            game.Events.BlockDefinitionChanged  += OnBlockChanged;
            Keyboard.KeyRepeat              = true;
            game.Graphics.ContextLost      += ContextLost;
            game.Graphics.ContextRecreated += ContextRecreated;
        }
Beispiel #21
0
        public override void Init()
        {
            table                = new TableWidget(game);
            table.font           = font;
            table.ElementsPerRow = game.PureClassic ? 9 : 10;
            table.Init();

            // User is holding invalid block
            if (table.SelectedIndex == -1)
            {
                table.MakeDescTex(game.Inventory.Selected);
            }

            game.Events.BlockPermissionsChanged += OnBlockChanged;
            game.Events.BlockDefinitionChanged  += OnBlockChanged;
            game.Keyboard.KeyRepeat              = true;
            game.Graphics.ContextLost           += ContextLost;
            game.Graphics.ContextRecreated      += ContextRecreated;
        }
Beispiel #22
0
        void MakeTableWidget()
        {
            int         tableHeight = Math.Max(game.Height - tableY - 50, 1);
            TableWidget widget;

            if (widgets[tableIndex] != null)
            {
                widget = (TableWidget)widgets[tableIndex];
            }
            else
            {
                widget = new TableWidget(game);
                widget.SetEntries(game.Session.Servers);
                widget.SetDrawData(drawer, tableFont, textFont,
                                   Anchor.LeftOrTop, Anchor.LeftOrTop, tableX, tableY);
                widget.SortDefault();
                widgets[widgetIndex] = widget;
            }

            widget.Height = tableHeight;
            widgetIndex++;
        }
Beispiel #23
0
        void MakeTableWidget()
        {
            int         tableHeight = Math.Max(game.Height - tableY - 50, 1);
            TableWidget widget;

            if (widgets[tableIndex] != null)
            {
                widget = (TableWidget)widgets[tableIndex];
                if (widget.servers != game.Servers)
                {
                    ResetTable(widget);
                }
            }
            else
            {
                widget = new TableWidget(game);
                ResetTable(widget);
                widgets[widgetIndex] = widget;
            }

            widget.Height = tableHeight;
            widgetIndex++;
        }
        void CheckFetchStatus()
        {
            fetchTask.Tick();
            if (!fetchTask.Completed)
            {
                return;
            }

            if (fetchTask.Success)
            {
                game.Servers = fetchTask.Servers;
                FetchFlags(game);
            }

            view.RefreshText = fetchTask.Success ? "Refresh" : "&cFailed";
            fetchTask        = null;
            Resize();

            // needed to ensure 'highlighted server hash' is over right entry after refresh
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            table.SetSelected(widgets[view.hashIndex].Text);
            MarkPendingRedraw();
        }
Beispiel #25
0
        private TableWidget<TestType> CreateTableWidget(TableViewMock view, int? visibleRows = null, int? visibleColumns = null)
        {

            var widget = new TableWidget<TestType>(visibleRows, visibleColumns, view);
            widget.SetCoordinates(10, 10, 500, 500);
            return widget;
        }
        void ConnectToServer(int mouseX, int mouseY)
        {
            TableWidget table = (TableWidget)widgets[view.tableIndex];

            game.ConnectToServer(table.servers, Get(view.hashIndex));
        }