Galv’s Visual Novel Choices V.1.9

Demo – Version 1.9 >
Graphics are included in the demo.

#------------------------------------------------------------------------------#
#  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 = "Cursor"  # 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 = "Choice"   # 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 = 1        # Turn this switch ON to disable this script
 
  CHOICES_Y = 0             # Y offset to move choice window up or down.
                            # useful if you use a script that creates a namebox
  CHOICES_Z = 50            # 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[i] = 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

67 thoughts on “Galv’s Visual Novel Choices V.1.9

  1. max says:

    Its says “unable to find: Graphics/System/Cursor” Can you help

  2. max says:

    Well it still cant find it even after me extracting the folder

  3. Prapassorn Tinnabavorn says:

    The file from the link has been deleted :(
    Can you please send me the Script ?
    Thx. :D

  4. max says:

    I just copy and paste it into the space where it says to, i didn’t do anything wrong, also i looked at your demo and the script was exactly the same to mine, but it wont work on my game :(

  5. Kikiz says:

    I’m having the same issue as Max there; I copied and pasted the script into the right place, put the pictures into the correct folders and everything. I’m using the right version of RPGMaker, and there aren’t any other scripts I have implemented that could clash with yours. It doesn’t give me an error message, it just displays Choice Lists as though there is no installed script. All I really wanted to do was to find an easy way to center the choice list windows, and so I tried to use your script because it seemed like the most straightforward method. :(

    • Galv says:

      Make sure you don’t have the ‘DISABLE_SWITCH’ (in the settings) turned on. Else it will disable the script.
      I can’t think of any other reason you’d have for it to just not work.

      • Kikiz says:

        I haven’t touched the DISABLE_SWITCH, I left it as it’s written on your Demo. It works fine on new projects, but for some reason it isn’t working on my current game which leads me to think it might be conflicting with other codes, but when I tried to do an elimination process there were no changes. It’s very odd.

      • Kikiz says:

        I’ve found my problem and it’s to do with the displaying the choice tabs as pictures. My game runs with Parallax Maps and Scenery Overlays displayed as pictures and it’s extremely problematic since I have nearly 50 pictures displaying in various areas. I’ve tried setting the Z tab to something above the others, but it’s not working at all. *sigh* :(

  6. Galv says:

    The z value should work for pictures. Try a really high number like 90000 and see what happens.

    • Kikiz says:

      No it doesn’t work :( It just uses default choice layout instead. The only place its working is on a blank introduction cinematic map which doesn’t have any picture overlays.

      • Galv says:

        It should only revert to the default choice layout if the DISABLE_SWITCH you specified is turned ON.
        If the disable switch is set to 1, that means if you turn switch 1 ON in your game, you will disable this script.

        Maybe I am not understanding the problem but if you’d like to send your project to me to look, PM me on rpgmakervxace.net or rpgmakerweb.com.

  7. Kikiz says:

    OOOOOOH… OH.. OH… AAH. Sorry but you JUST solved my problem. I use a metric tonne of switches and I completely overlooked it! OH! Sorry, so damn happy now. I was so angry it wasn’t working and the solution was so simple. Thank you so very much ^__^

  8. Yu Mi says:

    The script works fine. But it doesn’t work with the script called “choice options” by Tsukihime. (In that script I could disable some choices)

  9. Misaki says:

    Can it be possible to change the background image of the choices using a script call? I want to make it so that when a switch is ON the color of the choice changes, letting the player know they’ve already picked it. So far I’m using many conditional branches to change the colors, but I’d like to do so without cluttering events too much with extra choices and label jumps.

    • Galv says:

      That functionality is not in this script.
      But you might be able to do something with variables to make it easier.

      I haven’t tested this as I don’t have time but see if you can use:
      \B[\v[1]] First option
      \B[\v[2]] Second option
      \B[\v[3]] Third option

      Then change the variables to change the background when you select those options.

      • Misaki says:

        I just tested it out and it works great! Just a note, I found that the images needed to be renamed as Choice0X for it to work. Thank you for the help!

  10. ultimacj says:

    The script works, however, the choices aren’t being displayed on the screen. However, I do hear sounds etc when making a selection / movement of the cursor. The script works but the choices don’t show up.

  11. ultimacj says:

    The FAQ didn’t help much sadly :( I re-read the comments on this page and tried the 90,000 trick that was mentioned (and I don’t use pictures) and it showed up. I didn’t think of trying that trick since I don’t use pictures for my project, especially for choices. I appericate you answering back Galv, thanks, it’s working now.

    • Galv says:

      If you did the tests for script conflicts (one of the points in the FAQ) it should have shown which script was displaying something above the choices or modifying the z level of something. But I’m glad you worked it out.

      • ultimacj says:

        Odd thing is I tried your demo (since the resources where there) as well copied / paste the script from the demo itself. Ran the demo ran perfectly, not sure why it would act weird like that with my project since I have no other scripts that go with it. Let you know when the project is finished Galv ;).

  12. Peter says:

    Hello galv can you re make it and make a variable that allocates the choices to move on the right side?

  13. Asteria says:

    I added the visual novels script and now your busts script doesn’t appear to be working…it just shows the image of the original head instead of the bust I’ve decided to use D: please help <3

    • Galv says:

      Each script uses switches. You set the switches in the script settings – check you are not turning on/off switches that are set in each.

  14. Tiel says:

    So, I’m using a script that makes my game window larger than the default. I notice that when the options are pretty short, the centering doesn’t work quite right, kind of like this:

    That one’s pretty minor, but it gets worse if the choices are any shorter than that. I was wondering if you knew anything I could do to fix this? Thanks!

  15. Mr. Neat says:

    How do I make the choices overlap pictures?

  16. JN says:

    Can’t download demo :c

  17. JN says:

    It’s working now, didn’t know what was the problem, it was giving me error :/ well thanks anyway :D

  18. AM says:

    Hey Galv, is there a chance to change the font in the choice boxes? thx

  19. Linally says:

    Hey Galv, I just discovered an issue with the script. It doesn’t like Switches. As soon as a switch is activated, the script just stops working. No error message or anything. It doesn’t matter how the switch is activated or if it gets erased by some means, the choices just stop showing and it reverts to the old choice box. I tested it in your demo to be sure it wasn’t another script on my end.
    Any thoughts?

    • Galv says:

      In the script setup options you will see it says:
      DISABLE_SWITCH = 1 # Turn this switch ON to disable this script

      You can change that from 1 to another number. Or 0 if you dont want to use it. But you are disabling the script with the switch number that is specified here. It’s not an issue, it’s an option.

  20. KilerDiLeo says:

    Instead of using custom options graphics, can I just have the normal window replacing it?

    • Galv says:

      The script was not designed for that, no.

      • Infamous.V says:

        Hey galv , i found a bug in your script.
        man i tell you this bug has caused me enormous stress :(
        well you know when you activate fade-out, the default (show choice) works but yours doesn’t so i have to use fade in. which is a hassle to do every time, now, when i press (enter) the thing still progresses but i can’t see the choices graphics :(
        . anyway galv please fix this bug.

      • Galv says:

        Unfortunately I don’t know when I can get to this as I am super busy, but you could use Tint-Screen and tint to black then the choices will be visible.

  21. Infamous.V says:

    oh okay, great alternative , why didn’t i think of that?
    anyway thanks. peace out

  22. Lara says:

    Hi Galv , This script doesn’t have fade in and fade out , can you tell me how to add it ?

  23. Hi Galv, I’m with a problem see:
    [img]https://s12.postimg.org/l0m9nfc0d/imagem.png[/img]

    I need that the bar stand in front of the image. What I do?

    • Galv says:

      In the script settings you’ll see:

      CHOICES_Z = 50 # 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.

      Try changing 50 to a much higher number (For example to test make it 2000) and see if that works.

  24. OMG! Haha Thanks Galv!! All ok here. ^^

  25. uli6636 says:

    where is the demo link? i can’t find it

  26. uli6636 says:

    where is the demo download link? i can’t find it

  27. tilamagames says:

    Hi Galv, I have a problem. If a character is too close at the window, there are problems with the choice window. Picture: https://mega.nz/#!YFh1ADwQ!rQuT53R2sQTM7jS8xMweSuJVwYShaKNt9FsxxWiczDU
    Thank you

    • Galv says:

      Unfortunately yes, that will happen. You’ll have to plan your events to show the message above characters when at the bottom or leave more map tiles lower so it doesn’t happen.

Leave a comment