Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # Zer0 ScreenTest
- # Author: ForeverZer0
- # Version: 2.1
- # Date: 10.3.2010
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # Version History
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # v.1.0 (3.20.2010)
- # - Original write and release
- #
- # v.1.1 (3.31.2010)
- # - Added extra feature if using Zer0 Advanced Weather System
- #
- # v.1.2. (5.14.2010)
- # - Improved coding. Shortened.
- #
- # v.2.0 (10.3.2010)
- # - Totally re-written. Code has been vastly improved.
- # - No need to configure any filenames anymore. Searches through the game
- # folders and RTPs (even custom ones) and adds all the images for each.
- # - Improved look/layout.
- # - Added "Hide" button to make windows invisible while held to better
- # view the effect you are testing.
- # - Configurable call button to bring up the menu.
- # - Compatible with Zer0 Advanced Weather 2.0 (not available at release)
- # - Added the following features to test:
- # - Test animations on the map. (All)
- # - Test pictures on the map. (All)
- # - Blend type for fog
- # - Duration for screen shakes and weather.
- #
- # v.2.1 (2.13.2011)
- # - Fixed a bug that would prevent the fog scroll values from going below 100. (Thanks Taiine)
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #
- # Compatibility:
- # - No known script compatibility issues.
- #
- # Explanation:
- # Basically just a Debug Menu for screen effects. Allows player to change/test
- # an assortment of different screen effects in real-time to help find one that
- # looks good.
- #
- # Features:
- # - All of effects below can be altered while test playing:
- # - Change the screen tone (R, G, B, Gr)
- # - Change weather (Type, Power, Duration, Variation)
- # - Test screen shakes (Power, Speed, Duration)
- # - Change fog (Type, Opacity, Blend-Type, Zoom, Hue, Scroll)
- # - Change panorama (Name, Hue)
- # - Test animations (Name, X, Y)
- # - Test pictures (Name, X, Y, Opacity, Zoom, Blend Type, Angle)
- #
- # Instructions:
- # - Place script above Main and below other default scripts.
- # - During test play, press F8 (default) to bring up the menu.
- #
- # Notes:
- # - None of the changes will be saved, this is merely a tool to help make
- # life easier when trying to find a good screen effect.
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #===============================================================================
- # ** Scene_ScreenTest
- #===============================================================================
- class Scene_ScreenTest
- #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
- # BEGIN CONFIGURATION
- #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
- WEATHER_TYPES = 32
- # Number of weather types used in your game. If using Zer0 Advanced Weather
- # version 2.0 or higher, you do not need to configure this.
- WINDOW = ['Candara', 20, 160] # [FONTNAME, FONTSIZE, OPACITY]
- # Settings for the window. Purely aesthetic. No one else should ever see it.
- CALL_BUTTON = Input::F8
- # Button used to call scene from Scene_Map.
- HIDE_BUTTON = Input::SHIFT
- # Button used to hide the windows. Windows will not be visible while held.
- #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
- # END CONFIGURATION
- #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
- def main
- # Make map sprite.
- @map = Spriteset_Map.new
- # Set current screen tone.
- @tone = [$game_screen.tone.red, $game_screen.tone.green,
- $game_screen.tone.blue, $game_screen.tone.gray]
- # Set current weather type, power, and duration.
- @weather = [$game_screen.weather_type, $game_screen.weather_max, 0]
- # Set name, hue, opacity, zoom, blend type, sx, and sy of current fog.
- @fog = [$game_map.fog_name, $game_map.fog_hue, $game_map.fog_opacity,
- $game_map.fog_zoom, $game_map.fog_blend_type, $game_map.fog_sx, $game_map.fog_sy]
- # Set name and hue of current panorama.
- @panorama = [$game_map.panorama_name, $game_map.panorama_hue]
- # Set shake.
- @shake = [0, 0, 0]
- # Set animation.
- @animation = ['None', 0, 0]
- # Set picture.
- @picture = ['None', 0, 0, 255, 1.0, 0, 0]
- # Find all filenames of panoramas, fogs, and pictures in the game.
- find_graphics
- # Create the main window.
- commands = %w{ Tone Weather Fog Panorama Shake Animation Picture }
- @main_window = Window_Command.new(128, commands)
- # Set strings for the menu options.
- @commands = [
- ['Red', 'Green', 'Blue', 'Gray'],
- ['Type', 'Power', 'Duration'],
- ['Name', 'Hue', 'Opacity', 'Zoom', 'Blend Type', 'Scroll-X', 'Scroll-Y'],
- ['Name', 'Hue'],
- ['Power', 'Speed', 'Duration'],
- ['Name', 'Map-X', 'Map-Y', 'Play Animation'],
- ['Name', 'X', 'Y', 'Opacity', 'Zoom', 'Blend Type', 'Angle']
- ]
- # Check for variable used in Zer0 Advanced Weather and MAWS.
- if defined?($game_screen.weather_variation)
- @weather.push($game_screen.weather_variation)
- @commands[1].push('Variation')
- end
- # Create window array. Holds all created windows for easy handling.
- @windows = [@main_window]
- # Set font name, font size, and opacity of main window.
- set_window_info(@main_window)
- # Transition graphics and begin main loop.
- Graphics.transition
- loop { Graphics.update; Input.update; update; break if $scene != self }
- # Dispose of the sprites.
- (@windows + [@map]).each {|sprite| sprite.dispose }
- end
- #-------------------------------------------------------------------------------
- def update
- if Input.trigger?(Input::Z)
- p 'Fogs', "", @fogs, '',
- 'Panoramas', "", @panoramas, '',
- 'Pictures', "Index: #{@pic_index}", @pictures
- end
- # Update window and map sprites.
- (@windows + [@map, $game_screen, $game_map]).each {|object| object.update }
- # Check for input.
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- if @main_window.active
- # Return to map if main window is active.
- $scene = Scene_Map.new
- else
- # Else find active window, deactivate it, and return to main window.
- active_window = @windows.find {|window| window.active }
- active_window.active = active_window.visible = false
- @main_window.active = true
- end
- return
- elsif Input.trigger?(Input::LEFT) || Input.repeat?(Input::LEFT)
- $game_system.se_play($data_system.cursor_se)
- @value = Input.trigger?(Input::LEFT) ? -1 : -5
- elsif Input.trigger?(Input::RIGHT) || Input.repeat?(Input::RIGHT)
- $game_system.se_play($data_system.cursor_se)
- @value = Input.trigger?(Input::RIGHT) ? 1 : 5
- elsif Input.press?(HIDE_BUTTON)
- memory = @windows.collect {|window| window.visible }
- @windows.each {|window| window.visible = false }
- while Input.press?(HIDE_BUTTON)
- Graphics.update; Input.update; update
- end
- @windows.each_index {|i| @windows[i].visible = memory[i] }
- end
- # Branch update method by what window is active.
- if @main_window.active
- update_main
- elsif @tone_window != nil && @tone_window.active
- update_tone
- elsif @weather_window != nil && @weather_window.active
- update_weather
- elsif @fog_window != nil && @fog_window.active
- update_fog
- elsif @panorama_window != nil && @panorama_window.active
- update_panorama
- elsif @shake_window != nil && @shake_window.active
- update_shake
- elsif @animation_window != nil && @animation_window.active
- update_animation
- elsif @picture_window != nil && @picture_window.active
- update_picture
- end
- # Reset @value variable at end of every update
- @value = nil
- end
- #-------------------------------------------------------------------------------
- def update_main
- if Input.trigger?(Input::C)
- # Play SE and deactivate main window.
- $game_system.se_play($data_system.decision_se)
- @main_window.active = false
- # Branch by main window index, creating new windows when needed.
- case @main_window.index
- when 0 # Tone
- if @tone_window == nil
- @tone_window = Window_Command.new(160, @commands[0])
- set_window_info(@tone_window)
- @windows.push(@tone_window)
- end
- @tone_window.active = @tone_window.visible = true
- when 1 # Weather
- if @weather_window == nil
- @weather_window = Window_Command.new(160, @commands[1])
- set_window_info(@weather_window)
- @windows.push(@weather_window)
- @weather_index = @weather[0]
- # Create an array of possible weather types.
- if $zer0_adv_weather != nil && $zer0_adv_weather >= 2.0
- @weather_types = $weather_cache.bitmaps.keys.sort
- else
- @weather_types = []
- (0..WEATHER_TYPES).each {|i| @weather_types.push(i) }
- end
- end
- @weather_window.active = @weather_window.visible = true
- when 2 # Fog
- if @fog_window == nil
- @fog[0] = 'None' if @fog[0] == ''
- @fog_index = @fogs.index(@fog[0])
- @fog_window = Window_Command.new(256, @commands[2])
- set_window_info(@fog_window)
- @windows.push(@fog_window)
- end
- @fog_window.active = @fog_window.visible = true
- when 3 # Panorama
- if @panorama_window == nil
- @panorama[0] = 'None' if @fog[0] == ''
- @panorama_index = @panoramas.index(@panorama[0])
- @panorama_window = Window_Command.new(256, @commands[3])
- set_window_info(@panorama_window)
- @windows.push(@panorama_window)
- end
- @panorama_window.active = @panorama_window.visible = true
- when 4 # Shake
- if @shake_window == nil
- @shake_window = Window_Command.new(160, @commands[4])
- set_window_info(@shake_window)
- @windows.push(@shake_window)
- end
- @shake_window.active = @shake_window.visible = true
- when 5 # Animation
- if @animation_window == nil
- @animation_index = 0
- @animation_window = Window_Command.new(256, @commands[5])
- set_window_info(@animation_window)
- @windows.push(@animation_window)
- end
- @animation_window.active = @animation_window.visible = true
- when 6 # Picture
- if @picture_window == nil
- @pic_index = 0
- @picture_window = Window_Command.new(256, @commands[6])
- set_window_info(@picture_window)
- @windows.push(@picture_window)
- end
- @picture_window.active = @picture_window.visible = true
- end
- # Set value to nil and refresh the activated window
- @value = nil
- refresh_window
- end
- end
- #-------------------------------------------------------------------------------
- def refresh_window
- # Refresh active window.
- case @main_window.index
- when 0 # Tone
- @tone_window.contents.clear
- @tone.each_index {|i|
- @tone_window.contents.draw_text(4, i*32, 128, 32, @commands[0][i])
- @tone_window.contents.draw_text(-4, i*32, 128, 32, @tone[i].to_i.to_s, 2) \
- }
- when 1 # Weather
- @weather_window.contents.clear
- @weather.each_index {|i|
- @weather_window.contents.draw_text(4, i*32, 128, 32, @commands[1][i])
- @weather_window.contents.draw_text(-4, i*32, 128, 32, @weather[i].to_i.to_s, 2)
- }
- when 2 # Fog
- @fog_window.contents.clear
- @fog.each_index {|i|
- @fog_window.contents.draw_text(4, i*32, 224, 32, @commands[2][i])
- @fog_window.contents.draw_text(-4, i*32, 224, 32, @fog[i].to_s, 2)
- }
- when 3 # Panorama
- @panorama_window.contents.clear
- @panorama.each_index {|i|
- @panorama_window.contents.draw_text(4, i*32, 224, 32, @commands[3][i])
- @panorama_window.contents.draw_text(-4, i*32, 224, 32, @panorama[i].to_s, 2)
- }
- when 4 # Shake
- @shake_window.contents.clear
- @shake.each_index {|i|
- @shake_window.contents.draw_text(4, i*32, 128, 32, @commands[4][i])
- @shake_window.contents.draw_text(-4, i*32, 128, 32, @shake[i].to_s, 2)
- }
- when 5 # Animation
- @animation_window.contents.clear
- @commands[5].each_index {|i|
- @animation_window.contents.draw_text(4, i*32, 224, 32, @commands[5][i])
- @animation_window.contents.draw_text(-4, i*32, 224, 32, @animation[i].to_s, 2)
- }
- when 6 # Picture
- @picture_window.contents.clear
- @picture.each_index {|i|
- @picture_window.contents.draw_text(4, i*32, 224, 32, @commands[6][i])
- @picture_window.contents.draw_text(-4, i*32, 224, 32, @picture[i].to_s, 2)
- }
- end
- end
- #-------------------------------------------------------------------------------
- def update_tone
- if @value != nil
- index = @tone_window.index
- @tone[index] += @value
- if index == 3
- @tone[index] %= 256
- else
- @tone[index] = 255 if @tone[index] < -255
- @tone[index] = -255 if @tone[index] > 255
- end
- tone = Tone.new(@tone[0], @tone[1], @tone[2], @tone[3])
- @tone[3] = 0 if @tone[3] < 0
- $game_screen.start_tone_change(tone, 0)
- refresh_window
- end
- end
- #-------------------------------------------------------------------------------
- def update_weather
- if @value != nil
- index = @weather_window.index
- case index
- when 0
- @weather_index = (@weather_index + @value) % @weather_types.size
- @weather[0] = @weather_types[@weather_index]
- when 1
- @weather[1] = (@weather[1] + @value) % 51
- when 2, 3
- @weather[index] = (@weather[index] + @value) % 1000
- end
- # Apply weather effect to screen.
- if @weather.size == 4
- $game_screen.weather(@weather[0], @weather[1], @weather[2], @weather[3])
- else
- $game_screen.weather(@weather[0], @weather[1], @weather[2])
- end
- refresh_window
- end
- end
- #-------------------------------------------------------------------------------
- def update_fog
- if @value != nil
- index = @fog_window.index
- if index == 0
- @fog_index = (@fog_index + @value) % @fogs.size
- @fog[0] = @fogs[@fog_index]
- else
- @fog[index] += @value
- end
- @fog[1] %= 360
- @fog [2] %= 256
- @fog[3] = [[@fog[3], 100].max, 800].min
- @fog[4] %= 3
- $game_map.fog_name = @fog[0] == 'None' ? '' : @fog[0]
- $game_map.fog_opacity, $game_map.fog_zoom = @fog[2], @fog[3]
- $game_map.fog_blend_type, $game_map.fog_hue = @fog[4], @fog[1]
- $game_map.fog_sx, $game_map.fog_sy = @fog[5], @fog[6]
- refresh_window
- end
- end
- #-------------------------------------------------------------------------------
- def update_panorama
- if @value != nil
- if @panorama_window.index == 0
- @panorama_index = (@value + @panorama_index) % @panoramas.size
- @panorama[0] = @panoramas[@panorama_index]
- else
- @panorama[1] += @value
- end
- @panorama[1] %= 360
- $game_map.panorama_name = @panorama[0] == 'None' ? '' : @panorama[0]
- $game_map.panorama_hue = @panorama[1]
- refresh_window
- end
- end
- #-------------------------------------------------------------------------------
- def update_shake
- if @value != nil
- $game_system.se_play($data_system.cursor_se)
- index = @shake_window.index
- @shake[index] += @value
- [0, 1].each {|i| @shake[i] %= 30 }
- @shake[2] %= 1000
- $game_screen.start_shake(@shake[0], @shake[1], @shake[2])
- refresh_window
- end
- end
- #-------------------------------------------------------------------------------
- def update_animation
- if Input.trigger?(Input::C) && @animation_window.index == 3
- animation = $data_animations[@animation_index]
- return if animation == nil
- @map.make_animation(@animation_index, @animation[1], @animation[2])
- end
- if @value != nil
- case @animation_window.index
- when 0
- @animation_index = (@animation_index + @value) % $data_animations.size
- if $data_animations[@animation_index] == nil
- @animation[0] = 'None'
- else
- name = $data_animations[@animation_index].name
- @animation[0] = name == '' ? "(#{@animation_index})" : name
- end
- when 1
- @animation[1] = (@animation[1] + @value) % $game_map.width
- when 2
- @animation[2] = (@animation[2] + @value) % $game_map.height
- end
- refresh_window
- end
- end
- #-------------------------------------------------------------------------------
- def update_picture
- if @value != nil
- index = @picture_window.index
- if index == 0
- @pic_index = (@pic_index + @value) % @pictures.size
- elsif index == 4
- @picture[4] += (@value / 10.0)
- else
- @picture[index] += @value
- end
- @picture[0] = @pic_index == 0 ? 'None' : @pictures[@pic_index]
- @picture[3] %= 256
- @picture[4] = [[@picture[4], 1.0].max, 10.0].min
- @picture[5] %= 3
- @picture[6] %= 360
- # Draw sprite.
- @map.make_picture(@picture)
- refresh_window
- end
- end
- #-------------------------------------------------------------------------------
- def set_window_info(window)
- # Set the configured look to all the windows as they are made.
- window.contents.font.name = WINDOW[0]
- window.contents.font.size = WINDOW[1]
- window.back_opacity = WINDOW[2]
- window.x = window == @main_window ? 0 : 128
- window.refresh
- end
- #-------------------------------------------------------------------------------
- def find_graphics
- # Search "Fogs", "Panoramas", and "Pictures" folder for files.
- @fogs = Dir.entries('Graphics/Fogs')
- @panoramas = Dir.entries('Graphics/Panoramas')
- @pictures = Dir.entries('Graphics/Pictures')
- # Add all files from RTP into their respective arrays.
- rtp_paths.each {|path|
- @fogs += Dir.entries(path + '\Graphics\Fogs')
- @panoramas += Dir.entries(path + '\Graphics\Panoramas')
- }
- # Iterate through combined folders, and omit all non-image files.
- [@fogs, @panoramas, @pictures].each {|folder|
- folder.collect! {|file|
- if ['.png', '.jpg'].include?(File.extname(file))
- # Remove file extension.
- file.gsub!(/.png|.jpg/) {''}
- end
- }
- # Remove nil elements and add 'None' string to each array.
- folder.unshift('None').compact!
- }
- end
- #-------------------------------------------------------------------------------
- def rtp_paths
- paths = []
- [1, 2, 3].each {|id|
- paths.push(RGSSGetPathWithRTP.call(RGSSGetRTPPath.call(id))) }
- return paths.find_all {|path| path != '' }
- end
- #-------------------------------------------------------------------------------
- end
- # DO NOT edit any of these lines. They are used to gather the RTP data.
- # Get the dll used for the game.
- GPPSA = Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L')
- dll = "\0" * 255
- GPPSA.call('Game', 'Library', '', dll, 255, '.\\Game.ini')
- dll.delete!("\0")
- # Set constants to call path with.
- RGSSGetRTPPath = Win32API.new(dll, 'RGSSGetRTPPath', 'L', 'L')
- RGSSGetPathWithRTP = Win32API.new(dll, 'RGSSGetPathWithRTP', 'L', 'P')
- #===============================================================================
- # ** Scene_Map
- #===============================================================================
- class Scene_Map
- # Add call button to Scene_Map
- alias zer0_screentest_map_upd update
- def update
- zer0_screentest_map_upd
- if $DEBUG && Input.trigger?(Scene_ScreenTest::CALL_BUTTON)
- $scene = Scene_ScreenTest.new
- end
- end
- end
- #===============================================================================
- # ** Spriteset_Map
- #===============================================================================
- class Spriteset_Map
- # Creates an event on the fly, plays the animation, then disposes it.
- def make_animation(animation_id, x, y)
- event = Game_Event.new($game_map.map_id, RPG::Event.new(x, y))
- event.animation_id = animation_id
- sprite = Sprite_Character.new(@viewport1, event)
- # Loop Graphics and sprite update as long as animation is occurring.
- while sprite.effect?
- sprite.update
- Graphics.update
- end
- sprite.dispose
- end
- def make_picture(data)
- # Create sprite if it does not exist.
- if @pic == nil
- @pic = Sprite.new(@viewport2)
- # Add to picture array, so it automatically updates and disposes.
- @picture_sprites.push(@pic)
- end
- # Clear bitmap and end method if no bitmap is defined.
- if data[0] == 'None'
- @pic.bitmap.clear if @pic.bitmap != nil
- return
- end
- # Set the configured data to the picture.
- @pic.bitmap = RPG::Cache.picture(data[0]).clone
- @pic.x, @pic.y, @pic.opacity, @pic.angle = data[1], data[2], data[3], data[6]
- @pic.zoom_x, @pic.zoom_y, @pic.blend_type = data[4], data[4], data[5]
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement