Advertisement
roninator2

Syvkal Ring Menu Addon - Choice Ring

Nov 21st, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.92 KB | None | 0 0
  1. # ╔═══════════════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Syvkal Ring Menu Addon - Choice Ring   ║  Version: 1.03     ║
  3. # ║ Author: Roninator2                            ║                    ║
  4. # ╠═══════════════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                                     ║   Date Created     ║
  6. # ║    Add ring menu to choice window             ╠════════════════════╣
  7. # ║    Adjusts to choice size                     ║    31 Dec 2020     ║
  8. # ╚═══════════════════════════════════════════════╩════════════════════╝
  9. # ╔════════════════════════════════════════════════════════════════════╗
  10. # ║ Requires: Syvkal Ring Menu Script                                  ║
  11. # ║                                                                    ║
  12. # ╚════════════════════════════════════════════════════════════════════╝
  13. # ╔════════════════════════════════════════════════════════════════════╗
  14. # ║ Brief Description:                                                 ║
  15. # ║       Allow ring menu for choices                                  ║
  16. # ╚════════════════════════════════════════════════════════════════════╝
  17. # ╔════════════════════════════════════════════════════════════════════╗
  18. # ║ Instructions:                                                      ║
  19. # ║   Script will automatically place icons for each choice            ║
  20. # ║   option that is provided. Requires Syvkal's Ring Menu             ║
  21. # ║   Tested with Hime Large choices                                   ║
  22. # ║   Icons are placed in the pictures folder.                         ║
  23. # ║   Icons must be in the format of ''choice' + space + icon'         ║
  24. # ║   example                                                          ║
  25. # ║    'yes icon'.png or 'no icon'.png  - without quotes               ║
  26. # ╚════════════════════════════════════════════════════════════════════╝
  27. # ╔════════════════════════════════════════════════════════════════════╗
  28. # ║ Updates:                                                           ║
  29. # ║ 1.01 - 01 Jan 2021 - Added Background blur                         ║
  30. # ║ 1.02 - 02 Jan 2021 - Changed to overwrite ChoiceList               ║
  31. # ║ 1.03 - 02 Jan 2021 - Centered ChoiceList on Player                 ║
  32. # ╚════════════════════════════════════════════════════════════════════╝
  33. # ╔════════════════════════════════════════════════════════════════════╗
  34. # ║ Credits and Thanks:                                                ║
  35. # ║   Roninator2                                                       ║
  36. # ║   Syvkal                                                           ║
  37. # ║                                                                    ║
  38. # ╚════════════════════════════════════════════════════════════════════╝
  39. # ╔════════════════════════════════════════════════════════════════════╗
  40. # ║ Terms of use:                                                      ║
  41. # ║  Follow the original Authors terms of use where applicable         ║
  42. # ║    - When not made by me (Roninator2)                              ║
  43. # ║  Free for all uses in RPG Maker except nudity                      ║
  44. # ║  Anyone using this script in their project before these terms      ║
  45. # ║  were changed are allowed to use this script even if it conflicts  ║
  46. # ║  with these new terms. New terms effective 03 Apr 2024             ║
  47. # ║  No part of this code can be used with AI programs or tools        ║
  48. # ║  Credit must be given                                              ║
  49. # ╚════════════════════════════════════════════════════════════════════╝
  50.  
  51. module Ring_Menu
  52.   #--------------------------------------------------------------------------
  53.   # * Object Initialization
  54.   #--------------------------------------------------------------------------
  55.   def initialize(*args)
  56.     super(*args)
  57.     @cx = $game_player.screen_x - 16
  58.     @cy = $game_player.screen_y - 28
  59.     self.opacity = 0
  60.     @startup = STARTUP_FRAMES
  61.     @icons = []
  62.     @mode = :start
  63.     @steps = @startup
  64.   end
  65. end
  66.  
  67. class Window_MenuCommand < Window_Command
  68.   #--------------------------------------------------------------------------
  69.   # * Refresh
  70.   #--------------------------------------------------------------------------
  71.   def refresh
  72.     super
  73.     @cx = $game_player.screen_x - 16
  74.     @cy = $game_player.screen_y - 28
  75.     rect = Rect.new(@cx - 254, @cy, self.contents.width, line_height)
  76.     draw_text(rect, command_name(index), 1)
  77.   end
  78. end
  79.  
  80. #==============================================================================
  81. # ** Window_ChoiceList_Ring
  82. #------------------------------------------------------------------------------
  83. #  This window is used for the event command [Show Choices].
  84. #==============================================================================
  85. class Window_ChoiceList < Window_Command
  86.   #--------------------------------------------------------------------------
  87.   # * Includes The Ring_Menu Module
  88.   #--------------------------------------------------------------------------
  89.   include Ring_Menu
  90.   #--------------------------------------------------------------------------
  91.   # * Object Initialization
  92.   #--------------------------------------------------------------------------
  93.   def initialize(message_window)
  94.     @message_window = message_window
  95.     super(0, 0)
  96.     self.openness = 0
  97.     deactivate
  98.     @mode = :wait
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Start Input Processing
  102.   #--------------------------------------------------------------------------
  103.   def start
  104.     @cx = $game_player.screen_x - 16
  105.     @cy = $game_player.screen_y - 28
  106.     @icons = []
  107.     @choices = []
  108.     make_command_list
  109.     make_choice_list
  110.     select(0)
  111.     open
  112.     activate
  113.     create_background
  114.     refresh
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # * Make_choice_list
  118.   #--------------------------------------------------------------------------
  119.   def make_choice_list
  120.     $game_message.choices.each_with_index do |choice, i|
  121.       @icons.push(Cache::picture(choice + ' Icon'))
  122.       @choices.push(choice)
  123.       @cx = $game_player.screen_x - 16
  124.       @cy = $game_player.screen_y - 28
  125.       rect = Rect.new(@cx, @cy, @icons[i].width / 2, @icons[i].height / 2)
  126.       draw_item(rect.x, rect.y, i)
  127.     end
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # * Refresh
  131.   #--------------------------------------------------------------------------
  132.   def refresh
  133.     super
  134.     @cx = $game_player.screen_x - 16
  135.     @cy = $game_player.screen_y - 28
  136.     rect = Rect.new(@cx - 254, @cy, self.contents.width, line_height)
  137.     draw_text(rect, choice_name(index), 1)
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # * Make_command_list
  141.   #--------------------------------------------------------------------------
  142.   def make_command_list
  143.      $game_message.choices.each do |choice|
  144.       add_command(choice, :choice)
  145.     end
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # * Get Window Width
  149.   #--------------------------------------------------------------------------
  150.   def window_width
  151.     return Graphics.width
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # * Get Window Height
  155.   #--------------------------------------------------------------------------
  156.   def window_height
  157.     return Graphics.height
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # * Get Maximum Width of Choices
  161.   #--------------------------------------------------------------------------
  162.   def max_choice_width
  163.     Graphics.width
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # * Calculate Height of Window Contents
  167.   #--------------------------------------------------------------------------
  168.   def contents_height
  169.     Graphics.height
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # * Get Activation State of Cancel Processing
  173.   #--------------------------------------------------------------------------
  174.   def cancel_enabled?
  175.     $game_message.choice_cancel_type > 0
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # * Get Command Name
  179.   #--------------------------------------------------------------------------
  180.   def choice_name(index)
  181.     return if @choices == nil
  182.     @choices[index]
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # * Call OK Handler
  186.   #--------------------------------------------------------------------------
  187.   def call_ok_handler
  188.     $game_message.choice_proc.call(index)
  189.     close
  190.     clean_choices
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # * Call Cancel Handler
  194.   #--------------------------------------------------------------------------
  195.   def call_cancel_handler
  196.     $game_message.choice_proc.call($game_message.choice_cancel_type - 1)
  197.     close
  198.     clean_choices
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # * Clear choice lists
  202.   #--------------------------------------------------------------------------
  203.   def clean_choices
  204.     $game_message.choices.clear
  205.     @list.clear
  206.     dispose_background
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # * Draw Item
  210.   #     x     : draw spot x-coordinate
  211.   #     y     : draw spot y-coordinate
  212.   #     i     : item number
  213.   #--------------------------------------------------------------------------
  214.   def draw_item(x, y, i)
  215.     rect = Rect.new(0, 0, @icons[i].width, @icons[i].height)
  216.     if i == index
  217.       self.contents.blt(x - rect.width/2, y - rect.height/2, @icons[i], rect )
  218.       unless command_enabled?(index)
  219.         self.contents.blt(x - rect.width/2, y - rect.height/2, ICON_DISABLE, rect )
  220.       end
  221.     else
  222.       self.contents.blt(x - rect.width/2, y - rect.height/2, @icons[i], rect, 128 )
  223.     end
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # * Create Background
  227.   #--------------------------------------------------------------------------
  228.   def create_background
  229.     @background_sprite = Sprite.new
  230.     SceneManager.snapshot_for_background
  231.     @background_sprite.bitmap = SceneManager.background_bitmap
  232.     @background_sprite.color.set(16, 16, 16, 128)
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # * Free Background
  236.   #--------------------------------------------------------------------------
  237.   def dispose_background
  238.     @background_sprite.dispose
  239.   end
  240. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement