Advertisement
Black_Mage

Max Resolution Addon RMVXA Script

Jun 27th, 2019
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.75 KB | None | 0 0
  1. #==============================================================================
  2. # Some stuff to enhance Max Resolution Script. Put this script below it.
  3. # By Black Mage
  4. # Version 1.3
  5. #
  6. # This script required Max Resolution Script to function properly. You can get
  7. # the script at:
  8. # https://pastebin.com/FyLyMzis
  9. #
  10. # You can add Tsukihime's Map Screenshot Script on your project to have a
  11. # better transition when changing into a higher resolution. The original script
  12. # function will be disabled, but you can turn it on through a setting below if
  13. # you wan to use it.
  14. # You can ge the script at:
  15. # http://himeworks.com/2013/02/map-screenshot/
  16. #
  17. # -----------------------------------------------------------------------------
  18. # What this script actualy do?
  19. #
  20. # Well, there's this black bar occupying the window if you change into a higher
  21. # resolution from map. When you access the menu, and back to the map again, the
  22. # black bar is gone, and you can freely change the resolution back and forth
  23. # without have to worry that the black bar will appear, unless you're changing
  24. # into a new higher resolution compared to the last resolution where the black
  25. # bar appeared.
  26. #
  27. # This script run a dummy scene to simulate the menu access in order to fix the
  28. # black bar problem when a higher resolution change is happened.
  29. # -----------------------------------------------------------------------------
  30. # Note that the Max Resolution Script has a memory dependancy. If somehow your
  31. # project crashes when doing a playtest, just do some other stuff and hope that
  32. # when you playtest and changing resolution again, nothing wrong happened. XD
  33. #
  34. # Don't immediately playtest when a crashes occured!
  35. # -----------------------------------------------------------------------------
  36. # Stuff that's not fixed yet from Max Resolution Script:
  37. # If you're on a big map, and you change resolution from the right corner of
  38. # the map, your map camera might shot a wrong part of the map for a few seconds,
  39. # or until you move your character to left for a bit.
  40. #
  41. # I'm not sure when I'll fix this in the future. If you somehow able to fix it,
  42. # let me know.
  43. #==============================================================================
  44.  
  45. #==============================================================================
  46. # Changelog
  47. # Version 1.3
  48. # - Add Hime Map Screenshot integration for a better transition.
  49. #
  50. # Version 1.2
  51. # - Fix some bugs that made it unable to change resolution through other scene
  52. #   except Scene_Map.
  53. #
  54. # Version 1.1
  55. # - Add Game_Temp initialize, in case the resolution is changed when it's not
  56. #   initialized yet.
  57. #
  58. # Version 1.0
  59. # - Initial Version.
  60. #==============================================================================
  61.  
  62. module BLACK
  63.   # Set this to true if you have Hime Map Screenshot script on your project and
  64.   # want to use it's original feature on your game.
  65.   HIME_MAPSHOT = false
  66. end
  67.  
  68. $imported = {} if $imported.nil?
  69. $imported["BM_MaxResoAddon"] = true
  70.  
  71. class Game_Temp; attr_accessor :b_size; end
  72.  
  73. module Graphics
  74.   class << self; alias :b_r_s :resize_screen; end
  75.   attr_reader :b_width; attr_reader :b_height
  76.   def self.resize_screen(width, height)
  77.     if SceneManager.scene_is?(Scene_Map)
  78.       (save_w_h(width, height); return) if (!@b_width && !@b_height)
  79.       (save_w_h(width, height); return) if (@b_width < width) && (@b_height < height)
  80.     end
  81.     b_r_s(width, height)
  82.   end
  83.   def self.save_w_h(width, height)
  84.     $game_temp = Game_Temp.new if !$game_temp
  85.     $game_temp.b_size = [width, height]
  86.     SceneManager.call(Black_Scene)
  87.     Window_MenuCommand::init_command_position
  88.     @b_width = width; @b_height = height
  89.   end
  90. end
  91.  
  92. class Black_Scene < Scene_MenuBase
  93.   def update
  94.     super; a = $game_temp.b_size
  95.     Graphics.resize_screen(a[0], a[1])
  96.     SceneManager.return
  97.   end
  98.   def create_background
  99.     @background_sprite = Sprite.new
  100.     @background_sprite.bitmap = SceneManager.reso_bmp
  101.    
  102.     # Hime Mapshot integration
  103.     if $imported["TH_MapSaver"]
  104.       w, h = [Graphics.width, Graphics.height]
  105.       m_s1 = [($game_map.width * 32) - w, ($game_map.height * 32) - h]
  106.       m_s2 = [$game_player.x * 32 - w/2 + 16, $game_player.y * 32 - h/2 + 32]
  107.       error = [w/2 - $game_player.screen_x, h/2 - $game_player.screen_y]
  108.       m_s2 = [m_s2[0] + error[0], m_s2[1] + error[1]]
  109.       cor = [[[m_s2[0], 0].max, m_s1[0]].min, [[m_s2[1], 0].max, m_s1[1]].min]
  110.       @background_sprite.x = -cor[0]
  111.       @background_sprite.y = -cor[1]
  112.     end
  113.    
  114.   end
  115. end
  116.  
  117. module SceneManager
  118.   @reso_bmp = nil
  119.   class << self; alias :black_s_f_b :snapshot_for_background; end
  120.   def self.snapshot_for_background
  121.     black_s_f_b
  122.     @reso_bmp.dispose if @reso_bmp
  123.    
  124.     # Hime Mapshot integration
  125.     if $imported["TH_MapSaver"] && $game_map.map_id != 0
  126.       s = Map_Saver.new($game_map.map_id)
  127.       s.set_scale(TH::Map_Saver::Mapshot_Scale)        
  128.       @reso_bmp = s.blackshot
  129.     else
  130.       @reso_bmp = Graphics.snap_to_bitmap
  131.     end
  132.    
  133.   end
  134.   def self.reso_bmp; @reso_bmp; end
  135. end
  136.  
  137. if $imported["TH_MapSaver"] && BLACK::HIME_MAPSHOT
  138. #==============================================================================
  139. # This will disable Tsukihime's Map Screenshot Script from triggering, as we
  140. # don't want it to do so.
  141. #==============================================================================
  142. class Game_Player < Game_Character; def update; th_mapsaver_update; end; end
  143. end
  144.  
  145. if $imported["TH_MapSaver"]
  146. #==============================================================================
  147. # New function for Hime Map_Saver
  148. #==============================================================================
  149. class Map_Saver
  150.   def blackshot; @screen_local = false; redraw; return @map_image; end
  151. end
  152. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement