示例#1
0
        public WidgetStyle AddStyle(StringValue name, WidgetStyle basis)
        {
            var r = new WidgetStyle(basis.ReadOnly);

            styles.Add(name.ToString().ToUpperInvariant(), r);
            return(r);
        }
示例#2
0
 public Widget(Box parent, WidgetStyle style)
 {
     this.parent           = parent;
     this.copyOnWriteStyle = style;
     Enabled = true;
     Shown   = true;
     RegisterInitializer(InitializeSuffixes);
 }
示例#3
0
 public Slider(Box parent, bool h_not_v, float v, float from, float to) : base(parent, parent.FindStyle(h_not_v ? "horizontalSlider" : "verticalSlider"))
 {
     RegisterInitializer(InitializeSuffixes);
     horizontal   = h_not_v;
     val          = v;
     valueVisible = v;
     min          = from;
     max          = to;
     thumbStyle   = parent.FindStyle(horizontal ? "horizontalSliderThumb" : "verticalSliderThumb");
 }
示例#4
0
        public PopupMenu(Box parent) : base(parent, "", parent.FindStyle("popupMenu"))
        {
            IsToggle = true;

            itemStyle  = FindStyle("popupMenuItem");
            popupStyle = FindStyle("popupWindow");

            list = new ListValue();
            SetInitialContentImage(Utilities.Utils.GetTextureWithErrorMsg("kOS/GFX/dds_popupmenu", false));
            RegisterInitializer(InitializeSuffixes);
        }
示例#5
0
        public PopupMenu(Box parent) : base(parent, "", parent.FindStyle("popupMenu"))
        {
            IsToggle = true;

            itemStyle  = FindStyle("popupMenuItem");
            popupStyle = FindStyle("popupWindow");

            list = new ListValue();
            SetInitialContentImage(GameDatabase.Instance.GetTexture("kOS/GFX/popupmenu", false));
            RegisterInitializer(InitializeSuffixes);
        }
示例#6
0
        private WidgetStyle GetStyle(string name)
        {
            WidgetStyle r;

            if (styles.TryGetValue(name, out r))
            {
                return(r);
            }
            r = new WidgetStyle(Skin.GetStyle(name));
            styles.Add(name, r);
            return(r);
        }
示例#7
0
 private void InitializeSuffixes()
 {
     AddSuffix("ENABLED", new SetSuffix <BooleanValue>(() => Enabled, value => Enabled = value));
     AddSuffix("VISIBLE", new SetSuffix <BooleanValue>(() => Shown, value => { if (value)
                                                                               {
                                                                                   Show();
                                                                               }
                                                                               else
                                                                               {
                                                                                   Hide();
                                                                               } }));
     AddSuffix("SHOW", new NoArgsVoidSuffix(Show));
     AddSuffix("HIDE", new NoArgsVoidSuffix(Hide));
     AddSuffix("DISPOSE", new NoArgsVoidSuffix(Dispose));
     AddSuffix("STYLE", new SetSuffix <WidgetStyle>(() => copyOnWriteStyle, value => copyOnWriteStyle = value));
     AddSuffix("GUI", new Suffix <GUIWidgets>(() => FindGUI()));
     AddSuffix("PARENT", new Suffix <Widget>(() => parent));
 }
示例#8
0
文件: Label.cs 项目: pand5461/KOS-1
 public Label(Box parent, string text, WidgetStyle style) : base(parent, style)
 {
     RegisterInitializer(InitializeSuffixes);
     content         = new GUIContent(text);
     content_visible = new GUIContent(text);
 }
示例#9
0
文件: Button.cs 项目: pand5461/KOS-1
 public Button(Box parent, string text, WidgetStyle buttonStyle) : base(parent, text, buttonStyle)
 {
     IsToggle = false;
     RegisterInitializer(InitializeSuffixes);
 }
示例#10
0
 public TextField(Box parent, string text) : base(parent, text, parent.FindStyle("textField"))
 {
     emptyHintStyle = FindStyle("emptyHintStyle");
     RegisterInitializer(InitializeSuffixes);
 }
示例#11
0
 public TextField(Box parent, string text) : base(parent, text, parent.FindStyle("textField"))
 {
     toolTipStyle = FindStyle("labelTipOverlay");
     RegisterInitializer(InitializeSuffixes);
 }
示例#12
0
 public Box(Box parent, LayoutMode mode, WidgetStyle style) : base(parent, style)
 {
     RegisterInitializer(InitializeSuffixes);
     Mode    = mode;
     Widgets = new List <Widget>();
 }
示例#13
0
 public Box(LayoutMode mode, WidgetStyle style) : this(null, mode, style)
 {
 }
示例#14
0
 void SetFont(StringValue name)
 {
     Skin.font = WidgetStyle.FontNamed(name);
 }
示例#15
0
 public void SetStyle(string name, WidgetStyle style)
 {
     styles[name.ToUpperInvariant()] = style;
 }
示例#16
0
 public ScrollBox(Box parent) : base(parent, LayoutMode.Vertical, parent.FindStyle("scrollView"))
 {
     hsbStyle = parent.FindStyle("horizontalScrollbar");
     vsbStyle = parent.FindStyle("verticalScrollbar");
     RegisterInitializer(InitializeSuffixes);
 }
示例#17
0
        public GUIWidgets(int width, int height, SharedObjects shared) : base(Box.LayoutMode.Vertical, new WidgetStyle(new GUIStyle(HighLogic.Skin.window)))
        {
            instances.Add(new WeakReference(this));

            RecentToolTip = "";
            var gskin = UnityEngine.Object.Instantiate(HighLogic.Skin);

            // Use Arial as that's what used in other KSP GUIs
            gskin.font = WidgetStyle.FontNamed("Arial");

            // Undo KSP weirdness with toggle style
            gskin.toggle.clipping            = TextClipping.Clip;
            gskin.toggle.contentOffset       = Vector2.zero;
            gskin.toggle.fixedWidth          = 0;
            gskin.toggle.overflow            = new RectOffset(8, -45, 10, -1);
            gskin.toggle.padding             = new RectOffset(27, 0, 3, 0);
            gskin.toggle.margin              = new RectOffset(4, 4, 4, 4);
            gskin.toggle.border              = new RectOffset(40, 0, 40, 0);
            gskin.toggle.normal.background   = GameDatabase.Instance.GetTexture("kOS/GFX/toggle_bg_normal", false);
            gskin.toggle.onNormal.background = GameDatabase.Instance.GetTexture("kOS/GFX/toggle_bg_onnormal", false);
            gskin.toggle.active.background   = GameDatabase.Instance.GetTexture("kOS/GFX/toggle_bg_onactive", false);
            gskin.toggle.onActive.background = GameDatabase.Instance.GetTexture("kOS/GFX/toggle_bg_active", false);
            gskin.toggle.hover.background    = GameDatabase.Instance.GetTexture("kOS/GFX/toggle_bg_hover", false);
            gskin.toggle.onHover.background  = GameDatabase.Instance.GetTexture("kOS/GFX/toggle_bg_onhover", false);

            // Get back the style we made in the base initializer.
            gskin.window = ReadOnlyStyle;
            // no title area.
            gskin.window.padding.top = gskin.window.padding.bottom;

            // Stretch labels, otherwise ALIGN is confusing.
            gskin.label.stretchWidth = true;

            // align better with labels.
            gskin.horizontalSlider.margin.top    = 8;
            gskin.horizontalSlider.margin.bottom = 8;

            List <GUIStyle> styles = new List <GUIStyle>(gskin.customStyles);

            var flatLayout = new GUIStyle(gskin.box);

            flatLayout.name              = "flatLayout";
            flatLayout.margin            = new RectOffset(0, 0, 0, 0);
            flatLayout.padding           = new RectOffset(0, 0, 0, 0);
            flatLayout.normal.background = null;
            styles.Add(flatLayout);

            var popupWindow = new GUIStyle(gskin.window);

            popupWindow.name              = "popupWindow";
            popupWindow.padding.left      = 0;
            popupWindow.padding.right     = 0;
            popupWindow.margin            = new RectOffset(0, 0, 0, 0);
            popupWindow.normal.background = gskin.button.onNormal.background;
            popupWindow.border            = gskin.button.border;

            styles.Add(popupWindow);

            var popupMenu = new GUIStyle(gskin.button);

            popupMenu.name      = "popupMenu";
            popupMenu.alignment = TextAnchor.MiddleLeft;
            styles.Add(popupMenu);

            var popupMenuItem = new GUIStyle(gskin.label);

            popupMenuItem.name              = "popupMenuItem";
            popupMenuItem.margin.top        = 0;
            popupMenuItem.margin.bottom     = 0;
            popupMenuItem.normal.background = null;
            popupMenuItem.hover.background  = GameDatabase.Instance.GetTexture("kOS/GFX/popupmenu_bg_hover", false);
            popupMenuItem.hover.textColor   = Color.black;
            popupMenuItem.active.background = popupMenuItem.hover.background;
            popupMenuItem.stretchWidth      = true;
            styles.Add(popupMenuItem);

            var emptyHintStyle = new GUIStyle(gskin.label);

            emptyHintStyle.name             = "emptyHintStyle";
            emptyHintStyle.normal.textColor = new Color(0.6f, 0.6f, 0.6f, 0.8f);
            styles.Add(emptyHintStyle);

            var tipDisplayLabel = new GUIStyle(gskin.label);

            tipDisplayLabel.name             = "tipDisplay";
            tipDisplayLabel.normal.textColor = new Color(1f, 1f, 1f, 1f);
            styles.Add(tipDisplayLabel);

            gskin.customStyles = styles.ToArray();

            Skin = new WidgetSkin(gskin);

            var go = new GameObject("kOSGUIWindow");

            window = go.AddComponent <GUIWindow>();
            window.AttachTo(width, height, "", shared, this);
            InitializeSuffixes();
        }
示例#18
0
 public TipDisplay(Box parent, string text, WidgetStyle buttonStyle) : base(parent, text, buttonStyle)
 {
 }