Esempio n. 1
0
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            Textures          = new Dictionary <MyStringId, MyGuiCompositeTexture>(MyStringId.Comparer);
            IconStyles        = new Dictionary <MyStringId, IconStyleDefinition>(MyStringId.Comparer);
            ButtonStyles      = new Dictionary <MyStringId, MyGuiControlButton.StyleDefinition>(MyStringId.Comparer);
            ComboboxStyles    = new Dictionary <MyStringId, MyGuiControlCombobox.StyleDefinition>(MyStringId.Comparer);
            LabelStyles       = new Dictionary <MyStringId, MyGuiControlLabel.StyleDefinition>(MyStringId.Comparer);
            CheckboxStyles    = new Dictionary <MyStringId, MyGuiControlCheckbox.StyleDefinition>(MyStringId.Comparer);
            SliderStyles      = new Dictionary <MyStringId, MyGuiControlSliderBase.StyleDefinition>(MyStringId.Comparer);
            ImageButtonStyles = new Dictionary <MyStringId, MyGuiControlImageButton.StyleDefinition>(MyStringId.Comparer);
            ListboxStyles     = new Dictionary <MyStringId, MyGuiControlListbox.StyleDefinition>(MyStringId.Comparer);
            TextboxStyles     = new Dictionary <MyStringId, MyGuiControlTextbox.StyleDefinition>(MyStringId.Comparer);
            ImageStyles       = new Dictionary <MyStringId, MyGuiControlImage.StyleDefinition>(MyStringId.Comparer);
            ContextMenuStyles = new Dictionary <MyStringId, MyContextMenuStyleDefinition>(MyStringId.Comparer);
            ButtonListStyles  = new Dictionary <MyStringId, MyButtonListStyleDefinition>(MyStringId.Comparer);

            var ob = builder as MyObjectBuilder_GuiSkinDefinition;

            if (ob == null)
            {
                return;
            }

            if (ob.GuiTextures != null)
            {
                foreach (var textureStyleDef in ob.GuiTextures)
                {
                    Textures[MyStringId.GetOrCompute(textureStyleDef.StyleName)] = textureStyleDef.Texture;
                }
            }

            if (ob.GuiIcons != null)
            {
                foreach (var iconStyleDef in ob.GuiIcons)
                {
                    var iconStyle = new IconStyleDefinition()
                    {
                        Normal          = iconStyleDef.Normal,
                        Highlight       = iconStyleDef.Highlight,
                        Active          = iconStyleDef.Active,
                        ActiveHighlight = iconStyleDef.ActiveHighlight,
                        Disabled        = iconStyleDef.Disabled
                    };
                    IconStyles[MyStringId.GetOrCompute(iconStyleDef.StyleName)] = iconStyle;
                }
            }

            if (ob.Buttons != null)
            {
                foreach (var buttonStyleDef in ob.Buttons)
                {
                    var buttonStyle = new MyGuiControlButton.StyleDefinition()
                    {
                        BackgroundColor  = buttonStyleDef.BackgroundColor,
                        NormalTexture    = buttonStyleDef.Normal.Texture,
                        HighlightTexture = buttonStyleDef.Highlight.Texture,
                        NormalFont       = buttonStyleDef.Normal.Font,
                        HighlightFont    = buttonStyleDef.Highlight.Font,
                        Padding          = new MyGuiBorderThickness(
                            buttonStyleDef.Padding.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            buttonStyleDef.Padding.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            buttonStyleDef.Padding.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
                            buttonStyleDef.Padding.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y),
                    };

                    var imageButtonStyle = new MyGuiControlImageButton.StyleDefinition()
                    {
                        BackgroundColor = buttonStyleDef.BackgroundColor,
                        Padding         = new MyGuiBorderThickness(
                            buttonStyleDef.Padding.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            buttonStyleDef.Padding.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            buttonStyleDef.Padding.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
                            buttonStyleDef.Padding.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y),
                    };

                    MyDebug.AssertDebug(buttonStyleDef.Normal != null, String.Format("Normal state for {0} not defined!", buttonStyleDef.StyleName));
                    imageButtonStyle.Normal = new MyGuiControlImageButton.StateDefinition()
                    {
                        Font           = buttonStyleDef.Normal.Font,
                        Texture        = buttonStyleDef.Normal.Texture,
                        CornerTextFont = buttonStyleDef.Normal.CornerTextFont,
                        CornerTextSize = buttonStyleDef.Normal.CornerTextSize
                    };

                    if (buttonStyleDef.Disabled != null)
                    {
                        imageButtonStyle.Disabled = new MyGuiControlImageButton.StateDefinition()
                        {
                            Font           = buttonStyleDef.Disabled.Font,
                            Texture        = buttonStyleDef.Disabled.Texture,
                            CornerTextFont = buttonStyleDef.Disabled.CornerTextFont,
                            CornerTextSize = buttonStyleDef.Disabled.CornerTextSize
                        }
                    }
                    ;
                    else
                    {
                        imageButtonStyle.Disabled = imageButtonStyle.Normal;
                    }

                    if (buttonStyleDef.Active != null)
                    {
                        imageButtonStyle.Active = new MyGuiControlImageButton.StateDefinition()
                        {
                            Font           = buttonStyleDef.Active.Font,
                            Texture        = buttonStyleDef.Active.Texture,
                            CornerTextFont = buttonStyleDef.Active.CornerTextFont,
                            CornerTextSize = buttonStyleDef.Active.CornerTextSize
                        }
                    }
                    ;
                    else
                    {
                        imageButtonStyle.Active = imageButtonStyle.Normal;
                    }

                    if (buttonStyleDef.Highlight != null)
                    {
                        imageButtonStyle.Highlight = new MyGuiControlImageButton.StateDefinition()
                        {
                            Font           = buttonStyleDef.Highlight.Font,
                            Texture        = buttonStyleDef.Highlight.Texture,
                            CornerTextFont = buttonStyleDef.Highlight.CornerTextFont,
                            CornerTextSize = buttonStyleDef.Highlight.CornerTextSize
                        }
                    }
                    ;
                    else
                    {
                        imageButtonStyle.Highlight = imageButtonStyle.Normal;
                    }

                    if (buttonStyleDef.ActiveHighlight != null)
                    {
                        imageButtonStyle.ActiveHighlight = new MyGuiControlImageButton.StateDefinition()
                        {
                            Font           = buttonStyleDef.ActiveHighlight.Font,
                            Texture        = buttonStyleDef.ActiveHighlight.Texture,
                            CornerTextFont = buttonStyleDef.ActiveHighlight.CornerTextFont,
                            CornerTextSize = buttonStyleDef.ActiveHighlight.CornerTextSize
                        }
                    }
                    ;
                    else
                    {
                        imageButtonStyle.ActiveHighlight = imageButtonStyle.Highlight;
                    }

                    ButtonStyles[MyStringId.GetOrCompute(buttonStyleDef.StyleName)]      = buttonStyle;
                    ImageButtonStyles[MyStringId.GetOrCompute(buttonStyleDef.StyleName)] = imageButtonStyle;
                }
            }

            if (ob.Labels != null)
            {
                foreach (var labelStyleDef in ob.Labels)
                {
                    var labelStyle = new MyGuiControlLabel.StyleDefinition()
                    {
                        Font      = labelStyleDef.Font,
                        ColorMask = labelStyleDef.Color,
                        TextScale = labelStyleDef.TextScale
                    };

                    LabelStyles[MyStringId.GetOrCompute(labelStyleDef.StyleName)] = labelStyle;
                }
            }

            if (ob.Checkboxes != null)
            {
                foreach (var checkboxStyleDef in ob.Checkboxes)
                {
                    var checkbodexStyle = new MyGuiControlCheckbox.StyleDefinition()
                    {
                        NormalCheckedTexture      = checkboxStyleDef.NormalChecked.Texture,
                        NormalUncheckedTexture    = checkboxStyleDef.NormalUnchecked.Texture,
                        HighlightCheckedTexture   = checkboxStyleDef.HighlightChecked.Texture,
                        HighlightUncheckedTexture = checkboxStyleDef.HighlightUnchecked.Texture,
                        CheckedIcon = new MyGuiHighlightTexture()
                        {
                            Highlight = checkboxStyleDef.HighlightChecked.Icon,
                            Normal    = checkboxStyleDef.NormalChecked.Icon,
                            SizePx    = checkboxStyleDef.IconSize,
                        },
                        UncheckedIcon = new MyGuiHighlightTexture()
                        {
                            Highlight = checkboxStyleDef.HighlightUnchecked.Icon,
                            Normal    = checkboxStyleDef.NormalUnchecked.Icon,
                            SizePx    = checkboxStyleDef.IconSize,
                        },
                    };

                    CheckboxStyles[MyStringId.GetOrCompute(checkboxStyleDef.StyleName)] = checkbodexStyle;
                }
            }

            if (ob.Sliders != null)
            {
                foreach (var sliderStyleDef in ob.Sliders)
                {
                    MyDebug.AssertDebug(sliderStyleDef.Normal != null, String.Format("Normal state for {0} not defined!", sliderStyleDef.StyleName));

                    var sliderStyle = new MyGuiControlSliderBase.StyleDefinition()
                    {
                        RailTexture          = sliderStyleDef.Normal.TrackTexture,
                        RailHighlightTexture = sliderStyleDef.Highlight != null ? sliderStyleDef.Highlight.TrackTexture : sliderStyleDef.Normal.TrackTexture,
                        ThumbTexture         = new MyGuiHighlightTexture()
                        {
                            Highlight = sliderStyleDef.Highlight != null ? sliderStyleDef.Highlight.Thumb : sliderStyleDef.Normal.Thumb,
                            Normal    = sliderStyleDef.Normal.Thumb,
                            SizePx    = sliderStyleDef.ThumbSize,
                        },
                    };

                    SliderStyles[MyStringId.GetOrCompute(sliderStyleDef.StyleName)] = sliderStyle;
                }
            }

            if (ob.Comboboxes != null)
            {
                foreach (var comboboxStyleDef in ob.Comboboxes)
                {
                    MyDebug.AssertDebug(comboboxStyleDef.Normal != null, String.Format("Normal state for {0} not defined!", comboboxStyleDef.StyleName));

                    var comboboxStyle = new MyGuiControlCombobox.StyleDefinition()
                    {
                        TextScale                   = comboboxStyleDef.TextScale,
                        ComboboxTextureNormal       = comboboxStyleDef.Normal.Texture,
                        ComboboxTextureHighlight    = comboboxStyleDef.Highlight != null ? comboboxStyleDef.Highlight.Texture : comboboxStyleDef.Normal.Texture,
                        ItemFontNormal              = comboboxStyleDef.Normal.ItemFont,
                        ItemFontHighlight           = comboboxStyleDef.Highlight != null ? comboboxStyleDef.Highlight.ItemFont : comboboxStyleDef.Normal.ItemFont,
                        ItemTextureHighlight        = comboboxStyleDef.ItemTextureHighlight,
                        DropDownHighlightExtraWidth = 0.007f,
                        SelectedItemOffset          = new Vector2(0.01f, 0.005f),
                        ScrollbarMargin             = new MyGuiBorderThickness()
                        {
                            Left   = comboboxStyleDef.ScrollbarMargin.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            Right  = comboboxStyleDef.ScrollbarMargin.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            Bottom = comboboxStyleDef.ScrollbarMargin.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
                            Top    = comboboxStyleDef.ScrollbarMargin.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y
                        },
                        DropDownTexture = comboboxStyleDef.DropDownTexture
                    };

                    ComboboxStyles[MyStringId.GetOrCompute(comboboxStyleDef.StyleName)] = comboboxStyle;
                }
            }

            if (ob.Listboxes != null)
            {
                foreach (var listboxStyleDef in ob.Listboxes)
                {
                    var listboxStyle = new MyGuiControlListbox.StyleDefinition();

                    listboxStyle.TextScale            = listboxStyleDef.TextScale;
                    listboxStyle.ItemFontHighlight    = listboxStyleDef.ItemFontHighlight;
                    listboxStyle.ItemFontNormal       = listboxStyleDef.ItemFontNormal;
                    listboxStyle.ItemSize             = listboxStyleDef.ItemSize;
                    listboxStyle.ItemsOffset          = listboxStyleDef.ItemOffset;
                    listboxStyle.ItemTextureHighlight = listboxStyleDef.ItemTextureHighlight;
                    listboxStyle.Texture       = listboxStyleDef.Texture;
                    listboxStyle.XSizeVariable = listboxStyleDef.XSizeVariable;
                    listboxStyle.DrawScroll    = listboxStyleDef.DrawScrollbar;

                    ListboxStyles[MyStringId.GetOrCompute(listboxStyleDef.StyleName)] = listboxStyle;
                }
            }

            if (ob.Textboxes != null)
            {
                foreach (var textboxStyleDef in ob.Textboxes)
                {
                    var textboxStyle = new MyGuiControlTextbox.StyleDefinition();

                    MyDebug.AssertDebug(textboxStyleDef.Normal != null, String.Format("Normal state for {0} not defined!", textboxStyleDef.StyleName));

                    textboxStyle.NormalFont    = textboxStyleDef.Normal.Font;
                    textboxStyle.NormalTexture = textboxStyleDef.Normal.Texture;
                    if (textboxStyleDef.Highlight != null)
                    {
                        textboxStyle.HighlightFont    = textboxStyleDef.Highlight.Font;
                        textboxStyle.HighlightTexture = textboxStyleDef.Highlight.Texture;
                    }
                    else
                    {
                        textboxStyle.HighlightFont    = textboxStyleDef.Normal.Font;
                        textboxStyle.HighlightTexture = textboxStyleDef.Normal.Texture;
                    }

                    TextboxStyles[MyStringId.GetOrCompute(textboxStyleDef.StyleName)] = textboxStyle;
                }
            }

            if (ob.Images != null)
            {
                foreach (var imageStyleDef in ob.Images)
                {
                    var imageStyle = new MyGuiControlImage.StyleDefinition()
                    {
                        BackgroundTexture = imageStyleDef.Texture,
                        Padding           = new MyGuiBorderThickness(
                            imageStyleDef.Padding.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            imageStyleDef.Padding.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            imageStyleDef.Padding.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
                            imageStyleDef.Padding.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y),
                    };

                    ImageStyles[MyStringId.GetOrCompute(imageStyleDef.StyleName)] = imageStyle;
                }
            }

            if (ob.ContextMenus != null)
            {
                foreach (var contextMenuStyleDef in ob.ContextMenus)
                {
                    var contextMenuStyle = new MyContextMenuStyleDefinition()
                    {
                        TitleTexture    = contextMenuStyleDef.TitleTexture,
                        ImageStyle      = MyStringId.GetOrCompute(contextMenuStyleDef.ImageStyle),
                        SeparatorStyle  = MyStringId.GetOrCompute(contextMenuStyleDef.SeparatorStyle),
                        SeparatorHeight = contextMenuStyleDef.SeparatorHeight,
                        Margin          = contextMenuStyleDef.Margin
                    };

                    ContextMenuStyles[MyStringId.GetOrCompute(contextMenuStyleDef.StyleName)] = contextMenuStyle;
                }
            }

            if (ob.ButtonListStyles != null)
            {
                foreach (var btnListStyleDef in ob.ButtonListStyles)
                {
                    var newBtnListStyle = new MyButtonListStyleDefinition();
                    newBtnListStyle.ButtonMargin = btnListStyleDef.ButtonMargin;
                    newBtnListStyle.ButtonSize   = btnListStyleDef.ButtonSize;

                    ButtonListStyles[MyStringId.GetOrCompute(btnListStyleDef.StyleName)] = newBtnListStyle;
                }
            }
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            Textures = new Dictionary<MyStringId, MyGuiCompositeTexture>(MyStringId.Comparer);
            IconStyles = new Dictionary<MyStringId, IconStyleDefinition>(MyStringId.Comparer);
            ButtonStyles = new Dictionary<MyStringId, MyGuiControlButton.StyleDefinition>(MyStringId.Comparer);
            ComboboxStyles = new Dictionary<MyStringId, MyGuiControlCombobox.StyleDefinition>(MyStringId.Comparer);
            LabelStyles = new Dictionary<MyStringId, MyGuiControlLabel.StyleDefinition>(MyStringId.Comparer);
            CheckboxStyles = new Dictionary<MyStringId, MyGuiControlCheckbox.StyleDefinition>(MyStringId.Comparer);
            SliderStyles = new Dictionary<MyStringId, MyGuiControlSliderBase.StyleDefinition>(MyStringId.Comparer);
            ImageButtonStyles = new Dictionary<MyStringId, MyGuiControlImageButton.StyleDefinition>(MyStringId.Comparer);
            ListboxStyles = new Dictionary<MyStringId, MyGuiControlListbox.StyleDefinition>(MyStringId.Comparer);
            TextboxStyles = new Dictionary<MyStringId, MyGuiControlTextbox.StyleDefinition>(MyStringId.Comparer);
            ImageStyles = new Dictionary<MyStringId, MyGuiControlImage.StyleDefinition>(MyStringId.Comparer);
            ContextMenuStyles = new Dictionary<MyStringId, MyContextMenuStyleDefinition>(MyStringId.Comparer);
            ButtonListStyles = new Dictionary<MyStringId, MyButtonListStyleDefinition>(MyStringId.Comparer);

            var ob = builder as MyObjectBuilder_GuiSkinDefinition;
            if (ob == null)
                return;

            if (ob.GuiTextures != null)
            {
                foreach (var textureStyleDef in ob.GuiTextures)
                {
                    Textures[MyStringId.GetOrCompute(textureStyleDef.StyleName)] = textureStyleDef.Texture;
                }
            }

            if (ob.GuiIcons != null)
            {
                foreach (var iconStyleDef in ob.GuiIcons)
                {
                    var iconStyle = new IconStyleDefinition()
                    {
                        Normal = iconStyleDef.Normal,
                        Highlight = iconStyleDef.Highlight,
                        Active = iconStyleDef.Active,
                        ActiveHighlight = iconStyleDef.ActiveHighlight,
                        Disabled = iconStyleDef.Disabled
                    };
                    IconStyles[MyStringId.GetOrCompute(iconStyleDef.StyleName)] = iconStyle;
                }
            }

            if (ob.Buttons != null)
            {
                foreach (var buttonStyleDef in ob.Buttons)
                {
                    var buttonStyle = new MyGuiControlButton.StyleDefinition()
                    {
                        BackgroundColor = buttonStyleDef.BackgroundColor,
                        NormalTexture = buttonStyleDef.Normal.Texture,
                        HighlightTexture = buttonStyleDef.Highlight.Texture,
                        NormalFont = buttonStyleDef.Normal.Font,
                        HighlightFont = buttonStyleDef.Highlight.Font,
                        Padding = new MyGuiBorderThickness(
                            buttonStyleDef.Padding.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            buttonStyleDef.Padding.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            buttonStyleDef.Padding.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
                            buttonStyleDef.Padding.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y),
                    };

                    var imageButtonStyle = new MyGuiControlImageButton.StyleDefinition()
                    {
                        BackgroundColor = buttonStyleDef.BackgroundColor,
                        Padding = new MyGuiBorderThickness(
                            buttonStyleDef.Padding.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            buttonStyleDef.Padding.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            buttonStyleDef.Padding.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
                            buttonStyleDef.Padding.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y),
                    };

                    MyDebug.AssertDebug(buttonStyleDef.Normal != null, String.Format("Normal state for {0} not defined!", buttonStyleDef.StyleName));
                    imageButtonStyle.Normal = new MyGuiControlImageButton.StateDefinition()
                    {
                        Font = buttonStyleDef.Normal.Font,
                        Texture = buttonStyleDef.Normal.Texture,
                        CornerTextFont = buttonStyleDef.Normal.CornerTextFont,
                        CornerTextSize = buttonStyleDef.Normal.CornerTextSize
                    };

                    if (buttonStyleDef.Disabled != null)
                        imageButtonStyle.Disabled = new MyGuiControlImageButton.StateDefinition()
                        {
                            Font = buttonStyleDef.Disabled.Font,
                            Texture = buttonStyleDef.Disabled.Texture,
                            CornerTextFont = buttonStyleDef.Disabled.CornerTextFont,
                            CornerTextSize = buttonStyleDef.Disabled.CornerTextSize
                        };
                    else
                        imageButtonStyle.Disabled = imageButtonStyle.Normal;

                    if (buttonStyleDef.Active != null)
                        imageButtonStyle.Active = new MyGuiControlImageButton.StateDefinition()
                        {
                            Font = buttonStyleDef.Active.Font,
                            Texture = buttonStyleDef.Active.Texture,
                            CornerTextFont = buttonStyleDef.Active.CornerTextFont,
                            CornerTextSize = buttonStyleDef.Active.CornerTextSize
                        };
                    else
                        imageButtonStyle.Active = imageButtonStyle.Normal;

                    if (buttonStyleDef.Highlight != null)
                        imageButtonStyle.Highlight = new MyGuiControlImageButton.StateDefinition()
                        {
                            Font = buttonStyleDef.Highlight.Font,
                            Texture = buttonStyleDef.Highlight.Texture,
                            CornerTextFont = buttonStyleDef.Highlight.CornerTextFont,
                            CornerTextSize = buttonStyleDef.Highlight.CornerTextSize
                        };
                    else
                        imageButtonStyle.Highlight = imageButtonStyle.Normal;

                    if (buttonStyleDef.ActiveHighlight != null)
                        imageButtonStyle.ActiveHighlight = new MyGuiControlImageButton.StateDefinition()
                        {
                            Font = buttonStyleDef.ActiveHighlight.Font,
                            Texture = buttonStyleDef.ActiveHighlight.Texture,
                            CornerTextFont = buttonStyleDef.ActiveHighlight.CornerTextFont,
                            CornerTextSize = buttonStyleDef.ActiveHighlight.CornerTextSize
                        };
                    else
                        imageButtonStyle.ActiveHighlight = imageButtonStyle.Highlight;

                    ButtonStyles[MyStringId.GetOrCompute(buttonStyleDef.StyleName)] = buttonStyle;
                    ImageButtonStyles[MyStringId.GetOrCompute(buttonStyleDef.StyleName)] = imageButtonStyle;
                }
            }

            if (ob.Labels != null)
            {
                foreach (var labelStyleDef in ob.Labels)
                {
                    var labelStyle = new MyGuiControlLabel.StyleDefinition()
                    {
                        Font = labelStyleDef.Font,
                        ColorMask = labelStyleDef.Color,
                        TextScale = labelStyleDef.TextScale
                    };

                    LabelStyles[MyStringId.GetOrCompute(labelStyleDef.StyleName)] = labelStyle;
                }
            }

            if (ob.Checkboxes != null)
            {
                foreach (var checkboxStyleDef in ob.Checkboxes)
                {
                    var checkbodexStyle = new MyGuiControlCheckbox.StyleDefinition()
                    {
                        NormalCheckedTexture = checkboxStyleDef.NormalChecked.Texture,
                        NormalUncheckedTexture = checkboxStyleDef.NormalUnchecked.Texture,
                        HighlightCheckedTexture = checkboxStyleDef.HighlightChecked.Texture,
                        HighlightUncheckedTexture = checkboxStyleDef.HighlightUnchecked.Texture,
                        CheckedIcon = new MyGuiHighlightTexture()
                        {
                            Highlight = checkboxStyleDef.HighlightChecked.Icon,
                            Normal = checkboxStyleDef.NormalChecked.Icon,
                            SizePx = checkboxStyleDef.IconSize,
                        },
                        UncheckedIcon = new MyGuiHighlightTexture()
                        {
                            Highlight = checkboxStyleDef.HighlightUnchecked.Icon,
                            Normal = checkboxStyleDef.NormalUnchecked.Icon,
                            SizePx = checkboxStyleDef.IconSize,
                        },
                    };

                    CheckboxStyles[MyStringId.GetOrCompute(checkboxStyleDef.StyleName)] = checkbodexStyle;
                }
            }

            if (ob.Sliders != null)
            {
                foreach (var sliderStyleDef in ob.Sliders)
                {
                    MyDebug.AssertDebug(sliderStyleDef.Normal != null, String.Format("Normal state for {0} not defined!", sliderStyleDef.StyleName));

                    var sliderStyle = new MyGuiControlSliderBase.StyleDefinition()
                    {
                        RailTexture = sliderStyleDef.Normal.TrackTexture,
                        RailHighlightTexture = sliderStyleDef.Highlight != null ? sliderStyleDef.Highlight.TrackTexture : sliderStyleDef.Normal.TrackTexture,
                        ThumbTexture = new MyGuiHighlightTexture()
                        {
                            Highlight = sliderStyleDef.Highlight != null ? sliderStyleDef.Highlight.Thumb : sliderStyleDef.Normal.Thumb,
                            Normal = sliderStyleDef.Normal.Thumb,
                            SizePx = sliderStyleDef.ThumbSize,
                        },
                    };

                    SliderStyles[MyStringId.GetOrCompute(sliderStyleDef.StyleName)] = sliderStyle;
                }
            }

            if (ob.Comboboxes != null)
            {
                foreach (var comboboxStyleDef in ob.Comboboxes)
                {
                    MyDebug.AssertDebug(comboboxStyleDef.Normal != null, String.Format("Normal state for {0} not defined!", comboboxStyleDef.StyleName));

                    var comboboxStyle = new MyGuiControlCombobox.StyleDefinition()
                    {
                        TextScale = comboboxStyleDef.TextScale,
                        ComboboxTextureNormal = comboboxStyleDef.Normal.Texture,
                        ComboboxTextureHighlight = comboboxStyleDef.Highlight != null ? comboboxStyleDef.Highlight.Texture : comboboxStyleDef.Normal.Texture,
                        ItemFontNormal = comboboxStyleDef.Normal.ItemFont,
                        ItemFontHighlight = comboboxStyleDef.Highlight != null ? comboboxStyleDef.Highlight.ItemFont : comboboxStyleDef.Normal.ItemFont,
                        ItemTextureHighlight = comboboxStyleDef.ItemTextureHighlight,
                        DropDownHighlightExtraWidth = 0.007f,
                        SelectedItemOffset = new Vector2(0.01f, 0.005f),
                        ScrollbarMargin = new MyGuiBorderThickness()
                        {
                            Left = comboboxStyleDef.ScrollbarMargin.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            Right = comboboxStyleDef.ScrollbarMargin.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            Bottom = comboboxStyleDef.ScrollbarMargin.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
                            Top = comboboxStyleDef.ScrollbarMargin.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y
                        },
                        DropDownTexture = comboboxStyleDef.DropDownTexture
                    };

                    ComboboxStyles[MyStringId.GetOrCompute(comboboxStyleDef.StyleName)] = comboboxStyle;
                }
            }

            if (ob.Listboxes != null)
            {
                foreach (var listboxStyleDef in ob.Listboxes)
                {
                    var listboxStyle = new MyGuiControlListbox.StyleDefinition();

                    listboxStyle.TextScale = listboxStyleDef.TextScale;
                    listboxStyle.ItemFontHighlight = listboxStyleDef.ItemFontHighlight;
                    listboxStyle.ItemFontNormal = listboxStyleDef.ItemFontNormal;
                    listboxStyle.ItemSize = listboxStyleDef.ItemSize;
                    listboxStyle.ItemsOffset = listboxStyleDef.ItemOffset;
                    listboxStyle.ItemTextureHighlight = listboxStyleDef.ItemTextureHighlight;
                    listboxStyle.Texture = listboxStyleDef.Texture;
                    listboxStyle.XSizeVariable = listboxStyleDef.XSizeVariable;
                    listboxStyle.DrawScroll = listboxStyleDef.DrawScrollbar;

                    ListboxStyles[MyStringId.GetOrCompute(listboxStyleDef.StyleName)] = listboxStyle;
                }
            }

            if (ob.Textboxes != null)
            {
                foreach (var textboxStyleDef in ob.Textboxes)
                {
                    var textboxStyle = new MyGuiControlTextbox.StyleDefinition();

                    MyDebug.AssertDebug(textboxStyleDef.Normal != null, String.Format("Normal state for {0} not defined!", textboxStyleDef.StyleName));

                    textboxStyle.NormalFont = textboxStyleDef.Normal.Font;
                    textboxStyle.NormalTexture = textboxStyleDef.Normal.Texture;
                    if (textboxStyleDef.Highlight != null)
                    {
                        textboxStyle.HighlightFont = textboxStyleDef.Highlight.Font;
                        textboxStyle.HighlightTexture = textboxStyleDef.Highlight.Texture;
                    }
                    else
                    {
                        textboxStyle.HighlightFont = textboxStyleDef.Normal.Font;
                        textboxStyle.HighlightTexture = textboxStyleDef.Normal.Texture;
                    }

                    TextboxStyles[MyStringId.GetOrCompute(textboxStyleDef.StyleName)] = textboxStyle;
                }
            }

            if (ob.Images != null)
            {
                foreach (var imageStyleDef in ob.Images)
                {
                    var imageStyle = new MyGuiControlImage.StyleDefinition()
                    {
                        BackgroundTexture = imageStyleDef.Texture,
                        Padding = new MyGuiBorderThickness(
                            imageStyleDef.Padding.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            imageStyleDef.Padding.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            imageStyleDef.Padding.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
                            imageStyleDef.Padding.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y),
                    };

                    ImageStyles[MyStringId.GetOrCompute(imageStyleDef.StyleName)] = imageStyle;
                }
            }

            if (ob.ContextMenus != null)
            {
                foreach (var contextMenuStyleDef in ob.ContextMenus)
                {
                    var contextMenuStyle = new MyContextMenuStyleDefinition()
                    {
                        TitleTexture = contextMenuStyleDef.TitleTexture,
                        ImageStyle = MyStringId.GetOrCompute(contextMenuStyleDef.ImageStyle),
                        SeparatorStyle = MyStringId.GetOrCompute(contextMenuStyleDef.SeparatorStyle),
                        SeparatorHeight = contextMenuStyleDef.SeparatorHeight,
                        Margin = contextMenuStyleDef.Margin
                    };

                    ContextMenuStyles[MyStringId.GetOrCompute(contextMenuStyleDef.StyleName)] = contextMenuStyle;
                }
            }

            if (ob.ButtonListStyles != null)
            {
                foreach (var btnListStyleDef in ob.ButtonListStyles)
                {
                    var newBtnListStyle = new MyButtonListStyleDefinition();
                    newBtnListStyle.ButtonMargin = btnListStyleDef.ButtonMargin;
                    newBtnListStyle.ButtonSize = btnListStyleDef.ButtonSize;

                    ButtonListStyles[MyStringId.GetOrCompute(btnListStyleDef.StyleName)] = newBtnListStyle;
                }
            }
        }
Esempio n. 3
0
        protected override unsafe void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            this.Textures          = new Dictionary <MyStringId, MyGuiCompositeTexture>(MyStringId.Comparer);
            this.IconStyles        = new Dictionary <MyStringId, IconStyleDefinition>(MyStringId.Comparer);
            this.ButtonStyles      = new Dictionary <MyStringId, MyGuiControlButton.StyleDefinition>(MyStringId.Comparer);
            this.ComboboxStyles    = new Dictionary <MyStringId, MyGuiControlCombobox.StyleDefinition>(MyStringId.Comparer);
            this.LabelStyles       = new Dictionary <MyStringId, MyGuiControlLabel.StyleDefinition>(MyStringId.Comparer);
            this.CheckboxStyles    = new Dictionary <MyStringId, MyGuiControlCheckbox.StyleDefinition>(MyStringId.Comparer);
            this.SliderStyles      = new Dictionary <MyStringId, MyGuiControlSliderBase.StyleDefinition>(MyStringId.Comparer);
            this.ImageButtonStyles = new Dictionary <MyStringId, MyGuiControlImageButton.StyleDefinition>(MyStringId.Comparer);
            this.ListboxStyles     = new Dictionary <MyStringId, MyGuiControlListbox.StyleDefinition>(MyStringId.Comparer);
            this.TextboxStyles     = new Dictionary <MyStringId, MyGuiControlTextbox.StyleDefinition>(MyStringId.Comparer);
            this.ImageStyles       = new Dictionary <MyStringId, MyGuiControlImage.StyleDefinition>(MyStringId.Comparer);
            this.ContextMenuStyles = new Dictionary <MyStringId, MyContextMenuStyleDefinition>(MyStringId.Comparer);
            this.ButtonListStyles  = new Dictionary <MyStringId, MyButtonListStyleDefinition>(MyStringId.Comparer);
            MyObjectBuilder_GuiSkinDefinition definition = builder as MyObjectBuilder_GuiSkinDefinition;

            if (definition != null)
            {
                MyGuiHighlightTexture texture;
                if (definition.GuiTextures != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.TextureStyleDefinition definition2 in definition.GuiTextures)
                    {
                        this.Textures[MyStringId.GetOrCompute(definition2.StyleName)] = definition2.Texture;
                    }
                }
                if (definition.GuiIcons != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.IconStyleDefinition definition3 in definition.GuiIcons)
                    {
                        IconStyleDefinition definition1 = new IconStyleDefinition();
                        definition1.Normal          = definition3.Normal;
                        definition1.Highlight       = definition3.Highlight;
                        definition1.Active          = definition3.Active;
                        definition1.ActiveHighlight = definition3.ActiveHighlight;
                        definition1.Disabled        = definition3.Disabled;
                        IconStyleDefinition definition4 = definition1;
                        this.IconStyles[MyStringId.GetOrCompute(definition3.StyleName)] = definition4;
                    }
                }
                if (definition.Buttons != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.ButtonStyleDefinition definition5 in definition.Buttons)
                    {
                        MyGuiControlButton.StyleDefinition definition26 = new MyGuiControlButton.StyleDefinition();
                        definition26.BackgroundColor  = (Vector4)definition5.BackgroundColor;
                        definition26.NormalTexture    = definition5.Normal.Texture;
                        definition26.HighlightTexture = definition5.Highlight.Texture;
                        definition26.NormalFont       = definition5.Normal.Font;
                        definition26.HighlightFont    = definition5.Highlight.Font;
                        definition26.Padding          = new MyGuiBorderThickness(definition5.Padding.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X, definition5.Padding.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X, definition5.Padding.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y, definition5.Padding.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y);
                        MyGuiControlButton.StyleDefinition      definition6  = definition26;
                        MyGuiControlImageButton.StyleDefinition definition27 = new MyGuiControlImageButton.StyleDefinition();
                        definition27.BackgroundColor = (Vector4)definition5.BackgroundColor;
                        definition27.Padding         = new MyGuiBorderThickness(definition5.Padding.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X, definition5.Padding.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X, definition5.Padding.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y, definition5.Padding.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y);
                        MyGuiControlImageButton.StyleDefinition definition7  = definition27;
                        MyGuiControlImageButton.StateDefinition definition28 = new MyGuiControlImageButton.StateDefinition();
                        definition28.Font           = definition5.Normal.Font;
                        definition28.Texture        = definition5.Normal.Texture;
                        definition28.CornerTextFont = definition5.Normal.CornerTextFont;
                        definition28.CornerTextSize = definition5.Normal.CornerTextSize;
                        definition7.Normal          = definition28;
                        if (definition5.Disabled == null)
                        {
                            definition7.Disabled = definition7.Normal;
                        }
                        else
                        {
                            MyGuiControlImageButton.StateDefinition definition29 = new MyGuiControlImageButton.StateDefinition();
                            definition29.Font           = definition5.Disabled.Font;
                            definition29.Texture        = definition5.Disabled.Texture;
                            definition29.CornerTextFont = definition5.Disabled.CornerTextFont;
                            definition29.CornerTextSize = definition5.Disabled.CornerTextSize;
                            definition7.Disabled        = definition29;
                        }
                        if (definition5.Active == null)
                        {
                            definition7.Active = definition7.Normal;
                        }
                        else
                        {
                            MyGuiControlImageButton.StateDefinition definition30 = new MyGuiControlImageButton.StateDefinition();
                            definition30.Font           = definition5.Active.Font;
                            definition30.Texture        = definition5.Active.Texture;
                            definition30.CornerTextFont = definition5.Active.CornerTextFont;
                            definition30.CornerTextSize = definition5.Active.CornerTextSize;
                            definition7.Active          = definition30;
                        }
                        if (definition5.Highlight == null)
                        {
                            definition7.Highlight = definition7.Normal;
                        }
                        else
                        {
                            MyGuiControlImageButton.StateDefinition definition31 = new MyGuiControlImageButton.StateDefinition();
                            definition31.Font           = definition5.Highlight.Font;
                            definition31.Texture        = definition5.Highlight.Texture;
                            definition31.CornerTextFont = definition5.Highlight.CornerTextFont;
                            definition31.CornerTextSize = definition5.Highlight.CornerTextSize;
                            definition7.Highlight       = definition31;
                        }
                        if (definition5.ActiveHighlight == null)
                        {
                            definition7.ActiveHighlight = definition7.Highlight;
                        }
                        else
                        {
                            MyGuiControlImageButton.StateDefinition definition32 = new MyGuiControlImageButton.StateDefinition();
                            definition32.Font           = definition5.ActiveHighlight.Font;
                            definition32.Texture        = definition5.ActiveHighlight.Texture;
                            definition32.CornerTextFont = definition5.ActiveHighlight.CornerTextFont;
                            definition32.CornerTextSize = definition5.ActiveHighlight.CornerTextSize;
                            definition7.ActiveHighlight = definition32;
                        }
                        this.ButtonStyles[MyStringId.GetOrCompute(definition5.StyleName)]      = definition6;
                        this.ImageButtonStyles[MyStringId.GetOrCompute(definition5.StyleName)] = definition7;
                    }
                }
                if (definition.Labels != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.LabelStyleDefinition definition8 in definition.Labels)
                    {
                        MyGuiControlLabel.StyleDefinition definition33 = new MyGuiControlLabel.StyleDefinition();
                        definition33.Font      = definition8.Font;
                        definition33.ColorMask = (Vector4)definition8.Color;
                        definition33.TextScale = definition8.TextScale;
                        MyGuiControlLabel.StyleDefinition definition9 = definition33;
                        this.LabelStyles[MyStringId.GetOrCompute(definition8.StyleName)] = definition9;
                    }
                }
                if (definition.Checkboxes != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.CheckboxStyleDefinition definition10 in definition.Checkboxes)
                    {
                        MyGuiControlCheckbox.StyleDefinition definition34 = new MyGuiControlCheckbox.StyleDefinition();
                        definition34.NormalCheckedTexture      = definition10.NormalChecked.Texture;
                        definition34.NormalUncheckedTexture    = definition10.NormalUnchecked.Texture;
                        definition34.HighlightCheckedTexture   = definition10.HighlightChecked.Texture;
                        definition34.HighlightUncheckedTexture = definition10.HighlightUnchecked.Texture;
                        texture = new MyGuiHighlightTexture {
                            Highlight = definition10.HighlightChecked.Icon,
                            Normal    = definition10.NormalChecked.Icon,
                            SizePx    = (Vector2)definition10.IconSize
                        };
                        definition34.CheckedIcon = texture;
                        texture = new MyGuiHighlightTexture {
                            Highlight = definition10.HighlightUnchecked.Icon,
                            Normal    = definition10.NormalUnchecked.Icon,
                            SizePx    = (Vector2)definition10.IconSize
                        };
                        definition34.UncheckedIcon = texture;
                        MyGuiControlCheckbox.StyleDefinition definition11 = definition34;
                        this.CheckboxStyles[MyStringId.GetOrCompute(definition10.StyleName)] = definition11;
                    }
                }
                if (definition.Sliders != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.SliderStyleDefinition definition12 in definition.Sliders)
                    {
                        MyGuiHighlightTexture *texturePtr1;
                        MyGuiControlSliderBase.StyleDefinition definition35 = new MyGuiControlSliderBase.StyleDefinition();
                        definition35.RailTexture          = definition12.Normal.TrackTexture;
                        definition35.RailHighlightTexture = (definition12.Highlight != null) ? definition12.Highlight.TrackTexture : definition12.Normal.TrackTexture;
                        texture = new MyGuiHighlightTexture();
                        MyGuiControlSliderBase.StyleDefinition local3 = definition35;
                        MyGuiControlSliderBase.StyleDefinition local4 = definition35;
                        texturePtr1->Highlight = (definition12.Highlight != null) ? definition12.Highlight.Thumb : definition12.Normal.Thumb;
                        texturePtr1            = (MyGuiHighlightTexture *)ref texture;
                        texture.Normal         = definition12.Normal.Thumb;
                        texture.SizePx         = (Vector2)definition12.ThumbSize;
                        local4.ThumbTexture    = texture;
                        MyGuiControlSliderBase.StyleDefinition definition13 = local4;
                        this.SliderStyles[MyStringId.GetOrCompute(definition12.StyleName)] = definition13;
                    }
                }
                if (definition.Comboboxes != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.ComboboxStyleDefinition definition14 in definition.Comboboxes)
                    {
                        MyGuiControlCombobox.StyleDefinition definition36 = new MyGuiControlCombobox.StyleDefinition();
                        definition36.TextScale                = definition14.TextScale;
                        definition36.ComboboxTextureNormal    = definition14.Normal.Texture;
                        definition36.ComboboxTextureHighlight = (definition14.Highlight != null) ? definition14.Highlight.Texture : definition14.Normal.Texture;
                        MyGuiControlCombobox.StyleDefinition local1 = definition36;
                        local1.ItemFontNormal    = definition14.Normal.ItemFont;
                        local1.ItemFontHighlight = (definition14.Highlight != null) ? definition14.Highlight.ItemFont : definition14.Normal.ItemFont;
                        MyGuiControlCombobox.StyleDefinition local2 = local1;
                        local2.ItemTextureHighlight        = definition14.ItemTextureHighlight;
                        local2.DropDownHighlightExtraWidth = 0.007f;
                        local2.SelectedItemOffset          = new Vector2(0.01f, 0.005f);
                        MyGuiBorderThickness thickness = new MyGuiBorderThickness {
                            Left   = definition14.ScrollbarMargin.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            Right  = definition14.ScrollbarMargin.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X,
                            Bottom = definition14.ScrollbarMargin.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y,
                            Top    = definition14.ScrollbarMargin.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y
                        };
                        local2.ScrollbarMargin = thickness;
                        local2.DropDownTexture = definition14.DropDownTexture;
                        MyGuiControlCombobox.StyleDefinition definition15 = local2;
                        this.ComboboxStyles[MyStringId.GetOrCompute(definition14.StyleName)] = definition15;
                    }
                }
                if (definition.Listboxes != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.ListboxStyleDefinition definition16 in definition.Listboxes)
                    {
                        MyGuiControlListbox.StyleDefinition definition17 = new MyGuiControlListbox.StyleDefinition {
                            TextScale            = definition16.TextScale,
                            ItemFontHighlight    = definition16.ItemFontHighlight,
                            ItemFontNormal       = definition16.ItemFontNormal,
                            ItemSize             = (Vector2)definition16.ItemSize,
                            ItemsOffset          = (Vector2)definition16.ItemOffset,
                            ItemTextureHighlight = definition16.ItemTextureHighlight,
                            Texture       = definition16.Texture,
                            XSizeVariable = definition16.XSizeVariable,
                            DrawScroll    = definition16.DrawScrollbar
                        };
                        this.ListboxStyles[MyStringId.GetOrCompute(definition16.StyleName)] = definition17;
                    }
                }
                if (definition.Textboxes != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.TextboxStyleDefinition definition18 in definition.Textboxes)
                    {
                        MyGuiControlTextbox.StyleDefinition definition19 = new MyGuiControlTextbox.StyleDefinition {
                            NormalFont    = definition18.Normal.Font,
                            NormalTexture = definition18.Normal.Texture
                        };
                        if (definition18.Highlight != null)
                        {
                            definition19.HighlightFont    = definition18.Highlight.Font;
                            definition19.HighlightTexture = definition18.Highlight.Texture;
                        }
                        else
                        {
                            definition19.HighlightFont    = definition18.Normal.Font;
                            definition19.HighlightTexture = definition18.Normal.Texture;
                        }
                        this.TextboxStyles[MyStringId.GetOrCompute(definition18.StyleName)] = definition19;
                    }
                }
                if (definition.Images != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.ImageStyleDefinition definition20 in definition.Images)
                    {
                        MyGuiControlImage.StyleDefinition definition37 = new MyGuiControlImage.StyleDefinition();
                        definition37.BackgroundTexture = definition20.Texture;
                        definition37.Padding           = new MyGuiBorderThickness(definition20.Padding.Left / MyGuiConstants.GUI_OPTIMAL_SIZE.X, definition20.Padding.Right / MyGuiConstants.GUI_OPTIMAL_SIZE.X, definition20.Padding.Top / MyGuiConstants.GUI_OPTIMAL_SIZE.Y, definition20.Padding.Bottom / MyGuiConstants.GUI_OPTIMAL_SIZE.Y);
                        MyGuiControlImage.StyleDefinition definition21 = definition37;
                        this.ImageStyles[MyStringId.GetOrCompute(definition20.StyleName)] = definition21;
                    }
                }
                if (definition.ContextMenus != null)
                {
                    foreach (MyObjectBuilder_GuiSkinDefinition.ContextMenuStyleDefinition definition22 in definition.ContextMenus)
                    {
                        MyContextMenuStyleDefinition definition38 = new MyContextMenuStyleDefinition();
                        definition38.TitleTexture    = definition22.TitleTexture;
                        definition38.ImageStyle      = MyStringId.GetOrCompute(definition22.ImageStyle);
                        definition38.SeparatorStyle  = MyStringId.GetOrCompute(definition22.SeparatorStyle);
                        definition38.SeparatorHeight = definition22.SeparatorHeight;
                        definition38.Margin          = (Vector2)definition22.Margin;
                        MyContextMenuStyleDefinition definition23 = definition38;
                        this.ContextMenuStyles[MyStringId.GetOrCompute(definition22.StyleName)] = definition23;
                    }
                }
                if (definition.ButtonListStyles != null)
                {
                    foreach (MyObjectBuilder_ButtonListStyleDefinition definition24 in definition.ButtonListStyles)
                    {
                        MyButtonListStyleDefinition definition25 = new MyButtonListStyleDefinition {
                            ButtonMargin = (Vector2)definition24.ButtonMargin,
                            ButtonSize   = (Vector2)definition24.ButtonSize
                        };
                        this.ButtonListStyles[MyStringId.GetOrCompute(definition24.StyleName)] = definition25;
                    }
                }
            }
        }