[XP] Zer0 Options Controller

Started by ForeverZer0, March 02, 2010, 04:23:39 pm

Previous topic - Next topic

ForeverZer0

March 02, 2010, 04:23:39 pm Last Edit: March 17, 2010, 05:57:24 pm by ForeverZero
Zer0 Options Controller
Authors: ForeverZero
Version: 2.1
Type: Options Controller
Key Term: Misc Add-on



Introduction

Custom "Option" system that can be used on the fly.


Features


  • No menu option, uses hot keys to change anytime on the game map.
  • Easily accessible
  • Very customizable
  • Can independently change the text font/size for the window base and message windows.
  • Can change windowskins on the fly.
  • Change color of any windowskin.
  • Can redefine what the "Normal" text color is.
  • Auto-Configuration
  • Plug & Play, no intensive configuration needed



Screenshots

None


Demo

http://www.mediafire.com/download.php?www1etgmkhj


Script

Spoiler: ShowHide

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Zer0 Options Controller
# By ForeverZer0
# Version: 2.1
# Date: 3.12.2010 (newest version)
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Version History
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Version 0.9 (2.28.2010)
#   - Original write and release. Not yet bug-free.
#
# Version 1.0 (3.4.2010)
#   - Improved coding slightly.
#   - Now disposes window when not in use to reduce lag
#
# Version 1.1 (3.5.2010)
#   - Removed some redundant code and improved some refresh/update methods
#   - Added the function so that changes can be made during battle
#   - Added a compatibility switch for Wachunga's MMW  
#   - Now 'Plug & Play', no intensive configuration needed
#
# Version 2.0 (3.10.2010)
#   - Totally overhauled. All configuration is in the module at the top.
#   - All fonts, skins, etc. were placed in arrays instead of branches
#   - Removed bug that would cause an error if the <, >, +, or - buttons
#     were pressed without holding 1, 2, or 3.
#   - Scrapped the opacity changer due to bugs and incompatibilty issues with
#     MMW that I couldn't work out, since the only way I know how to do it will
#     totally override all windows, which isn't always cool...
#
# Version 2.1 (3.12.2010)
#   - Can now change color of any windowskin (Provided it initially had color)
#   - Altered sample window to show font name and size as well as show the
#     name for the windowskin and windowskin color.
#   - Fixed small error that would allow the text size to be changed one
#     over/under the allowable size.
#   - Made a few minor improvements to the coding
#  
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#  - Will likely not not be compatible with an 'Options' menu or
#    system that alters the fonts, windowskins, etc.
#  - Compatible with SDK 1.5 and older. Not tested with newer versions,
#    though I don't believe there would be any incompatibility issues.
#
# Explanation:
#   This system will allow you to change the font type/size on the fly in
#   the game.  It will also allow the player to just as easily change the
#   windowskin. A sample window will pop up when holding any of the option
#   buttons to show the player the changes. It will dispose when the button is
#   released to keep it fom causing lag. The player can change the system font
#   (i.e. menus, etc.) seperately from the message window used for speech,
#   etc. if using Wachunga's Multiple Message Windows.
#
# Instructions:
#  - Configuration is below. You can add/remove as many different items from
#    the arrays, just make sure each item is seperated by a comma, and that
#    there is a bracket at the beginning and end ([ ]).
#  - All names for windowskins, fonts, etc are case sensitive and must be
#    spelled exactly the same as the filename.
#  - If you use this in your game, include an Auto-Font Installer with it
#    to make sure anyone who plays it will have all available fonts.
#
# To Use:
#  - Hold [1], press [<] and [>] to change system font, [+] and [-] for size.
#  - Hold [2], press [<] and [>] to change message font, [+] and [-] for size.
#  - Hold [3], press [<] and [>] to change skin, [+] and [-] for skin color.
#  - Hold [4], press [+] and [-] to change text color.
#
# Warnings:
#   Now, obviously making the text to big/small will cause graphical errors
#   and cause text to be cut-off, crammed together, etc., so use this with
#   a little common sense. If the minimum/maximum text size is set too small/big
#   it will cause an error, so make sure these are set within a usable range.
#
# Requirements:  
# - Need 'Blizzard's Custom Controls' to set-up controls (configuration below)
# - Script was written to be compatible with Wachanga's "Multiple Message
#   Windows". Therefore, not all of the features will be available if not
#   using this message system.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=                                  
# BEGIN Zer0 CONFIGURATION                                    
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

 # All changed settings will be saved with the gamefile.
 # Default settings will always be used on the title screen and will override
 # the settings in the database.
 
module Zer0_CFG
#-------------------------------------------------------------------------------

#   If you have Blizzard's Custom Controls script and have no other keys
#   assigned to the above defined buttons, just set this switch to true
#   for auto-configuration. Configuration for the keys is at the bottom of
#   the script if you wish to alter them for some reason.

     Blizzard_Controls_AutoConfig = true
     
     Wachunga_MMS = false # Set to true only if using Multiple Message Windows
     
#-------------------------------------------------------------------------------      

 # This defines the fonts used. Add or remove as many as needed.
 
 System_Fonts = ['Calibri', 'Comic Sans MS', 'Times New Roman', 'Candara',
                 'Arial', 'Tahoma', 'Tempus Sans ITC', 'Verdana',
                 'Century Gothic', 'Corbel', 'Segoe Print']
 
 Default_Font = ['Calibri', 18]   # <--- Default font and size
 Font_Size_Range = [10, 24] # Minimum/Maximum allowed values for the font size.
 
 # These will ONLY effect text that is 'normal_color'.
 Font_Color =  [ Color.new(255,255,255,255),   # White (Default Color)
                 Color.new(0,0,0,255),         # Black
                 Color.new(128,128,128,255),   # Gray
                 Color.new(64,64,64,255),      # Dark Gray
                 Color.new(255,128,128,255),   # Red
                 Color.new(128,128,255,255),   # Blue
                 Color.new(128,255,128,255),   # Green
                 Color.new(255,255,128,255) ]  # Yellow
                 # (Red, Green, Blue, Alpha)
                 
#-------------------------------------------------------------------------------  
 # If not using Wachanga's Multiple Message Windows, skip this section
 
 MMW_Fonts = ['Calibri', 'Comic Sans MS', 'Times New Roman', 'Candara',
                 'Arial', 'Tahoma', 'Tempus Sans ITC', 'Verdana',
                 'Century Gothic', 'Corbel', 'Segoe Print']
             
 Default_MMW_Font = ['Comic Sans MS', 17]  # <--- Default font and size          
 MMW_Font_Size_Range = [10, 24] # Min/Max allowed values for the font size.
 
 # Only change this if not using this windowskin for MMW
 MMW_Speech_Windowskin = 'white-windowskin_speech'
 
#-------------------------------------------------------------------------------
 
 Default_Windowskin = '001-Blue01'  # <--- Must be in array below
 
 Windowskins = ['Blizzard Hell Breath', 'Clover', 'Simple',
                 'Simple 2', '001-Blue01']
end
#-------------------------------------------------------------------------------
 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=                                  
# END Zer0 CONFIGURATION                                    
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
 Z = Zer0_CFG  # DO NOT edit this
#==============================================================================
# ** Game_System
#==============================================================================

class Game_System
 
 attr_accessor :textshade
 attr_accessor :fontsize
 attr_accessor :message_size_changer
 attr_accessor :skin_color

 alias zer0_customizer_init initialize
 def initialize
   zer0_customizer_init
   @fontname = Z::Default_Font[0]
   @fontsize = Z::Default_Font[1]
   @system_font_changer = Z::System_Fonts.index(@fontname)
   @system_size_changer = @fontsize
   @message_font_changer = Z::MMW_Fonts.index(Z::Default_MMW_Font[0])    
   @message_size_changer = Z::Default_MMW_Font[1]    
   @skintype = Z::Windowskins.index(Z::Default_Windowskin)
   @skin_color = @textshade = 0            
   check_for_window_change
 end

 def check_for_window_change
   @windowskin_name = Z::Windowskins[@skintype]
   @fontsize = @system_size_changer
   @fontname = Z::System_Fonts[@system_font_changer]
   Font.default_name = $defaultfonttype = $fontface = @fontname #**
   Font.default_size = $defaultfontsize = $fontsize = @fontsize #**
   if Z::Wachunga_MMS
     @message.font_name = Z::MMW_Fonts[@message_font_changer]
     @message.font_size = @message_size_changer
   end
 end
 
 #** = Credit goes to Blizzard for lines marked with this
                                                   
 alias zer0_customizer_upd update          
 def update                                            
   zer0_customizer_upd
   @fontsize = @system_size_changer
   @fontname = Z::System_Fonts[@system_font_changer]
   Font.default_name = $defaultfonttype = $fontface = @fontname #**
   Font.default_size = $defaultfontsize = $fontsize = @fontsize #**
   
   if Input.press?(Input::SYS_FONT)                
     if Input.trigger?(Input::OPT_LEFT)              
       @system_font_changer += 1                
       @system_font_changer %= Z::System_Fonts.size
     elsif Input.trigger?(Input::OPT_RIGHT)  
       @system_font_changer += (Z::System_Fonts.size - 1)
       @system_font_changer %= Z::System_Fonts.size
     elsif Input.trigger?(Input::OPT_DOWN)
       if @system_size_changer > Z::Font_Size_Range[0]
         @system_size_changer -= 1
       end
     elsif Input.trigger?(Input::OPT_UP)
       if @system_size_changer < Z::Font_Size_Range[1]
         @system_size_changer += 1
       end
     end
   end
   
   if Input.press?(Input::MMW_FONT) && Z::Wachunga_MMS                    
     if Input.trigger?(Input::OPT_LEFT)          
       @message_font_changer += 1                
       @message_font_changer %= Z::MMW_Fonts.size                        
     elsif Input.trigger?(Input::OPT_RIGHT)  
       @message_font_changer -= 1
       @message_font_changer %= Z::MMW_Fonts.size
     elsif Input.trigger?(Input::OPT_DOWN)
       if @message_size_changer > Z::MMW_Font_Size_Range[0]
         @message_size_changer -= 1
       end
     elsif Input.trigger?(Input::OPT_UP)
       if @message_size_changer < Z::MMW_Font_Size_Range[1]
         @message_size_changer += 1
       end  
     end
   end
     
   if Input.press?(Input::WINDOW)
     if Input.trigger?(Input::OPT_DOWN)  
       @skin_color -= 8                 # Color changes will only apply to
       @skin_color %= 360               # windowskins that initially have color
     elsif Input.trigger?(Input::OPT_UP)  
       @skin_color += 8
       @skin_color %= 360
     elsif Input.trigger?(Input::OPT_LEFT)  
       @skintype -= 1
       @skintype %= Z::Windowskins.size
     elsif Input.trigger?(Input::OPT_RIGHT)  
       @skintype += 1
       @skintype %= Z::Windowskins.size
     end
   end  

   if Input.press?(Input::COLOR)
      if Input.trigger?(Input::OPT_DOWN)  
       @textshade -= 1                  
       @textshade %= Z::Font_Color.size
     elsif Input.trigger?(Input::OPT_UP)  
       @textshade += 1
       @textshade %= Z::Font_Color.size
     end
   end

 end
end

#==============================================================================
# ** Window_Base
#==============================================================================
class Window_Base < Window
 # Redefines what the 'normal_color' for text is
 alias zer0_norm_color normal_color
 def normal_color  
   zer0_norm_color
   normal_color = Z::Font_Color[$game_system.textshade]
 end
end
 
#==============================================================================
# ** Window_Sample   (Simple window to show modifications on-screen)
#==============================================================================
class Window_Sample < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
   super(112, 108, 416, 264)  
   self.z = 9998
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh  # Refresh method if changing message window
   if Z::Wachunga_MMS && Input.press?(Input::MMW_FONT)
     self.contents.clear
     self.windowskin = RPG::Cache.windowskin(Z::MMW_Speech_Windowskin)
     self.contents.font.name = $game_system.message.font_name
     self.contents.font.size = $game_system.message.font_size
     self.contents.font.color = Color.new(0,0,0)
   else   # Normal refresh method
     self.windowskin = RPG::Cache.windowskin($game_system.windowskin_name)
     self.contents.clear
     self.contents.font.name = Font.default_name
     self.contents.font.size = Font.default_size
     self.contents.font.color = normal_color
   end
 
   # Define the strings used (Not needed, but keeps code neat)
   abctext = 'The quick brown fox jumped over the lazy dog.'
   numtext = '0 1 2 3 4 5 6 7 8 9'
   helptext = 'Press [+], [-], [<], or [>] to customize'
   sysfontname = "#{Font.default_name}"
   sysfontsize = "#{$game_system.fontsize}"
   messfontname = "#{$game_system.message.font_name}" if Z::Wachunga_MMS
   messfontsize = "#{$game_system.message_size_changer}" if Z::Wachunga_MMS
   skinname = "#{$game_system.windowskin_name}"
   skincolor = "#{($game_system.skin_color / 8) + 1}"
   
   # Recalculates the width of the text strings each time window refreshes
   w1 = contents.text_size('System Font').width
   w2 = contents.text_size('Message Font').width
   w3 = contents.text_size('System Window Base').width
   w4 = contents.text_size('Font Name:').width
   w5 = contents.text_size('Font Size:').width
   w6 = contents.text_size('Windowskin Name:').width
   w7 = contents.text_size(abctext).width
   w8 = contents.text_size(numtext).width
   w9 = contents.text_size(helptext).width
   w10 = contents.text_size(sysfontname).width
   w11 = contents.text_size(messfontname).width if Z::Wachunga_MMS
   w12 = contents.text_size(sysfontsize).width
   w13 = contents.text_size(messfontsize).width if Z::Wachunga_MMS
   w14 = contents.text_size(skinname).width
   w15 = contents.text_size('Windowskin Tone:').width
   w16 = contents.text_size(skincolor).width
   
   # Shows different info in window depending on button being pressed
   if Input.press?(Input::SYS_FONT)
     self.contents.font.color = system_color
     self.contents.draw_text(4, 0, w1, 32, 'System Font', 2)
     self.contents.draw_text(4, 96, w4, 32, 'Font Name:', 2)
     self.contents.draw_text(4, 128, w5, 32, 'Font Size:', 2)
     self.contents.draw_text(4, 192, w9, 32, helptext, 2)
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 32, w7, 32, abctext, 2)
     self.contents.draw_text(4, 64, w8, 32, numtext, 2)
     self.contents.draw_text(w4 + 15, 96, w10, 32, sysfontname, 2)
     self.contents.draw_text(w5 + 15, 128, w12, 32, sysfontsize, 2)
   elsif (Input.press?(Input::MMW_FONT) && Z::Wachunga_MMS)
     self.contents.font.color = Color.new(0, 64, 128)
     self.contents.draw_text(4, 0, w2, 32, 'Message Font', 2)
     self.contents.draw_text(4, 96, w4, 32, 'Font Name:', 2)
     self.contents.draw_text(4, 128, w5, 32, 'Font Size:', 2)
     self.contents.draw_text(4, 192, w9, 32, helptext, 2)
     self.contents.font.color = Color.new(0, 0, 0) # Dark font for whiteback
     self.contents.draw_text(4, 32, w7, 32, abctext, 2)
     self.contents.draw_text(4, 64, w8, 32, numtext, 2)
     self.contents.draw_text(w4 + 15, 96, w11, 32, messfontname, 2)
     self.contents.draw_text(w5 + 15, 128, w13, 32, messfontsize, 2)
   elsif (Input.press?(Input::MMW_FONT) && !Z::Wachunga_MMS)
     self.contents.font.name, self.contents.font.size = 'Arial Black', 18
     warn1 = 'This feature requires' # I gotta learn how to splice text... :P
     warn2 = "Wachanga's Multiple Message Windows!"
     ww1 = contents.text_size(warn1).width  
     ww2 = contents.text_size(warn2).width
     self.contents.draw_text(4, 64, ww1, 32, warn1, 2)
     self.contents.draw_text(4, 96, ww2, 32, warn2, 2)
   elsif Input.press?(Input::WINDOW) || Input.press?(Input::COLOR)
     self.contents.font.color = system_color
     self.contents.draw_text(4, 0, w3, 32, 'System Window Base', 2)
     self.contents.draw_text(4, 96, w6, 32, 'Windowskin Name:', 2)
     self.contents.draw_text(4, 128, w15, 32, 'Windowskin Tone:', 2)
     self.contents.draw_text(4, 192, w9, 32, helptext, 2)
     self.contents.font.color = normal_color
     self.contents.draw_text(4, 32, w7, 32, abctext, 2)
     self.contents.draw_text(4, 64, w8, 32, numtext, 2)
     self.contents.draw_text(w6 + 15, 96, w14, 32, skinname, 2)
     self.contents.draw_text(w15 + 15, 128, w16, 32, skincolor, 2)
   end
 end
end

#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
 
 alias sample_window_map_upd update
 def update
   sample_window_map_upd
   @sample_window.update if @sample_window != nil
   if Input.press?(Input::SYS_FONT) || Input.press?(Input::WINDOW) ||
      Input.press?(Input::MMW_FONT) || Input.press?(Input::COLOR)
     if @sample_window == nil
       @sample_window = Window_Sample.new
       $game_system.se_play($data_system.decision_se)
     end
   elsif @sample_window != nil
     @sample_window.dispose
     @sample_window = nil
   end
   if (Input.trigger?(Input::OPT_UP) || Input.trigger?(Input::OPT_DOWN) ||
     Input.trigger?(Input::OPT_LEFT) || Input.trigger?(Input::OPT_RIGHT)) &&
     (Input.press?(Input::SYS_FONT) || Input.press?(Input::MMW_FONT) ||
     Input.press?(Input::WINDOW) || Input.press?(Input::COLOR))
       $game_system.se_play($data_system.cursor_se)
       $game_system.check_for_window_change
       @sample_window.refresh if @sample_window != nil
   end
 end
end

#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle

 alias sample_window_battle_upd update
 def update
   sample_window_battle_upd
   @sample_window.update if @sample_window != nil
   if Input.press?(Input::SYS_FONT) || Input.press?(Input::WINDOW) ||
      Input.press?(Input::MMW_FONT) || Input.press?(Input::COLOR)
     if @sample_window == nil
       @sample_window = Window_Sample.new
       $game_system.se_play($data_system.decision_se)
     end
   elsif @sample_window != nil
     @sample_window.dispose
     @sample_window = nil
   end
   if (Input.trigger?(Input::OPT_UP) || Input.trigger?(Input::OPT_DOWN) ||
     Input.trigger?(Input::OPT_LEFT) || Input.trigger?(Input::OPT_RIGHT)) &&
     (Input.press?(Input::SYS_FONT) || Input.press?(Input::MMW_FONT) ||
     Input.press?(Input::WINDOW) || Input.press?(Input::COLOR))
       $game_system.se_play($data_system.cursor_se)
       $game_system.check_for_window_change
       @sample_window.refresh if @sample_window != nil
   end
 end
end

#-------------------------------------------------------------------------------
module Input
 if Zer0_CFG::Blizzard_Controls_AutoConfig
#  The 'Key' can be changed, but do not change the NAME for the button

# NAME        Key
 SYS_FONT = [Key['1']]    # Hold to engage System FontChanger  
 MMW_FONT = [Key['2']]    # Hold to engage Message FontChanger (if MMW)
 WINDOW = [Key['3']]      # Hold to engage Skin Color/Skin Changer
 COLOR = [Key['4']]       # Hold to engage Text Color Changer
 OPT_LEFT = [Key[',']]    # For changing options while Option is engaged [<]
 OPT_RIGHT = [Key['.']]   # For changing options while Option is engaged [>]
 OPT_UP = [Key['=']]      # For changing options while Option is engaged [+]
 OPT_DOWN = [Key['-']]    # For changing options while Option is engaged [-]
 
 end
end
#-------------------------------------------------------------------------------
module RPG
 module Cache
   def self.windowskin(filename)
     self.load_bitmap("Graphics/Windowskins/", filename, $game_system.skin_color)
   end
 end
end
#-------------------------------------------------------------------------------



Instructions

Place below debug and below main.
Rest of instructions are in the Script.


Compatibility

None known. Compatible with SDK.
Does require Blizzard's Custom Controls


Credits and Thanks


  • ForeverZero, for writing the script.
  • Blizzard, for writing a fantastic help manual



Author's Notes

Feel free to use any part of this in your game, just give me credit.
Some lines of code may have to be added/altered in other scripts, I'll probably update that sometime soon so
that it is not required.
Let me know how you like it, or if you have any constructive criticism, feel free to let me know.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

ForeverZer0

Version is now 2.0.
Totally rewritten code.
Code has been optimized to reduce any lag and configuration has been made MUCH easier.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.