public void WriteProcessingData(Rect rect) { GUI.BeginGroup(rect); Rect buttonRect = new Rect(0, 5, rect.width * 0.2f, 22); Rect barRect = new Rect(buttonRect.xMax + 5, 5, rect.width - buttonRect.width - 5, 22); float curY = buttonRect.height; string text = shouldRecalc ? (shouldStop ? "Continue" : "Stop") : "Recalculate"; if (Widgets.ButtonText(buttonRect, text, true, false, CurrentMods.Any())) { Notify_ChangeState(); } Widgets.FillableBar(barRect, TotalPctUsage, StaticContent.blue, Texture2D.blackTexture, true); Text.Anchor = TextAnchor.MiddleCenter; string label = MEMOVERFLOW ? "Not Enough VRAM" : MemoryString(TotalBytes) + "/" + MemoryString(TotalVRAM); Widgets.Label(barRect, label); Text.Anchor = default; if (Calculating) { string calcLabel = "Calculating... Please wait. (" + MemoryUsageByMod.Count + "/" + CurrentMods.Count() + ")"; var textSize = Text.CalcHeight(calcLabel, rect.width); Rect textRect = new Rect(0, curY + 5, rect.width, textSize); Widgets.Label(textRect, calcLabel); curY = textRect.yMax; } /*else if (GraphicSetter.settings.AnySettingsChanged()) * { * string settingsChangedLabel = "Settings changed, recalculate to check the memory use!"; * var textSize = Text.CalcHeight(settingsChangedLabel, rect.width); * Rect textRect = new Rect(0, curY + 5, rect.width, textSize); * Widgets.Label(textRect, settingsChangedLabel); * curY = textRect.yMax; * } */ if (Critical) { Text.Font = GameFont.Small; string warningLabel = "Warning:\n" + (MEMOVERFLOW ? "Your system cannot support these settings.\nCompression will be enabled on startup." : "Your system may struggle with these settings."); var textSize = Text.CalcHeight(warningLabel, rect.width); Rect warningLabelRect = new Rect(0, curY + 5, rect.width, textSize); Widgets.Label(warningLabelRect, warningLabel); Text.Font = default; } GUI.EndGroup(); }
public void Notify_ChangeState() { if (!CurrentMods.Any()) { return; } if (shouldRecalc) { shouldStop = !shouldStop; return; } routine = StaticContent.CoroutineDriver.StartCoroutine(DoTheThing()); shouldRecalc = true; }
public IEnumerator DoTheThing() { MemoryUsageByMod.Clear(); int count = CurrentMods.Count(); int k = 0; while (shouldStop || k < count) { if (shouldStop) { yield return(null); continue; } var mod = CurrentMods.ElementAt(k); MemoryUsageByMod.Add(mod, 0); Dictionary <string, FileInfo> allFilesForMod = ModContentPack.GetAllFilesForMod(mod, GenFilePaths.ContentPath <Texture2D>(), (ModContentLoader <Texture2D> .IsAcceptableExtension)); int i = 0; while (shouldStop || i < allFilesForMod.Count) { if (shouldStop) { yield return(null); continue; } var pair = allFilesForMod.ElementAt(i); MemoryUsageByMod[mod] += StaticTools.TextureSize(new VirtualFileWrapper(pair.Value)); i++; if (i % 3 == 0) { yield return(null); } } LargestModSize = MemoryUsageByMod[mod] > LargestModSize ? MemoryUsageByMod[mod] : LargestModSize; k++; } shouldRecalc = false; GraphicSetter.settings.CausedMemOverflow = MEMOVERFLOW; }
public void DrawModList(Rect rect) { Widgets.DrawBoxSolid(rect, ListingBG); GUI.color = Color.gray; Widgets.DrawBox(rect, 1); GUI.color = Color.white; Rect newRect = rect.ContractedBy(5); GUI.BeginGroup(newRect); int y = 0; Rect viewRect = new Rect(0, 0, newRect.width, CurrentMods.Count() * 20); Widgets.BeginScrollView(new Rect(0, 0, newRect.width, newRect.height), ref scrollview, viewRect, false); var list = MemoryUsageByMod.ToList(); list.Sort((p1, p2) => p2.Value.CompareTo(p1.Value)); foreach (var mod in list) { var pct = MemoryPctOf(mod.Key, out long memUsage); var text = mod.Key.Name + " (" + MemoryString(memUsage) + ") " + pct.ToStringPercent(); var tipRect = new Rect(0, y, rect.width, 20); StaticTools.FillableBarLabeled(new Rect(0, y, newRect.width, 18), pct, text, GetColorFor(mod.Key), Color.clear, false); //WidgetRow row = new WidgetRow(0, y, UIDirection.RightThenDown); //row.FillableBar(newRect.width, 18, pct, text, GetColorFor(pct), StaticContent.clear); Widgets.DrawHighlightIfMouseover(tipRect); TooltipHandler.TipRegion(tipRect, text); y += 20; } if (!MemoryUsageByMod.Any()) { string text = CurrentMods.Any() ? $"{CurrentMods.Count()} mods to process...": "No mods to process."; float textHeight = Text.CalcHeight(text, rect.width); Widgets.Label(new Rect(0, y, rect.width, textHeight), text); } Widgets.EndScrollView(); GUI.EndGroup(); }
private void load(OsuColour colours) { BeatmapSelectButton beatmapButton; ModDisplay modDisplay; InternalChildren = new Drawable[] { new Container { RelativeSizeAxes = Axes.Both, Masking = true, Children = new Drawable[] { new HeaderBackgroundSprite { RelativeSizeAxes = Axes.Both }, new Box { RelativeSizeAxes = Axes.Both, Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.4f), Color4.Black.Opacity(0.6f)), }, } }, new Box { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, Height = 1, Colour = colours.Yellow }, new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING }, Children = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Padding = new MarginPadding { Top = 20 }, Direction = FillDirection.Vertical, Children = new Drawable[] { new BeatmapTypeInfo(), modDisplay = new ModDisplay { Scale = new Vector2(0.75f), DisplayUnrankedText = false }, } }, new Container { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, RelativeSizeAxes = Axes.Y, Width = 200, Padding = new MarginPadding { Vertical = 10 }, Child = beatmapButton = new BeatmapSelectButton { RelativeSizeAxes = Axes.Both, Height = 1, }, }, Tabs = new MatchTabControl { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X }, }, }, }; CurrentMods.BindValueChanged(m => modDisplay.Current.Value = m, true); beatmapButton.Action = () => RequestBeatmapSelection?.Invoke(); }