Advertisement
Falmc

Untitled

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