Va-nu-pieds Lv.4
Age : 30 Inscrit le : 23/07/2008 Messages : 56
| Sujet: [VX] Panormisateur Ven 1 Aoû 2008 - 17:36 | |
| Ce script permet de panoramiser une map. Il en fait la capture d'écran totale. Il suffit de les assembler pour avoir le panorama. Auteur : Zeus81 Il faut mettre ce fichier dans le dossier de votre projet : Fichier Placer se script au-dessus de Main : - Code:
-
#=============================================================================== # El Panoramisator # Script créé par Zeus81 # # Screenshot # Script créé par Andreas21 modifié par Zeus81 #===============================================================================
module Screen gamename = open("Game.ini").readlines[4] gamename = gamename[6, gamename.size - 7] Window = Win32API.new('user32', 'FindWindow', %w(p p), 'l').call('RGSS Player', gamename) Screenshot = Win32API.new('screenshot.dll', 'Screenshot', %w(l l l l p l l), '') module_function def shot(filename = "Screenshot", type = 2) case type when 1; filename += ".jpg" when 2; filename += ".png" else ; filename += ".bmp" end Screenshot.call(0, 0, 544, 416, filename, Window, type) end end
class Map_2_Panorama def initialize(map_id, background_color, autotiles_anime) sprite1 = Sprite.new sprite1.bitmap = Bitmap.new(544, 416) sprite1.bitmap.fill_rect(0, 0, 544, 416, background_color) map = load_data(sprintf("Data/Map%03d.rvdata", map_id)) tilemap = Tilemap.new tilemap.bitmaps[0] = Cache.system("TileA1") tilemap.bitmaps[1] = Cache.system("TileA2") tilemap.bitmaps[2] = Cache.system("TileA3") tilemap.bitmaps[3] = Cache.system("TileA4") tilemap.bitmaps[4] = Cache.system("TileA5") tilemap.bitmaps[5] = Cache.system("TileB") tilemap.bitmaps[6] = Cache.system("TileC") tilemap.bitmaps[7] = Cache.system("TileD") tilemap.bitmaps[8] = Cache.system("TileE") tilemap.map_data = map.data tilemap.passages = $data_system.passages sprite2 = Sprite.new sprite2.bitmap = Bitmap.new(544, 416) width = (map.width/17.0).ceil height = (map.height/13.0).ceil for sx in 0...width for sy in 0...height tilemap.ox = sx * 544 tilemap.oy = sy * 416 sprite2.bitmap.fill_rect(0, 0, 544, 416, Color.new(0,0,0)) sprite2.bitmap.fill_rect(0, 0, [map.width*32-sx*544, 544].min, [map.height*32-sy*416, 416].min, Color.new(0,0,0,0)) for autotile in 0..(autotiles_anime ? 3 : 0) 6.times do Graphics.update end Screen.shot(sprintf("Map[%03d]_Autotile[%d]_x[%02d]_y[%02d]", map_id, autotile, sx, sy)) if autotiles_anime 30.times do tilemap.update end end end end end tilemap.dispose sprite1.dispose sprite2.dispose end end
class Window_MapList < Window_Selectable def initialize super(134, 88, 276, 272) self.windowskin = Cache.system("Window") self.opacity = 0 self.active = false self.visible = false refresh end def refresh @maps_id = [] for i in 1..999 filename = sprintf("Data/Map%03d.rvdata", i) if FileTest.exist?(filename) @maps_id.push(i) end end @item_max = @maps_id.size @index = 0 self.contents = Bitmap.new(244, @item_max*24 ) self.contents.font.name = "Comic Sans MS" self.contents.font.size = 20 self.contents.fill_rect(0, 0, 244, @item_max*24, Color.new(64,64,128,128)) for i in 0...@maps_id.size self.contents.fill_rect(4, i*24+2, 236, 20, Color.new(0,0,0)) map_name = sprintf(" %03d - ", @maps_id[i]) + load_data("Data/MapInfos.rvdata")[@maps_id[i]].name self.contents.draw_text(4, i*24+2, 236, 20, map_name) end end def map_id return @maps_id[@index] end def update_help text = "Touche C : Valider - Touche B : Annuler" @help_window.set_text(text, 1) end end
class Window_Panoramisator < Window_Selectable attr_accessor :item_max attr_accessor :map_id attr_accessor :background_color attr_accessor :autotiles_anime def initialize super(0, 0, 544, 416) self.windowskin = Cache.system("Window") self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = "Comic Sans MS" @item_max = 4 @index = 0 @map_id = 0 @background_color = Color.new(0, 255, 0) @autotiles_anime = false refresh end def refresh self.contents.clear self.contents.fill_rect(0, 48, 512, 1, normal_color) self.contents.fill_rect(0, 336, 512, 1, normal_color) self.contents.font.size = 28 self.contents.font.color = knockout_color self.contents.draw_text(0, 0, 512, 48, "El Panoramisator", 1) self.contents.font.size = 18 self.contents.font.color = normal_color self.contents.draw_text(0, 316, 512, 20, "© Zeus81 2008 ", 2) self.contents.draw_text(0, 336, 64, 20, "Aide") self.contents.font.size = 20 self.contents.draw_text(0, 56, 512, 32, "Choix de la map à panoramiser", 1) self.contents.draw_text(0, 120, 512, 32, "Choix de la couleur de fond", 1) self.contents.draw_text(152, 152, 64, 32, "Rouge", 1) self.contents.draw_text(152, 176, 64, 32, "Vert", 1) self.contents.draw_text(152, 200, 64, 32, "Bleu", 1) self.contents.draw_text(0, 232, 512, 32, "Animer les autotiles sur 4 images", 1) self.contents.draw_text(0, 264, 512, 32, "Démarrer la séance photo", 1) self.contents.font.color = Color.new(0,0,0) self.contents.font.shadow = false refresh_values end def refresh_values self.contents.fill_rect(138, 90, 236, 20, normal_color) if @map_id == 0 self.contents.draw_text(138, 90, 236, 20, "Veuillez sélectionner une map", 1) else map_name = sprintf(" %03d - ", @map_id) + load_data("Data/MapInfos.rvdata")[@map_id].name self.contents.draw_text(138, 90, 236, 20, map_name) end self.contents.fill_rect(216, 158, 40, 20, normal_color) self.contents.fill_rect(216, 182, 40, 20, normal_color) self.contents.fill_rect(216, 206, 40, 20, normal_color) self.contents.draw_text(216, 158, 40, 20, @background_color.red.to_i.to_s, 1) self.contents.draw_text(216, 182, 40, 20, @background_color.green.to_i.to_s, 1) self.contents.draw_text(216, 206, 40, 20, @background_color.blue.to_i.to_s, 1) self.contents.fill_rect(272, 156, 72, 72, @background_color) color = @autotiles_anime ? Color.new(255, 0, 0) : Color.new(128, 128, 128) self.contents.fill_rect(115, 243, 10, 10, Color.new(29, 82, 129)) self.contents.fill_rect(116, 244, 8, 8, normal_color) self.contents.fill_rect(117, 245, 6, 6, color) end def update_cursor if @item_max == 4 y = @index * 32 + (@index > 0 ? (@index > 1 ? 168 : 88) : 56) self.cursor_rect.set(104, y, 304, 32) else y = @index * 24 + 156 self.cursor_rect.set(152, y, 112, 24) end end def update_help if @item_max == 4 case @index when 0; text = "Selectionnez la map que vous désirez transformer en panorama." when 1; text = "Configurez la couleur qui remplacera les zones transparentes." when 2; text = "Désirez-vous capturer les animations des autotiles ?" when 3; text = "Exécuter le programme ?" end else text = "Touche C : Valider - Touche B : Annuler - Touche Gauche & Droite : Modifier valeur" end @help_window.set_text(text, 1) end
end
class Scene_Panoramisator def main @panoramisator_window = Window_Panoramisator.new @maplist_window = Window_MapList.new @help_window = Window_Help.new @help_window.y = 352 @help_window.opacity = 0 @help_window.contents.font.name = "Comic Sans MS" @help_window.contents.font.size = 20 @panoramisator_window.help_window = @help_window @maplist_window.help_window = @help_window Graphics.transition loop do update Graphics.update Input.update end end def update @panoramisator_window.update @maplist_window.update if @panoramisator_window.active if @panoramisator_window.item_max == 4 update_panoramisator_window else update_background_color end else update_maplist_window end end def update_panoramisator_window if Input.trigger?(Input::C) case @panoramisator_window.index when 0 Sound.play_decision @maplist_window.visible = true @maplist_window.active = true @panoramisator_window.active = false when 1 Sound.play_decision @last_background_color = @panoramisator_window.background_color.dup @count = 1 @panoramisator_window.item_max = 3 @panoramisator_window.index = 0 when 2 Sound.play_decision @panoramisator_window.autotiles_anime = !@panoramisator_window.autotiles_anime @panoramisator_window.refresh_values when 3 if @panoramisator_window.map_id == 0 Sound.play_buzzer else Sound.play_save @panoramisator_window.visible = false @help_window.visible = false map_id = @panoramisator_window.map_id background_color = @panoramisator_window.background_color autotiles_anime = @panoramisator_window.autotiles_anime Map_2_Panorama.new(map_id, background_color, autotiles_anime) @panoramisator_window.visible = true @help_window.visible = true print(" La séance photo est terminée !\n", "Les captures d'écran se trouvent dans le dossier de votre jeu.") end end end end def update_background_color background_color = @panoramisator_window.background_color if Input.press?(Input::LEFT) == Input.press?(Input::RIGHT) @count = 1 elsif Input.repeat?(Input::LEFT) Sound.play_cursor case @panoramisator_window.index when 0; background_color.red = [background_color.red - @count.round, 0].max when 1; background_color.green = [background_color.green - @count.round, 0].max when 2; background_color.blue = [background_color.blue - @count.round, 0].max end @panoramisator_window.refresh_values elsif Input.repeat?(Input::RIGHT) Sound.play_cursor case @panoramisator_window.index when 0; background_color.red += @count.round when 1; background_color.green += @count.round when 2; background_color.blue += @count.round end @panoramisator_window.refresh_values end if Input.trigger?(Input::C) Sound.play_decision @panoramisator_window.item_max = 4 @panoramisator_window.index = 1 elsif Input.trigger?(Input::B) Sound.play_cancel @panoramisator_window.background_color = @last_background_color.dup @panoramisator_window.item_max = 4 @panoramisator_window.index = 1 @panoramisator_window.refresh_values end @count *= 1.02 end def update_maplist_window if Input.trigger?(Input::C) Sound.play_decision @maplist_window.visible = false @maplist_window.active = false @panoramisator_window.active = true @panoramisator_window.map_id = @maplist_window.map_id @panoramisator_window.refresh_values elsif Input.trigger?(Input::B) Sound.play_cancel @maplist_window.visible = false @maplist_window.active = false @panoramisator_window.active = true end end end Pour appeler le script, faite un nouvel événement : -Appelation de script : $scene = Scene_Panoramisator.new Voilà. |
|