private AbstractRenderable MakeStatLabel(int stat) { if (stat < 100000) { return(AbstractRenderable.MakeLabel(FontManager.tooltip, stat.ToString())); } else if (stat < 10000000) { return(AbstractRenderable.MakeLabel(FontManager.tooltip, (stat / 1000).ToString() + "K")); } else { return(AbstractRenderable.MakeLabel(FontManager.tooltip, (stat / 1000000).ToString() + "M")); } }
private void ShowPerformanceTab() { Optional <string> cycleCounts = (Optional <string>)Empty.INSTANCE; Optional <string> reactorCounts = (Optional <string>)Empty.INSTANCE; Optional <string> symbolCounts = (Optional <string>)Empty.INSTANCE; Optional <HistogramsContent> histogramsContent = LocalHistogramsUtils.GetScoreOrEmpty(CurrentPuzzle.name); if (histogramsContent.isPresent) { cycleCounts = (Optional <string>)histogramsContent.GetValue().cycleCounts; reactorCounts = (Optional <string>)histogramsContent.GetValue().reactorCounts; symbolCounts = (Optional <string>)histogramsContent.GetValue().symbolCounts; } bool isDefense = PuzzleManager.IsDefense(CurrentPuzzle.name); AbstractRenderable completedLabel = AbstractRenderable.MakeColoredLabel(FontManager.huge, Localization.Localize("Assignment Complete!", "ENGLISH ALPHABET ONLY"), LabelFactory.darkYellow); AbstractRenderable mainUIBlock; // here is the only change: the section that made a dummy box in the defense case was removed, // so that we show full metrics for them as well (sadly the game has no hist data) if (Constants.ShowLeaderboards()) { Optional <MetricLeaderboard> cyclesLB = PuzzlesUtils.GetSteamLBForLevelAndMetric(CurrentPuzzle.name, MetricType.Cycles); Optional <MetricLeaderboard> reactorsLB = PuzzlesUtils.GetSteamLBForLevelAndMetric(CurrentPuzzle.name, MetricType.Reactors); Optional <MetricLeaderboard> symbolsLB = PuzzlesUtils.GetSteamLBForLevelAndMetric(CurrentPuzzle.name, MetricType.Symbols); Optional <int> thisCycles = thisScore.isPresent ? GetCycles_1(thisScore.GetValue()) : Optional <int> .ABSENT; Optional <int> bestCycles = bestScore.isPresent ? GetCycles_2(bestScore.GetValue()) : Optional <int> .ABSENT; Optional <int> newBestCycles = MinOptional(thisCycles, bestCycles); Optional <int> thisReactors = thisScore.isPresent ? GetReactors_1(thisScore.GetValue()) : Optional <int> .ABSENT; Optional <int> bestReactors = bestScore.isPresent ? GetReactors_2(bestScore.GetValue()) : Optional <int> .ABSENT; Optional <int> newBestReactors = MinOptional(thisReactors, bestReactors); Optional <int> thisSymbols = thisScore.isPresent ? GetSymbols_1(thisScore.GetValue()) : Optional <int> .ABSENT; Optional <int> bestSymbols = bestScore.isPresent ? GetSymbols_2(bestScore.GetValue()) : Optional <int> .ABSENT; Optional <int> newBestSymbols = MinOptional(thisSymbols, bestSymbols); AbstractRenderable pressTABLabel = AbstractRenderable.EMPTY; if (SystemUtils.isSteamVersion) { pressTABLabel = FontManager.tooltip.MakeRenderable(Localization.Localize("Press Tab to view\nGRAPHS."), HorizontalAlignment.Center, (Optional <int>)Empty.INSTANCE).WithColor(LabelFactory.paleBlue); } mainUIBlock = completedLabel.WithAddedRenderableBelow(AbstractRenderable.LayoutVertically(HorizontalAlignment.Center, 20, new AbstractRenderable[2] { AbstractRenderable.MakeColoredLabel(FontManager.large, Localization.Localize("Your performance, compared to other engineers, is as follows:"), LabelFactory.paleBlue), AbstractRenderable.LayoutHorizontally(VerticalAlignment.Center, 40, new AbstractRenderable[4] { pressTABLabel, HistogramUtils.MakeLeaderboard(cyclesLB, newBestCycles, HistogramUtils.elapsedCycles, false, false, false), HistogramUtils.MakeLeaderboard(reactorsLB, newBestReactors, HistogramUtils.reactorsUsed, false, false, false), HistogramUtils.MakeLeaderboard(symbolsLB, newBestSymbols, HistogramUtils.symbolsUsed, false, false, false) }) }), HorizontalAlignment.Center, 20); } else { AbstractRenderable pressTABLabel = AbstractRenderable.EMPTY; if (SystemUtils.isSteamVersion) { pressTABLabel = FontManager.tooltip.MakeRenderable(Localization.Localize("Press Tab to view\nLEADERBOARDS."), HorizontalAlignment.Center, (Optional <int>)Empty.INSTANCE).WithColor(LabelFactory.paleBlue); } AbstractRenderable[] histogramsBlock = new AbstractRenderable[4] { pressTABLabel, null, null, null }; Optional <int> thisCycles = thisScore.isPresent ? GetCycles_3(thisScore.GetValue()) : Optional <int> .ABSENT; Optional <int> bestCycles = bestScore.isPresent ? GetCycles_4(bestScore.GetValue()) : Optional <int> .ABSENT; AbstractRenderable cyclesHist = HistogramUtils.MakeHistogram(cycleCounts, thisCycles, bestCycles, Localization.Localize("THIS"), HistogramUtils.elapsedCycles, false, false, false); histogramsBlock[1] = cyclesHist; Optional <int> thisReactors = thisScore.isPresent ? GetReactors_3(thisScore.GetValue()) : Optional <int> .ABSENT; Optional <int> bestReactors = bestScore.isPresent ? GetReactors_4(bestScore.GetValue()) : Optional <int> .ABSENT; AbstractRenderable reactorsHist = HistogramUtils.MakeHistogram(reactorCounts, thisReactors, bestReactors, Localization.Localize("THIS"), HistogramUtils.reactorsUsed, false, false, false); histogramsBlock[2] = reactorsHist; Optional <int> thisSymbols = thisScore.isPresent ? GetSymbols_3(thisScore.GetValue()) : Optional <int> .ABSENT; Optional <int> bestSymbols = bestScore.isPresent ? GetSymbols_4(bestScore.GetValue()) : Optional <int> .ABSENT; AbstractRenderable symbolsHist = HistogramUtils.MakeHistogram(symbolCounts, thisSymbols, bestSymbols, Localization.Localize("THIS"), HistogramUtils.symbolsUsed, false, false, false); histogramsBlock[3] = symbolsHist; AbstractRenderable histogramsRow = AbstractRenderable.LayoutHorizontally(VerticalAlignment.Center, 40, histogramsBlock); AbstractRenderable[] mainBlock = new AbstractRenderable[2] { AbstractRenderable.MakeColoredLabel(FontManager.large, Localization.Localize("Your performance, compared to other engineers, is as follows:"), LabelFactory.paleBlue), histogramsRow }; AbstractRenderable mainRow = AbstractRenderable.LayoutVertically(HorizontalAlignment.Center, 20, mainBlock); mainUIBlock = completedLabel.WithAddedRenderableBelow(mainRow, HorizontalAlignment.Center, 20); } AbstractRenderable achievBox = BoxesButtonsFactory.MakeAngledBox(new Vector2i(560, 150), LabelFactory.paleBlue, LabelFactory.gray); Optional <Achievement> completedAchiev = CurrentPuzzle.GetCompletedAchievement(); if (this.plaqueLevel.isPresent) { achievBox = achievBox.WithAddedCenteredRenderable(AbstractRenderable.MakeColoredLabel(FontManager.medium, Localization.Localize("Congratulations! You have been promoted to"), LabelFactory.paleBlue) .WithAddedRenderableBelow(AbstractRenderable.MakeColoredLabel(FontManager.large, this.plaqueLevel.GetValue(), LabelFactory.paleBlue), HorizontalAlignment.Center, 10)); } else if (completedAchiev.isPresent && completedAchiev.GetValue().showAtLevelEnd) { achievBox = achievBox.WithAddedCenteredRenderable(AbstractRenderable.MakeColoredLabel(FontManager.large, Localization.Localize("Challenge complete!"), LabelFactory.paleBlue) .WithAddedRenderableBelow(completedAchiev.GetValue().AchievIcon(), HorizontalAlignment.Center, 0)); } AbstractRenderable recordButtonContent = AbstractRenderable.LayoutVertically(HorizontalAlignment.Center, 0, new AbstractRenderable[5] { AbstractRenderable.MakeLabel(FontManager.large, Localization.Localize("Record Solution")), FontManager.normal.MakeRenderable(Localization.Localize("After recording your solution, you can save the video to your desktop or upload it to a YouTube account."), HorizontalAlignment.Center, (Optional <int>) 280), AbstractRenderable.MakeBlankRenderable(new BoundingBox(0, 0, 1, 8)), AbstractRenderable.MakeTexturedRectangle(ResourceUtils.LoadResource <TextureElement>("misc/youtube_small")), AbstractRenderable.MakeBlankRenderable(new BoundingBox(0, 0, 1, 8)) }); if (isDefense) { recordButtonContent = AbstractRenderable.MakeColoredLabel(FontManager.large, Localization.Localize("Record Solution"), LabelFactory.paleBlue) .WithAddedRenderableBelow(FontManager.normal.MakeRenderable(Localization.Localize("The details of this assignment are SpaceChem confidential and may not be shared with unprivileged employees."), HorizontalAlignment.Center, (Optional <int>) 280), HorizontalAlignment.Center, 0); } if (AbstractGame.FBOUnavailable || SystemUtils.GetOnlive()) { recordButtonContent = AbstractRenderable.MakeColoredLabel(FontManager.large, Localization.Localize("Record Solution"), LabelFactory.paleBlue) .WithAddedRenderableBelow(FontManager.normal.MakeRenderable(Localization.Localize("This action is disabled."), HorizontalAlignment.Center, (Optional <int>) 280), HorizontalAlignment.Center, 0); } Button recordButton; AbstractRenderable achievUIBlock = achievBox.WithAddedRenderableAbove(AbstractRenderable.MakeColoredLabel(FontManager.large, Localization.Localize("Additional Information"), LabelFactory.darkYellow), HorizontalAlignment.Right, 10); AbstractUiElement performanceUI = AbstractUiElement.LayoutVertically(HorizontalAlignment.Center, 20, new AbstractUiElement[2] { (AbstractUiElement)mainUIBlock, AbstractUiElement.LayoutHorizontally(VerticalAlignment.Center, 30, new AbstractUiElement[2] { (AbstractUiElement)achievUIBlock, AbstractUiElement.LayoutVertically(HorizontalAlignment.Center, 15, new AbstractUiElement[1] { (recordButton = LabelFactory.MakeButtonWithContent(recordButtonContent, new Vector2i(300, 200), new Action(OpenRecordingScreen))) }) }) }); if (AbstractGame.FBOUnavailable || isDefense || SystemUtils.GetOnlive()) { recordButton.SetEnabled(false); } AbstractRenderable performanceTab = AbstractRenderable.MakeTexturedRectangle(ResourceUtils.LoadResource <TextureElement>("mainmenu/story_background")).WithTranslation(7, 59) .NullSafeWithAddedRenderable(MakeTabButtonState(Localization.Localize("Performance"), false, false).WithTranslation(AfterVictoryScreen.positionTab3)) .NullSafeWithAddedRenderable(AbstractRenderable.MakeTexturedRectangle(ResourceUtils.LoadResource <TextureElement>("mainmenu/story_tab_bottom")).WithTranslation(AfterVictoryScreen.positionTab3 + new Vector2i(0, 52))); wholeUI = new WholeUI((AbstractUI) new UiElementContainer(new ContainedUiElement[5] { new ContainedUiElement(Vector2i.NULL, MakeTopBar()), new ContainedUiElement(new Vector2i(AfterVictoryScreen.positionTab1), MakeTabButton(Localization.Localize("Story"), storyIsPresentAndUnlocked, new Action(ShowStoryTab_1))), new ContainedUiElement(new Vector2i(AfterVictoryScreen.positionTab2), MakeTabButton(Localization.Localize("Training"), trainingIsPresentAndUnlocked, new Action(ShowTrainingTab_1))), new ContainedUiElement(Vector2i.NULL, (AbstractUiElement)performanceTab), new ContainedUiElement(new Vector2i(512, 120), performanceUI) }), false, (Optional <AbstractUiElement>)Empty.INSTANCE, this); }
public static Button MakeButtonWithContent(AbstractRenderable content, Vector2i size, Action action) => null;
public AbstractRenderable WithAddedRenderableAbove(AbstractRenderable renderable, HorizontalAlignment alignment, int padding) => null;
public AbstractRenderable WithAddedCenteredRenderable(AbstractRenderable renderable) => null;
public AbstractRenderable NullSafeWithAddedRenderable(AbstractRenderable renderable) => null;