Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Leon_Westbrooke on July 19, 2009, 07:08:27 pm

Title: [XP] Screen Fog Debug menu
Post by: Leon_Westbrooke on July 19, 2009, 07:08:27 pm
Screen Fog Debug Menu
Authors: Leon_Westbrooke
Version: 1.1
Type: Debug System


Introduction
This script is designed to assist in setting the fog exactly right in an RmXP project.



Features
Allows you to set the fog in-game and see what it looks like at that exact moment.



Screenshots
'screenshot': ShowHide

(http://i50.photobucket.com/albums/f310/virtuouspaladin9/FogDisplay.png)




Script
'fogdebug': ShowHide
#===============================================================================
#  Leon_Westbrooke's Fog Debug Menu  (a.k.a. Leon)
#-------------------------------------------------------------------------------
#  Release: July 1st, 2009
#  version: 1.0
#-------------------------------------------------------------------------------
#  Instructions:
# Place above Main, but below all other default scripts.
# Any imported fogs must be added to the 'Names' array in the 'Fogs' module.
# Press F6 in Debug mode to call up this menu.
# Use the various controls to set your fog.
#-------------------------------------------------------------------------------
#  Features:
# Allows you to choose a fog for your current map, and set the following
# parameters:
#  Hue
#  Opacity
#  Blending
#  Starting Location (x and y)
#  Speed of Fog Scrolling (x and y)
#  Zoom
#  Tone
#
# This will only give you the values.  You MUST set these values up in an
# event to get the effect of them.  So, in essence, this to keep from having
# to test over and again.
#-------------------------------------------------------------------------------
#  Notes:
# The Starting Locations (ox and oy) will go haywire if you set the speed
# scroll options.  This is normal as it is just showing its current x and y
# of the upper left corner of the original fog graphic.
#-------------------------------------------------------------------------------
#  Credits:
# Credits go to Leon/Leon_Westbrooke for this one. It is really the same
# person.  I just added the '_Westbrooke' to I.D. myself better.
#-------------------------------------------------------------------------------


#===============================================================================
#  *  module Fogs
#===============================================================================
module Fogs
 #------------------------------------------------------------
 #  Add any imported fogs to this list.
 #------------------------------------------------------------
 Names = [ '',
'001-Fog01',
'002-Clouds01',
'003-Shade01',
'004-Shade02',
'005-Sandstorm01',
'006-Sandstorm02',
'007-Water01',
'008-Water02',
'009-Water03',
'010-Water04']
end
#===============================================================================
#  *  END Module
#===============================================================================



#===============================================================================
#  *  Game_Map
#===============================================================================
class Game_Map
 attr_accessor :fog_ox
 attr_accessor :fog_oy
 attr_accessor :fog_tone
end
#===============================================================================
# END Game_Map
#===============================================================================


#===============================================================================
#  *  Scene_Map
#===============================================================================
class Scene_Map
 
 alias leon_fogdebug_scenemap_update update

 def update
leon_fogdebug_scenemap_update
if $DEBUG and Input.press?(Input::F6)
 $scene = Scene_FogChange.new
end
 end
end
#===============================================================================
# END Scene_Map
#===============================================================================


#===============================================================================
#  *  Window_FogNames
#===============================================================================
class Window_FogNames < Window_Selectable
 def initialize
super(0, 0, 192, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = Fogs::Names.size
@index = 0
@active = true
self.opacity = 96
refresh
 end
 
 def item
return @data[index]
 end
 
 
 def refresh
if self.contents != nil
 self.contents.dispose
 self.contents = nil
end
@data = []
for i in 0...Fogs::Names.size
 @data.push(Fogs::Names[i])
end
@item_max = @data.size
if @item_max > 0
 self.contents = Bitmap.new(width - 32, row_max * 32)
 for i in 0...@item_max
draw_item(i)
 end
end
 end
 
 def draw_item(index)
item = @data[index]
x = 4
y = index * 32
self.contents.draw_text(x, y, 160, 32, item)
 end
end
#===============================================================================
# END Window_FogNames
#===============================================================================


#===============================================================================
#  *  Window_FogSettings
#===============================================================================
class Window_FogSettings < Window_Selectable
 def initialize
super(0, 160, 192, 288)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 8
self.index = -1
self.active = false
self.opacity = 96
refresh
 end
 
 def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 128, 32, "Hue:")
self.contents.draw_text(0, 32, 128, 32, "Opacity:")
self.contents.draw_text(0, 64, 128, 32, "Blending:")
self.contents.draw_text(0, 96, 128, 32, "Starting X:")
self.contents.draw_text(0, 128, 128, 32, "Starting Y:")
self.contents.draw_text(0, 160, 128, 32, "Move X:")
self.contents.draw_text(0, 192, 128, 32, "Move Y:")
self.contents.draw_text(0, 224, 128, 32, "Zoom:")

self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 160, 32, $game_map.fog_hue.to_s, 2)
self.contents.draw_text(0, 32, 160, 32, $game_map.fog_opacity.to_s, 2)
self.contents.draw_text(0, 64, 160, 32, $game_map.fog_blend_type.to_s, 2)
self.contents.draw_text(0, 96, 160, 32, $game_map.fog_ox.to_s, 2)
self.contents.draw_text(0, 128, 160, 32, $game_map.fog_oy.to_s, 2)
self.contents.draw_text(0, 160, 160, 32, $game_map.fog_sx.to_s, 2)
self.contents.draw_text(0, 192, 160, 32, $game_map.fog_sy.to_s, 2)
self.contents.draw_text(0, 224, 160, 32, $game_map.fog_zoom.to_s, 2)
 end
 
 def update_cursor_rect

if @index < 0
 self.cursor_rect.empty
else
 self.cursor_rect.set(100, @index * 32, 64, 32)
end
 end
end
#===============================================================================
# END Window_FogSettings
#===============================================================================


#===============================================================================
#  *  Window_FogTint
#===============================================================================
class Window_FogTint < Window_Selectable
 def initialize
super(192, 0, 192, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 4
self.index = -1
self.active = false
self.opacity = 96
refresh
 end
 
 def refresh
self.contents.clear
self.contents.draw_text(4, 0, 160, 32, "Red")
self.contents.draw_text(4, 32, 160, 32, "Green")
self.contents.draw_text(4, 64, 160, 32, "Blue")
self.contents.draw_text(4, 96, 160, 32, "Gray")
self.contents.draw_text(-4, 0, 160, 32, $game_map.fog_tone.red.to_i.to_s, 2)
self.contents.draw_text(-4, 32, 160, 32, $game_map.fog_tone.green.to_i.to_s, 2)
self.contents.draw_text(-4, 64, 160, 32, $game_map.fog_tone.blue.to_i.to_s, 2)
self.contents.draw_text(-4, 96, 160, 32, $game_map.fog_tone.gray.to_i.to_s, 2)
 end
end
#===============================================================================
# END Window_FogTint
#===============================================================================


#===============================================================================
#  *  Scene_FogChange
#===============================================================================
class Scene_FogChange
 def main
@spriteset = Spriteset_Map.new
@name_window = Window_FogNames.new
@settings_window = Window_FogSettings.new
@tint_window = Window_FogTint.new

Graphics.transition
loop do
 Graphics.update
 Input.update
 update
 if $scene != self
break
 end
end
Graphics.freeze

@name_window.dispose
@settings_window.dispose
@spriteset.dispose
@tint_window.dispose
 end
 
 def update
$game_map.update
@spriteset.update

if @name_window.active
 update_name
 return
end

if @settings_window.active
 update_settings
 return
end

if @tint_window.active
 update_tint
 return
end
 end
 
 def update_name
@name_window.update
if Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or Input.repeat?(Input::DOWN) or Input.repeat?(Input::UP)
 $game_map.fog_name = @name_window.item
end
if Input.trigger?(Input::C)
 @name_window.active = false
 @settings_window.active = true
 @settings_window.index = 0
end
if Input.trigger?(Input::B)
 $game_system.se_play($data_system.decision_se)
 $scene = Scene_Map.new
end
 end
 
 def update_settings
@settings_window.update
case @settings_window.index
when 0
 if Input.trigger?(Input::RIGHT)
$game_map.fog_hue += 1
if $game_map.fog_hue >= 360
 $game_map.fog_hue = 360
end
@settings_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_hue -= 1
if $game_map.fog_hue <= 0
 $game_map.fog_hue = 0
end
@settings_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_hue += 5
if $game_map.fog_hue >= 360
 $game_map.fog_hue = 360
end
@settings_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_hue -= 5
if $game_map.fog_hue <= 0
 $game_map.fog_hue = 0
end
@settings_window.refresh
 end
when 1
 if Input.trigger?(Input::RIGHT)
$game_map.fog_opacity += 1
if $game_map.fog_opacity >= 255
 $game_map.fog_opacity = 255
end
@settings_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_opacity -= 1
if $game_map.fog_opacity <= 0
 $game_map.fog_opacity = 0
end
@settings_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_opacity += 5
if $game_map.fog_opacity >= 255
 $game_map.fog_opacity = 255
end
@settings_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_opacity -= 5
if $game_map.fog_opacity <= 0
 $game_map.fog_opacity = 0
end
@settings_window.refresh
 end
when 2
 if Input.trigger?(Input::RIGHT)
$game_map.fog_blend_type += 1
if $game_map.fog_blend_type >= 2
 $game_map.fog_blend_type = 2
end
@settings_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_blend_type -= 1
if $game_map.fog_blend_type <= 0
 $game_map.fog_blend_type = 0
end
@settings_window.refresh
 end
when 3
 if Input.trigger?(Input::RIGHT)
$game_map.fog_ox += 0.1
if $game_map.fog_ox >= 640
 $game_map.fog_ox = 640
end
@settings_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_ox -= 0.1
if $game_map.fog_ox <= -640
 $game_map.fog_ox = -640
end
@settings_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_ox += 0.5
if $game_map.fog_ox >= 640
 $game_map.fog_ox = 640
end
@settings_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_ox -= 0.5
if $game_map.fog_ox <= -640
 $game_map.fog_ox = -640
end
@settings_window.refresh
 end
when 4
 if Input.trigger?(Input::RIGHT)
$game_map.fog_oy += 0.1
if $game_map.fog_oy >= 640
 $game_map.fog_oy = 640
end
@settings_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_oy -= 0.1
if $game_map.fog_oy <= -640
 $game_map.fog_oy = -640
end
@settings_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_oy += 0.5
if $game_map.fog_oy >= 640
 $game_map.fog_oy = 640
end
@settings_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_oy -= 0.5
if $game_map.fog_oy <= -640
 $game_map.fog_oy = -640
end
@settings_window.refresh
 end
when 5
 if Input.trigger?(Input::RIGHT)
$game_map.fog_sx += 1
if $game_map.fog_sx >= 256
 $game_map.fog_sx = 256
end
@settings_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_sx -= 1
if $game_map.fog_sx <= -256
 $game_map.fog_sx = -256
end
@settings_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_sx += 5
if $game_map.fog_sx >= 256
 $game_map.fog_sx = 256
end
@settings_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_sx -= 5
if $game_map.fog_sx <= -256
 $game_map.fog_sx = -256
end
@settings_window.refresh
 end
when 6
 if Input.trigger?(Input::RIGHT)
$game_map.fog_sy += 1
if $game_map.fog_sy >= 256
 $game_map.fog_sy = 256
end
@settings_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_sy -= 1
if $game_map.fog_sy <= -256
 $game_map.fog_sy = -256
end
@settings_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_sy += 5
if $game_map.fog_sy >= 256
 $game_map.fog_sy = 256
end
@settings_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_sy -= 5
if $game_map.fog_sy <= -256
 $game_map.fog_sy = -256
end
@settings_window.refresh
 end
when 7
 if Input.trigger?(Input::RIGHT)
$game_map.fog_zoom += 1
if $game_map.fog_zoom >= 800
 $game_map.fog_zoom = 800
end
@settings_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_zoom -= 1
if $game_map.fog_zoom <= 100
 $game_map.fog_zoom = 100
end
@settings_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_zoom += 5
if $game_map.fog_zoom >= 800
 $game_map.fog_zoom = 800
end
@settings_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_zoom -= 5
if $game_map.fog_zoom <= 100
 $game_map.fog_zoom = 100
end
@settings_window.refresh
 end
end
if Input.trigger?(Input::C)
 @settings_window.index = -1
 @settings_window.active = false
 @tint_window.active = true
 @tint_window.index = 0
end
if Input.trigger?(Input::B)
 $game_system.se_play($data_system.cancel_se)
 @name_window.active = true
 @settings_window.index = -1
 @settings_window.active = false
end
 end
 
 def update_tint
@tint_window.update
case @tint_window.index
when 0
 if Input.trigger?(Input::RIGHT)
$game_map.fog_tone.red += 1
if $game_map.fog_tone.red >= 255
 $game_map.fog_tone.red = 255
end
@tint_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_tone.red -= 1
if $game_map.fog_tone.red <= -255
 $game_map.fog_tone.red = -255
end
@tint_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_tone.red += 5
if $game_map.fog_tone.red >= 255
 $game_map.fog_tone.red = 255
end
@tint_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_tone.red -= 5
if $game_map.fog_tone.red <= -255
 $game_map.fog_tone.red = -255
end
@tint_window.refresh
 end
when 1
 if Input.trigger?(Input::RIGHT)
$game_map.fog_tone.green += 1
if $game_map.fog_tone.green >= 255
 $game_map.fog_tone.green = 255
end
@tint_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_tone.green -= 1
if $game_map.fog_tone.green <= -255
 $game_map.fog_tone.green = -255
end
@tint_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_tone.green += 5
if $game_map.fog_tone.green >= 255
 $game_map.fog_tone.green = 255
end
@tint_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_tone.green -= 5
if $game_map.fog_tone.green <= -255
 $game_map.fog_tone.green = -255
end
@tint_window.refresh
 end
when 2
 if Input.trigger?(Input::RIGHT)
$game_map.fog_tone.blue += 1
if $game_map.fog_tone.blue >= 255
 $game_map.fog_tone.blue = 255
end
@tint_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_tone.blue -= 1
if $game_map.fog_tone.blue <= -255
 $game_map.fog_tone.blue = -255
end
@tint_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_tone.blue += 5
if $game_map.fog_tone.blue >= 255
 $game_map.fog_tone.blue = 255
end
@tint_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_tone.blue -= 5
if $game_map.fog_tone.blue <= -255
 $game_map.fog_tone.blue = -255
end
@tint_window.refresh
 end
when 3
 if Input.trigger?(Input::RIGHT)
$game_map.fog_tone.gray += 1
if $game_map.fog_tone.gray >= 255
 $game_map.fog_tone.gray = 255
end
@tint_window.refresh
 elsif Input.trigger?(Input::LEFT)
$game_map.fog_tone.gray -= 1
if $game_map.fog_tone.gray <= -255
 $game_map.fog_tone.gray = -255
end
@tint_window.refresh
 elsif Input.repeat?(Input::RIGHT)
$game_map.fog_tone.gray += 5
if $game_map.fog_tone.gray >= 255
 $game_map.fog_tone.gray = 255
end
@tint_window.refresh
 elsif Input.repeat?(Input::LEFT)
$game_map.fog_tone.gray -= 5
if $game_map.fog_tone.gray <= -255
 $game_map.fog_tone.gray = -255
end
@tint_window.refresh
 end
end
if Input.trigger?(Input::C)
 $game_system.se_play($data_system.decision_se)
 $scene = Scene_Map.new
end
if Input.trigger?(Input::B)
 @tint_window.active = false
 @tint_window.index = -1
 @settings_window.active = true
 @settings_window.index = 0
end
 end
end
#===============================================================================
# END Scene_FogChange
#===============================================================================




Instructions
Place the script below the default scripts, and above main.
In game, press 'F6' to access the Fog debug menu.



Compatibility
No known issues.



Credits and Thanks




Author's Notes
Title: Re: Screen Fog Debug menu.
Post by: G_G on July 19, 2009, 07:27:45 pm
Awesome script! *lv's up* Here's the template all setup for you.

you should apply the template
Title: Re: [XP]Screen Fog Debug menu.
Post by: Aqua on July 19, 2009, 07:50:21 pm
I fixed the template for you.

Good looking script.