public UIProgressBar(float wide, float high, FieldBinding field, float increment, Color c = default(Color))
     : base(0.0f, 0.0f, 0.0f, 0.0f)
 {
     this._field         = field;
     this._barSize       = new Vec2(wide, high);
     this._collisionSize = this._barSize;
     this._step          = increment;
 }
        public override ContextMenu GetContextMenu()
        {
            FieldBinding    radioBinding = new FieldBinding((object)this, "contains");
            EditorGroupMenu contextMenu  = base.GetContextMenu() as EditorGroupMenu;

            contextMenu.InitializeGroups(new EditorGroup(typeof(PhysicsObject)), radioBinding);
            return((ContextMenu)contextMenu);
        }
 public void SetFieldBinding(FieldBinding f)
 {
     this._field = f;
     if (this._multiToggleElement == null)
     {
         return;
     }
     this._multiToggleElement.SetFieldBinding(f);
 }
Beispiel #4
0
 public UIMultiToggle(
     float wide,
     float high,
     FieldBinding field,
     List <string> captions,
     bool compressed = false)
     : base("AAAAAAAAA", Color.White)
 {
     this._field      = field;
     this._captions   = captions;
     this._compressed = compressed;
 }
Beispiel #5
0
 public ContextCheckBox(string text, IContextListener owner, FieldBinding field = null, System.Type myType = null)
     : base(owner)
 {
     this.itemSize.x = 150f;
     this.itemSize.y = 16f;
     this._text      = text;
     this._field     = field;
     this._checkBox  = new SpriteMap("Editor/checkBox", 16, 16);
     this.depth      = new Depth(0.8f);
     this._myType    = myType;
     if (field != null)
     {
         return;
     }
     this._field = new FieldBinding((object)this, nameof(isChecked));
 }
        public void InitializeTeams(FieldBinding radioBinding)
        {
            this.AddItem((ContextMenu) new ContextRadio("None", false, (object)0, (IContextListener)this, radioBinding));
            EditorGroupMenu editorGroupMenu = (EditorGroupMenu)null;
            int             num1            = 0;

            if (Teams.all.Count > 10)
            {
                editorGroupMenu      = new EditorGroupMenu((IContextListener)this);
                editorGroupMenu.text = "Hats " + (object)num1;
            }
            int num2 = 0;

            for (int index = 0; index < Teams.all.Count; ++index)
            {
                if (index >= 4)
                {
                    ContextRadio contextRadio = new ContextRadio(Teams.all[index].name, false, (object)index, (IContextListener)this, radioBinding);
                    if (editorGroupMenu != null)
                    {
                        editorGroupMenu.AddItem((ContextMenu)contextRadio);
                    }
                    else
                    {
                        this.AddItem((ContextMenu)contextRadio);
                    }
                    ++num2;
                    if (num2 == 10)
                    {
                        ++num1;
                        num2 = 0;
                        this.AddItem((ContextMenu)editorGroupMenu);
                        editorGroupMenu      = new EditorGroupMenu((IContextListener)this);
                        editorGroupMenu.text = "Hats " + (object)num1;
                    }
                }
            }
            if (editorGroupMenu == null || num2 <= 0)
            {
                return;
            }
            this.AddItem((ContextMenu)editorGroupMenu);
        }
