Aventurier Lv.16
Age : 28 Inscrit le : 03/08/2009 Messages : 1399
| Sujet: Re: Charger grisé dans le menu Ven 30 Avr 2010 - 18:43 | |
| @Azuma =>C'est exactement ça merci beaucoup. @Sylfurion => Les deux scripts sont de Berka Sauvegarde dit ultime : - Spoiler:
- Code:
-
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Gestion de sauvegardes ultime # rgss 2 par Berka 11/11/09 #---------------------------------------------------------------------------------------------------------------------------------- # http://rpgmakervx.1fr1.net #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
module Berka module SaveFile P_Save = "Sauvegardes" # Dossier de sauvegarde P_Fichier = "partie" # Fichier de sauvegarde SF_Latence = 3 # Delais fermeture du message en secondes SF_Strings = {'FR'=>["Sauvegarde n°","%s possédés:","Temps de jeu:","Lieu:"], 'EN'=>["Save number","%s obtained:","PlayTime:","Location:"], 'BR'=>["Salvaguarda n°","%s possuídos","Tempo de jogo:","Lugar:"]} SF_Ecraser = {'FR'=>"Voulez-vous écraser ce fichier ?", 'EN'=>"Do you really want to crush this savefile?", 'BR'=>"Querem substituir-vos o ficheiro?"} SF_Fichier = {'FR'=>"Fichier:", 'EN'=>'File:', 'BR'=>"Ficheiro:"} SF_Date = {'FR'=>"Date", 'EN'=>'Date:', 'BR'=>"Data:"} SF_Confirm = {'FR'=>["Oui","Non"], 'EN'=>["Yes","No"], 'BR'=>["Sim","Não"]} SF_Avert = {'FR'=>"La partie a été sauvegardée.", 'EN'=>'Game has been successfully saved', 'BR'=>"O jogo foi salvaguardado"} SF_Nouv = {'FR'=>"Créer une nouvelle sauvegarde", 'EN'=>'Click to create a New Save', 'BR'=>"O jogo foi salvaguardado"} end # Une petite API parce qu'il faut bien en caser dans un script: détection automatique de langue ^^ def self.lang (l={1036=>"FR",2060=>"FR",3084=>"FR",4108=>"FR",5132=>"FR", 1033=>"EN",2057=>"EN",3081=>"EN",4105=>"EN",5129=>"EN",6153=>"EN",7177=>"EN", 1046=>"BR",2070=>"BR" }[Win32API.new('kernel32','GetUserDefaultLCID','','l').call]).nil? ? "EN" : l end Lang=self.lang if defined?(Lang).nil? end include Berka::SaveFile
class Scene_File<Scene_Base def initialize(sauver,titre,event) @sauver,@titre,@event,@donnees=sauver,titre,event,[] Dir.mkdir(P_Save,777)rescue nil end def start super create_menu_background @help=Window_Help.new @fichiers=Dir.glob("#{P_Save}/*.rvdata").sort! @fichiers.each{|k|preload(File.open(k,'rb'))} if @sauver @help.set_text(Vocab::SaveMessage,1) @obj,d=(@index_max=@fichiers.size+1),(@donnees<<nil).reverse else @help.set_text(Vocab::LoadMessage,1) @obj,d=(@index_max=@fichiers.size),@donnees.reverse! end @fenetre=Window_File.new(@sauver,0,56,544*@index_max,360) @fenetre.create_planes(@obj,d,@fichiers,@sauver) end def terminate @fenetre.dispose @help.dispose end def update super @help.update next_scene if Input.trigger?(Input::B) confirm if Input.trigger?(Input::C) @index=(@fenetre.x/544).to_i.abs case Input.dir4 when 4;move(false)if @index>0 when 6;move if @index<@index_max-1 end end def preload(file) h=(a=[:scr,:inf,:cha,:fra,:bgm,:bgs,:sys,:msg,:swi,:var,:ssw,:act,:par,:tro,:map,:pla]).to_hash a.size.times{|i|h[a[i]]=Marshal.load(file)} @donnees.insert(0,h) file.close end
def confirm Sound.play_decision path=P_Save+"/#{fi=@fichiers[@index]}" if @sauver if fi.nil? path=P_Save+"/#{P_Fichier+@index.to_s}.rvdata" else f=Window_Temp.new(SF_Ecraser[Berka::Lang])if FileTest.exist?(path) (return if !f.refresh)rescue nil end sauver(File.open(path,"wb")) avert(SF_Avert[Berka::Lang]) $scene=Scene_Menu.new else charger(File.open(path,"rb")) $scene=Scene_Map.new RPG::BGM.fade(1500) Graphics.fadeout(60) Graphics.wait(40) @last_bgm.play @last_bgs.play end end def avert(msg) h=Window_Help.new h.width=344;h.x,h.y=(544-h.width)/2,(416-h.height)/2 h.contents=Bitmap.new(308,h.height-32) h.set_text(msg) (SF_Latence*Graphics.frame_rate).times{Graphics.update} h.dispose Sound.play_decision end def sauver(file) characters=[] for actor in $game_party.members characters<<[actor.character_name,actor.character_index] end $game_system.save_count+=1 $game_system.version_id=$data_system.version_id @last_bgm=RPG::BGM::last @last_bgs=RPG::BGS::last t,fo=Time.new,"%02d/%02d/%02d" Berka::Lang=="FR" ? @infos=[sprintf(fo,t.day,t.month,t.year)] : @infos=[sprintf(fo,t.month,t.day,t.year)] Marshal.dump($capture, file) Marshal.dump(@infos, file) Marshal.dump(characters, file) Marshal.dump(Graphics.frame_count,file) Marshal.dump(@last_bgm, file) Marshal.dump(@last_bgs, file) Marshal.dump($game_system, file) Marshal.dump($game_message, file) Marshal.dump($game_switches, file) Marshal.dump($game_variables, file) Marshal.dump($game_self_switches,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 charger(file) $capture = Marshal.load(file) @infos = Marshal.load(file) characters = Marshal.load(file) Graphics.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) $game_variables = Marshal.load(file) $game_self_switches = 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.version_id!=$data_system.version_id $game_map.setup($game_map.map_id) $game_player.center($game_player.x,$game_player.y) end file.close end
def move(right=true,i=68,ok=false) Sound.play_cursor i.times{|n|@n=n Input.update Graphics.update @fenetre.update (ok=true;break)if Input.trigger?(right ? Input::LEFT : Input::RIGHT) right ? @fenetre.x-=8 : @fenetre.x+=8} move(!right,68-i+@n)if ok end def next_scene Sound.play_cancel if @titre;$scene=Scene_Title.new elsif @event;$scene=Scene_Map.new else;$scene=Scene_Menu.new(4) end end end
class Window_File<Window_Base def initialize(bool,x,y,w,h) super(x,y,w,h) @fondb=Sprite.new @fondb.x,@fondb.y,@fondb.z=23,396,1000 @fondb.bitmap=Bitmap.new(501,8) @fondb.bitmap.fill_rect(0,0,501,8,Color.new(255,255,255)) @fondb.bitmap.coins @fondb.bitmap.fill_rect(1,1,499,6,Color.new(0,0,0,0)) @bar=Sprite.new @bar.x,@bar.y,@bar.z=23,396,1000 @bar.bitmap=Bitmap.new(501,8) update end def create_planes(i,d,fs,sauve) @i=i update fs.collect!{|f|f=f.split('/')[-1]} @i.times{|n|create_cursor(8+(x=544*n),8,492,300) if sauve&&d[n].nil? self.contents.font.size=96 self.contents.draw_text(x,40,544,132,"?",1) self.contents.font.size=20 self.contents.draw_text(x,256,544,WLH,SF_Nouv[Berka::Lang],1) next end (cadre(x);self.contents.blt(16+x,16,d[n][:scr].coins,d[n][:scr].rect)rescue next) d[n][:cha].each_with_index{|nm,i| create_cursor(278+x,28+48*i,214,32) draw_character(nm[0],nm[1],288+x,56+48*i) draw_actor_name(a=d[n][:par].members[i],302+x,48*(i+1)-29) draw_actor_hp(a,368+x,48*(i+1)-30,120) draw_actor_level(a,308+x,48*(i+1)-8) draw_actor_class(a,388+x,48*(i+1)-8)} create_cursor(15+x,220,477,80) self.contents.font.color=system_color self.contents.draw_text(20+x,224,272,WLH,SF_Strings[Berka::Lang][3]) self.contents.draw_text(20+x,248,272,WLH,sprintf(SF_Strings[Berka::Lang][1],Vocab::gold)) self.contents.draw_text(20+x,272,272,WLH,SF_Strings[Berka::Lang][2]) self.contents.draw_text(272+x,224,272,WLH,SF_Fichier[Berka::Lang]) self.contents.draw_text(272+x,248,272,WLH,SF_Date[Berka::Lang]) self.contents.font.color=normal_color self.contents.draw_text(x,224,264,WLH,lieu(d[n][:map].map_id),2) self.contents.draw_text(x,248,264,WLH,d[n][:par].gold,2) h=sprintf("%02d:%02d:%02d",(ts=d[n][:fra]/Graphics.frame_rate)/60/60,ts/60%60,ts%60) self.contents.draw_text(x,272,264,WLH,h.to_s,2) self.contents.fill_rect(268+x,225,1,82,normal_color) self.contents.fill_rect(269+x,226,1,80,system_color) self.contents.draw_text(274+x,224,224,WLH,fs[n],2) self.contents.draw_text(274+x,248,224,WLH,d[n][:inf][-1],2)} end def lieu(id) load_data("Data/MapInfos.rvdata")[id].name end def cadre(n) self.contents.fill_rect(15+544*n,15,274,210,Color.new(255,255,255)) [[15+n,15],[288+n,15],[288+n,224],[15+n,224]].each{|x,y| self.contents.set_pixel(x,y,Color.new(0,0,0,0))} end def update @bar.bitmap.clear x=1+(502.0)*(self.x.abs.to_f/self.width.to_f) @bar.bitmap.fill_rect(x-1,1,(503.0/(@i)),6,Color.new(255,255,255,50))rescue nil @fondb.update @bar.update end def dispose @bar.dispose @fondb.dispose super end def create_cursor(x,y,w,h) wsk=self.windowskin [[0]*4,[w,0,24,0],[w,h,24,24],[0,h,0,24]].each{|a,b,c,d| self.contents.blt(x+a,y+b,wsk,Rect.new(64+c,64+d,8,8))} [[8,0,w-8,8,8,0],[w,8,8,h-8,24,8],[8,h,w-8,8,8,24],[0,8,8,h-8,0,8],[8,8,w-8,h-8,8,8]].each{|a,b,c,d,e,f| self.contents.stretch_blt(Rect.new(x+a,y+b,c,d),wsk,Rect.new(64+e,64+f,8,8))} end end
class Window_Temp<Window_Selectable def initialize(texte) super(100,160,344,84) @sprite,@texte=Sprite.new,texte @sprite.z=self.z-1 (@sprite.bitmap=Graphics.snap_to_bitmap).blur @sprite.color.set(16,16,16,128) @confirm=Window_Command.new(344,SF_Confirm[Berka::Lang],2) @confirm.x,@confirm.y,@confirm.opacity=self.x,self.y+self.height-48,0 end def refresh loop{ Graphics.update Input.update @sprite.update @confirm.update self.contents.clear self.contents.draw_text(0,0,300,WLH,@texte,1) @ok=@confirm.index==0 if Input.trigger?(Input::C) (dispose;return @ok)if !@ok.nil?} end def dispose @sprite.dispose @confirm.dispose super end end
class Scene_Menu<Scene_Base alias :capt_init :initialize def initialize(menu_index=0) capt_init(menu_index) $capture.dispose if !$capture.nil?&&!$capture.disposed? $capture=Graphics.snap_to_bitmap.resize(0.5) end end
class Bitmap def resize(z) (b=Bitmap.new(self.width*z,self.height*z)).stretch_blt(b.rect,self,self.rect);b end def coins(c=Color.new(0,0,0,0)) [[0,0],[self.width-1,0],[self.width-1,self.height-1],[0,self.height-1]].each{|x,y| self.set_pixel(x,y,c)} self end #! Par Yeyinde (http://hbgames.org) RtlMoveMemory_pi=Win32API.new('kernel32','RtlMoveMemory','pii','i') RtlMoveMemory_ip=Win32API.new('kernel32','RtlMoveMemory','ipi','i') def _dump(limit) data="rgba"*width*height RtlMoveMemory_pi.call(data,address,data.length) [width,height,Zlib::Deflate.deflate(data)].pack("LLa*") end def self._load(str) w,h,zdata=str.unpack("LLa*");b=new(w,h) RtlMoveMemory_ip.call(b.address,Zlib::Inflate.inflate(zdata),w*h*4);b end def address buffer,ad="xxxx",object_id*2+16 RtlMoveMemory_pi.call(buffer,ad,4);ad=buffer.unpack("L")[0]+8 RtlMoveMemory_pi.call(buffer,ad,4);ad=buffer.unpack("L")[0]+16 RtlMoveMemory_pi.call(buffer,ad,4);buffer.unpack("L")[0] end end
class Font def marshal_dump;end def marshal_load(obj);end end #! class Scene_Title<Scene_Base def check_continue @continue_enabled=(Dir.glob(P_Save+'/*.rvdata').size>0) end end #! Petite méthode perso ^^ class Array def to_hash(val=nil) Hash[*self.collect{|v|[v,val]}.flatten] end end
Scene_chargement : - Spoiler:
- Code:
-
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Chargement par Berka # RGSS 2 (RMVX) # http://www.rpgmakerxp.frbb.net #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#=============================================================== # # www.rpgmakervx-fr.com # #===============================================================
FOND = "fond" # image a placer dans le dossier system BARRE = "barre" # image a placer dans le dossier system DUREE = 10 # en secondes TEXTE = "Chargement en cours..." # texte a afficher X_BAR = nil #position x de la barre, nil par default Y_BAR = nil #position y de la barre, nil par default LONG = 400 #longueur de la barre HAUT = 28 #hauteur de la barre TITRE = true # afficher le nom du projet ? COULEUR_FOND = Color.new(0, 0, 0, 100) # couleur fond barre COULEUR_BARRE = Color.new(0, 0, 250, 255) # couleur barre class Scene_Chargement def main $bar , $b , $tps =0, 0, DUREE*60 @fond = Sprite.new @barre = Sprite.new @barre.visible = false @fonb = Sprite.new @fond.bitmap = Cache.system(FOND) rescue @fond.bitmap = Bitmap.new(544, 416) @fenetre = Window_Barre.new((544-360)/2, 316/3, 360, 200) @barre.bitmap = Cache.system(BARRE) rescue nil if X_BAR == nil or Y_BAR == nil @barre.x, @barre.y = (544-LONG)/2, 240 else @barre.x, @barre.y = X_BAR, Y_BAR end @xb, @yb = @barre.x, @barre.y @fonb.bitmap = Bitmap.new(544, 416) Graphics.transition loop do Graphics.update Input.update update break if $scene != self end Graphics.freeze @fond.dispose @fenetre.dispose @barre.dispose end def update @barre.visible = true if $tps > 0 and $bar <300 $tps -= 1 else $scene = $scene = $scene = Scene_Title.new # scene a executer a la fin du chargement end $b = LONG - LONG * $tps/(DUREE*60) @barre.src_rect.set(0, 0, $b , HAUT) @fonb.bitmap.fill_rect(@xb-1, @yb-1, LONG+2 , HAUT+2, COULEUR_FOND) @fond.update @fenetre.update @barre.update end end
class Window_Barre < Window_Base def initialize(x, y, width, height) @width, @height = width, height super(x, y, @width, @height) self.opacity = 0 refresh end def refresh self.contents.clear w = contents.text_size(TEXTE).width self.contents.draw_text((@width-w)/3, 40, w, WLH, TEXTE) tx = ($b.to_f/LONG)*100 s = contents.text_size(tx.to_i.to_s + " %").width self.contents.draw_text((@width-s)/3+32, 120, s, WLH, tx.to_i.to_s + " %") t = $tps / Graphics.frame_rate end def update super refresh end end
Bye Ps : Pour scene_chargement modifie "Main" est met - Spoiler:
- Code:
-
#============================================================================== # ** Main #------------------------------------------------------------------------------ # After defining each class, actual processing begins here. #==============================================================================
unless Font.exist?("UmePlus Gothic") print "Le fichier Font 'UmePlus Gothic' n'a pas été trouvé" exit end
begin $showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), '' $showm.call(18,0,0,0) $showm.call(13,0,0,0) $showm.call(13,0,2,0) $showm.call(18,0,2,0) Graphics.freeze $scene = Scene_Chargement.new $scene.main while $scene != nil Graphics.transition(30) rescue Errno::ENOENT filename = $!.message.sub("No such file or directory - ", "") print("Le ficher #{filename} n'a pas été trouvé.") end
|
|