赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 809 |
最后登录 | 2012-2-28 |
在线时间 | 26 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 26 小时
- 注册时间
- 2011-6-12
- 帖子
- 17
|
本帖最后由 RPG问题多多者 于 2011-8-10 00:13 编辑
请问有大大能修改这个脚本让这个脚本不影响其它窗口吗?
※脚本过長我分成两段:- #出自50rpg---http://www.50rpg.com/---這行請勿刪除
- if $gmae_F12 ; $add_save_load.save $add_50rpg
- end ; $gmae_F12 = true
- class String ; def text_size ; self.split(//u).length ; end ; end
- class Bitmap ; def word_step1(x, y, width, height, str, align = 0) ; str_arr = str.split(//u) ; str_arr.
- size.times{|i|self.draw_text(x + i*self.font.size, y, width, height, str_arr[i], align)} ; end ; end
- #class Game_Map ; def initialize ; @map_id, @display_x, @display_y = 1, 0, 0 ; end ; end
- class Initialization < Window_Base
- def initialize ; super(200, 240-22-32, 240, 22+32) ; Graphics.transition
- self.contents = Bitmap.new(width - 32, height - 32) ; self.contents.clear ; self.back_opacity = 200
- 35.times{|i| ; self.contents.clear
- self.contents.draw_text(0, 0, 340-32, 22, "--- Now Loading " + "-"*(i/3), 0) ; update
- 3.times{Graphics.update}} ; 44.times{Graphics.update} ; Graphics.freeze ; self.dispose
- unless FileTest.exist?("Data/add_address_pass_word.rmxp50rpg") ; $add_pass_hash_50rpg = {}
- $add_pass_50rpg = open("Data/add_address_pass_word.rmxp50rpg", "w")
- Marshal.dump($add_pass_hash_50rpg, $add_pass_50rpg) ; $add_pass_50rpg.close
- end ; $add_pass_50rpg = Marshal.load(open("Data/add_address_pass_word.rmxp50rpg"))
- end
- end
- class Scene_Map
- def call_menu
- $game_temp.menu_calling = false
- if $game_temp.menu_beep
- $game_system.se_play($data_system.decision_se) ; $game_temp.menu_beep = false
- end ; $game_player.straighten ; $scene_menu = Scene_Menu.new
- end
- def call_save
- $game_player.straighten ; $scene_save = Scene_Save.new
- end
- end
- class Object ; def stop_g ; Graphics.freeze ; end ; end
- class Scene_Menu ; alias update_command_part1 update_command
- def initialize(menu_index = 0)
- @menu_index = menu_index ; @out = false ; @del = false ; main
- end
- def main
- s1 = $data_system.words.item
- s2 = $data_system.words.skill
- s3 = $data_system.words.equip
- s4 = "狀態"
- s5 = "存檔"
- s6 = "離開"
- @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
- @command_window.index = @menu_index
- @command_window.back_opacity = 255
- if $game_party.actors.size == 0
- @command_window.disable_item(0)
- @command_window.disable_item(1)
- @command_window.disable_item(2)
- @command_window.disable_item(3)
- end ; @command_window.disable_item(4) if $game_system.save_disabled
- @playtime_window = Window_PlayTime.new
- @playtime_window.back_opacity = 255
- @playtime_window.x = 0 ; @playtime_window.y = 224 ; @playtime_window.z = 999999
- @steps_window = Window_Steps.new
- @steps_window.back_opacity = 255 ; @steps_window.x = 0 ; @steps_window.y = 320 ; @steps_window.z = 999999
- @gold_window = Window_Gold.new
- @gold_window.back_opacity = 255 ; @gold_window.x = 0 ; @gold_window.y = 416 ; @gold_window.z = 999999
- @status_window = Window_MenuStatus.new
- @status_window.back_opacity = 255 ; @status_window.x = 160 ; @status_window.y = 0 ; @status_window.z = 999999
- Graphics.transition
- loop{Graphics.update ; Input.update ; update ; break if @out} ; del_win
- end
- def del_win ; unless @del ; @out = !@out
- @command_window.dispose ; @playtime_window.dispose ; @del = !@del
- @status_window.dispose ; @steps_window.dispose ; @gold_window.dispose ; end
- end
- def update ; @command_window.update ; @playtime_window.update
- @steps_window.update ; @gold_window.update ; @status_window.update
- if @command_window.active ; update_command ; return ; end
- if @status_window.active ; update_status ; return ; end
- end
- def update_command
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se) ; @out = !@out ; return
- end
- if Input.trigger?(Input::C)
- if $game_party.actors.size == 0 and @command_window.index < 4
- $game_system.se_play($data_system.buzzer_se) ; return
- end
- case @command_window.index
- when 0 ; stop_g ; del_win
- $game_system.se_play($data_system.decision_se) ; $scene_item = Scene_Item.new
- when 1
- $game_system.se_play($data_system.decision_se) ; @command_window.active = false
- @status_window.active = true ; @status_window.index = 0
- when 2
- $game_system.se_play($data_system.decision_se) ; @command_window.active = false
- @status_window.active = true ; @status_window.index = 0
- when 3
- $game_system.se_play($data_system.decision_se) ; @command_window.active = false
- @status_window.active = true ; @status_window.index = 0
- when 4 ; stop_g
- if $game_system.save_disabled
- $game_system.se_play($data_system.buzzer_se) ; return
- end
- $game_system.se_play($data_system.decision_se)
- del_win ; $scene_save = Scene_Save.new
- when 5 ; stop_g
- $game_system.se_play($data_system.decision_se) ; del_win ; $scene_end = Scene_End.new
- end ; return
- end
- end
- def update_status
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @command_window.active = true
- @status_window.active = false
- @status_window.index = -1
- return
- end
- if Input.trigger?(Input::C)
- case @command_window.index
- when 1 ; stop_g ; del_win
- if $game_party.actors[@status_window.index].restriction >= 2
- $game_system.se_play($data_system.buzzer_se) ; return
- end
- $game_system.se_play($data_system.decision_se)
- $scene_skill = Scene_Skill.new(@status_window.index)
- when 2 ; stop_g ; del_win
- $game_system.se_play($data_system.decision_se)
- $scene_Equip = Scene_Equip.new(@status_window.index)
- when 3 ; stop_g ; del_win
- $game_system.se_play($data_system.decision_se)
- $scene_status = Scene_Status.new(@status_window.index)
- end
- return
- end
- end
- end
- class Scene_Item ; def initialize ; @out = false ; main ; end
- def main ; @help_window = Window_Help.new ; @item_window = Window_Item.new
- @item_window.help_window = @help_window ; @target_window = Window_Target.new
- @help_window.back_opacity = 255
- @item_window.back_opacity = 255
- @target_window.back_opacity = 255
- @target_window.visible = false ; @target_window.active = false ; Graphics.transition
- loop{Graphics.update ; Input.update ; update ; break if @out}
- end
- def del_win ; @out = !@out
- @help_window.dispose ; @item_window.dispose ; @target_window.dispose
- end
- def update ; @help_window.update ; @item_window.update ; @target_window.update
- if @item_window.active ; update_item ; return ; end
- if @target_window.active ; update_target ; return ; end
- end
- def update_item
- if Input.trigger?(Input::B) ; del_win
- $game_system.se_play($data_system.cancel_se)
- $scene_menu = Scene_Menu.new(0) ; return
- end
- if Input.trigger?(Input::C)
- @item = @item_window.item
- unless @item.is_a?(RPG::Item)
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- unless $game_party.item_can_use?(@item.id)
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.decision_se)
- if @item.scope >= 3
- @item_window.active = false
- @target_window.x = (@item_window.index + 1) % 2 * 304
- @target_window.visible = true
- @target_window.active = true
- if @item.scope == 4 || @item.scope == 6
- @target_window.index = -1
- else
- @target_window.index = 0
- end
- else
- if @item.common_event_id > 0
- $game_temp.common_event_id = @item.common_event_id
- $game_system.se_play(@item.menu_se)
- if @item.consumable
- $game_party.lose_item(@item.id, 1)
- @item_window.draw_item(@item_window.index)
- end ; @out = !@out ; return
- end
- end
- return
- end
- end
- def update_target
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- unless $game_party.item_can_use?(@item.id)
- @item_window.refresh
- end
- @item_window.active = true
- @target_window.visible = false
- @target_window.active = false
- return
- end
- if Input.trigger?(Input::C)
- if $game_party.item_number(@item.id) == 0
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- if @target_window.index == -1
- used = false
- for i in $game_party.actors
- used |= i.item_effect(@item)
- end
- end
- if @target_window.index >= 0
- target = $game_party.actors[@target_window.index]
- used = target.item_effect(@item)
- end
- if used
- $game_system.se_play(@item.menu_se)
- if @item.consumable
- $game_party.lose_item(@item.id, 1)
- @item_window.draw_item(@item_window.index)
- end
- @target_window.refresh
- if $game_party.all_dead? ; del_win
- $scene = Scene_Gameover.new
- return
- end
- if @item.common_event_id > 0 ; del_win
- $game_temp.common_event_id = @item.common_event_id
- return
- end
- end
- unless used
- $game_system.se_play($data_system.buzzer_se)
- end
- return
- end
- end
- end
- class Scene_Skill
- def initialize(actor_index = 0, equip_index = 0)
- @actor_index = actor_index ; @out = false ; main
- end
- def main
- @actor = $game_party.actors[@actor_index]
- @help_window = Window_Help.new
- @status_window = Window_SkillStatus.new(@actor)
- @skill_window = Window_Skill.new(@actor)
- @skill_window.help_window = @help_window
- @target_window = Window_Target.new
- @help_window.back_opacity = 255
- @status_window.back_opacity = 255
- @skill_window.back_opacity = 255
- @target_window.back_opacity = 255
- @target_window.visible = false
- @target_window.active = false
- Graphics.transition
- loop{Graphics.update ; Input.update ; update ; break if @out}
- end
- def del_win ; @out = !@out ; stop_g
- @help_window.dispose ; @status_window.dispose
- @skill_window.dispose ; @target_window.dispose
- end
- def update
- @help_window.update ; @status_window.update
- @skill_window.update ; @target_window.update
- if @skill_window.active
- update_skill
- return
- end
- if @target_window.active
- update_target
- return
- end
- end
- def update_skill
- if Input.trigger?(Input::B) ; del_win
- $game_system.se_play($data_system.cancel_se)
- $scene_menu = Scene_Menu.new(1)
- return
- end
- if Input.trigger?(Input::C)
- @skill = @skill_window.skill
- if @skill == nil or not @actor.skill_can_use?(@skill.id)
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $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
- if @skill.common_event_id > 0 ; del_win
- $game_temp.common_event_id = @skill.common_event_id
- $game_system.se_play(@skill.menu_se) ; @actor.sp -= @skill.sp_cost
- @status_window.refresh ; @skill_window.refresh ; @target_window.refresh
- return
- end
- end
- return
- end
- if Input.trigger?(Input::R) ; del_win
- $game_system.se_play($data_system.cursor_se)
- @actor_index = @actor_index+1 == $game_party.actors.size ? 0 : @actor_index+1
- $scene_skill = Scene_Skill.new(@actor_index)
- return
- end
- if Input.trigger?(Input::L) ; del_win
- $game_system.se_play($data_system.cursor_se)
- @actor_index = @actor_index-1 < 0 ? $game_party.actors.size-1 : @actor_index-1
- $scene_skill = Scene_Skill.new(@actor_index)
- return
- end
- end
- def update_target
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @skill_window.active = true
- @target_window.visible = false
- @target_window.active = false
- return
- end
- if Input.trigger?(Input::C)
- unless @actor.skill_can_use?(@skill.id)
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- if @target_window.index == -1
- used = false
- for i in $game_party.actors
- used |= i.skill_effect(@actor, @skill)
- end
- end
- if @target_window.index <= -2
- target = $game_party.actors[@target_window.index + 10]
- used = target.skill_effect(@actor, @skill)
- end
- if @target_window.index >= 0
- target = $game_party.actors[@target_window.index]
- used = target.skill_effect(@actor, @skill)
- end
- if used
- $game_system.se_play(@skill.menu_se)
- @actor.sp -= @skill.sp_cost
- @status_window.refresh
- @skill_window.refresh
- @target_window.refresh
- if $game_party.all_dead?
- $scene = Scene_Gameover.new
- return
- end
- if @skill.common_event_id > 0
- $game_temp.common_event_id = @skill.common_event_id
- $scene = Scene_Map.new
- return
- end
- end
- unless used
- $game_system.se_play($data_system.buzzer_se)
- end
- return
- end
- end
- end
- class Scene_Equip
- def initialize(actor_index = 0, equip_index = 0)
- @actor_index = actor_index ; @equip_index = equip_index ; @out = false ; main
- end
- def main
- @actor = $game_party.actors[@actor_index]
- @help_window = Window_Help.new
- @left_window = Window_EquipLeft.new(@actor)
- @right_window = Window_EquipRight.new(@actor)
- @item_window1 = Window_EquipItem.new(@actor, 0)
- @item_window2 = Window_EquipItem.new(@actor, 1)
- @item_window3 = Window_EquipItem.new(@actor, 2)
- @item_window4 = Window_EquipItem.new(@actor, 3)
- @item_window5 = Window_EquipItem.new(@actor, 4)
- @help_window.back_opacity = 255
- @left_window.back_opacity = 255
- @right_window.back_opacity = 255
- @item_window1.back_opacity = 255
- @item_window2.back_opacity = 255
- @item_window3.back_opacity = 255
- @item_window4.back_opacity = 255
- @item_window5.back_opacity = 255
- @right_window.help_window = @help_window
- @item_window1.help_window = @help_window
- @item_window2.help_window = @help_window
- @item_window3.help_window = @help_window
- @item_window4.help_window = @help_window
- @item_window5.help_window = @help_window
- @right_window.index = @equip_index ; refresh
- Graphics.transition
- loop{Graphics.update ; Input.update ; update ; break if @out}
- end
- def del_win ; stop_g ; @out = !@out ; @help_window.dispose ; @left_window.dispose
- @right_window.dispose ; @item_window1.dispose ; @item_window2.dispose
- @item_window3.dispose ; @item_window4.dispose ; @item_window5.dispose
- end
- def refresh
- @item_window1.visible = (@right_window.index == 0)
- @item_window2.visible = (@right_window.index == 1)
- @item_window3.visible = (@right_window.index == 2)
- @item_window4.visible = (@right_window.index == 3)
- @item_window5.visible = (@right_window.index == 4)
- item1 = @right_window.item
- case @right_window.index
- when 0
- @item_window = @item_window1
- when 1
- @item_window = @item_window2
- when 2
- @item_window = @item_window3
- when 3
- @item_window = @item_window4
- when 4
- @item_window = @item_window5
- end
- if @right_window.active
- @left_window.set_new_parameters(nil, nil, nil)
- end
- if @item_window.active
- item2 = @item_window.item
- last_hp = @actor.hp
- last_sp = @actor.sp
- @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
- new_atk = @actor.atk
- new_pdef = @actor.pdef
- new_mdef = @actor.mdef
- @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
- @actor.hp = last_hp
- @actor.sp = last_sp
- @left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
- end
- end
- def update ; @left_window.update ; @right_window.update ; @item_window.update ; refresh
- if @right_window.active ; update_right ; return ; end
- if @item_window.active ; update_item ; return ; end
- end
- def update_right
- if Input.trigger?(Input::B) ; del_win
- $game_system.se_play($data_system.cancel_se)
- $scene_menu = Scene_Menu.new(2)
- return
- end
- if Input.trigger?(Input::C)
- if @actor.equip_fix?(@right_window.index)
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.decision_se)
- @right_window.active = false
- @item_window.active = true
- @item_window.index = 0
- return
- end
- if Input.trigger?(Input::R) ; del_win
- $game_system.se_play($data_system.cursor_se)
- @actor_index = @actor_index+1 == $game_party.actors.size ? 0 : @actor_index+1
- $scene_Equip = Scene_Equip.new(@actor_index, @right_window.index)
- return
- end
- if Input.trigger?(Input::L) ; del_win
- $game_system.se_play($data_system.cursor_se)
- @actor_index = @actor_index-1 < 0 ? $game_party.actors.size-1 : @actor_index-1
- $scene_Equip = Scene_Equip.new(@actor_index, @right_window.index)
- return
- end
- end
- def update_item
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @right_window.active = true
- @item_window.active = false
- @item_window.index = -1
- return
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.equip_se)
- item = @item_window.item
- @actor.equip(@right_window.index, item == nil ? 0 : item.id)
- @right_window.active = true
- @item_window.active = false
- @item_window.index = -1
- @right_window.refresh
- @item_window.refresh
- return
- end
- end
- end
- class Scene_Status
- def initialize(actor_index = 0, equip_index = 0)
- @actor_index = actor_index ; @out = false ; main
- end
- def main
- @actor = $game_party.actors[@actor_index]
- @status_window = Window_Status.new(@actor)
- @status_window.back_opacity = 0
- Graphics.transition
- loop{Graphics.update ; Input.update ; update ; break if @out}
- end
- def del_win ; stop_g ; @out = !@out ; @status_window.dispose ; end
- def update
- if Input.trigger?(Input::B) ; del_win
- $game_system.se_play($data_system.cancel_se)
- $scene_menu = Scene_Menu.new(3)
- return
- end
- if Input.trigger?(Input::R) ; del_win
- $game_system.se_play($data_system.cursor_se)
- @actor_index = @actor_index+1 == $game_party.actors.size ? 0 : @actor_index+1
- $scene_status = Scene_Status.new(@actor_index)
- return
- end
- if Input.trigger?(Input::L) ; del_win
- $game_system.se_play($data_system.cursor_se)
- @actor_index = @actor_index-1 < 0 ? $game_party.actors.size-1 : @actor_index-1
- $scene_status = Scene_Status.new(@actor_index)
- return
- end
- end
- end
- class Scene_End ; def initialize ; @out = false ; main ; end
- def main ; s1, s2, s3 = "重新登入(關閉)", "結 束 遊 戲", "回 到 遊 戲"
- @command_window = Window_Command.new(192, [s1, s2, s3])
- @command_window.x = 320 - @command_window.width / 2
- @command_window.y = 240 - @command_window.height / 2
- @command_window.back_opacity = 255 ; Graphics.transition
- loop{Graphics.update ; Input.update ; update ; break if @out}
- if $scene.is_a?(Scene_Title) ; del_win ; Graphics.transition ; Graphics.freeze ; end
- end
- def del_win ; stop_g ; @out = !@out ; @command_window.dispose ; end
- def update ; @command_window.update
- if Input.trigger?(Input::B) ; del_win
- $game_system.se_play($data_system.cancel_se) ; $scene_menu = Scene_Menu.new(5) ; return
- end
- if Input.trigger?(Input::C)
- case @command_window.index
- when 0 ; command_to_title
- when 1 ; command_shutdown
- when 2 ; command_cancel
- end ; return
- end
- end
- def command_to_title ; $game_system.se_play($data_system.decision_se)
- Audio.bgm_fade(800) ; Audio.bgs_fade(800) ; Audio.me_fade(800)
- del_win ; @out = !@out ; $scene = Scene_Title.new
- end
- def command_shutdown ; $game_system.se_play($data_system.decision_se)
- Audio.bgm_fade(800) ; Audio.bgs_fade(800) ; Audio.me_fade(800) ; exit
- end
- def command_cancel ; $game_system.se_play($data_system.decision_se)
- $scene_menu = Scene_Menu.new(5)
- end
- end
- class Window_SaveFile < Window_Base
- attr_reader :filename # 檔案名稱
- attr_reader :selected # 選擇狀態
- attr_accessor :index_selected
- def initialize(filename) ; super(0, 64, 640, 104*4)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.back_opacity = 255 ; @filename = name = filename
- @time_stamp = Time.at(0) ; @file_exist = FileTest.exist?(@filename)
- @gogo_num = 0 ; @gogo = 0 ; @index_selected = 0
- unless @file_exist ; print "! 您的資料遭到刪除 !", "3" ; print "! 您的資料遭到刪除 !", "2"
- print "! 您的資料遭到刪除 !", "1" ; exit ; end
- file = File.open(@filename, "r")
- @time_stamp = file.mtime
- @characters = Marshal.load(file)
- @frame_count = Marshal.load(file)
- @game_system = Marshal.load(file)
- @game_switches = Marshal.load(file)
- @game_variables = Marshal.load(file)
- $total_sec = @frame_count / Graphics.frame_rate
- file.close ; refresh ; @selected = false
- end
- def update ; refresh
复制代码- @index_selected = @index_selected - 1 < 0 ? 1 : 0 if Input.repeat?(Input::LEFT)
- @index_selected = @index_selected + 1 > 1 ? 0 : 1 if Input.repeat?(Input::RIGHT)
- update_cursor_rect
- if @gogo_num == 5
- @gogo = @gogo + 1 > 3 ? 0 : @gogo + 1 ; @gogo_num = 0 ; else ; @gogo_num += 1
- end ; super
- end
- def refresh
- self.contents.clear ; self.contents.font.color = normal_color
- if @file_exist
- for i in [email protected]
- bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
- cw = bitmap.rect.width / 4
- ch = bitmap.rect.height / 4
- src_rect = Rect.new(@gogo*32, 0, cw, ch)
- x2 = ch + 10 + 640/5*i ; x3 = 640/4*i-i*3
- #x = 640/10 + ch/2 + 640/5*i#(640/8 + 640/5*i)#300 - @characters.size * 32 + i * 64 - cw / 2
- x = 640/10 + 640/5*i + ch/2
- self.contents.blt(x3, 68 - ch, bitmap, src_rect)
- @actor = $game_party.actors[i]
- xx = (@actor.name.text_size-2)*22 ; draw_actor_name(@actor, x3, 0)#(@actor, x-xx, 0)
- xx = @actor.class_name.text_size*22 ; draw_actor_class(@actor, x3+22*2, 22)
- draw_actor_level(@actor, x3+22*2, 22*2)
- draw_actor_state(@actor, x3, 64)#(@actor, 640/4*i, 64)
- draw_actor_hp(@actor, x3, 22*4, 170)
- draw_actor_sp(@actor, x3, 22*5, 170)
- draw_actor_parameter(@actor, x3, 22*7, 0)
- draw_actor_parameter(@actor, x3, 22*8, 1)
- draw_actor_parameter(@actor, x3, 22*9, 2)
- draw_actor_parameter(@actor, x3, 22*10, 3)
- draw_actor_parameter(@actor, x3, 22*11, 4)
- draw_actor_parameter(@actor, x3, 22*12, 5)
- draw_actor_parameter(@actor, x3, 22*13, 6)
- end
- self.contents.font.color = normal_color
- time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
- self.contents.draw_text(4, 480-32*4, 600, 32, time_string, 2)
- self.contents.draw_text(4, 480-32*4, 600, 32, "存檔", 0)
- self.contents.draw_text(4+22*4, 480-32*4, 600, 32, "刪除", 0)
- end
- end
- def draw_actor_level(actor, x, y)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 32, 32, "Lv")
- self.contents.font.color = normal_color
- self.contents.draw_text(x + 20, y, 24, 32, actor.level.to_s, 2)
- end
- def draw_actor_hp(actor, x, y, width = 144)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
- hp_x = x + 32
- flag = true
- self.contents.font.color = actor.hp == 0 ? knockout_color :
- actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
- self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 0)
- if flag
- self.contents.font.color = normal_color
- self.contents.draw_text(hp_x + 38, y, 12, 32, "/", 0)
- self.contents.draw_text(hp_x + 50, y, 48, 32, actor.maxhp.to_s)
- end
- end
- def draw_actor_sp(actor, x, y, width = 144)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
- sp_x = x + 32
- flag = true
- self.contents.font.color = actor.sp == 0 ? knockout_color :
- actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
- self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 0)
- if flag
- self.contents.font.color = normal_color
- self.contents.draw_text(sp_x + 38, y, 12, 32, "/", 0)
- self.contents.draw_text(sp_x + 50, y, 48, 32, actor.maxsp.to_s)
- end
- end
- def draw_actor_parameter(actor, x, y, type)
- case type
- when 0
- parameter_name = $data_system.words.atk
- parameter_value = actor.atk
- when 1
- parameter_name = $data_system.words.pdef
- parameter_value = actor.pdef
- when 2
- parameter_name = $data_system.words.mdef
- parameter_value = actor.mdef
- when 3
- parameter_name = $data_system.words.str
- parameter_value = actor.str
- when 4
- parameter_name = $data_system.words.dex
- parameter_value = actor.dex
- when 5
- parameter_name = $data_system.words.agi
- parameter_value = actor.agi
- when 6
- parameter_name = $data_system.words.int
- parameter_value = actor.int
- end
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 120, 32, parameter_name)
- self.contents.font.color = normal_color
- self.contents.draw_text(x + 90, y, 36, 32, parameter_value.to_s, 2)
- end
- def selected=(selected)
- @selected = selected
- update_cursor_rect
- end
- def update_cursor_rect
- if @selected
- self.cursor_rect.set(@index_selected*22*4, 480-32*4, 22*2+8, 32)
- else
- self.cursor_rect.empty
- end
- end
- end
- class Scene_File
- def initialize(help_text)
- @help_text = help_text ; @out = false ; @del = false ; main
- end
- def main ; @savefile_windows = Window_SaveFile.new "#{$add_50rpg}.rxdata"
- @help_window = Window_Help.new
- hour = $total_sec / 60 / 60 ; min = $total_sec / 60 % 60 ; sec = $total_sec % 60
- time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
- @help_window.set_text("手動存檔" + " "*5 + @help_text + " "*5 + time_string)
- @help_window.back_opacity = 255
- @file_index = $game_temp.last_file_index
- @savefile_windows.selected = true ; Graphics.transition
- loop{Graphics.update ; Input.update ; update ; break if @out} ; del_win
- end
- def del_win ; unless @del ; @out = !@out
- @help_window.dispose ; @savefile_windows.dispose ; @del = !@del ; end
- end
- def update
- @help_window.update
- @savefile_windows.update
- if Input.trigger?(Input::C)
- if @savefile_windows.index_selected == 1 ; $add_pass_50rpg.delete($add_50rpg)
- $add_pass_hash_50rpg = open("Data/add_address_pass_word.rmxp50rpg", "w")
- Marshal.dump($add_pass_50rpg, $add_pass_hash_50rpg) ; $add_pass_hash_50rpg.close
- $files1 = $add_50rpg + ".rxdata"
- $dels = true
- File.delete($files1)
- while FileTest.exist?($files1)
- Graphics.update
- end
- Thread.new {system('Game')} ; exit
- else
- del_win
- on_decision($add_50rpg)
- $game_temp.last_file_index = @file_index
- return
- end
- end
- if Input.trigger?(Input::B)
- del_win ; on_cancel
- return
- end
- end
- end
- class Scene_Save < Scene_File
- def initialize
- super("帳 號 : #$add_50rpg")
- end
- def on_decision(filename)
- $game_system.se_play($data_system.save_se)
- file = File.open(filename + ".rxdata", "wb")
- write_save_data(file)
- file.close
- if $game_temp.save_calling
- $game_temp.save_calling = false
- return
- end
- $scene_menu = Scene_Menu.new(4)
- end
- def on_cancel
- $game_system.se_play($data_system.cancel_se)
- if $game_temp.save_calling
- $game_temp.save_calling = false
- return
- end
- $scene_menu = Scene_Menu.new(4)
- end
- def write_save_data(file)
- characters = []
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- characters.push([actor.character_name, actor.character_hue])
- end
- Marshal.dump(characters, file)
- Marshal.dump(Graphics.frame_count, file)
- $game_system.save_count += 1
- $game_system.magic_number = $data_system.magic_number
- Marshal.dump($game_system, file)
- Marshal.dump($game_switches, file)
- Marshal.dump($game_variables, file)
- Marshal.dump($game_self_switches, file)
- Marshal.dump($game_screen, file)
- Marshal.dump($game_actors, file)
- Marshal.dump($game_party, file)
- Marshal.dump($game_troop, file)
- Marshal.dump($game_map, file)
- Marshal.dump($game_player, file)
- end
- end
- class Scene_Load < Scene_File
- def initialize
- $game_temp = Game_Temp.new
- $game_temp.last_file_index = 0
- latest_time = Time.at(0)
- for i in 0..3
- filename = make_filename(i)
- if FileTest.exist?(filename)
- file = File.open(filename, "r")
- if file.mtime > latest_time
- latest_time = file.mtime
- $game_temp.last_file_index = i
- end
- file.close
- end
- end
- super("帳 號 : #{$add_50rpg}")
- end
- def on_decision(filename)
- unless FileTest.exist?(filename)
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.load_se)
- file = File.open(filename + ".rxdata", "rb")
- read_save_data(file)
- file.close
- # 還原 BGM、BGS
- $game_system.bgm_play($game_system.playing_bgm)
- $game_system.bgs_play($game_system.playing_bgs)
- $game_map.update
- end
- def on_cancel
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Title.new
- end
- def read_save_data(file)
- characters = Marshal.load(file)
- Graphics.frame_count = Marshal.load(file)
- $game_system = Marshal.load(file)
- $game_switches = Marshal.load(file)
- $game_variables = Marshal.load(file)
- $game_self_switches = Marshal.load(file)
- $game_screen = Marshal.load(file)
- $game_actors = Marshal.load(file)
- $game_party = Marshal.load(file)
- $game_troop = Marshal.load(file)
- $game_map = Marshal.load(file)
- $game_player = Marshal.load(file)
- if $game_system.magic_number != $data_system.magic_number
- $game_map.setup($game_map.map_id)
- $game_player.center($game_player.x, $game_player.y)
- end
- $game_party.refresh
- end
- end
- class Window_Password < Window_Base ; def initialize ; initializes ; @input = Input_English.new
- super(100, 480/3, 640-200, 480/3) ; self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.clear ; self.back_opacity = 0 ; self.opacity = 0; @address = "" ; @address_x = 0 ; @pass_word = ""
- @pass_word_x = 0 ; @text_glitters = Sprite.new ; @text_glitters.bitmap = Bitmap.new(22*2 +
- 2, 24) ; @text_glitters.z = 1000 ; @text_glitters.x = -3 ; @text_glitters.y = -24
- @item = 1 ; @item_glitters = true ; @item_glitters_num = 0 ; @items = 1 ; @pass_words = 0
- self.contents.draw_text(0, 32*3, 340-32, 22, " ", 1) ; @system_message = ""
- $add_save_load = Add_save_load.new ; @system_messages = "帳號密碼限英文、數字 Delete清除全部"
- end ; def initializes ; @initialize = Initialization.new ; end
- def update ; if TrueInput.trigger?(0x2E) ; del_text ; end
- if Input.repeat?(Input::DOWN) ; @item = @item + 1 > 5 ? 1 : @item + 1 ; end
- if Input.repeat?(Input::UP) ; @item = @item-1 < 1 ? 5 : @item-1 ; end
- self.contents.clear ; self.opacity = 0 ; self.back_opacity = 0 ; super
- self.contents.font.color = Color.new(255, 0, 0) ; if @system_message == ""
- self.contents.draw_text(0, 32*3-20, 440-32, 22, "輸入完畢請操作上下鍵到登入並按下【Enter】", 1)
- else ; self.contents.draw_text(0, 32*3-22, 440-32, 22, "#@system_message", 1)
- end ; self.contents.draw_text(0, 32*3+4, 440-32, 22, "#@system_messages", 1)
- self.contents.font.color = Color.new(255, 255, 255) ; @pass_words = @pass_word.size
- self.contents.word_step1(0, 0, 440, 22, "帳號:#@address")
- self.contents.word_step1(0, 32, 440, 22, "密碼:" + "*"*@pass_words)
- self.contents.draw_text(0, 32+22, 440-32, 22, "登入 清除 離開", 1) ; case @item
- when 1 ; item_update ; @address_x = @address.text_size*self.contents.font.size
- if @items != 1 ; @item_glitters_num = 0 ; @items = 1 ; @text_glitters.bitmap.clear
- end ; if @address.size < 16 ; @address += @input.update
- else ; @system_message = "帳號過長(1~16) 重新輸入請按Delete" ; end
- @text_glitters.x = 100 + 22*3 + 10 + @address_x ; @text_glitters.y = 480/3 + 32/2
- when 2 ; item_update ; @pass_word_x = @pass_word.text_size*self.contents.font.size
- @text_glitters.x = 100 + 22*3 + 10 + @pass_word_x ; @text_glitters.y = 480/3 + 32/2 + 32
- if @items != 2 ; @item_glitters_num = 0 ; @items = 2 ; @text_glitters.bitmap.clear
- end ; if @pass_word.size < 16 ; @pass_word += @input.update
- else ; @system_message = "密碼過長(1~16) 重新輸入請按Delete" ; end
- @text_glitters.x = 100 + 22*3 + 10 + @pass_word_x ; @text_glitters.y = 480/3 + 32/2 + 32
- when 3 ; if @address == "" and @pass_word == "" ; @system_message = "請輸入帳號密碼"
- elsif @address == "" ; @system_message = "請輸入帳號"
- elsif @pass_word == "" ; @system_message = "請輸入密碼"
- else ; @system_message = "輸入完畢請操作上下鍵到登入並按下【Enter】"
- if Kboard.keyb($R_Key_RETURN) == 1
- $add_save_load.save_add(@address, @pass_word)
- @system_messages = "密碼錯誤"
- end
- end ; item_update true
- @text_glitters.x = 210 ; @text_glitters.y = 480/3 + 32/2 + 32*2+11 ; @items = 3
- when 4 ; @text_glitters.x = 210 + 22*4 ; @text_glitters.y = 480/3 + 32/2 + 32*2+11
- item_update true ; @system_message = "重新輸入帳號密碼" ; @items = 4
- del_text if Kboard.keyb($R_Key_RETURN) == 1
- @system_messages = "【Delete】清除全部"
- when 5 ; exit if Kboard.keyb($R_Key_RETURN) == 1 ; item_update true
- @text_glitters.x = 210 + 22*8 ; @text_glitters.y = 480/3 + 32/2 + 32*2+11
- @system_message = "結束遊戲" ; @items = 5
- end
- end
- def item_update(i = false) ; @system_message = ""
- if i ; @text_glitters.bitmap.clear
- @text_glitters.bitmap.fill_rect(0, 0, 22*2 + 2, 1, Color.new(255, 255, 255))
- else
- if @item_glitters_num == 10 ; @item_glitters = !@item_glitters ; @item_glitters_num = 0
- else ; @item_glitters_num += 1 ; end
- if @item_glitters ; @text_glitters.bitmap.fill_rect(0, 0, 3, 24, Color.new(100, 100, 100))
- else ; @text_glitters.bitmap.clear ; end
- end
- end ; def del_text ; @address, @pass_word = "", "" ; end
- def del_w ; self.contents.clear ; self.dispose ; @text_glitters.dispose ; end
- end
- class Add_save_load
- def save_add(add, pass)
- $add_50rpg = add
- if $add_pass_50rpg[add] ; $game_temp = Game_Temp.new
- if $add_pass_50rpg[add] == pass ; load(add) ; $scene = Scene_Map.new ; end
- else ; $add_pass_50rpg[add] = pass
- $add_pass_hash_50rpg = open("Data/add_address_pass_word.rmxp50rpg", "w")
- Marshal.dump($add_pass_50rpg, $add_pass_hash_50rpg) ; $add_pass_hash_50rpg.close
- $add_pass_50rpg = Marshal.load(open("Data/add_address_pass_word.rmxp50rpg"))
- $game_system = Game_System.new ; $game_troop = Game_Troop.new
- $game_switches = Game_Switches.new ; $game_temp = Game_Temp.new
- $game_variables = Game_Variables.new ; $game_party = Game_Party.new
- $game_self_switches = Game_SelfSwitches.new ; $game_map = Game_Map.new
- $game_actors = Game_Actors.new ; $game_player = Game_Player.new
- $game_screen = Game_Screen.new ; $add_pass_50rpg[add] = pass ; save(add)
- $game_party.setup_starting_members ; $game_map.setup($data_system.start_map_id)
- $game_player.moveto($data_system.start_x, $data_system.start_y)
- $game_player.refresh ; $game_map.autoplay ; $game_map.update
- save(add) ; $scene = Scene_Map.new
- end
- end
- def save(add) ; file = File.open(add + ".rxdata", "wb") ; characters = []
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i] ; characters.push([actor.character_name, actor.character_hue])
- end ; Marshal.dump(characters, file) ; Marshal.dump(Graphics.frame_count, file)
- $game_system.save_count += 1 ; $game_system.magic_number = $data_system.magic_number
- Marshal.dump($game_system, file) ; Marshal.dump($game_switches, file)
- Marshal.dump($game_variables, file) ; Marshal.dump($game_self_switches, file)
- Marshal.dump($game_screen, file) ; Marshal.dump($game_actors, file)
- Marshal.dump($game_party, file) ; Marshal.dump($game_troop, file)
- Marshal.dump($game_map, file) ; Marshal.dump($game_player, file) ; file.close
- end
- def load(add)
- unless FileTest.exist?(add+".rxdata") ; print "! 您的帳號已刪除 ! 4"
- print "! 您的帳號已刪除 ! 3" ; print "! 您的帳號已刪除 ! 2"
- print "! 您的帳號已刪除 ! 1" ; print "帳號初始化..." ; $game_screen = Game_Screen.new
- $game_system = Game_System.new ; $game_troop = Game_Troop.new
- $game_switches = Game_Switches.new ; $game_temp = Game_Temp.new
- $game_variables = Game_Variables.new ; $game_party = Game_Party.new
- $game_self_switches = Game_SelfSwitches.new ; $game_map = Game_Map.new
- $game_actors = Game_Actors.new ; $game_player = Game_Player.new
- $game_party.setup_starting_members ; $game_map.setup($data_system.start_map_id)
- $game_player.moveto($data_system.start_x, $data_system.start_y)
- $game_player.refresh ; $game_map.autoplay ; $game_map.update ; save(add)
- end ; file = File.open(add+".rxdata", "rb")
- characters = Marshal.load(file) ; Graphics.frame_count = Marshal.load(file)
- $game_system = Marshal.load(file) ; $game_switches = Marshal.load(file)
- $game_variables = Marshal.load(file) ; $game_self_switches = Marshal.load(file)
- $game_screen = Marshal.load(file) ; $game_actors = Marshal.load(file)
- $game_party = Marshal.load(file) ; $game_troop = Marshal.load(file)
- $game_map = Marshal.load(file) ; $game_player = Marshal.load(file)
- if $game_system.magic_number != $data_system.magic_number
- $game_map.setup($game_map.map_id)
- $game_player.center($game_player.x, $game_player.y)
- end ; $game_party.refresh
- end
- end
- class Scene_Title ; alias main_part1 main ; alias update_part1 update
- def main ; if $BTEST ; battle_test ; return ; end
- $data_actors = load_data("Data/Actors.rxdata")
- $data_classes = load_data("Data/Classes.rxdata")
- $data_skills = load_data("Data/Skills.rxdata")
- $data_items = load_data("Data/Items.rxdata")
- $data_weapons = load_data("Data/Weapons.rxdata")
- $data_armors = load_data("Data/Armors.rxdata")
- $data_enemies = load_data("Data/Enemies.rxdata")
- $data_troops = load_data("Data/Troops.rxdata")
- $data_states = load_data("Data/States.rxdata")
- $data_animations = load_data("Data/Animations.rxdata")
- $data_tilesets = load_data("Data/Tilesets.rxdata")
- $data_common_events = load_data("Data/CommonEvents.rxdata")
- $data_system = load_data("Data/System.rxdata")
- $game_system = Game_System.new ; @pass_windows = Window_Password.new
- @sprite = Sprite.new ; @sprite.bitmap = RPG::Cache.title($data_system.title_name)
- $game_system.bgm_play($data_system.title_bgm) ; Audio.me_stop ; Audio.bgs_stop
- Graphics.transition ; loop{Graphics.update ; Input.update ; update ; if $scene != self
- @pass_windows.del_w ; break ; end} ; Graphics.freeze ; @sprite.dispose ; end
- def update ; @pass_windows.update
- if Kboard.keyb($R_Key_RETURN) ; end ; end ; end ; module Kboard
- $Rmouse_BUTTON_L = 0x01 # left mouse button
- $Rmouse_BUTTON_R = 0x02 # right mouse button
- $Rmouse_BUTTON_M = 0x04 # middle mouse button
- $Rmouse_BUTTON_4 = 0x05 # 4th mouse button
- $Rmouse_BUTTON_5 = 0x06 # 5th mouse button
- $R_Key_BACK = 0x08 # BACKSPACE key
- $R_Key_TAB = 0x09 # TAB key
- $R_Key_RETURN = 0x0D # ENTER key
- $R_Key_SHIFT = 0x10 # SHIFT key
- $R_Key_CTLR = 0x11 # CTLR key
- $R_Key_ALT = 0x12 # ALT key
- $R_Key_PAUSE = 0x13 # PAUSE key
- $R_Key_CAPITAL = 0x14 # CAPS LOCK key
- $R_Key_ESCAPE = 0x1B # ESC key
- $R_Key_SPACE = 0x20 # SPACEBAR
- $R_Key_PRIOR = 0x21 # PAGE UP key
- $R_Key_NEXT = 0x22 # PAGE DOWN key
- $R_Key_END = 0x23 # END key
- $R_Key_HOME = 0x24 # HOME key
- $R_Key_LEFT = 0x25 # LEFT ARROW key
- $R_Key_UP = 0x26 # UP ARROW key
- $R_Key_RIGHT = 0x27 # RIGHT ARROW key
- $R_Key_DOWN = 0x28 # DOWN ARROW key
- $R_Key_SELECT = 0x29 # SELECT key
- $R_Key_PRINT = 0x2A # PRINT key
- $R_Key_SNAPSHOT = 0x2C # PRINT SCREEN key
- $R_Key_INSERT = 0x2D # INS key
- $R_Key_DELETE = 0x2E # DEL key
- $R_Key_0 = 0x30 # 0 key
- $R_Key_1 = 0x31 # 1 key
- $R_Key_2 = 0x32 # 2 key
- $R_Key_3 = 0x33 # 3 key
- $R_Key_4 = 0x34 # 4 key
- $R_Key_5 = 0x35 # 5 key
- $R_Key_6 = 0x36 # 6 key
- $R_Key_7 = 0x37 # 7 key
- $R_Key_8 = 0x38 # 8 key
- $R_Key_9 = 0x39 # 9 key
- $R_Key_A = 0x41 # A key
- $R_Key_B = 0x42 # B key
- $R_Key_C = 0x43 # C key
- $R_Key_D = 0x44 # D key
- $R_Key_E = 0x45 # E key
- $R_Key_F = 0x46 # F key
- $R_Key_G = 0x47 # G key
- $R_Key_H = 0x48 # H key
- $R_Key_I = 0x49 # I key
- $R_Key_J = 0x4A # J key
- $R_Key_K = 0x4B # K key
- $R_Key_L = 0x4C # L key
- $R_Key_M = 0x4D # M key
- $R_Key_N = 0x4E # N key
- $R_Key_O = 0x4F # O key
- $R_Key_P = 0x50 # P key
- $R_Key_Q = 0x51 # Q key
- $R_Key_R = 0x52 # R key
- $R_Key_S = 0x53 # S key
- $R_Key_T = 0x54 # T key
- $R_Key_U = 0x55 # U key
- $R_Key_V = 0x56 # V key
- $R_Key_W = 0x57 # W key
- $R_Key_X = 0x58 # X key
- $R_Key_Y = 0x59 # Y key
- $R_Key_Z = 0x5A # Z key
- $R_Key_LWIN = 0x5B # Left Windows key (Microsoft Natural keyboard)
- $R_Key_RWIN = 0x5C # Right Windows key (Natural keyboard)
- $R_Key_APPS = 0x5D # Applications key (Natural keyboard)
- $R_Key_NUMPAD0 = 0x60 # Numeric keypad 0 key
- $R_Key_NUMPAD1 = 0x61 # Numeric keypad 1 key
- $R_Key_NUMPAD2 = 0x62 # Numeric keypad 2 key
- $R_Key_NUMPAD3 = 0x63 # Numeric keypad 3 key
- $R_Key_NUMPAD4 = 0x64 # Numeric keypad 4 key
- $R_Key_NUMPAD5 = 0x65 # Numeric keypad 5 key
- $R_Key_NUMPAD6 = 0x66 # Numeric keypad 6 key
- $R_Key_NUMPAD7 = 0x67 # Numeric keypad 7 key
- $R_Key_NUMPAD8 = 0x68 # Numeric keypad 8 key
- $R_Key_NUMPAD9 = 0x69 # Numeric keypad 9 key
- $R_Key_MULTIPLY = 0x6A # Multiply key (*)
- $R_Key_ADD = 0x6B # Add key ( + )
- $R_Key_SEPARATOR = 0x6C # Separator key
- $R_Key_SUBTRACT = 0x6D # Subtract key (-)
- $R_Key_DECIMAL = 0x6E # Decimal key
- $R_Key_DIVIDE = 0x6F # Divide key (/)
- $R_Key_F1 = 0x70 # F1 key
- $R_Key_F2 = 0x71 # F2 key
- $R_Key_F3 = 0x72 # F3 key
- $R_Key_F4 = 0x73 # F4 key
- $R_Key_F5 = 0x74 # F5 key
- $R_Key_F6 = 0x75 # F6 key
- $R_Key_F7 = 0x76 # F7 key
- $R_Key_F8 = 0x77 # F8 key
- $R_Key_F9 = 0x78 # F9 key
- $R_Key_F10 = 0x79 # F10 key
- $R_Key_F11 = 0x7A # F11 key
- $R_Key_F12 = 0x7B # F12 key
- $R_Key_NUMLOCK = 0x90 # NUM LOCK key
- $R_Key_SCROLL = 0x91 # SCROLL LOCK key
- $R_Key_LSHIFT = 0xA0 # Left SHIFT key
- $R_Key_RSHIFT = 0xA1 # Right SHIFT key
- $R_Key_LCONTROL = 0xA2 # Left CONTROL key
- $R_Key_RCONTROL = 0xA3 # Right CONTROL key
- $R_Key_L_ALT = 0xA4 # Left ALT key
- $R_Key_R_ALT = 0xA5 # Right ALT key
- $R_Key_SEP = 0xBC # , key
- $R_Key_DASH = 0xBD # - key
- $R_Key_DOTT = 0xBE # . Key
- GetKeyState = Win32API.new("user32","GetAsyncKeyState",['I'],'I')
- GetKeyboardState = Win32API.new("user32","GetKeyState",['I'],'I')
- GetSetKeyState = Win32API.new("user32","SetKeyboardState",['I'],'I')
- module_function
- def keyb(rkey) ; if GetKeyState.call(rkey) != 0 ; return 1 ; end ; return 0 ; end# ; alias repeat? keyb
- def 按著(rkey) ; GetKeyState.call(rkey) & 0x01 == 1 ; end# ; alias press? 按著
- def key(rkey, key = 0) ; GetKeyboardState.call(rkey) & 0x01 == key ; end# ; alias trigger? key
- end
- class Input_English
- def initialize
- #@GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
- @GetAsyncKeyState = Win32API.new("user32","GetAsyncKeyState",['I'],'I')
- @GetKeyState = Win32API.new("user32","GetKeyState",['I'],'I')
- @SetKeyboardState = Win32API.new("user32","SetKeyboardState",['I'],'I')
- @input = [$R_Key_0 = 0x30,$R_Key_1 = 0x31,$R_Key_2 = 0x32,$R_Key_3 = 0x33,#0~9,A~Z
- $R_Key_4 = 0x34,$R_Key_5 = 0x35,$R_Key_6 = 0x36,$R_Key_7 = 0x37,$R_Key_8 = 0x38,
- $R_Key_9 = 0x39,$R_Key_A = 0x41,$R_Key_B = 0x42,$R_Key_C = 0x43,$R_Key_D = 0x44,
- $R_Key_E = 0x45,$R_Key_F = 0x46,$R_Key_G = 0x47,$R_Key_H = 0x48, $R_Key_I = 0x49,
- $R_Key_J = 0x4A,$R_Key_K = 0x4B,$R_Key_L = 0x4C,$R_Key_M = 0x4D,$R_Key_N = 0x4E,
- $R_Key_O = 0x4F,$R_Key_P = 0x50,$R_Key_Q = 0x51,$R_Key_R = 0x52,$R_Key_S = 0x53,
- $R_Key_T = 0x54,$R_Key_U = 0x55,$R_Key_V = 0x56,$R_Key_W = 0x57,$R_Key_X = 0x58,
- $R_Key_Y = 0x59,$R_Key_Z = 0x5A] ; @inputs = "0123456789abcdefghijklmnopqrstuvwxyz"
- end ; def update ; @keys = 0 ; for key in @input
- if TrueInput.trigger?(key) ; TrueInput.update ; return @inputs.split(//u)[@keys] ; end ; @keys += 1
- end ; TrueInput.update ; return "" ; end ; end
- module TrueInput
- VK_HOME=0x24;VK_LEFT=0x25;VK_UP=0x26;VK_RIGHT=0x27 ; VK_DOWN=0x28
- @GetKeyState=Win32API.new("user32","GetKeyState",'i','i')
- @keys_list=[];@keys_state={};@keys_trigger={};@keys_trigger_r={}
- @keys_repeat={};@dir4input=[0];@dir8input=[];@dir4=0;@dir8=0
- def self.update
- for key in@keys_list
- [email protected](key);@keys_state[key][email protected](key)
- if @keys_state[key]==nil
- @keys_trigger_r[key]=false;@keys_trigger[key]=true;@keys_repeat[key]=false;next
- end;@keys_trigger_r[key]=false
- if @keys_state[key][7]==1;@keys_repeat[key]=(not@keys_repeat[key])
- unless@keys_trigger[key];@keys_trigger[key]=true;@keys_trigger_r[key]=true;end
- else;@keys_repeat[key]=false;@keys_trigger[key]=false;end
- end;self.dir4input(VK_DOWN,2);self.dir4input(VK_LEFT,4)
- self.dir4input(VK_RIGHT,6);self.dir4input(VK_UP,8)
- @[email protected];@dir4=@dir4input[-1];@[email protected]
- case @dir8;when 2,8;@dir8+=dir8load(4,6,-1,+1)#VK_DOWN,VK_UP
- when 4,6;@dir8+=dir8load(8,2,+3,-3)#VK_LEFT,VK_RIGHT
- end
- end
- def self.press?(key)
- unless@keys_list.include?(key);@keys_list.push(key);@keys_state[key]=0;end
- return (@keys_state[key][7]==1)
- end
- def self.trigger?(key)
- unless@keys_list.include?(key)
- @keys_list.push(key);@keys_trigger[key]=false;@keys_trigger_r[key]=false
- end;return @keys_trigger_r[key]
- end
- def self.repeat?(key)
- @keys_list.push(key);@keys_repeat[key]=falseunless@keys_list.include?(key)
- return @keys_repeat[key]
- end
- def self.toggled?(key)
- unless@keys_list.include?(key);@keys_list.push(key);@keys_state[key]=0;end
- if @keys_state[key]==nil;return false;else;return (@keys_state[key][0]==1);end
- end
- def self.dir4;return @dir4;end;def self.dir8;return @dir8;end
- def self.dir4input(key,dir_int)
- if self.press?(key);@dir4input.push(dir_int)[email protected]?(dir_int)
- elsif @dir4input.include?(dir_int);@dir4input.delete(dir_int);end
- end;def self.dir8load(dir_a,dir_b,val_a,val_b)
- [email protected];if last==0;return 0;elsif last==dir_a;return val_a
- elsif last==dir_b;return val_b;else;return self.dir8load(dir_a,dir_b,val_a,val_b);end;end;end
- #TrueInput.update 更新按鍵狀態,每一FRAME調用一次 (同Input模組)
- #TrueInput.press?(key)判定key所代表的鍵是否被按下 (同Input模組)
- #TrueInput.trigger?(key)判定key所代表的鍵是否重新按下 (同Input模組)
- #TrueInput.repeat?(key) 判定key所代表的鍵是否重新按下(自動) (同Input模組)
- #TrueInput.toggled?(key)判定Caps Lock、Num Lock、Scroll Lock是否被打開用。
- begin ; Font.default_name = (["華康中圓體", "微軟正黑體","新細明體", "細明體",
- "新?明体", "標楷体", "宋体", "黑体", "??", "MS P????", "MS PGothic",
- "Tahoma", "Arial", "Arial Unicode MS"]) ; Graphics.freeze
- $scene = Scene_Title.new ; while $scene != nil ; $scene.main ; end ; Graphics.transition(20)
- rescue Errno::ENOENT
- filename = $!.message.sub("No such file or directory - ", "")
- print("沒有發現檔案 #{filename}。 ")
- rescue SystemExit
- $add_save_load.save $add_50rpg if $add_50rpg
- File.delete($files1) if $dels
- if $add_50rpg
- Graphics.update while FileTest.exist?($add_50rpg + ".rxdata") if $dels
- end
- end ; exit
- #出自50rpg---http://www.50rpg.com/---這行請勿刪除
复制代码![]()
|
|