Пример #1
0
 protected virtual void refresh_layout()
 {
     for (int i = 0; i < num_items(); i++)
     {
         Items[i].loc  = item_loc(i);
         Items[i].Size = new Vector2(this.column_width, 16);
     }
     Items.refresh_destinations();
     Items.WrapVerticalMove = Columns == 1;
 }
Пример #2
0
        private void refresh(bool preserveIndex = false)
        {
            if (ItemNodes == null)
            {
                preserveIndex = false;
            }

            int index = 0;

            if (preserveIndex)
            {
                index = this.index;
            }

            Items1 = actor1.num_items;
            Items2 = actor2.num_items;

            int column = this.column;

            if (Items1 == 0)
            {
                column = 1;
            }

            Item_Imgs1.Clear();
            Item_Imgs2.Clear();

            List <CommandUINode> nodes = new List <CommandUINode>();

            bool add_empty_slot = Mode != 0 && !this.is_help_active;

            for (int i = 0; i < Num; i++)
            {
                if (i < Items1)
                {
                    item_node(0, i, nodes);
                    Item_Imgs1.Add(nodes.Last());
                }
                else if (add_empty_slot && Selected[0] == 1 && i == Items1)
                {
                    empty_slot_node(0, i, nodes);
                    Item_Imgs1.Add(nodes.Last());
                }

                if (i < Items2)
                {
                    item_node(1, i, nodes);
                    Item_Imgs2.Add(nodes.Last());
                }
                else if (add_empty_slot && Selected[0] == 0 && i == Items2)
                {
                    empty_slot_node(1, i, nodes);
                    Item_Imgs2.Add(nodes.Last());
                }
            }

            ItemNodes = new UINodeSet <CommandUINode>(nodes);
            ItemNodes.WrapVerticalSameColumn    = true;
            ItemNodes.CursorMoveSound           = System_Sounds.Menu_Move1;
            ItemNodes.HorizontalCursorMoveSound = System_Sounds.Menu_Move2;

            ItemNodes.AngleMultiplier   = 2f;
            ItemNodes.TangentDirections = new List <CardinalDirections>
            {
                CardinalDirections.Left, CardinalDirections.Right
            };
            ItemNodes.refresh_destinations();

            if (column == 0)
            {
                this.index1 = Math.Min(index, Items1 - 1);
            }
            else
            {
                this.index2 = Math.Min(index, Items2 - 1);
            }

            var old_cursor = UICursor;

            UICursor             = new UICursor <CommandUINode>(ItemNodes);
            UICursor.draw_offset = new Vector2(-12, 0);
            UICursor.ratio       = new int[] { 1, 1 };
            if (preserveIndex)
            {
                UICursor.force_loc(old_cursor.loc);
                UICursor.offset = old_cursor.offset;
            }

            Equipped_Tag1.loc = loc + new Vector2(SPACING - 16, actor1.equipped * 16 - 8);
            Equipped_Tag2.loc = loc + new Vector2(SPACING * 2 - 16, actor2.equipped * 16 - 8);
        }
Пример #3
0
        internal PreviousChapterSelectionMenu(
            Vector2 centerLoc,
            string chapterId,
            WorldmapMenuData menuData,
            IHasCancelButton menu = null)
        {
            ChapterId              = chapterId;
            ProgressionIds         = menuData.ValidPreviousChapters.Keys.ToList();
            ValidPreviousChapters  = menuData.ValidPreviousChapters;
            PreviousChapterIndices = menuData.UsablePreviousChapterIndices;

            Window        = new SystemWindowHeadered();
            Window.width  = 104;
            Window.height = 32 + 16 * (ValidPreviousChapters.Count + 1) + 4;
            Window.offset = new Vector2(0, 16);

            Loc = centerLoc -
                  (new Vector2(Window.width, Window.height) - Window.offset) / 2;

            Header             = new TextSprite();
            Header.draw_offset = new Vector2(8, -8);
            Header.SetFont(Config.UI_FONT, Global.Content, "Yellow");
            Header.text = ValidPreviousChapters.Count > 1 ? "Previous Chapters" : "Previous Chapter";

            Divider             = new StatusWindowDivider();
            Divider.draw_offset = new Vector2(8, Window.height - 44);
            Divider.SetWidth(Window.width - 16);

            LeftArrows  = new Dictionary <Page_Arrow, int>();
            RightArrows = new Dictionary <Page_Arrow, int>();

            // Center, then adjust left to account for map sprite
            int x = ((Window.width / 2) / 8 * 8) - 16;
            List <CommandUINode> nodes = new List <CommandUINode>();

            for (int i = 0; i < ProgressionIds.Count; i++)
            {
                int y = i * 16 + 8;

                var text = new TextSprite();
                text.SetFont(Config.UI_FONT, Global.Content, "White");
                text.text = chapter(i).Id;
                var node = new MapSpriteUINode("", text, 56);
                refresh_map_sprite(node, i);
                node.loc = new Vector2(x, y);
                nodes.Add(node);

                // Add arrows for this set of chapters,
                // if there's more than one choice
                if (chapter_list(i).Count > 1)
                {
                    var left_arrow = new Page_Arrow();
                    left_arrow.loc           = new Vector2(8, y);
                    left_arrow.ArrowClicked += LeftArrow_ArrowClicked;
                    LeftArrows.Add(left_arrow, i);

                    var right_arrow = new Page_Arrow();
                    right_arrow.loc           = new Vector2(Window.width - 8, y);
                    right_arrow.mirrored      = true;
                    right_arrow.ArrowClicked += RightArrow_ArrowClicked;
                    RightArrows.Add(right_arrow, i);
                }
            }

            // Add confirm choice
            var confirmText = new TextSprite(
                Config.UI_FONT, Global.Content, "White",
                new Vector2(4, 0),
                "Confirm");
            var confirm = new TextUINode("", confirmText, 56);

            confirm.loc = new Vector2(x, nodes.Count * 16 + 8 + 4);
            nodes.Add(confirm);

            Items = new UINodeSet <CommandUINode>(nodes);
            Items.WrapVerticalSameColumn    = true;
            Items.CursorMoveSound           = System_Sounds.Menu_Move1;
            Items.HorizontalCursorMoveSound = System_Sounds.Menu_Move2;

            Items.AngleMultiplier   = 2f;
            Items.TangentDirections = new List <CardinalDirections> {
                CardinalDirections.Left, CardinalDirections.Right
            };
            Items.refresh_destinations();

            Items.set_active_node(confirm);

            UICursor             = new UICursor <CommandUINode>(Items);
            UICursor.draw_offset = new Vector2(-12, 0);
            //UICursor.ratio = new int[] { 1, 3 }; //Debug

            CreateCancelButton(menu);
        }
Пример #4
0
        private void refresh_rankings(string chapter)
        {
            // Get the rankings based on the selected chapter
            var current_rankings = Global.save_file.all_rankings(chapter);
            var rankings         = current_rankings
                                   .ToDictionary(p => p.Key, p => p.Value);

            // Get the rankings of all other chapters, and show them greyed out
            if (SHOW_ALL_CHAPTERS)
            {
                // Sort chapters
                var rankedChapters = Global.Chapter_List
                                     .Where(x => !Global.data_chapters[x].Unranked)
                                     .GroupBy(x => Global.data_chapters[x].Arc)
                                     .OrderBy(x =>
                {
                    int index = Constants.WorldMap.GAME_ARCS.Count;
                    if (Constants.WorldMap.GAME_ARCS.Contains(x.Key))
                    {
                        index = Constants.WorldMap.GAME_ARCS.IndexOf(x.Key);
                    }
                    return(index);
                })
                                     .SelectMany(x => x
                                                 .OrderBy(y => Global.Chapter_List.IndexOf(y))
                                                 .ToList())
                                     .ToList();
                // Get all cleared chapters, and
                // their ranking data accoring to themselves
                rankings = rankedChapters
                           .Where(x => Global.save_file.ContainsKey(x))
                           .ToDictionary(x => x, x => Global.save_file.ranking(x));
                // Overwrite each chapter based on the current chapter's history
                foreach (var key in current_rankings.Keys)
                {
                    rankings[key] = current_rankings[key];
                }
                rankings = rankings
                           .OrderBy(x => rankedChapters.IndexOf(x.Key))
                           .ToDictionary(p => p.Key, p => p.Value);
            }

            Rankings = rankings.ToList();

            int i = 0;
            List <TextUINode> ranks = new List <TextUINode>();

            foreach (string ch in Global.Chapter_List)
            {
                var chapter_data = Global.data_chapters[ch];

                if (rankings.ContainsKey(ch))
                {
                    var ranking = rankings[ch];

                    // Color the label yellow for history of the current
                    // chapter, grey if just other data from this file
                    string color = current_rankings.ContainsKey(ch) ?
                                   "Yellow" : "Grey";
                    var text = new TextSprite();
                    text.SetFont(Config.UI_FONT, Global.Content, color);
                    text.text         = chapter_data.ListName;
                    text.stereoscopic = Config.OPTIONS_OPTIONS_DEPTH; //Yeti

                    var node = new RankingUINode("", text, COLUMN_WIDTH, ranking);
                    node.loc = DATA_OFFSET +
                               new Vector2((i / ROWS * COLUMN_WIDTH), (i % ROWS) * 16);

                    ranks.Add(node);
                    i++;
                }
            }

            Nodes = new UINodeSet <TextUINode>(ranks);
            Nodes.AngleMultiplier   = 4f;
            Nodes.TangentDirections = new List <CardinalDirections>
            {
                CardinalDirections.Left, CardinalDirections.Right
            };
            Nodes.refresh_destinations();

            Cursor             = new UICursor <TextUINode>(Nodes);
            Cursor.draw_offset = new Vector2(-16, 0);
        }