Advertisement
blackmorning

Blackmorning - Ace Ring Menu

Nov 4th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.25 KB | None | 0 0
  1. #==============================================================================
  2. # ** Blackmorning -> Icon Ring Command (modded from Syvkal)
  3. #------------------------------------------------------------------------------
  4. #  Blackmorning
  5. #  Version 2.00
  6. #  updated 03/19/2014
  7. #  - more efficient coding
  8. #==============================================================================
  9. #  - INTRODUCTION -
  10. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  11. #  - ring command made of icons assigned in BM - Icon
  12. #  - movement based off XRXS, Dubealex & Hypershadow180's original XP Ring Menu,
  13. #  - ring for menu commands, actor & party commands are setup
  14. #==============================================================================
  15. # ¨‹ Instructions
  16. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  17. # To install this script, open up your script editor and copy/paste this script
  18. # to an open slot below BM - Base and other menu engines but above BM - Icon.
  19. # Remember to save.
  20.  
  21. # can be used with YEA - menu engine
  22. #==============================================================================
  23. module BM
  24.   module RING
  25.     # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  26.     # Ring Options
  27.     # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  28.     OPTIONS ={
  29.       :startup_frames => 20, #  Amount of frames for the Startup Animation, default = 20
  30.       :moving_frames  => 15, #  Amount of frames for Movement Animation,  default = 15
  31.       :menu_radius    => 54, #  Radius of Menu Command Ring, default = 60
  32.       :battle_radius  => 34, #  Radius of Actor & Party Command Rings (Battle Scene)
  33.       :title_radius   => 34,
  34.     } # DO NOT REMOVE      
  35.     ICON ={
  36.       :disable =>  972, # The icon displayed over disabled options
  37.     } # DO NOT REMOVE    
  38.     # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  39.     # Ring Menus Used
  40.     # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  41.     USE_RING_COMMAND ={ # which screens use the ring style commands
  42.       :menu   => true,
  43.       :title  => true,
  44.       :battle_actor => true,
  45.       :battle_party => true,
  46.     } # DO NOT REMOVE    
  47.   end
  48. end
  49. #===============================================================================
  50. # Editting anything past this point may potentially result in causing computer
  51. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  52. # Therefore, edit at your own risk.
  53. #===============================================================================
  54. module BM
  55.   def self.required(name, req, version, type = nil)
  56.     if !$imported[:bm_base]
  57.       msg = "The script '%s' requires the script\n"
  58.       msg += "'BM - Base' v%s or higher above it to work properly\n"
  59.       msg += "Go to bmscripts.weebly.com to download this script."
  60.       msgbox(sprintf(msg, self.script_name(name), version))
  61.       exit
  62.     else
  63.       self.required_script(name, req, version, type)
  64.     end
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # * script_name
  68.   #   Get the script name base on the imported value
  69.   #--------------------------------------------------------------------------
  70.   def self.script_name(name, ext = "BM")
  71.     name = name.to_s.gsub("_", " ").upcase.split
  72.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  73.     name.join(" ")
  74.   end
  75. end
  76. $imported ||= {}
  77. $imported[:bm_ring] = 2.00
  78. BM.required(:bm_ring, :bm_base, 1.00, :above)
  79. BM.required(:bm_ring, :bm_icon, 1.00, :below)
  80. #=============================================================================#
  81. # ** Icon
  82. #=============================================================================#
  83. module Icon
  84.   def self.disable; BM::RING::ICON[:disable]; end
  85. end
  86. #==============================================================================
  87. # ** Ring_Command
  88. #==============================================================================
  89. module Ring_Command
  90.   #--------------------------------------------------------------------------
  91.   # * Object Initialization
  92.   #--------------------------------------------------------------------------
  93.   def initialize(*args, &block)
  94.     @spin_count = 0  # 0 is left, 1 is right
  95.     @startup = BM::RING::OPTIONS[:startup_frames]
  96.     @mode = :start
  97.     @spin_count = @startup
  98.     super(*args, &block)    
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * cx and cy
  102.   #--------------------------------------------------------------------------
  103.   def cx; contents.width/2;  end
  104.   def cy; contents.height/2; end
  105.   #--------------------------------------------------------------------------
  106.   # * Default Radius
  107.   #--------------------------------------------------------------------------
  108.   def radius; 60; end
  109.   #--------------------------------------------------------------------------
  110.   # * item rect
  111.   #--------------------------------------------------------------------------
  112.   def item_rect(index)
  113.     rect = Rect.new
  114.     rect.width = 28
  115.     rect.height = 28
  116.     rect.x = (contents.width - rect.width) / 2
  117.     rect.y = cy - radius - rect.width/2
  118.     rect
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # * Determines if is moving
  122.   #--------------------------------------------------------------------------
  123.   def animation?; return @mode != :wait;  end
  124.   #--------------------------------------------------------------------------
  125.   # * Move Cursor Down
  126.   #--------------------------------------------------------------------------
  127.   def cursor_down(wrap)
  128.     unless animation?
  129.       select((index + 1) % item_max)
  130.       @mode = :right
  131.       @spin_count = BM::RING::OPTIONS[:moving_frames]
  132.       Sound.play_cursor
  133.     end
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # * Move Cursor Up
  137.   #--------------------------------------------------------------------------
  138.   def cursor_up(wrap)
  139.     unless animation?
  140.       select((index - 1 + item_max) % item_max)
  141.       @mode = :left
  142.       @spin_count = BM::RING::OPTIONS[:moving_frames]
  143.       Sound.play_cursor
  144.     end
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # * Overwrite: Move Cursor Right
  148.   #--------------------------------------------------------------------------
  149.   def cursor_right(wrap); cursor_down(wrap); end
  150.   #--------------------------------------------------------------------------
  151.   # * Overwrite: Move Cursor Left
  152.   #--------------------------------------------------------------------------
  153.   def cursor_left(wrap); cursor_up(wrap); end
  154.   #--------------------------------------------------------------------------
  155.   # * Frame Update
  156.   #--------------------------------------------------------------------------
  157.   def update
  158.     super
  159.     refresh if animation?
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   def index=(index)
  163.     super
  164.     refresh
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # * Refresh
  168.   #--------------------------------------------------------------------------
  169.   def refresh    
  170.     contents.clear
  171.     refresh_ring
  172.     draw_current_index  
  173.   end  
  174.   #--------------------------------------------------------------------------
  175.   # * Get Command Name
  176.   #--------------------------------------------------------------------------
  177.   def command_name(index)
  178.     return "" if @list[index] == nil
  179.     super#@list[index][:name]
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # * Refresh ring
  183.   #--------------------------------------------------------------------------
  184.   def refresh_ring
  185.     angle_size = 2.0 * Math::PI / item_max
  186.     r1 = radius - 1.0 * radius * @spin_count / @startup
  187.     r = (@mode == :start) ? r1 : radius
  188.     angle = 0
  189.     angle = angle_size / BM::RING::OPTIONS[:moving_frames] if animation?
  190.     angle = 1.0 * Math::PI / @startup if @mode == :start    
  191.     angle *= @spin_count
  192.     angle = (@mode == :right) ? angle : -angle
  193.     for i in 0...item_max
  194.       j = (@mode == :start) ? i : i - index
  195.       d = angle_size * j + angle
  196.       x = cx + ( r * Math.sin( d ) ).to_i
  197.       y = cy - ( r * Math.cos( d ) ).to_i
  198.       draw_ring_item(x, y, i)
  199.     end
  200.     return unless animation?
  201.     @spin_count -= 1
  202.     @mode = :wait if @spin_count < 0      
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # * New method: draw current index
  206.   #--------------------------------------------------------------------------
  207.   def draw_current_index
  208.     rect = Rect.new(0, (contents.height - item_height) / 2, contents.width, line_height)
  209.     draw_text(rect, command_name(index), 1)
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # * Overwrite: Draw Item
  213.   #--------------------------------------------------------------------------
  214.   def draw_ring_item(x, y, i)
  215.     rect = Rect.new(0, 0, 24, 24)
  216.     name = command_name(i)
  217.     icon = command_icon(name)
  218.     enable = (i == index) ? command_enabled?(index) : false
  219.     draw_icon(Icon.border, x - rect.width/2, y - rect.height/2, enable)
  220.     draw_icon(icon, x - rect.width/2, y - rect.height/2, enable)
  221.     draw_icon(Icon.disable, x - rect.width/2, y - rect.height/2, i == index) unless command_enabled?(i)
  222.   end
  223. end
  224.  
  225. if BM::RING::USE_RING_COMMAND[:menu]
  226. #==============================================================================
  227. # ** Window_MenuCommand
  228. #==============================================================================
  229. class Window_MenuCommand < Window_Command
  230.   #--------------------------------------------------------------------------
  231.   # * Includes The Ring_Command Module
  232.   #--------------------------------------------------------------------------  
  233.   include Ring_Command
  234.   #--------------------------------------------------------------------------
  235.   # * Alias: Object Initialization
  236.   #--------------------------------------------------------------------------
  237.   alias :bm_ring_init :initialize
  238.   def initialize
  239.     bm_ring_init
  240.     if @@last_command_symbol != nil
  241.       index = @list.index(@@last_command_symbol)
  242.       @mode = :wait
  243.     end
  244.     refresh
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # * Radius
  248.   #--------------------------------------------------------------------------
  249.   def radius; BM::RING::OPTIONS[:menu_radius]; end
  250. end
  251. end
  252.  
  253. if BM::RING::USE_RING_COMMAND[:battle_actor]
  254. #==============================================================================
  255. # ** Window_ActorCommand
  256. #==============================================================================
  257. class Window_ActorCommand < Window_Command
  258.   #--------------------------------------------------------------------------
  259.   # * Includes The Ring_Command Module
  260.   #--------------------------------------------------------------------------  
  261.   include Ring_Command
  262.   #--------------------------------------------------------------------------
  263.   # * New method: Refresh
  264.   #--------------------------------------------------------------------------
  265.   def draw_current_index
  266.     return unless @actor
  267.     super
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # * Get Item Height
  271.   #--------------------------------------------------------------------------
  272.   def item_height
  273.     (height - standard_padding * 2)/[4,item_max].max
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # * Overwrite: Move Cursor Right
  277.   #--------------------------------------------------------------------------
  278.   def cursor_right(wrap); end
  279.   #--------------------------------------------------------------------------
  280.   # * Overwrite: Move Cursor Left
  281.   #--------------------------------------------------------------------------
  282.   def cursor_left(wrap); end
  283.   #--------------------------------------------------------------------------
  284.   # * Overwrite: Get Number of Lines to Show
  285.   #--------------------------------------------------------------------------
  286.   def visible_line_number; item_max; end
  287.   #--------------------------------------------------------------------------
  288.   # * Overwrite: Get Window Height
  289.   #--------------------------------------------------------------------------
  290.   def window_height; fitting_height(4); end
  291.   #--------------------------------------------------------------------------
  292.   # * Radius
  293.   #--------------------------------------------------------------------------
  294.   def radius; BM::RING::OPTIONS[:battle_radius]; end
  295. end
  296. end
  297.  
  298. if BM::RING::USE_RING_COMMAND[:battle_party]
  299. #==============================================================================
  300. # ** Window_PartyCommand
  301. #==============================================================================
  302. class Window_PartyCommand < Window_Command
  303.   #--------------------------------------------------------------------------
  304.   # * Includes The Ring_Command Module
  305.   #--------------------------------------------------------------------------  
  306.   include Ring_Command
  307.   #--------------------------------------------------------------------------
  308.   # * Overwrite: Get Number of Lines to Show
  309.   #--------------------------------------------------------------------------
  310.   def visible_line_number; item_max; end
  311.   #--------------------------------------------------------------------------
  312.   # * Overwrite: Get Window Height
  313.   #--------------------------------------------------------------------------
  314.   def window_height; fitting_height(4); end
  315.   #--------------------------------------------------------------------------
  316.   # * Radius
  317.   #--------------------------------------------------------------------------
  318.   def radius; BM::RING::OPTIONS[:battle_radius]; end
  319. end
  320. end
  321.  
  322. if BM::RING::USE_RING_COMMAND[:title]
  323. #==============================================================================
  324. # ** Window_TitleCommand
  325. #==============================================================================
  326. class Window_TitleCommand < Window_Command
  327.   #--------------------------------------------------------------------------
  328.   # * Includes The Ring_Command Module
  329.   #--------------------------------------------------------------------------  
  330.   include Ring_Command
  331.   #--------------------------------------------------------------------------
  332.   # * Overwrite: Get Number of Lines to Show
  333.   #--------------------------------------------------------------------------
  334.   def visible_line_number; item_max; end
  335.   #--------------------------------------------------------------------------
  336.   # * Overwrite: Get Window Height
  337.   #--------------------------------------------------------------------------
  338.   def window_height; fitting_height(4); end
  339.   #--------------------------------------------------------------------------
  340.   # * Radius
  341.   #--------------------------------------------------------------------------
  342.   def radius; BM::RING::OPTIONS[:title_radius]; end
  343. end
  344. end
  345. #===============================================================================
  346. #
  347. # END OF FILE
  348. #
  349. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement