public override void add_choice(string str, Vector2 loc)
        {
            List <TextUINode> choices = Choices == null ?
                                        new List <TextUINode>() : Choices.ToList();

            var text = new TextSprite();

            text.SetFont(Tactile.Config.UI_FONT, Global.Content, "White");
            text.text = str;

            var node = new TextUINode("", text, text.text_width);

            node.loc = loc;
            choices.Add(node);

            Choices = new UINodeSet <TextUINode>(choices);
            Cursor  = new UICursor <TextUINode>(Choices);
            Cursor.hide_when_using_mouse(false);
            // Resize if needed
            int width = Font_Data.text_width(str, Tactile.Config.UI_FONT);

            width = width + (width % 8 == 0 ? 0 : (8 - width % 8)) + 16 + (int)loc.X;
            if (width > Size.X)
            {
                size = new Vector2(width, Size.Y);
            }
        }
        public DifficultySelectionMenu()
        {
            DifficultyPanels = new Difficulty_Info_Panel[Enum_Values.GetEnumCount(typeof(Difficulty_Modes))];
            int offset = 0;

            for (int i = 0; i < DifficultyPanels.Length; i++)
            {
                DifficultyPanels[i] = new Difficulty_Info_Panel((Difficulty_Modes)i);
                DifficultyPanels[i].stereoscopic = Config.TITLE_MENU_DEPTH;
                DifficultyPanels[i].active       = false;
                DifficultyPanels[i].loc          = new Vector2(0, offset);
                offset += DifficultyPanels[i].height + 8;
            }

            MenuLoc = new Vector2(
                (Config.WINDOW_WIDTH - Difficulty_Info_Panel.WIDTH) / 2,
                (Config.WINDOW_HEIGHT - 16) / 2);
            MenuLoc -= new Vector2(0, (offset / 2) / 8 * 8);

            DifficultyNodes = new UINodeSet <Difficulty_Info_Panel>(DifficultyPanels);
            DifficultyNodes.set_active_node(DifficultyNodes[(int)Difficulty_Modes.Normal]);
            DifficultyNodes.ActiveNode.active = true;

            CancelButton = Button_Description.button(Inputs.B,
                                                     Config.WINDOW_WIDTH - 64);
            CancelButton.description  = "Cancel";
            CancelButton.stereoscopic = Config.TITLE_MENU_DEPTH;
        }
示例#3
0
        public StyleSelectionMenu()
        {
            StylePanels = new Mode_Style_Info_Panel[Enum_Values.GetEnumCount(typeof(Mode_Styles))];
            int offset = 0;

            for (int i = 0; i < StylePanels.Length; i++)
            {
                StylePanels[i] = new Mode_Style_Info_Panel((Mode_Styles)i);
                StylePanels[i].stereoscopic = Config.TITLE_MENU_DEPTH;
                StylePanels[i].active       = false;
                StylePanels[i].loc          = new Vector2(0, offset);
                offset += StylePanels[i].height + 8;
            }

            MenuLoc = new Vector2(
                (Config.WINDOW_WIDTH - Mode_Style_Info_Panel.WIDTH) / 2,
                (Config.WINDOW_HEIGHT - 16) / 2);
            MenuLoc -= new Vector2(0, (offset / 2) / 8 * 8);

            StyleNodes = new UINodeSet <Mode_Style_Info_Panel>(StylePanels);
            StyleNodes.set_active_node(StyleNodes[(int)Mode_Styles.Standard]);
            StyleNodes.ActiveNode.active = true;

            CancelButton = Button_Description.button(Inputs.B,
                                                     Config.WINDOW_WIDTH - 64);
            CancelButton.description  = "Cancel";
            CancelButton.stereoscopic = Config.TITLE_MENU_DEPTH;
        }
示例#4
0
        protected void set_choices(int ox, string str1, string str2)
        {
            List <TextUINode> choices = new List <TextUINode>();

            var text1 = new TextSprite();

            text1.SetFont(Config.CONVO_FONT, Global.Content, "White");
            text1.text = str1;

            var node = new TextUINode("", text1, text1.text_width);

            node.loc = new Vector2(88 + ox, 32);
            choices.Add(node);

            var text2 = new TextSprite();

            text2.SetFont(Config.CONVO_FONT, Global.Content, "White");
            text2.text = str2;

            node     = new TextUINode("", text2, text2.text_width);
            node.loc = new Vector2(88 + ox + 40, 32);
            choices.Add(node);

            Choices            = new UINodeSet <TextUINode>(choices);
            Cursor             = new UICursor <TextUINode>(Choices);
            Cursor.draw_offset = new Vector2(-16, 0);
            Cursor.ratio       = new int[] { 1, 1 };
            Cursor.hide_when_using_mouse(false);
            Cursor.move_to_target_loc();
        }
示例#5
0
        protected virtual void set_nodes(List <CommandUINode> nodes)
        {
            Items = new UINodeSet <CommandUINode>(nodes);
            Items.CursorMoveSound  = System_Sounds.Menu_Move1;
            Items.WrapVerticalMove = true;

            UICursor             = new UICursor <CommandUINode>(Items);
            UICursor.draw_offset = new Vector2(-16, 0);
            UICursor.ratio       = new int[] { 1, 1 };
        }
示例#6
0
        public override void set_images(Game_Unit unit)
        {
            if (Global.ActorConfig.ShowAllActorWeaponTypes)
            {
                // Add potential WLvls
                var nodes = StatusPageNodes.ToList();
                foreach (var weapon_type in TemporaryWLvls)
                {
                    nodes.Remove(weapon_type);
                }

                HashSet <int> weapon_type_indices = new HashSet <int>();
                HashSet <int> added_weapon_types  = new HashSet <int>();
                foreach (var weapon_type in Global.weapon_types.Where(x => x.DisplayedInStatus))
                {
                    added_weapon_types.Add(weapon_type.Key);
                    weapon_type_indices.Add(weapon_type.StatusIndex);
                }
                int index = 0;
                foreach (var weapon_type in Global.weapon_types
                         .Where(x => !x.DisplayedInStatus)
                         .OrderBy(x => x.StatusIndex))
                {
                    if (unit.actor.has_rank(weapon_type))
                    {
                        while (weapon_type_indices.Contains(index))
                        {
                            index++;
                        }
                        var node = weapon_type_icon(weapon_type, index);
                        nodes.Add(node);
                        TemporaryWLvls.Add(node);

                        added_weapon_types.Add(weapon_type.Key);
                        weapon_type_indices.Add(index);
                    }
                }

                StatusPageNodes = new UINodeSet <StatusUINode>(nodes);

                int wlvl_rows = (int)Math.Ceiling(added_weapon_types.Count / (float)WLVL_COLUMNS);
                WLvls_Window.height = (wlvl_rows + 1) * 16;
            }
            // Refresh UI nodes
            refresh(unit);
        }
示例#7
0
        public ExtrasMenu() : base()
        {
            MenuChoices.Add(new MainMenuChoicePanel("Sound Room"));
            MenuChoices.Add(new MainMenuChoicePanel("Supports"));
            MenuChoices.Add(new MainMenuChoicePanel("Credits"));

            MenuChoices[(int)ExtrasSelections.SoundRoom].Visible     = Global.progress.SoundRoomAccessible;
            MenuChoices[(int)ExtrasSelections.SupportViewer].Visible = Global.progress.SupportViewerAccessible;

            RefreshLocs();

            IEnumerable <MainMenuChoicePanel> nodes = new List <MainMenuChoicePanel>(MenuChoices);

            nodes = nodes.Where(x => x.Visible);

            ChoiceNodes = new UINodeSet <MainMenuChoicePanel>(nodes);
            ChoiceNodes.CursorMoveSound  = System_Sounds.Menu_Move1;
            ChoiceNodes.SoundOnMouseMove = true;

            ChoiceNodes.set_active_node(nodes.FirstOrDefault());
            Selection = (ExtrasSelections)MenuChoices.IndexOf(ChoiceNodes.ActiveNode);
            RefreshLocs();
        }
示例#8
0
        internal void RefreshMenuChoices()
        {
            SuspendExists = Global.suspend_file_info != null;
            MenuChoices[(int)Main_Menu_Selections.Resume].Visible = SuspendExists;
            MenuChoices[(int)Main_Menu_Selections.Extras].Visible = Global.progress.ExtrasAccessible;

            if (SuspendExists)
            {
                SuspendPanel              = new Suspend_Info_Panel(true);
                SuspendPanel.loc          = new Vector2(-16, 8);
                SuspendPanel.stereoscopic = Config.TITLE_MENU_DEPTH;
            }
            else
            {
                SuspendPanel = null;
            }

            StartGamePanel = new StartGame_Info_Panel(
                Global.latest_save_id, MainMenuChoicePanel.PANEL_WIDTH, true);
            // Show preview of the latest save, if there is one
            StartGamePanel.active       = Global.latest_save_id != -1;
            StartGamePanel.loc          = new Vector2(-16, 8);
            StartGamePanel.stereoscopic = Config.TITLE_MENU_DEPTH;

            RefreshLocs();

            IEnumerable <MainMenuChoicePanel> nodes = new List <MainMenuChoicePanel>(MenuChoices);

            nodes       = nodes.Where(x => x.Visible);
            ChoiceNodes = new UINodeSet <MainMenuChoicePanel>(nodes);
            ChoiceNodes.CursorMoveSound  = System_Sounds.Menu_Move1;
            ChoiceNodes.SoundOnMouseMove = true;

            ChoiceNodes.set_active_node(MenuChoices[(int)Selection]);
            RefreshLocs();
        }
示例#9
0
        private void initialize(int fileId)
        {
            Cursor                   = new Hand_Cursor();
            Cursor.draw_offset       = new Vector2(-8, 4);
            Cursor.stereoscopic      = Config.TITLE_MENU_DEPTH;
            Move_Cursor              = new Hand_Cursor();
            Move_Cursor.draw_offset  = new Vector2(-8, 4);
            Move_Cursor.tint         = new Color(160, 160, 160, 255);
            Move_Cursor.stereoscopic = Config.TITLE_MENU_DEPTH;

            for (int i = 0; i < Panels.Length; i++)
            {
                Panels[i] = new StartGame_Info_Panel(Page * Config.SAVES_PER_PAGE + i + 1, PANEL_WIDTH);
                Panels[i].stereoscopic = Config.TITLE_MENU_DEPTH;
            }

            refresh_panel_locations();
            PanelNodes = new UINodeSet <StartGame_Info_Panel>(Panels);
            PanelNodes.CursorMoveSound  = System_Sounds.Menu_Move1;
            PanelNodes.WrapVerticalMove = true;

            // Page Arrows
            Left_Page_Arrow                = new Page_Arrow();
            Left_Page_Arrow.loc            = new Vector2(-4, 68);
            Left_Page_Arrow.stereoscopic   = Config.TITLE_MENU_DEPTH - 1;
            Left_Page_Arrow.ArrowClicked  += Left_Page_Arrow_ArrowClicked;
            Right_Page_Arrow               = new Page_Arrow();
            Right_Page_Arrow.loc           = new Vector2(PANEL_WIDTH - 4, 68);
            Right_Page_Arrow.mirrored      = true;
            Right_Page_Arrow.stereoscopic  = Config.TITLE_MENU_DEPTH - 1;
            Right_Page_Arrow.ArrowClicked += Right_Page_Arrow_ArrowClicked;

            create_cancel_button();

            this.file_id = fileId;
        }
示例#10
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);
        }
示例#11
0
        public Status_Page_1()
        {
            var nodes = new List <StatusUINode>();

            // Stats Window
            Stats_Window              = new System_Color_Window();
            Stats_Window.loc          = new Vector2(8, 80);
            Stats_Window.width        = 144;
            Stats_Window.height       = 112;
            Stats_Window.stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
            // Stats
            for (int i = 0; i < 6; i++)
            {
                string help_label;
                string label;

                var stat_label = (Stat_Labels)i + 1;

                Vector2 loc = Stats_Window.loc + new Vector2(8, i * 16 + 8);
                PrimaryStatState.label((Stat_Labels)i + 1, out label, out help_label);

                Func <Game_Unit, PrimaryStatState> stat_formula = (Game_Unit unit) =>
                {
                    return(new PrimaryStatState(unit, stat_label));
                };

                Func <Game_Unit, Color> label_color = null;
                if (Window_Status.show_stat_colors(stat_label))
                {
                    label_color = (Game_Unit unit) =>
                    {
                        if (unit.average_stat_hue_shown)
                        {
                            return(unit.actor.stat_color(stat_label));
                        }
                        return(Color.White);
                    };
                }

                nodes.Add(new StatusPrimaryStatUINode(
                              help_label, label, stat_formula, label_color, 40));
                nodes.Last().loc          = loc;
                nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
#if DEBUG
                nodes.Last().set_cheat(stat_cheat(stat_label));
#endif

                if (stat_label == Stat_Labels.Pow)
                {
                    PowNode = nodes.Last() as StatusStatUINode;
                }
            }

            // Move
            nodes.Add(new StatusPrimaryStatUINode(
                          "Move",
                          "Move",
                          (Game_Unit unit) =>
            {
                if (unit.immobile)
                {
                    return new PrimaryStatState
                    {
                        Stat     = 0,
                        Bonus    = 0,
                        Cap      = unit.stat_cap(Stat_Labels.Mov),
                        NullStat = true,
                    }
                }
                ;
                return(new PrimaryStatState
                {
                    Stat = unit.base_mov,
                    Bonus = unit.mov - unit.base_mov,
                    Cap = unit.stat_cap(Stat_Labels.Mov),
                });
            }, null, 40));
            nodes.Last().loc          = Stats_Window.loc + new Vector2(72, 0 * 16 + 8);
            nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
#if DEBUG
            nodes.Last().set_cheat(stat_cheat(Stat_Labels.Mov));
#endif
            // Con
            nodes.Add(new StatusPrimaryStatUINode(
                          "Con",
                          "Con",
                          (Game_Unit unit) =>
            {
                return(new PrimaryStatState
                {
                    Stat = unit.actor.stat(Stat_Labels.Con),
                    Bonus = Math.Min(unit.stat_bonus(Stat_Labels.Con),
                                     unit.actor.cap_base_difference(Stat_Labels.Con)),
                    Cap = unit.stat_cap(Stat_Labels.Con),
                    IsCapped = unit.actor.get_capped(Stat_Labels.Con)
                });
            }, null, 40));
            nodes.Last().loc          = Stats_Window.loc + new Vector2(72, 1 * 16 + 8);
            nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
#if DEBUG
            nodes.Last().set_cheat(stat_cheat(Stat_Labels.Con));
#endif
            // Aid
            nodes.Add(new StatusAidUINode(
                          "Aid",
                          "Aid",
                          (Game_Unit unit) =>
            {
                return(unit.aid().ToString());
            },
                          (Game_Unit unit) =>
            {
                if (unit.actor.actor_class.Class_Types.Contains(ClassTypes.FDragon))
                {
                    return(3);
                }
                else if (unit.actor.actor_class.Class_Types.Contains(ClassTypes.Flier))
                {
                    return(2);
                }
                else if (unit.actor.actor_class.Class_Types.Contains(ClassTypes.Cavalry))
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }, 40));
            nodes.Last().loc          = Stats_Window.loc + new Vector2(72, 2 * 16 + 8);
            nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
            // Trv
            nodes.Add(new StatusTravelerUINode(
                          "Trv",
                          "Trv",
                          (Game_Unit unit) =>
            {
                if (unit.is_rescued)
                {
                    return(Global.game_map.units[unit.rescued].actor.name);
                }
                else if (unit.is_rescuing)
                {
                    return(Global.game_map.units[unit.rescuing].actor.name);
                }
                return("---");
            },
                          (Game_Unit unit) =>
            {
                if (!unit.is_rescuing)
                {
                    return(0);
                }
                return(Global.game_map.units[unit.rescuing].team);
            }, 24));
            nodes.Last().loc          = Stats_Window.loc + new Vector2(72, 3 * 16 + 8);
            nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
            // Type
            nodes.Add(new StatusClassTypesUINode(
                          "Type",
                          "Type",
                          (Game_Unit unit) =>
            {
                return(unit.actor.class_types);
            }, 24));
            nodes.Last().loc          = Stats_Window.loc + new Vector2(72, 4 * 16 + 8);
            nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
            // Rating
            nodes.Add(new StatusLabeledTextUINode(
                          "Rating",
                          "Rating",
                          (Game_Unit unit) =>
            {
                return(unit.rating().ToString());
            }, 32));
            nodes.Last().loc          = Stats_Window.loc + new Vector2(72, 5 * 16 + 8);
            nodes.Last().Size         = new Vector2(64, 16);
            nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;

            // Items Window
            Items_Window              = new System_Color_Window();
            Items_Window.loc          = new Vector2(168, 80);
            Items_Window.width        = 144;
            Items_Window.height       = Global.ActorConfig.NumItems * 16 + 16;
            Items_Window.stereoscopic = Config.STATUS_RIGHT_WINDOW_DEPTH;

            // Skill Bg
            SiegeBg     = new Status_Support_Background();
            SiegeBg.loc = Items_Window.loc + new Vector2(
                8, 8 + (Global.ActorConfig.NumItems - 1) * 16);
            SiegeBg.stereoscopic = Config.STATUS_RIGHT_WINDOW_DEPTH;
            SiegeBg.visible      = false;

            // Items
            for (int i = 0; i < Global.ActorConfig.NumItems; i++)
            {
                int j = i;

                Vector2 loc = Items_Window.loc + new Vector2(8, i * 16 + 8);

                nodes.Add(new StatusItemUINode(
                              string.Format("Item{0}", i + 1),
                              (Game_Unit unit) =>
                {
                    return(new ItemState
                    {
                        Item = unit.actor.items[j],
                        Drops = unit.drops_item && j == unit.actor.num_items - 1,
                        Equipped = unit.actor.equipped - 1 == j
                    });
                }));
                nodes.Last().loc          = loc;
                nodes.Last().stereoscopic = Config.STATUS_RIGHT_WINDOW_DEPTH;
                Func <Game_Unit, DirectionFlags, bool> item_cheat = (unit, dir) =>
                {
                    // Uses
                    if (dir.HasFlag(DirectionFlags.Up) || dir.HasFlag(DirectionFlags.Down))
                    {
                        if (unit.actor.items[j].non_equipment ||
                            unit.actor.items[j].infinite_uses)
                        {
                            return(false);
                        }
                        int uses = unit.actor.items[j].Uses;
                        if (dir.HasFlag(DirectionFlags.Up))
                        {
                            uses++;
                        }
                        else
                        {
                            uses--;
                        }
                        uses = Math.Max(Math.Min(
                                            uses, unit.actor.items[j].max_uses), 1);
                        if (uses == unit.actor.items[j].Uses)
                        {
                            return(false);
                        }
                        unit.actor.items[j].Uses = uses;
                        return(true);
                    }
                    else
                    {
                        // Change item
                        if (unit.actor.items[j].is_weapon)
                        {
                            List <int> weapon_keys = Global.data_weapons.Keys.ToList();
                            int        index       = weapon_keys.IndexOf(unit.actor.items[j].Id);
                            if (dir.HasFlag(DirectionFlags.Right))
                            {
                                index++;
                            }
                            else if (dir.HasFlag(DirectionFlags.Left))
                            {
                                index--;
                            }
                            else
                            {
                                return(false);
                            }
                            index = (index + weapon_keys.Count) % weapon_keys.Count;
                            unit.actor.items[j].Id = weapon_keys[index];
                            unit.actor.setup_items(false);
                        }
                        else
                        {
                            List <int> item_keys = Global.data_items.Keys.ToList();
                            int        index     = item_keys.IndexOf(unit.actor.items[j].Id);
                            if (dir.HasFlag(DirectionFlags.Right))
                            {
                                index++;
                            }
                            else if (dir.HasFlag(DirectionFlags.Left))
                            {
                                index--;
                            }
                            else
                            {
                                return(false);
                            }
                            index = (index + item_keys.Count) % item_keys.Count;
                            unit.actor.items[j].Id = item_keys[index];
                        }
                        if (unit.actor.items[j].infinite_uses)
                        {
                            unit.actor.items[j].Uses = -1;
                        }
                        else
                        {
                            if (unit.actor.items[j].Uses == -1)
                            {
                                unit.actor.items[j].Uses = 1;
                            }
                        }
                        return(true);
                    }
                };
#if DEBUG
                nodes.Last().set_cheat(item_cheat);
#endif
            }

            // Siege engine
            Vector2 siege_loc = Items_Window.loc +
                                new Vector2(8, (Global.ActorConfig.NumItems - 1) * 16 + 8 + 2);

            nodes.Add(new StatusSiegeItemUINode(
                          string.Format("Item{0}", Global.ActorConfig.NumItems + 1),
                          (Game_Unit unit) =>
            {
                Item_Data siege = new Item_Data();
                if (!unit.actor.is_full_items && unit.is_on_siege())
                {
                    siege = unit.items[Siege_Engine.SiegeInventoryIndex];
                }

                return(new ItemState
                {
                    Item = siege,
                    Drops = false,
                    Equipped = false
                });
            }));
            nodes.Last().loc          = siege_loc;
            nodes.Last().stereoscopic = Config.STATUS_RIGHT_WINDOW_DEPTH;


            StatusPageNodes = new UINodeSet <StatusUINode>(nodes);

            init_design();
        }
示例#12
0
 protected void clear_choices()
 {
     Choices = null;
     Cursor  = null;
 }
示例#13
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);
        }
示例#14
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);
        }
示例#15
0
        public Status_Page_2()
        {
            var nodes = new List <StatusUINode>();

            // Skills Window
            Skills_Window              = new System_Color_Window();
            Skills_Window.loc          = new Vector2(8, 96);
            Skills_Window.width        = 144;
            Skills_Window.height       = 96;
            Skills_Window.stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;

            // WLvls Window
            int max_wlvl_index = 0;

            if (Global.weapon_types.Any(x => x.DisplayedInStatus))
            {
                max_wlvl_index = Global.weapon_types
                                 .Where(x => x.DisplayedInStatus)
                                 .Max(x => x.StatusIndex);
            }
            // @Debug: this doesn't really do what it's supposed to,
            // and the window height will be set in set_images() anyway
            int wlvl_rows = (max_wlvl_index / WLVL_COLUMNS) + 1;

            WLvls_Window              = new System_Color_Window();
            WLvls_Window.loc          = new Vector2(168, 96);
            WLvls_Window.width        = 144;
            WLvls_Window.height       = (wlvl_rows + 1) * 16; // 96; //Debug
            WLvls_Window.stereoscopic = Config.STATUS_RIGHT_WINDOW_DEPTH;

            // Skill Bg
            Skill_Bg              = new Status_Support_Background();
            Skill_Bg.loc          = Skills_Window.loc + new Vector2(8, 8 + ACTOR_SKILLS * 16);
            Skill_Bg.stereoscopic = Config.STATUS_RIGHT_WINDOW_DEPTH;

            // Skills
            for (int i = 0; i < ACTOR_SKILLS; i++)
            {
                int j = i;

                Vector2 loc = Skills_Window.loc +
                              new Vector2(8, 8 + (Config.SKILL_ICON_SIZE - 16) / 2 +
                                          i * Config.SKILL_ICON_SIZE);

                nodes.Add(new StatusSkillUINode(
                              string.Format("Skill{0}", i + 1),
                              (Game_Unit unit) =>
                {
                    if (unit.actor.skills.Count <= j)
                    {
                        return(new SkillState());
                    }
                    var skill = Global.data_skills[unit.actor.skills[j]];

                    float charge = -1f;
                    if (Game_Unit.MASTERIES.Contains(skill.Abstract))
                    {
                        charge = unit.mastery_charge_percent(skill.Abstract);
                    }
                    return(new SkillState
                    {
                        Skill = skill,
                        Charge = charge
                    });
                }));
                nodes.Last().loc         = loc;
                nodes.Last().draw_offset = new Vector2(
                    0, -(Config.SKILL_ICON_SIZE - 16) / 2);
                nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
#if DEBUG
                // Charges skill gauges
                Func <Game_Unit, DirectionFlags, bool> skill_cheat = (unit, dir) =>
                {
                    if (unit.actor.skills.Count > j)
                    {
                        var skill = Global.data_skills[unit.actor.skills[j]];
                        if (Game_Unit.MASTERIES.Contains(skill.Abstract))
                        {
                            int charge = 0;
                            if (dir.HasFlag(DirectionFlags.Right))
                            {
                                charge = 1;
                            }
                            else if (dir.HasFlag(DirectionFlags.Left))
                            {
                                charge = -1;
                            }

                            unit.charge_masteries(skill.Abstract,
                                                  charge * Game_Unit.MASTERY_RATE_NEW_TURN);
                            return(charge != 0);
                        }
                    }
                    return(false);
                };
                nodes.Last().set_cheat(skill_cheat);
#endif
            }
            for (int i = 0; i < ITEM_SKILLS; i++)
            {
                int j = i;

                Vector2 loc = Skills_Window.loc +
                              new Vector2(8 + (Config.SKILL_ICON_SIZE - 16) / 2 +
                                          i * Config.SKILL_ICON_SIZE, 72 + 2);

                nodes.Add(new StatusSkillIconUINode(
                              string.Format("Item Skill{0}", i + 1),
                              (Game_Unit unit) =>
                {
                    if (unit.actor.item_skills.Count <= j)
                    {
                        return(new SkillState());
                    }
                    var skill = Global.data_skills[unit.actor.item_skills[j]];

                    float charge = -1f;
                    if (Game_Unit.MASTERIES.Contains(skill.Abstract))
                    {
                        charge = unit.mastery_charge_percent(skill.Abstract);
                    }
                    return(new SkillState
                    {
                        Skill = skill,
                        Charge = charge
                    });
                }));
                nodes.Last().loc         = loc;
                nodes.Last().draw_offset = new Vector2(
                    0, -(Config.SKILL_ICON_SIZE - 16) / 2);
                nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
            }
            // WLvls
            foreach (var weapon_type in Global.weapon_types)
            {
                if (!weapon_type.DisplayedInStatus)
                {
                    continue;
                }

                nodes.Add(weapon_type_icon(weapon_type, weapon_type.StatusIndex));
            }

            StatusPageNodes = new UINodeSet <StatusUINode>(nodes);

            init_design();
        }
示例#16
0
        public Status_Page_3()
        {
            var nodes = new List <StatusUINode>();

            // Bonuses Window
            Bonuses_Window              = new System_Color_Window();
            Bonuses_Window.loc          = new Vector2(8, 80);
            Bonuses_Window.width        = 144;
            Bonuses_Window.height       = 112;
            Bonuses_Window.stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
            // Status Label
            nodes.Add(new StatusTextUINode(
                          "Cond",
                          (Game_Unit unit) => "Status"));
            nodes.Last().loc = Bonuses_Window.loc + new Vector2(16, 8);
            (nodes.Last() as StatusTextUINode).set_color("Yellow");
            nodes.Last().Size         = new Vector2(32, 16);
            nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;

            // Statuses
            for (int i = 0; i < ACTOR_STATUSES; i++)
            {
                int j = i;

                Vector2 loc = Bonuses_Window.loc + new Vector2(48 + i * 16, 8);

                nodes.Add(new StatusStateUINode(
                              string.Format("Status{0}", i + 1),
                              (Game_Unit unit) =>
                {
                    if (unit.actor.states.Count <= j)
                    {
                        return(new Tuple <int, int>(-1, 0));
                    }

                    int id    = unit.actor.states[j];
                    int turns = unit.actor.state_turns_left(id);

                    return(new Tuple <int, int>(id, turns));
                }));
                nodes.Last().loc          = loc;
                nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
            }

            // Bond
            nodes.Add(new StatusLabeledTextUINode(
                          "Bond",
                          "Bond",
                          (Game_Unit unit) =>
            {
                if (unit.actor.bond > 0)
                {
                    return(Global.game_actors[unit.actor.bond].name);
                }
                else
                {
                    return("-----");
                }
            }, 52, true));
            nodes.Last().loc = Bonuses_Window.loc + new Vector2(32 + 4, 2 * 16 + 4);
            (nodes.Last() as StatusTextUINode).set_color("White");
            nodes.Last().Size         = new Vector2(80, 16);
            nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
            // Bonuses
            for (int i = 0; i < 6; i++)
            {
                string help_label;
                string label;
                Func <Game_Unit, string> stat_formula;
                switch (i)
                {
                // Atk
                case 0:
                default:
                    help_label   = "BAtk";
                    label        = "Atk";
                    stat_formula = (Game_Unit unit) =>
                                   unit.support_bonus(Combat_Stat_Labels.Dmg, true).ToString();
                    break;

                // Hit
                case 1:
                    help_label   = "BHit";
                    label        = "Hit";
                    stat_formula = (Game_Unit unit) =>
                                   unit.support_bonus(Combat_Stat_Labels.Hit, true).ToString();
                    break;

                // Crit
                case 2:
                    help_label   = "BCrt";
                    label        = "Crit";
                    stat_formula = (Game_Unit unit) =>
                                   unit.support_bonus(Combat_Stat_Labels.Crt, true).ToString();
                    break;

                // Def
                case 3:
                    help_label   = "BDef";
                    label        = "Def";
                    stat_formula = (Game_Unit unit) =>
                                   unit.support_bonus(Combat_Stat_Labels.Def, true).ToString();
                    break;

                // Avoid
                case 4:
                    help_label   = "BAvo";
                    label        = "Avoid";
                    stat_formula = (Game_Unit unit) =>
                                   unit.support_bonus(Combat_Stat_Labels.Avo, true).ToString();
                    break;

                // Dodge
                case 5:
                    help_label   = "BDod";
                    label        = "Dodge";
                    stat_formula = (Game_Unit unit) =>
                                   unit.support_bonus(Combat_Stat_Labels.Dod, true).ToString();
                    break;
                }

                Vector2 loc = Bonuses_Window.loc +
                              new Vector2(20 + (i / 3) * 56, 56 + (i % 3) * 16);

                nodes.Add(new StatusStatUINode(help_label, label, stat_formula));
                nodes.Last().loc          = loc;
                nodes.Last().stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;
            }
            // Bonus Bg
            Bonus_Bg              = new Status_Bonus_Background();
            Bonus_Bg.loc          = Bonuses_Window.loc + new Vector2(8, 24);
            Bonus_Bg.stereoscopic = Config.STATUS_LEFT_WINDOW_DEPTH;

            // Supports Window
            Supports_Window              = new System_Color_Window();
            Supports_Window.loc          = new Vector2(168, 80);
            Supports_Window.width        = 144;
            Supports_Window.height       = 112;
            Supports_Window.stereoscopic = Config.STATUS_RIGHT_WINDOW_DEPTH;
            // Affinity
            nodes.Add(new StatusAffinityUINode(
                          "Affin",
                          (Game_Unit unit) => unit.actor.affin));
            nodes.Last().loc          = Supports_Window.loc + new Vector2(40, 8);
            nodes.Last().stereoscopic = Config.STATUS_RIGHT_WINDOW_DEPTH;
            // Supports
            Supports              = new Status_Support_List();
            Supports.loc          = Supports_Window.loc + new Vector2(32, 24);
            Supports.stereoscopic = Config.STATUS_RIGHT_WINDOW_DEPTH;
            // Support Bg
            Support_Bg              = new Status_Support_Background();
            Support_Bg.loc          = Supports_Window.loc + new Vector2(8, 24);
            Support_Bg.stereoscopic = Config.STATUS_RIGHT_WINDOW_DEPTH;

            StatusPageNodes = new UINodeSet <StatusUINode>(nodes);

            init_design();
        }