查看: 1516|回复: 0

[已经过期] 【环形菜单】能否修改一下这个菜单中的项目?

[复制链接]
梦石
0
星屑
50
在线时间
24 小时
注册时间
2016-1-5
回帖
88
发表于 2016-1-7 12:13:26 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 江河武信 于 2016-4-1 20:07 编辑



脚本

  1.   #--------------------------------------------------------------------------
  2.   # * Startup Frames
  3.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4.   #  启动动画的帧数量Amount of frames for the Startup Animation
  5.   #--------------------------------------------------------------------------
  6.     STARTUP_FRAMES = 20
  7.   #--------------------------------------------------------------------------
  8.   # * Movement Frames
  9.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  10.   #  运动动画的帧量Amount of frames for Movement Animation
  11.   #--------------------------------------------------------------------------
  12.     MOVING_FRAMES = 15
  13.   #--------------------------------------------------------------------------
  14.   # * Menu Ring Radius
  15.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  16.   #  环的半径Radius of the Menu Ring
  17.   #--------------------------------------------------------------------------
  18.     RING_R = 75
  19.   #--------------------------------------------------------------------------
  20.   # * Show Disabled Options
  21.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  22.   #  设置为假以排除菜单的禁用选项Set to false to exclude disabled options for the menu
  23.   #--------------------------------------------------------------------------
  24.     DISABLED_SHOW = false
  25.   #--------------------------------------------------------------------------
  26.   # * Disabled Icon
  27.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  28.   #  图标显示在禁用选项The icon displayed over disabled options
  29.   #  (only used when DISABLED_SHOW =  true)
  30.   #--------------------------------------------------------------------------
  31.     ICON_DISABLE = Cache::picture('Disable Icon')
  32.   #--------------------------------------------------------------------------
  33.   # * Skip Single Actor Select
  34.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  35.   #  如果只有一个党员的话,就要跳过演员选拔Set to true to skip the actor selection if there's only one party member
  36.   #--------------------------------------------------------------------------
  37.     ACTOR_SKIP = true
  38.   #--------------------------------------------------------------------------
  39.   # * Load Command Vocab
  40.   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  41.   #  加载选项的文本显示Text displayed for the loading option
  42.   #--------------------------------------------------------------------------
  43.     Vocab::Load = "读取"
  44.       
  45.             #===================================================#
  46.             #  **     E N D   C O N F I G U R A T I O N     **  #
  47.             #===================================================#
  48. #==============================================================================
  49. # ** Ring_Menu Module
  50. #------------------------------------------------------------------------------
  51. #  模块设计中所需的父类定义的方法重写Module designed to rewrite methods defined in the desired Superclass.
  52. #==============================================================================

  53. module Ring_Menu
  54.   #--------------------------------------------------------------------------
  55.   # * Object Initialization
  56.   #--------------------------------------------------------------------------
  57.   def initialize(*args)
  58.     super(*args)
  59.     @cx = contents.width / 2; @cy = contents.height / 2
  60.     self.opacity = 0
  61.     @startup = STARTUP_FRAMES
  62.     @icons = []
  63.     @mode = :start
  64.     @steps = @startup
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # * Update Cursor
  68.   #--------------------------------------------------------------------------
  69.   def update_cursor
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # * Determines if is moving
  73.   #--------------------------------------------------------------------------
  74.   def animation?
  75.     return @mode != :wait
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # * Move Cursor Down
  79.   #--------------------------------------------------------------------------
  80.   def cursor_down(wrap)
  81.     cursor_right(wrap)
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # * Move Cursor Up
  85.   #--------------------------------------------------------------------------
  86.   def cursor_up(wrap)
  87.     cursor_left(wrap)
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # * Move Cursor Right
  91.   #--------------------------------------------------------------------------
  92.   def cursor_right(wrap)
  93.     unless animation?
  94.       select((index + 1) % item_max)
  95.       @mode = :mover
  96.       @steps = MOVING_FRAMES
  97.       Sound.play_cursor
  98.     end
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Move Cursor Left
  102.   #--------------------------------------------------------------------------
  103.   def cursor_left(wrap)
  104.     unless animation?
  105.       select((index - 1 + item_max) % item_max)
  106.       @mode = :movel
  107.       @steps = MOVING_FRAMES
  108.       Sound.play_cursor
  109.     end
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # * Frame Update
  113.   #--------------------------------------------------------------------------
  114.   def update
  115.     super
  116.     refresh if animation?
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # * Refresh
  120.   #--------------------------------------------------------------------------
  121.   def refresh   
  122.     self.contents.clear
  123.     case @mode
  124.     when :start
  125.       refresh_start
  126.     when :wait
  127.       refresh_wait
  128.     when :mover
  129.       refresh_move(1)
  130.     when :movel
  131.       refresh_move(0)
  132.     end
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * Refresh Start Period
  136.   #--------------------------------------------------------------------------
  137.   def refresh_start
  138.     d1 = 2.0 * Math::PI / item_max
  139.     d2 = 1.0 * Math::PI / @startup
  140.     r = RING_R - 1.0 * RING_R * @steps / @startup
  141.     for i in 0...item_max
  142.       d = d1 * i + d2 * @steps
  143.       x = @cx + ( r * Math.sin( d ) ).to_i
  144.       y = @cy - ( r * Math.cos( d ) ).to_i
  145.       draw_item(x, y, i)
  146.     end
  147.     @steps -= 1
  148.     if @steps < 0
  149.       @mode = :wait
  150.     end
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # * Refresh Wait Period
  154.   #--------------------------------------------------------------------------
  155.   def refresh_wait
  156.     d = 2.0 * Math::PI / item_max
  157.     for i in 0...item_max
  158.       j = i - index
  159.       x = @cx + ( RING_R * Math.sin( d * j) ).to_i
  160.       y = @cy - ( RING_R * Math.cos( d * j) ).to_i
  161.       draw_item(x, y, i)
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # * Refresh Movement Period
  166.   #--------------------------------------------------------------------------
  167.   def refresh_move( mode )
  168.     d1 = 2.0 * Math::PI / item_max
  169.     d2 = d1 / MOVING_FRAMES
  170.     d2 *= -1 unless mode != 0
  171.     for i in 0...item_max
  172.       j = i - index
  173.       d = d1 * j + d2 * @steps
  174.       x = @cx + ( RING_R * Math.sin( d ) ).to_i
  175.       y = @cy - ( RING_R * Math.cos( d ) ).to_i
  176.       draw_item(x, y, i)
  177.     end
  178.     @steps -= 1
  179.     if @steps < 0
  180.       @mode = :wait
  181.     end
  182.   end
  183. end
  184. #Ring_Menu_end
  185. #==============================================================================
  186. # ** Window_MenuCommand
  187. #------------------------------------------------------------------------------
  188. #  Converted into a Ring Menu.
  189. #==============================================================================

  190. class Window_MenuCommand < Window_Command
  191.   #--------------------------------------------------------------------------
  192.   # * Includes The Ring_Menu Module
  193.   #--------------------------------------------------------------------------  
  194.   include Ring_Menu
  195.   #--------------------------------------------------------------------------
  196.   # * Alias Listings
  197.   #--------------------------------------------------------------------------  
  198.   alias add_save_command_ring_menu_original add_save_command
  199.   #--------------------------------------------------------------------------
  200.   # * Object Initialization
  201.   #--------------------------------------------------------------------------
  202.   def initialize
  203.     super(0, 0)
  204.     unless DISABLED_SHOW
  205.       @list.delete_if {|i| !i[:enabled]}
  206.     end
  207.     for i in 0...item_max
  208.       @icons.push(Cache::picture(command_name(i) + ' Icon'))
  209.     end
  210.     if @@last_command_symbol != nil
  211.       index = @list.index(@@last_command_symbol)
  212.       @mode = :wait
  213.     end
  214.     select_last
  215.     refresh
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # * Refresh
  219.   #--------------------------------------------------------------------------
  220.   def refresh
  221.     super
  222.     rect = Rect.new(0, 196, self.contents.width, line_height)
  223.     draw_text(rect, command_name(index), 1)
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # * Get Window Width
  227.   #--------------------------------------------------------------------------
  228.   def window_width
  229.     return 544
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # * Get Window Height
  233.   #--------------------------------------------------------------------------
  234.   def window_height
  235.     return 416
  236.   end  
  237.   #--------------------------------------------------------------------------
  238.   # * Add Load to Command List
  239.   #--------------------------------------------------------------------------
  240.   def add_save_command
  241.     add_save_command_ring_menu_original
  242.     add_command(Vocab::Load, :load)
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # * Draw Item
  246.   #     x     : draw spot x-coordinate
  247.   #     y     : draw spot y-coordinate
  248.   #     i     : item number
  249.   #--------------------------------------------------------------------------
  250.   def draw_item(x, y, i)
  251.     rect = Rect.new(0, 0, @icons[i].width, @icons[i].height)
  252.     if i == index
  253.       self.contents.blt(x - rect.width/2, y - rect.height/2, @icons[i], rect )
  254.       unless command_enabled?(index)
  255.         self.contents.blt(x - rect.width/2, y - rect.height/2, ICON_DISABLE, rect )
  256.       end
  257.     else
  258.       self.contents.blt(x - rect.width/2, y - rect.height/2, @icons[i], rect, 128 )
  259.     end
  260.   end
  261. end

  262. #==============================================================================
  263. # ** Window_RingStatus
  264. #------------------------------------------------------------------------------
  265. #  Ring Menu for selection of Party Members
  266. #==============================================================================

  267. class Window_RingStatus < Window_Selectable
  268.   #--------------------------------------------------------------------------
  269.   # * Includes The Ring_Menu Module
  270.   #--------------------------------------------------------------------------  
  271.   include Ring_Menu
  272.   #--------------------------------------------------------------------------
  273.   # * Public Instance Variables
  274.   #--------------------------------------------------------------------------
  275.   attr_accessor   :pending_index            # Pending position (for formation)
  276.   attr_accessor   :pending                  # Pending
  277.   #--------------------------------------------------------------------------
  278.   # * Object Initialization
  279.   #--------------------------------------------------------------------------
  280.   def initialize
  281.     super(0, 0, 544, 416)
  282.     self.hide
  283.     @mode = :wait
  284.     @pending_index = -1
  285.     @pending = false
  286.     refresh
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # * Refresh
  290.   #--------------------------------------------------------------------------
  291.   def refresh   
  292.     super
  293.     rect = Rect.new(0, 196, self.contents.width, line_height)
  294.     draw_text(rect, $game_party.members[index].name, 1)
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # * Get Number of Items
  298.   #--------------------------------------------------------------------------
  299.   def item_max
  300.     $game_party.members.size
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # * Refresh Movement Period
  304.   #--------------------------------------------------------------------------
  305.   def refresh_move( mode )
  306.     unless pending_index >= 0
  307.       super
  308.     else
  309.       d = 2.0 * Math::PI / item_max
  310.       for i in 0...item_max
  311.         j = i - pending_index
  312.         x = @cx + ( RING_R * Math.sin( d * j) ).to_i
  313.         y = @cy - ( RING_R * Math.cos( d * j) ).to_i
  314.         draw_item(x, y, i)
  315.       end
  316.       @mode = :wait
  317.     end
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # * Draw Item
  321.   #     x     : draw spot x-coordinate
  322.   #     y     : draw spot y-coordinate
  323.   #     index : item number
  324.   #--------------------------------------------------------------------------
  325.   def draw_item(x, y, i)
  326.     if i == index && !(@pending && @pending_index < 0)
  327.       draw_character($game_party.members[i].character_name,
  328.       $game_party.members[i].character_index , x, y, true, true)
  329.     else
  330.       draw_character($game_party.members[i].character_name,
  331.       $game_party.members[i].character_index , x, y, false, true)
  332.     end
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # * Processing When OK Button Is Pressed
  336.   #--------------------------------------------------------------------------
  337.   def process_ok
  338.     super
  339.     $game_party.menu_actor = $game_party.members[index] unless pending
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # * Restore Previous Selection Position
  343.   #--------------------------------------------------------------------------
  344.   def select_last
  345.     select($game_party.members.index($game_party.menu_actor) || 0)
  346.     refresh
  347.   end
  348. end

  349. #==============================================================================
  350. # ** Scene_Menu
  351. #==============================================================================

  352. class Scene_Menu < Scene_MenuBase
  353.   #--------------------------------------------------------------------------
  354.   # * Alias Listings
  355.   #--------------------------------------------------------------------------  
  356.   alias start_ring_original start
  357.   alias create_command_window_ring_menu_original create_command_window
  358.   alias command_personal_ring_original command_personal
  359.   alias command_formation_ring_original command_formation
  360.   alias on_personal_cancel_ring_original on_personal_cancel
  361.   #--------------------------------------------------------------------------
  362.   # * Start Processing
  363.   #--------------------------------------------------------------------------
  364.   def start
  365.     start_ring_original
  366.     create_location_window
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # * Create Location Window
  370.   #--------------------------------------------------------------------------
  371.   def create_location_window
  372.     @location_window = Window_location.new(0, 0)
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # * Create Command Window
  376.   #--------------------------------------------------------------------------
  377.   def create_command_window
  378.     create_command_window_ring_menu_original
  379.     @command_window.set_handler(:load,      method(:command_load))
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # * Create Status Window
  383.   #--------------------------------------------------------------------------
  384.   def create_status_window
  385.     @status_window = Window_RingStatus.new
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # * [Skill], [Equipment] and [Status] Commands
  389.   #--------------------------------------------------------------------------
  390.   def command_personal
  391.     if $game_party.members.size < 2 && ACTOR_SKIP
  392.       on_personal_ok
  393.     else
  394.       @command_window.hide
  395.       @status_window.show
  396.       command_personal_ring_original
  397.     end
  398.   end
  399.   #--------------------------------------------------------------------------
  400.   # * [Formation] Command
  401.   #--------------------------------------------------------------------------
  402.   def command_formation
  403.     @status_window.pending = true
  404.     @command_window.hide
  405.     command_formation_ring_original
  406.     @status_window.index = 0
  407.     @status_window.refresh
  408.     @status_window.show
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # * [Load] Command
  412.   #--------------------------------------------------------------------------
  413.   def command_load
  414.     SceneManager.call(Scene_Load)
  415.   end
  416.   #--------------------------------------------------------------------------
  417.   # * [Cancel] Personal Command
  418.   #--------------------------------------------------------------------------
  419.   def on_personal_cancel
  420.     @status_window.hide
  421.     on_personal_cancel_ring_original
  422.     @status_window.deactivate
  423.     @command_window.show
  424.   end
  425.   #--------------------------------------------------------------------------
  426.   # * Formation [OK]
  427.   #--------------------------------------------------------------------------
  428.   def on_formation_ok
  429.     if @status_window.pending_index >= 0
  430.       $game_party.swap_order(@status_window.index,
  431.                              @status_window.pending_index)
  432.       @status_window.index = @status_window.pending_index
  433.       @status_window.pending_index = -1
  434.     else
  435.       @status_window.pending_index = @status_window.index
  436.     end
  437.     @status_window.refresh
  438.     @status_window.activate
  439.   end
  440.   #--------------------------------------------------------------------------
  441.   # * Formation [Cancel]
  442.   #--------------------------------------------------------------------------
  443.   def on_formation_cancel
  444.     if @status_window.pending_index >= 0
  445.       @status_window.index = @status_window.pending_index
  446.       @status_window.pending_index = -1
  447.       @status_window.activate
  448.       @status_window.refresh
  449.     else
  450.       @status_window.pending = false
  451.       @status_window.hide
  452.       @status_window.select_last
  453.       @status_window.deactivate
  454.       @command_window.show
  455.       @command_window.activate
  456.     end
  457.   end
  458. end

  459. #==============================================================================
  460. # ** Window_Base
  461. #------------------------------------------------------------------------------
  462. #  Edited to allow disabled character icons and y centring
  463. #==============================================================================

  464. class Window_Base < Window
  465.   #--------------------------------------------------------------------------
  466.   # * Draw Character Graphic
  467.   #--------------------------------------------------------------------------
  468.   def draw_character(character_name, character_index, x, y, enabled = true, centred = false)
  469.     return if character_name == nil
  470.     bitmap = Cache.character(character_name)
  471.     sign = character_name[/^[\!\$]./]
  472.     if sign && sign.include?(')
  473.       cw = bitmap.width / 3
  474.       ch = bitmap.height / 4
  475.     else
  476.       cw = bitmap.width / 12
  477.       ch = bitmap.height / 8
  478.     end
  479.     n = character_index
  480.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  481.     self.contents.blt(x - cw / 2, centred ? y - ch/2 : y - ch, bitmap, src_rect,
  482.     enabled ? 255 : 128)
  483.   end
  484. end

  485. #==============================================================================
  486. # ** Window_Location
  487. #------------------------------------------------------------------------------
  488. #  This class shows the current map name.
  489. #==============================================================================

  490. class Window_location < Window_Base
  491.   #--------------------------------------------------------------------------
  492.   # * Object Initialization
  493.   #--------------------------------------------------------------------------
  494.   def initialize(x, y)
  495.     super(x, y, 160, (line_height*2) + 32)
  496.     refresh
  497.   end
  498.   #--------------------------------------------------------------------------
  499.   # * Refresh
  500.   #--------------------------------------------------------------------------
  501.   def refresh
  502.     contents.clear
  503.     @map = load_data(sprintf("Data/Map%03d.rvdata2", $game_map.map_id))
  504.     change_color(system_color)
  505.     draw_text(4, 0, 128, line_height, "Location :")
  506.     change_color(normal_color)
  507.     draw_text(0, line_height, 128, line_height, @map.display_name, 1)
  508.   end
  509. end
复制代码

将这个脚本改为“武器选择菜单”,即:按下D键,环形菜单出现后,列出的都是物品栏中可以装备的武器,选择其中的一个,角色就装备上该武器。并最大限度保留原脚本的功能。

如果能这样就更好了:
  按下D键,菜单出现。再按D键,菜单旋转。
  按下S,装备装备,按下A,关闭环形菜单。
  这个环形还很容易改成其他菜单,如“物品”、“技能”、“队伍”等。

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部