Advertisement
Falmc

Rmvxace Game resolution 1.1

Aug 7th, 2012
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.00 KB | None | 0 0
  1. #===========================================================================#
  2. #  #*****************#              Game Resolution 1.1                     #
  3. #  #*** By Falcao ***#              Add the resolution option to the menu   #
  4. #  #*****************#              RMVXACE Date Aungust 6 2012             #
  5. #===========================================================================#
  6.  
  7. #---------------------------------------------------------------------------
  8. # This script add a resolution option to the game menu, you can choose from
  9. # Normal screen 544 x 416 and Full screen, also it remember your last option
  10. # when you start the game.
  11. #
  12. # Installation: copy and paste above main
  13. #--------------------------------------------------------------------------
  14.  
  15. module FalRes
  16.   def self.write_decision
  17.     File.delete("System/Resolution.txt") rescue nil
  18.     File.open("System/Resolution.txt","a+") {|fh|fh.puts($game_resolution)}
  19.   end
  20.  
  21.   def self.read_decision
  22.     decision = File.read("System/Resolution.txt").split("\n") rescue [0]
  23.     return decision.last.to_i
  24.   end
  25.  
  26.   def self.resolution
  27.     res = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
  28.     res.call(18,0,0,0)
  29.     res.call(13,0,0,0)
  30.     res.call(13,0,2,0)
  31.     res.call(18,0,2,0)
  32.   end
  33.   $game_resolution = self.read_decision
  34.   self.resolution if $game_resolution == 1
  35. end
  36.  
  37. class Window_MenuCommand < Window_Command
  38.   alias falcao_addnew_command add_original_commands
  39.   def add_original_commands
  40.     add_command('Resolution',   :reso, main_commands_enabled)
  41.     falcao_addnew_command
  42.   end
  43. end
  44.  
  45. class Scene_Menu < Scene_MenuBase
  46.   alias falcao_reso_command create_command_window
  47.   def create_command_window
  48.     falcao_reso_command
  49.     @command_window.set_handler(:reso,     method(:resolution_window))
  50.   end
  51.  
  52.   def resolution_window
  53.     @commands_reso = Window_ResoCommand.new
  54.     @commands_reso.set_handler(:normal,    method(:reso_selection))
  55.     @commands_reso.set_handler(:full,      method(:reso_selection))
  56.     @commands_reso.set_handler(:cancel,    method(:cancelar))
  57.   end
  58.  
  59.   def reso_selection
  60.     case @commands_reso.current_symbol
  61.     when :normal
  62.       if $game_resolution == 1
  63.         $game_resolution = 0
  64.         make_resolution
  65.       else
  66.         cancelar ; return
  67.       end
  68.     @commands_reso.activate
  69.     when :full
  70.       if $game_resolution == 0
  71.         $game_resolution = 1
  72.         make_resolution
  73.       else
  74.         cancelar ; return
  75.       end
  76.       @commands_reso.activate
  77.     end
  78.   end
  79.  
  80.   def make_resolution
  81.     FalRes.resolution
  82.     FalRes.write_decision
  83.   end
  84.  
  85.   def cancelar
  86.     @commands_reso.dispose
  87.     @commands_reso = nil
  88.     @command_window.activate
  89.   end
  90. end
  91.  
  92. class Window_ResoCommand < Window_Command
  93.   def initialize
  94.     super(164, 130)
  95.     self.openness = 0
  96.     open
  97.   end
  98.   def window_width
  99.     return 180
  100.   end
  101.   def make_command_list
  102.     add_command('Normal 544x416',     :normal)
  103.     add_command('Full Screen ',       :full)
  104.   end
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement