Advertisement
Guest User

inventory - Draw GUI

a guest
Jan 22nd, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. /// @description
  2.  
  3. if(!show_inventory) exit; // Don't run anything under this if the inventory is shut
  4.  
  5. // ----- Inventory Background
  6. inv_ui_sprite = draw_sprite_part_ext(s_inventory_ui, 0, cell_size, 0, inv_ui_width, inv_ui_height, inv_ui_x, inv_ui_y, scale, scale, c_white, inv_alpha);
  7.  
  8. // ----- Player Info
  9. var info_grid = ds_player_info;
  10.  
  11. //Player's Name
  12. draw_set_font(fnt_manaspace_medium);
  13. var c = c_white;
  14. draw_text_colour(info_x, info_y, info_grid[# 1, 3], c, c, c, c, 1);
  15.  
  16. //Player's Money
  17. draw_set_font(fnt_manaspace_small);
  18. var yy = 0; repeat(3) {
  19.  
  20. draw_text_colour(info_x + (192*scale) + ((15+18)*scale*yy), info_y+2, string(info_grid[# 1, yy]), c, c, c, c, 1);
  21. yy++;
  22. }
  23.  
  24. // ----- Inventory
  25.  
  26. var ii, ix, iy, xx, yy, sx, sy, iitem, inv_grid;
  27. ii = 0; ix = 0; iy = 0; inv_grid = ds_inventory;
  28.  
  29. repeat(inv_slots) {
  30. // Slot's x, y
  31. xx = slots_x + ((cell_size+x_buffer)*ix*scale);
  32. yy = slots_y + ((cell_size+y_buffer)*iy*scale);
  33.  
  34. // Get Item From Grid
  35. iitem = inv_grid[# 0, ii];
  36. //Get Item's Sprite Location on Item Sprite Sheet
  37. sx = (iitem mod s_inv_items_columns)*cell_size;
  38. sy = (iitem div s_inv_items_columns)*cell_size;
  39.  
  40. // Draw Slot
  41. draw_sprite_part_ext(s_inv_ui, 0, 0, 0, cell_size, cell_size, xx, yy, scale, scale, c_white, inv_alpha/2);
  42.  
  43. // Draw Item
  44. switch(ii) {
  45. case selected_slot: // Draw when the mouse is over this slot
  46. if(iitem > 0) draw_sprite_part_ext(s_inv_items, 0, sx, sy, cell_size, cell_size, xx, yy, scale, scale, c_white, 1);
  47.  
  48. gpu_set_blendmode(bm_add);
  49. draw_sprite_part_ext(s_inv_ui, 0, 0, 0, cell_size, cell_size, xx, yy, scale, scale, c_white, .3);
  50. gpu_set_blendmode(bm_normal);
  51. break;
  52.  
  53. case pickup_slot:
  54. //Do Nothing atm
  55. break;
  56.  
  57.  
  58. default: // Draw the item normally
  59. if(iitem > 0) draw_sprite_part_ext(s_inv_items, 0, sx, sy, cell_size, cell_size, xx, yy, scale, scale, c_white, 1);
  60. break;
  61. }
  62.  
  63. //Draw Item Count
  64. switch(ii) {
  65.  
  66. case pickup_slot:
  67. //Do Nothing atm
  68. break;
  69.  
  70. default:
  71. if(iitem > 0) {
  72. c = c_white
  73. draw_set_font(fnt_manaspace_small);
  74. var inum = inv_grid[# 1, ii];
  75. draw_set_halign(fa_right);
  76. if(inum > 1) draw_text_colour(xx+(cell_size*scale)-2, yy+2, string(inum), c, c, c, c, 1);
  77. draw_set_halign(fa_left);
  78. }
  79. break;
  80. }
  81.  
  82. // Increment
  83. ii++; // Selects next Slot
  84. ix = ii mod inv_slots_width; // Finds what slot in the row to be on (0 - 8)
  85. iy = ii div inv_slots_width; // Finds what row to be on
  86. }
  87.  
  88. if(pickup_slot != -1) {
  89. // Get Item From Grid
  90. iitem = inv_grid[# 0, pickup_slot];
  91. //Get Item's Sprite Location on Item Sprite Sheet
  92. sx = (iitem mod s_inv_items_columns)*cell_size;
  93. sy = (iitem div s_inv_items_columns)*cell_size;
  94.  
  95. if(iitem > 0) draw_sprite_part_ext(s_inv_items, 0, sx, sy, cell_size, cell_size, mousex, mousey, scale, scale, c_white, inv_alpha);
  96.  
  97. var inum = inv_grid[# 1, pickup_slot];
  98. draw_set_halign(fa_right);
  99. if(inum > 1) draw_text_colour(mousex+(cell_size*scale)-2, mousey+2, string(inum), c, c, c, c, inv_alpha);
  100. draw_set_halign(fa_left);
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement