Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-------------------------------------------------------------------------------
- # Automatic sprite name indexing for v4.3 and above
- #-------------------------------------------------------------------------------
- module EBS_SpriteConversion
- def self.included base
- base.class_eval do
- alias loadSpriteConversion pbStartLoadScreen if !self.method_defined?(:loadSpriteConversion)
- def pbStartLoadScreen(*args)
- # skips if not in debug mode
- return loadSpriteConversion(*args) if !$memDebug || Input.press?(Input::CTRL)
- # generates a list of all .png files
- allFiles = readDirectoryFiles("Graphics/Battlers/",["*.png"])
- files = []
- # pushes the necessary file names into the main processing list
- for i in 1..PBSpecies.maxValue
- next if !(getConstantName(PBSpecies,i) rescue nil)
- species = sprintf("%03d",i)
- species_name = getConstantName(PBSpecies,i)
- j = 0
- (allFiles.length).times do
- sprite = allFiles[j]
- if sprite.include?(species) || sprite.include?(species_name)
- files.push(sprite)
- allFiles.delete_at(j)
- else
- j += 1
- end
- end
- end
- # starts automatic renaming
- unless allFiles.empty !allFiles.include?("egg.png") && !allFiles.include?("eggCracks.png")
- Kernel.pbMessage("The game has detected that you're running the Elite Battle System version 4.3 or above, but have sprites in your Graphics/Battlers that do not match the new naming convention. This will break your game!")
- if Kernel.pbConfirmMessage("Would you like to automatically resolve this issue?")
- dir = "Graphics/Battlers/"
- # creates new directories if necessary
- for ext in ["Front/","Back/","FrontShiny/","BackShiny/","Eggs/"]
- Dir.mkdir(dir+ext) if !FileTest.directory?(dir+ext)
- Dir.mkdir(dir+ext+"Female/") if !FileTest.directory?(dir+ext+"Female/") && ext != "Eggs/"
- end
- for file in files
- user = dir+file
- dest = dir
- # generates target directory and target name
- if file.include?("egg") || file.include?("Egg")
- dest = dir+"Eggs/"
- if file.include?("eggCracks")
- new_name = file.gsub(/eggCracks/) {|s| "cracks" }
- elsif file.include?("Egg")
- new_name = file.gsub(/Egg/) {|s| "" }
- else
- new_name = file.gsub(/egg/) {|s| "" }
- end
- elsif file.include?("s")
- if file.include?("b")
- dest = dir+"BackShiny/"
- new_name = file.gsub(/sb/) {|s| "" }
- else
- dest = dir+"FrontShiny/"
- new_name = file.gsub(/s/) {|s| "" }
- end
- else
- if file.include?("b")
- dest = dir+"Back/"
- new_name = file.gsub(/b/) {|s| "" }
- else
- dest = dir+"Front/"
- new_name = file
- end
- end
- if file.include?("f")
- dest += "Female/"
- new_name.gsub!(/f/) {|s| "" }
- end
- target = dest+new_name
- # moves the files into their appropriate folders
- File.rename(user,target)
- end
- end
- # Egg conversion
- allFiles = readDirectoryFiles("Graphics/Battlers/",["*.png"])
- for file in allFiles
- if file == "egg.png"
- File.rename("Graphics/Battlers/egg.png","Graphics/Battlers/Eggs/000.png")
- elsif file == "eggCracks.png"
- File.rename("Graphics/Battlers/eggCracks.png","Graphics/Battlers/Eggs/000cracks.png")
- end
- end
- Kernel.pbMessage("Conversion complete! Have fun using the new system!")
- end
- # goes back to the load screen
- return loadSpriteConversion(*args)
- end
- end
- end
- end
- if defined?(PokemonLoadScreen)
- PokemonLoadScreen.send(:include,EBS_SpriteConversion)
- end
- if defined?(PokemonLoad)
- PokemonLoad.send(:include,EBS_SpriteConversion)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement