Advertisement
Guest User

RAFAEL_SOL_MAKER's VX MAP ADJUSTER v1.0

a guest
Nov 17th, 2011
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.76 KB | None | 0 0
  1. #===============================================================================
  2. #      RAFAEL_SOL_MAKER's VX MAP ADJUSTER v1.0 (Add-on for screen resolution)
  3. #-------------------------------------------------------------------------------
  4. # Description:   Automatically resize your map if it's smaller than the screen
  5. #               size, to prevent a bug in the map scrolling.
  6. #               It warns you when you run the game, and you can save the map
  7. #               with the size already corrected and filled up, if in test mode.
  8. #               This code was made for me considering the fact that it's not
  9. #               possible to resize Map Tables directly without crashing the game
  10. #               OBS.: Generally speaking, it requires a "resolution script" to
  11. #                scale the screen size and so do some real work...
  12. #-------------------------------------------------------------------------------
  13. # How to Use: Just configure it in the advanced configuration module(below).
  14. #-------------------------------------------------------------------------------
  15. # Special Thanks: -
  16. #-------------------------------------------------------------------------------
  17. #===============================================================================
  18.  
  19. module PowerPackVX_Advanced_Configs
  20.   Auto_Resize_Map = true    # Automatically resize the smaller maps?
  21.   Save_Resized_Map = false  # Save the scaled map?
  22.   Filler_Tile_ID = 2816     # Tile ID to fill the gaps
  23. end
  24.  
  25. class Game_Map
  26. include PowerPackVX_Advanced_Configs
  27.  
  28.   alias sol_maker_setup setup unless $@
  29.   def setup(map_id)
  30.     sol_maker_setup (map_id)
  31.     if Auto_Resize_Map
  32.       # Discover what the minimum ideal size for the map;
  33.       wd = Graphics.width / 32
  34.       wd += 1 if (Graphics.width % 32) > 0
  35.       hg = Graphics.height / 32
  36.       hg += 1 if (Graphics.height % 32) > 0    
  37.       if @map.width < wd or @map.height < hg
  38.         if $TEST
  39.           p 'The map must have a minimum size of ' + wd.to_s +
  40.             ' tiles of width, and '+ hg.to_s +
  41.             ' tiles of height for the selected resolution;',
  42.             'It will be automatically resized to this size. '
  43.           resize_map (wd,hg)
  44.         end #if $TEST
  45.       end #if map width/height
  46.     end #if Resize
  47.   end
  48.  
  49.  
  50.   def resize_map (mapwidth, mapheight)  
  51.     # Create a bew map;
  52.     map2 = RPG::Map.new ([@map.width, mapwidth].max, [@map.height, mapheight].max)    
  53.     # Fill it with the one-tile pattern...
  54.     for x in 0.. map2.width-1
  55.       for y in 0..map2.height-1
  56.         map2.data[x,y,0] = Filler_Tile_ID
  57.         map2.data[x,y,1] = 0
  58.         map2.data[x,y,2] = 0
  59.       end
  60.     end
  61.     # "Put" the open map into the new;
  62.     for x in 0..@map.width-1
  63.       for y in 0..@map.height-1
  64.         for z in 0..2
  65.           map2.data[x,y,z] = @map.data[x,y,z]
  66.         end
  67.       end
  68.     end
  69.     # Copy all properties, obviously;
  70.     map2.scroll_type = @map.scroll_type
  71.     map2.autoplay_bgm = @map.autoplay_bgm
  72.     map2.bgm = @map.bgm
  73.     map2.autoplay_bgs = @map.autoplay_bgs
  74.     map2.bgs = @map.bgs
  75.     map2.disable_dashing = @map.disable_dashing
  76.     map2.encounter_list = @map.encounter_list
  77.     map2.encounter_step = @map.encounter_step
  78.     map2.parallax_name = @map.parallax_name
  79.     map2.parallax_loop_x = @map.parallax_loop_x
  80.     map2.parallax_loop_y = @map.parallax_loop_y
  81.     map2.parallax_sx = @map.parallax_sx
  82.     map2.parallax_sy = @map.parallax_sy
  83.     map2.parallax_show = @map.parallax_show
  84.     map2.events = @map.events
  85.     # The map is finally ready, discards the temporary map.
  86.     @map = map2; map2 = nil
  87.     if Save_Resized_Map
  88.       save_data(@map, sprintf("Data/Map%03d.rvdata", @map_id))
  89.       p 'The map has been properly resized and saved successfully!'
  90.     end
  91.   end
  92.  
  93. end
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement