Esempio n. 1
0
 public static void CollapsibleSectionHeader(Rect rect, SectionRect section, string text)
 {
     if (Widgets.ButtonText(rect, text))
     {
         section.isCollapsed = !section.isCollapsed;
     }
 }
Esempio n. 2
0
        public void SetupJobSections(Rect jobRect)
        {
            if (jobSections == null)
            {
                jobSections = new List <SectionRect>();
                //
                //  Description
                //
                SectionRect descriptionSection = new SectionRect();
                descriptionSection.renderAction =
                    delegate(Rect rect)
                {
                    //Head section.
                    Rect collapsibleRect = rect;
                    collapsibleRect.height = descriptionSection.collapsedHeight;

                    DivineJobsUI.CollapsibleSectionHeader(collapsibleRect, descriptionSection, "DivineJobs_Tab_Jobs_Description".Translate());

                    if (!descriptionSection.isCollapsed)
                    {
                        rect.height -= collapsibleRect.height;
                        rect.y      += collapsibleRect.height;
                        Widgets.Label(rect, def.description);
                    }
                };
                descriptionSection.heightGetter =
                    delegate()
                {
                    return(DivineJobsUI.RowHeight + Text.CalcHeight(def.description, jobRect.width));
                };
                jobSections.Add(descriptionSection);

                //
                //  Level Modifiers
                //
                SectionRect levelModifierSection = new SectionRect();
                levelModifierSection.renderAction =
                    delegate(Rect rect)
                {
                    //Head section.
                    Rect collapsibleRect = rect;
                    collapsibleRect.height = levelModifierSection.collapsedHeight;

                    DivineJobsUI.CollapsibleSectionHeader(collapsibleRect, levelModifierSection, "DivineJobs_Tab_Jobs_LevelModifiers".Translate());

                    if (!levelModifierSection.isCollapsed)
                    {
                        rect.height -= collapsibleRect.height;
                        rect.y      += collapsibleRect.height;

                        int stageInt = 0;
                        foreach (DivineJobsLevelStage stage in def.levelStages)
                        {
                            //Stage Level
                            rect.height = DivineJobsUI.RowHeight;
                            if (level == stageInt)
                            {
                                Widgets.DrawBoxSolid(rect, Color.yellow);
                            }
                            else
                            {
                                Widgets.DrawBoxSolid(rect, Color.cyan);
                            }
                            Color color = GUI.color;
                            GUI.color   = Color.black;
                            Text.Anchor = TextAnchor.MiddleCenter;
                            Widgets.Label(rect, $"{stageInt + 1}");
                            Text.Anchor = TextAnchor.UpperLeft;
                            GUI.color   = color;
                            rect.y     += DivineJobsUI.RowHeight;

                            //Stage content
                            float stageHeight = DivineJobsUI.CalculateHeightOfStageModifier(stage);
                            rect.height = stageHeight;
                            DivineJobsUI.FillStageModifier(rect, stage, level == stageInt, owner);
                            rect.y += stageHeight;
                            stageInt++;
                        }
                    }
                };
                levelModifierSection.heightGetter =
                    delegate()
                {
                    float result = DivineJobsUI.RowHeight;
                    foreach (DivineJobsLevelStage stage in def.levelStages)
                    {
                        result += DivineJobsUI.RowHeight + DivineJobsUI.CalculateHeightOfStageModifier(stage);
                    }
                    return(result);
                };
                jobSections.Add(levelModifierSection);

                //
                //  Experience graph -- experienceGraph
                //
                experienceGraph = new GraphView(def.ExperiencePerLevelRequired);
                experienceGraph.SetupGraph();
                SectionRect experienceGraphSection = new SectionRect();
                experienceGraphSection.renderAction =
                    delegate(Rect rect)
                {
                    //Head section.
                    Rect collapsibleRect = rect;
                    collapsibleRect.height = experienceGraphSection.collapsedHeight;

                    DivineJobsUI.CollapsibleSectionHeader(collapsibleRect, experienceGraphSection, "DivineJobs_Tab_Jobs_ExperienceGraph".Translate());

                    if (!experienceGraphSection.isCollapsed)
                    {
                        rect.height -= collapsibleRect.height;
                        rect.y      += collapsibleRect.height;

                        rect.width = rect.height;
                        rect.x    += rect.width / 2f;

                        experienceGraph.OnGUI(rect);
                    }
                };
                experienceGraphSection.heightGetter =
                    delegate()
                {
                    float result = DivineJobsUI.RowHeight + 256f;
                    return(result);
                };
                jobSections.Add(experienceGraphSection);
            }
        }