예제 #1
0
        public override void DrawMiddle(float x, ref float y, float width)
        {
            WindowUtil.PlusMinusLabel(x, ref y, width, "Components",
                                      delegate
            {
                Find.WindowStack.Add(new Dialog_StoryTellerComponentDialog(v =>
                {
                    if (v == null)
                    {
                        return("Component must be set");
                    }
                    AcceptanceReport r = this.IsUnique(v);
                    if (!r.Accepted)
                    {
                        return(r);
                    }

                    this.comps.Add(new StorytellerCompPropertiesWidget(v));
                    base.Def.comps.Add(v);

                    return(true);
                }));
            },
                                      delegate
            {
                WindowUtil.DrawFloatingOptions(
                    new WindowUtil.FloatOptionsArgs <StorytellerCompPropertiesWidget>()
                {
                    items          = this.comps,
                    getDisplayName = c => c.DisplayLabel,
                    onSelect       = c =>
                    {
                        for (int i = 0; i < this.comps.Count; ++i)
                        {
                            if (this.comps[i] == c)
                            {
                                this.comps.RemoveAt(i);
                                base.Def.comps.RemoveAt(i);
                            }
                        }
                    }
                });
            });

            foreach (var v in this.comps)
            {
                v.Draw(x + 10, ref y, width);
            }
        }
        protected override void DrawInputs(float x, ref float y, float width)
        {
            if (this.curve != null)
            {
                WindowUtil.PlusMinusLabel(x, ref y, width, this.name,
                                          () =>
                {
                    MinMaxFloatStats p = new MinMaxFloatStats(0, 0);
                    this.points.Add(p);
                    this.pointsInputs.Add(this.CreateFloatInput(p));
                },
                                          () => WindowUtil.DrawFloatingOptions(pointsArgs));
                SimpleCurveDrawer.DrawCurve(new Rect(x + 20, y, width, 100), curve);
                y += 110;

                if (this.innerY > 300)
                {
                    Widgets.BeginScrollView(
                        new Rect(x + 20, y, width - 16, 300),
                        ref this.scroll,
                        new Rect(0, 0, width - 32, this.innerY));
                    this.innerY = 0;

                    foreach (var v in this.pointsInputs)
                    {
                        v.Draw(10, ref this.innerY, width - 60);
                    }

                    Widgets.EndScrollView();
                    y += 332;
                }
                else
                {
                    this.innerY = 0;
                    foreach (var v in this.pointsInputs)
                    {
                        float orig = y;
                        v.Draw(10, ref y, width - 60);
                        this.innerY += y - orig;
                    }
                }
            }
        }
        public void Draw(float x, ref float y, float width)
        {
            WindowUtil.DrawLabel(x, y, width, this.DisplayLabel, true);
            y += 40;

            x += 10;
            WindowUtil.DrawLabel(x, y, 100, "Min");
            if (Widgets.ButtonText(new Rect(110f, y, 100, 30), this.QualityRange.min.GetLabel()))
            {
                WindowUtil.DrawFloatingOptions(this.MinQualityRange);
            }
            y += 40;

            WindowUtil.DrawLabel(x, y, 100, "Max");
            if (Widgets.ButtonText(new Rect(110f, y, 100, 30), this.QualityRange.max.GetLabel()))
            {
                WindowUtil.DrawFloatingOptions(this.MaxQualityRange);
            }
            y += 40;
        }
예제 #4
0
        private void DrawTools(float x, ref float y, float width)
        {
            WindowUtil.PlusMinusLabel(x, ref y, width, "Tools",
                                      delegate
            {
                Find.WindowStack.Add(new Dialog_Name(
                                         "Name the new tool",
                                         delegate(string name)
                {
                    Tool t = new Tool()
                    {
                        label = name
                    };
                    base.Def.tools.Add(t);
                    this.ToolWidgets.Add(new ToolWidget(t));
                },
                                         delegate(string name)
                {
                    foreach (Tool t in base.Def.tools)
                    {
                        if (t.label.Equals(name))
                        {
                            return("Tool with name \"" + name + "\" already exists.");
                        }
                    }
                    return(true);
                }));
            },
                                      delegate
            {
                WindowUtil.DrawFloatingOptions(
                    new WindowUtil.FloatOptionsArgs <Tool>()
                {
                    items          = base.Def.tools,
                    getDisplayName = delegate(Tool t) { return(t.label); },
                    onSelect       = delegate(Tool t)
                    {
                        for (int i = 0; i < base.Def.tools.Count; ++i)
                        {
                            if (base.Def.tools[i].label.Equals(t.label))
                            {
                                base.Def.tools.RemoveAt(i);
                                break;
                            }
                        }
                        for (int i = 0; i < this.ToolWidgets.Count; ++i)
                        {
                            if (this.ToolWidgets[i].Tool.label.Equals(t.label))
                            {
                                this.ToolWidgets.RemoveAt(i);
                                break;
                            }
                        }
                    }
                });
            });
            y += 10;

            x += 10;

            foreach (ToolWidget w in this.ToolWidgets)
            {
                w.Draw(x, ref y, width - x);
            }
        }