def self.Fullscr(fulls = true) Graphics.fullscreen_mode if fulls && !Fullscr? Graphics.windowed_mode if !fulls && Fullscr? end
1.43 MB, 下载次数: 476
VA的游戏设置
藤原妹红丶 发表于 2017-8-13 17:27
楼主你好,我想问一下 这脚本是否可以将中间的框框删除 替换一张背景图呢? ...
#============================================================================== # ★☆ Game Setting #------------------------------------------------------------------------------ # 游戏设置菜单 图片背景版 # By Beka # MinoGS 2017 # # Free for non commercial and commercial use # Licence : [url]http://creativecommons.org/licenses/by-sa/3.0/[/url] #============================================================================== # # 在任意位置调用打开菜单请执行以下脚本: # SceneManager.call(Scene_Setting) # #============================================================================== GS_Set_Define = { "path" => "Graphics/Characters/!$Gate2",# 窗口背景地址(建议440*310) "butopacity" => 128 # 按钮窗口的透明度(0-255) } GS_Set_Def = { "music" => 10, "sound" => 10, "full" => false }# 默认缺省设置 #============================================================================== # ** GameSetting #------------------------------------------------------------------------------ # 游戏设置模块 #============================================================================== module Option # 用语 Setting = "设置" OK = "确定" Cancel = "取消" Reset = "重置" MusicVol = "音乐音量:" SoundVol = "音效音量:" Fullscreen = "全屏模式:" SwitchON = "ON" SwitchOFF = "OFF" # 功能函数 def self.Fullscr(fulls = true) if fulls && !Fullscr? # 窗口模式切全屏 keybd = Win32API.new 'user32.dll', 'keybd_event', ['i', 'i', 'l', 'l'], 'v' keybd.call 0xA4, 0, 0, 0 keybd.call 13, 0, 0, 0 keybd.call 13, 0, 2, 0 keybd.call 0xA4, 0, 2, 0 elsif !fulls && Fullscr? # 全屏模式切窗口 keybd = Win32API.new 'user32.dll', 'keybd_event', ['i', 'i', 'l', 'l'], 'v' keybd.call 0xA4, 0, 0, 0 keybd.call 13, 0, 0, 0 keybd.call 13, 0, 2, 0 keybd.call 0xA4, 0, 2, 0 end end def self.Fullscr? get_foreground_wnd = Win32API.new('user32', 'GetForegroundWindow', 'v', 'i') get_wnd_long = Win32API.new('user32', 'GetWindowLong', 'ii', 'l') if (get_wnd_long.call(get_foreground_wnd.call, -16) & 0x00c00000) == 0 return true else return false end end def self.load_setting if FileTest.exist?("System/Setting.gsd") $GS_Set = load_data("System/Setting.gsd") else $GS_Set = GS_Set_Def.clone end end end Option.load_setting Option.Fullscr($GS_Set["full"]) #============================================================================== # ** Scene_Setting #------------------------------------------------------------------------------ # 处理游戏系统的设置菜单 #============================================================================== class Scene_Setting < Scene_Base #-------------------------------------------------------------------------- # * Start Processing #-------------------------------------------------------------------------- def start super create_background setting_load $GS_Set["full"] = Option.Fullscr? create_window end #-------------------------------------------------------------------------- # * Termination Processing #-------------------------------------------------------------------------- def terminate super dispose_background end #-------------------------------------------------------------------------- # * Create Background #-------------------------------------------------------------------------- def create_background @background_sprite = Sprite.new @background_sprite.bitmap = SceneManager.background_bitmap @background_sprite.color.set(16, 16, 16, 128) end #-------------------------------------------------------------------------- # * Free Background #-------------------------------------------------------------------------- def dispose_background @cur.dispose @val.dispose @main_window.dispose @main_back.bitmap.dispose @main_back.dispose @button_window.dispose @background_sprite.dispose end #-------------------------------------------------------------------------- # * 创建窗口 #-------------------------------------------------------------------------- def create_window @main_window = Window_Base.new(0,0, 440, 260) @main_window.opacity = 0 @main_back = Sprite.new @main_back.z = @main_window.z - 1 @main_back.bitmap = Bitmap.new(GS_Set_Define["path"]) @button_window = Window_SetButton.new(0,0, 440, 50) @button_window.set_handler(:ok, method(:command_ok)) @button_window.set_handler(:cancel, method(:command_cancel)) @button_window.set_handler(:reset, method(:command_reset)) @button_window.opacity = GS_Set_Define["butopacity"] center_window # 光标所在的位置(0为按钮窗口,1-3为选项) @cur_index = 0 # 绘制 UI 文字 @main_window.contents.font.size = 28 @main_window.contents.font.color.set(255, 255, 128, 255) rect = Rect.new(0, 0, @main_window.contents.width, 50) @main_window.contents.draw_text(rect, Option::Setting, 1) @main_window.contents.font.size = Font.default_size draw_x = 40 @main_window.contents.draw_text(draw_x, 50,150,50, Option::MusicVol, 0) @main_window.contents.draw_text(draw_x,110,150,50, Option::SoundVol, 0) @main_window.contents.draw_text(draw_x,170,150,50, Option::Fullscreen,0) @main_window.contents.font.color.set(255, 255, 255, 255) draw_x = @main_window.contents.width - 128 @main_window.contents.draw_text(draw_x, 50,130,50,"[-] [+]",1) @main_window.contents.draw_text(draw_x,110,130,50,"[-] [+]",1) # 绘制指针与值 @cur = Sprite.new @cur.bitmap = Bitmap.new(40,50) @cur.x = @main_window.x + 12 @cur.z = @main_window.z + 1 @cur.bitmap.font.color.set(255, 255, 128, 255) @cur.bitmap.draw_text(0,0,40,50,">>",1) @val = Sprite.new @val.bitmap = Bitmap.new(130,200) @val.x = @cur.x + @main_window.contents.width - 128 @val.y = @main_window.y + 12 + 50 @val.z = @cur.z draw_val_cur(@cur_index) end #-------------------------------------------------------------------------- # * 居中窗口 #-------------------------------------------------------------------------- def center_window @main_window.x = (Graphics.width - @main_window.width) / 2 @button_window.x = @main_window.x @main_window.y = (Graphics.height - @main_window.height - @button_window.height) / 2 @button_window.y = @main_window.y + @main_window.height @main_back.x = (Graphics.width - @main_back.width) / 2 @main_back.y = (Graphics.height - @main_back.height) / 2 end #-------------------------------------------------------------------------- # * 重写父类的刷新,用于接管键盘输入 #-------------------------------------------------------------------------- def update last_index = @cur_index super @cur_index = (@cur_index - 1) % 4 if Input.repeat?(Input::UP) @cur_index = (@cur_index + 1) % 4 if Input.repeat?(Input::DOWN) if last_index != @cur_index @cur_index == 0 ? button_enable : button_disable last_index = @cur_index end case @cur_index when 1 # Volunm $GS_Set["music"] -= 1 if $GS_Set["music"] > 0 && Input.trigger?(Input::LEFT) $GS_Set["music"] += 1 if $GS_Set["music"] < 10 && Input.trigger?(Input::RIGHT) RPG::BGM.last.play if RPG::BGM.last!= nil when 2 #Sound FX if Input.trigger?(Input::LEFT) $GS_Set["sound"] -= 1 if $GS_Set["sound"] > 0 Sound.play_cursor end if Input.trigger?(Input::RIGHT) $GS_Set["sound"] += 1 if $GS_Set["sound"] < 10 Sound.play_cursor end when 3 # Full Screen switch_val("full") if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT) end draw_val_cur(@cur_index) command_cancel if Input.trigger?(Input::B) && @cur_index != 0 end #-------------------------------------------------------------------------- # * 绘制值与光标 #-------------------------------------------------------------------------- def draw_val_cur(cur_index) @val.bitmap.clear @val.bitmap.draw_text(0, 0,130,50,$GS_Set["music"].to_s,1) @val.bitmap.draw_text(0, 60,130,50,$GS_Set["sound"].to_s,1) status = $GS_Set["full"] ? Option::SwitchON : Option::SwitchOFF @val.bitmap.draw_text(0,120,130,50,status,1) @cur.opacity = cur_index == 0 ? 0 : 255 @cur.y = @main_window.y + 62 + 60 * (cur_index - 1) end #-------------------------------------------------------------------------- # * 启用与停用按钮窗口 #-------------------------------------------------------------------------- def button_enable @button_window.active = true @button_window.update_cursor end def button_disable @button_window.active = false @button_window.cursor_rect.empty end #-------------------------------------------------------------------------- # * 切换开关(布尔值) #-------------------------------------------------------------------------- def switch_val(val) $GS_Set[val] = !$GS_Set[val] end def get_text_size(str) text = Bitmap.new(1,1) rect = text.text_size(str) return [rect.width, rect.height] end #-------------------------------------------------------------------------- # * 菜单项功能定义 #-------------------------------------------------------------------------- def command_ok setting_save # 改变屏幕 $GS_Set["full"] ? Option.Fullscr : Option.Fullscr(false) Graphics.freeze return_scene end def command_cancel Graphics.freeze return_scene setting_load end def command_reset setting_reset draw_val_cur(0) button_enable end #-------------------------------------------------------------------------- # * 存储与载入设置数据文件 #-------------------------------------------------------------------------- def setting_save save_data($GS_Set,"System/Setting.gsd") end def setting_load if FileTest.exist?("System/Setting.gsd") $GS_Set = load_data("System/Setting.gsd") else setting_reset setting_save end end def setting_reset $GS_Set = GS_Set_Def.clone RPG::BGM.last.play if RPG::BGM.last!= nil end end #============================================================================== # ** Window_SettingButton #============================================================================== class Window_SetButton < Window_HorzCommand def initialize(x, y, w_width ,w_height) @w_width = w_width @w_height = w_height super(x, y) select(1) end #-------------------------------------------------------------------------- # * Get Window Width #-------------------------------------------------------------------------- def window_width return @w_width end def window_height return @w_height end #-------------------------------------------------------------------------- # * Get Digit Count #-------------------------------------------------------------------------- def col_max return 3 end #-------------------------------------------------------------------------- # * Create Command List #-------------------------------------------------------------------------- def make_command_list add_command(Option::OK, :ok) add_command(Option::Cancel, :cancel) add_command(Option::Reset, :reset) end end #============================================================================== # ** 重定义增加设置入口 #============================================================================== class Scene_Title < Scene_Base alias org_create_win create_command_window def create_command_window org_create_win @command_window.set_handler(:setting, method(:command_setting)) end def command_setting close_command_window SceneManager.call(Scene_Setting) end end class Window_TitleCommand < Window_Command def make_command_list add_command(Vocab::new_game, :new_game) add_command(Vocab::continue, :continue, continue_enabled) add_command(Option::Setting, :setting) add_command(Vocab::shutdown, :shutdown) end end class Scene_Menu < Scene_MenuBase alias org_create_win create_command_window def create_command_window org_create_win @command_window.set_handler(:setting, method(:command_setting)) end def command_setting SceneManager.call(Scene_Setting) end end class Window_MenuCommand < Window_Command def make_command_list add_main_commands add_formation_command add_original_commands add_save_command add_setting add_game_end_command end def add_setting add_command(Option::Setting, :setting) end end #============================================================================== # ** Game Setting #------------------------------------------------------------------------------ # 重定义类 #============================================================================== class RPG::BGM < RPG::AudioFile def play(pos = 0) if @name.empty? Audio.bgm_stop @@last = RPG::BGM.new else Audio.bgm_play('Audio/BGM/' + @name, @volume * $GS_Set["music"] / 10, @pitch, pos) @@last = self.clone end end end class RPG::BGS < RPG::AudioFile def play(pos = 0) if @name.empty? Audio.bgs_stop @@last = RPG::BGS.new else Audio.bgs_play('Audio/BGS/' + @name, @volume * $GS_Set["sound"] / 10, @pitch, pos) @@last = self.clone end end end class RPG::ME < RPG::AudioFile def play if @name.empty? Audio.me_stop else Audio.me_play('Audio/ME/' + @name, @volume * $GS_Set["sound"] / 10, @pitch) end end end class RPG::SE < RPG::AudioFile def play unless @name.empty? Audio.se_play('Audio/SE/' + @name, @volume * $GS_Set["sound"] / 10, @pitch) end end end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |