wltr3565 Senior
Posts : 870 Thanked : 28 Engine : RMVX Skill : Skilled Type : Scripter
Trophies
Awards:
| Subyek: Music Room ala ZUN v1.0 2010-05-17, 12:58 | |
| Music Room ala ZUN Versi: 1.0 Tipe: Custom Scene PengenalanIni untuk projectku (atau jangan ya?). Dari semua script music room yang kutemukan, gak ada yang kusuka. Mereka gak bisa ngekomentar. Komentar kan penting untuk komposer kamu, atau untuk nambah deskripsi pada musiknya... Fitur- Gak perlu ngenamain ulang file musiknya! - Pembukaan musik secara otomatis! - Berdasarkan music roomnya ZUN: ' Dimana biasanya dia beri komentar, ' Dimana biasanya dia biarin player untuk ngemainin musik yang belum kebuka, ' Dimana biasanya dia beri nama musiknya beda dengan filenamenya, ' Dimana kadang dia gak ngelist beberapa lagu... - Instalasi command pada title secara otomatis (Terima kasih pada KGC) - Ngekomentar kayak kamu nulis di event! - Ngecheck antara savefile yang ada! ScreenshotsSungguh simpel... Demohttp://www.mediafire.com/?0tvzmm1wu3d Scripts- Spoiler:
- Code:
-
=begin ================================================================================ Music Room ~ ZUN's Style v1.0 by wltr3565 ================================================================================ This is mainly for my project (or shouldn't I?). Among all music room scripts that I found, none of them sastify me. They lack commentary. Comments are very important for your composers, you know, or to add more description for the music... ================================================================================ Features: - No need to rename the music files! - Auto music unlock! - Based on ZUN's music room: ' That he usually add comments, ' That he usually lets the players to play locked musics, ' That he usually gives the music name different from the actual file's name, ' That he sometimes doesn't list some songs... - Auto command install on title! (Thanks to KGC) - Commentary format is like normal message in the events! - Checks between existing savefiles! ================================================================================ How it will work: This script tracks the musics that was listed and played, for later to be replayed in the Music Room Scene. The script detects the unlocked musics between existing savefiles. You can play the unlocked ones, but to play the locked ones, you can't just select it once, but twice for your own safety (spoilers possible!). ================================================================================ How to Use: There's some event commands for controlling the music locks. What's between [] is optional:
- $game_system.music_flag[id] = control That one will control the flag of the musics' lock. id is the music's id, from the set order. control is the control between true or false. true will unlock the music, regardless, and false will lock the music, regardless.
- $game_system.music_unlocked?(id) Checks if the music is alread unlocked. id is the music's id, from the set order. Use it for conditional branches.
- $game_system.music_unlock_all This command will make all of the musics available to be unlocked.
- $scene = Scene_Music.new[(file, call)] This command will call the music room. File represents the saveslot for obtaining the information from the assigned slot. call represents the target Scene for coming back. The default is title. If you assign the call "Map", will bring you back to the map. If you insert the file nil, will check all existing saveslots. More functions can be seen in the configurations below. ================================================================================ Install: Insert below title-related scripts and above main. ================================================================================ Terms of Use: Credit me, wltr3565. Free to use in commercial games as long I'm being credited. Crediting who I thanked will be a good idea. ================================================================================ Thanks: ZUN: His games and musics :P, and main inspiration. KGC: Method for adding command in the menu. ================================================================================ =end #=============================================================================== # COMMENCING COMPATIBILITY FLAG #=============================================================================== $imported = {} if $imported == nil $imported["wltr3565's_Music_Room"] = true #=============================================================================== # END COMPATIBILITY FLAG #=============================================================================== module WLTR module MUSIC_ROOM_SETUP MUSICS = [ # Don't touch #=============================================================================== # List of musics available at the music room. Write their filename in a string, # and be sure to add "," without the quotation for each musics, like this: # Town1, # Battle2, #=============================================================================== "Town5", # Music 1, "Field1", # Music 2, "Battle1", # Music 3 and so forth. "st31", "th06_15", #=============================================================================== ] # Don't touch MUSICS_NAME = [# Don't touch #=============================================================================== # Each musics' name to be shown at the music room. Write it in a string. It will # be used at each assigned musics in the same order, like this: # filename name # "Town1", "Melancholy", # "Battle2", "Battling", # At the music room, the Town1 music will have it's name shown as Melancholy, # and Battle2 as Battling. #=============================================================================== "Town5", # Music 1, "Field1", # Music 2 and so forth. "Battle1", "Beloved Tomboyish Girl", "U.N. Owen Was Her?!", #=============================================================================== ] # Don't touch MUSICS_COMMENT = [] # << EXTREMELY DO NOT TOUCH! #=============================================================================== # In here you can make comments for the musics listed. The format for writing # them is almost the same as the normal message in text events. To make one, # do this: # MUSICS_COMMENT[id] = comment # The id represents the music's order from 0 that listed above. comment is the # comment. Be sure to close the text with "". You can use | for making new lines # other than using enter. Example: # # MUSICS_COMMENT[0] = "What we usually hear while testing our game... # You guys must be bored." # The Town1 music (from the example list of above) will show it's comments like # this: # What we usually hear while testing our game... # You guys must be bored. # # Doesn't make one will make the comment empty. #=============================================================================== MUSICS_COMMENT[0] = "VX RTP's music. Commonly used for title screen. Enterbrain just prefer this music for new projects' title theme. But really, why don't they name it \"Title\" or something more fit other than \"Town5\"?"
MUSICS_COMMENT[1] = "VX RTP's music. I do like this one personally, too bad, I'm not even sure what's the best situation for using this piece... No need to answer this, really."
MUSICS_COMMENT[2] = "VX RTP's music. The default battle theme.
Enterbrain do made 4 battle themes for us to use, but they selected this for the default. Because of the default battle system?"
MUSICS_COMMENT[3] = "~ Beloved Tomboyish Girl ~ Composed by ZUN, Cirno's theme from TH12.3.
This piece was not made purely by ZUN himself, it's rearranged by Tasofro's composer. I love this theme! The theme's so stupid, but cool at a time. One of the best Tasofro's Touhou music remix, I guess." MUSICS_COMMENT[4] = "~ U.N. Owen Was Her?! ~ Composed by ZUN, Flandre Scarlet's theme from TH06.
One of ZUN's most loli-tastic musics. The theme's very chaotic aswell. Really Touhou-like. This one's the MIDI version. I prefer the MIDI version compared to the WAV version because the MIDI version more fit for RPG games..." #===============================================================================
#=============================================================================== # Comment for a locked music, to warn the players that the music is not yet # unlocked in the game. The format for writing it is the same. #=============================================================================== EMPTY_COMMENT = "*** The selected music has not yet been played in the game. ***
The comments may contain spoiler, as well as the music itself. Select the music again to play the music, or select another music." #===============================================================================
#=============================================================================== # Letter used to mark that the music is not yet unlocked. Write it in a string. # Example: Melancholy will show ?????????? if it's not yet unlocked and the # UNKNOWN_WORD is "?". #=============================================================================== UNKNOWN_WORD = "?" #=============================================================================== # The music room texts' font size. The higher the number, the bigger the # the letters. Write it in a number. Suggested that the font size is not 20, but # 16. #=============================================================================== FONT_SIZE = 16 #=============================================================================== # Custom background for the music room. Leave it "" if you don't want to use # one. The background image must be located in Graphics/System folder. # To note tha if you want to use a background, the big window that shows the # music room's name at the top-left of the screen will vanish. #=============================================================================== BACKGROUND = "" #=============================================================================== # The music room's name shown in the commands. Write it in a string. #=============================================================================== MUSIC_ROOM_NAME = "Music Room" #=============================================================================== # This will check if you want to let the music unlocked while played in the # music room, while the music itself is not yet unlocked. # true : Let it unlocked. # false : Don't unlock it. #=============================================================================== SPOIL_UNLOCK = false #=============================================================================== # This will check if you can play a locked music after you select it twice. # true : Play it. # false : Don't play it. #=============================================================================== LOCK_PLAYABLE = true #=============================================================================== # Checks if you want the command to be useable for title screen. # true : Add it. # false : Don't add it. #=============================================================================== ADD_TO_MENU = true #=============================================================================== # The switch for limiting the accessibility of the music room at the title # screen. Set the id. If the assigned switch is on, the command will show. # If it's off, will not show. Useless if ADD_TO_MENU is false. Set below to nil # if you want the music room accessable at anytime. #=============================================================================== TITLE_SWITCH = 1 end end
"==============================================================================" " BELOW IS TOO DANGEROUS TO READ WITHOUT PROPER SCRIPTING SKILLS. THEREFOR, " " EDIT AT YOUR OWN RISK! " "=============================================================================="
class Game_System attr_reader :music_list attr_accessor :music_flag attr_accessor :spoiler alias initialize_musics initialize def initialize initialize_musics @spoiler = false @music_list = WLTR::MUSIC_ROOM_SETUP::MUSICS @music_flag = [] for i in 0..@music_list.size - 1 @music_flag[i] = false end end def music_unlocked?(id) return @music_flag[id] end def music_unlock_all for i in 0..@music_list.size - 1 @music_flag[i] = true end end end
module RPG class BGM < AudioFile alias play_check play def play if !@name.empty? check = $game_system.music_list.index(@name)
play_check return if $game_system.spoiler return if check == nil $game_system.music_flag[check] = true end end end end
class Scene_Music < Scene_Base def initialize(file = nil, call = "Title") @before_bgm = RPG::BGM.last @index = 0 @available_musics = [] for i in 0..WLTR::MUSIC_ROOM_SETUP::MUSICS.size - 1 @available_musics[i] = false end if file == nil for i in 0..3 @filename = make_filename(i) load_musicdata next if !@file_exist counter = 0 for flag in @game_system.music_flag if flag == true @available_musics[counter] = true end counter += 1 end end elsif @file != 0 @filename = make_filename(file) load_musicdata counter = 0 for flag in @game_system.music_flag if flag == true @available_musics[counter] = true end counter += 1 end end counter = 0 for flag in $game_system.music_flag if flag == true @available_musics[counter] = true end counter += 1 end @file = file @call = call @spoil = false $game_system.spoiler = true if !WLTR::MUSIC_ROOM_SETUP::SPOIL_UNLOCK end def make_filename(file_index) return "Save#{file_index + 1}.rvdata" end def load_musicdata @time_stamp = Time.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, "r") @time_stamp = file.mtime 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) rescue @file_exist = false ensure file.close end end end def start super create_menu_background if WLTR::MUSIC_ROOM_SETUP::BACKGROUND != "" @background = Sprite.new @background.bitmap = Cache.system(WLTR::MUSIC_ROOM_SETUP::BACKGROUND) else @background = Window_Base.new(0, 0, 272, 60) @background.contents.draw_text(0, 0, 272, 24, WLTR::MUSIC_ROOM_SETUP::MUSIC_ROOM_NAME) end @viewport = Viewport.new(0, 0, 544, 416) @music_list = Window_Music_List.new(0, 60, 272, 416 - 260, @file) @music_list.viewport = @viewport @comment = Window_Comment.new(0, 416 - 200, 544, 200) @comment.viewport = @viewport @spoil = true if $game_system.music_flag[0] == false @comment.refresh(@spoil) @spoil = false @index = @music_list.index end
def terminate super dispose_menu_background @music_list.dispose @comment.dispose @background.dispose if @background != nil end
def return_scene eval("$scene = Scene_" + @call + ".new") $game_system.spoiler = false RPG::BGM.stop @before_bgm.play end
def update super update_menu_background @music_list.update @comment.update update_music end def update_music @spoil = false if @music_list.index != @index @index = @music_list.index if @music_list.index != @index if Input.trigger?(Input::C) if @available_musics[@music_list.index] == true bgm = RPG::BGM.new($game_system.music_list[@music_list.index]) bgm.play @spoil = false @comment.id = @music_list.index spoil = false spoil = true if !$game_system.music_flag[@music_list.index] @comment.refresh(spoil) else if @spoil == false RPG::BGM.stop @comment.id = @music_list.index @comment.refresh @spoil = true if WLTR::MUSIC_ROOM_SETUP::LOCK_PLAYABLE else return if !WLTR::MUSIC_ROOM_SETUP::LOCK_PLAYABLE bgm = RPG::BGM.new($game_system.music_list[@music_list.index]) bgm.play @comment.id = @music_list.index @spoil = false @comment.refresh(true) @music_list.refresh if !$game_system.spoiler end end elsif Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::X) RPG::BGM.stop elsif Input.trigger?(Input::Y) RPG::BGM.fade(600) end end end
class Window_Music_List < Window_Selectable def initialize(x, y, width, height, file = nil) super(x, y, width, height) self.opacity = 0 if WLTR::MUSIC_ROOM_SETUP::BACKGROUND != "" @available_musics = [] for i in 0..WLTR::MUSIC_ROOM_SETUP::MUSICS.size - 1 @available_musics[i] = false end if file == nil for i in 0..3 @filename = make_filename(i) load_musicdata next if !@file_exist counter = 0 for flag in @game_system.music_flag if flag == true @available_musics[counter] = true end counter += 1 end end elsif @file != 0 @filename = make_filename(file) load_musicdata counter = 0 for flag in @game_system.music_flag if flag == true @available_musics[counter] = true end counter += 1 end end counter = 0 for flag in $game_system.music_flag if flag == true @available_musics[counter] = true end counter += 1 end @column_max = 1 @index = 0 refresh end def refresh self.contents.clear @data = WLTR::MUSIC_ROOM_SETUP::MUSICS_NAME @item_max = @data.size create_contents for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) item = @data[index] if item != nil rect.width -= 4 name = item known = @available_musics[index] if !known count = name.size + 1 name = "" for i in 1...count name += WLTR::MUSIC_ROOM_SETUP::UNKNOWN_WORD end end rect.width -= 4 self.contents.font.size = WLTR::MUSIC_ROOM_SETUP::FONT_SIZE self.contents.draw_text(0, rect.y, 24, rect.height, sprintf("%2d:", index + 1), 2) self.contents.draw_text(rect.x + 24, rect.y, self.width - 32, rect.height, name) end end def make_filename(file_index) return "Save#{file_index + 1}.rvdata" end def load_musicdata @time_stamp = Time.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, "r") @time_stamp = file.mtime 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) rescue @file_exist = false ensure file.close end end end end
class Window_Comment < Window_Base attr_accessor :id def initialize(x, y, width, height, id = 0) super(x, y, width, height) self.opacity = 0 if WLTR::MUSIC_ROOM_SETUP::BACKGROUND != "" @id = id self.contents.font.size = WLTR::MUSIC_ROOM_SETUP::FONT_SIZE pre_start refresh end def pre_start #=============================================================================== # Insert a code or two here if you want to do something before the first refresh # starts. #===============================================================================
#=============================================================================== end def pre_refresh #=============================================================================== # Insert a code or two here if you want to do something before the refresh # starts. #===============================================================================
#=============================================================================== end def refresh(spoil = false) pre_refresh @x = 0 @y = 0 self.contents.clear text = WLTR::MUSIC_ROOM_SETUP::MUSICS_COMMENT[@id] text = WLTR::MUSIC_ROOM_SETUP::EMPTY_COMMENT if !$game_system.music_unlocked?(@id) and spoil == false text = "" if text == nil process = text text = convert_special_characters(process) @comment = [] for i in 0..text.size - 1 @comment << text[i, 1] end update end def convert_special_characters(text) text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] } text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name } text.gsub!(/\n/i) { "|" } return text end def update super word = @comment.shift return if word == nil case word when "|" @x = 0 @y += self.contents.text_size(word).height else self.contents.draw_text(@x, @y, 40, WLH, word) width = self.contents.text_size(word).width @x += width end end end
#============================================================================== # ■ Window_Command #============================================================================== # Stole this from KGC... class Window_Command < Window_Selectable unless method_defined?(:add_command) #-------------------------------------------------------------------------- # ○ コマンドを追加 # 追加した位置を返す #-------------------------------------------------------------------------- def add_command(command) @commands << command @item_max = @commands.size item_index = @item_max - 1 refresh_command draw_item(item_index) return item_index end #-------------------------------------------------------------------------- # ○ コマンドをリフレッシュ #-------------------------------------------------------------------------- def refresh_command buf = self.contents.clone self.height = [self.height, row_max * WLH + 32].max create_contents self.contents.blt(0, 0, buf, buf.rect) buf.dispose end #-------------------------------------------------------------------------- # ○ コマンドを挿入 #-------------------------------------------------------------------------- def insert_command(index, command) @commands.insert(index, command) @item_max = @commands.size refresh_command refresh end #-------------------------------------------------------------------------- # ○ コマンドを削除 #-------------------------------------------------------------------------- def remove_command(command) @commands.delete(command) @item_max = @commands.size refresh end end end
class Scene_Title < Scene_Base def make_filename(file_index) return "Save#{file_index + 1}.rvdata" end def load_cleardata @time_stamp = Time.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, "r") @time_stamp = file.mtime 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) rescue @file_exist = false ensure file.close end end if @file_exist and WLTR::MUSIC_ROOM_SETUP::TITLE_SWITCH != nil @unlock_flag = @game_switches[WLTR::MUSIC_ROOM_SETUP::TITLE_SWITCH] unless @unlock_flag == true end end # Stole this from KGC's enemy guide. if WLTR::MUSIC_ROOM_SETUP::ADD_TO_MENU #-------------------------------------------------------------------------- # ● コマンドウィンドウの作成 #-------------------------------------------------------------------------- alias create_command_window_item_almanac create_command_window def create_command_window create_command_window_item_almanac
return if $imported["CustomMenuCommand"] for i in 0..3 @filename = make_filename(i) load_cleardata end if WLTR::MUSIC_ROOM_SETUP::TITLE_SWITCH != nil return if !@unlock_flag end @__command_music_room = @command_window.add_command(WLTR::MUSIC_ROOM_SETUP::MUSIC_ROOM_NAME) if @command_window.oy > 0 @command_window.oy -= Window_Base::WLH end end end #-------------------------------------------------------------------------- # ● コマンド選択の更新 #-------------------------------------------------------------------------- alias update_command_selection_music_room update def update current_menu_index = @__command_music_room call_item_almanac = false
if Input.trigger?(Input::C) case @command_window.index when @__command_music_room # モンスター図鑑 call_enemy_guide_flag = true end end
# モンスター図鑑に移行 if call_enemy_guide_flag Sound.play_decision $scene = Scene_Music.new return end
update_command_selection_music_room end end #=============================================================================== # # END OF SCRIPT # #===============================================================================
Terms of useKredit aku, wltr3565. Boleh untuk game komersial asalkan aku dikredit. Ngekredit yang ku terima kasih bukan ide yang buruk. Thanks
- ZUN untuk game dan musicnya dan inspirasi utama.
- KGC untuk nambah command.
| |
|