查看: 84|回复: 0

[转载发布] 自己写的一个菜单界面的美化脚本

[复制链接]
  • TA的每日心情
    开心
    5 天前
  • 签到天数: 33 天

    连续签到: 1 天

    [LV.5]常住居民I

    2022

    主题

    32

    回帖

    7144

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5074
    OK点
    16
    积分
    7144
    发表于 同元一千年八月六日(秋) | 显示全部楼层 |阅读模式
    嗯……第一次正儿八经地写一个脚本,第一次在发布区发布我的作品,心情还是很激动很忐忑的{:2_285:}
    其实说这是我写的吧,也不完全算是,基本上还是用默认脚本改的,另外Window_Base类中几个新方法的定义也是引用了其他大神的脚本里的内容。总共改动了9个类,Game一个,Window4个,Scene4个,主要是对Scene_Menu类和Window_MenuStatus类的改写。可能在高手看来,真的好蠢好蠢……不过看在我是第一次的份上,就宽容一下嘛{:2_251:} 希望可以给我提出一些宝贵意见,不论是脚本结构方面、算法方面和效果方面,都可以尽情地提出来,如果发现什么bug,也希望可以第一时间告诉我~
    下面放出效果截图、代码内容和范例工程(范例工程里什么也没做,只是放了几张头像图而已。。头像图来自66rpg整合素材包,不会告我侵权吧= =)

    另外,注释里写的by 飞云,飞云就是我啦…………只不过当时注册论坛号的时候不知道可以打中文,只好用xingxing991219,现在知道了也没法改= =很郁闷的说,其实飞云才是我的真正艺名~_~

    好吧,就扯这么多。

    RUBY 代码
    1. #==============================================================
    2. # 菜单界面大调整脚本   by 飞云
    3. #==============================================================
    4. # 本脚本大幅度调整了Esc菜单界面的结构,窗口为半透明状态,各文字内容
    5. # 可在下方修改,具体对应关系可在游戏测试中查看。
    6. #
    7. # 本脚本兼容性较差,重新定义了Scene_Menu脚本的大部分方法,如果您
    8. # 使用了其他修改菜单界面的脚本,请慎重使用本脚本,如有冲突,请自
    9. # 行整合。
    10. #
    11. # 使用方法:将全部内容插入到Main上方,并在Graphics目录下新建一个
    12. # Heads文件夹,将头像文件放入,格式为Actorx.png(注:x为该角色在数
    13. # 据库内的编号,1、2、3、4……11、12、13…… 比如一号角色的头像文件名
    14. # 为Actor001,二十号角色的头像文件名为Actor020,128号角色的头像文
    15. # 件名为Actor128,如果序号超过999,请自行修改脚本= =)
    16. #
    17. # 转载和使用请保留本信息,谢谢合作!
    18. #
    19. # (已知本脚本不与柳柳大人的技能分类脚本、小翼的值槽脚本冲突,其他
    20. # 脚本一概请大家自行测试,带来的不便请谅解~)
    21. # 菜单栏选项文字
    22. ITEM = "查看背包"
    23. SKILL = "功夫武学"
    24. EQUIP = "更换装备"
    25. STATUS = "角色状态"
    26. SAVE = "保存记录"
    27. EXIT = "离开游戏"
    28. # 金钱窗口的标题
    29. GOLD = "银两"
    30. # 等级的前缀,如Lv  Lv.  Level等
    31. LEVEL = "等级"
    32. class Game_Actor
    33.   #--------------------------------------------------------------------------
    34.   # ★ 2个 EXP 字符串函数 by 小翼 [FDU]alwing
    35.   #--------------------------------------------------------------------------
    36.   def now_exp
    37.     return@exp - @exp_list[@level]
    38.   end
    39.   def next_exp
    40.     return@exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
    41.         end
    42. end
    43. class Window_Base < Window
    44.   #--------------------------------------------------------------------------
    45.   # ★ 获取文字色 by 小翼 [FDU]alwing WOW
    46.   #     n : 颜色编号
    47.   #--------------------------------------------------------------------------
    48.   def rec_color(n)
    49.     case n
    50.     # 蓝色
    51.     when0
    52.       return Color.new(0, 16, 65, 255)
    53.     when1
    54.       return Color.new(0, 40, 160, 255)
    55.     when2
    56.       return Color.new(0, 54, 215, 255)
    57.     when3
    58.       return Color.new(0, 49, 195, 255)
    59.     when4
    60.       return Color.new(0, 41, 165, 255)
    61.     when5
    62.       return Color.new(0, 35, 140, 255)
    63.     when6
    64.       return Color.new(0, 26, 105, 255)
    65.     when7
    66.       return Color.new(0, 10, 40, 255)
    67.     # 橙色
    68.     when10
    69.       return Color.new(65, 32, 0, 255)
    70.     when11
    71.       return Color.new(160, 80, 0, 255)
    72.     when12
    73.       return Color.new(215, 107, 0, 255)
    74.     when13
    75.       return Color.new(195, 97, 0, 255)
    76.     when14
    77.       return Color.new(165, 82, 0, 255)
    78.     when15
    79.       return Color.new(140, 70, 0, 255)
    80.     when16
    81.       return Color.new(105, 52, 0, 255)
    82.     when17
    83.       return Color.new(40, 20, 0, 255)
    84.     # 青色
    85.     when20
    86.       return Color.new(0, 65, 65, 255)
    87.     when21
    88.       return Color.new(0, 160, 160, 255)
    89.     when22
    90.       return Color.new(0, 215, 215, 255)
    91.     when23
    92.       return Color.new(0, 195, 195, 255)
    93.     when24
    94.       return Color.new(0, 165, 165, 255)
    95.     when25
    96.       return Color.new(0, 140, 140, 255)
    97.     when26
    98.       return Color.new(0, 105, 105, 255)
    99.     when27
    100.       return Color.new(0, 40, 40, 255)
    101.     # 紫红
    102.     when30
    103.       return Color.new(65, 0, 32, 255)
    104.     when31
    105.       return Color.new(160, 0, 80, 255)
    106.     when32
    107.       return Color.new(215, 0, 107, 255)
    108.     when33
    109.       return Color.new(195, 0, 97, 255)
    110.     when34
    111.       return Color.new(165, 0, 82, 255)
    112.     when35
    113.       return Color.new(140, 0, 70, 255)
    114.     when36
    115.       return Color.new(105, 0, 52, 255)
    116.     when37
    117.       return Color.new(40, 0, 20, 255)
    118.     end
    119.   end
    120. #--------------------------------------------------------------------------
    121.   # ● 职业的描绘
    122.   #     actor : 角色
    123.   #     x     : 描画目标 X 坐标
    124.   #     y     : 描画目标 Y 坐标
    125.   #--------------------------------------------------------------------------
    126.   def draw_actor_class(actor, x, y)
    127.     self.contents.font.color = normal_color
    128.     self.contents.draw_text(x, y, 236, 32, "[" + actor.class_name + "]")
    129.   end
    130.   #--------------------------------------------------------------------------
    131.   # ● 描画 EXP ★主菜单
    132.   #     actor : 角色
    133.   #     x     : 描画目标 X 坐标
    134.   #     y     : 描画目标 Y 坐标
    135.   #--------------------------------------------------------------------------
    136.   def draw_actor_exp(actor, x, y)
    137.     self.contents.font.size = 20
    138.     self.contents.font.color = system_color
    139.     self.contents.draw_text(x+1, y, 80, 32, "EXP")
    140.     self.contents.font.color = normal_color
    141.     self.contents.draw_text(x - 10 , y, 84, 32, actor.exp_s, 2)
    142.     self.contents.draw_text(x + 74, y, 12, 32, "/", 1)
    143.     self.contents.draw_text(x + 88, y, 84, 32, actor.next_exp_s)
    144.   end
    145.   #--------------------------------------------------------------------------
    146.   # ● 描画 EXP ★状态窗口
    147.   #     actor : 角色
    148.   #     x     : 描画目标 X 坐标
    149.   #     y     : 描画目标 Y 坐标
    150.   #--------------------------------------------------------------------------
    151.   def draw_actor_exp_status(actor, x, y)
    152.     self.contents.font.size = 20
    153.     self.contents.font.color = system_color
    154.     self.contents.draw_text(x+1, y, 80, 32, "EXP")
    155.     self.contents.font.color = normal_color
    156.     self.contents.draw_text(x + 108, y, 84, 32, actor.exp_s, 2)
    157.     self.contents.draw_text(x + 192, y, 12, 32, "/", 1)
    158.     self.contents.draw_text(x + 204, y, 84, 32, actor.next_exp_s)
    159.   end
    160.   #--------------------------------------------------------------------------
    161.   # ★ 描绘 EXP 矩形 by 小翼 [FDU]alwing
    162.   #     actor : 角色
    163.   #     x     : 描画目标 X 坐标
    164.   #     y     : 描画目标 Y 坐标
    165.   #     width : 描画目标的宽
    166.   #--------------------------------------------------------------------------
    167.   def EXP(actor,x,y,width = 128)
    168.     self.contents.fill_rect(x+26, y+60, width+4,9, Color.new(0,0,0,255))
    169.     self.contents.fill_rect(x+27, y+61, width+2,7, Color.new(255,255,255,255))
    170.     self.contents.fill_rect(x+28, y+62, width,5, Color.new(0,0,0,255))
    171.     if actor.next_exp > 0
    172.       @EXPw = width * actor.now_exp/actor.next_exp
    173.       self.contents.fill_rect(x+28, y+62, @EXPw,1, Color.new(100,50,150,255))
    174.       self.contents.fill_rect(x+28, y+63, @EXPw,1, Color.new(150,100,200,255))
    175.       self.contents.fill_rect(x+28, y+64, @EXPw,1, Color.new(200,150,255,255))
    176.       self.contents.fill_rect(x+28, y+65, @EXPw,1, Color.new(150,100,200,255))
    177.       self.contents.fill_rect(x+28, y+66, @EXPw,1, Color.new(100,50,150,255))
    178.     else
    179.       self.contents.fill_rect(x+28, y+62, width,1, Color.new(50,150,150,255))
    180.       self.contents.fill_rect(x+28, y+63, width,1, Color.new(100,200,200,255))
    181.       self.contents.fill_rect(x+28, y+64, width,1, Color.new(150,255,255,255))
    182.       self.contents.fill_rect(x+28, y+65, width,1, Color.new(100,200,200,255))
    183.       self.contents.fill_rect(x+28, y+66, width,1, Color.new(50,150,150,255))
    184.     end
    185.   end
    186.   #--------------------------------------------------------------------------
    187.   # ● 描绘 HP
    188.   #     actor : 角色
    189.   #     x     : 描画目标 X 坐标
    190.   #     y     : 描画目标 Y 坐标
    191.   #     width : 描画目标的宽
    192.   #--------------------------------------------------------------------------
    193.   def draw_actor_hp(actor, x, y, width = 144)
    194.     # 描绘字符串 "HP"
    195.     self.contents.font.color = system_color
    196.     self.contents.font.size = 20
    197.     self.contents.draw_text(x+16, y, 32, 32, "体")
    198.     # 计算描绘 MaxHP 所需的空间
    199.     if width - 32 >= 108
    200.       hp_x = x + width - 108
    201.       flag = true
    202.     elsif width - 32 >= 48
    203.       hp_x = x + width - 48
    204.       flag = false
    205.     end
    206.     # 描绘 HP
    207.     if flag
    208.       self.contents.font.color = actor.hp == 0 ? knockout_color :
    209.         actor.hp = 48
    210.       sp_x = x + width - 48
    211.       flag = false
    212.     end
    213.     # 描绘 SP
    214.     if flag
    215.       self.contents.font.color = actor.sp == 0 ? knockout_color :
    216.         actor.sp = 0 && index = 3 && index = 10 && actor.id < 100
    217.                         testname = "Actor0"+ actor.id.to_s
    218.                 elsif actor.id >= 100 && actor.id = 2
    219.                                 @status_window[1].active = false
    220.                                 @status_window[1].index = -1
    221.                            if$game_party.actors.size >= 3
    222.                                    @status_window[2].active = false
    223.                                    @status_window[2].index = -1
    224.                               if$game_party.actors.size >= 4
    225.                                       @status_window[3].active = false
    226.                                                    @status_window[3].index = -1
    227.                                            end
    228.                                   end
    229.                         end
    230.                         when1
    231.                         @status_window[0].active = false
    232.                         @status_window[0].index = -1
    233.                         if$game_party.actors.size >= 2
    234.                                 @status_window[1].active = true
    235.                                 @status_window[1].index = 0
    236.                            if$game_party.actors.size >= 3
    237.                                    @status_window[2].active = false
    238.                                    @status_window[2].index = -1
    239.                               if$game_party.actors.size >= 4
    240.                                       @status_window[3].active = false
    241.                                                    @status_window[3].index = -1
    242.                                            end
    243.                                   end
    244.                         end
    245.                         when2
    246.                         @status_window[0].active = false
    247.                         @status_window[0].index = -1
    248.                         if$game_party.actors.size >= 2
    249.                                 @status_window[1].active = false
    250.                                 @status_window[1].index = -1
    251.                            if$game_party.actors.size >= 3
    252.                                    @status_window[2].active = true
    253.                                    @status_window[2].index = 0
    254.                               if$game_party.actors.size >= 4
    255.                                       @status_window[3].active = false
    256.                                                    @status_window[3].index = -1
    257.                                            end
    258.                                   end
    259.                         end
    260.                                 @status_window[0].active = false
    261.                                 @status_window[0].index = -1
    262.                                 @status_window[1].active = false
    263.                                 @status_window[1].index = -1
    264.                                 @status_window[2].active = true
    265.                                 @status_window[2].index = 0
    266.                                 @status_window[3].active = false
    267.                                 @status_window[3].index = -1
    268.                         when3
    269.                         @status_window[0].active = false
    270.                         @status_window[0].index = -1
    271.                         if$game_party.actors.size >= 2
    272.                                 @status_window[1].active = false
    273.                                 @status_window[1].index = -1
    274.                            if$game_party.actors.size >= 3
    275.                                    @status_window[2].active = false
    276.                                    @status_window[2].index = -1
    277.                               if$game_party.actors.size >= 4
    278.                                       @status_window[3].active = true
    279.                                                    @status_window[3].index = 0
    280.                                            end
    281.                                   end
    282.                         end
    283.                 end
    284.     # 按下 B 键的情况下
    285.     if Input.trigger?(Input::B)
    286.       # 演奏取消 SE
    287.       $game_system.se_play($data_system.cancel_se)
    288.       # 激活命令窗口
    289.       @command_window.active = true
    290.       @status_window[@status_index].active = false
    291.       @status_window[@status_index].index = -1
    292.                          @status_index = 0
    293.       return
    294.     end
    295.     # 按下 C 键的情况下
    296.     if Input.trigger?(Input::C)
    297.       # 命令窗口的光标位置分支
    298.       case@command_window.index
    299.       when1  # 特技
    300.         # 本角色的行动限制在 2 以上的情况下
    301.         if$game_party.actors[@status_index].restriction >= 2
    302.           # 演奏冻结 SE
    303.           $game_system.se_play($data_system.buzzer_se)
    304.           return
    305.         end
    306.         # 演奏确定 SE
    307.         $game_system.se_play($data_system.decision_se)
    308.         # 切换到特技画面
    309.         $scene = Scene_Skill.new(@status_index)#window.index)
    310.       when2  # 装备
    311.         # 演奏确定 SE
    312.         $game_system.se_play($data_system.decision_se)
    313.         # 切换的装备画面
    314.         $scene = Scene_Equip.new(@status_index)#@status_window.index)
    315.       when3  # 状态
    316.         # 演奏确定 SE
    317.         $game_system.se_play($data_system.decision_se)
    318.         # 切换到状态画面
    319.         $scene = Scene_Status.new(@status_index)#@status_window.index)
    320.       end
    321.       return
    322.     end
    323.   end
    324. end
    325. class Scene_Skill
    326.   def update_skill
    327.     # 按下 B 键的情况下
    328.                 $cancel = true
    329.                 $index = @actor_index
    330.     if Input.trigger?(Input::B)
    331.       # 演奏取消 SE
    332.       $game_system.se_play($data_system.cancel_se)
    333.       # 切换到菜单画面
    334.       $scene = Scene_Menu.new(1)
    335.       return
    336.     end
    337.     # 按下 C 键的情况下
    338.     if Input.trigger?(Input::C)
    339.       # 获取特技窗口现在选择的特技的数据
    340.       @skill = @skill_window.skill
    341.       # 不能使用的情况下
    342.       if@skill == nilornot@actor.skill_can_use?(@skill.id)
    343.         # 演奏冻结 SE
    344.         $game_system.se_play($data_system.buzzer_se)
    345.         return
    346.       end
    347.       # 演奏确定 SE
    348.       $game_system.se_play($data_system.decision_se)
    349.       # 效果范围是我方的情况下
    350.       if@skill.scope >= 3
    351.         # 激活目标窗口
    352.         @skill_window.active = false
    353.         @target_window.x = (@skill_window.index + 1) % 2 * 304
    354.         @target_window.visible = true
    355.         @target_window.active = true
    356.         # 设置效果范围 (单体/全体) 的对应光标位置
    357.         if@skill.scope == 4 || @skill.scope == 6
    358.           @target_window.index = -1
    359.         elsif@skill.scope == 7
    360.           @target_window.index = @actor_index - 10
    361.         else
    362.           @target_window.index = 0
    363.         end
    364.       # 效果在我方以外的情况下
    365.       else
    366.         # 公共事件 ID 有效的情况下
    367.         if@skill.common_event_id > 0
    368.           # 预约调用公共事件
    369.           $game_temp.common_event_id = @skill.common_event_id
    370.           # 演奏特技使用时的 SE
    371.           $game_system.se_play(@skill.menu_se)
    372.           # 消耗 SP
    373.           @actor.sp -= @skill.sp_cost
    374.           # 再生成各窗口的内容
    375.           @status_window.refresh
    376.           @skill_window.refresh
    377.           @target_window.refresh
    378.           # 切换到地图画面
    379.           $scene = Scene_Map.new
    380.           return
    381.         end
    382.       end
    383.       return
    384.     end
    385.     # 按下 R 键的情况下
    386.     if Input.trigger?(Input::R)
    387.       # 演奏光标 SE
    388.       $game_system.se_play($data_system.cursor_se)
    389.       # 移至下一位角色
    390.       @actor_index += 1
    391.       @actor_index %= $game_party.actors.size
    392.       # 切换到别的特技画面
    393.       $scene = Scene_Skill.new(@actor_index)
    394.       return
    395.     end
    396.     # 按下 L 键的情况下
    397.     if Input.trigger?(Input::L)
    398.       # 演奏光标 SE
    399.       $game_system.se_play($data_system.cursor_se)
    400.       # 移至上一位角色
    401.       @actor_index += $game_party.actors.size - 1
    402.       @actor_index %= $game_party.actors.size
    403.       # 切换到别的特技画面
    404.       $scene = Scene_Skill.new(@actor_index)
    405.       return
    406.     end
    407.   end
    408. end
    409. class Scene_Equip
    410.   def update_right
    411.     # 按下 B 键的情况下
    412.     if Input.trigger?(Input::B)
    413.                         $cancel = true
    414.                   $index = @actor_index
    415.       # 演奏取消 SE
    416.       $game_system.se_play($data_system.cancel_se)
    417.       # 切换到菜单画面
    418.       $scene = Scene_Menu.new(2)
    419.       return
    420.     end
    421.     # 按下 C 键的情况下
    422.     if Input.trigger?(Input::C)
    423.       # 固定装备的情况下
    424.       if@actor.equip_fix?(@right_window.index)
    425.         # 演奏冻结 SE
    426.         $game_system.se_play($data_system.buzzer_se)
    427.         return
    428.       end
    429.       # 演奏确定 SE
    430.       $game_system.se_play($data_system.decision_se)
    431.       # 激活物品窗口
    432.       @right_window.active = false
    433.       @item_window.active = true
    434.       @item_window.index = 0
    435.       return
    436.     end
    437.     # 按下 R 键的情况下
    438.     if Input.trigger?(Input::R)
    439.       # 演奏光标 SE
    440.       $game_system.se_play($data_system.cursor_se)
    441.       # 移至下一位角色
    442.       @actor_index += 1
    443.       @actor_index %= $game_party.actors.size
    444.       # 切换到别的装备画面
    445.       $scene = Scene_Equip.new(@actor_index, @right_window.index)
    446.       return
    447.     end
    448.     # 按下 L 键的情况下
    449.     if Input.trigger?(Input::L)
    450.       # 演奏光标 SE
    451.       $game_system.se_play($data_system.cursor_se)
    452.       # 移至上一位角色
    453.       @actor_index += $game_party.actors.size - 1
    454.       @actor_index %= $game_party.actors.size
    455.       # 切换到别的装备画面
    456.       $scene = Scene_Equip.new(@actor_index, @right_window.index)
    457.       return
    458.     end
    459.   end
    460. end
    461. class Scene_Status
    462.   def update
    463.     # 按下 B 键的情况下
    464.     if Input.trigger?(Input::B)
    465.                         $cancel = true
    466.                         $index = @actor_index
    467.       # 演奏取消 SE
    468.       $game_system.se_play($data_system.cancel_se)
    469.       # 切换到菜单画面
    470.       $scene = Scene_Menu.new(3)
    471.       return
    472.     end
    473.     # 按下 R 键的情况下
    474.     if Input.trigger?(Input::R)
    475.       # 演奏光标 SE
    476.       $game_system.se_play($data_system.cursor_se)
    477.       # 移至下一位角色
    478.       @actor_index += 1
    479.       @actor_index %= $game_party.actors.size
    480.       # 切换到别的状态画面
    481.       $scene = Scene_Status.new(@actor_index)
    482.       return
    483.     end
    484.     # 按下 L 键的情况下
    485.     if Input.trigger?(Input::L)
    486.       # 演奏光标 SE
    487.       $game_system.se_play($data_system.cursor_se)
    488.       # 移至上一位角色
    489.       @actor_index += $game_party.actors.size - 1
    490.       @actor_index %= $game_party.actors.size
    491.       # 切换到别的状态画面
    492.       $scene = Scene_Status.new(@actor_index)
    493.       return
    494.     end
    495.   end
    496. end
    复制代码


    (o゚ω゚o)( ゚ω゚)(o゚ω゚o)  


                 本帖来自P1论坛作者xingxing991219,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=381982  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2024-5-3 03:09 , Processed in 0.061959 second(s), 44 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表