Beispiel #1
0
        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;
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
 static bool Prefix(VirtualFile file, ref Texture2D __result)
 {
     __result = StaticTools.LoadTexture(file);
     return(false);
 }