Project1

标题: 请大大来帮我精简下菜单脚本 [打印本页]

作者: 16732682    时间: 2007-7-28 03:56
提示: 作者被禁止或删除 内容自动屏蔽
作者: 16732682    时间: 2007-7-28 03:56
提示: 作者被禁止或删除 内容自动屏蔽
作者: 精灵使者    时间: 2007-7-28 04:06

  1. #========================================
  2. #■ Window_Base
  3. #----------------------------------------
  4. # Setting functions for the "Base"
  5. #========================================

  6. class Window_Base < Window

  7.   def draw_actor_face(actor, x, y)
  8.     face=Bitmap.new("Graphics/heads/#{actor.character_name}")
  9.     fw = face.width
  10.     fh = face.height
  11.     src_rect = Rect.new(0, 0, 200, 200)
  12.     self.contents.blt(x - fw / 23, y, face, src_rect)
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 图形的描绘
  16.   #     actor : 角色
  17.   #     x     : 描画目标 X 坐标
  18.   #     y     : 描画目标 Y 坐标
  19.   #--------------------------------------------------------------------------
  20.   def draw_actor_half_graphic(actor, x, y)
  21.     bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  22.     cw = bitmap.width / 4
  23.     ch = bitmap.height / 8
  24.     src_rect = Rect.new(0, 0, cw, ch)
  25.     self.contents.blt(x - cw / 2, y, bitmap, src_rect)
  26.   end
  27. end

  28. #========================================
  29. #■ Game_Map
  30. #----------------------------------------
  31. # Setting functions for the Map
  32. #========================================
  33. class Game_Map

  34. def name
  35. $map_infos[@map_id]
  36. end
  37. end

  38. #========================================
  39. #■ Window_Title
  40. #----------------------------------------
  41. # Setting functions for the Title
  42. #========================================
  43. class Scene_Title
  44. $map_infos = load_data("Data/MapInfos.rxdata")
  45. for key in $map_infos.keys
  46. $map_infos[key] = $map_infos[key].name
  47. end
  48. end




  49. #==============================================================================
  50. # ■ Window_MenuStatus
  51. #------------------------------------------------------------------------------
  52. #  Sets up the Choosing.
  53. #==============================================================================

  54. class Window_MenuStatus < Window_Selectable
  55. #--------------------------------------------------------------------------
  56. # Set up
  57. #--------------------------------------------------------------------------
  58. def initialize
  59.    super(0, 0, 520, 454)
  60.    self.contents = Bitmap.new(width - 32, height - 32)
  61.    self.contents.font.name = "黑体"
  62.    self.contents.font.size = 20
  63.    refresh
  64.    self.active = false
  65.    self.index = -1
  66. end

  67. #--------------------------------------------------------------------------
  68. # Update of Cursor
  69. #--------------------------------------------------------------------------
  70. def update_cursor_rect
  71.    if @index < 0
  72.      self.cursor_rect.empty
  73.    else
  74.      case @index
  75.      when 0
  76.        self.cursor_rect.set(0, 0, self.width - 32, 125)
  77.      when 1
  78.        self.cursor_rect.set(0, 130, self.width - 32, 125)
  79.      else
  80.        self.cursor_rect.set(0, 300+(@index-2)*30, self.width - 32, 30)
  81.     end
  82.    end
  83. end
  84. end
  85. #=======================================#
  86. # ■Window_GameStats                                                             #
  87. # written by AcedentProne                                                          #
  88. #------------------------------------------------------------------------------#
  89. class Window_GameStats < Window_Base
  90. def initialize
  91.   super(0, 0, 160, 140)
  92.   self.contents = Bitmap.new(width - 32, height - 32)
  93.   self.contents.font.name = "黑体"
  94.   self.contents.font.size = 18
  95.   refresh
  96. end

  97. def refresh
  98.   self.contents.clear
  99.   self.contents.font.color = system_color
  100.   # Draw "Time"
  101.   @total_sec = Graphics.frame_count / Graphics.frame_rate
  102.   hour = @total_sec / 60 / 60
  103.   min = @total_sec / 60 % 60
  104.   sec = @total_sec % 60
  105.   text = sprintf("%02d:%02d:%02d", hour, min, sec)
  106.   self.contents.font.color = normal_color
  107.   self.contents.draw_text(4, 22, 120, 32, text, 2)
  108.   self.contents.font.color = system_color
  109.   self.contents.draw_text(4, 0, 100, 32, "游戏时间")
  110.   self.contents.font.color = system_color
  111.   self.contents.draw_text(4, 60, 100, 32, "金钱")
  112.   self.contents.font.color = normal_color
  113.   self.contents.draw_text(4, 60, 120, 32,$game_party.gold.to_s, 2)
  114. end
  115. #--------------------------------------------------------------------------
  116. # Update of The count
  117. #--------------------------------------------------------------------------
  118. def update
  119.   super
  120.   if Graphics.frame_count / Graphics.frame_rate != @total_sec
  121.     refresh
  122.   end
  123. end
  124. end
  125. #==============================================================================
  126. # ■ Window_Mapname
  127. #------------------------------------------------------------------------------
  128. #  Draws the Map name
  129. #==============================================================================

  130. class Window_Mapname < Window_Base
  131. #--------------------------------------------------------------------------
  132. # Set up
  133. #--------------------------------------------------------------------------
  134. def initialize
  135. super(0, 0, 320, 60)
  136. self.contents = Bitmap.new(width - 52, height - 32)
  137. self.contents.font.name = "黑体"
  138. self.contents.font.size = 20
  139. refresh
  140. end
  141. #--------------------------------------------------------------------------
  142. # Draws info on screen
  143. #--------------------------------------------------------------------------
  144. def refresh
  145. self.contents.clear

  146. # Map Name
  147. #map = $game_map.name
  148. self.contents.font.color = system_color
  149. self.contents.draw_text(4, 0, 220, 32, "所在地点")
  150. self.contents.font.color = normal_color
  151. self.contents.draw_text(175, 0, 80, 32, $game_map.name)
  152. end
  153. end
  154. #==============================================================================
  155. # ■ Scene_Menu
  156. #------------------------------------------------------------------------------
  157. #  处理菜单画面的类。
  158. #==============================================================================

  159. class Scene_Menu
  160.   #--------------------------------------------------------------------------
  161.   # ● 初始化对像
  162.   #     menu_index : 命令光标的初期位置
  163.   #--------------------------------------------------------------------------
  164.   def initialize(menu_index = 0)
  165.     @menu_index = menu_index
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● 主处理
  169.   #--------------------------------------------------------------------------
  170.   def main
  171.     # 生成命令窗口
  172.     s1 = $data_system.words.item
  173.     s2 = "状态"
  174.     s3 = "存档"
  175.     s4 = "结束游戏"
  176.     @command_window = Window_Command.new(160, [s1, s2, s3, s4])
  177.     @command_window.index = @menu_index
  178.     # 同伴人数为 0 的情况下
  179.     if $game_party.actors.size == 0
  180.       # 物品、特技、装备、状态无效化
  181.       @command_window.disable_item(0)
  182.       @command_window.disable_item(1)
  183.     end
  184.     # 禁止存档的情况下
  185.     if $game_system.save_disabled
  186.       # 存档无效
  187.       @command_window.disable_item(3)
  188.     end
  189.     # 生成游戏时间窗口
  190.     @playtime_window = Window_PlayTime.new
  191.     @playtime_window.x = 0
  192.     @playtime_window.y = 224
  193.     # 生成步数窗口
  194.     @steps_window = Window_Steps.new
  195.     @steps_window.x = 0
  196.     @steps_window.y = 320
  197.     # 生成金钱窗口
  198.     @gold_window = Window_Gold.new
  199.     @gold_window.x = 0
  200.     @gold_window.y = 416
  201.     # 生成状态窗口
  202.     @status_window = Window_MenuStatus.new
  203.     @status_window.x = 160
  204.     @status_window.y = 0
  205.     # 执行过渡
  206.     Graphics.transition
  207.     # 主循环
  208.     loop do
  209.       # 刷新游戏画面
  210.       Graphics.update
  211.       # 刷新输入信息
  212.       Input.update
  213.       # 刷新画面
  214.       update
  215.       # 如果切换画面就中断循环
  216.       if $scene != self
  217.         break
  218.       end
  219.     end
  220.     # 准备过渡
  221.     Graphics.freeze
  222.     # 释放窗口
  223.     @command_window.dispose
  224.     @playtime_window.dispose
  225.     @steps_window.dispose
  226.     @gold_window.dispose
  227.     @status_window.dispose
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # ● 刷新画面
  231.   #--------------------------------------------------------------------------
  232.   def update
  233.     # 刷新窗口
  234.     @command_window.update
  235.     @playtime_window.update
  236.     @steps_window.update
  237.     @gold_window.update
  238.     @status_window.update
  239.     # 命令窗口被激活的情况下: 调用 update_command
  240.     if @command_window.active
  241.       update_command
  242.       return
  243.     end
  244.     # 状态窗口被激活的情况下: 调用 update_status
  245.     if @status_window.active
  246.       update_status
  247.       return
  248.     end
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 刷新画面 (命令窗口被激活的情况下)
  252.   #--------------------------------------------------------------------------
  253.   def update_command
  254.     # 按下 B 键的情况下
  255.     if Input.trigger?(Input::B)
  256.       # 演奏取消 SE
  257.       $game_system.se_play($data_system.cancel_se)
  258.       # 切换的地图画面
  259.       $scene = Scene_Map.new
  260.       return
  261.     end
  262.     # 按下 C 键的情况下
  263.     if Input.trigger?(Input::C)
  264.       # 同伴人数为 0、存档、游戏结束以外的场合
  265.       if $game_party.actors.size == 0 and @command_window.index < 4
  266.         # 演奏冻结 SE
  267.         $game_system.se_play($data_system.buzzer_se)
  268.         return
  269.       end
  270.       # 命令窗口的光标位置分支
  271.       case @command_window.index
  272.       when 0  # 物品
  273.         # 演奏确定 SE
  274.         $game_system.se_play($data_system.decision_se)
  275.         # 切换到物品画面
  276.         $scene = Scene_Item.new
  277.       when 1   # 状态
  278.         # 演奏确定 SE
  279.         $game_system.se_play($data_system.decision_se)
  280.         # 激活状态窗口
  281.         @command_window.active = false
  282.         @status_window.active = true
  283.         @status_window.index = 0      
  284.       when 2  # 存档
  285.         # 禁止存档的情况下
  286.         if $game_system.save_disabled
  287.           # 演奏冻结 SE
  288.           $game_system.se_play($data_system.buzzer_se)
  289.           return
  290.         end
  291.         # 演奏确定 SE
  292.         $game_system.se_play($data_system.decision_se)
  293.         # 切换到存档画面
  294.         $scene = Scene_Save.new        
  295.       when 3 # 游戏结束
  296.         # 演奏确定 SE
  297.         $game_system.se_play($data_system.decision_se)
  298.         # 切换到游戏结束画面
  299.         $scene = Scene_End.new
  300.       end
  301.       return
  302.     end
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # ● 刷新画面 (状态窗口被激活的情况下)
  306.   #--------------------------------------------------------------------------
  307.   def update_status
  308.     # 按下 B 键的情况下
  309.     if Input.trigger?(Input::B)
  310.       # 演奏取消 SE
  311.       $game_system.se_play($data_system.cancel_se)
  312.       # 激活命令窗口
  313.       @command_window.active = true
  314.       @status_window.active = false
  315.       @status_window.index = -1
  316.       return
  317.     end
  318.     # 按下 C 键的情况下
  319.     if Input.trigger?(Input::C)
  320.       # 命令窗口的光标位置分支
  321.       case @command_window.index
  322.       when 1  # 特技
  323.         # 本角色的行动限制在 2 以上的情况下
  324.         if $game_party.actors[@status_window.index].restriction >= 2
  325.           # 演奏冻结 SE
  326.           $game_system.se_play($data_system.buzzer_se)
  327.           return
  328.         end
  329.         # 演奏确定 SE
  330.         $game_system.se_play($data_system.decision_se)
  331.         # 切换到特技画面
  332.         $scene = Scene_Skill.new(@status_window.index)
  333.       when 2  # 装备
  334.         # 演奏确定 SE
  335.         $game_system.se_play($data_system.decision_se)
  336.         # 切换的装备画面
  337.         $scene = Scene_Equip.new(@status_window.index)
  338.       when 3  # 状态
  339.         # 演奏确定 SE
  340.         $game_system.se_play($data_system.decision_se)
  341.         # 切换到状态画面
  342.       #  $scene = Scene_Status.new(@status_window.index)
  343.          $scene = Scene_Charactor.new(@status_window.index)
  344.       end
  345.       return
  346.     end
  347.   end
  348. end
复制代码

应该是这样的吧。p.s.其他窗口没有修正,请自己调整。 [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: 16732682    时间: 2007-7-28 04:14
提示: 作者被禁止或删除 内容自动屏蔽
作者: 精灵使者    时间: 2007-7-28 04:17
我把特技部分和装备部分的选项全部去掉了,而且进行了相应整合。
现在第一选项是物品。第二选项是状态,第三选项存档,第4选项退出。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1