IceDragon200

SceneMouse

Jun 13th, 2011
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.48 KB | None | 0 0
  1. #==============================================================================
  2. # ** Scene_Mouse
  3. #------------------------------------------------------------------------------
  4. #  This class performs mouse configuration processing.
  5. #==============================================================================
  6.  
  7. class Scene_Mouse < Scene_Base
  8.   #--------------------------------------------------------------------------
  9.   # * Start processing
  10.   #--------------------------------------------------------------------------
  11.   def start
  12.     super
  13.     create_menu_background
  14.     create_command_window
  15.     @help_window = Window_Help.new()
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # * Post-Start Processing
  19.   #--------------------------------------------------------------------------
  20.   def post_start
  21.     super
  22.     open_command_window
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # * Pre-termination Processing
  26.   #--------------------------------------------------------------------------
  27.   def pre_terminate
  28.     super
  29.     close_command_window
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # * Termination Processing
  33.   #--------------------------------------------------------------------------
  34.   def terminate
  35.     super
  36.     dispose_command_window()
  37.     @help_window.dispose() unless @help_window.nil?()
  38.     dispose_menu_background()
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # * Return to Original Screen
  42.   #--------------------------------------------------------------------------
  43.   def return_scene
  44.     $scene = Scene_Menu.new(5)
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # * Frame Update
  48.   #--------------------------------------------------------------------------
  49.   def update
  50.     super
  51.     update_menu_background
  52.     @command_window.update
  53.     case @command_window.commands[ @command_window.index ]
  54.     when "On"          ; @help_window.set_text( "Turn Mouse ON" )
  55.     when "Off"         ; @help_window.set_text( "Turn Mouse OFF" )
  56.     when Vocab::cancel ; @help_window.set_text( "Cancel" )
  57.     end  
  58.     if Input.trigger?(Input::B)
  59.       Sound.play_cancel
  60.       return_scene
  61.     elsif Input.trigger?(Input::C) && $game_switches[474]
  62.       case @command_window.index
  63.       when 0  # mouse on
  64.         command_mouse_on
  65.       when 1  # cancel
  66.         command_cancel
  67.       end
  68.     elsif Input.trigger?(Input::C) && !$game_switches[474]
  69.         case @command_window.index
  70.         when 0 #mouse off
  71.           command_mouse_off
  72.         when 1 #cancel
  73.           command_cancel
  74.       end
  75.     end
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # * Update Background for Menu Screen
  79.   #--------------------------------------------------------------------------
  80.   def update_menu_background
  81.     super
  82.     @menuback_sprite.tone.set(0, 0, 0, 128)
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # * Create Command Window
  86.   #--------------------------------------------------------------------------
  87.   def create_command_window
  88.     if $game_switches[474]
  89.       s1 = "On"
  90.       s2 = Vocab::cancel
  91.     else
  92.       s1 = "Off"
  93.       s2 = Vocab::cancel
  94.     end
  95.     @command_window = Window_Command.new(172, [s1, s2])
  96.     @command_window.x = (544 - @command_window.width) / 2
  97.     @command_window.y = (416 - @command_window.height) / 2
  98.     @command_window.openness = 0
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Dispose of Command Window
  102.   #--------------------------------------------------------------------------
  103.   def dispose_command_window
  104.     @command_window.dispose
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # * Open Command Window
  108.   #--------------------------------------------------------------------------
  109.   def open_command_window
  110.     @command_window.open
  111.     begin
  112.       @command_window.update
  113.       Graphics.update
  114.     end until @command_window.openness == 255
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # * Close Command Window
  118.   #--------------------------------------------------------------------------
  119.   def close_command_window
  120.     @command_window.close
  121.     begin
  122.       @command_window.update
  123.       Graphics.update
  124.     end until @command_window.openness == 0
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # * Process When Choosing [On] Command
  128.   #--------------------------------------------------------------------------
  129.   def command_mouse_on
  130.     Sound.play_decision
  131.     $game_switches[474] = false
  132.     $cursor.opacity = 255
  133.     $cursor.update
  134.     return_scene
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # * Process When Choosing [Off] Command
  138.   #--------------------------------------------------------------------------
  139.   def command_mouse_off
  140.     Sound.play_decision
  141.     $game_switches[474] = true
  142.     $cursor.opacity = 0
  143.     $cursor.update
  144.     return_scene
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # *  Process When Choosing [Cancel] Command
  148.   #--------------------------------------------------------------------------
  149.   def command_cancel
  150.     Sound.play_decision
  151.     return_scene
  152.   end
  153.  
  154. end
Advertisement
Add Comment
Please, Sign In to add comment