Advertisement
Black_Mage

Centered Title Option Text Script

Jul 5th, 2022 (edited)
708
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.95 KB | None
  1. #==============================================================================
  2. # Center Aligned Title Screen's Option Text Script by Black Mage.
  3. # For: RPG Maker VX
  4. # Version: 1.0
  5. #
  6. # License: CC-BY 3.0
  7. # https://burningwizard.wordpress.com/
  8. #==============================================================================
  9.  
  10. #==============================================================================
  11. # Changelog
  12. #==============================================================================
  13. # Version 1.0
  14. #   - Initial version.
  15. #==============================================================================
  16.  
  17. #------------------------------------------------------------------------------
  18. # * Beyond this is the sacred land of code. You need programming qualification
  19. #   to delve deeper, or it'll cause many unnecessary problems. Proceed on your
  20. #   own risk.
  21. #------------------------------------------------------------------------------
  22.  
  23. class Scene_Title < Scene_Base
  24.   def create_command_window
  25.     s1 = Vocab::new_game; s2 = Vocab::continue; s3 = Vocab::shutdown
  26.     @command_window = Center_Window_Command.new(172, [s1, s2, s3])
  27.     @command_window.x = (544 - @command_window.width) / 2
  28.     @command_window.y = 288
  29.     @continue_enabled ? @command_window.index = 1 : @command_window.draw_item(1, false)
  30.     @command_window.openness = 0; @command_window.open
  31.   end
  32. end  
  33. class Center_Window_Command < Window_Command
  34.   def draw_item(index, enabled = true)
  35.     rect = black_item_rect(index,@commands[index])
  36.     self.contents.clear_rect(rect)
  37.     self.contents.font.color = normal_color
  38.     self.contents.font.color.alpha = enabled ? 255 : 128
  39.     self.contents.draw_text(rect, @commands[index])
  40.   end  
  41.   def black_item_rect(index,text)
  42.     rect = item_rect(index)
  43.     max_chc_wdth = text.collect {|s| contents.text_size(s).width }
  44.     center = (self.width - max_chc_wdth[0] - 32) / 2
  45.     rect.x = center; rect.width -= 8; rect
  46.   end
  47. end
Advertisement
RAW Paste Data Copied
Advertisement