| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2013-5-30 |
| 在线时间 | 24 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 24 小时
- 注册时间
- 2012-10-27
- 回帖
- 7
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
前幾天我用了沉影不器大大提供的新式菜單腳本→(http://www.66rpg.com/articles/3043)
可是因為我有把視窗調整成640X480的大小,
導致裡面很多視窗都顯示在左上角,看起來相當奇怪
我有自己試著調調看了,但還是有些視窗還是不會調
請教教我要怎麼調,還有可以順便問一下嗎?
存檔截圖可不可以用大一點呀?
如果不需要存檔功能要怎麼弄掉?
(因為原本SAVE攻能已經去掉了.
但是用這個腳本SAVE功能又跑出來了)
圈起來的地方是不會調的部分
- #==============================================================================
- MAX_SAVE_ID = 20 # 最大存档数
- MENU_ICON = [144, 128, 52, 137, 133, 112] # 菜单图标id
- SAVE_DIR = "Saves/" # 改变的存档目录(不希望改变目录请删)
- #==============================================================================
- # (快速存储Bitmap的Marshal 作者: 柳之一) 强大啊
- #==============================================================================
- class Bitmap
- # 传送到内存的API函数
- RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
- RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
- def _dump(limit)
- data = "rgba" * width * height
- RtlMoveMemory_pi.call(data, address, data.length)
- [width, height, Zlib::Deflate.deflate(data)].pack("LLa*") # 压缩
- end
- def self._load(str)
- w, h, zdata = str.unpack("LLa*")
- b = self.new(w, h)
- RtlMoveMemory_ip.call(b.address, Zlib::Inflate.inflate(zdata), w * h * 4)
- return b
- end
- # [[[bitmap.object_id * 2 + 16] + 8] + 16] == 数据的开头
- def address
- buffer, ad = "rgba", object_id * 2 + 16
- RtlMoveMemory_pi.call(buffer, ad, 4)
- ad = buffer.unpack("L")[0] + 8
- RtlMoveMemory_pi.call(buffer, ad, 4)
- ad = buffer.unpack("L")[0] + 16
- RtlMoveMemory_pi.call(buffer, ad, 4)
- return buffer.unpack("L")[0]
- end
- end
- #==============================================================================
- # ■ Game_Temp
- #==============================================================================
- class Game_Temp
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :menu_bitmap # 菜单背景位图
- attr_accessor :sub_menu_bitmap # 子菜单背景位图
- attr_accessor :save_bitmap # 存档位图
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- alias ini initialize
- def initialize
- ini
- @menu_bitmap = Bitmap.new(1, 1)
- @sub_menu_bitmap = Bitmap.new(1, 1)
- @save_bitmap = Bitmap.new(1, 1)
- end
- end
- #==============================================================================
- # ■ Window_MenuTarget
- #==============================================================================
- class Window_MenuTarget < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, 510, 128)
- self.contents.font.size = 18
- refresh
- self.active = false
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- super
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- @item_max = $game_party.members.size
- for i in 0...@item_max
- draw_item(i)
- end
- draw_6Rface(@index) if @index >= 0
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- rect.x += 4
- rect.width -= 8
- self.contents.clear_rect(rect)
- self.contents.font.color = normal_color
- actor = $game_party.members[index]
- draw_actor_name(actor, 124, rect.y + 2)
- begin_x = self.contents.text_size(actor.name).width + 4
- draw_actor_state(actor, begin_x, rect.y, 24)
- draw_actor_hp(actor, 230, rect.y, 65)
- draw_actor_mp(actor, 310, rect.y, 65)
- end
- #--------------------------------------------------------------------------
- # ● 描绘人物头像
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_6Rface(index)
- rect = Rect.new(0, 0, 96, 96)
- self.contents.clear_rect(rect)
- actor = $game_party.members[index]
- draw_actor_face(actor, 0, 0, 96)
- end
- #--------------------------------------------------------------------------
- # ● 设置光标的位置
- # index : 新的光标位置
- #--------------------------------------------------------------------------
- def index=(index)
- @index = index
- update_cursor
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 获取项目描画矩形
- # index : 项目编号
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = contents.width - 113
- rect.height = WLH
- rect.x = 113
- rect.y = index / @column_max * WLH
- return rect
- end
- #--------------------------------------------------------------------------
- # ● 更新光标矩形
- #--------------------------------------------------------------------------
- def update_cursor
- if @index < 0 # 光标位置不满 0 的情况下
- self.cursor_rect.empty # 光标无效
- else # 光标位 0 以上的情况下
- row = @index / @column_max # 获取当前的行
- if row < top_row # 当前行被显示开头行前面的情况下
- self.top_row = row # 从当前行向开头行滚动
- end
- if row > bottom_row # 当前行被显示末尾行之后的情况下
- self.bottom_row = row # 从当前行向末尾滚动
- end
- rect = item_rect(@index) # 获取选择项的矩形
- rect.y -= self.oy # 矩形滚动的位置加起来
- self.cursor_rect = rect # 更新光标矩形
- end
- end
- end
- #==============================================================================
- # ■ Window_EquipItem
- #==============================================================================
- class Window_EquipItem < Window_Item
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- # width : 窗口的宽
- # height : 窗口的高
- # actor : 角色
- # equip_type : 装备部位 (0~4)
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height, actor, equip_type)
- [url=home.php?mod=space&uid=95897]@actor[/url] = actor
- if equip_type == 1 and actor.two_swords_style # 二刀流
- equip_type = 0 # 将盾更改为武器
- end
- @equip_type = equip_type
- super(x, y, width, height)
- @column_max = 1
- self.index = 0
- refresh
- end
- end
- #==============================================================================
- # ■ Window_Equip
- #==============================================================================
- class Window_Equip < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- # actor : 角色
- #--------------------------------------------------------------------------
- def initialize(x, y, actor)
- super(x, y, 510, WLH * 5 + 32)
- @actor = actor
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- alias old_refresh refresh
- def refresh
- old_refresh
- draw_actor_face(@actor, 278, 16, size = 96)
- end
- #--------------------------------------------------------------------------
- # ● 获取项目要描画的矩形
- # index : 项目编号
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = (contents.width + @spacing) / @column_max - @spacing - 112
- rect.height = WLH
- rect.x = index % @column_max * (rect.width + @spacing)
- rect.y = index / @column_max * WLH
- return rect
- end
- end
- #==============================================================================
- # ■ Window_Status
- #==============================================================================
- class Window_Status < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # actor : 角色
- #--------------------------------------------------------------------------
- def initialize(actor)
- super(32, 56, 510, 304)
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- draw_actor_name(@actor, 4, 0)
- draw_actor_class(@actor, 128, 0)
- draw_actor_face(@actor, 8, 32)
- draw_basic_info(128, 32)
- draw_parameters(32, 160)
- draw_exp_info(264, 0)
- draw_equipments(264, 128)
- end
- end
- #==============================================================================
- # ■ Window_SaveFile
- #==============================================================================
- class Window_SaveFile < Window_Base
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :filename # 文件名
- attr_reader :file_exist # 文件存在标志
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # file_index : 存档文件索引 (0~3)
- # filename : 文件名
- #--------------------------------------------------------------------------
- def initialize(file_index, filename)
- super(179, 59, 416, 298)
- @file_index = file_index
- @filename = filename
- load_gamedata
- refresh(@file_index)
- end
- #--------------------------------------------------------------------------
- # ● 读取部分游戏数据
- #--------------------------------------------------------------------------
- def load_gamedata
- @file_exist = FileTest.exist?(SAVE_DIR + @filename)
- if @file_exist
- file = File.open(SAVE_DIR + @filename, "r")
- begin
- @characters = Marshal.load(file)
- @frame_count = Marshal.load(file)
- @last_bgm = Marshal.load(file)
- @last_bgs = Marshal.load(file)
- @game_system = Marshal.load(file)
- @game_message = Marshal.load(file)
- @game_switches = Marshal.load(file)
- @game_variables = Marshal.load(file)
- @total_sec = @frame_count / Graphics.frame_rate
- rescue
- @file_exist = false
- ensure
- file.close
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- # index : 索引
- #--------------------------------------------------------------------------
- def refresh(index)
- file_index = index
- self.contents.clear
- self.contents.font.color = normal_color
- if @file_exist
- self.contents.fill_rect(0, 0, 272,208+2, Color.new(0,0,64))
- if FileTest.exist?(SAVE_DIR + @filename.split(/\./)[0] + ".png")
- self.contents.blur
- draw_save_bitmap(0,0)
- else
- self.contents.draw_text(0, 64, 304-32, 24, "找不到截图文件!", 1)
- end
- draw_party_characters(108, 288-30)
- draw_playtime(0, 288+8-56, contents.width-4, 2)
- else
- self.contents.draw_text(0, 288-56, contents.width-4, 24, "无此存档!", 1)
- end
- end
- #--------------------------------------------------------------------------
- # ● 更改索引
- # index : 索引
- #--------------------------------------------------------------------------
- def file_index=(file_index)
- @file_index = file_index
- end
- #--------------------------------------------------------------------------
- # ● 描绘截图
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_party_characters(x, y)
- for i in [url=mailto:0...@characters.size]0...@characters.size[/url]
- name = @characters[i][0]
- index = @characters[i][1]
- draw_character(name, index, x + i * 48, y)
- end
- end
- #--------------------------------------------------------------------------
- # ● パーティキャラの描画
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_save_bitmap(x, y)
- bitmap = Bitmap.new(SAVE_DIR + @filename.split(/\./)[0] + ".png")
- rect = Rect.new(0, 0, 0, 0)
- rect.width = bitmap.width
- rect.height = bitmap.height
- self.contents.blt(x, y, bitmap, rect)
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # ● 描绘游戏时间
- # x : 描绘目标 X 坐标
- # y : 描绘目标 Y 坐标
- # width : 宽
- # align : 配置
- #--------------------------------------------------------------------------
- def draw_playtime(x, y, width, align)
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y, width, WLH, time_string, 2)
- end
- end
- #==============================================================================
- # ■ Window_Menu_Command
- #==============================================================================
- class Window_Menu_Command < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :commands # 命令
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # width : 窗口宽
- # commands : 命令字符串列表
- # column_max : 行数 (2 以上横向选择)
- # row_max : 列数 (0:与命令数一致)
- # spacing : 项目横向的空白空间
- #--------------------------------------------------------------------------
- def initialize(width, commands, column_max = 16, row_max = 0, spacing = 8)
- if row_max == 0
- row_max = (commands.size + column_max - 1) / column_max
- end
- super(0, 416-54, width, row_max * WLH + 32, spacing)
- @commands = commands
- @item_max = commands.size
- @column_max = column_max
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- # enabled : 有效标志。false 为半透明描绘。
- #--------------------------------------------------------------------------
- def draw_item(index, enabled = true)
- rect = item_rect(index)
- rect.width -= 8
- self.contents.clear_rect(rect)
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled ? 255 : 128
- draw_icon(MENU_ICON[index], rect.x, rect.y, index == self.index)
- end
- #--------------------------------------------------------------------------
- # ● 更新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- text = $data_system.game_title
- if @commands[self.index] != nil
- text += ": " + @commands[self.index]
- end
- @help_window.set_text(text)
- end
- end
- #==============================================================================
- # ■ Scene_Base
- #==============================================================================
- class Scene_Base
- #--------------------------------------------------------------------------
- # ● 生成菜单画面背景
- #--------------------------------------------------------------------------
- def create_menu_background
- @menuback_sprite = Sprite.new
- @menuback_sprite.bitmap = $game_temp.background_bitmap
- update_menu_background
- end
- #--------------------------------------------------------------------------
- # ● 生成子菜单画面背景
- #--------------------------------------------------------------------------
- def create_sub_menu_background
- @menuback_sprite = Sprite.new
- @menuback_sprite.bitmap = $game_temp.sub_menu_bitmap
- update_menu_background
- end
- #--------------------------------------------------------------------------
- # ● 生成存档位图快照
- #--------------------------------------------------------------------------
- def snapshot_for_save
- d_rect = Rect.new(0, 0, 272, 208)
- s_rect = Rect.new(0, 0, 640, 480)
- save_bitmap = Graphics.snap_to_bitmap
- $game_temp.save_bitmap.dispose
- $game_temp.save_bitmap = Bitmap.new(272, 208)
- $game_temp.save_bitmap.stretch_blt(d_rect, save_bitmap, s_rect)
- end
- end
- #==============================================================================
- # ■ Scene_Map
- #==============================================================================
- class Scene_Map < Scene_Base
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- snapshot_for_save # 截图存档
- if $scene.is_a?(Scene_Battle) # 正在切换战斗画面的情况下
- @spriteset.dispose_characters # 为了生成背景隐藏角色
- end
- snapshot_for_background # 背景图快照
- snapshot_for_menu # 菜单背景图快照
- @spriteset.dispose
- @message_window.dispose
- if $scene.is_a?(Scene_Battle) # 正在切换战斗画面的情况下
- perform_battle_transition # 执行战斗前变换
- end
- end
- #--------------------------------------------------------------------------
- # ● 菜单背景快照
- #--------------------------------------------------------------------------
- def snapshot_for_menu
- $game_temp.menu_bitmap.dispose
- $game_temp.menu_bitmap = Graphics.snap_to_bitmap
- end
- #--------------------------------------------------------------------------
- # ● 切换至菜单画面
- #--------------------------------------------------------------------------
- def call_menu
- if $game_temp.menu_beep
- Sound.play_decision
- $game_temp.menu_beep = false
- end
- $game_temp.next_scene = nil
- $scene = Scene_Menu.new(0, true)
- end
- end
- #==============================================================================
- # ■ Scene_Title
- #==============================================================================
- class Scene_Title < Scene_Base
- #--------------------------------------------------------------------------
- # ● 判断继续是否有效
- #--------------------------------------------------------------------------
- def check_continue
- @continue_enabled = (Dir.glob(SAVE_DIR + 'Save*.rvdata').size > 0)
- end
- end
- #==============================================================================
- # ■ Scene_Menu
- #==============================================================================
- class Scene_Menu < Scene_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # menu_index : 指令光标初期位置
- # show : 是否动态出现菜单
- #--------------------------------------------------------------------------
- def initialize(menu_index = 0, show = false)
- @menu_index = menu_index
- @status_index = 0
- [url=home.php?mod=space&uid=32215]@show[/url] = show
- end
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- create_command_window
- @gold_window = Window_Gold.new(384, 360)
- @gold_window.opacity = 0
- @gold_window.y = @show ? 416 : 360
- @status_window = Window_MenuTarget.new(64, 144)
- @status_window.visible = false
- @status_window.openness = 0
- @help_window = Window_Help.new
- @help_window.y = @show ? -56 : 0
- @command_window.help_window = @help_window
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @command_window.dispose
- @gold_window.dispose
- @status_window.dispose
- @help_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @command_window.update
- @gold_window.update
- @status_window.update
- @help_window.update
- loop do
- break if @help_window.y >= 0
- @help_window.y += 8
- @gold_window.y -= 8
- @command_window.y -= 8
- Graphics.update
- end
- @help_window.y = 0
- @command_window.y = 360
- if @command_window.active
- update_command_selection
- if @menu_index != @command_window.index
- @menu_index = @command_window.index
- @command_window.refresh
- end
- elsif @status_window.active
- update_actor_selection
- if @status_index != @status_window.index
- @status_index = @status_window.index
- @status_window.refresh
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 打开指令窗口
- #--------------------------------------------------------------------------
- def show_status_window
- @status_window.open
- begin
- @status_window.update
- Graphics.update
- end until @status_window.openness == 255
- end
- #--------------------------------------------------------------------------
- # ● 关闭指令窗口
- #--------------------------------------------------------------------------
- def hide_status_window
- @status_window.close
- begin
- @status_window.update
- Graphics.update
- end until @status_window.openness == 0
- end
- #--------------------------------------------------------------------------
- # ● 菜单背景快照
- #--------------------------------------------------------------------------
- def snapshot_for_sub_menu
- $game_temp.sub_menu_bitmap.dispose
- $game_temp.sub_menu_bitmap = Graphics.snap_to_bitmap
- end
- #--------------------------------------------------------------------------
- # ● 生成菜单画面背景
- #--------------------------------------------------------------------------
- def create_menu_background
- @menuback_sprite = Sprite.new
- @menuback_sprite.bitmap = $game_temp.menu_bitmap
- update_menu_background
- end
- #--------------------------------------------------------------------------
- # ● 生成指令窗口
- #--------------------------------------------------------------------------
- def create_command_window
- s1 = Vocab::item
- s2 = Vocab::skill
- s3 = Vocab::equip
- s4 = Vocab::status
- s5 = Vocab::save
- s6 = Vocab::game_end
- @command_window = Window_Menu_Command.new(640, [s1, s2, s3, s4, s5, s6])
- @command_window.y = @show ? 510 : 360
- @command_window.index = @menu_index
- @command_window.refresh
- if $game_party.members.size == 0 # 同伴人数为 0 的情况下
- @command_window.draw_item(0, false) # 物品无效化
- @command_window.draw_item(1, false) # 特技无效化
- @command_window.draw_item(2, false) # 装备无效化
- @command_window.draw_item(3, false) # 状态无效化
- end
- if $game_system.save_disabled # 禁止存档的情况下
- @command_window.draw_item(4, false) # 存档无效化
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新指令选择
- #--------------------------------------------------------------------------
- def update_command_selection
- if Input.trigger?(Input::B)
- loop do
- break if @help_window.y <= -56
- @help_window.y -= 8
- @gold_window.y += 8
- @command_window.y += 8
- Graphics.update
- end
- Sound.play_cancel
- $scene = Scene_Map.new
- elsif Input.trigger?(Input::C)
- if $game_party.members.size == 0 and @command_window.index < 4
- Sound.play_buzzer
- return
- elsif $game_system.save_disabled and @command_window.index == 4
- Sound.play_buzzer
- return
- end
- Sound.play_decision
- case @command_window.index
- when 0 # 物品
- @help_window.set_text("")
- snapshot_for_sub_menu
- $scene = Scene_Item.new
- when 1,2,3 # 特技、装备、状态
- @help_window.set_text("")
- snapshot_for_sub_menu
- start_actor_selection
- when 4 # 存档
- @help_window.set_text("")
- snapshot_for_sub_menu
- $scene = Scene_File.new(true, false, false)
- when 5 # 游戏结束
- @help_window.set_text("")
- snapshot_for_sub_menu
- $scene = Scene_End.new
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● アクター選択の開始
- #--------------------------------------------------------------------------
- def start_actor_selection
- @command_window.active = false
- @status_window.active = true
- @status_window.visible = true
- show_status_window
- if $game_party.last_actor_index < @status_window.item_max
- @status_window.index = $game_party.last_actor_index
- else
- @status_window.index = 0
- end
- end
- #--------------------------------------------------------------------------
- # ● アクター選択の終了
- #--------------------------------------------------------------------------
- def end_actor_selection
- @command_window.active = true
- @status_window.active = false
- hide_status_window
- @status_window.visible = false
- @status_window.index = -1
- end
- #--------------------------------------------------------------------------
- # ● アクター選択の更新
- #--------------------------------------------------------------------------
- def update_actor_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- end_actor_selection
- elsif Input.trigger?(Input::C)
- $game_party.last_actor_index = @status_window.index
- Sound.play_decision
- case @command_window.index
- when 1 # スキル
- $scene = Scene_Menu_Skill.new(@status_window.index)
- when 2 # 装備
- $scene = Scene_Equip.new(@status_window.index)
- when 3 # ステータス
- $scene = Scene_Status.new(@status_window.index)
- end
- end
- end
- end
- #==============================================================================
- # ■ Scene_Item
- #==============================================================================
- class Scene_Item < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_sub_menu_background
- @viewport = Viewport.new(0, 0, 640, 480)
- @help_window = Window_Help.new
- @help_window.opacity = 0
- @help_window.viewport = @viewport
- @item_window = Window_Item.new(64, 112, 510, 176)
- @item_window.viewport = @viewport
- @item_window.help_window = @help_window
- @item_window.openness = 0
- @item_window.active = false
- @target_window = Window_MenuTarget.new(64, 232)
- @actor_index = 0
- hide_target_window
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @help_window.update
- @item_window.update
- @target_window.update
- if @item_window.active
- update_item_selection
- elsif @target_window.active
- if @actor_index != @target_window.index
- @actor_index = @target_window.index
- @target_window.refresh
- end
- update_target_selection
- end
- end
- #--------------------------------------------------------------------------
- # ● 开始后处理
- #--------------------------------------------------------------------------
- def post_start
- super
- open_item_window
- end
- #--------------------------------------------------------------------------
- # ● 结束前处理
- #--------------------------------------------------------------------------
- def pre_terminate
- super
- close_item_window
- end
- #--------------------------------------------------------------------------
- # ● 打开指令窗口
- #--------------------------------------------------------------------------
- def open_item_window
- @item_window.open
- begin
- @item_window.update
- Graphics.update
- end until @item_window.openness == 255
- end
- #--------------------------------------------------------------------------
- # ● 关闭指令窗口
- #--------------------------------------------------------------------------
- def close_item_window
- @item_window.close
- begin
- @item_window.update
- Graphics.update
- end until @item_window.openness == 0
- end
- #--------------------------------------------------------------------------
- # ● 确定物品
- #--------------------------------------------------------------------------
- def determine_item
- if @item.for_friend?
- show_target_window
- if @item.for_all?
- @target_window.index = 99
- else
- if $game_party.last_target_index < @target_window.item_max
- @target_window.index = $game_party.last_target_index
- else
- @target_window.index = 0
- end
- end
- else
- use_item_nontarget
- end
- end
- #--------------------------------------------------------------------------
- # ● 显示目标窗口
- #--------------------------------------------------------------------------
- def show_target_window
- loop do
- @item_window.y -= 8
- Graphics.update
- break if @item_window.y <= 56
- end
- @item_window.active = false
- @target_window.visible = true
- @target_window.active = true
- end
- #--------------------------------------------------------------------------
- # ● 不显示目标窗口
- #--------------------------------------------------------------------------
- def hide_target_window
- @target_window.visible = false
- loop do
- @item_window.y += 8
- Graphics.update
- break if @item_window.y >= 112
- end
- @item_window.active = true
- @target_window.active = false
- @viewport.rect.set(0, 0, 640, 480)
- @viewport.ox = 0
- end
- end
- #==============================================================================
- # ■ Scene_Menu_Skill
- #==============================================================================
- class Scene_Menu_Skill < Scene_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # actor_index : 角色索引
- #--------------------------------------------------------------------------
- def initialize(actor_index = 0, equip_index = 0)
- @actor_index = actor_index
- end
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_sub_menu_background
- @actor = $game_party.members[@actor_index]
- @viewport = Viewport.new(0, 0, 640, 480)
- @help_window = Window_Help.new
- @help_window.opacity = 0
- @help_window.viewport = @viewport
- @skill_window = Window_Skill.new(64, 112, 510, 176, @actor)
- @skill_window.viewport = @viewport
- @skill_window.help_window = @help_window
- @skill_window.openness = 0
- @skill_window.open
- @target_window = Window_MenuTarget.new(64, 232)
- hide_target_window
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @help_window.dispose
- @skill_window.dispose
- @target_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 开始后处理
- #--------------------------------------------------------------------------
- def post_start
- super
- open_skill_window
- end
- #--------------------------------------------------------------------------
- # ● 结束前处理
- #--------------------------------------------------------------------------
- def pre_terminate
- super
- close_skill_window
- end
- #--------------------------------------------------------------------------
- # ● 打开指令窗口
- #--------------------------------------------------------------------------
- def open_skill_window
- @skill_window.open
- begin
- @skill_window.update
- Graphics.update
- end until @skill_window.openness == 255
- end
- #--------------------------------------------------------------------------
- # ● 关闭指令窗口
- #--------------------------------------------------------------------------
- def close_skill_window
- @skill_window.close
- begin
- @skill_window.update
- Graphics.update
- end until @skill_window.openness == 0
- end
- #--------------------------------------------------------------------------
- # ● 还原至原来的画面
- #--------------------------------------------------------------------------
- def return_scene
- $scene = Scene_Menu.new(1)
- end
- #--------------------------------------------------------------------------
- # ● 切换至下一名角色的画面
- #--------------------------------------------------------------------------
- def next_actor
- @actor_index += 1
- @actor_index %= $game_party.members.size
- $scene = Scene_Skill.new(@actor_index)
- end
- #--------------------------------------------------------------------------
- # ● 切换至上一名角色的画面
- #--------------------------------------------------------------------------
- def prev_actor
- @actor_index += $game_party.members.size - 1
- @actor_index %= $game_party.members.size
- $scene = Scene_Skill.new(@actor_index)
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @help_window.update
- @skill_window.update
- @target_window.update
- if @skill_window.active
- update_skill_selection
- elsif @target_window.active
- if @actor_index != @target_window.index
- @actor_index = @target_window.index
- @target_window.refresh
- end
- update_target_selection
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新选择特技
- #--------------------------------------------------------------------------
- def update_skill_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- elsif Input.trigger?(Input::R)
- Sound.play_cursor
- next_actor
- elsif Input.trigger?(Input::L)
- Sound.play_cursor
- prev_actor
- elsif Input.trigger?(Input::C)
- @skill = @skill_window.skill
- if @skill != nil
- @actor.last_skill_id = @skill.id
- end
- if @actor.skill_can_use?(@skill)
- Sound.play_decision
- determine_skill
- else
- Sound.play_buzzer
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 确定特技
- #--------------------------------------------------------------------------
- def determine_skill
- if @skill.for_friend?
- show_target_window
- if @skill.for_all?
- @target_window.index = 99
- elsif @skill.for_user?
- @target_window.index = @actor_index + 100
- else
- if $game_party.last_target_index < @target_window.item_max
- @target_window.index = $game_party.last_target_index
- else
- @target_window.index = 0
- end
- end
- else
- use_skill_nontarget
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新选择目标
- #--------------------------------------------------------------------------
- def update_target_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- hide_target_window
- elsif Input.trigger?(Input::C)
- if not @actor.skill_can_use?(@skill)
- Sound.play_buzzer
- else
- determine_target
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 确定目标
- # 无效的情况下 (在不能战斗的情况下使用恢复剂) 播放 buzzer 的 SE。
- #--------------------------------------------------------------------------
- def determine_target
- used = false
- if @skill.for_all?
- for target in $game_party.members
- target.skill_effect(@actor, @skill)
- used = true unless target.skipped
- end
- elsif @skill.for_user?
- target = $game_party.members[@target_window.index - 100]
- target.skill_effect(@actor, @skill)
- used = true unless target.skipped
- else
- $game_party.last_target_index = @target_window.index
- target = $game_party.members[@target_window.index]
- target.skill_effect(@actor, @skill)
- used = true unless target.skipped
- end
- if used
- use_skill_nontarget
- else
- Sound.play_buzzer
- end
- end
- #--------------------------------------------------------------------------
- # ● 显示目标窗口
- #--------------------------------------------------------------------------
- def show_target_window
- loop do
- @skill_window.y -= 8
- Graphics.update
- break if @skill_window.y <= 56
- end
- @skill_window.active = false
- @target_window.visible = true
- @target_window.active = true
- end
- #--------------------------------------------------------------------------
- # ● 不显示目标窗口
- #--------------------------------------------------------------------------
- def hide_target_window
- @target_window.visible = false
- loop do
- @skill_window.y += 8
- Graphics.update
- break if @skill_window.y >= 112
- end
- @skill_window.active = true
- @target_window.active = false
- @viewport.rect.set(0, 0, 640, 480)
- @viewport.ox = 0
- end
- #--------------------------------------------------------------------------
- # ● 使用特技 (也适用于我方对象以外的效果)
- #--------------------------------------------------------------------------
- def use_skill_nontarget
- Sound.play_use_skill
- @actor.mp -= @actor.calc_mp_cost(@skill)
- @skill_window.refresh
- @target_window.refresh
- if $game_party.all_dead?
- $scene = Scene_Gameover.new
- elsif @skill.common_event_id > 0
- $game_temp.common_event_id = @skill.common_event_id
- $scene = Scene_Map.new
- end
- end
- end
- #==============================================================================
- # ■ Scene_Equip
- #==============================================================================
- class Scene_Equip < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_sub_menu_background
- @actor = $game_party.members[@actor_index]
- @help_window = Window_Help.new
- @help_window.opacity = 0
- create_item_windows
- @equip_window = Window_Equip.new(64, 56, @actor)
- @equip_window.help_window = @help_window
- @equip_window.index = @equip_index
- @equip_window.openness = 0
- @status_window = Window_EquipStatus.new(64, 208, @actor)
- @status_window.openness = 0
- end
- #--------------------------------------------------------------------------
- # ● 生成物品窗口
- #--------------------------------------------------------------------------
- def create_item_windows
- @item_windows = []
- for i in 0...EQUIP_TYPE_MAX
- @item_windows[i] = Window_EquipItem.new(272, 208, 208, 152, @actor, i)
- @item_windows[i].help_window = @help_window
- @item_windows[i].visible = (@equip_index == i)
- @item_windows[i].y = 208
- @item_windows[i].height = 152
- @item_windows[i].active = false
- @item_windows[i].index = -1
- end
- @item_windows[@equip_index].openness = 0
- end
- #--------------------------------------------------------------------------
- # ● 开始后处理
- #--------------------------------------------------------------------------
- def post_start
- super
- open_equip_window
- end
- #--------------------------------------------------------------------------
- # ● 结束前处理
- #--------------------------------------------------------------------------
- def pre_terminate
- super
- close_equip_window
- end
- #--------------------------------------------------------------------------
- # ● 打开指令窗口
- #--------------------------------------------------------------------------
- def open_equip_window
- @item_windows[@equip_window.index].open
- @status_window.open
- @equip_window.open
- begin
- @item_windows[@equip_window.index].update
- @status_window.update
- @equip_window.update
- Graphics.update
- end until @equip_window.openness == 255
- end
- #--------------------------------------------------------------------------
- # ● 关闭指令窗口
- #--------------------------------------------------------------------------
- def close_equip_window
- @item_windows[@equip_window.index].close
- @status_window.close
- @equip_window.close
- begin
- @item_windows[@equip_window.index].update
- @status_window.update
- @equip_window.update
- Graphics.update
- end until @equip_window.openness == 0
- end
- end
- #==============================================================================
- # ■ Scene_Status
- #==============================================================================
- class Scene_Status < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_sub_menu_background
- @actor = $game_party.members[@actor_index]
- @status_window = Window_Status.new(@actor)
- @status_window.openness = 0
- end
- #--------------------------------------------------------------------------
- # ● 开始后处理
- #--------------------------------------------------------------------------
- def post_start
- super
- open_status_window
- end
- #--------------------------------------------------------------------------
- # ● 结束前处理
- #--------------------------------------------------------------------------
- def pre_terminate
- super
- close_status_window
- end
- #--------------------------------------------------------------------------
- # ● 打开指令窗口
- #--------------------------------------------------------------------------
- def open_status_window
- @status_window.open
- begin
- @status_window.update
- Graphics.update
- end until @status_window.openness == 255
- end
- #--------------------------------------------------------------------------
- # ● 关闭指令窗口
- #--------------------------------------------------------------------------
- def close_status_window
- @status_window.close
- begin
- @status_window.update
- Graphics.update
- end until @status_window.openness == 0
- end
- end
- #==============================================================================
- # ■ Scene_File
- #------------------------------------------------------------------------------
- # 处理文件的类。
- #==============================================================================
- class Scene_File < Scene_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # saving : 存档标志 (false 为载入画面)
- # from_title : 调用标题画面的 "继续" 标志
- # from_event : 事件的 "调用存档画面" 的调用标志
- #--------------------------------------------------------------------------
- def initialize(saving, from_title, from_event)
- @saving = saving
- @from_title = from_title
- @from_event = from_event
- end
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- @help_window = Window_Help.new
- unless $game_temp.sub_menu_bitmap.width == 1
- @help_window.opacity = 0
- create_sub_menu_background
- else
- create_title_graphic
- end
- create_command_window
- if @saving
- @index = $game_temp.last_file_index
- @help_window.set_text(Vocab::SaveMessage)
- else
- @index = self.latest_file_index
- @help_window.set_text(Vocab::LoadMessage)
- end
- @refresh_index = @command_window.index = @index
- @item_max = MAX_SAVE_ID
- create_savefile_window
- @savefile_window.openness = 0
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @help_window.dispose
- dispose_item_windows
- end
- #--------------------------------------------------------------------------
- # ● 还原至原先的画面
- #--------------------------------------------------------------------------
- def return_scene
- if @from_title
- $scene = Scene_Title.new
- elsif @from_event
- $scene = Scene_Map.new
- else
- $scene = Scene_Menu.new(4)
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @help_window.update
- update_savefile_windows
- update_savefile_selection
- end
- #--------------------------------------------------------------------------
- # ● 开始后处理
- #--------------------------------------------------------------------------
- def post_start
- super
- open_savefile_window
- end
- #--------------------------------------------------------------------------
- # ● 结束前处理
- #--------------------------------------------------------------------------
- def pre_terminate
- super
- close_savefile_window
- end
- #--------------------------------------------------------------------------
- # ● 生成标题画面背景
- #--------------------------------------------------------------------------
- def create_title_graphic
- @menuback_sprite = Sprite.new
- @menuback_sprite.bitmap = Cache.system("Title")
- end
- #--------------------------------------------------------------------------
- # ● 生成存档文件列表窗口
- #--------------------------------------------------------------------------
- def create_command_window
- file_names = []
- for i in 0...MAX_SAVE_ID
- id = sprintf("%02d", i+1)
- file_names.push(Vocab::File + "\s" + id)
- end
- @command_window = Window_Command.new(112, file_names)
- @command_window.height = 298
- @command_window.x = 64
- @command_window.y = 59
- @command_window.openness = 0
- end
- #--------------------------------------------------------------------------
- # ● 生成存档文件窗口
- #--------------------------------------------------------------------------
- def create_savefile_window
- @savefile_window = Window_SaveFile.new(@command_window.index, make_filename(@command_window.index))
- end
- #--------------------------------------------------------------------------
- # ● 释放存档文件
- #--------------------------------------------------------------------------
- def dispose_item_windows
- @command_window.dispose
- @savefile_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 打开指令窗口
- #--------------------------------------------------------------------------
- def open_savefile_window
- @command_window.open
- @savefile_window.open
- begin
- @command_window.update
- @savefile_window.update
- Graphics.update
- end until @savefile_window.openness == 255
- end
- #--------------------------------------------------------------------------
- # ● 关闭指令窗口
- #--------------------------------------------------------------------------
- def close_savefile_window
- @command_window.close
- @savefile_window.close
- begin
- @command_window.update
- @savefile_window.update
- Graphics.update
- end until @savefile_window.openness == 0
- end
- #--------------------------------------------------------------------------
- # ● 更新存档文件窗口
- #--------------------------------------------------------------------------
- def update_savefile_windows
- @command_window.update
- @savefile_window.update
- end
- #--------------------------------------------------------------------------
- # ● 更新存档文件选择
- #--------------------------------------------------------------------------
- def update_savefile_selection
- if Input.trigger?(Input::C)
- determine_savefile
- end
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- end
- if @refresh_index != @command_window.index
- @refresh_index = @command_window.index
- @savefile_window.dispose
- create_savefile_window
- end
- end
- #--------------------------------------------------------------------------
- # ● 确定存档文件
- #--------------------------------------------------------------------------
- def determine_savefile
- if @saving
- Sound.play_save
- do_save
- else
- if @savefile_window.file_exist
- Sound.play_load
- do_load
- else
- Sound.play_buzzer
- return
- end
- end
- $game_temp.last_file_index = @index
- end
- #--------------------------------------------------------------------------
- # ● 生成文件名
- # file_index : 存档文件索引 (0~3)
- #--------------------------------------------------------------------------
- def make_filename(file_index)
- return "Save#{file_index + 1}.rvdata"
- end
- #--------------------------------------------------------------------------
- # ● 按时间戳选择最新的文件
- #--------------------------------------------------------------------------
- def latest_file_index
- index = 0
- latest_time = Time.at(0) # 时间戳
- for i in 0...MAX_SAVE_ID
- file_name = make_filename(i)
- if FileTest.exist?(SAVE_DIR + file_name)
- file = File.open(SAVE_DIR + file_name, "r")
- if file.mtime > latest_time
- latest_time = file.mtime
- index = i
- end
- end
- end
- return index
- end
- #--------------------------------------------------------------------------
- # ● 执行存档
- #--------------------------------------------------------------------------
- def do_save
- file_name = make_filename(@command_window.index)
- $game_temp.save_bitmap.make_png(file_name.split(/\./)[0], SAVE_DIR)
- file = File.open(SAVE_DIR + file_name, "wb")
- write_save_data(file)
- file.close
- return_scene
- end
- #--------------------------------------------------------------------------
- # ● 执行载入
- #--------------------------------------------------------------------------
- def do_load
- file_name = make_filename(@command_window.index)
- file = File.open(SAVE_DIR + file_name, "rb")
- read_save_data(file)
- file.close
- $scene = Scene_Map.new
- RPG::BGM.fade(1500)
- Graphics.fadeout(60)
- Graphics.wait(40)
- @last_bgm.play
- @last_bgs.play
- end
- end
- #==============================================================================
- # 本脚本出自[url=http://www.66rpg.com]www.66rpg.com[/url],转载请注明。
- #==============================================================================
- # Bitmap to PNG By 轮回者
- #==============================================================================
- # 对Bitmap对象直接使用
- # bitmap_obj.make_png(name[, path])
- # name:保存文件名
- # path:保存路径
- # 感谢66、夏娜、金圭子的提醒和帮助!
- #==============================================================================
- module Zlib
- class Png_File < GzipWriter
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def make_png(bitmap_Fx)
- @bitmap_Fx = bitmap_Fx
- self.write(make_header)
- self.write(make_ihdr)
- self.write(make_idat)
- self.write(make_iend)
- end
- #--------------------------------------------------------------------------
- # ● PNG文件头数据块
- #--------------------------------------------------------------------------
- def make_header
- return [0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a].pack("C*")
- end
- #--------------------------------------------------------------------------
- # ● PNG文件情报头数据块(IHDR)
- #--------------------------------------------------------------------------
- def make_ihdr
- ih_size = [13].pack("N")
- ih_sign = "IHDR"
- ih_width = [@bitmap_Fx.width].pack("N")
- ih_height = [@bitmap_Fx.height].pack("N")
- ih_bit_depth = [8].pack("C")
- ih_color_type = [6].pack("C")
- ih_compression_method = [0].pack("C")
- ih_filter_method = [0].pack("C")
- ih_interlace_method = [0].pack("C")
- string = ih_sign + ih_width + ih_height + ih_bit_depth + ih_color_type +
- ih_compression_method + ih_filter_method + ih_interlace_method
- ih_crc = [Zlib.crc32(string)].pack("N")
- return ih_size + string + ih_crc
- end
- #--------------------------------------------------------------------------
- # ● 生成图像数据(IDAT)
- #--------------------------------------------------------------------------
- def make_idat
- header = "\x49\x44\x41\x54"
- data = make_bitmap_data
- data = Zlib::Deflate.deflate(data, 8)
- crc = [Zlib.crc32(header + data)].pack("N")
- size = [data.length].pack("N")
- return size + header + data + crc
- end
- #--------------------------------------------------------------------------
- # ● 从Bitmap对象中生成图像数据 mode
- #--------------------------------------------------------------------------
- def make_bitmap_data
- gz = Zlib::GzipWriter.open('hoge.gz')
- t_Fx = 0
- w = @bitmap_Fx.width
- h = @bitmap_Fx.height
- data = []
- for y in 0...h
- data.push(0)
- for x in 0...w
- t_Fx += 1
- if t_Fx % 10000 == 0
- Graphics.update
- end
- if t_Fx % 100000 == 0
- s = data.pack("C*")
- gz.write(s)
- data.clear
- end
- color = @bitmap_Fx.get_pixel(x, y)
- red = color.red
- green = color.green
- blue = color.blue
- alpha = color.alpha
- data.push(red)
- data.push(green)
- data.push(blue)
- data.push(alpha)
- end
- end
- s = data.pack("C*")
- gz.write(s)
- gz.close
- data.clear
- gz = Zlib::GzipReader.open('hoge.gz')
- data = gz.read
- gz.close
- File.delete('hoge.gz')
- return data
- end
- #--------------------------------------------------------------------------
- # ● PNG文件尾数据块(IEND)
- #--------------------------------------------------------------------------
- def make_iend
- ie_size = [0].pack("N")
- ie_sign = "IEND"
- ie_crc = [Zlib.crc32(ie_sign)].pack("N")
- return ie_size + ie_sign + ie_crc
- end
- end
- end
- #==============================================================================
- # ■ Bitmap
- #------------------------------------------------------------------------------
- # 关联到Bitmap。
- #==============================================================================
- class Bitmap
- #--------------------------------------------------------------------------
- # ● 关联
- #--------------------------------------------------------------------------
- def make_png(name="like", path="",mode=0)
- make_dir(path) if path != ""
- Zlib::Png_File.open("temp.gz") {|gz|
- gz.make_png(self)
- }
- Zlib::GzipReader.open("temp.gz") {|gz|
- $read = gz.read
- }
- f = File.open(path + name + ".png","wb")
- f.write($read)
- f.close
- File.delete('temp.gz')
- end
- #--------------------------------------------------------------------------
- # ● 生成保存路径
- #--------------------------------------------------------------------------
- def make_dir(path)
- dir = path.split("/")
- for i in 0...dir.size
- unless dir == "."
- add_dir = dir[0..i].join("/")
- begin
- Dir.mkdir(add_dir)
- rescue
- end
- end
- end
- end
- end
复制代码
因為不知道要調哪邊,所以就全貼上來了
|
|