ATS: Choice Options
Version: 1.0.0
Author: modern algebra
Date: 27 January 2013
Version History
- <Version 1.0.0> 2013.01.27 - Original Release
Description
This script improves your control over the choice box by permitting more than four choices in a box, each of which you can disable or remove contingent on the value of any given switch. Additionally, it also allows you to extend the length of the choice beyond the editor's spacial limitations, allowing you to have long choices, and it adds an option for a help window to assist in describing the choices. Aside from that dynamic control over choice branches, you are also permitted to set the number of columns in the choice box, its size, and its position. There are other more minor features as well, which you can learn about in the instructions.
Features
- More than four choices!
- Hide or disable choices based on switch value
- Can set size and position of choice box
- Can set number of columns
- Multi-line and long choices
- Help window to assist player in decision
If you are looking for other features from my VX script of the same name, then see some of the other scripts in the ATS series (http://rmrk.net/index.php/topic,44525.0.html).
Screenshots
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fs7.postimage.org%2F604at5h1n%2Fatsco1.png&hash=3be19e02fd6296d6aec766b61cd899178cc45595)
Instructions
Paste the script into its own slot in the Script Editor, above Main but below Materials.
See the header for instructions on configuration and use.
Script
Retrieve it from Pastebin (http://pastebin.com/iz4kk3Fb).
Credit
Support
Please post in this topic at RMRK.net if you have any questions, suggestions, error reports, or comments about this script. It is perfectly fine to post here even if this topic has not been posted in for a very long time.
Please do not message me privately, as any concerns you have are likely shared by others and they will benefit from our correspondence being public. Additionally, I am occasionally absent, and posting publically will allow other members to assist you when I am unable to do so quickly.
Known Compatibility Issues
I am currently unaware of any compatibility issues.
Demo
See attached (http://rmrk.net/index.php?action=dlattach;topic=47593.0;attach=30455).
Terms of Use
I adopt RMRK's default Terms of Use (http://rmrk.net/index.php/topic,45481.0.html).
What happens if you change
self.contents = Bitmap.new(contents_width, 24)
to
self.contents = Bitmap.new(24, 24)
Hi, it's strange that happens, since that variable should be assigned an array as soon as a new game starts. It may be that you are loading an old save game from before you installed the script.
In any event, you should be able to fix it by pasting the following code into a script call before the choice branch:
$game_message.choice_help_texts = []
If it's not from an old save file, then it may be an incompatibility with another script.
Hmm, I guess I tried to get too fancy. The following should work :
EDIT: Code updated to include an option for a help window dimmed background.
#==============================================================================
# ** Game_ATS
#==============================================================================
class Game_ATS
CONFIG[:ats_choice_options].merge!( {
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# EDITABLE REGION
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# :choice_help_align_text
# ├ (value) 0 - Left Align
# ├ (value) 1 - Center Align
# └ (value) 2 - Right Align
choice_help_align_text: 0,
# :choice_help_dim_bg
# ├ (value) true - Display Dim Background
# └ (value) false - Display Windowskin
choice_help_dim_bg: false,
# :choice_help_dim_bg_color1
# └ (value) Color Object - Color used in background gradient
choice_help_dim_bg_color1: Color.new(0, 0, 0, 160),
# :choice_help_dim_bg_color2
# └ (value) Color Object - Color used in background gradient
choice_help_dim_bg_color2: Color.new(0, 0, 0, 0),
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# END EDITABLE REGION
#////////////////////////////////////////////////////////////////////////
} )
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
CONFIG[:ats_choice_options].keys.each { |key| attr_accessor key }
end # Game_ATS
#==============================================================================
# ** Game_Message
#==============================================================================
class Game_Message
Game_ATS::CONFIG[:ats_choice_options].keys.each { |key| attr_accessor key }
end # Game_Message
#==============================================================================
# ** Window_ChoiceHelp
#==============================================================================
class Window_ChoiceHelp < Window_Base
#--------------------------------------------------------------------------
# * NEW - Object Initialization
#--------------------------------------------------------------------------
def initialize(line_number = 2)
super(0, 0, Graphics.width, fitting_height(line_number))
create_back_bitmap
create_back_sprite
end
#--------------------------------------------------------------------------
# * SUPER - Free
#--------------------------------------------------------------------------
def dispose
dispose_back_bitmap
dispose_back_sprite
super
end
#--------------------------------------------------------------------------
# * NEW - Set Text
#--------------------------------------------------------------------------
def set_text(text)
update_back_sprite
update_text_alignment
if text != @text
@text = text
refresh
end
end
#--------------------------------------------------------------------------
# * NEW - Clear
#--------------------------------------------------------------------------
def clear
set_text("")
end
#--------------------------------------------------------------------------
# * NEW - Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_text_ex(4, 0, @text)
end
#--------------------------------------------------------------------------
# * SUPER - Hide Window
#--------------------------------------------------------------------------
def hide
@back_sprite.visible = false
super
end
#--------------------------------------------------------------------------
# * NEW - Create Background Bitmap
#--------------------------------------------------------------------------
def create_back_bitmap
@back_bitmap = Bitmap.new(width, height)
rect1 = Rect.new(0, 0, width, 12)
rect2 = Rect.new(0, 12, width, height - 24)
rect3 = Rect.new(0, height - 12, width, 12)
@back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
@back_bitmap.fill_rect(rect2, back_color1)
@back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
end
#--------------------------------------------------------------------------
# * NEW - Get Background Color 1
#--------------------------------------------------------------------------
def back_color1
$game_message.choice_help_dim_bg_color1
end
#--------------------------------------------------------------------------
# * NEW - Get Background Color 2
#--------------------------------------------------------------------------
def back_color2
$game_message.choice_help_dim_bg_color2
end
#--------------------------------------------------------------------------
# * NEW - Create Background Sprite
#--------------------------------------------------------------------------
def create_back_sprite
@back_sprite = Sprite.new
@back_sprite.bitmap = @back_bitmap
@back_sprite.visible = false
@back_sprite.z = z - 1
end
#--------------------------------------------------------------------------
# * NEW - Update Background Sprite
#--------------------------------------------------------------------------
def update_back_sprite
@back_sprite.visible = $game_message.choice_help_dim_bg
@back_sprite.x = x
@back_sprite.y = y
@back_sprite.opacity = openness
@back_sprite.update
end
#--------------------------------------------------------------------------
# * NEW - Update Text Alignment
#--------------------------------------------------------------------------
def update_text_alignment
@align = $game_message.choice_help_align_text
end
#--------------------------------------------------------------------------
# * NEW - Free Background Bitmap
#--------------------------------------------------------------------------
def dispose_back_bitmap
@back_bitmap.dispose
end
#--------------------------------------------------------------------------
# * NEW - Free Background Sprite
#--------------------------------------------------------------------------
def dispose_back_sprite
@back_sprite.dispose
end
#--------------------------------------------------------------------------
# * SUPER - Draw Text with Control Characters
#--------------------------------------------------------------------------
def draw_text_ex(x, y, text, *args, &block)
if @align != 0
text = convert_escape_characters(text)
@max_text_width = text_size(text).width
end
super(x, y, text, *args, &block)
end
#--------------------------------------------------------------------------
# * SUPER - Normal Character Processing
#--------------------------------------------------------------------------
def process_normal_character(c, pos, *args, &block)
if @align != 0
text_width = text_size(c).width
case @align
when 1
draw_text(((width / 2) - (@max_text_width / 2)) - pos[:x], pos[:y], text_width * 2, pos[:height], c)
when 2
draw_text((contents.width - @max_text_width) - pos[:x], pos[:y], text_width * 2, pos[:height], c)
end
pos[:x] -= text_width
else
super(c, pos, *args, &block)
end
end
end # Window_ChoiceHelp
#==============================================================================
# ** Window_ChoiceList
#==============================================================================
class Window_ChoiceList
#--------------------------------------------------------------------------
# * ALIAS - Object Initialization
#--------------------------------------------------------------------------
unless method_defined?(:choice_XYJpWTIZ_wcl_initialize)
alias_method(:choice_XYJpWTIZ_wcl_initialize, :initialize)
end
def initialize(*args, &block)
choice_XYJpWTIZ_wcl_initialize(*args, &block)
create_help_window
end
#--------------------------------------------------------------------------
# * ALIAS - Start
#--------------------------------------------------------------------------
unless method_defined?(:choice_s23eH7xd_wcl_start)
alias_method(:choice_s23eH7xd_wcl_start, :start)
end
def start(*args, &block)
update_background
choice_s23eH7xd_wcl_start(*args, &block)
end
#--------------------------------------------------------------------------
# * SUPER - Free
#--------------------------------------------------------------------------
def dispose
super
dispose_all_windows
end
#--------------------------------------------------------------------------
# * NEW - Free All Windows
#--------------------------------------------------------------------------
def dispose_all_windows
self.help_window.dispose
end
#--------------------------------------------------------------------------
# * NEW - Update Window Background
#--------------------------------------------------------------------------
def update_background
@background = $game_message.choice_help_dim_bg
self.help_window.opacity = @background ? 0 : 255
end
#--------------------------------------------------------------------------
# * NEW - Create Help Window
#--------------------------------------------------------------------------
def create_help_window
lines = $game_message.choice_help_win_lines
self.help_window = Window_ChoiceHelp.new(lines > 0 ? lines : 1)
help_window.z = self.z
help_window.hide
end
#--------------------------------------------------------------------------
# * OVERWRITE - Update Help Window
#--------------------------------------------------------------------------
def update_help
if index >= 0 && $game_message.choice_help_texts[index].is_a?(String)
@help_window.set_text($game_message.choice_help_texts[index])
else
help_window.clear
end
end
end # Window_ChoiceList
Mm, where at? In the choice window or help window? o:
I had a text code set up to make the font change color in the help window, and it stopped working when I added the add-on. ;_; That's really weird... :o
Sorry for the delay. Yes, you can change the position of the text box by selecting "Top" or "Middle" when writing your message. If you need more positioning options for the message box, you can try my ATS: Message Options (http://rmrk.net/index.php?topic=46770.0).
With respect to the position of the choice box, that is controlled by the settings described in the portion of the script at lines 116-140:
# :choice_win_x - This controls the horizontal position of the choice
# window. It can be set to either :L, :R, :C, or an integer. If an integer,
# then it is set directly to that x-coordinate. If :L, it is flush with the
# left side of the message window. If :C, it is in the centre of the
# message window. If :R, it is flush with the right side of the message
# window.
choice_win_x: :R,
# :choice_win_x_offset - This is the number of pixels offset when
# :choice_win_x is set to :L or :R. When :L, it is added. When :R, it is
# subtracted.
choice_win_x_offset: 0,
# :choice_win_y - This controls the vertical position of the choice window.
# It can be set to either :T, :B, or an integer. If an integer, then it is
# set directly to that y-coordinate. If :T, it is flush with the top of the
# message window. If :B, it is flush with the bottom of the message window.
choice_win_y: :T,
# :choice_win_y_offset - This is the number of pixels offset when
# :choice_win_y is set to :T or :B. When :T, it is added. When :B, it is
# subtracted.
choice_win_y_offset: 0,