Centering Show Choices Text

Hi! I'm just wondering what should be edited in the scripts so that the choices in a Show Choices box will always be centered? Or maybe there is a script that does this?

Thank you! 🙂
Try this one

Code:
#==============================================================================# ** Window_ChoiceList#------------------------------------------------------------------------------#   This window is used for the event command [Show Choices].#============================================================================== class Window_ChoiceList < Window_Command  #--------------------------------------------------------------------------  # * Update Window Position  #--------------------------------------------------------------------------  def update_placement    self.width = [max_choice_width + 12, 96].max + padding * 2    self.width = [width, Graphics.width].min    self.height = fitting_height($game_message.choices.size)    self.x = Graphics.width / 2 - width / 2    if @message_window.y >= Graphics.height / 2      self.y = @message_window.y - height    else      self.y = @message_window.y + @message_window.height    end  end end
Um, thank you for this, but what I wanted to make center is the text inside the Show Choices box. I'm not sure, but I've been messing with rect.x in Window_ChoiceList and it's moving the choices, just not in the place I want it to be.

I think this topic wants the same thing to happen, but I tried the script there and it did not work for me.

http://forums.rpgmakerweb.com/index.php?/topic/27305-choice-window-text-align/

This is how my Window_ChoiceList looks like right now:

Spoiler
#==============================================================================
# ** Window_ChoiceList
#------------------------------------------------------------------------------
# This window is used for the event command [show Choices].
#==============================================================================

class Window_ChoiceList < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(message_window)
@message_window = message_window
super(0, 0)
self.openness = 0
deactivate
end


def alignment
1
end
#--------------------------------------------------------------------------
# * Start Input Processing
#--------------------------------------------------------------------------
def start
update_placement
refresh
select(0)
open
activate
end
#--------------------------------------------------------------------------
# * Update Window Position
#--------------------------------------------------------------------------
def update_placement
self.width = [max_choice_width + 12, 96].max + padding * 2
self.width = [width, Graphics.width].min
self.height = fitting_height($game_message.choices.size)
self.x = (Graphics.width - width) / 2
self.y = 125
#self.x = Graphics.width - width
#self.x = 225 - Graphics.width
#if @message_window.y >= Graphics.height / 2
# self.y = @message_window.y - height
#else
# self.y = @message_window.y + @message_window.height
#end

end
#--------------------------------------------------------------------------
# * Get Maximum Width of Choices
#--------------------------------------------------------------------------
def max_choice_width
$game_message.choices.collect {|s| text_size(s).width }.max
end
#--------------------------------------------------------------------------
# * Calculate Height of Window Contents
#--------------------------------------------------------------------------
def contents_height
item_max * item_height
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
$game_message.choices.each do |choice|
add_command(choice, :choice)
end
end

#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect_for_text(index)
# rect.x = (max_choice_width) / 4
draw_text_ex(rect.x, rect.y, command_name(index))
end

#--------------------------------------------------------------------------
# * Get Activation State of Cancel Processing
#--------------------------------------------------------------------------
def cancel_enabled?
$game_message.choice_cancel_type > 0
end
#--------------------------------------------------------------------------
# * Call OK Handler
#--------------------------------------------------------------------------
def call_ok_handler
$game_message.choice_proc.call(index)
close
end

#--------------------------------------------------------------------------
# * Call Cancel Handler
#--------------------------------------------------------------------------
def call_cancel_handler
$game_message.choice_proc.call($game_message.choice_cancel_type - 1)
close
end
end
Thank you for the help.
Are you using ANY message system scripts?
Yes, I'm using Modern Algebra's and Yanfly's. Does this affect the display of text in the Show Choice box?
normally MA and probably Yanfly have centering text code. I also tried the script on that thread, it doesn't work for me either, it just puts show choices window outside the window (it was missing an end on the end)
I've managed to center the text at the cost of having a fixed Choice Box width. Here's the script modified. Maybe I could get help on how to make it change depending on the length of the texts and still center itself correctly? Thank you.

The modified Window_ChoiceList script is below.

Spoiler
 
Code:
#==============================================================================# ** Window_ChoiceList#------------------------------------------------------------------------------#  This window is used for the event command [Show Choices].#==============================================================================class Window_ChoiceList < Window_Command  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize(message_window)    @message_window = message_window    super(0, 0)    self.openness = 0    deactivate  end      def alignment    1  end  #--------------------------------------------------------------------------  # * Start Input Processing  #--------------------------------------------------------------------------  def start    update_placement    refresh    select(0)    open    activate  end  #--------------------------------------------------------------------------  # * Update Window Position  #--------------------------------------------------------------------------  def update_placement    self.width = 344#[max_choice_width + 12, 96].max + padding * 2    self.width = 344#[width, Graphics.width].min    self.height = fitting_height($game_message.choices.size)    self.x = (Graphics.width - width) / 2    self.y = 125    #self.x = Graphics.width - width    #self.x = 225 - Graphics.width    #if @message_window.y >= Graphics.height / 2    #  self.y = @message_window.y - height    #else    #  self.y = @message_window.y + @message_window.height    #end        end  #--------------------------------------------------------------------------  # * Get Maximum Width of Choices  #--------------------------------------------------------------------------  def max_choice_width    $game_message.choices.collect {|s| text_size(s).width }.max  end  #--------------------------------------------------------------------------  # * Calculate Height of Window Contents  #--------------------------------------------------------------------------  def contents_height    item_max * item_height  end  #--------------------------------------------------------------------------  # * Create Command List  #--------------------------------------------------------------------------  def make_command_list    $game_message.choices.each do |choice|      add_command(choice, :choice)    end  end    #--------------------------------------------------------------------------  # * Draw Item  #--------------------------------------------------------------------------  def draw_item(index)    rect = item_rect_for_text(index) #   rect.x =(max_choice_width) rect.x = (344 - $game_message.choices.collect {|s| text_size(s) .width }[index] - (padding * 2)) / 2    draw_text_ex(rect.x, rect.y, command_name(index))  end  #--------------------------------------------------------------------------  # * Get Activation State of Cancel Processing  #--------------------------------------------------------------------------  def cancel_enabled?    $game_message.choice_cancel_type > 0  end  #--------------------------------------------------------------------------  # * Call OK Handler  #--------------------------------------------------------------------------  def call_ok_handler    $game_message.choice_proc.call(index)    close  end    #--------------------------------------------------------------------------  # * Call Cancel Handler  #--------------------------------------------------------------------------  def call_cancel_handler    $game_message.choice_proc.call($game_message.choice_cancel_type - 1)    close  endend
You could try to use the draw_text method:

def draw_item(index)  rect = item_rect_for_text(index)  draw_text(rect, command_name(index), 1)endsomething like this.
If I may ask further, where would this go? At the Draw Item section of the script?

EDIT: I managed to see how it works. Thank you! This may be closed now.

Original thread: https://forums.rpgmakerweb.com/threads/centering-show-choices-text.28855/