Zorothegallade

Untitled

Feb 20th, 2021 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. #Zorothegallade's Earthbound-like PSI menu.
  2. #HOW TO USE
  3. #This script will make all of the actor's skills appear in the same menu regardless of category.
  4. #They will be separated into rows depending on their type.
  5. #Make sure the database is arranged so that skills of the same type are grouped together.
  6. #They will appear in the window in the same order they are in the database
  7. #This script is free for use for commercial and noncommercial use, as long as you give credit to the author (Zorothegallade or Ares Vaiarelli)
  8.  
  9. module ZOROGALLADE_PSIMENU
  10. ##############START OF CONFIG##############
  11. HEADER_COLOR = Color.new(200,200,200, 255) #change the color of the header
  12. MAX_COLUMNS = 5 #maximum number of columns, aka max levels of a skill
  13. WHITELISTED_CHARACTERS = /[^αβγδΣ]/ #Only these characters from the skill name will appear in the menu
  14. ##############END OF CONFIG##############
  15. end
  16.  
  17. class Window_SkillList < Window_Selectable
  18. attr_accessor :current_header
  19.  
  20. def col_max
  21. return ZOROGALLADE_PSIMENU::MAX_COLUMNS
  22. end
  23.  
  24. def draw_all_items
  25. item_max.times {|i| draw_item(i) }
  26. end
  27.  
  28. def include?(item)
  29. true
  30. end
  31.  
  32. def make_item_list
  33. @data = []
  34. current_type = nil
  35. i = 0
  36. @actor.skills.each do |skill|
  37. p i
  38. if current_type and current_type != skill.stype_id
  39. (col_max - i % col_max).times do
  40. @data.push(nil)
  41. i += 1
  42. end
  43. end
  44. current_type = skill.stype_id
  45. @data.push(skill)
  46. i += 1
  47. end
  48. end
  49.  
  50. def item_rect(index)
  51. rect = Rect.new
  52. rect.width = item_width
  53. rect.height = item_height
  54. rect.x = 100 + index % col_max * (item_width + spacing)
  55. rect.y = index / col_max * item_height
  56. rect
  57. end
  58.  
  59. def item_width
  60. (width - standard_padding * 2 + spacing - 100) / col_max - spacing
  61. end
  62.  
  63. def draw_item(index)
  64. skill = @data[index]
  65. if skill
  66. rect = item_rect(index)
  67. rect.width -= 4
  68. draw_item_name(skill, rect.x, rect.y, enable?(skill))
  69. draw_skill_cost(rect, skill)
  70. if @current_header != skill.stype_id
  71. change_color (ZOROGALLADE_PSIMENU::HEADER_COLOR)
  72. draw_text(0, item_rect(index).y, 200, line_height, $data_system.skill_types[skill.stype_id],0)
  73. @current_header = skill.stype_id
  74. end
  75. end
  76. end
  77.  
  78. def draw_item_name(item, x, y, enabled = true, width = 172)
  79. return unless item
  80. draw_icon(item.icon_index, x, y, enabled)
  81. change_color(normal_color, enabled)
  82. text = item.name
  83. text.gsub!(ZOROGALLADE_PSIMENU::WHITELISTED_CHARACTERS) { "" }
  84. draw_text(x + 24, y, width, line_height, item.name)
  85. end
  86.  
  87. end
  88.  
Advertisement
Add Comment
Please, Sign In to add comment