As the title said, how do I align the text? I prefer it like in image below than the default.
Thanks in advance
Thanks in advance
def main
# Make command window
s1 = "To Title"
s2 = "Shutdown"
s3 = "Cancel"
@command_window = Window_Command.new(192, [s1, s2, s3])
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 240 - @command_window.height / 2
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame Update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of window
@command_window.dispose
# If switching to title screen
if $scene.is_a?(Scene_Title)
# Fade out screen
Graphics.transition
Graphics.freeze
end
end
@command_window = Window_Command.new(192, [s1, s2, s3])
#==============================================================================
# ** Window_Quit
#==============================================================================
class Window_Quit < Window_Selectable
# ------------------------
def initialize()
super(0, 32, 250, 128)
@column_max = 1
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Draw the contents of the item window
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
# draw the bitmap. the text will appear on this bitmap
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
#self.contents.font.bold = true
# n represents the y coordinate where the entry will be displayed
@y_cord = 0
@item_max = 3
# show the items in the menu
for i in 0..3
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw info about a character in the window
#--------------------------------------------------------------------------
def draw_item(index)
case index
when 0
item = "To Title"
when 1
item = "Shutdown"
when 2
item = "Cancel"
when 3
item = ""
end
# draw the option
self.contents.draw_text(0, @y_cord, width-30, 32, item, 1)
# move the next info block down so that characters don't overlap
@y_cord += 32
end
end
#==============================================================================
# ** Scene_End
#------------------------------------------------------------------------------
# This class performs game end screen processing.
#==============================================================================
class Scene_End
def initialize(index)
@location = index
end
def main
if @location != 1
@spriteset = Spriteset_Map.new
end
# Set up options window
@quit_window = Window_Quit.new
@quit_window.x = 320 - @quit_window.width / 2
@quit_window.y = 240 - @quit_window.height / 2
if @location != 1
@quit_window.back_opacity = $game_temp.menu_transparency
end
# Update graphics and input
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
# Freeze graphics for transition
Graphics.freeze
# Erase
@quit_window.dispose
if @location != 1
@spriteset.dispose
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
#@command_window.update
@quit_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(5)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @quit_window.index
when 0 # to title
command_to_title
when 1 # shutdown
command_shutdown
when 2 # quit
command_cancel
end
return
end
end
#--------------------------------------------------------------------------
# * Process When Choosing [To Title] Command
#--------------------------------------------------------------------------
def command_to_title
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Fade out BGM, BGS, and ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# Switch to title screen
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# * Process When Choosing [Shutdown] Command
#--------------------------------------------------------------------------
def command_shutdown
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Fade out BGM, BGS, and ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# Shutdown
$scene = nil
end
#--------------------------------------------------------------------------
# * Process When Choosing [Cancel] Command
#--------------------------------------------------------------------------
def command_cancel
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to menu screen
$scene = Scene_Menu.new(5)
end
end
class Window_CommandCentered < Window_Command
#--------------------------------------------------------------------------
# * Draw Item - NEW draws text centered
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1) #ONLY line changed from Window_Command
end
end
class Scene_End
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = "To Title"
s2 = "Shutdown"
s3 = "Cancel"
@command_window = Window_CommandCentered.new(192, [s1, s2, s3]) # ONLY LINE CHANGED!
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 240 - @command_window.height / 2
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame Update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of window
@command_window.dispose
# If switching to title screen
if $scene.is_a?(Scene_Title)
# Fade out screen
Graphics.transition
Graphics.freeze
end
end
end
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.
Original thread: https://forums.rpgmakerweb.com/threads/resolved-xp-how-do-i-align-center-scene_end-command-text.105921/