Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################################################################################
- ################################# AJISAIVE #####################################
- ################################################################################
- # Auteur : Biward
- # Date : 07/09/2013 2h27
- # Pour : Ajisai <3
- #
- # Ce script permet de modifier d'ajouter des chapitres à son jeu
- # Pour définir un chapitre, modifier la variable sur le chapitre que vous avez
- # choisi ou utiliser cette commande en appel de script :
- # chapitre(id_chapitre)
- #
- module AJISAIVE
- # Indiquez ici la variable qui va enregistrer le chapitre !
- V = 5
- # Indiquez ici le nombre de sauvegarde possible
- Max_Save = 5
- # Indiquez ici le fond
- # Back = false pour aucun fond (c'est à dire le fond de l'écran titre et/ou la map)
- # Back = "nom" pour une seule image
- # Back = [nombre de frame, "image1", "image2", etc] pour plusieurs images
- # Le nombre de frame correspond au nombre de frame entre chaque image.
- Back = [60, "Back", "Back1", "Back2", "Back3", "Back4"]
- # Indiquez ici la police du men ude sauvegarde !
- # Mettez false pour garder celle de base
- Font = "Comic Sans MS"
- # Indiquez ici le son que vous voulez jouer durant le menu de sauvegarde
- # Mettez false pour ne pas jouer de son
- # Mettez true pour jouer le son de la scène précédente (map ou écran titre)
- # Mettez ["nom", volume, tempo] pour jouer une musique personnalisée
- Sound = ["Town1", 100, 100]
- # Indiquez ici le temps de transition (fondu des images et de la musique)
- TimeTransition = 120
- end
- ################################################################################
- ############################## DEBUT DU SCRIPT #################################
- ################################################################################
- ##### DataManager #####
- #~ module DataManager
- #~ # chapter = $game_variables[AJISAIVE::V]
- #~ end
- ##### Game_Interpreter #####
- class Game_Interpreter
- def chapitre(id)
- $game_variables[AJISAIVE::V] = id
- end
- end
- ##### Scene_File #####
- class Scene_File < Scene_MenuBase
- class << self
- attr_accessor :back
- end
- def start
- super
- initialize_toshow
- initialize_index
- create_back
- create_sprite
- create_window
- update_toshow
- @window_save[@index].selected = true
- RPG::BGM.fade(1200) if AJISAIVE::Sound.is_a?(Array) || ! AJISAIVE::Sound
- Graphics.transition(AJISAIVE::TimeTransition)
- sound if AJISAIVE::Sound
- RPG::BGM.stop if ! AJISAIVE::Sound
- end
- def sound
- Audio.bgm_play("Audio/BGM/" + AJISAIVE::Sound[0], AJISAIVE::Sound[1], AJISAIVE::Sound[2]) if AJISAIVE::Sound.is_a?(Array)
- end
- def initialize_toshow
- @toshow = [0, 1, 2, 3]
- end
- def initialize_index
- @index = 0
- @index_back = 0
- end
- def item_max
- AJISAIVE::Max_Save
- end
- def back
- return AJISAIVE::Back[@index_back + 1] if Scene_File.back
- AJISAIVE::Back
- end
- def create_window
- @window_save ||= Array.new
- @window_save = Array.new(item_max) { |i| Window_SaveFile.new(50, i) }
- @window_save.size.times do |i|
- @window_save[i].opacity = 0 if back
- @window_save[i].x = 9 + ((i % 2).to_i * 268)
- @window_save[i].y = @sprite_chapter.height + 30 + (((i % 4).to_i / 2).to_i * 54)
- end
- end
- def id_chapter
- return @gv[AJISAIVE::V] if ex
- return 0
- end
- def create_sprite
- @sprite_chapter = Sprite.new
- @sprite_chapter.bitmap = Cache.system("cap#{id_chapter.to_s}")
- @sprite_chapter.z = 1
- @sprite_sl = Sprite.new
- @sprite_sl.bitmap = Cache.system("save_b") if SceneManager.scene.is_a?(Scene_Save)
- @sprite_sl.bitmap = Cache.system("load_b") if SceneManager.scene.is_a?(Scene_Load)
- @sprite_sl.z = 2
- @sprite_sl.y = @sprite_chapter.height - 10
- @sprite_save ||= Array.new
- @sprite_save = Array.new(4) { |i| Sprite.new }
- @sprite_save.size.times do |i|
- @sprite_save[i].bitmap = Cache.system("save_f")
- @sprite_save[i].x = 9 + (((i + 0) % 2 ).to_i * 268)
- @sprite_save[i].y = @sprite_chapter.height + 30 + (((i) / 2).to_i * 54)
- @sprite_save[i].z = 3
- end
- update_sprite
- end
- def create_back
- if back
- @background = Sprite.new
- if back.is_a?(String)
- @background.bitmap = Cache.system(back.to_s)
- elsif back.is_a?(Array)
- Scene_File.back = true
- @index_back = 0
- @background.bitmap = Cache.system(back.to_s)
- end
- end
- end
- def terminate
- super
- RPG::BGM.fade(1200)
- dispose_window
- dispose_sprite
- dispose_back
- end
- def dispose_window
- @window_save.each { |i| i.dispose }
- end
- def dispose_sprite
- @sprite_sl.dispose
- @sprite_chapter.dispose
- @sprite_save.each { |i| i.dispose }
- end
- def dispose_back
- @background.dispose if @background
- end
- def update
- super
- update_input
- update_window
- update_back if Scene_File.back
- end
- def update_input
- cursor_move(2) if Input.trigger?(:DOWN)
- cursor_move(-2) if Input.trigger?(:UP)
- cursor_move(-1) if Input.trigger?(:LEFT)
- cursor_move(1) if Input.trigger?(:RIGHT)
- on_savefile_cancel if Input.trigger?(:B)
- on_savefile_ok if Input.trigger?(:C)
- end
- def cursor_move(i)
- @index = check_index(i)
- Sound.play_cursor
- update_toshow
- update_sprite
- end
- def check_index(i)
- case i
- when 1
- return 0 if (@index + i) >= item_max
- when 2
- return 0 if (@index + i) >= item_max
- return 1 if (@index + i) >= item_max
- when -1
- return (item_max - 1) if (@index + i) < 0
- when -2
- return (item_max - 1) if (@index + i) < 0
- return (item_max - 2) if (@index + i) < 0
- end
- return @index + i
- end
- def update_window
- if ! @window_save[@index].selected
- @window_save.each { |i| i.selected = false }
- @window_save[@index].selected = true
- end
- end
- def update_toshow
- @toshow.clear
- 4.times do |i|
- d = ((@index / 4).to_i * 4).to_i + i
- @toshow << d if d < item_max
- end
- draw_window
- end
- def draw_window
- @window_save.each { |i| i.visible = false }
- @toshow.each do |i|
- @window_save[i].visible = true
- end
- @window_save.each { |i| i.selected = true }
- @window_save.each { |i| i.selected = false }
- @window_save[@index].selected = true
- end
- def update_sprite
- @sprite_save.each { |i| i.visible = false }
- @toshow.size.times { |i| @sprite_save[i].visible = true }
- @sprite_chapter.dispose if @sprite_chapter
- @sprite_chapter = Sprite.new
- @sprite_chapter.bitmap = Cache.system("cap#{id_chapter.to_s}")
- @sprite_chapter.z = 1
- end
- def update_back
- @nb ||= 0
- @nb += 1
- if @nb == AJISAIVE::Back[0]
- @index_back += 1
- @nb = 0
- if @index_back >= (AJISAIVE::Back.size - 1)
- @index_back = 0
- end
- @background.dispose
- @background = Sprite.new
- @background.bitmap = Cache.system(back.to_s)
- @background.z = 0
- end
- end
- ##############################################################################
- ##### Accès à la sauvegarde
- ##############################################################################
- def ex
- begin
- extract_without_rescue
- rescue
- false
- end
- end
- def extract_without_rescue
- File.open(make_filename(@index), "rb") do |file|
- Marshal.load(file)
- extract_save_variables(Marshal.load(file))
- end
- return true
- end
- def extract_save_variables(contents)
- @gv = contents[:variables]
- end
- def make_filename(index)
- sprintf("Save%02d.rvdata2", index + 1)
- end
- end
- ##### Window_SaveFile #####
- class Window_SaveFile < Window_Base
- def initialize(height, index)
- super(0, index * height, 258, height)
- self.contents.font.name = [AJISAIVE::Font, 20] if AJISAIVE::Font
- self.z = 100
- @file_index = index
- refresh
- @selected = false
- end
- end
- ################################################################################
- ############################### Fin du Script ##################################
- ################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement