Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

MOG Menu resolution

Hi,

I'm currently using MOG's set of menus (title screen, item screen, skills, the whole works) in conjunction with the following increased resolution script (altering screen size to 1024x768)

Code:
#################################################################################
#################################################################################
############################### Resolution #####################################
#################################################################################
#################################################################################
#========================================================================
# Script written by Renan Tsuneo Hangai Junior
#========================================================================
#========================================================================

class Game_Window
    
  WINDOW_WIDTH  = 1024
  
  WINDOW_HEIGHT = 768
  
  FULLSCREEN = false
  
   # Fixes viewports? 
   # Viewports wide 640 will be treated as width of the screen 
   # Viewports in height 480 will be treated as height of the screen 
   # Note to scripters ---------------- ---------------- 
   # By using this script and leave below true, use the method: 
   # Viewport.new (x, y, width, height, force_fix) 
   # Where if you do not define force_fix will always be true 
   # If you leave false, will not fix the standard
  # -----------------------------------------------------
  
  VIEWPORT_FIX = true
  
  attr_reader :x
  attr_reader :y
  attr_reader :width
  attr_reader :height
  
  def initialize
    @gpps = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
    @title = "\0" * 256
    @gpps.call("Game", "Title", "", @title, 256, ".\\Game.ini")
    @title.delete!("\0")
    @set_resolution   = Win32API.new('Display.dll', 'SetResolution', 'III', '')
    @set_window_long  = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
    @set_window_pos   = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
    @gsm              = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    @gcr              = Win32API.new('user32', 'GetClientRect', 'LP', 'I')
    @window           = Win32API.new('user32', 'FindWindow', 'PP', 'I').call("RGSS Player", @title)
    @kbe              = Win32API.new('user32', 'keybd_event', 'LLLL', '')
    @gaks             = Win32API.new('user32', 'GetAsyncKeyState', 'L', 'I')
    @gks              = Win32API.new('user32', 'GetKeyState', 'L', 'I')
    @default_size = self.size
    @width = WINDOW_WIDTH
    @height = WINDOW_HEIGHT
    if @default_size[0] < @width or @default_size[1] < @height
      print("Necessário uma resolução de vídeo de no mínimo #{@width} x #{@height}")
      exit
    end
    @x = (self.size[0] / 2) - (@width / 2)
    @y = (self.size[1] / 2) - (@height / 2)
    @height_add = 26
    @width_add = 6
    @state = "normal"
    if FULLSCREEN
      self.fullscreen
    else
      self.center
    end
  end
  
  def x=(valor)
    @x = valor
    @set_window_long.call(@window, -16, 0x14CA0000)
    @set_window_pos.call(@window, 0, @x, @y, @width + @width_add, @height + @height_add, 0)
  end
  
  def y=(valor)
    @y = valor
    @set_window_long.call(@window, -16, 0x14CA0000)
    @set_window_pos.call(@window, 0, @x, @y, @width + @width_add, @height + @height_add, 0)
  end
  
  def fullscreen
    return if @state == "full"
    @window_size = self.asize
    @state = "full"
    @set_window_long.call(@window, -16, 0x14000000)
    @set_window_pos.call(@window, -1, -1, -1, @width + 2, @height + 2, 64)
    @set_resolution.call(@width, @height, 4)
  end
  
  def normal
    return if @state == "normal"
    @window_size = self.asize
    @state = "normal"
    @set_resolution.call(@default_size[0], @default_size[1], 4)
    @set_window_long.call(@window, -16, 0x14CA0000)
    @set_window_pos.call(@window, 0, @x, @y, @width + @width_add, @height + @height_add, 0)
  end
  
  def center
    @x = self.size[0] / 2 - (@width / 2)
    @y = self.size[1] / 2 - (@height / 2)
    @set_window_long.call(@window, -16, 0x14CA0000)
    @set_window_pos.call(@window, 0, @x, @y, @width + @width_add, @height + @height_add, 0)
  end
  
  def size
    width = @gsm.call(0)
    height = @gsm.call(1)
    return width, height
  end
  
  def asize
    rect = [0, 0, 0, 0].pack('l4')
    @gcr.call(@window, rect)
    width, height = rect.unpack('l4')[2..3]
    return width, height
  end
  
  def trigger?(key)
    return (@gaks.call(key) & 0x01 == 1)
  end

  def pressed?(key)
    return (not @gks.call(key).between?(0, 1))
  end
  
  def update
    @kbe.call(18, 0, 2, 0) 
    if self.trigger?(115) or self.pressed?(115)
      exit
    end
    if self.trigger?(122)
      self.change
      Graphics.update
      sleep(0.1)
      Graphics.update
    end
  end
  
  def change
    if @state == "normal"
      self.fullscreen
    else
      self.normal
    end
  end

end

if Game_Window::VIEWPORT_FIX

  class Viewport
    
    alias resolution_viewport_initialize initialize
    
    def initialize(x, y, w, h, fix=true)
      if fix
        if w == 1024
          w = $window.width
        end
        if h == 768
          h = $window.height
        end
      end
      resolution_viewport_initialize(x, y, w, h)
    end
    
  end
  
end

module Graphics
  
  class << self
    
    alias game_resolution_graphics_update update
    
    def update
      game_resolution_graphics_update
      $window.update
    end

  end
  
end

$window = Game_Window.new

class Game_Player < Game_Character
  
  CENTER_X = ($window.width / 2 - 16) * 4
  CENTER_Y = ($window.height / 2 - 16) * 4
    
  def center(x, y)
    @@center_x = ($window.width / 2 - 16) * 4
    @@center_y = ($window.height / 2 - 16) * 4
    maxsizex = ($window.width / 32.0) # .ceil
    maxsizey = ($window.height / 32.0) # .ceil
    max_x = (($game_map.width - maxsizex) * 128).to_i
    max_y = (($game_map.height - maxsizey) * 128).to_i
    $game_map.display_x = [0, [x * 128 - @@center_x, max_x].min].max
    $game_map.display_y = [0, [y * 128 - @@center_y, max_y].min].max
  end
  
end

class Game_Map
  
  #--------------------------------------------------------------------------
  # - Scroll para Baixo
  #
  #     distance : distância do scroll
  #--------------------------------------------------------------------------
  
  def scroll_down(distance)
    @display_y = [@display_y + distance, (self.height * 128) - ($window.height * 4)].min
  end
  
  #--------------------------------------------------------------------------
  # - Scroll para Direita
  #
  #     distance : distância do scroll
  #--------------------------------------------------------------------------
  
  def scroll_right(distance)
    @display_x = [@display_x + distance, (self.width * 128) - ($window.width * 4)].min
  end
  
end

class Tilemap
  #--------------------------------------------------------------------------
    attr_accessor :tileset
    attr_accessor :tileset
    attr_accessor :autotiles
    attr_accessor :map_data
    attr_accessor :flash_data
    attr_accessor :priorities
    attr_accessor :visible
    attr_accessor :ox
    attr_accessor :oy
  #--------------------------------------------------------------------------
  def initialize(viewport)
    @map = []
    width, height = $game_map.width * 32, $game_map.height * 32
    for p in 0...2
      @map[p] = Sprite.new(viewport)
      @map[p].bitmap = Bitmap.new(width, height )
    end
    @map[0].z = 0
    @map[1].z = 3000
    @tileset_tile_width = 32
    @tileset_tile_height = 32
    @tileset = nil
    @autotiles = []
    @autotiles2 = []
    @map_data = nil
    @data = nil
    @flash_data = nil
    @priorities = nil
    @visible = true
    @ox = 0
    @oy = 0
  end
  #--------------------------------------------------------------------------
  def update
    if @data != @map_data
      refresh
    end
  end
  def ox=(valor)
    return if @ox == valor
    @ox = valor
    for p in 0...2
      @map[p].ox = @ox
    end
  end
  def oy=(valor)
    return if @oy == valor
    @oy = valor
    for p in 0...2
      @map[p].oy = @oy
    end
  end
  #--------------------------------------------------------------------------
  def refresh
    @data = @map_data
    generate_autotiles2
    for p in 0..5
      for z in 0...@map_data.zsize
        for x in 0...@map_data.xsize
          for y in 0...@map_data.ysize
            id = @map_data[x,y,z]
            next if @priorities[id] != p
            refresh_autotiles(x,y,p,id) if id < 384
            refresh_tileset(x,y,p,id) if id >= 384
          end
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  def refresh_autotiles(x,y,p,id)
    p = [p, 1].min
    if id >= 48 and id <= 95
      sy = id - 48
      sy /= 8
      sx = id - 48
      sx = sx - (8 * sy)
      src_rect = Rect.new(sx*32, sy*32, 32, 32)
      @map[p].bitmap.blt(x*32, y*32, @autotiles2[0], src_rect)
    end
  end
  #--------------------------------------------------------------------------
  def refresh_tileset(x,y,p,id)
    p = [p, 1].min
    sy = id - 384
    sy /= 8
    sx = id - 384
    sx = sx - (8 * sy)
    src_rect = Rect.new(sx*32, sy*32, 32, 32)
    @map[p].bitmap.blt(x*32, y*32, @tileset, src_rect)
  end
  #--------------------------------------------------------------------------
  def dispose
    for p in 0...2
      @map[p].bitmap.dispose
    end
  end
  #======================================
  #   â–  Generates Autotiles
  #   By: Fuso
  #   Generates the tiles used by the game (can be seen in the editor by
  #   doubleclicking an autotile field), from the images given as
  #   resources.
  #======================================
  def generate_autotiles2(ats = @autotiles, frame_id = 0)
    h = 32
    w = 32
    for at in 0..6
      @autotiles2[at] = Bitmap.new(@tileset_tile_width * 8, @tileset_tile_height * 6) if @autotiles2[at].nil?
      break if at >= @autotiles.size
      # Generate the 16 tiles containing water and a number of corners.
      # Each bit in i will represent whether or not a certain corner will be filled in.
      for i in 0...16
        @autotiles2[at].blt(i % 8 * w,             i / 8 * h,            ats[at], Rect.new(frame_id * 3 * w + w,           2 * h, w,      h)) if i < 15
        @autotiles2[at].blt(i % 8 * w,             i / 8 * h,            ats[at], Rect.new(frame_id * 3 * w + 2 * w,      0,      w / 2, h / 2)) if i & 0x1 == 0x1
        @autotiles2[at].blt(i % 8 * w + w / 2, i / 8 * h,            ats[at], Rect.new(frame_id * 3 * w + 5 * w / 2, 0,      w / 2, h / 2)) if i & 0x2 == 0x2
        @autotiles2[at].blt(i % 8 * w + w / 2, i / 8 * h + h / 2, ats[at], Rect.new(frame_id * 3 * w + 5 * w / 2, h / 2, w / 2, h / 2)) if i & 0x4 == 0x4
        @autotiles2[at].blt(i % 8 * w,             i / 8 * h + h / 2, ats[at], Rect.new(frame_id * 3 * w + 2 * w,      h / 2, w / 2, h / 2)) if i & 0x8 == 0x8
      end
      # Generate the 16 tiles containing a certain whole strip + up to 2 corners.
      # The two most signifant bits will hold the direction of the strip and the other
      # two bits whether or not the remaining 2 corners will be filled in.
      for i in 0...16
        d = i / 4
        # The strip.
        #@autotiles2[at].blt(i % 8 * w + (d==3 ? w / 2 : 0), 2 * h + i / 8 * h + (d==4 ? h / 2 : 0), ats[at],
        #  Rect.new(d == 0 ? 0 : d == 2 ? 5 * d / 4 : d, d == 1 ? h : d == 3 ? 7 * h / 4 : 2 * h,
        #               (d&3 + 1) * w / 2, (4 - d&3) * h / 2))
        @autotiles2[at].blt(i % 8 * w, (2 + i / 8) * h, ats[at], Rect.new(frame_id * 3 * w + d == 0 ? 0 : d == 2 ? 2 * w : w, d == 1 ? h : d == 3 ? 3 * h : 2 * h, w, h))
        l1 = (d + 1)%4
        l2 = (d + 2)%4
        x1 = (l1 == 1 or l1 == 2) ? w / 2 : 0
        x2 = (l2 == 1 or l2 == 2) ? w / 2 : 0
        y1 = l1/2 * h / 2
        y2 = l2/2 * h / 2
        @autotiles2[at].blt(i % 8 * w + x1, (2 + i / 8) * h + y1, ats[at], Rect.new(frame_id * 3 * w + 2 * w + x1, y1, w / 2,  h / 2)) if i & 0x1 == 0x1
        @autotiles2[at].blt(i % 8 * w + x2, (2 + i / 8) * h + y2, ats[at], Rect.new(frame_id * 3 * w + 2 * w + x2, y2, w / 2,  h / 2)) if i & 0x2 == 0x2
      end
      # The "double-strip" tiles.
      @autotiles2[at].blt(0,       4 * h,           ats[at], Rect.new(frame_id * 3 * w + 0,            2 * h,             w,      h))
      @autotiles2[at].blt(w / 2, 4 * h,           ats[at], Rect.new(frame_id * 3 * w + 5 * w / 2, 2 * h,             w / 2, h))
      @autotiles2[at].blt(w,      4 * h,           ats[at], Rect.new(frame_id * 3 * w + w,            h,                  w,      h))
      @autotiles2[at].blt(w,      4 * h + h /2, ats[at], Rect.new(frame_id * 3 * w + w,            3 * h + h / 2, w, h / 2))
      for i in 0...4
        @autotiles2[at].blt((2 + 2 * i)%8 * w, (4 + i/3) * h, ats[at], Rect.new(frame_id * 3 * w + ((i == 1 or i == 2) ? 2 * w : 0), ((i&2) + 1) * h, w, h))
        @autotiles2[at].blt((3 + 2 * i)%8 * w, (4 + i/3) * h, ats[at], Rect.new(frame_id * 3 * w + ((i == 1 or i == 2) ? 2 * w : 0), ((i&2) + 1) * h, w, h))
        l = (i + 2)%4
        x = (l == 1 or l == 2) ? w / 2 : 0
        y = l/2 * h / 2
        @autotiles2[at].blt((3 + 2 * i)%8 * w + x, (4 + i/3) * h + y, ats[at], Rect.new(frame_id * 3 * w + 2 * w + x, y, w / 2,  h / 2))
      end
      for i in 0...4
        @autotiles2[at].blt((i + 2) * w, 5 * h, ats[at], Rect.new(frame_id * 3 * w + i/2 * 2 * w, (i == 1 or i == 2) ? 3 * h : h, w, h))
        l = (i + 3) % 4
        dx = (l == 3 ? w / 2 : 0)
        dy = (l == 2 ? h / 2 : 0)
        tx = (l < 2 ? 0 : 2 * w)
        ty = (l == 0 ? 0 : l == 3 ? 0 : 2 * h)
        @autotiles2[at].blt((i + 2) * w + dx, 5 * h + dy, ats[at], Rect.new(frame_id * 3 * w + tx + dx, h + ty + dy, w - l%2 * w / 2, h / 2 + l%2 * h / 2))
      end
      # The final two squares which is simply the upper left one and possiby a merge of the
      # inner corners, we'll make them both the first tile for now.
      @autotiles2[at].blt(6 * w, 5 * h, ats[at], Rect.new(0, 0, w, h))
      @autotiles2[at].blt(7 * w, 5 * h, ats[at], Rect.new(0, 0, w, h))
    end
  end
end

class Spriteset_Map
  #--------------------------------------------------------------------------
  def initialize
    width, height  = $window.size
    @viewport1 = Viewport.new(0, 0, width, height)
    @viewport_panormas = []
    for i in 1..4
      x = ((i - 1) % 2) * 640
      y = ((i - 1) / 2) * 480
      v = Viewport.new(x, y, 640, 480)
      v.z = @viewport1.z - 1
      @viewport_panormas.push(v)
    end
    @viewport_fogs = []
    for i in 1..4
      x = ((i - 1) % 2) * 640
      y = ((i - 1) / 2) * 480
      v = Viewport.new(x, y, 640, 480)
      v.z = @viewport1.z + 1
      @viewport_fogs.push(v)
    end
    @viewport2 = Viewport.new(0, 0, width, height)
    @viewport3 = Viewport.new(0, 0, width, height)
    @viewport2.z = 200
    @viewport3.z = 5000
    @tilemap = Tilemap.new(@viewport1)
    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
    for i in 0..6
      autotile_name = $game_map.autotile_names[i]
      @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
    end
    @tilemap.map_data = $game_map.data
    @tilemap.priorities = $game_map.priorities
    @panoramas = []
    panorama = Plane.new(@viewport_panormas[0])
    panorama.z = -1000
    @panoramas.push(panorama)
    panorama = Plane.new(@viewport_panormas[1])
    panorama.z = -1000
    @panoramas.push(panorama)
    panorama = Plane.new(@viewport_panormas[2])
    panorama.z = -1000
    @panoramas.push(panorama)
    panorama = Plane.new(@viewport_panormas[3])
    panorama.z = -1000
    @panoramas.push(panorama)
    @fogs = []
    fog = Plane.new(@viewport_fogs[0])
    fog.z = 3000
    @fogs.push(fog)
    fog = Plane.new(@viewport_fogs[1])
    fog.z = 3000
    @fogs.push(fog)
    fog = Plane.new(@viewport_fogs[2])
    fog.z = 3000
    @fogs.push(fog)
    fog = Plane.new(@viewport_fogs[3])
    fog.z = 3000
    @fogs.push(fog)
    @character_sprites = []
    for i in $game_map.events.keys.sort
      sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
      @character_sprites.push(sprite)
    end
    @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
    @weather = RPG::Weather.new(@viewport1)
    @picture_sprites = []
    for i in 1..50
      @picture_sprites.push(Sprite_Picture.new(@viewport2,
        $game_screen.pictures[i]))
    end
    @timer_sprite = Sprite_Timer.new
    update
  end
  
  #--------------------------------------------------------------------------
  # - Display
  #--------------------------------------------------------------------------
  
  def dispose
    
    @tilemap.tileset.dispose
    for i in 0..6
      @tilemap.autotiles[i].dispose
    end
    @tilemap.dispose
    
    for panorama in @panoramas
      panorama.dispose
    end
    
    for fog in @fogs
      fog.dispose
    end
    
    for sprite in @character_sprites
      sprite.dispose
    end
    
    @weather.dispose
    
    for sprite in @picture_sprites
      sprite.dispose
    end
    
    @timer_sprite.dispose
    
    @viewport1.dispose
    for v in @viewport_panormas + @viewport_fogs
      v.dispose
    end
    @viewport2.dispose
    @viewport3.dispose
  end
  
  #--------------------------------------------------------------------------
  # - Frame Update
  #--------------------------------------------------------------------------
  
  def update
    
    if @panorama_name != $game_map.panorama_name or
      @panorama_hue != $game_map.panorama_hue
      @panorama_name = $game_map.panorama_name
      @panorama_hue = $game_map.panorama_hue
      if @panorama_bitmap != nil
        @panorama_bitmap.dispose
        @panorama_bitmap = nil
      end
      if @panorama_name != ""
        @panorama_bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
        for p in @panoramas
          p.bitmap = @panorama_bitmap
        end
      end
      Graphics.frame_reset
    end
    #
    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
      @fog_name = $game_map.fog_name
      @fog_hue = $game_map.fog_hue
      if @fog_bitmap != nil
        @fog_bitmap.dispose
        @fog_bitmap = nil
      end
      if @fog_name != ""
        @fog_bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
        for p in @fogs
          p.bitmap = @fog_bitmap
        end
      end
      Graphics.frame_reset
    end
    
    @tilemap.ox = $game_map.display_x / 4
    @tilemap.oy = $game_map.display_y / 4
    @tilemap.update
    
    for i in 0...@panoramas.size
      panorama = @panoramas[i]
      rwadd = (i % 2) * (@panorama_bitmap.nil? ? 0 : 640 - @panorama_bitmap.width)
      rhadd = (i / 2) * (@panorama_bitmap.nil? ? 0 : 480 - @panorama_bitmap.height)
      panorama.ox = $game_map.display_x / 8 + rwadd
      panorama.oy = $game_map.display_y / 8 + rhadd
    end
    for i in 0...@fogs.size
      fog = @fogs[i]
      
      fog.zoom_x = $game_map.fog_zoom / 100.0
      fog.zoom_y = $game_map.fog_zoom / 100.0
      fog.opacity = $game_map.fog_opacity
      fog.blend_type = $game_map.fog_blend_type
      rwadd = (i % 2) * (@fog_bitmap.nil? ? 0 : (@fog_bitmap.width) / 2)
      rhadd = (i / 2) * 480
      fog.ox = $game_map.display_x / 4 + $game_map.fog_ox + rwadd
      fog.oy = $game_map.display_y / 4 + $game_map.fog_oy + rhadd
      fog.tone = $game_map.fog_tone
    end
    
    for sprite in @character_sprites
      sprite.update
    end
    
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.ox = $game_map.display_x / 4
    @weather.oy = $game_map.display_y / 4
    @weather.update
    
    for sprite in @picture_sprites
      sprite.update
    end
    
    @timer_sprite.update
    
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    for v in @viewport_panormas + @viewport_fogs
      v.tone = $game_screen.tone
      v.ox = $game_screen.shake
    end
    
    @viewport3.color = $game_screen.flash_color
    
    @viewport1.update
    @viewport3.update
  end
end

However, I can't find any lines of code in MOG's scripts that allow me to change the resolution of the menus. I edited the image files to fit 1024x768 but they still cut off on the screen and appear to be 640x480, despite the screen size being correct (leaving big black gaps of nothing)

Basically, I want to know if anyone's ever had success resizing MOG's menu scripts. Thanks for your time

Please use code tags even if it's inside a spoiler. Thanks.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top