Exemplo n.º 1
0
 public override void PostOpen()
 {
     base.PostOpen();
     tabs.Clear();
     foreach (ResearchTabDef allDef in DefDatabase <ResearchTabDef> .AllDefs)
     {
         ResearchTabDef localTabDef = allDef;
         tabs.Add(new TabRecord(localTabDef.LabelCap, delegate
         {
             CurTab = localTabDef;
         }, () => CurTab == localTabDef));
     }
 }
Exemplo n.º 2
0
        private Vector2 ViewSize(ResearchTabDef tab)
        {
            List <ResearchProjectDef> allDefsListForReading = DefDatabase <ResearchProjectDef> .AllDefsListForReading;
            float num  = 0f;
            float num2 = 0f;

            Text.Font = GameFont.Small;
            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                ResearchProjectDef researchProjectDef = allDefsListForReading[i];
                if (researchProjectDef.tab == tab)
                {
                    Rect rect = new Rect(0f, 0f, 140f, 0f);
                    Widgets.LabelCacheHeight(ref rect, GetLabel(researchProjectDef), renderLabel: false);
                    num  = Mathf.Max(num, PosX(researchProjectDef) + 140f);
                    num2 = Mathf.Max(num2, PosY(researchProjectDef) + rect.height);
                }
            }
            return(new Vector2(num + 20f, num2 + 20f));
        }
        private Vector2 ViewSize(ResearchTabDef tab)
        {
            List <ResearchProjectDef> visibleResearchProjects = VisibleResearchProjects;
            float num  = 0f;
            float num2 = 0f;

            Text.Font = GameFont.Small;
            for (int i = 0; i < visibleResearchProjects.Count; i++)
            {
                ResearchProjectDef researchProjectDef = visibleResearchProjects[i];
                if (researchProjectDef.tab == tab)
                {
                    Rect rect = new Rect(0f, 0f, 140f, 0f);
                    Widgets.LabelCacheHeight(ref rect, GetLabel(researchProjectDef) + "\n", renderLabel: false);
                    num  = Mathf.Max(num, PosX(researchProjectDef) + 140f);
                    num2 = Mathf.Max(num2, PosY(researchProjectDef) + rect.height);
                }
            }
            return(new Vector2(num + 20f, num2 + 20f));
        }
Exemplo n.º 4
0
        private void DrawRightRect(Rect rightOutRect)
        {
            rightOutRect.yMin += 32f;
            Widgets.DrawMenuSection(rightOutRect);
            List <TabRecord> list = new List <TabRecord>();

            foreach (ResearchTabDef allDef in DefDatabase <ResearchTabDef> .AllDefs)
            {
                ResearchTabDef localTabDef = allDef;
                list.Add(new TabRecord(localTabDef.LabelCap, delegate
                {
                    CurTab = localTabDef;
                }, CurTab == localTabDef));
            }
            TabDrawer.DrawTabs(rightOutRect, list);
            if (Prefs.DevMode)
            {
                Rect rect = rightOutRect;
                rect.yMax = rect.yMin + 20f;
                rect.xMin = rect.xMax - 80f;
                Rect butRect = rect.RightPartPixels(30f);
                rect = rect.LeftPartPixels(rect.width - 30f);
                Widgets.CheckboxLabeled(rect, "Edit", ref editMode);
                if (Widgets.ButtonImageFitted(butRect, TexButton.Copy))
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (ResearchProjectDef item in from def in DefDatabase <ResearchProjectDef> .AllDefsListForReading
                             where def.Debug_IsPositionModified()
                             select def)
                    {
                        stringBuilder.AppendLine(item.defName);
                        stringBuilder.AppendLine(string.Format("  <researchViewX>{0}</researchViewX>", item.ResearchViewX.ToString("F2")));
                        stringBuilder.AppendLine(string.Format("  <researchViewY>{0}</researchViewY>", item.ResearchViewY.ToString("F2")));
                        stringBuilder.AppendLine();
                    }
                    GUIUtility.systemCopyBuffer = stringBuilder.ToString();
                    Messages.Message("Modified data copied to clipboard.", MessageTypeDefOf.SituationResolved, historical: false);
                }
            }
            else
            {
                editMode = false;
            }
            Rect outRect = rightOutRect.ContractedBy(10f);
            Rect rect2   = new Rect(0f, 0f, rightViewWidth, rightViewHeight);
            Rect rect3   = rect2.ContractedBy(10f);

            rect2.width = rightViewWidth;
            rect3       = rect2.ContractedBy(10f);
            Vector2 start = default(Vector2);
            Vector2 end   = default(Vector2);

            Widgets.ScrollHorizontal(outRect, ref rightScrollPosition, rect2);
            Widgets.BeginScrollView(outRect, ref rightScrollPosition, rect2);
            GUI.BeginGroup(rect3);
            List <ResearchProjectDef> allDefsListForReading = DefDatabase <ResearchProjectDef> .AllDefsListForReading;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < allDefsListForReading.Count; j++)
                {
                    ResearchProjectDef researchProjectDef = allDefsListForReading[j];
                    if (researchProjectDef.tab == CurTab)
                    {
                        start.x = PosX(researchProjectDef);
                        start.y = PosY(researchProjectDef) + 25f;
                        for (int k = 0; k < researchProjectDef.prerequisites.CountAllowNull(); k++)
                        {
                            ResearchProjectDef researchProjectDef2 = researchProjectDef.prerequisites[k];
                            if (researchProjectDef2 != null && researchProjectDef2.tab == CurTab)
                            {
                                end.x = PosX(researchProjectDef2) + 140f;
                                end.y = PosY(researchProjectDef2) + 25f;
                                if (selectedProject == researchProjectDef || selectedProject == researchProjectDef2)
                                {
                                    if (i == 1)
                                    {
                                        Widgets.DrawLine(start, end, TexUI.HighlightLineResearchColor, 4f);
                                    }
                                }
                                else if (i == 0)
                                {
                                    Widgets.DrawLine(start, end, TexUI.DefaultLineResearchColor, 2f);
                                }
                            }
                        }
                    }
                }
            }
            for (int l = 0; l < allDefsListForReading.Count; l++)
            {
                ResearchProjectDef researchProjectDef3 = allDefsListForReading[l];
                if (researchProjectDef3.tab == CurTab)
                {
                    Rect   source    = new Rect(PosX(researchProjectDef3), PosY(researchProjectDef3), 140f, 50f);
                    string label     = GetLabel(researchProjectDef3);
                    Rect   rect4     = new Rect(source);
                    Color  textColor = Widgets.NormalOptionColor;
                    Color  color     = default(Color);
                    Color  color2    = default(Color);
                    bool   flag      = !researchProjectDef3.IsFinished && !researchProjectDef3.CanStartNow;
                    if (researchProjectDef3 == Find.ResearchManager.currentProj)
                    {
                        color = TexUI.ActiveResearchColor;
                    }
                    else if (researchProjectDef3.IsFinished)
                    {
                        color = TexUI.FinishedResearchColor;
                    }
                    else if (flag)
                    {
                        color = TexUI.LockedResearchColor;
                    }
                    else if (researchProjectDef3.CanStartNow)
                    {
                        color = TexUI.AvailResearchColor;
                    }
                    if (selectedProject == researchProjectDef3)
                    {
                        color += TexUI.HighlightBgResearchColor;
                        color2 = TexUI.HighlightBorderResearchColor;
                    }
                    else
                    {
                        color2 = TexUI.DefaultBorderResearchColor;
                    }
                    if (flag)
                    {
                        textColor = ProjectWithMissingPrerequisiteLabelColor;
                    }
                    for (int m = 0; m < researchProjectDef3.prerequisites.CountAllowNull(); m++)
                    {
                        ResearchProjectDef researchProjectDef4 = researchProjectDef3.prerequisites[m];
                        if (researchProjectDef4 != null && selectedProject == researchProjectDef4)
                        {
                            color2 = TexUI.HighlightLineResearchColor;
                        }
                    }
                    if (requiredByThisFound)
                    {
                        for (int n = 0; n < researchProjectDef3.requiredByThis.CountAllowNull(); n++)
                        {
                            ResearchProjectDef researchProjectDef5 = researchProjectDef3.requiredByThis[n];
                            if (selectedProject == researchProjectDef5)
                            {
                                color2 = TexUI.HighlightLineResearchColor;
                            }
                        }
                    }
                    if (Widgets.CustomButtonText(ref rect4, label, color, textColor, color2, cacheHeight: true))
                    {
                        SoundDefOf.Click.PlayOneShotOnCamera();
                        selectedProject = researchProjectDef3;
                    }
                    if (editMode && Mouse.IsOver(rect4) && Input.GetMouseButtonDown(0))
                    {
                        draggingTab = researchProjectDef3;
                    }
                }
            }
            GUI.EndGroup();
            Widgets.EndScrollView();
            if (!Input.GetMouseButton(0))
            {
                draggingTab = null;
            }
            if (draggingTab != null && !Input.GetMouseButtonDown(0) && Event.current.type == EventType.Layout)
            {
                ResearchProjectDef researchProjectDef6 = draggingTab;
                Vector2            delta = Event.current.delta;
                float   x      = PixelsToCoordX(delta.x);
                Vector2 delta2 = Event.current.delta;
                researchProjectDef6.Debug_ApplyPositionDelta(new Vector2(x, PixelsToCoordY(delta2.y)));
            }
        }
        private void DrawRightRect(Rect rightOutRect)
        {
            rightOutRect.yMin += 32f;
            Widgets.DrawMenuSection(rightOutRect);
            List <TabRecord> list = new List <TabRecord>();

            foreach (ResearchTabDef allDef in DefDatabase <ResearchTabDef> .AllDefs)
            {
                ResearchTabDef localTabDef = allDef;
                list.Add(new TabRecord(localTabDef.LabelCap, delegate
                {
                    this.CurTab = localTabDef;
                }, this.CurTab == localTabDef));
            }
            TabDrawer.DrawTabs(rightOutRect, list);
            Rect outRect = rightOutRect.ContractedBy(10f);
            Rect rect    = new Rect(0f, 0f, this.rightViewWidth, this.rightViewHeight);
            Rect rect2   = rect.ContractedBy(10f);

            rect.width = this.rightViewWidth;
            rect2      = rect.ContractedBy(10f);
            Vector2 start = default(Vector2);
            Vector2 end   = default(Vector2);

            Widgets.ScrollHorizontal(outRect, ref this.rightScrollPosition, rect, 20f);
            Widgets.BeginScrollView(outRect, ref this.rightScrollPosition, rect, true);
            GUI.BeginGroup(rect2);
            List <ResearchProjectDef> allDefsListForReading = DefDatabase <ResearchProjectDef> .AllDefsListForReading;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < allDefsListForReading.Count; j++)
                {
                    ResearchProjectDef researchProjectDef = allDefsListForReading[j];
                    if (researchProjectDef.tab == this.CurTab)
                    {
                        start.x = this.PosX(researchProjectDef);
                        start.y = (float)(this.PosY(researchProjectDef) + 25.0);
                        for (int k = 0; k < researchProjectDef.prerequisites.CountAllowNull(); k++)
                        {
                            ResearchProjectDef researchProjectDef2 = researchProjectDef.prerequisites[k];
                            if (researchProjectDef2 != null && researchProjectDef2.tab == this.CurTab)
                            {
                                end.x = (float)(this.PosX(researchProjectDef2) + 140.0);
                                end.y = (float)(this.PosY(researchProjectDef2) + 25.0);
                                if (this.selectedProject == researchProjectDef || this.selectedProject == researchProjectDef2)
                                {
                                    if (i == 1)
                                    {
                                        Widgets.DrawLine(start, end, TexUI.HighlightLineResearchColor, 4f);
                                    }
                                }
                                else if (i == 0)
                                {
                                    Widgets.DrawLine(start, end, TexUI.DefaultLineResearchColor, 2f);
                                }
                            }
                        }
                    }
                }
            }
            for (int l = 0; l < allDefsListForReading.Count; l++)
            {
                ResearchProjectDef researchProjectDef3 = allDefsListForReading[l];
                if (researchProjectDef3.tab == this.CurTab)
                {
                    Rect   source    = new Rect(this.PosX(researchProjectDef3), this.PosY(researchProjectDef3), 140f, 50f);
                    string label     = this.GetLabel(researchProjectDef3);
                    Rect   rect3     = new Rect(source);
                    Color  textColor = Widgets.NormalOptionColor;
                    Color  color     = default(Color);
                    Color  color2    = default(Color);
                    bool   flag      = !researchProjectDef3.IsFinished && !researchProjectDef3.CanStartNow;
                    if (researchProjectDef3 == Find.ResearchManager.currentProj)
                    {
                        color = TexUI.ActiveResearchColor;
                    }
                    else if (researchProjectDef3.IsFinished)
                    {
                        color = TexUI.FinishedResearchColor;
                    }
                    else if (flag)
                    {
                        color = TexUI.LockedResearchColor;
                    }
                    else if (researchProjectDef3.CanStartNow)
                    {
                        color = TexUI.AvailResearchColor;
                    }
                    if (this.selectedProject == researchProjectDef3)
                    {
                        color += TexUI.HighlightBgResearchColor;
                        color2 = TexUI.HighlightBorderResearchColor;
                    }
                    else
                    {
                        color2 = TexUI.DefaultBorderResearchColor;
                    }
                    if (flag)
                    {
                        textColor = MainTabWindow_Research.ProjectWithMissingPrerequisiteLabelColor;
                    }
                    for (int m = 0; m < researchProjectDef3.prerequisites.CountAllowNull(); m++)
                    {
                        ResearchProjectDef researchProjectDef4 = researchProjectDef3.prerequisites[m];
                        if (researchProjectDef4 != null && this.selectedProject == researchProjectDef4)
                        {
                            color2 = TexUI.HighlightLineResearchColor;
                        }
                    }
                    if (this.requiredByThisFound)
                    {
                        for (int n = 0; n < researchProjectDef3.requiredByThis.CountAllowNull(); n++)
                        {
                            ResearchProjectDef researchProjectDef5 = researchProjectDef3.requiredByThis[n];
                            if (this.selectedProject == researchProjectDef5)
                            {
                                color2 = TexUI.HighlightLineResearchColor;
                            }
                        }
                    }
                    if (Widgets.CustomButtonText(ref rect3, label, color, textColor, color2, true, 1, true, true))
                    {
                        SoundDefOf.Click.PlayOneShotOnCamera(null);
                        this.selectedProject = researchProjectDef3;
                    }
                }
            }
            GUI.EndGroup();
            Widgets.EndScrollView();
        }
 private float <get_InitialSize> m__0(ResearchTabDef tab)
 {
     return(this.ViewSize(tab).y);
 }