Visual Novel choice - X offset

Status
Not open for further replies.

Nosleinad

Storyteller
Veteran
Joined
Dec 12, 2012
Messages
351
Reaction score
29
First Language
Portuguese
Primarily Uses
I am using the visual novel choices script from Galv, and i am trying to offset the entire choice window in the X axis, so it can avoid my busts and minimap.

I tryed to mess with some values in the script codes, but without success. Could someone help me out? Here's the script for easier reference:

#------------------------------------------------------------------------------#
# Galv's Visual Novel Choices
#------------------------------------------------------------------------------#
# For: RPGMAKER VX ACE
# Version 1.9
#------------------------------------------------------------------------------#
# 2013-01-16 - Version 1.9 - Added Y offset for choice window
# 2012-11-28 - Version 1.8 - Z level setting added
# 2012-11-28 - Version 1.7 - Added compatability for some cursor scripts
# 2012-11-28 - Version 1.6 - Fixed a bug that could crash the game.
# 2012-11-28 - Version 1.5 - Added offset to change postion of cursor x and y
# 2012-11-28 - Version 1.4 - Fixed z levels and made cursor use an image
# 2012-11-27 - Version 1.3 - Fixed a bug with cancel choice selection
# 2012-11-27 - Version 1.2 - added a switch to disable script effects
# 2012-11-27 - Version 1.1 - added ability to use different image per choice
# - added a couple more options
# 2012-11-27 - Version 1.0 - release
#------------------------------------------------------------------------------#
# This script overwrites the default "Show Choices" list. The choices are
# changed so they display centered on the screen with a graphic behind each
# of them. Made with visual novel choice selection in mind.
#------------------------------------------------------------------------------#
# INSTRUCTIONS:
# Copy the graphic from the demo /Graphics/System into your project.
# Copy the script into your script list, below Materials and above Main
#
# Some setup options below, most only need to be changed if you use your own
# custom choice image.
#------------------------------------------------------------------------------#
# Codes:
#------------------------------------------------------------------------------#
# Most of the usual codes that work in messages should work in choices.
# (eg. \V[x], \N[x], \C[x], etc. Look at message tooltip to know more.)
#
# A new one has been added so you can change the background image for separate
# choice options.
#
# \B[x]
#
# This works by adding the number x (as you put in the code above) to the end
# of the CHOICE IMAGE file name. For example, the default choice image is:
# "Choice.png" located in /Graphics/System/. If you put the code anywhere in
# a choice box: \B[3] it will look for "Choice3.png" image in the same
# location.
#------------------------------------------------------------------------------#

($imported ||= {})["Galvs_Image_Choices"] = true
module Galv_Choice

#------------------------------------------------------------------------------#
# SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#

CURSOR_IMAGE = "Cursor2" # Images used to determine which option you select
CURSOR_OPACITY = 255 # Opacity of the cursor
CURSOR_Y_OFFSET = 0 # Nudge cursor position vertically
CURSOR_X_OFFSET = 0 # Nudge cursor position horizontally

CHOICE_IMAGE = "Choice1" # Image for each choice located in /Graphics/System
IMAGE_Y_OFFSET = 3 # Nudge your choice image vertically if needed
IMAGE_OPACITY = 215 # The opacity of the image

CHOICE_HEIGHT = 45 # How tall each choice.
CHOICE_ITEM_Y = 2 # Offset for choice item text

CENTER_TEXT = true # left aligned if false, centered if true

DISABLE_SWITCH = 0 # Turn this switch ON to disable this script

CHOICES_Y = 250 # Y offset to move choice window up or down.
# useful if you use a script that creates a namebox
CHOICES_Z = 550 # The z value of the choices window. Try changing it
# if pictures or other scripts appear over or under
# the choices window to how you like.

#------------------------------------------------------------------------------#
OTHER_Y_OFFSET = 12 # May fix other cursor scripts positioning
#------------------------------------------------------------------------------#
# SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#

end

class Window_ChoiceList < Window_Command

alias galv_choice_initialize initialize
def initialize(message_window)
galv_choice_initialize(message_window)
self.z = Galv_Choice::CHOICES_Z
end

def start
@index = 0
setup_choices
make_cursor
refresh
open
activate
update_placement
update_bgs
refresh
select(0)
end

def make_cursor
return if $game_switches[Galv_Choice::DISABLE_SWITCH]
@cursor_sprite = Sprite.new
@cursor_sprite.bitmap = Cache.system(Galv_Choice::CURSOR_IMAGE)
end

def setup_choices
@choice_sprite = []
if !$game_switches[Galv_Choice::DISABLE_SWITCH]
self.opacity = 0
get_widths
else
self.opacity = 255
end
end

alias galv_choice_update_placement update_placement
def update_placement
if $game_switches[Galv_Choice::DISABLE_SWITCH]
galv_choice_update_placement
else
self.width = [max_choice_width + 12, 96].max + padding * 4
self.width = [width, Graphics.width].min
self.height = contents_height + Galv_Choice::CHOICE_HEIGHT - 10
self.x = (Graphics.width - width) / 2

if @message_window.openness < 100
self.y = Graphics.height - contents_height + item_height / 2
elsif @message_window.y >= Graphics.height / 2
self.y = @message_window.y - contents_height + item_height / 2 - Galv_Choice::CHOICES_Y
else
self.y = @message_window.y + @message_window.height + item_height / 2 + Galv_Choice::CHOICES_Y
end
end
end

alias galv_choice_contents_height contents_height
def contents_height
if $game_switches[Galv_Choice::DISABLE_SWITCH]
galv_choice_contents_height
else
(item_max + 1) * item_height
end
end

def draw_item(index)
rect = item_rect_for_text(index)
draw_text_ex(rect.x, rect.y, command_name(index))
if !$game_switches[Galv_Choice::DISABLE_SWITCH]
draw_bgs(index)
end
end

def item_rect_for_text(index)
rect = item_rect(index)

if $game_switches[Galv_Choice::DISABLE_SWITCH]
rect.x += 4
rect.width -= 8
rect
else
if Galv_Choice::CENTER_TEXT
rect.x = (max_choice_width - @text_sizes.collect {|s| text_size(s).width }[index] + (padding * 3)) / 2
else
rect.x += 4
end
rect.width -= 8
rect.y += Galv_Choice::CHOICE_ITEM_Y
rect
end
end

def get_widths
@text_sizes = []
@choice_background = []
$game_message.choices.each_with_index do |c,i|
@text_sizes = esc_characters(c,i)
end
end

def esc_characters(text,index)
result = text.to_s.clone
result.gsub!(/\\/) { "\e" }
result.gsub!(/\e\e/) { "\\" }
result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
result.gsub!(/\eN\[(\d+)\]/i) { $game_actors[$1.to_i].name}
result.gsub!(/\eP\[(\d+)\]/i) {
if $game_party.members[$1.to_i].nil?
""
else
$game_party.members[$1.to_i].name
end
}
result.gsub!(/\eG/i) { Vocab::currency_unit }
result.gsub!(/\eC\[(\d+)\]/i) { "" }
result.gsub!(/\eI\[(\d+)\]/i) { " " }
result.gsub!(/\eB\[(\d+)\]/i) { @choice_background[index] = $1.to_i }
result.gsub!(/\eB\[(\d+)\]/i) { "" }
result
end

def convert_escape_characters(text)
result = text.to_s.clone
result.gsub!(/\\/) { "\e" }
result.gsub!(/\e\e/) { "\\" }
result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }
result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }
result.gsub!(/\eG/i) { Vocab::currency_unit }
result.gsub!(/\eB\[(\d+)\]/i) { "" }
result
end

def item_height
return line_height if $game_switches[Galv_Choice::DISABLE_SWITCH]
return Galv_Choice::CHOICE_HEIGHT
end

def item_rect(index)
rect = Rect.new
rect.width = item_width
rect.height = item_height - 15
rect.height += 15 if $game_switches[Galv_Choice::DISABLE_SWITCH]
rect.x = index % col_max * (item_width + spacing)
rect.y = index / col_max * item_height
rect
end

def draw_bgs(index)
return if @choice_sprite[index] != nil

if @choice_background[index].nil?
b = ""
else
b = @choice_background[index]
end
@choice_sprite[index] = Sprite.new
@choice_sprite[index].bitmap = Cache.system(Galv_Choice::CHOICE_IMAGE + b.to_s)
@choice_sprite[index].x = index % col_max * (item_width + spacing)
@choice_sprite[index].y = index / col_max * item_height
@choice_sprite[index].z = self.z - 2
end

def update_bgs
@choice_sprite.each_with_index do |s,i|
s.y = self.y + i * Galv_Choice::CHOICE_HEIGHT + Galv_Choice::IMAGE_Y_OFFSET
s.x = (Graphics.width - s.width) / 2
s.opacity = Galv_Choice::IMAGE_OPACITY
end
end

def dispose_bgs
@choice_sprite.each_with_index do |s,i|
s.dispose
s.bitmap.dispose
end
if !$game_switches[Galv_Choice::DISABLE_SWITCH]
@cursor_sprite.dispose
@cursor_sprite.bitmap.dispose
@choice_sprite = []
end
end

alias galv_choice_call_ok_handler call_ok_handler
def call_ok_handler
galv_choice_call_ok_handler
dispose_bgs
end
alias galv_choice_call_cancel_handler call_cancel_handler
def call_cancel_handler
galv_choice_call_cancel_handler
dispose_bgs
end

def update_cursor
if $game_switches[Galv_Choice::DISABLE_SWITCH]
super
else
cursor_rect.empty
return if @cursor_sprite.nil? || @choice_sprite.nil?
if @index < 0
@cursor_sprite.opacity = 0
else
@cursor_sprite.opacity = Galv_Choice::CURSOR_OPACITY
@cursor_sprite.x = @choice_sprite[@index].x + Galv_Choice::CURSOR_X_OFFSET
@cursor_sprite.y = @choice_sprite[@index].y + Galv_Choice::CURSOR_Y_OFFSET
@cursor_sprite.z = self.z - 1
cursor_rect.y = (item_height * @index) + Galv_Choice::oTHER_Y_OFFSET
end
end
end

end # Window_ChoiceList < Window_Command
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,839
Reaction score
14,031
First Language
English
Primarily Uses
RMMV
It's better to post a link to the forum thread where you got the script, so we can see the author's notes. Your script is also badly formatted and hard to read, since you didn't put the code into code tags. Next time, if you MUST paste the script itself into your post, use spoiler AND code tags at the time of pasting the script, so the indentation is maintained.


Look for this:

CHOICES_Y = 250 # Y offset to move choice window up or down.Add this on the next line:
Code:
CHOICES_X = 100 # X offset to move choice window left (negative number) or right (positive number)
The 100 is what you will change to move it further left or right. Negative numbers will move it left, positive numbers will move it right.
Look for this:

Code:
self.x = (Graphics.width - width) / 2
Change it to this:
Code:
self.x = (Graphics.width - width) / 2 + Galv_Choice::CHOICES_X
 
Last edited by a moderator:

Nosleinad

Storyteller
Veteran
Joined
Dec 12, 2012
Messages
351
Reaction score
29
First Language
Portuguese
Primarily Uses
Thanks for the tips about the post, and also for the directions you gave me for changing the script  :) .


When i get home (Lunch time at work :unsure: ) i will test them ASAP and post the results here.


I followed the instructions, and something weird happened actually. I think an image can describe better than words:





Actually i can move the green boxes with the Y offset, but not with the new customized X offset.
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,839
Reaction score
14,031
First Language
English
Primarily Uses
RMMV
Maybe where I put that, it just moves the text and not the graphics behind it. Strange that it only moved one though, and not both.


Find this line:

s.x = (Graphics.width - s.width) / 2Replace it with this:
Code:
s.x = (Graphics.width - s.width) / 2 + Galv_Choice::CHOICES_X

Then show me what it does.
 
Last edited by a moderator:

Nosleinad

Storyteller
Veteran
Joined
Dec 12, 2012
Messages
351
Reaction score
29
First Language
Portuguese
Primarily Uses
It's working perfectly now thanks again Shaz.

I also wondered why just one of the text messages went to the left after the first mod.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,839
Reaction score
14,031
First Language
English
Primarily Uses
RMMV
Awesome :)


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Looking back at some sketches, and game design documents on my PC dated summer of 2015. I started development with the release of MZ, but in 2015, I felt a strong desire to make a game out of the blue. I remember feeling sad for no apparent reason, and all these ideas rushed into my head. Now that I think about it, since that day, everything has become easier to do on my PC . . . it’s very creepy.
Everything's going to be alright! We're all in this together. <3
Aaaaannd published my game's tech demo. :D

Feel free to download and play it. And give feedback!
Hey everyone, we know that the edit bar is missing. We're working on it. You can talk about it in the announcement here: https://forums.rpgmakerweb.com/index.php?threads/forum-errors-missing-edit-bar-etc.132715/
So, explain why we can no longer use BBC code or smilies in our posts? This sparks much sadness...

Forum statistics

Threads
107,794
Messages
1,032,255
Members
139,941
Latest member
Finley
Top