Пример #1
0
        private void SnapToClosestBar(double position, GroupChartItem selectedItem)
        {
            var selectedValues = new SelectedChartValueItemArgs
            {
                ChartValueItems = new List <ChartValueItemParam>(),
                TouchedPoint    = TouchedPoint
            };

            foreach (var chartEntry in ChartEntries.Where(x => x.IsVisible))
            {
                var chartEntryItem = chartEntry.Items.FirstOrDefault(i => i.Tag.ToString() == selectedItem.Tag.ToString());

                if (chartEntryItem == null)
                {
                    continue;
                }

                selectedValues.ChartValueItems.Add(new ChartValueItemParam(chartEntryItem, null, chartEntry));
            }

            // Invoke command with selected items
            SelectedValuesCommand?.Execute(selectedValues);

            Device.BeginInvokeOnMainThread(async() =>
            {
                isSnapping = true;

                ScrollComponent.Scrolled -= ScrollComponent_Scrolled;

                SelectedLabel = selectedItem.Label;

                lastScrollPosition = position;

                await ScrollComponent.ScrollToAsync(lastScrollPosition, 0, false);

                ShowSwipeNotifications(lastScrollPosition);

                ScrollComponent.Scrolled += ScrollComponent_Scrolled;

                isSnapping = false;
            });
        }
Пример #2
0
    private static void initComponent(Children child, GameObject parentObj, string fileName = "")
    {
        var propStr = child.options.property;
        var props   = propStr.Split('\r');
        var prop    = new Property();

        prop.DeserializeProperty(props);

        GameObject tempObj  = null;
        GameObject childObj = null;

        if ((child.classname == "LABEL") && (!prop.isInput))
        {
            childObj = TextComponent.InitTextComponent(child, parentObj);
        }
        else if ((child.classname == "LABEL") && (prop.isInput))
        {
            childObj = TextFieldComponent.InitTextFieldComponent(child, parentObj);
        }
        else if (child.classname == "IMAGE")
        {
            childObj = ImageComponent.InitImageComponent(child, parentObj, fileName);
        }
        else if (child.classname == "GROUP")
        {
            childObj = RectComponent.InitRectComponent(child, parentObj);
        }
        else if (child.classname == "LIST")
        {
            childObj = ScrollComponent.InitComponent(child, parentObj);
        }

        if ((child.children.Length > 0) && (childObj != null))
        {
            for (int i = child.children.Length - 1; i >= 0; i--)
            {
                initComponent(child.children [i], childObj, fileName);
            }
        }
    }
Пример #3
0
        public QuestsPage(string name, string title, int x, int y, int width, int height, Texture2D tabTexture, Rectangle tabSourceRect, ITranslationHelper translation) :
            base(name, title, x, y, width, height, tabTexture, tabSourceRect, translation)
        {
            questButtons   = new List <ClickableComponent>();
            _pages         = new List <List <IQuest> >();
            _objectiveText = new List <string>();

            Game1.dayTimeMoneyBox.DismissQuestPing();
            PaginateQuests();

            Rectangle bounds = new Rectangle(xPositionOnScreen + 16, 0, width - 32, (height - 32) / 6 + 4);

            for (int i = 0; i < 6; ++i)
            {
                bounds.Y = yPositionOnScreen + 16 + i * ((height - 32) / 6);
                questButtons.Add(new ClickableComponent(bounds, i.ToString())
                {
                    myID            = i,
                    upNeighborID    = i - 1,
                    downNeighborID  = CUSTOM_SNAP_BEHAVIOR,
                    rightNeighborID = CUSTOM_SNAP_BEHAVIOR,
                    leftNeighborID  = CUSTOM_SNAP_BEHAVIOR,
                    fullyImmutable  = true
                });
            }

            forwardButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + width + 16, yPositionOnScreen + height - 48, 48, 44),
                Game1.mouseCursors,
                new Rectangle(365, 495, 12, 11),
                4f)
            {
                myID = 101
            };

            backButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen - 128, yPositionOnScreen + 8, 48, 44),
                Game1.mouseCursors,
                new Rectangle(352, 495, 12, 11),
                4f)
            {
                myID                  = 102,
                rightNeighborID       = CUSTOM_SNAP_BEHAVIOR,
                downNeighborID        = CUSTOM_SNAP_BEHAVIOR,
                downNeighborImmutable = true
            };

            rewardBox = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + width / 2 - 80, yPositionOnScreen + height - 128, 96, 96),
                Game1.mouseCursors,
                new Rectangle(293, 360, 24, 24),
                4f, drawShadow: true)
            {
                myID = 103
            };

            cancelQuestButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + 4, yPositionOnScreen + height + 4, 48, 48),
                Game1.mouseCursors,
                new Rectangle(322, 498, 12, 12),
                4f, drawShadow: true)
            {
                myID = 104
            };

            Rectangle scrollBarBounds     = new Rectangle(x + width + 16, y + 148, 24, height - 216);
            Rectangle scrollContentBounds = default;

            scrollContentBounds.X      = x + 32;
            scrollContentBounds.Y      = y + 96;
            scrollContentBounds.Width  = width - 64;
            scrollContentBounds.Height = y + height - 32 - scrollContentBounds.Y;
            scrollContentBounds        = Utility.ConstrainScissorRectToScreen(scrollContentBounds);

            scrollComponent = new ScrollComponent(scrollBarBounds, scrollContentBounds, 32, false);

            exitFunction = () => Game1.activeClickableMenu?.exitThisMenu();
        }
Пример #4
0
        public TasksPage(string name, string title, int x, int y, int width, int height, Texture2D tabTexture, Rectangle tabSourceRect, ITranslationHelper translation) :
            base(name, title, x, y, width, height, tabTexture, tabSourceRect, translation)
        {
            if (DeluxeJournalMod.Instance?.Config is not Config config)
            {
                throw new InvalidOperationException("TasksPage created before mod entry.");
            }

            if (DeluxeJournalMod.Instance?.TaskManager is not TaskManager taskManager)
            {
                throw new InvalidOperationException("TasksPage created before instantiation of TaskManager");
            }

            _config                = config;
            _taskManager           = taskManager;
            _dragScrollInterval    = 0.16;
            _dragScrollStartTime   = 0;
            _currentlySnappedEntry = 0;
            _selectedTaskIndex     = -1;
            _dragging              = false;
            taskEntries            = new List <TaskEntryComponent>();
            moneyDial              = new MoneyDial(8, false);

            Rectangle bounds = new Rectangle(x + 16, y + 16, width - 32, (height - 32) / maxEntries);

            for (int i = 0; i < maxEntries; i++)
            {
                bounds.Y = y + 20 + i * bounds.Height;
                taskEntries.Add(new TaskEntryComponent(bounds, i.ToString(), Translation)
                {
                    myID            = i,
                    upNeighborID    = CUSTOM_SNAP_BEHAVIOR,
                    downNeighborID  = CUSTOM_SNAP_BEHAVIOR,
                    rightNeighborID = CUSTOM_SNAP_BEHAVIOR,
                    leftNeighborID  = CUSTOM_SNAP_BEHAVIOR,
                    fullyImmutable  = true
                });
            }

            addTaskButton = new ClickableTextureComponent(
                new Rectangle(x + width - 336, y + height, 60, 60),
                DeluxeJournalMod.UiTexture,
                new Rectangle(0, 32, 15, 17),
                4f)
            {
                myID                   = 1000,
                upNeighborID           = CUSTOM_SNAP_BEHAVIOR,
                leftNeighborID         = CUSTOM_SNAP_BEHAVIOR,
                rightNeighborID        = 1001,
                rightNeighborImmutable = true
            };

            moneyButton = new ClickableTextureComponent(
                new Rectangle(x + width - 260, y + height + 20, 24, 36),
                DeluxeJournalMod.UiTexture,
                new Rectangle(85, 37, 6, 9),
                4f)
            {
                myID            = 1001,
                upNeighborID    = CUSTOM_SNAP_BEHAVIOR,
                rightNeighborID = 1002,
                leftNeighborID  = 1000,
                fullyImmutable  = true
            };

            moneyBox = new ClickableComponent(new Rectangle(x + width - 236, y + height, 236, 68), "moneyBox")
            {
                myID           = 1002,
                upNeighborID   = CUSTOM_SNAP_BEHAVIOR,
                leftNeighborID = 1001,
                fullyImmutable = true
            };

            Rectangle scrollBarBounds     = new Rectangle(x + width + 16, y + 148, 24, height - 216);
            Rectangle scrollContentBounds = new Rectangle(x, y + 16, width, height - 32);

            scrollComponent = new ScrollComponent(scrollBarBounds, scrollContentBounds, (height - 32) / 8, true);
            scrollComponent.ContentHeight = _taskManager.Tasks.Count * scrollComponent.ScrollDistance;

            _boundsWithScrollBar = new Rectangle(x, y, scrollBarBounds.Right - x + 16, height);

            RefreshMoneyDial();
        }