Esempio n. 1
0
        // Token: 0x0600032B RID: 811 RVA: 0x00019D70 File Offset: 0x00017F70
        public bool DrawValueSlider(string label, ref EditColor edit, int idx, ref float sliderVal)
        {
            bool flag  = false;
            bool flag2 = false;

            GUILayout.BeginHorizontal(new GUILayoutOption[]
            {
                this.optItemHeight
            });
            try
            {
                this.DrawLabel(ref label);
                if (!edit.isSyncs[idx])
                {
                    this.SetTextColor(this.uiParams.textStyleSC, ref this.textColorRed);
                    flag2 = true;
                }
                EditRange <float> range = edit.GetRange(idx);
                string            text  = GUILayout.TextField(edit.editVals[idx], this.uiParams.textStyleSC, new GUILayoutOption[]
                {
                    this.optInputWidth
                });
                if (edit.editVals[idx] != text)
                {
                    edit.Set(idx, text, range);
                }
                flag |= this.DrawSlider(ref sliderVal, range.editMin, range.editMax);
                GUILayout.Space(this.buttonMargin);
            }
            catch (Exception ex)
            {
                LogUtil.DebugF("{0}, idx={1}, color={2}, vals.length={3}, syncs.length={4}, e={5}", new object[]
                {
                    label,
                    idx,
                    edit.val,
                    edit.editVals.Length,
                    edit.isSyncs.Length,
                    ex
                });
                throw;
            }
            finally
            {
                GUILayout.EndHorizontal();
                if (flag2)
                {
                    this.SetTextColor(this.uiParams.textStyleSC, ref this.textColor);
                }
            }
            return(flag);
        }
        public bool DrawValueSlider(string label, ref EditColor edit, int idx, ref float sliderVal)
        {
            var changed     = false;
            var fontChanged = false;

            GUILayout.BeginHorizontal(optItemHeight);
            try {
                DrawLabel(ref label);

                if (!edit.isSyncs[idx])
                {
                    SetTextColor(uiParams.textStyleSC, ref textColorRed);
                    fontChanged = true;
                }

                var range = edit.GetRange(idx);
                var val2  = GUILayout.TextField(edit.editVals[idx], uiParams.textStyleSC, optInputWidth);
                if (edit.editVals[idx] != val2)   // 直接書き換えられたケース
                {
                    edit.Set(idx, val2, range);
                }

                changed |= DrawSlider(ref sliderVal, range.editMin, range.editMax);
                GUILayout.Space(buttonMargin);
            } catch (Exception e) {
                LogUtil.DebugF("{0}, idx={1}, color={2}, vals.length={3}, syncs.length={4}, e={5}",
                               label, idx, edit.val, edit.editVals.Length, edit.isSyncs.Length, e);
                throw;
            } finally {
                GUILayout.EndHorizontal();
                if (fontChanged)
                {
                    SetTextColor(uiParams.textStyleSC, ref textColor);
                }
            }
            return(changed);
        }
        internal bool DrawColorSlider(string label, ref EditColor edit, ColorType colType, IEnumerable <float> vals, ref bool expand, ColorPicker picker = null)
        {
            GUILayout.BeginHorizontal();
            var c       = edit.val;
            var changed = false;

            try {
                if (picker != null)
                {
                    picker.Color = c;
                    if (GUILayout.Button(picker.ColorTex, uiParams.lStyleS, optItemHeight, picker.IconWidth, GUILayout.ExpandWidth(false)))
                    {
                        picker.expand = !picker.expand;
                    }
                }
                if (GUILayout.Button(label, uiParams.lStyle, optItemHeight))
                {
                    expand = !expand;
                }
                if (picker != null && ColorPicker.IsColorCode(picker.ColorCode))
                {
                    if (GUILayout.Button(CopyIcon, uiParams.lStyle, optCPWidth, optItemHeight))
                    {
                        clipHandler.SetClipboard(picker.ColorCode);
                    }

                    var clip = clipHandler.GetClipboard();
                    GUI.enabled &= ColorPicker.IsColorCode(clip);
                    try {
                        if (GUILayout.Button(PasteIcon, uiParams.lStyle, optCPWidth, optItemHeight))
                        {
                            try {
                                if (picker.SetColorCode(clip))
                                {
                                    c       = picker.Color;
                                    changed = true;
                                }
                            } catch (Exception e) {
                                LogUtil.Error("failed to import color-code", e);
                            }
                        }
                    } finally {
                        GUI.enabled = true;
                    }

                    var code = GUILayout.TextField(picker.ColorCode, 7, uiParams.textStyleSC, optCodeWidth);
                    if (code != picker.ColorCode && picker.SetColorCode(code))
                    {
                        c       = picker.Color;
                        changed = true;
                    }
                }

                if (!expand)
                {
                    return(false);
                }

                foreach (var val in vals)
                {
                    var cont = new GUIContent(val.ToString(CultureInfo.InvariantCulture));
                    if (!GUILayout.Button(cont, bStyleSS, getWidthOpt(cont)))
                    {
                        continue;
                    }
                    c.r     = c.g = c.b = val;
                    changed = true;
                }

                if (GUILayout.Button("-", bStyleSS, bWidthOpt))
                {
                    if (c.r < DELTA)
                    {
                        c.r = 0;
                    }
                    else
                    {
                        c.r -= DELTA;
                    }
                    if (c.g < DELTA)
                    {
                        c.g = 0;
                    }
                    else
                    {
                        c.g -= DELTA;
                    }
                    if (c.b < DELTA)
                    {
                        c.b = 0;
                    }
                    else
                    {
                        c.b -= DELTA;
                    }
                    changed = true;
                }

                if (GUILayout.Button("+", bStyleSS, bWidthOpt))
                {
                    if (c.r + DELTA > edit.GetRange(0).editMax)
                    {
                        c.r = edit.GetRange(0).editMax;
                    }
                    else
                    {
                        c.r += DELTA;
                    }
                    if (c.g + DELTA > edit.GetRange(1).editMax)
                    {
                        c.g = edit.GetRange(1).editMax;
                    }
                    else
                    {
                        c.g += DELTA;
                    }
                    if (c.b + DELTA > edit.GetRange(2).editMax)
                    {
                        c.b = edit.GetRange(2).editMax;
                    }
                    else
                    {
                        c.b += DELTA;
                    }
                    changed = true;
                }
            } finally {
                GUILayout.EndHorizontal();
            }

            var idx = 0;

            if (colType == ColorType.rgb || colType == ColorType.rgba)
            {
                changed |= DrawValueSlider("R", ref edit, idx++, ref c.r);
                changed |= DrawValueSlider("G", ref edit, idx++, ref c.g);
                changed |= DrawValueSlider("B", ref edit, idx++, ref c.b);
            }
            if (colType == ColorType.rgba || colType == ColorType.a)
            {
                changed |= DrawValueSlider("A", ref edit, idx, ref c.a);
            }
            if (picker != null)
            {
                if (picker.expand && picker.DrawLayout())
                {
                    c       = picker.Color;
                    changed = true;
                }
            }
            if (changed)
            {
                edit.Set(c);
            }

            return(changed);
        }
Esempio n. 4
0
        // Token: 0x06000326 RID: 806 RVA: 0x000195DC File Offset: 0x000177DC
        internal bool DrawColorSlider(string label, ref EditColor edit, ColorType colType, IEnumerable <float> vals, ref bool expand, ColorPicker picker = null)
        {
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            Color color = edit.val;
            bool  flag  = false;

            try
            {
                if (picker != null)
                {
                    picker.Color = color;
                    if (GUILayout.Button(picker.ColorTex, this.uiParams.lStyleS, new GUILayoutOption[]
                    {
                        this.optItemHeight,
                        picker.IconWidth,
                        GUILayout.ExpandWidth(false)
                    }))
                    {
                        picker.expand = !picker.expand;
                    }
                }
                if (GUILayout.Button(label, this.uiParams.lStyle, new GUILayoutOption[]
                {
                    this.optItemHeight
                }))
                {
                    expand = !expand;
                }
                if (picker != null && ColorPicker.IsColorCode(picker.ColorCode))
                {
                    if (GUILayout.Button(SliderHelper.CopyIcon, this.uiParams.lStyle, new GUILayoutOption[]
                    {
                        this.optCPWidth,
                        this.optItemHeight
                    }))
                    {
                        SliderHelper.clipHandler.SetClipboard(picker.ColorCode);
                    }
                    string text = SliderHelper.clipHandler.GetClipboard();
                    GUI.enabled &= ColorPicker.IsColorCode(text);
                    try
                    {
                        if (GUILayout.Button(SliderHelper.PasteIcon, this.uiParams.lStyle, new GUILayoutOption[]
                        {
                            this.optCPWidth,
                            this.optItemHeight
                        }))
                        {
                            try
                            {
                                if (picker.SetColorCode(text))
                                {
                                    color = picker.Color;
                                    flag  = true;
                                }
                            }
                            catch (Exception ex)
                            {
                                LogUtil.Error(new object[]
                                {
                                    "failed to import color-code",
                                    ex
                                });
                            }
                        }
                    }
                    finally
                    {
                        GUI.enabled = true;
                    }
                    string text2 = GUILayout.TextField(picker.ColorCode, 7, this.uiParams.textStyleSC, new GUILayoutOption[]
                    {
                        this.optCodeWidth
                    });
                    if (text2 != picker.ColorCode && picker.SetColorCode(text2))
                    {
                        color = picker.Color;
                        flag  = true;
                    }
                }
                if (!expand)
                {
                    return(false);
                }
                foreach (float num in vals)
                {
                    float      b          = num;
                    GUIContent guicontent = new GUIContent(b.ToString(CultureInfo.InvariantCulture));
                    if (GUILayout.Button(guicontent, this.bStyleSS, new GUILayoutOption[]
                    {
                        this.getWidthOpt(guicontent)
                    }))
                    {
                        color.r = (color.g = (color.b = b));
                        flag    = true;
                    }
                }
                if (GUILayout.Button("-", this.bStyleSS, new GUILayoutOption[]
                {
                    this.bWidthOpt
                }))
                {
                    if (color.r < SliderHelper.DELTA)
                    {
                        color.r = 0f;
                    }
                    else
                    {
                        color.r -= SliderHelper.DELTA;
                    }
                    if (color.g < SliderHelper.DELTA)
                    {
                        color.g = 0f;
                    }
                    else
                    {
                        color.g -= SliderHelper.DELTA;
                    }
                    if (color.b < SliderHelper.DELTA)
                    {
                        color.b = 0f;
                    }
                    else
                    {
                        color.b -= SliderHelper.DELTA;
                    }
                    flag = true;
                }
                if (GUILayout.Button("+", this.bStyleSS, new GUILayoutOption[]
                {
                    this.bWidthOpt
                }))
                {
                    if (color.r + SliderHelper.DELTA > edit.GetRange(0).editMax)
                    {
                        color.r = edit.GetRange(0).editMax;
                    }
                    else
                    {
                        color.r += SliderHelper.DELTA;
                    }
                    if (color.g + SliderHelper.DELTA > edit.GetRange(1).editMax)
                    {
                        color.g = edit.GetRange(1).editMax;
                    }
                    else
                    {
                        color.g += SliderHelper.DELTA;
                    }
                    if (color.b + SliderHelper.DELTA > edit.GetRange(2).editMax)
                    {
                        color.b = edit.GetRange(2).editMax;
                    }
                    else
                    {
                        color.b += SliderHelper.DELTA;
                    }
                    flag = true;
                }
            }
            finally
            {
                GUILayout.EndHorizontal();
            }
            int idx = 0;

            if (colType == ColorType.rgb || colType == ColorType.rgba)
            {
                flag |= this.DrawValueSlider("R", ref edit, idx++, ref color.r);
                flag |= this.DrawValueSlider("G", ref edit, idx++, ref color.g);
                flag |= this.DrawValueSlider("B", ref edit, idx++, ref color.b);
            }
            if (colType == ColorType.rgba || colType == ColorType.a)
            {
                flag |= this.DrawValueSlider("A", ref edit, idx, ref color.a);
            }
            if (picker != null && picker.expand && picker.DrawLayout())
            {
                color = picker.Color;
                flag  = true;
            }
            if (flag)
            {
                edit.Set(color);
            }
            return(flag);
        }