SHOW:
|
|
- or go back to the newest paste.
| 1 | =begin | |
| 2 | #=============================================================================== | |
| 3 | Title: Unlimited Resolution | |
| 4 | Date: Oct 24, 2013 | |
| 5 | -------------------------------------------------------------------------------- | |
| 6 | ** Change log | |
| 7 | Nov 6, 2013 | |
| 8 | - added some plane modifications to fix parallax images | |
| 9 | Oct 24, 2013 | |
| 10 | - Initial release | |
| 11 | -------------------------------------------------------------------------------- | |
| 12 | ** Terms of Use | |
| 13 | * Free | |
| 14 | -------------------------------------------------------------------------------- | |
| 15 | ** Description | |
| 16 | ||
| 17 | This script modifies Graphics.resize_screen to overcome the 640x480 limitation. | |
| 18 | It also includes some code to properly display maps that are smaller than the | |
| 19 | screen size. | |
| 20 | ||
| 21 | Now you can have arbitrarily large game resolutions. | |
| 22 | ||
| 23 | -------------------------------------------------------------------------------- | |
| 24 | ** Installation | |
| 25 | ||
| 26 | You should place this script above all custom scripts | |
| 27 | ||
| 28 | -------------------------------------------------------------------------------- | |
| 29 | ** Usage | |
| 30 | ||
| 31 | As usual, simply resize your screen using the script call | |
| 32 | ||
| 33 | Graphics.resize_screen(width, height) | |
| 34 | ||
| 35 | -------------------------------------------------------------------------------- | |
| 36 | ** Credits | |
| 37 | ||
| 38 | Unknown author for overcoming the 640x480 limitation | |
| 39 | Lantier, from RMW forums for posting the snippet above | |
| 40 | Esrever for handling the viewport | |
| 41 | Jet, for the custom Graphics code | |
| 42 | ||
| 43 | #=============================================================================== | |
| 44 | =end | |
| 45 | $imported = {} if $imported.nil?
| |
| 46 | $imported["TH_UnlimitedResolution"] = true | |
| 47 | #=============================================================================== | |
| 48 | # ** Configuration | |
| 49 | #=============================================================================== | |
| 50 | class << SceneManager | |
| 51 | ||
| 52 | alias resolution_run run | |
| 53 | def run(*args, &block) | |
| 54 | Graphics.ensure_sprite | |
| 55 | resolution_run(*args, &block) | |
| 56 | end | |
| 57 | end | |
| 58 | ||
| 59 | module Graphics | |
| 60 | ||
| 61 | @@super_sprite = Sprite.new | |
| 62 | @@super_sprite.z = (2 ** (0.size * 8 - 2) - 1) | |
| 63 | ||
| 64 | class << self | |
| 65 | alias :th_large_screen_resize_screen :resize_screen | |
| 66 | ||
| 67 | def freeze(*args, &block) | |
| 68 | @@super_sprite.bitmap = snap_to_bitmap | |
| 69 | end | |
| 70 | ||
| 71 | def transition(time = 10, filename = nil, vague = nil) | |
| 72 | if filename | |
| 73 | @@super_sprite.bitmap = Bitmap.new(filename) | |
| 74 | end | |
| 75 | @@super_sprite.opacity = 255 | |
| 76 | incs = 255.0 / time | |
| 77 | time.times do |i| | |
| 78 | @@super_sprite.opacity = 255.0 - incs * i | |
| 79 | Graphics.wait(1) | |
| 80 | end | |
| 81 | @@super_sprite.bitmap.dispose if @@super_sprite.bitmap | |
| 82 | reform_sprite_bitmap | |
| 83 | Graphics.brightness = 255 | |
| 84 | end | |
| 85 | ||
| 86 | def reform_sprite_bitmap | |
| 87 | @@super_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height) | |
| 88 | @@super_sprite.bitmap.fill_rect(@@super_sprite.bitmap.rect, Color.new(0, 0, 0, 255)) | |
| 89 | end | |
| 90 | ||
| 91 | def fadeout(frames) | |
| 92 | incs = 255.0 / frames | |
| 93 | frames.times do |i| | |
| 94 | i += 1 | |
| 95 | Graphics.brightness = 255 - incs * i | |
| 96 | Graphics.wait(1) | |
| 97 | end | |
| 98 | end | |
| 99 | ||
| 100 | def fadein(frames) | |
| 101 | incs = 255.0 / frames | |
| 102 | frames.times do |i| | |
| 103 | Graphics.brightness = incs * i | |
| 104 | Graphics.wait(1) | |
| 105 | end | |
| 106 | end | |
| 107 | ||
| 108 | def brightness=(i) | |
| 109 | @@super_sprite.opacity = 255.0 - i | |
| 110 | end | |
| 111 | ||
| 112 | def brightness | |
| 113 | 255 - @@super_sprite.opacity | |
| 114 | end | |
| 115 | ||
| 116 | def ensure_sprite | |
| 117 | if @@super_sprite.disposed? | |
| 118 | @@super_sprite = Sprite.new | |
| 119 | @@super_sprite.z = (2 ** (0.size * 8 - 2) - 1) | |
| 120 | reform_sprite_bitmap | |
| 121 | end | |
| 122 | end | |
| 123 | end | |
| 124 | ||
| 125 | #----------------------------------------------------------------------------- | |
| 126 | # Unknown Scripter. Copied from http://pastebin.com/sM2MNJZj | |
| 127 | #----------------------------------------------------------------------------- | |
| 128 | def self.resize_screen(width, height) | |
| 129 | wt, ht = width.divmod(32), height.divmod(32) | |
| 130 | #wt.last + ht.last == 0 || fail('Incorrect width or height')
| |
| 131 | wh = -> w, h, off = 0 { [w + off, h + off].pack('l2').scan /.{4}/ }
| |
| 132 | w, h = wh.(width, height) | |
| 133 | ww, hh = wh.(width, height, 32) | |
| 134 | www, hhh = wh.(wt.first.succ, ht.first.succ) | |
| 135 | base = 0x10000000 # fixed? | |
| 136 | mod = -> adr, val { DL::CPtr.new(base + adr)[0, val.size] = val }
| |
| 137 | mod.(0x195F, "\x90" * 5) # ??? | |
| 138 | mod.(0x19A4, h) | |
| 139 | mod.(0x19A9, w) | |
| 140 | mod.(0x1A56, h) | |
| 141 | mod.(0x1A5B, w) | |
| 142 | mod.(0x20F6, w) | |
| 143 | mod.(0x20FF, w) | |
| 144 | mod.(0x2106, h) | |
| 145 | mod.(0x210F, h) | |
| 146 | # speed up y? | |
| 147 | #mod.(0x1C5E3, h) | |
| 148 | #mod.(0x1C5E8, w) | |
| 149 | zero = [0].pack ?l | |
| 150 | mod.(0x1C5E3, zero) | |
| 151 | mod.(0x1C5E8, zero) | |
| 152 | mod.(0x1F477, h) | |
| 153 | mod.(0x1F47C, w) | |
| 154 | mod.(0x211FF, hh) | |
| 155 | mod.(0x21204, ww) | |
| 156 | mod.(0x21D7D, hhh[0]) | |
| 157 | mod.(0x21E01, www[0]) | |
| 158 | mod.(0x10DEA8, h) | |
| 159 | mod.(0x10DEAD, w) | |
| 160 | mod.(0x10DEDF, h) | |
| 161 | mod.(0x10DEF0, w) | |
| 162 | mod.(0x10DF14, h) | |
| 163 | mod.(0x10DF18, w) | |
| 164 | mod.(0x10DF48, h) | |
| 165 | mod.(0x10DF4C, w) | |
| 166 | mod.(0x10E6A7, w) | |
| 167 | mod.(0x10E6C3, h) | |
| 168 | mod.(0x10EEA9, w) | |
| 169 | mod.(0x10EEB9, h) | |
| 170 | th_large_screen_resize_screen(width, height) | |
| 171 | end | |
| 172 | end | |
| 173 | ||
| 174 | #=============================================================================== | |
| 175 | # Esrever's code from | |
| 176 | # http://www.rpgmakervxace.net/topic/100-any-chance-of-higher-resolution-or-larger-sprite-support/page-2#entry7997 | |
| 177 | #=============================================================================== | |
| 178 | class Game_Map | |
| 179 | ||
| 180 | #-------------------------------------------------------------------------- | |
| 181 | # overwrite method: scroll_down | |
| 182 | #-------------------------------------------------------------------------- | |
| 183 | def scroll_down(distance) | |
| 184 | if loop_vertical? | |
| 185 | @display_y += distance | |
| 186 | @display_y %= @map.height * 256 | |
| 187 | @parallax_y += distance | |
| 188 | else | |
| 189 | last_y = @display_y | |
| 190 | dh = Graphics.height > height * 32 ? height : screen_tile_y | |
| 191 | @display_y = [@display_y + distance, height - dh].min | |
| 192 | @parallax_y += @display_y - last_y | |
| 193 | end | |
| 194 | end | |
| 195 | ||
| 196 | #-------------------------------------------------------------------------- | |
| 197 | # overwrite method: scroll_right | |
| 198 | #-------------------------------------------------------------------------- | |
| 199 | def scroll_right(distance) | |
| 200 | if loop_horizontal? | |
| 201 | @display_x += distance | |
| 202 | @display_x %= @map.width * 256 | |
| 203 | @parallax_x += distance | |
| 204 | else | |
| 205 | last_x = @display_x | |
| 206 | dw = Graphics.width > width * 32 ? width : screen_tile_x | |
| 207 | @display_x = [@display_x + distance, width - dw].min | |
| 208 | @parallax_x += @display_x - last_x | |
| 209 | end | |
| 210 | end | |
| 211 | ||
| 212 | end # Game_Map | |
| 213 | ||
| 214 | #============================================================================== | |
| 215 | # ■ Spriteset_Map | |
| 216 | #============================================================================== | |
| 217 | ||
| 218 | class Spriteset_Map | |
| 219 | ||
| 220 | #-------------------------------------------------------------------------- | |
| 221 | # overwrite method: create_viewports | |
| 222 | #-------------------------------------------------------------------------- | |
| 223 | def create_viewports | |
| 224 | if Graphics.width > $game_map.width * 32 && !$game_map.loop_horizontal? | |
| 225 | dx = (Graphics.width - $game_map.width * 32) / 2 | |
| 226 | else | |
| 227 | dx = 0 | |
| 228 | end | |
| 229 | dw = [Graphics.width, $game_map.width * 32].min | |
| 230 | dw = Graphics.width if $game_map.loop_horizontal? | |
| 231 | if Graphics.height > $game_map.height * 32 && !$game_map.loop_vertical? | |
| 232 | dy = (Graphics.height - $game_map.height * 32) / 2 | |
| 233 | else | |
| 234 | dy = 0 | |
| 235 | end | |
| 236 | dh = [Graphics.height, $game_map.height * 32].min | |
| 237 | dh = Graphics.height if $game_map.loop_vertical? | |
| 238 | @viewport1 = Viewport.new(dx, dy, dw, dh) | |
| 239 | @viewport2 = Viewport.new(dx, dy, dw, dh) | |
| 240 | @viewport3 = Viewport.new(dx, dy, dw, dh) | |
| 241 | @viewport2.z = 50 | |
| 242 | @viewport3.z = 100 | |
| 243 | end | |
| 244 | ||
| 245 | #-------------------------------------------------------------------------- | |
| 246 | # new method: update_viewport_sizes | |
| 247 | #-------------------------------------------------------------------------- | |
| 248 | def update_viewport_sizes | |
| 249 | if Graphics.width > $game_map.width * 32 && !$game_map.loop_horizontal? | |
| 250 | dx = (Graphics.width - $game_map.width * 32) / 2 | |
| 251 | else | |
| 252 | dx = 0 | |
| 253 | end | |
| 254 | dw = [Graphics.width, $game_map.width * 32].min | |
| 255 | dw = Graphics.width if $game_map.loop_horizontal? | |
| 256 | if Graphics.height > $game_map.height * 32 && !$game_map.loop_vertical? | |
| 257 | dy = (Graphics.height - $game_map.height * 32) / 2 | |
| 258 | else | |
| 259 | dy = 0 | |
| 260 | end | |
| 261 | dh = [Graphics.height, $game_map.height * 32].min | |
| 262 | dh = Graphics.height if $game_map.loop_vertical? | |
| 263 | rect = Rect.new(dx, dy, dw, dh) | |
| 264 | for viewport in [@viewport1, @viewport2, @viewport3] | |
| 265 | viewport.rect = rect | |
| 266 | end | |
| 267 | end | |
| 268 | ||
| 269 | end # Spriteset_Map | |
| 270 | ||
| 271 | #------------------------------------------------------------------------------- | |
| 272 | # FenixFyre's custom Plane, simply drawing a sprite. Needs to do something about | |
| 273 | # the y-axis | |
| 274 | #------------------------------------------------------------------------------- | |
| 275 | class Plane | |
| 276 | attr_reader :ox, :oy | |
| 277 | ||
| 278 | alias :th_unlimited_resolution_initialize :initialize | |
| 279 | def initialize(viewport = nil) | |
| 280 | th_unlimited_resolution_initialize(viewport) | |
| 281 | @sprite = Sprite.new(viewport) | |
| 282 | @bitmap = nil | |
| 283 | @ox = 0 | |
| 284 | @oy = 0 | |
| 285 | end | |
| 286 | ||
| 287 | def method_missing(symbol, *args) | |
| 288 | @sprite.method(symbol).call(*args) | |
| 289 | end | |
| 290 | ||
| 291 | def bitmap=(bitmap) | |
| 292 | @bitmap = bitmap | |
| 293 | refresh | |
| 294 | end | |
| 295 | ||
| 296 | def bitmap | |
| 297 | @sprite.bitmap | |
| 298 | end | |
| 299 | ||
| 300 | def ox=(ox) | |
| 301 | w = @sprite.viewport != nil ? @sprite.viewport.rect.width : Graphics.width | |
| 302 | @ox = ox % w | |
| 303 | @sprite.ox = @ox | |
| 304 | end | |
| 305 | ||
| 306 | def oy=(oy) | |
| 307 | h = @sprite.viewport != nil ? @sprite.viewport.rect.height : Graphics.height | |
| 308 | @oy = oy % h | |
| 309 | @sprite.oy = @oy | |
| 310 | end | |
| 311 | ||
| 312 | def z=(n) | |
| 313 | @sprite.z = n | |
| 314 | end | |
| 315 | ||
| 316 | def z | |
| 317 | @sprite.z | |
| 318 | end | |
| 319 | ||
| 320 | def refresh | |
| 321 | return if @bitmap.nil? | |
| 322 | w = @sprite.viewport != nil ? @sprite.viewport.rect.width : Graphics.width | |
| 323 | h = @sprite.viewport != nil ? @sprite.viewport.rect.height : Graphics.height | |
| 324 | if @sprite.bitmap != nil | |
| 325 | @sprite.bitmap.dispose | |
| 326 | end | |
| 327 | @sprite.bitmap = Bitmap.new(w * 2, h * 2) | |
| 328 | ||
| 329 | max_x = w / @bitmap.width | |
| 330 | max_y = h / @bitmap.height | |
| 331 | for x in 0..max_x | |
| 332 | for y in 0..max_y | |
| 333 | @sprite.bitmap.blt(x * @bitmap.width, y * @bitmap.height, | |
| 334 | @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height)) | |
| 335 | end | |
| 336 | end | |
| 337 | for i in 1...4 | |
| 338 | x = i % 2 * w | |
| 339 | y = i / 2 * h | |
| 340 | @sprite.bitmap.blt(x, y, @sprite.bitmap, Rect.new(0, 0, w, h)) | |
| 341 | end | |
| 342 | end | |
| 343 | end | |
| 344 | ||
| 345 | #============================================================================== | |
| 346 | # ■ Scene_Map | |
| 347 | #============================================================================== | |
| 348 | ||
| 349 | class Scene_Map < Scene_Base | |
| 350 | ||
| 351 | #-------------------------------------------------------------------------- | |
| 352 | # alias method: post_transfer | |
| 353 | #-------------------------------------------------------------------------- | |
| 354 | alias scene_map_post_transfer_ace post_transfer | |
| 355 | def post_transfer | |
| 356 | @spriteset.update_viewport_sizes | |
| 357 | scene_map_post_transfer_ace | |
| 358 | end | |
| 359 | ||
| 360 | end # Scene_Map |