Advertisement
mikb89

[Ace] Shangai FF13 Main Menu per MihaChan

Apr 22nd, 2012
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 18.12 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Final Fantasy 13 Main Menu
  4. # Last Date Updated: 2010.06.02
  5. # Level: Normal
  6. #
  7. # This makes your main menu ordered like Final Fantasy 13's.
  8. #
  9. # Converted by mikb89 to work for VX Ace.
  10. # UNOFFICIAL porting, all credits go to Shangai.
  11. #===============================================================================
  12. # Instructions
  13. # -----------------------------------------------------------------------------
  14. # To install this script, open up your script editor and copy/paste this script
  15. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  16. #
  17. #===============================================================================
  18.  
  19. $imported = {} if $imported == nil
  20. $imported["FinalFantasy13Menu"] = true
  21.  
  22. module SSS
  23.   # This is the image file for the menu background. Place this inside of the
  24.   # Graphics\System folder.
  25.   MENU_BACK_IMAGE = "MenuBack"
  26.  
  27.   # This is the image file used for the back of each of the menu items. This
  28.   # image must be 160x24 pixels and placed inside of the Graphics\System folder.
  29.   MENU_BACK_ITEM_IMAGE = "MenuBackItem"
  30.  
  31.   # This sets the menu help window's text color.
  32.   MENU_HELP_TEXT_COLOR = Color.new(0, 0, 0)
  33.  
  34.   # This is the text format used to write out the current map.
  35.   MENU_LOCATION = "Location: %s"
  36.  
  37.   # This hash sets the image files for your actors. These images must be placed
  38.   # inside of the Graphics\System folder and they have to be 104x288 pixels.
  39.   MENU_ACTOR_IMAGES ={
  40.     1 => "Charas",
  41.     2 => "Charas",
  42.     3 => "Charas",
  43.     4 => "Charas",
  44.   } # Remove this and perish.
  45.  
  46.   # This hash sets what colors belong to which class when drawn.
  47.   MENU_CLASS_COLORS ={
  48.     1 => 2,
  49.     2 => 6,
  50.     3 => 4,
  51.     4 => 5,
  52.   } # Remove this and perish.
  53.  
  54.   # This sets the help window descripts for the menu commands.
  55.   MENU_HELP_WINDOW ={
  56.     "Oggetti"     => "View and manage your party's items.",
  57.     "Status"   => "View a party member's status.",
  58.     "Abilità"    => "Manage a party member's skills.",
  59.     "Equip."    => "Manage a party member's equipment.",
  60.     "Salva"     => "Save your current progress.",
  61.     "Esci" => "End the current game.",
  62.     "System"   => "Adjust the game's options.",
  63.   } # Remove this and perish.
  64.  
  65.   # Let you choose how much member are visible in the main menu
  66.   MAX_MENU_MEMBERS = 4
  67. end
  68.  
  69. #===============================================================================
  70. # Override Main Menu Melody Settings
  71. #===============================================================================
  72.  
  73. module YEM; module MENU
  74. USE_ICONS = false
  75. MENU_RIGHT_SIDE = false
  76. ON_SCREEN_MENU = false
  77. USE_MULTI_VARIABLE_WINDOW = false
  78. end; end
  79.  
  80. #==============================================================================
  81. # ** Window_Base
  82. #==============================================================================
  83.  
  84. class Window_Base < Window
  85.   WLH = 24
  86.   #--------------------------------------------------------------------------
  87.   # * Object Initialization
  88.   #--------------------------------------------------------------------------
  89.   alias initialize_sss_ff13_menu_window_base initialize unless $@
  90.   def initialize(x, y, width, height)
  91.     initialize_sss_ff13_menu_window_base(x, y, width, height)
  92.     self.opacity = 0 if SceneManager.scene_is?(Scene_Menu)
  93.   end
  94. end
  95.  
  96. #==============================================================================
  97. # ** Window_MenuHelp
  98. #==============================================================================
  99.  
  100. class Window_MenuHelp < Window_Help
  101.   #--------------------------------------------------------------------------
  102.   # * Set Text
  103.   #--------------------------------------------------------------------------
  104.   def set_text(text, align = 0)
  105.     if text != @text or align != @align
  106.       self.contents.clear
  107.       self.contents.font.shadow = false
  108.       self.contents.font.color = SSS::MENU_HELP_TEXT_COLOR
  109.       self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
  110.       @text = text
  111.       @align = align
  112.     end
  113.   end
  114. end
  115.  
  116. #==============================================================================
  117. # ** Window_MainMenuParty
  118. #==============================================================================
  119.  
  120. class Window_MainMenuParty < Window_Selectable
  121.   #--------------------------------------------------------------------------
  122.   # * Public Instance Variables
  123.   #--------------------------------------------------------------------------
  124.   attr_reader   :pending_index            # Pending position (for formation)
  125.   #--------------------------------------------------------------------------
  126.   # * Object Initialization
  127.   #--------------------------------------------------------------------------
  128.   def initialize(x, y)
  129.     super(x-24, y, Graphics.width-x+32, Graphics.height-y)
  130.     @pending_index = -1
  131.     self.active = false
  132.     refresh
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * Get Digit Count
  136.   #--------------------------------------------------------------------------
  137.   def col_max
  138.     return [SSS::MAX_MENU_MEMBERS, $game_party.members.size].max
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # * Get Spacing for Items Arranged Side by Side
  142.   #--------------------------------------------------------------------------
  143.   def spacing
  144.     return 0
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # * Get Number of Items
  148.   #--------------------------------------------------------------------------
  149.   def item_max
  150.     return $game_party.members.size
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # * Refresh
  154.   #--------------------------------------------------------------------------
  155.   def refresh
  156.     self.contents.clear
  157.     create_contents
  158.     for i in 0...item_max
  159.       draw_item(i)
  160.     end
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # * Draw Item
  164.   #--------------------------------------------------------------------------
  165.   def draw_item(index)
  166.     rect = item_rect(index)
  167.     self.contents.clear_rect(rect)
  168.     actor = $game_party.members[index]
  169.     unless actor.nil?
  170.       draw_item_background(index)
  171.       draw_actor_image(actor, rect)
  172.       draw_actor_name(actor, rect)
  173.       draw_actor_icons(actor, rect.x, WLH*5/2, 96)
  174.       draw_actor_class(actor, rect)
  175.       draw_actor_level(actor, rect)
  176.       draw_actor_hp(actor, rect)
  177.       draw_actor_mp(actor, rect)
  178.     end
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # * Draw Background for Item
  182.   #--------------------------------------------------------------------------
  183.   def draw_item_background(index)
  184.     if index == @pending_index
  185.       contents.fill_rect(item_rect(index), pending_color)
  186.     end
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * Draw Actor Image
  190.   #--------------------------------------------------------------------------
  191.   def draw_actor_image(actor, rect)
  192.     filename = SSS::MENU_ACTOR_IMAGES[actor.id]
  193.     return if filename.nil?
  194.     bitmap = Cache.system(filename)
  195.     image_rect = Rect.new(2, 2, rect.width-4, 284)
  196.     self.contents.blt(rect.x+2, rect.y+2, bitmap, image_rect)
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # * Draw Actor Name
  200.   #--------------------------------------------------------------------------
  201.   def draw_actor_name(actor, rect)
  202.     name = actor.name
  203.     self.contents.font.size = Font.default_size
  204.     self.contents.font.color = normal_color
  205.     self.contents.draw_text(rect.x+4, WLH*3/2, rect.width-8, WLH, name)
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # * Draw Actor Class
  209.   #--------------------------------------------------------------------------
  210.   def draw_actor_class(actor, rect)
  211.     name = actor.class.name
  212.     self.contents.font.size = Font.default_size - 4
  213.     color_id = SSS::MENU_CLASS_COLORS[actor.class.id].to_i
  214.     self.contents.font.color = text_color(color_id)
  215.     self.contents.draw_text(rect.x+4, WLH*0, rect.width-8, WLH, name, 2)
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # * Draw Actor Level
  219.   #--------------------------------------------------------------------------
  220.   def draw_actor_level(actor, rect)
  221.     self.contents.font.size = Font.default_size - 4
  222.     self.contents.font.color = power_up_color
  223.     yy = 288 - WLH*7/2 - 8
  224.     self.contents.draw_text(rect.x+4, yy, rect.width-8, WLH, Vocab.level_a, 0)
  225.     yy += WLH/2
  226.     self.contents.font.color = normal_color
  227.     self.contents.font.size += 2
  228.     self.contents.draw_text(rect.x+4, yy, rect.width-8, WLH, actor.level, 2)
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Draw Actor HP
  232.   #--------------------------------------------------------------------------
  233.   def draw_actor_hp(actor, rect)
  234.     self.contents.font.size = Font.default_size - 4
  235.     self.contents.font.color = hp_gauge_color2
  236.     yy = 288 - WLH*5/2 - 4
  237.     self.contents.draw_text(rect.x+4, yy, rect.width-8, WLH, Vocab.hp, 0)
  238.     yy += WLH/2
  239.     self.contents.font.color = normal_color
  240.     self.contents.font.size += 2
  241.     self.contents.draw_text(rect.x+4, yy, rect.width-8, WLH, actor.hp, 2)
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # * Draw Actor MP
  245.   #--------------------------------------------------------------------------
  246.   def draw_actor_mp(actor, rect)
  247.     self.contents.font.size = Font.default_size - 4
  248.     self.contents.font.color = mp_gauge_color2
  249.     yy = 288 - WLH*3/2
  250.     self.contents.draw_text(rect.x+4, yy, rect.width-8, WLH, Vocab.mp, 0)
  251.     yy += WLH/2
  252.     self.contents.font.color = normal_color
  253.     self.contents.font.size += 2
  254.     self.contents.draw_text(rect.x+4, yy, rect.width-8, WLH, actor.mp, 2)
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # * Item Rect
  258.   #--------------------------------------------------------------------------
  259.   def item_rect(index)
  260.     rect = Rect.new(0, 0, 0, 0)
  261.     rect.width = (contents.width + spacing) / col_max - spacing
  262.     rect.height = 288
  263.     rect.x = index % col_max * (rect.width + spacing)
  264.     rect.y = index / col_max * WLH
  265.     return rect
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # * Processing When OK Button Is Pressed
  269.   #--------------------------------------------------------------------------
  270.   def process_ok
  271.     super
  272.     $game_party.menu_actor = $game_party.members[index]
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # * Restore Previous Selection Position
  276.   #--------------------------------------------------------------------------
  277.   def select_last
  278.     select($game_party.menu_actor.index || 0)
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # * Set Pending Position (for Formation)
  282.   #--------------------------------------------------------------------------
  283.   def pending_index=(index)
  284.     last_pending_index = @pending_index
  285.     @pending_index = index
  286.     redraw_item(@pending_index)
  287.     redraw_item(last_pending_index)
  288.   end
  289. end
  290.  
  291. #==============================================================================
  292. # ** Window_MenuTimer
  293. #==============================================================================
  294.  
  295. class Window_MenuTimer < Window_Base
  296.   #--------------------------------------------------------------------------
  297.   # * Object Initialization
  298.   #--------------------------------------------------------------------------
  299.   def initialize
  300.     super(0, Graphics.height - 60, 120, 56)
  301.     self.contents.font.size = Font.default_size - 4
  302.     self.contents.font.shadow = false
  303.     self.contents.font.color = SSS::MENU_HELP_TEXT_COLOR
  304.     refresh
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # * Refresh
  308.   #--------------------------------------------------------------------------
  309.   def refresh
  310.     self.contents.clear
  311.     format = "%03d:%02d:%02d"
  312.     @game_time = Graphics.frame_count / Graphics.frame_rate
  313.     hours = @game_time / 3600
  314.     minutes = @game_time / 60 % 60
  315.     seconds = @game_time % 60
  316.     text = sprintf(format, hours, minutes, seconds)
  317.     self.contents.draw_text(0, 0, contents.width-4, WLH, text, 2)
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # * Update
  321.   #--------------------------------------------------------------------------
  322.   def update
  323.     super
  324.     refresh if @game_time != (Graphics.frame_count / Graphics.frame_rate)
  325.   end
  326. end
  327.  
  328. #==============================================================================
  329. # ** Window_MenuGold
  330. #==============================================================================
  331.  
  332. class Window_MenuGold < Window_Base
  333.   #--------------------------------------------------------------------------
  334.   # * Object Initialization
  335.   #--------------------------------------------------------------------------
  336.   def initialize
  337.     super(100, Graphics.height - 60, 120, 56)
  338.     self.contents.font.size = Font.default_size - 4
  339.     self.contents.font.shadow = false
  340.     self.contents.font.color = SSS::MENU_HELP_TEXT_COLOR
  341.     refresh
  342.   end
  343.   #--------------------------------------------------------------------------
  344.   # * Refresh
  345.   #--------------------------------------------------------------------------
  346.   def refresh
  347.     self.contents.clear
  348.     text = sprintf("%d%s", $game_party.gold, Vocab::currency_unit)
  349.     self.contents.draw_text(0, 0, contents.width-4, WLH, text, 0)
  350.   end
  351. end
  352.  
  353. #==============================================================================
  354. # ** Window_MenuLocation
  355. #==============================================================================
  356.  
  357. class Window_MenuLocation < Window_Base
  358.   #--------------------------------------------------------------------------
  359.   # * Object Initialization
  360.   #--------------------------------------------------------------------------
  361.   def initialize
  362.     super(Graphics.width/2-16, Graphics.height - 60, Graphics.width/2+16, 56)
  363.     self.contents.font.size = Font.default_size - 4
  364.     self.contents.font.shadow = false
  365.     self.contents.font.color = SSS::MENU_HELP_TEXT_COLOR
  366.     refresh
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # * Refresh
  370.   #--------------------------------------------------------------------------
  371.   def refresh
  372.     self.contents.clear
  373.     text = sprintf(SSS::MENU_LOCATION, $game_map.display_name)
  374.     self.contents.draw_text(4, 0, contents.width, WLH, text, 0)
  375.   end
  376. end
  377.  
  378. #==============================================================================
  379. # ** Scene_Menu
  380. #==============================================================================
  381.  
  382. class Scene_Menu
  383.   #--------------------------------------------------------------------------
  384.   # * Start processing
  385.   #--------------------------------------------------------------------------
  386.   alias start_sss_ff13_menu start unless $@
  387.   def start
  388.     start_sss_ff13_menu
  389.     create_background
  390.     start_ff13_menu_style
  391.     create_menu_back_items
  392.     @command_window.z += 100000
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   # * Create Background for Menu Screen
  396.   #--------------------------------------------------------------------------
  397.   def create_background
  398. #~     @background_sprite = Sprite.new
  399. #~     @background_sprite.bitmap = Cache.system(SSS::MENU_BACK_IMAGE)
  400. #~     update_menu_backgroundsuper
  401.     super
  402.     @background_sprite.color.set(0, 0, 0, 0)
  403.     b = Cache.system(SSS::MENU_BACK_IMAGE)
  404.     @background_sprite.bitmap.blt(0,0,b,b.rect,128)
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   # * Create Menu Back Items
  408.   #--------------------------------------------------------------------------
  409.   def create_menu_back_items
  410.     @menubackitem_sprite = Sprite.new(@viewport)
  411.     @menubackitem_sprite.z -= 100000
  412.     width = 160
  413.     height = @command_window.height-32
  414.     @menubackitem_sprite.bitmap = Bitmap.new(width, height)
  415.     bitmap = Cache.system(SSS::MENU_BACK_ITEM_IMAGE)
  416.     rect = Rect.new(0, 0, 160, 24)
  417.     y = 0
  418.     loop do
  419.       break if y >= height
  420.       @menubackitem_sprite.bitmap.blt(0, y, bitmap, rect)
  421.       y += 24
  422.     end
  423.     @menubackitem_sprite.y = @command_window.y+16
  424.   end
  425.   #--------------------------------------------------------------------------
  426.   # * Start Final Fantasy 13 Menu Style
  427.   #--------------------------------------------------------------------------
  428.   def start_ff13_menu_style
  429.     @gold_window.dispose
  430.     @gold_window = Window_MenuGold.new
  431.     @menu_timer_window = Window_MenuTimer.new
  432.     @location_window = Window_MenuLocation.new
  433.     @help_window = Window_MenuHelp.new
  434.     @help_window.x += 48
  435.     @help_window.width -= 48
  436.     @help_window.create_contents
  437.     @help_window.contents.font.size = Font.default_size - 4
  438.     @command_window.y = @help_window.height - 9
  439.     @status_window.dispose
  440.     x = @command_window.width
  441.     y = @help_window.height-9
  442.     @status_window = Window_MainMenuParty.new(x, y)
  443.     @command_window.x -= 4
  444.     @help_window.y += 12
  445.     update_help
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # * Update Help Window
  449.   #--------------------------------------------------------------------------
  450.   def update_help
  451.     return if @help_window_index == @command_window.index
  452.     @help_window_index = @command_window.index
  453.     text = SSS::MENU_HELP_WINDOW[@command_window.command_name(@help_window_index)].to_s
  454.     @help_window.set_text(text)
  455.   end
  456.  
  457.   # Little addition to update help
  458.   def update
  459.     super
  460.     update_help
  461.   end
  462. end
  463.  
  464. #===============================================================================
  465. #
  466. # END OF FILE
  467. #
  468. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement