コード例 #1
0
        public override void DoWindowContents(Rect inRect)
        {
            EItemUpdateStatus eItemUpdateStatus;
            float             num;

            Workshop.GetUpdateStatus(out eItemUpdateStatus, out num);
            WorkshopInteractStage curStage = Workshop.CurStage;

            if (curStage == WorkshopInteractStage.None && eItemUpdateStatus == EItemUpdateStatus.k_EItemUpdateStatusInvalid)
            {
                this.Close(true);
                return;
            }
            string text = string.Empty;

            if (curStage != WorkshopInteractStage.None)
            {
                text += curStage.GetLabel();
                text += "\n\n";
            }
            if (eItemUpdateStatus != EItemUpdateStatus.k_EItemUpdateStatusInvalid)
            {
                text += eItemUpdateStatus.GetLabel();
                if (num > 0f)
                {
                    text = text + " (" + num.ToStringPercent() + ")";
                }
                text += GenText.MarchingEllipsis(0f);
            }
            Widgets.Label(inRect, text);
        }
コード例 #2
0
        public static void DrawLogs(Rect rect)
        {
            Widgets.DrawMenuSection(rect);

            if (!GUIController.CurrentEntry?.isPatched ?? true)
            {
                DubGUI.Heading(rect, $"Loading{GenText.MarchingEllipsis(0f)}");
                return;
            }

            var columnsR = rect.TopPartPixels(50f);

            DrawColumns(columnsR);

            columns[(int)SortBy.Average].total = 0;

            rect.AdjustVerticallyBy(columnsR.height + 4);
            rect.height -= 2f;
            rect.width  -= 2;

            Rect innerRect = rect.AtZero();

            innerRect.height = listing.curY;
            if (innerRect.height > rect.height)
            {
                innerRect.width -= 17f;
            }

            viewFrustum    = rect.AtZero();    // Our view frustum starts at 0,0 from the rect we are given
            viewFrustum.y += ScrollPosition.y; // adjust our view frustum vertically based on the scroll position

            {                                  // Begin scope for Scroll View
                Widgets.BeginScrollView(rect, ref ScrollPosition, innerRect);
                GUI.BeginGroup(innerRect);
                listing.Begin(innerRect);

                Text.Anchor = TextAnchor.MiddleCenter;
                Text.Font   = GameFont.Tiny;


                float currentListHeight = BOX_HEIGHT;

                Text.Anchor = TextAnchor.MiddleLeft;

                lock (Analyzer.LogicLock)
                {
                    foreach (ProfileLog log in Analyzer.Logs)
                    {
                        DrawLog(log, ref currentListHeight);
                    }
                }

                listing.End();
                GUI.EndGroup();
                Widgets.EndScrollView();
            }


            DubGUI.ResetFont();
        }
コード例 #3
0
        public override void DoWindowContents(Rect inRect)
        {
            Workshop.GetUpdateStatus(out EItemUpdateStatus updateStatus, out float progPercent);
            WorkshopInteractStage curStage = Workshop.CurStage;

            if (curStage == WorkshopInteractStage.None && updateStatus == EItemUpdateStatus.k_EItemUpdateStatusInvalid)
            {
                Close();
            }
            else
            {
                string text = string.Empty;
                if (curStage != 0)
                {
                    text += curStage.GetLabel();
                    text += "\n\n";
                }
                if (updateStatus != 0)
                {
                    text += updateStatus.GetLabel();
                    if (progPercent > 0f)
                    {
                        text = text + " (" + progPercent.ToStringPercent() + ")";
                    }
                    text += GenText.MarchingEllipsis();
                }
                Widgets.Label(inRect, text);
            }
        }
コード例 #4
0
        private void DoModRowDownloading(Listing_Standard listing, int index)
        {
            Rect rect = new Rect(0f, (float)index * 26f, listing.ColumnWidth, 26f);

            ContentSourceUtility.DrawContentSource(rect, ContentSource.SteamWorkshop);
            rect.xMin += 28f;
            Widgets.Label(rect, "Downloading".Translate() + GenText.MarchingEllipsis());
        }
コード例 #5
0
        private void DoModRowDownloading(Listing_Standard listing, int index)
        {
            Rect rect = listing.GetRect(26f);

            ContentSourceUtility.DrawContentSource(rect, ContentSource.SteamWorkshop, null);
            rect.xMin += 28f;
            Widgets.Label(rect, "Downloading".Translate() + GenText.MarchingEllipsis(0f));
        }
コード例 #6
0
ファイル: Panel_Logs.cs プロジェクト: Skharr/Hardcore-SK
        public static void DrawLogs(Rect rect)
        {
            Widgets.DrawMenuSection(rect);

            if (!GUIController.CurrentEntry?.isPatched ?? true)
            {
                DubGUI.Heading(rect, $"Loading{GenText.MarchingEllipsis(0f)}");
                return;
            }

            Rect innerRect = rect.AtZero();

            innerRect.height = cachedListHeight;

            viewFrustum    = rect.AtZero();    // Our view frustum starts at 0,0 from the rect we are given
            viewFrustum.y += ScrollPosition.y; // adjust our view frustum vertically based on the scroll position

            {                                  // Begin scope for Scroll View
                Widgets.BeginScrollView(rect, ref ScrollPosition, innerRect, true);
                GUI.BeginGroup(innerRect);
                listing.Begin(innerRect);

                Text.Anchor = TextAnchor.MiddleCenter;
                Text.Font   = GameFont.Tiny;

                DrawColumns(listing.GetRect(BOX_HEIGHT));
                float currentListHeight = BOX_HEIGHT;

                Text.Anchor = TextAnchor.MiddleLeft;

                lock (Analyzer.LogicLock)
                {
                    foreach (ProfileLog log in Analyzer.Logs)
                    {
                        DrawLog(log, ref currentListHeight);
                    }
                }

                cachedListHeight = currentListHeight;

                listing.End();
                GUI.EndGroup();
                Widgets.EndScrollView();
            }

            DubGUI.ResetFont();
        }
コード例 #7
0
        public static bool DrawLongEventWindowContents(Rect rect)
        {
            if (currentEvent == null)
            {
                return(false);
            }

            if (Event.current.type == EventType.Repaint)
            {
                currentEvent.alreadyDisplayed = true;
            }

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;
            float num = 0f;

            if (levelLoadOp != null)
            {
                float f = 1f;
                if (!levelLoadOp.isDone)
                {
                    f = levelLoadOp.progress;
                }

                TaggedString taggedString = "LoadingAssets".Translate() + " " + f.ToStringPercent();
                num = Text.CalcSize(taggedString).x;
                Widgets.Label(rect, taggedString);
            }
            else
            {
                lock (CurrentEventTextLock)
                {
                    num = Text.CalcSize(currentEvent.eventText).x;
                    Widgets.Label(rect, currentEvent.eventText);
                }
            }

            Text.Anchor = TextAnchor.MiddleLeft;
            rect.xMin   = rect.center.x + num / 2f;
            Widgets.Label(rect, (!currentEvent.UseAnimatedDots) ? "..." : GenText.MarchingEllipsis());
            Text.Anchor = TextAnchor.UpperLeft;
            return(false);
        }
コード例 #8
0
        private void DoThingTab(Rect rect)
        {
            if (!Analyzer.SelectedMode.IsPatched)
            {
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(rect, $"Loading{GenText.MarchingEllipsis(0f)}");
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.UpperLeft;
                return;
            }

            var  topslot = rect.TopPartPixels(20f);
            Rect rowby   = topslot.LeftPartPixels(25f);

            if (Widgets.ButtonImage(rowby, TexButton.SpeedButtonTextures[Analyzer.running ? 0 : 1]))
            {
                Analyzer.running = !Analyzer.running;
            }

            TooltipHandler.TipRegion(rowby, "Start and stop logging");
            bool save = false;

            if (Analyzer.Settings.AdvancedMode)
            {
                Rect searchbox = topslot.LeftPartPixels(topslot.width - 300f);
                searchbox.x += 25f;
                DubGUI.InputField(searchbox, "Search", ref TimesFilter, DubGUI.MintSearch);
                rowby.x     = searchbox.xMax;
                rowby.width = 175f;
                if (Widgets.ButtonTextSubtle(rowby, stlank, Mathf.Clamp01(Mathf.InverseLerp(H_RootUpdate.LastMinGC, H_RootUpdate.LastMaxGC, totalBytesOfMemoryUsed)), 5))
                {
                    totalBytesOfMemoryUsed = GC.GetTotalMemory(true);
                }
                TooltipHandler.TipRegion(rowby, "Approximation of total bytes currently allocated in managed memory + rate of new allocation\n\nClick to force GC");

                rowby.x     = rowby.xMax;
                rowby.width = 100f;
                save        = Widgets.ButtonTextSubtle(rowby, "Save .CSV");
                TooltipHandler.TipRegion(rowby, $"Save the current list of times to a csv file in {GenFilePaths.FolderUnderSaveData("Profiling")}");
            }
            else
            {
                Rect searchbox = topslot.RightPartPixels(topslot.width - 25f);
                DubGUI.InputField(searchbox, "Search", ref TimesFilter, DubGUI.MintSearch);
            }

            rowby.x     = rowby.xMax;
            rowby.width = 25f;


            rect.y      += 25f;
            rect.height -= 25f;

            var innyrek = rect.AtZero();

            innyrek.width -= 16f;
            innyrek.height = groaner;

            GizmoListRect    = rect.AtZero();
            GizmoListRect.y += scrolpos.y;
            Widgets.BeginScrollView(rect, ref scrolpos, innyrek);

            GUI.BeginGroup(innyrek);

            listing.Begin(innyrek);

            float goat = 0;

            //List<ProfileLog> logs = null;

            //if (Analyzer.SortBy == "First")
            //{
            //    logs = Analyzer.Logs.ToList();
            //}
            //else if (Analyzer.SortBy == "A-Z")
            //{
            //    logs = Analyzer.Logs.ToList().OrderBy(x => x.Key).ToList();
            //}
            //else if (Analyzer.SortBy == "Usage")
            //{
            //    logs = Analyzer.Logs.ToList().OrderByDescending(x => x.Average).ToList();
            //}

            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Tiny;

            lock (Analyzer.sync)
            {
                foreach (var log in Analyzer.Logs)
                {
                    if (!log.Label.Has(TimesFilter))
                    {
                        continue;
                    }

                    var r = listing.GetRect(40f);

                    if (r.Overlaps(GizmoListRect))
                    {
                        var profile = Analyzer.Profiles[log.Key];

                        if (Input.GetKey(KeyCode.LeftControl))
                        {
                            if (Widgets.ButtonInvisible(r))
                            {
                                Analyzer.SelectedMode.Clicked?.Invoke(null, new object[] { profile, log });
                                Analyzer.Settings.Write();
                            }
                        }

                        bool on = true;

                        if (Analyzer.SelectedMode.Selected != null)
                        {
                            on = (bool)Analyzer.SelectedMode.Selected.Invoke(null, new object[] { profile, log });
                        }

                        if (Analyzer.SelectedMode.Checkbox != null)
                        {
                            var r2 = new Rect(r.x, r.y, 25f, r.height);
                            r.x += 25f;
                            if (DubGUI.Checkbox(r2, "", ref on))
                            {
                                Analyzer.SelectedMode.Checkbox?.Invoke(null, new object[] { profile, log });
                                Analyzer.Settings.Write();
                            }
                        }

                        Widgets.DrawHighlightIfMouseover(r);

                        if (Widgets.ButtonInvisible(r))
                        {
                            Dialog_Graph.RunKey(log.Key);
                        }

                        if (Dialog_Graph.key == log.Key)
                        {
                            Widgets.DrawHighlightSelected(r);
                        }


                        var col = grey;
                        if (log.Percent > 0.25f)
                        {
                            col = blue;
                        }

                        if (log.Percent > 0.75f)
                        {
                            col = red;
                        }


                        Widgets.FillableBar(r.BottomPartPixels(8f), log.Percent, col, clear, false);

                        r = r.LeftPartPixels(50);

                        if (!on)
                        {
                            GUI.color = Color.grey;
                        }

                        Widgets.Label(r, log.Average_s);

                        if (Analyzer.Settings.AdvancedMode)
                        {
                            r.x = r.xMax;

                            Widgets.Label(r, profile.memRiseStr);
                        }

                        r.x     = r.xMax;
                        r.width = 2000;
                        Widgets.Label(r, log.Label);

                        GUI.color = Color.white;

                        if (save)
                        {
                            csv.Append($"{log.Label},{log.Average},{profile.BytesUsed}");
                            foreach (var historyTime in profile.History.times)
                            {
                                csv.Append($",{historyTime}");
                            }
                            csv.AppendLine();
                        }
                    }
                    listing.GapLine(0f);
                    goat += 4f;
                    goat += r.height;
                }
            }

            if (save)
            {
                var path = GenFilePaths.FolderUnderSaveData("Profiling") + $"/{Analyzer.SelectedMode.name}_{DateTime.Now.ToFileTime()}.csv";
                File.WriteAllText(path, csv.ToString());
                csv.Clear();
                Messages.Message($"Saved to {path}", MessageTypeDefOf.TaskCompletion, false);
            }

            listing.End();
            groaner = goat;
            GUI.EndGroup();

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.EndScrollView();
        }
コード例 #9
0
        public override void DoWindowContents(Rect canvas)
        {
            if (Event.current.type == EventType.Layout)
            {
                return;
            }

            //  canvas.y += 35;
            //   canvas.height -= 35f;

            // Widgets.DrawMenuSection(canvas);

            // TabDrawer.DrawTabs(canvas, MainTabs, 150f);

            var ListerBox = canvas.LeftPart(0.30f);

            ListerBox.width -= 10f;
            Widgets.DrawMenuSection(ListerBox);
            ListerBox = ListerBox.ContractedBy(4f);
            var innyrek = ListerBox.AtZero();

            innyrek.width -= 16f;
            innyrek.height = moaner;
            var goat = 0f;

            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Tiny;
            Widgets.BeginScrollView(ListerBox, ref scrolpostabs, innyrek);
            GUI.BeginGroup(innyrek);
            listing.Begin(innyrek);
            // var row = listing.getr

            foreach (var maintab in MainTabs)
            {
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.UpperLeft;
                goat       += 40f;
                var row = listing.GetRect(30f);
                if (maintab.Selected)
                {
                    Widgets.DrawOptionSelected(row);
                }
                if (Widgets.ButtonInvisible(row))
                {
                    maintab.clickedAction();
                }
                row.x += 5f;
                Widgets.Label(row, maintab.label);

                TooltipHandler.TipRegion(row, maintab.Tip);

                Text.Anchor = TextAnchor.MiddleLeft;
                Text.Font   = GameFont.Tiny;

                foreach (var mode in maintab.Modes)
                {
                    if (!mode.Key.Basics && !Analyzer.Settings.AdvancedMode)
                    {
                        continue;
                    }
                    row = listing.GetRect(30f);
                    Widgets.DrawHighlightIfMouseover(row);
                    if (Analyzer.SelectedMode == mode.Key)
                    {
                        Widgets.DrawOptionSelected(row);
                    }
                    row.x += 20f;
                    goat  += 30f;
                    Widgets.Label(row, mode.Key.name);
                    if (Widgets.ButtonInvisible(row))
                    {
                        if (ShowSettings)
                        {
                            ShowSettings = false;
                            Analyzer.Settings.Write();
                        }
                        if (Analyzer.SelectedMode != null)
                        {
                            AccessTools.Field(Analyzer.SelectedMode.typeRef, "Active").SetValue(null, false);
                        }
                        AccessTools.Field(mode.Value, "Active").SetValue(null, true);
                        Analyzer.SelectedMode = mode.Key;
                        Analyzer.Reset();

                        if (!mode.Key.IsPatched)
                        {
                            mode.Key.ProfilePatch();
                        }
                    }
                    TooltipHandler.TipRegion(row, mode.Key.tip);

                    if (Analyzer.SelectedMode == mode.Key)
                    {
                        var doo = 0;
                        foreach (var keySetting in mode.Key.Settings)
                        {
                            if (keySetting.Key.FieldType == typeof(bool))
                            {
                                row       = listing.GetRect(30f);
                                row.x    += 20f;
                                GUI.color = Widgets.OptionSelectedBGBorderColor;
                                Widgets.DrawLineVertical(row.x, row.y, 15f);
                                if (doo != 0)
                                {
                                    Widgets.DrawLineVertical(row.x, row.y - 15f, 15f);
                                }
                                row.x += 10f;
                                Widgets.DrawLineHorizontal(row.x - 10f, row.y + 15f, 10f);
                                GUI.color = Color.white;
                                goat     += 30f;
                                bool cur = (bool)keySetting.Key.GetValue(null);
                                if (DubGUI.Checkbox(row, keySetting.Value.name, ref cur))
                                {
                                    keySetting.Key.SetValue(null, cur);
                                    Analyzer.Reset();
                                }
                            }
                            if (keySetting.Key.FieldType == typeof(float) || keySetting.Key.FieldType == typeof(int))
                            {
                            }

                            doo++;
                        }
                    }
                }
            }

            listing.End();
            moaner = goat;
            GUI.EndGroup();

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.EndScrollView();


            var inner = canvas.RightPart(0.70f).Rounded();

            if (ShowSettings)
            {
                Analyzer.Settings.DoSettings(inner);
            }
            else
            {
                try
                {
                    if (PatchedEverything)
                    {
                        if (Dialog_Graph.key != string.Empty)
                        {
                            Rect blurg = inner.TopPart(0.75f).Rounded();
                            Widgets.DrawMenuSection(blurg);
                            blurg = blurg.ContractedBy(6f);
                            DoThingTab(blurg);
                            blurg = inner.BottomPart(0.25f).Rounded();
                            //blurg = blurg.BottomPartPixels(inner.height - 10f);
                            Dialog_Graph.DoGraph(blurg);
                        }
                        else
                        {
                            Widgets.DrawMenuSection(inner);
                            DoThingTab(inner.ContractedBy(6f));
                        }
                    }
                    else
                    {
                        Widgets.DrawMenuSection(inner);
                        Text.Font   = GameFont.Medium;
                        Text.Anchor = TextAnchor.MiddleCenter;
                        Widgets.Label(inner, $"Loading{GenText.MarchingEllipsis(0f)}");
                        Text.Font   = GameFont.Small;
                        Text.Anchor = TextAnchor.UpperLeft;
                    }
                }
                catch (Exception e)
                {
                    // Console.WriteLine(e);
                    //  throw;
                }
            }
        }
            public static bool Prefix()
            {
                if (CGO.useCustomWindowContent)
                {
                    UIMenuBackgroundManager.background = new UI_BackgroundMain();
                    UIMenuBackgroundManager.background.BackgroundOnGUI();
                    // Fill the whole screen
                    Rect fullRect = new Rect(0, 0, UI.screenWidth, UI.screenHeight);
                    // Content
                    Vector2 screenCenter = fullRect.center;

                    // Loading infos
                    Rect loadingRect = new Rect(screenCenter.x - WidthOffest, loadingRectYStart + outerBorderSize, windowWidth, (UI.screenHeight / 4) - outerBorderSize);
                    Widgets.DrawShadowAround(loadingRect);
                    Widgets.DrawWindowBackground(loadingRect);

                    if (CGO.currentGenStep == null || CGO.currentGenStep == "")
                    {
                        CGO.currentGenStep = "Generating";
                    }
                    if (CGO.currentGenStepMoreInfo == null || CGO.currentGenStepMoreInfo == "")
                    {
                        CGO.currentGenStepMoreInfo = "...";
                    }

                    Text.Anchor = TextAnchor.LowerCenter;
                    Widgets.Label(loadingRect.TopHalf().TopHalf(), CGO.currentGenStep + GenText.MarchingEllipsis(0f));
                    Widgets.Label(loadingRect.TopHalf().BottomHalf(), string.Format("<i>{0}</i>", CGO.currentGenStepMoreInfo));
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(loadingRect.BottomHalf(), (DateTime.Now - CGO.dateTime).Duration().TotalSeconds.ToString("00.00") + "s");
                    Text.Anchor = TextAnchor.UpperLeft;

                    // grid
                    Rect gridRect = new Rect(screenCenter.x - WidthOffest, gridRectYStart + innerBorderSize, windowWidth, (UI.screenHeight / 2) - innerBorderSize * 2);
                    Widgets.DrawShadowAround(gridRect);
                    Widgets.DrawWindowBackground(gridRect);

                    if (CGO.useStructureLayout)
                    {
                        if (structure == null && CGO.structureLayoutDef != null)
                        {
                            int[][] tempStructure = new int[CGO.structureLayoutDef.layouts[0][0].Split(',').Length][];
                            int     x             = CGO.structureLayoutDef.layouts[0].Count;
                            for (int i = 0; i < tempStructure.Length; i++)
                            {
                                tempStructure[i] = new int[x];
                            }

                            for (int layoutN = 0; layoutN < CGO.structureLayoutDef.layouts.Count; layoutN++)
                            {
                                for (int layoutLine = CGO.structureLayoutDef.layouts[layoutN].Count - 1; layoutLine >= 0; layoutLine--)
                                {
                                    string[] splitLine = CGO.structureLayoutDef.layouts[layoutN][layoutLine].Split(',');
                                    for (int splitN = 0; splitN < splitLine.Length; splitN++)
                                    {
                                        if (splitLine[splitN] != ".")
                                        {
                                            tempStructure[splitN][layoutLine] = 1;
                                        }
                                        else
                                        {
                                            tempStructure[splitN][layoutLine] = 0;
                                        }
                                    }
                                }
                            }
                            structure = tempStructure;
                        }
                        else
                        {
                            float smallRectWidth  = gridRect.width / structure.Length;
                            float smallRectHeight = gridRect.height / structure[0].Length;

                            float rSize = Math.Min(smallRectWidth, smallRectHeight);
                            float x     = (gridRect.width - (structure.Length * rSize)) / 2;
                            float y     = (gridRect.height - (structure[0].Length * rSize)) / 2;

                            for (int i = 0; i < structure.Length; i++)
                            {
                                for (int j = 0; j < structure[0].Length; j++)
                                {
                                    if (structure[i][j] == 1)
                                    {
                                        Rect rect = new Rect(gridRect.x + x + (i * rSize), gridRect.y + y + (j * rSize), rSize, rSize);
                                        GUI.DrawTexture(rect, BaseContent.WhiteTex);
                                    }
                                }
                            }
                        }
                    }
                    else if (CGO.grid != null)
                    {
                        float smallRectWidth  = gridRect.width / CGO.grid[0].Length;
                        float smallRectHeight = gridRect.height / CGO.grid.Length;

                        float rSize = Math.Min(smallRectWidth, smallRectHeight);
                        float x     = (gridRect.width - (CGO.grid.Length * rSize)) / 2;
                        float y     = (gridRect.height - (CGO.grid[0].Length * rSize)) / 2;

                        for (int i = 0; i < CGO.grid.Length; i++)
                        {
                            for (int j = 0; j < CGO.grid[0].Length; j++)
                            {
                                Rect     rect = new Rect(gridRect.x + x + (i * rSize), gridRect.y + y + (j * rSize), rSize, rSize);
                                CellType type = CGO.grid[i][j].Type;
                                GUI.color = type == CellType.BUILDING || type == CellType.BUILDINGPASSABLE ? Color.black :
                                            (type == CellType.DOOR ? Color.black :
                                             (type == CellType.MAINROAD || type == CellType.ROAD ? Color.grey :
                                              (type == CellType.WATER ? Color.blue :
                                               (type == CellType.FIELD ? Color.green :
                                                Color.clear))));
                                GUI.DrawTexture(rect, BaseContent.WhiteTex);
                                GUI.color = Color.white;
                            }
                        }
                    }

                    // tip
                    Rect tipRect = new Rect(screenCenter.x - WidthOffest, tipsRectYStart, windowWidth, (UI.screenHeight / 4) - outerBorderSize);
                    Widgets.DrawShadowAround(tipRect);
                    Widgets.DrawWindowBackground(tipRect);

                    if (CGO.tipAvailable && (currentTip == null || DateTime.Now.Ticks - lastTipShownTick >= 60000000) && CGO.allTip.Count > 1)
                    {
                        currentTip       = CGO.allTip.RandomElement();
                        lastTipShownTick = DateTime.Now.Ticks;
                    }
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(tipRect, string.Format("<size=16>{0}</size>", currentTip));
                    Text.Anchor = TextAnchor.UpperLeft;
                    return(false);
                }
                return(true);
            }
コード例 #11
0
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Medium;
            var titleRect = new Rect(inRect.x, inRect.y, inRect.width, 40);

            Widgets.Label(titleRect, "HugsLib_logs_publisherTitle".Translate());
            Text.Font = GameFont.Small;
            var labelEntry      = statusMessages[publisher.Status];
            var statusLabelText = labelEntry.requiresEllipsis ? labelEntry.labelKey.Translate(GenText.MarchingEllipsis(Time.realtimeSinceStartup)) : labelEntry.labelKey.Translate();

            if (publisher.Status == LogPublisher.PublisherStatus.Error)
            {
                statusLabelText = String.Format(statusLabelText, publisher.ErrorMessage);
            }
            var statusLabelRect = new Rect(inRect.x, inRect.y + titleRect.height, inRect.width, StatusLabelHeight);

            Widgets.Label(statusLabelRect, statusLabelText);
            if (publisher.Status == LogPublisher.PublisherStatus.Done)
            {
                var urlAreaRect = new Rect(inRect.x, statusLabelRect.y + statusLabelRect.height, inRect.width, CopyButtonSize.y);
                GUI.DrawTexture(urlAreaRect, UrlBackgroundTex);
                var urlLabelRect = new Rect(urlAreaRect.x, urlAreaRect.y, urlAreaRect.width - CopyButtonSize.x, urlAreaRect.height);
                Text.Font = GameFont.Medium;
                var prevAnchor = Text.Anchor;
                Text.Anchor = TextAnchor.MiddleCenter;
                var croppedResultUrl = publisher.ResultUrl;
                if (croppedResultUrl.Length > MaxResultUrlLength)
                {
                    // crop the url in case shortening has failed and the original url is displayed
                    croppedResultUrl = croppedResultUrl.Substring(0, MaxResultUrlLength) + "...";
                }
                Widgets.Label(urlLabelRect, croppedResultUrl);
                Text.Anchor = prevAnchor;
                Text.Font   = GameFont.Small;
                var copyBtnRect = new Rect(inRect.width - CopyButtonSize.x, urlAreaRect.y, CopyButtonSize.x, CopyButtonSize.y);
                if (Widgets.ButtonText(copyBtnRect, "HugsLib_logs_copy".Translate()))
                {
                    HugsLibUtility.CopyToClipboard(publisher.ResultUrl);
                }
            }
            var bottomLeftBtnRect = new Rect(inRect.x, inRect.height - ControlButtonSize.y, ControlButtonSize.x, ControlButtonSize.y);

            if (publisher.Status == LogPublisher.PublisherStatus.Error)
            {
                if (Widgets.ButtonText(bottomLeftBtnRect, "HugsLib_logs_retryBtn".Translate()))
                {
                    publisher.BeginUpload();
                }
            }
            else if (publisher.Status == LogPublisher.PublisherStatus.Done)
            {
                if (Widgets.ButtonText(bottomLeftBtnRect, "HugsLib_logs_browseBtn".Translate()))
                {
                    Application.OpenURL(publisher.ResultUrl);
                }
            }
            var bottomRightBtnRect = new Rect(inRect.width - ControlButtonSize.x, inRect.height - ControlButtonSize.y, ControlButtonSize.x, ControlButtonSize.y);

            if (publisher.Status == LogPublisher.PublisherStatus.Uploading)
            {
                if (Widgets.ButtonText(bottomRightBtnRect, "HugsLib_logs_abortBtn".Translate()))
                {
                    publisher.AbortUpload();
                }
            }
            else
            {
                if (Widgets.ButtonText(bottomRightBtnRect, "CloseButton".Translate()))
                {
                    Close();
                }
            }
        }
コード例 #12
0
        private void DoStatusReadout(Rect inRect)
        {
            string status;

            if (previewGenerator.NumQueuedPreviews > 0)
            {
                status = "Reroll2_previews_statusGenerating".Translate(previewGenerator.NumQueuedPreviews, GenText.MarchingEllipsis());
            }
            else
            {
                status = "Reroll2_previews_statusComplete".Translate(previewGenerator.PreviewCount);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(inRect, status);
            Text.Anchor = TextAnchor.UpperLeft;
        }