Advertisement
Guest User

Untitled

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