Example #1
0
 private void DrawInventory()
 {
     ExtendedConsole.ClearConsoleArea((short)(Console.BufferWidth - (INV_WIDTH - 1)), 1, INV_WIDTH - 1,
                                      (short)(Console.BufferHeight - (1 + 3)));
     Console.SetCursorPosition(Console.BufferWidth - (INV_WIDTH - 2), 1);
     foreach (var item in Player.Items)
     {
         if (item is LiquidContainerItem)
         {
             ("» " + item.Name).Write();
             Console.ForegroundColor = ConsoleColor.DarkGray;
             var li = item as LiquidContainerItem;
             var ml = li.LiquidTypes.Max(o => o.Length);
             var mt = li.LiquidUnits.Values.Max(o => o.Length);
             var am = li.LiquidStorage.Values.Max(o => $"{o:0.##}".Length);
             var mm = li.LiquidMax.Values.Max(o => $"{o:0.##}".Length);
             foreach (var l in li.LiquidTypes.Where(o => li.LiquidStorage[o] > 0))
             {
                 var a    = li.LiquidStorage[l];
                 var m    = li.LiquidMax[l];
                 var astr = $"{a:0.##}";
                 var mstr = $"{m:0.##}";
                 var amnt = $"{new string(' ', am - astr.Length)}{astr}/{mstr}{li.LiquidUnits[l]}{new string(' ', mt - li.LiquidUnits[l].Length)}{new string(' ', mm - mstr.Length)}";
                 var w    = (INV_WIDTH - 7) - (ml + amnt.Length);
                 var p    = (int)(w * (a / m));
                 Console.SetCursorPosition(Console.BufferWidth - (INV_WIDTH - 2), Console.CursorTop + 1);
                 var n = $"{l}{new string(' ', ml - l.Length)}";
                 Console.Write($"∙ {n} {amnt} {new string('█', p)}");
                 Console.Write(new string('░', w - p));
             }
         }
         else
         {
             ("» " + item.Name).Write();
         }
         Console.SetCursorPosition(Console.BufferWidth - (INV_WIDTH - 2), Console.CursorTop + 1);
     }
 }