Advertisement
LiTTleDRAgo

[RGSS] Custom Resolution - Adjust Menu Position (RTP)

Jan 14th, 2014
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 18.40 KB | None | 0 0
  1. #==============================================================================
  2. # ** Custom Resolution - Adjust Menu Position (Default Menu)
  3. # Version : 1.04
  4. # Author : LiTTleDRAgo
  5. #==============================================================================
  6. ($imported ||= {})[:custom_resolution_adjust_default_menu] = 1.04
  7.  
  8. " Delete This Script if you want to use default Resolution (640 x 480) "
  9.  
  10.  
  11.  
  12. text  = "This Script needs at least Custom Resolution v0.96 or "
  13. text += "Drago - Core Engine v1.40"
  14. Graphics.respond_to?(:snap_to_bitmap) || raise(text)
  15. #==============================================================================
  16. # ** Object
  17. #------------------------------------------------------------------------------
  18. #  
  19. #==============================================================================
  20. class Object
  21.   #--------------------------------------------------------------------------
  22.   # * New method: adjust_position_xy
  23.   #--------------------------------------------------------------------------
  24.   def adjust_position_xy(w = 640, h = 480)
  25.     _w, _h = Graphics.width, Graphics.height
  26.     x = (_w - w) / 2
  27.     y = (_h - h) / 2
  28.     return [x, y]
  29.   end
  30. end
  31. #==============================================================================
  32. # ** Window_Base
  33. #------------------------------------------------------------------------------
  34. #  This class is for all in-game windows.
  35. #==============================================================================
  36. class Window_Base
  37.   #--------------------------------------------------------------------------
  38.   # * Alias Listing
  39.   #--------------------------------------------------------------------------
  40.   $@ || alias_method(:drg_initialize_viewport_adjust, :initialize)
  41.   #--------------------------------------------------------------------------
  42.   # * Aliased method: initialize
  43.   #--------------------------------------------------------------------------
  44.   def initialize(x,y,width,height)
  45.     x1, y1 = adjust_position_xy
  46.     if @no_adjustment
  47.       return drg_initialize_viewport_adjust(x,y,width,height)
  48.     end
  49.     drg_initialize_viewport_adjust(x + x1,y + y1,width,height)
  50.   end
  51. end
  52.  
  53. #==============================================================================
  54. # ** Window_Message
  55. #------------------------------------------------------------------------------
  56. #  This message window is used to display text.
  57. #==============================================================================
  58.  
  59. class Window_Message
  60.   #--------------------------------------------------------------------------
  61.   # * Alias Listing
  62.   #--------------------------------------------------------------------------
  63.   $@ || alias_method(:drg_win_msg_initialize_viewport_adjust, :initialize)
  64.   $@ || alias_method(:drg_win_msg_update_viewport_adjust,     :update)
  65.   #--------------------------------------------------------------------------
  66.   # * Aliased method: initialize
  67.   #--------------------------------------------------------------------------
  68.   def initialize(*args)
  69.     @no_adjustment = true
  70.     @screen_width  = Graphics.width - 1
  71.     @screen_height = Graphics.height - 1
  72.     drg_win_msg_initialize_viewport_adjust(*args)
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # * Aliased method: update
  76.   #--------------------------------------------------------------------------
  77.   def update(*args)
  78.     if Graphics.respond_to?(:width) &&
  79.       (@screen_width != Graphics.width || @screen_height != Graphics.height)
  80.       @screen_width  = Graphics.width  
  81.       @screen_height = Graphics.height
  82.       self.width = @screen_width * 0.8125
  83.       self.height = @screen_height / 3
  84.       self.x = @screen_width / 2 - self.width / 2
  85.       self.y = @screen_height - self.height - 16
  86.       if self.contents && !self.contents.disposed?
  87.         self.contents.dispose
  88.       end
  89.       self.contents = Bitmap.new(width - 32, height - 32)
  90.     end
  91.     drg_win_msg_update_viewport_adjust(*args)
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Aliased method: reset_window
  95.   #--------------------------------------------------------------------------
  96.   if method_defined?(:reset_window) && !method_defined?(:drg_rst_window_v_adj)
  97.     alias_method(:drg_rst_window_v_adj, :reset_window)
  98.     def reset_window(*args)
  99.       drg_rst_window_v_adj(*args)
  100.       if !$game_temp.in_battle
  101.         case $game_system.message_position
  102.         when 0  # up
  103.           self.y = 16
  104.         when 1  # middle
  105.           self.y = @screen_height / 2 - self.height / 2
  106.         when 2  # down
  107.           self.y = @screen_height - self.height - 16
  108.         end
  109.       end
  110.     end
  111.   end
  112. end
  113.  
  114.  
  115. #==============================================================================
  116. # ** Scene_Menu
  117. #------------------------------------------------------------------------------
  118. #  This class performs menu screen processing.
  119. #==============================================================================
  120. class Scene_Menu
  121.   #--------------------------------------------------------------------------
  122.   # * Alias Listing
  123.   #--------------------------------------------------------------------------
  124.   $@ || alias_method(:drg_main_viewport_adjust,   :main)
  125.   $@ || alias_method(:drg_update_viewport_adjust, :update)
  126.   #--------------------------------------------------------------------------
  127.   # * Aliased method: main
  128.   #--------------------------------------------------------------------------
  129.   def main(*args)
  130.     @sprite_black = Sprite.new
  131.     @sprite_black.z = 0x3FFFFFFF
  132.     @sprite_black.bitmap = Graphics.snap_to_bitmap
  133.     drg_main_viewport_adjust(*args)
  134.     @sprite_black.disposed? || @sprite_black.dispose
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # * Aliased method: update
  138.   #--------------------------------------------------------------------------
  139.   def update(*args)
  140.     unless @adjusted
  141.       x, y = adjust_position_xy
  142.       @playtime_window.x += x
  143.       @playtime_window.y += y
  144.       @steps_window.x    += x
  145.       @steps_window.y    += y
  146.       @gold_window.x     += x
  147.       @gold_window.y     += y
  148.       @status_window.x   += x
  149.       @status_window.y   += y
  150.       @adjusted = true
  151.     end
  152.     @sprite_black.opacity -= 10
  153.     drg_update_viewport_adjust(*args)
  154.   end
  155. end
  156.  
  157. #==============================================================================
  158. # ** Scene_End
  159. #------------------------------------------------------------------------------
  160. #  This class performs game end screen processing.
  161. #==============================================================================
  162. class Scene_End
  163.   #--------------------------------------------------------------------------
  164.   # * Alias Listing
  165.   #--------------------------------------------------------------------------
  166.   $@ || alias_method(:drg_main_viewport_adjust,   :main)
  167.   $@ || alias_method(:drg_update_viewport_adjust, :update)
  168.   #--------------------------------------------------------------------------
  169.   # * Aliased method: main
  170.   #--------------------------------------------------------------------------
  171.   def main(*args)
  172.     @sprite_black = Sprite.new
  173.     @sprite_black.z = 0x3FFFFFFF
  174.     @sprite_black.bitmap = Graphics.snap_to_bitmap
  175.     drg_main_viewport_adjust(*args)
  176.     @sprite_black.disposed? || @sprite_black.dispose
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # * Aliased method: update
  180.   #--------------------------------------------------------------------------
  181.   def update(*args)
  182.     unless @adjusted
  183.       x, y = adjust_position_xy
  184.       @command_window.x += x
  185.       @command_window.y += y
  186.       @adjusted = true
  187.     end
  188.     @sprite_black.opacity -= 10
  189.     drg_update_viewport_adjust(*args)
  190.   end
  191. end
  192.  
  193. #==============================================================================
  194. # ** Scene_Shop
  195. #------------------------------------------------------------------------------
  196. #  This class performs shop screen processing.
  197. #==============================================================================
  198.  
  199. class Scene_Shop
  200.   #--------------------------------------------------------------------------
  201.   # * Alias Listing
  202.   #--------------------------------------------------------------------------
  203.   $@ || alias_method(:drg_main_viewport_adjust,   :main)
  204.   $@ || alias_method(:drg_update_viewport_adjust, :update)
  205.   #--------------------------------------------------------------------------
  206.   # * Aliased method: main
  207.   #--------------------------------------------------------------------------
  208.   def main(*args)
  209.     @sprite_black = Sprite.new
  210.     @sprite_black.z = 0x3FFFFFFF
  211.     @sprite_black.bitmap = Graphics.snap_to_bitmap
  212.     drg_main_viewport_adjust(*args)
  213.     @sprite_black.disposed? || @sprite_black.dispose
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # * Aliased method: update
  217.   #--------------------------------------------------------------------------
  218.   def update(*args)
  219.     unless @adjusted
  220.       x, y = adjust_position_xy
  221.       @gold_window.x += x
  222.       @gold_window.y += y
  223.       @adjusted = true
  224.     end
  225.     @sprite_black.opacity -= 10
  226.     drg_update_viewport_adjust(*args)
  227.   end
  228. end
  229.  
  230. #==============================================================================
  231. # ** Scene_Gameover
  232. #------------------------------------------------------------------------------
  233. #  This class performs game over screen processing.
  234. #==============================================================================
  235.  
  236. class Scene_Gameover
  237.   #--------------------------------------------------------------------------
  238.   # * Alias Listing
  239.   #--------------------------------------------------------------------------
  240.   $@ || alias_method(:drg_main_viewport_adjust,   :main)
  241.   $@ || alias_method(:drg_update_viewport_adjust, :update)
  242.   #--------------------------------------------------------------------------
  243.   # * Aliased method: main
  244.   #--------------------------------------------------------------------------
  245.   def main(*args)
  246.     @sprite_black = Sprite.new
  247.     @sprite_death = Sprite.new
  248.     @sprite_black.z = 0x3FFFFFFF
  249.     @sprite_death.z = @sprite_black.z - 10
  250.     @sprite_black.bitmap = Graphics.snap_to_bitmap
  251.     bitmap = RPG::Cache.gameover($data_system.gameover_name)
  252.     object = @sprite_death.bitmap = @sprite_black.bitmap.clone
  253.     object.stretch_blt(object.rect,bitmap,bitmap.rect)
  254.     Graphics.transition
  255.     26.times { (@sprite_black.opacity -= 10) && Graphics.update }
  256.     drg_main_viewport_adjust(*args)
  257.     @sprite_black.disposed? || @sprite_black.dispose
  258.     @sprite_death.disposed? || @sprite_death.dispose
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # * Aliased method: update
  262.   #--------------------------------------------------------------------------
  263.   def update(*args)
  264.     unless @adjusted
  265.       x, y = adjust_position_xy
  266.       #@sprite.x += x
  267.       #@sprite.y += y
  268.       @sprite.bitmap.dispose
  269.       @sprite.bitmap = @sprite_black.bitmap.dup
  270.       @adjusted = true
  271.     end
  272.     @sprite_black.opacity -= 10
  273.     drg_update_viewport_adjust(*args)
  274.   end
  275. end
  276.  
  277.  
  278. #==============================================================================
  279. # ** Scene_Title
  280. #------------------------------------------------------------------------------
  281. #  This class performs title screen processing.
  282. #==============================================================================
  283.  
  284. class Scene_Title
  285.   #--------------------------------------------------------------------------
  286.   # * Alias Listing
  287.   #--------------------------------------------------------------------------
  288.   $@ || alias_method(:drg_main_viewport_adjust,   :main)
  289.   $@ || alias_method(:drg_update_viewport_adjust, :update)
  290.   #--------------------------------------------------------------------------
  291.   # * Aliased method: main
  292.   #--------------------------------------------------------------------------
  293.   def main(*args)
  294.     @sprite_black = Sprite.new
  295.     #@sprite_title = Sprite.new
  296.     @sprite_black.z = 0x3FFFFFFF
  297.     #@sprite_title.z = @sprite_black.z - 10
  298.     @sprite_black.bitmap = Graphics.snap_to_bitmap
  299.     Graphics.transition
  300.     drg_main_viewport_adjust(*args)
  301.     @sprite_black.disposed? || @sprite_black.dispose
  302.     #@sprite_title.disposed? || @sprite_title.dispose
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # * Aliased method: update
  306.   #--------------------------------------------------------------------------
  307.   def update(*args)
  308.     unless @adjusted
  309.       bitmap = @sprite.bitmap
  310.       x, y = adjust_position_xy(bitmap.width, bitmap.height)
  311.       if bitmap
  312.         @sprite.x += x
  313.         @sprite.y += y
  314.       end
  315.       x, y = adjust_position_xy
  316.       @command_window.x += x
  317.       @command_window.y += y
  318.       @adjusted = true
  319.     end
  320.     @sprite_black.opacity -= 10
  321.     drg_update_viewport_adjust(*args)
  322.   end
  323. end
  324.  
  325.  
  326.  
  327. #==============================================================================
  328. # ** Scene_Battle
  329. #------------------------------------------------------------------------------
  330. #  This class performs battle screen processing.
  331. #==============================================================================
  332.  
  333. class Scene_Battle
  334.   #--------------------------------------------------------------------------
  335.   # * Alias Listing
  336.   #--------------------------------------------------------------------------
  337.   $@ || alias_method(:drg_main_viewport_adjust,   :main)
  338.   $@ || alias_method(:drg_update_viewport_adjust, :update)
  339.   #--------------------------------------------------------------------------
  340.   # * Aliased method: main
  341.   #--------------------------------------------------------------------------
  342.   def main(*args)
  343.     @sprite_black = Sprite.new
  344.     @sprite_black.z = 0x3FFFFFFF
  345.     @sprite_black.bitmap = Graphics.snap_to_bitmap
  346.     drg_main_viewport_adjust(*args)
  347.     @sprite_black.disposed? || @sprite_black.dispose
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # * Aliased method: update
  351.   #--------------------------------------------------------------------------
  352.   def update(*args)
  353.     unless @adjusted
  354.       x, y = adjust_position_xy
  355.       @actor_command_window.y += y
  356.       @adjusted = true
  357.     end
  358.     @sprite_black.opacity -= 10
  359.     drg_update_viewport_adjust(*args)
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # * Aliased method: phase3_setup_command_window
  363.   #--------------------------------------------------------------------------
  364.   if method_defined?(:phase3_setup_command_window)
  365.     $@ || alias_method(:drg_phase3_scwin_adjust, :phase3_setup_command_window)
  366.     def phase3_setup_command_window(*args)
  367.       drg_phase3_scwin_adjust(*args)
  368.       x, y = adjust_position_xy
  369.       @actor_command_window.x += x
  370.     end
  371.   end
  372. end
  373.  
  374.  
  375. #==============================================================================
  376. # ** Spriteset_Battle
  377. #------------------------------------------------------------------------------
  378. #  This class brings together battle screen sprites. It's used within
  379. #  the Scene_Battle class.
  380. #==============================================================================
  381.  
  382. class Spriteset_Battle
  383.   #--------------------------------------------------------------------------
  384.   # * Alias Listing
  385.   #--------------------------------------------------------------------------
  386.   unless method_defined?(:drg_spriteset_viewport_adjust)
  387.     alias_method :drg_spriteset_viewport_adjust, :update
  388.     #--------------------------------------------------------------------------
  389.     # * Aliased method: update
  390.     #--------------------------------------------------------------------------
  391.     def update(*args)
  392.       if viewport_size_change?
  393.         @viewport_screen_width  = Graphics.width
  394.         @viewport_screen_height = Graphics.height
  395.         [@viewport1,@viewport2,@viewport3,@viewport4].compact.each do |v|
  396.           w, h = v.rect.width, v.rect.height
  397.           x, y = adjust_position_xy
  398.           v.resize(Rect.new(x, y, w, h))
  399.         end
  400.       end
  401.       drg_spriteset_viewport_adjust(*args)
  402.     end
  403.     #--------------------------------------------------------------------------
  404.     # * New method: viewport_size_change?
  405.     #--------------------------------------------------------------------------
  406.     def viewport_size_change?
  407.       return true if @viewport_screen_width  != Graphics.width
  408.       return true if @viewport_screen_height != Graphics.height
  409.     end
  410.   end
  411. end
  412.  
  413. #==============================================================================
  414. # ** Window_Item
  415. #------------------------------------------------------------------------------
  416. #  This window displays items in possession on the item and battle screens.
  417. #==============================================================================
  418.  
  419. class Window_Item
  420.   #--------------------------------------------------------------------------
  421.   # * Alias Listing
  422.   #--------------------------------------------------------------------------
  423.   $@ || alias_method(:drg_initialize_item_adjust, :initialize)
  424.   #--------------------------------------------------------------------------
  425.   # * Aliased method: initialize
  426.   #--------------------------------------------------------------------------
  427.   def initialize(*args)
  428.     drg_initialize_item_adjust(*args)
  429.     if $game_temp.in_battle
  430.       x, y = adjust_position_xy
  431.       self.y += y
  432.     end
  433.   end
  434. end
  435.  
  436. #==============================================================================
  437. # ** Window_Skill
  438. #------------------------------------------------------------------------------
  439. #  This window displays usable skills on the skill and battle screens.
  440. #==============================================================================
  441. class Window_Skill
  442.   #--------------------------------------------------------------------------
  443.   # * Alias Listing
  444.   #--------------------------------------------------------------------------
  445.   $@ || alias_method(:drg_initialize_item_adjust, :initialize)
  446.   #--------------------------------------------------------------------------
  447.   # * Aliased method: initialize
  448.   #--------------------------------------------------------------------------
  449.   def initialize(*args)
  450.     drg_initialize_item_adjust(*args)
  451.     if $game_temp.in_battle
  452.       x, y = adjust_position_xy
  453.       self.y += y
  454.     end
  455.   end
  456. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement