自己写的一个菜单界面的美化脚本
嗯……第一次正儿八经地写一个脚本,第一次在发布区发布我的作品,心情还是很激动很忐忑的{:2_285:}其实说这是我写的吧,也不完全算是,基本上还是用默认脚本改的,另外Window_Base类中几个新方法的定义也是引用了其他大神的脚本里的内容。总共改动了9个类,Game一个,Window4个,Scene4个,主要是对Scene_Menu类和Window_MenuStatus类的改写。可能在高手看来,真的好蠢好蠢……不过看在我是第一次的份上,就宽容一下嘛{:2_251:} 希望可以给我提出一些宝贵意见,不论是脚本结构方面、算法方面和效果方面,都可以尽情地提出来,如果发现什么bug,也希望可以第一时间告诉我~
下面放出效果截图、代码内容和范例工程(范例工程里什么也没做,只是放了几张头像图而已。。头像图来自66rpg整合素材包,不会告我侵权吧= =)
另外,注释里写的by 飞云,飞云就是我啦…………只不过当时注册论坛号的时候不知道可以打中文,只好用xingxing991219,现在知道了也没法改= =很郁闷的说,其实飞云才是我的真正艺名~_~
好吧,就扯这么多。
RUBY 代码
#==============================================================
# 菜单界面大调整脚本 by 飞云
#==============================================================
# 本脚本大幅度调整了Esc菜单界面的结构,窗口为半透明状态,各文字内容
# 可在下方修改,具体对应关系可在游戏测试中查看。
#
# 本脚本兼容性较差,重新定义了Scene_Menu脚本的大部分方法,如果您
# 使用了其他修改菜单界面的脚本,请慎重使用本脚本,如有冲突,请自
# 行整合。
#
# 使用方法:将全部内容插入到Main上方,并在Graphics目录下新建一个
# Heads文件夹,将头像文件放入,格式为Actorx.png(注:x为该角色在数
# 据库内的编号,1、2、3、4……11、12、13…… 比如一号角色的头像文件名
# 为Actor001,二十号角色的头像文件名为Actor020,128号角色的头像文
# 件名为Actor128,如果序号超过999,请自行修改脚本= =)
#
# 转载和使用请保留本信息,谢谢合作!
#
# (已知本脚本不与柳柳大人的技能分类脚本、小翼的值槽脚本冲突,其他
# 脚本一概请大家自行测试,带来的不便请谅解~)
# 菜单栏选项文字
ITEM = "查看背包"
SKILL = "功夫武学"
EQUIP = "更换装备"
STATUS = "角色状态"
SAVE = "保存记录"
EXIT = "离开游戏"
# 金钱窗口的标题
GOLD = "银两"
# 等级的前缀,如LvLv.Level等
LEVEL = "等级"
class Game_Actor
#--------------------------------------------------------------------------
# ★ 2个 EXP 字符串函数 by 小翼 alwing
#--------------------------------------------------------------------------
def now_exp
return@exp - @exp_list[@level]
end
def next_exp
return@exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
# ★ 获取文字色 by 小翼 alwing WOW
# n : 颜色编号
#--------------------------------------------------------------------------
def rec_color(n)
case n
# 蓝色
when0
return Color.new(0, 16, 65, 255)
when1
return Color.new(0, 40, 160, 255)
when2
return Color.new(0, 54, 215, 255)
when3
return Color.new(0, 49, 195, 255)
when4
return Color.new(0, 41, 165, 255)
when5
return Color.new(0, 35, 140, 255)
when6
return Color.new(0, 26, 105, 255)
when7
return Color.new(0, 10, 40, 255)
# 橙色
when10
return Color.new(65, 32, 0, 255)
when11
return Color.new(160, 80, 0, 255)
when12
return Color.new(215, 107, 0, 255)
when13
return Color.new(195, 97, 0, 255)
when14
return Color.new(165, 82, 0, 255)
when15
return Color.new(140, 70, 0, 255)
when16
return Color.new(105, 52, 0, 255)
when17
return Color.new(40, 20, 0, 255)
# 青色
when20
return Color.new(0, 65, 65, 255)
when21
return Color.new(0, 160, 160, 255)
when22
return Color.new(0, 215, 215, 255)
when23
return Color.new(0, 195, 195, 255)
when24
return Color.new(0, 165, 165, 255)
when25
return Color.new(0, 140, 140, 255)
when26
return Color.new(0, 105, 105, 255)
when27
return Color.new(0, 40, 40, 255)
# 紫红
when30
return Color.new(65, 0, 32, 255)
when31
return Color.new(160, 0, 80, 255)
when32
return Color.new(215, 0, 107, 255)
when33
return Color.new(195, 0, 97, 255)
when34
return Color.new(165, 0, 82, 255)
when35
return Color.new(140, 0, 70, 255)
when36
return Color.new(105, 0, 52, 255)
when37
return Color.new(40, 0, 20, 255)
end
end
#--------------------------------------------------------------------------
# ● 职业的描绘
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_class(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 236, 32, "[" + actor.class_name + "]")
end
#--------------------------------------------------------------------------
# ● 描画 EXP ★主菜单
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_exp(actor, x, y)
self.contents.font.size = 20
self.contents.font.color = system_color
self.contents.draw_text(x+1, y, 80, 32, "EXP")
self.contents.font.color = normal_color
self.contents.draw_text(x - 10 , y, 84, 32, actor.exp_s, 2)
self.contents.draw_text(x + 74, y, 12, 32, "/", 1)
self.contents.draw_text(x + 88, y, 84, 32, actor.next_exp_s)
end
#--------------------------------------------------------------------------
# ● 描画 EXP ★状态窗口
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_exp_status(actor, x, y)
self.contents.font.size = 20
self.contents.font.color = system_color
self.contents.draw_text(x+1, y, 80, 32, "EXP")
self.contents.font.color = normal_color
self.contents.draw_text(x + 108, y, 84, 32, actor.exp_s, 2)
self.contents.draw_text(x + 192, y, 12, 32, "/", 1)
self.contents.draw_text(x + 204, y, 84, 32, actor.next_exp_s)
end
#--------------------------------------------------------------------------
# ★ 描绘 EXP 矩形 by 小翼 alwing
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标的宽
#--------------------------------------------------------------------------
def EXP(actor,x,y,width = 128)
self.contents.fill_rect(x+26, y+60, width+4,9, Color.new(0,0,0,255))
self.contents.fill_rect(x+27, y+61, width+2,7, Color.new(255,255,255,255))
self.contents.fill_rect(x+28, y+62, width,5, Color.new(0,0,0,255))
if actor.next_exp > 0
@EXPw = width * actor.now_exp/actor.next_exp
self.contents.fill_rect(x+28, y+62, @EXPw,1, Color.new(100,50,150,255))
self.contents.fill_rect(x+28, y+63, @EXPw,1, Color.new(150,100,200,255))
self.contents.fill_rect(x+28, y+64, @EXPw,1, Color.new(200,150,255,255))
self.contents.fill_rect(x+28, y+65, @EXPw,1, Color.new(150,100,200,255))
self.contents.fill_rect(x+28, y+66, @EXPw,1, Color.new(100,50,150,255))
else
self.contents.fill_rect(x+28, y+62, width,1, Color.new(50,150,150,255))
self.contents.fill_rect(x+28, y+63, width,1, Color.new(100,200,200,255))
self.contents.fill_rect(x+28, y+64, width,1, Color.new(150,255,255,255))
self.contents.fill_rect(x+28, y+65, width,1, Color.new(100,200,200,255))
self.contents.fill_rect(x+28, y+66, width,1, Color.new(50,150,150,255))
end
end
#--------------------------------------------------------------------------
# ● 描绘 HP
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标的宽
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 144)
# 描绘字符串 "HP"
self.contents.font.color = system_color
self.contents.font.size = 20
self.contents.draw_text(x+16, y, 32, 32, "体")
# 计算描绘 MaxHP 所需的空间
if width - 32 >= 108
hp_x = x + width - 108
flag = true
elsif width - 32 >= 48
hp_x = x + width - 48
flag = false
end
# 描绘 HP
if flag
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp = 48
sp_x = x + width - 48
flag = false
end
# 描绘 SP
if flag
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp = 0 && index = 3 && index = 10 && actor.id < 100
testname = "Actor0"+ actor.id.to_s
elsif actor.id >= 100 && actor.id = 2
@status_window.active = false
@status_window.index = -1
if$game_party.actors.size >= 3
@status_window.active = false
@status_window.index = -1
if$game_party.actors.size >= 4
@status_window.active = false
@status_window.index = -1
end
end
end
when1
@status_window.active = false
@status_window.index = -1
if$game_party.actors.size >= 2
@status_window.active = true
@status_window.index = 0
if$game_party.actors.size >= 3
@status_window.active = false
@status_window.index = -1
if$game_party.actors.size >= 4
@status_window.active = false
@status_window.index = -1
end
end
end
when2
@status_window.active = false
@status_window.index = -1
if$game_party.actors.size >= 2
@status_window.active = false
@status_window.index = -1
if$game_party.actors.size >= 3
@status_window.active = true
@status_window.index = 0
if$game_party.actors.size >= 4
@status_window.active = false
@status_window.index = -1
end
end
end
@status_window.active = false
@status_window.index = -1
@status_window.active = false
@status_window.index = -1
@status_window.active = true
@status_window.index = 0
@status_window.active = false
@status_window.index = -1
when3
@status_window.active = false
@status_window.index = -1
if$game_party.actors.size >= 2
@status_window.active = false
@status_window.index = -1
if$game_party.actors.size >= 3
@status_window.active = false
@status_window.index = -1
if$game_party.actors.size >= 4
@status_window.active = true
@status_window.index = 0
end
end
end
end
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 激活命令窗口
@command_window.active = true
@status_window[@status_index].active = false
@status_window[@status_index].index = -1
@status_index = 0
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口的光标位置分支
case@command_window.index
when1# 特技
# 本角色的行动限制在 2 以上的情况下
if$game_party.actors[@status_index].restriction >= 2
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到特技画面
$scene = Scene_Skill.new(@status_index)#window.index)
when2# 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换的装备画面
$scene = Scene_Equip.new(@status_index)#@status_window.index)
when3# 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到状态画面
$scene = Scene_Status.new(@status_index)#@status_window.index)
end
return
end
end
end
class Scene_Skill
def update_skill
# 按下 B 键的情况下
$cancel = true
$index = @actor_index
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(1)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取特技窗口现在选择的特技的数据
@skill = @skill_window.skill
# 不能使用的情况下
if@skill == nilornot@actor.skill_can_use?(@skill.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 效果范围是我方的情况下
if@skill.scope >= 3
# 激活目标窗口
@skill_window.active = false
@target_window.x = (@skill_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 设置效果范围 (单体/全体) 的对应光标位置
if@skill.scope == 4 || @skill.scope == 6
@target_window.index = -1
elsif@skill.scope == 7
@target_window.index = @actor_index - 10
else
@target_window.index = 0
end
# 效果在我方以外的情况下
else
# 公共事件 ID 有效的情况下
if@skill.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @skill.common_event_id
# 演奏特技使用时的 SE
$game_system.se_play(@skill.menu_se)
# 消耗 SP
@actor.sp -= @skill.sp_cost
# 再生成各窗口的内容
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
return
end
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的特技画面
$scene = Scene_Skill.new(@actor_index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的特技画面
$scene = Scene_Skill.new(@actor_index)
return
end
end
end
class Scene_Equip
def update_right
# 按下 B 键的情况下
if Input.trigger?(Input::B)
$cancel = true
$index = @actor_index
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(2)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 固定装备的情况下
if@actor.equip_fix?(@right_window.index)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活物品窗口
@right_window.active = false
@item_window.active = true
@item_window.index = 0
return
end
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的装备画面
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的装备画面
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
end
end
class Scene_Status
def update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
$cancel = true
$index = @actor_index
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(3)
return
end
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的状态画面
$scene = Scene_Status.new(@actor_index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的状态画面
$scene = Scene_Status.new(@actor_index)
return
end
end
end
(o゚ω゚o)( ゚ω゚)(o゚ω゚o)
本帖来自P1论坛作者xingxing991219,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=381982若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页:
[1]