Exemple #1
0
 private byte setting_from_node(SettingUINode node)
 {
     if (node is SettingGaugeUINode)
     {
         var   option_data = this.active_option_data;
         int   range       = option_data.GaugeMax - option_data.GaugeMin;
         float value       = (SettingsNodes.ActiveNode as SettingGaugeUINode).SliderValue;
         value = value * range;
         int setting = (int)Math.Round(value / option_data.GaugeInterval) * option_data.GaugeInterval;
         setting += option_data.GaugeMin;
         return((byte)MathHelper.Clamp(setting, option_data.GaugeMin, option_data.GaugeMax));
     }
     else
     {
         return((byte)SettingsGroups[OptionsNodes.ActiveNodeIndex].IndexOf(node));
     }
 }
Exemple #2
0
        protected void initialize_sprites()
        {
            // Black Screen
            Black_Screen           = new Sprite();
            Black_Screen.texture   = Global.Content.Load <Texture2D>(@"Graphics/White_Square");
            Black_Screen.dest_rect = new Rectangle(0, 0, Config.WINDOW_WIDTH, Config.WINDOW_HEIGHT);
            Black_Screen.tint      = new Color(0, 0, 0, 255);
            // Banner
            Banner                   = new MenuScreenBanner();
            Banner.width             = 120;
            Banner.loc               = new Vector2(OPTIONS_OFFSET, 8);
            Banner.stereoscopic      = Config.OPTIONS_BANNER_DEPTH;
            Banner_Text              = new Sprite();
            Banner_Text.texture      = Global.Content.Load <Texture2D>(@"Graphics/Pictures/Banner_Text");
            Banner_Text.src_rect     = new Rectangle(0, 0, 96, 16);
            Banner_Text.loc          = new Vector2(OPTIONS_OFFSET + 24 + 2, 8 + 8);
            Banner_Text.stereoscopic = Config.OPTIONS_BANNER_DEPTH;
            // Background
            Background         = new Menu_Background();
            Background.texture = Global.Content.Load <Texture2D>(@"Graphics/Pictures/Option_Background");
            (Background as Menu_Background).vel  = new Vector2(-0.25f, 0);
            (Background as Menu_Background).tile = new Vector2(3, 1);
            Background.stereoscopic = Config.MAPMENU_BG_DEPTH;
            // Description Window
            Description_Window              = new System_Color_Window();
            Description_Window.loc          = new Vector2(60, 156);
            Description_Window.width        = 200;
            Description_Window.height       = 24;
            Description_Window.small        = true;
            Description_Window.stereoscopic = Config.OPTIONS_DESC_DEPTH;
            // Description
            Description     = new TextSprite();
            Description.loc = new Vector2(72, 160);
            Description.SetFont(Config.UI_FONT, Global.Content, "White");
            Description.stereoscopic = Config.OPTIONS_DESC_DEPTH;
            // Solo Anim Button Icon
            Solo_Icon     = new SoloAnim_Button();
            Solo_Icon.loc = new Vector2(
                CHOICES_OFFSET + 20 +
                OptionsConfig.OPTIONS_DATA[(int)Constants.Options.Animation_Mode]
                .Options[(int)Constants.Animation_Modes.Solo].Offset,
                16 * (int)Constants.Options.Animation_Mode) +
                            new Vector2(Data_Scissor_Rect.X, Data_Scissor_Rect.Y);
            Solo_Icon.stereoscopic = Config.OPTIONS_OPTIONS_DEPTH;
            // Page Arrows
            Up_Page_Arrow                = new Page_Arrow();
            Up_Page_Arrow.loc            = new Vector2(CHOICES_OFFSET - 4, Data_Scissor_Rect.Y - 4);
            Up_Page_Arrow.angle          = MathHelper.PiOver2;
            Up_Page_Arrow.stereoscopic   = Config.OPTIONS_ARROWS_DEPTH;
            Down_Page_Arrow              = new Page_Arrow();
            Down_Page_Arrow.loc          = new Vector2(CHOICES_OFFSET - 4, Data_Scissor_Rect.Y + Data_Scissor_Rect.Height + 4);
            Down_Page_Arrow.mirrored     = true;
            Down_Page_Arrow.angle        = MathHelper.PiOver2;
            Down_Page_Arrow.stereoscopic = Config.OPTIONS_ARROWS_DEPTH;

            Up_Page_Arrow.ArrowClicked   += Up_Page_Arrow_ArrowClicked;
            Down_Page_Arrow.ArrowClicked += Down_Page_Arrow_ArrowClicked;

            // UI Nodes
            List <OptionsUINode> nodes = new List <OptionsUINode>();

            // Options
            for (int index = 0; index < OptionsConfig.OPTIONS_DATA.Length; index++)
            {
                Vector2 loc = new Vector2(OPTIONS_OFFSET + 16, index * 16) +
                              new Vector2(Data_Scissor_Rect.X, Data_Scissor_Rect.Y);

                nodes.Add(new OptionsUINode(index));
                nodes[index].stereoscopic = Config.OPTIONS_OPTIONS_DEPTH;
                nodes[index].loc          = loc;
            }

            OptionsNodes = new PartialRangeVisibleUINodeSet <OptionsUINode>(nodes);
            OptionsNodes.CursorMoveSound = System_Sounds.Menu_Move1;

            OptionsCursor              = new UICursor <OptionsUINode>(OptionsNodes);
            OptionsCursor.draw_offset  = new Vector2(-(16 + 12), 0);
            OptionsCursor.stereoscopic = Config.OPTIONS_CURSOR_DEPTH;
            // Settings
            List <SettingUINode> settings_nodes = new List <SettingUINode>();

            SettingsGroups = new List <List <SettingUINode> >();
            foreach (var option_node in OptionsNodes)
            {
                int i              = (int)option_node.Option;
                var option         = OptionsConfig.OPTIONS_DATA[i];
                var settings_group = new List <SettingUINode>();

                if (option.Gauge)
                {
                    Vector2 loc = new Vector2(CHOICES_OFFSET, i * 16) +
                                  new Vector2(Data_Scissor_Rect.X, Data_Scissor_Rect.Y);

                    var node = new SettingGaugeUINode(option.Options[0].Name,
                                                      option.GaugeWidth, option.GaugeMin, option.GaugeMax, option.gauge_offset);
                    node.stereoscopic = Config.OPTIONS_OPTIONS_DEPTH;
                    node.loc          = loc;
                    settings_nodes.Add(node);
                    settings_group.Add(node);
                }
                else
                {
                    for (int j = 0; j < option.Options.Length; j++)
                    {
                        Vector2 loc = new Vector2(CHOICES_OFFSET + option.Options[j].Offset, i * 16) +
                                      new Vector2(Data_Scissor_Rect.X, Data_Scissor_Rect.Y);

                        var node = new SettingUINode(option.Options[j].Name);
                        node.stereoscopic = Config.OPTIONS_OPTIONS_DEPTH;
                        node.loc          = loc;
                        settings_nodes.Add(node);
                        settings_group.Add(node);
                    }
                }

                SettingsGroups.Add(settings_group);
            }

            SettingsNodes = new PartialRangeVisibleUINodeSet <SettingUINode>(settings_nodes);
            SettingsNodes.CursorMoveSound = System_Sounds.Menu_Move2;
            SettingsNodes.set_active_node(SettingsNodes[this.current_setting]);

            SettingsCursor                     = new UICursor <SettingUINode>(SettingsNodes);
            SettingsCursor.draw_offset         = new Vector2(-16, 0);
            SettingsCursor.min_distance_y      = 4;
            SettingsCursor.override_distance_y = 16;
            SettingsCursor.stereoscopic        = Config.OPTIONS_CURSOR_DEPTH;
            SettingsCursor.move_to_target_loc();

            // Scrollbar

            /* //Debug
             * Scrollbar = new Scroll_Bar(
             *  ROWS_AT_ONCE * 16 - 16, OptionsConfig.OPTIONS_DATA.Length, ROWS_AT_ONCE, 0);
             * Scrollbar.loc = new Vector2(Data_Scissor_Rect.Width - 12, Data_Scissor_Rect.Y + 8);
             *
             * Scrollbar.UpArrowClicked += Scrollbar_UpArrowClicked;
             * Scrollbar.DownArrowClicked += Scrollbar_DownArrowClicked;*/

            create_cancel_button();

            refresh_arrow_visibility();
            update_loc();
        }