Beispiel #7
0
        public UIMenuItemNumber(
            string text,
            UIMenuAction action          = null,
            FieldBinding field           = null,
            int step                     = 1,
            Color c                      = default(Color),
            FieldBinding upperBoundField = null,
            FieldBinding lowerBoundField = null,
            string append                = "",
            FieldBinding filterField     = null,
            List <string> valStrings     = null,
            MatchSetting setting         = null)
            : base(action)
        {
            this._setting = setting;
            if (c == new Color())
            {
                c = Colors.MenuOption;
            }
            this._valueStrings = valStrings;
            UIDivider uiDivider = new UIDivider(true, this._valueStrings != null ? 0.0f : 0.8f);
            UIText    uiText    = new UIText(text, c);

            uiText.align = UIAlign.Left;
            uiDivider.leftSection.Add((UIComponent)uiText, true);
            if (this._valueStrings != null)
            {
                if (text == "" || text == null)
                {
                    uiDivider.leftSection.align = UIAlign.Left;
                    this._textItem = uiText;
                    int index = (int)field.value;
                    if (index >= 0 && index < this._valueStrings.Count)
                    {
                        this._textItem.text = this._valueStrings[index];
                    }
                }
                else
                {
                    this._textItem = (UIText) new UIChangingText(-1f, -1f, field, (FieldBinding)null);
                    int index = (int)field.value;
                    if (index >= 0 && index < this._valueStrings.Count)
                    {
                        this._textItem.text = this._valueStrings[index];
                    }
                    this._textItem.align = UIAlign.Right;
                    uiDivider.rightSection.Add((UIComponent)this._textItem, true);
                }
            }
            else
            {
                UINumber uiNumber = new UINumber(-1f, -1f, field, append, filterField, this._setting);
                uiNumber.align = UIAlign.Right;
                uiDivider.rightSection.Add((UIComponent)uiNumber, true);
            }
            this.rightSection.Add((UIComponent)uiDivider, true);
            this._arrow         = new UIImage("contextArrowRight");
            this._arrow.align   = UIAlign.Right;
            this._arrow.visible = false;
            this.leftSection.Add((UIComponent)this._arrow, true);
            this._field           = field;
            this._step            = step;
            this._upperBoundField = upperBoundField;
            this._lowerBoundField = lowerBoundField;
            this._filterField     = filterField;
        }
Beispiel #8
0
        public override void Activate(string trigger)
        {
            if (this._filterField != null)
            {
                if (!(bool)this._filterField.value && trigger == "RIGHT")
                {
                    SFX.Play("textLetter", 0.7f);
                    this._filterField.value = (object)true;
                    this._field.value       = (object)(int)this._field.min;
                    return;
                }
                if ((bool)this._filterField.value && trigger == "LEFT" && (double)(int)this._field.value == (double)this._field.min)
                {
                    SFX.Play("textLetter", 0.7f);
                    this._filterField.value = (object)false;
                    return;
                }
                if (this._setting != null && trigger == "GRAB")
                {
                    SFX.Play("textLetter", 0.7f);
                    if (this._setting.filterMode == FilterMode.GreaterThan)
                    {
                        this._setting.filterMode = FilterMode.Equal;
                        return;
                    }
                    if (this._setting.filterMode == FilterMode.Equal)
                    {
                        this._setting.filterMode = FilterMode.LessThan;
                        return;
                    }
                    if (this._setting.filterMode != FilterMode.LessThan)
                    {
                        return;
                    }
                    this._setting.filterMode = FilterMode.GreaterThan;
                    return;
                }
            }
            int num1 = (int)this._field.value;

            if (trigger == "LEFT")
            {
                this._field.value = (object)((int)this._field.value - this.GetStep((int)this._field.value, false));
            }
            else if (trigger == "RIGHT")
            {
                this._field.value = (object)((int)this._field.value + this.GetStep((int)this._field.value, true));
            }
            int index = (int)Maths.Clamp((float)(int)this._field.value, this._field.min, this._field.max);

            if (this._upperBoundField != null && index > (int)this._upperBoundField.value)
            {
                this._upperBoundField.value = (object)index;
            }
            if (this._lowerBoundField != null && index < (int)this._lowerBoundField.value)
            {
                this._lowerBoundField.value = (object)index;
            }
            if (num1 != (int)this._field.value)
            {
                SFX.Play("textLetter", 0.7f);
            }
            int num2 = index - num1;

            this._field.value = (object)index;
            if (num2 > 0)
            {
                int num3 = num2;
                using (List <FieldBinding> .Enumerator enumerator = this.percentageGroup.GetEnumerator())
                {
label_29:
                    while (enumerator.MoveNext())
                    {
                        FieldBinding current = enumerator.Current;
                        while (true)
                        {
                            if ((double)(int)current.value > (double)current.min && num3 > 0)
                            {
                                int num4 = (int)current.value - (int)current.inc;
                                current.value = (object)num4;
                                num3         -= (int)current.inc;
                            }
                            else
                            {
                                goto label_29;
                            }
                        }
                    }
                }
            }
            else if (num2 < 0)
            {
                int num3 = num2;
                using (List <FieldBinding> .Enumerator enumerator = this.percentageGroup.GetEnumerator())
                {
label_37:
                    while (enumerator.MoveNext())
                    {
                        FieldBinding current = enumerator.Current;
                        while (true)
                        {
                            if ((double)(int)current.value < (double)current.max && num3 < 0)
                            {
                                int num4 = (int)current.value + (int)current.inc;
                                current.value = (object)num4;
                                num3         += (int)current.inc;
                            }
                            else
                            {
                                goto label_37;
                            }
                        }
                    }
                }
            }
            if (this._textItem == null || index < 0 || index >= this._valueStrings.Count)
            {
                return;
            }
            this._textItem.text = this._valueStrings[index];
        }
Beispiel #9
0
 public void SetFieldBinding(FieldBinding f) => this._field = f;
        public void InitializeGroups(
            EditorGroup group,
            FieldBinding radioBinding  = null,
            EditorGroup scriptingGroup = null)
        {
            ++EditorGroupMenu.deep;
            this._text      = group.Name;
            this.itemSize.x = (float)(this._text.Length * 8 + 16);
            foreach (EditorGroup subGroup in group.SubGroups)
            {
                EditorGroupMenu editorGroupMenu = new EditorGroupMenu((IContextListener)this);
                editorGroupMenu.fancy = this.fancy;
                editorGroupMenu.InitializeGroups(subGroup, radioBinding);
                if (!editorGroupMenu.greyOut)
                {
                    this.greyOut = false;
                }
                if (!editorGroupMenu.willOnlineGrayout)
                {
                    this.willOnlineGrayout = false;
                }
                this.AddItem((ContextMenu)editorGroupMenu);
            }
            if (scriptingGroup != null)
            {
                EditorGroupMenu editorGroupMenu = new EditorGroupMenu((IContextListener)this);
                editorGroupMenu.InitializeGroups(scriptingGroup, radioBinding);
                if (!editorGroupMenu.greyOut)
                {
                    this.greyOut = false;
                }
                if (!editorGroupMenu.willOnlineGrayout)
                {
                    this.willOnlineGrayout = false;
                }
                this.AddItem((ContextMenu)editorGroupMenu);
            }
            foreach (Thing allThing in group.AllThings)
            {
                IReadOnlyPropertyBag bag = ContentProperties.GetBag(allThing.GetType());
                if (Main.isDemo && bag.GetOrDefault <bool>("isInDemo", false))
                {
                    this.greyOut = false;
                }
                if (bag.GetOrDefault <bool>("isOnlineCapable", true))
                {
                    this.greyOut           = false;
                    this.willOnlineGrayout = false;
                }
                switch (allThing)
                {
                case BackgroundTile _:
                case ForegroundTile _:
                case SubBackgroundTile _:
                    ContextBackgroundTile contextBackgroundTile = new ContextBackgroundTile(allThing, (IContextListener)this);
                    contextBackgroundTile.contextThing = allThing;
                    this.AddItem((ContextMenu)contextBackgroundTile);
                    continue;

                default:
                    if (radioBinding != null)
                    {
                        if (radioBinding.value is IList)
                        {
                            if (radioBinding.value is List <TypeProbPair> )
                            {
                                ContextSlider contextSlider = new ContextSlider(allThing.editorName, (IContextListener)this, radioBinding, 0.05f, myType: allThing.GetType());
                                contextSlider.greyOut      = Main.isDemo && !bag.GetOrDefault <bool>("isInDemo", false);
                                contextSlider.contextThing = allThing;
                                if (!bag.Contains("isOnlineCapable") || bag.Get <bool>("isOnlineCapable"))
                                {
                                    this.willOnlineGrayout = false;
                                }
                                this.AddItem((ContextMenu)contextSlider);
                                continue;
                            }
                            ContextCheckBox contextCheckBox = new ContextCheckBox(allThing.editorName, (IContextListener)this, radioBinding, allThing.GetType());
                            contextCheckBox.greyOut      = Main.isDemo && !bag.GetOrDefault <bool>("isInDemo", false);
                            contextCheckBox.contextThing = allThing;
                            if (!bag.Contains("isOnlineCapable") || bag.Get <bool>("isOnlineCapable"))
                            {
                                this.willOnlineGrayout = false;
                            }
                            this.AddItem((ContextMenu)contextCheckBox);
                            continue;
                        }
                        ContextRadio contextRadio = new ContextRadio(allThing.editorName, false, (object)allThing.GetType(), (IContextListener)this, radioBinding);
                        contextRadio.greyOut      = Main.isDemo && !bag.GetOrDefault <bool>("isInDemo", false);
                        contextRadio.contextThing = allThing;
                        if (!bag.Contains("isOnlineCapable") || bag.Get <bool>("isOnlineCapable"))
                        {
                            this.willOnlineGrayout = false;
                        }
                        this.AddItem((ContextMenu)contextRadio);
                        continue;
                    }
                    ContextObject contextObject = new ContextObject(allThing, (IContextListener)this);
                    contextObject.contextThing = allThing;
                    this.AddItem((ContextMenu)contextObject);
                    continue;
                }
            }
            --EditorGroupMenu.deep;
            if (EditorGroupMenu.deep != 0)
            {
                return;
            }
            this.UpdateGrayout();
        }
        public UIMenuItemToggle(
            string text,
            UIMenuAction action        = null,
            FieldBinding field         = null,
            Color c                    = default(Color),
            FieldBinding filterBinding = null,
            List <string> multi        = null,
            bool compressedMulti       = false,
            bool tiny                  = false)
            : base(action)
        {
            if (c == new Color())
            {
                c = Colors.MenuOption;
            }
            BitmapFont f = (BitmapFont)null;

            if (tiny)
            {
                f = new BitmapFont("smallBiosFontUI", 7, 5);
            }
            UIDivider uiDivider = new UIDivider(true, 0.0f);

            if (text != "")
            {
                UIText uiText = new UIText(text, c);
                if (tiny)
                {
                    uiText.SetFont(f);
                }
                uiText.align = UIAlign.Left;
                uiDivider.leftSection.Add((UIComponent)uiText, true);
            }
            if (multi != null)
            {
                this._multiToggleElement       = new UIMultiToggle(-1f, -1f, field, multi, compressedMulti);
                this._multiToggleElement.align = compressedMulti ? UIAlign.Right : UIAlign.Right;
                if (text != "")
                {
                    uiDivider.rightSection.Add((UIComponent)this._multiToggleElement, true);
                }
                else
                {
                    uiDivider.leftSection.Add((UIComponent)this._multiToggleElement, true);
                    this._multiToggleElement.align = UIAlign.Left;
                }
                if (tiny)
                {
                    this._multiToggleElement.SetFont(f);
                }
                this._multiToggle = multi;
                this._compressed  = compressedMulti;
            }
            else
            {
                UIOnOff uiOnOff = new UIOnOff(-1f, -1f, field, filterBinding);
                if (tiny)
                {
                    uiOnOff.SetFont(f);
                }
                uiOnOff.align = UIAlign.Right;
                uiDivider.rightSection.Add((UIComponent)uiOnOff, true);
            }
            this.rightSection.Add((UIComponent)uiDivider, true);
            if (tiny)
            {
                this._arrow = new UIImage("littleContextArrowRight");
            }
            else
            {
                this._arrow = new UIImage("contextArrowRight");
            }
            this._arrow.align   = UIAlign.Right;
            this._arrow.visible = false;
            this.leftSection.Add((UIComponent)this._arrow, true);
            this._field       = field;
            this._filterField = filterBinding;
        }