Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. #define CLIENT_ONLY
  2. //Made by Vamist
  3. const int X = getScreenWidth();
  4. const int Y = getScreenHeight();
  5. int currentID = 0;
  6.  
  7. class hudData
  8. {
  9. Vec2f TopLeft;
  10. Vec2f BotRight;
  11. string BlobName;
  12. string ImageID;
  13. int ObjAmount;
  14. SColor Col;
  15.  
  16. hudData(Vec2f TopLeftCorner, Vec2f BotRightCorner, string name,string imageName)
  17. {
  18. TopLeft = TopLeftCorner;
  19. BotRight = BotRightCorner;
  20. ImageID = imageName;
  21. BlobName = name;
  22. Col = SColor(255,255,255,255);
  23. }
  24.  
  25. void addVertextPos()
  26. {
  27. v_r_invoBack.push_back(Vertex(TopLeft.x , TopLeft.y , 1, 0, 0, Col));
  28. v_r_invoBack.push_back(Vertex(BotRight.x, TopLeft.y , 1, 1, 0, Col));
  29. v_r_invoBack.push_back(Vertex(BotRight.x, BotRight.y, 1, 1, 1, Col));
  30. v_r_invoBack.push_back(Vertex(TopLeft.x , BotRight.y, 1, 0, 1, Col));
  31. }
  32.  
  33. void addSpritePos()
  34. {
  35. v_r_temp_data.push_back(Vertex(TopLeft.x , TopLeft.y , 1, 0, 0, Col));
  36. v_r_temp_data.push_back(Vertex(BotRight.x, TopLeft.y , 1, 1, 0, Col));
  37. v_r_temp_data.push_back(Vertex(BotRight.x, BotRight.y, 1, 1, 1, Col));
  38. v_r_temp_data.push_back(Vertex(TopLeft.x , BotRight.y, 1, 0, 1, Col));
  39. }
  40. }
  41.  
  42.  
  43. class groupedHudData
  44. {
  45. hudData[] DataArray;
  46.  
  47. int Gap = 20;//Pixel gap between each 'slot'
  48. Vec2f TopLeftStartPos = Vec2f(30,50);
  49. Vec2f BotRightStartPos = Vec2f(80,100);
  50.  
  51. groupedHudData()
  52. {
  53.  
  54. }
  55.  
  56. void addBlob(CBlob@ blob)
  57. {
  58. for(int a = 0; a < DataArray.length(); ++a)
  59. {
  60. if(DataArray[a].BlobName == blob.getName())
  61. {
  62. DataArray[a].ObjAmount += blob.getQuantity();
  63. return;
  64. }
  65. }
  66.  
  67. newHud(blob);
  68. }
  69.  
  70. void newHud(CBlob@ blob)
  71. {
  72. print(DataArray.length()+ "");
  73. int num = ((BotRightStartPos.y - TopLeftStartPos.y) + Gap) * DataArray.length();
  74. Vec2f tempTop = Vec2f(TopLeftStartPos.x, TopLeftStartPos.y + num );
  75. Vec2f tempBot = Vec2f(BotRightStartPos.x,BotRightStartPos.y + num );
  76. //tempTop.y += Gap * num;
  77. //tempBot.y += Gap * num;
  78. print(blob.getSprite().asLayer().getFilename());
  79. hudData tempData = hudData(tempTop,tempBot,blob.getName(),blob.getSprite().asLayer().getFilename());
  80. DataArray.push_back(tempData);
  81. tempData.addVertextPos();
  82. }
  83.  
  84. }
  85.  
  86.  
  87. void onInit(CBlob@ this)
  88. {
  89. Reset();
  90. }
  91.  
  92. void onInit(CSprite@ this)
  93. {
  94. Reset();
  95. }
  96.  
  97. void Reset()
  98. {
  99. currentID = Render::addScript(Render::layer_prehud, "DefaultActorHUD.as", "hiHud", 0.0f);
  100. }
  101.  
  102. void onDie( CBlob@ this )
  103. {
  104. Render::RemoveScript(currentID);
  105. }
  106.  
  107. void hiHud(int id)//New onRender
  108. {
  109. CPlayer@ p = getLocalPlayer();
  110. byeHud(p,p.getBlob());
  111. }
  112.  
  113. groupedHudData Data = groupedHudData();
  114. Vertex[] v_r_temp_data;
  115. Vertex[] v_r_hearts;
  116. Vertex[] v_r_invoBack;
  117.  
  118. void byeHud(CPlayer@ p, CBlob@ this)
  119. {
  120. Render::SetTransformScreenspace();
  121. Render::RawQuads("backdrop.png", v_r_invoBack);
  122. for(int a = 0; a < Data.DataArray.length(); a++)
  123. {
  124. Data.DataArray[a].addSpritePos();
  125. Render::RawQuads(Data.DataArray[a].ImageID, v_r_temp_data);
  126. v_r_temp_data.clear();
  127. }
  128. }
  129.  
  130. void onAddToInventory( CBlob@ this, CBlob@ blob )
  131. {
  132. Data.addBlob(blob);
  133. }
  134.  
  135. void onRemoveFromInventory( CBlob@ this, CBlob@ blob )
  136. {
  137. print(blob.getName());
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement