Advertisement
RyanCordell

doom zsbarinfo

Apr 12th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.71 KB | None | 0 0
  1. class DoomStatusBar : BaseStatusBar
  2. {
  3.     HUDFont mHUDFont;
  4.     HUDFont mIndexFont;
  5.     HUDFont mAmountFont;
  6.     InventoryBarState diparms;
  7.    
  8.  
  9.     override void Init()
  10.     {
  11.         Super.Init();
  12.         SetSize(32, 320, 200);
  13.  
  14.         // Create the font used for the fullscreen HUD
  15.         Font fnt = "HUDFONT_DOOM";
  16.         mHUDFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), true, 1, 1);
  17.         fnt = "INDEXFONT_DOOM";
  18.         mIndexFont = HUDFont.Create(fnt, fnt.GetCharWidth("0"), true);
  19.         mAmountFont = HUDFont.Create("INDEXFONT");
  20.         diparms = InventoryBarState.Create();
  21.     }
  22.  
  23.     override void DrawAutomapHUD(double ticFrac)
  24.     {
  25.         // This uses the normal automap HUD but just changes the highlight color.
  26.         DoDrawAutomapHUD(Font.CR_GREY, Font.CR_UNTRANSLATED);
  27.     }
  28.    
  29.     override void Draw (int state, double TicFrac)
  30.     {
  31.         Super.Draw (state, TicFrac);
  32.  
  33.         if (state == HUD_StatusBar)
  34.         {
  35.             BeginStatusBar();
  36.             DrawMainBar (TicFrac);
  37.         }
  38.         else if (state == HUD_Fullscreen)
  39.         {
  40.             BeginHUD();
  41.             DrawFullScreenStuff ();
  42.         }
  43.     }
  44.  
  45.     protected void DrawMainBar (double TicFrac)
  46.     {
  47.         DrawImage("STBAR", (0, 168), DI_ITEM_OFFSETS);
  48.         DrawImage("STTPRCNT", (90, 171), DI_ITEM_OFFSETS);
  49.         DrawImage("STTPRCNT", (221, 171), DI_ITEM_OFFSETS);
  50.        
  51.         Inventory a1 = GetCurrentAmmo();
  52.         if (a1 != null) DrawString(mHUDFont, FormatNumber(a1.Amount, 3), (44, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
  53.         DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (90, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
  54.         DrawString(mHUDFont, FormatNumber(GetArmorAmount(), 3), (221, 171), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW);
  55.  
  56.         bool locks[6];
  57.         String image;
  58.         for(int i = 0; i < 6; i++) locks[i] = CPlayer.mo.CheckKeys(i + 1, false, true);
  59.         // key 1
  60.         if (locks[1] && locks[4]) image = "STKEYS6";
  61.         else if (locks[1]) image = "STKEYS0";
  62.         else if (locks[4]) image = "STKEYS3";
  63.         DrawImage(image, (239, 171), DI_ITEM_OFFSETS);
  64.         // key 2
  65.         if (locks[2] && locks[5]) image = "STKEYS7";
  66.         else if (locks[2]) image = "STKEYS1";
  67.         else if (locks[5]) image = "STKEYS4";
  68.         else image = "";
  69.         DrawImage(image, (239, 181), DI_ITEM_OFFSETS);
  70.         // key 3
  71.         if (locks[0] && locks[3]) image = "STKEYS8";
  72.         else if (locks[0]) image = "STKEYS2";
  73.         else if (locks[3]) image = "STKEYS5";
  74.         else image = "";
  75.         DrawImage(image, (239, 191), DI_ITEM_OFFSETS);
  76.        
  77.         int amt1, maxamt;
  78.         [amt1, maxamt] = GetAmount("Clip");
  79.         DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 173), DI_TEXT_ALIGN_RIGHT);
  80.         DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 173), DI_TEXT_ALIGN_RIGHT);
  81.  
  82.         [amt1, maxamt] = GetAmount("Shell");
  83.         DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 179), DI_TEXT_ALIGN_RIGHT);
  84.         DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 179), DI_TEXT_ALIGN_RIGHT);
  85.  
  86.         [amt1, maxamt] = GetAmount("RocketAmmo");
  87.         DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 185), DI_TEXT_ALIGN_RIGHT);
  88.         DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 185), DI_TEXT_ALIGN_RIGHT);
  89.  
  90.         [amt1, maxamt] = GetAmount("Cell");
  91.         DrawString(mIndexFont, FormatNumber(amt1, 3), (288, 191), DI_TEXT_ALIGN_RIGHT);
  92.         DrawString(mIndexFont, FormatNumber(maxamt, 3), (314, 191), DI_TEXT_ALIGN_RIGHT);
  93.        
  94.         if (deathmatch || teamplay)
  95.         {
  96.             DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (138, 171), DI_TEXT_ALIGN_RIGHT);
  97.         }
  98.         else
  99.         {
  100.             DrawImage("STARMS", (104, 168), DI_ITEM_OFFSETS);
  101.             DrawImage(CPlayer.HasWeaponsInSlot(2)? "STYSNUM2" : "STGNUM2", (111, 171), DI_ITEM_OFFSETS);
  102.             DrawImage(CPlayer.HasWeaponsInSlot(3)? "STYSNUM3" : "STGNUM3", (123, 171), DI_ITEM_OFFSETS);
  103.             DrawImage(CPlayer.HasWeaponsInSlot(4)? "STYSNUM4" : "STGNUM4", (135, 171), DI_ITEM_OFFSETS);
  104.             DrawImage(CPlayer.HasWeaponsInSlot(5)? "STYSNUM5" : "STGNUM5", (111, 181), DI_ITEM_OFFSETS);
  105.             DrawImage(CPlayer.HasWeaponsInSlot(6)? "STYSNUM6" : "STGNUM6", (123, 181), DI_ITEM_OFFSETS);
  106.             DrawImage(CPlayer.HasWeaponsInSlot(7)? "STYSNUM7" : "STGNUM7", (135, 181), DI_ITEM_OFFSETS);
  107.         }
  108.        
  109.         if (multiplayer)
  110.         {
  111.             DrawImage("STFBANY", (143, 168), DI_ITEM_OFFSETS|DI_TRANSLATABLE);
  112.         }
  113.        
  114.         if (CPlayer.mo.InvSel != null && !level.NoInventoryBar)
  115.         {
  116.             DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198));
  117.             if (CPlayer.mo.InvSel.Amount > 1)
  118.             {
  119.                 DrawString(mAmountFont, FormatNumber(CPlayer.mo.InvSel.Amount), (175, 198-mIndexFont.mFont.GetHeight()), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD);
  120.             }
  121.         }
  122.         else
  123.         {
  124.             DrawTexture(GetMugShot(5), (143, 168), DI_ITEM_OFFSETS);
  125.         }
  126.         if (isInventoryBarVisible())
  127.         {
  128.             DrawInventoryBar(diparms, (48, 169), 7, DI_ITEM_LEFT_TOP);
  129.         }
  130.        
  131.     }
  132.  
  133.     protected void DrawFullScreenStuff ()
  134.     {
  135.         Vector2 iconbox = (40, 20);
  136.         // Draw health
  137.         let berserk = CPlayer.mo.FindInventory("PowerStrength");
  138.         DrawImage(berserk? "PSTRA0" : "MEDIA0", (20, -2));
  139.         DrawString(mHUDFont, FormatNumber(CPlayer.health, 3), (44, -20));
  140.        
  141.         let armor = CPlayer.mo.FindInventory("BasicArmor");
  142.         if (armor != null)
  143.         {
  144.             DrawInventoryIcon(armor, (20, -22));
  145.             DrawString(mHUDFont, FormatNumber(armor.Amount, 3), (44, -40));
  146.         }
  147.         Inventory ammotype1, ammotype2;
  148.         [ammotype1, ammotype2] = GetCurrentAmmo();
  149.         int invY = -20;
  150.         if (ammotype1 != null)
  151.         {
  152.             DrawInventoryIcon(ammotype1, (-14, -4));
  153.             DrawString(mHUDFont, FormatNumber(ammotype1.Amount, 3), (-30, -20), DI_TEXT_ALIGN_RIGHT);
  154.             invY -= 20;
  155.         }
  156.         if (ammotype2 != null && ammotype2 != ammotype1)
  157.         {
  158.             DrawInventoryIcon(ammotype2, (-14, invY + 17));
  159.             DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);
  160.             invY -= 20;
  161.         }
  162.         if (!isInventoryBarVisible() && !level.NoInventoryBar && CPlayer.mo.InvSel != null)
  163.         {
  164.             DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17));
  165.             DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT);
  166.         }
  167.         if (deathmatch)
  168.         {
  169.             DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (-3, 1), DI_TEXT_ALIGN_RIGHT, Font.CR_GOLD);
  170.         }
  171.        
  172.         // Draw the keys. This does not use a special draw function like SBARINFO because the specifics will be different for each mod
  173.         // so it's easier to copy or reimplement the following piece of code instead of trying to write a complicated all-encompassing solution.
  174.         Vector2 keypos = (-10, 2);
  175.         int rowc = 0;
  176.         double roww = 0;
  177.         for(let i = CPlayer.mo.Inv; i != null; i = i.Inv)
  178.         {
  179.             if (i is "Key" && i.Icon.IsValid())
  180.             {
  181.                 DrawTexture(i.Icon, keypos, DI_SCREEN_RIGHT_TOP|DI_ITEM_LEFT_TOP);
  182.                 Vector2 size = TexMan.GetScaledSize(i.Icon);
  183.                 keypos.Y += size.Y + 2;
  184.                 roww = max(roww, size.X);
  185.                 if (++rowc == 3)
  186.                 {
  187.                     keypos.Y = 2;
  188.                     keypos.X -= roww + 2;
  189.                     roww = 0;
  190.                     rowc = 0;
  191.                 }
  192.             }
  193.         }
  194.         if (isInventoryBarVisible())
  195.         {
  196.             DrawInventoryBar(diparms, (0, 0), 7, DI_SCREEN_CENTER_BOTTOM, HX_SHADOW);
  197.         }
  198.     }
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement