Advertisement
AngryPacman

Compact Menu Add-on

Aug 22nd, 2011
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.21 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Compact Menu System
  4. # 22/8/2011 - Pacman
  5. # Paste above main and below any scripts that alter the menu. This script was
  6. # first intended for usage with PAC Main Menu, but it works perfectly fine
  7. # standalone.
  8. # Edit the configuration module as you see fit below. I think I've explained
  9. # everything pretty thoroughly.
  10. #
  11. #===============================================================================
  12.  
  13. module PAC
  14.   module MM
  15.    
  16.     # Pixels per frame the windows move (number)
  17.     COMPACT_SCROLL_SPEED = 4
  18.     # Direction the command window will move to when actor selection begins
  19.     # (:left / :right)
  20.     COMPACT_SELECTION = :right
  21.     # Button to toggle gold window visibility (Input::Button)
  22.     GOLD_BUTTON = Input::L
  23.     # Start scene with gold window visible? (true / false)
  24.     START_GOLD_WINDOW = true
  25.   end
  26. end
  27.  
  28. #===============================================================================
  29. #
  30. # Why would you even think about editing this?
  31. #
  32. #===============================================================================
  33.  
  34. $imported = {} unless $imported
  35. $imported["PAC Compact Menu"] = true
  36.  
  37. #==============================================================================
  38. # ** Scene_Menu
  39. #------------------------------------------------------------------------------
  40. #  This class performs the menu screen processing.
  41. #==============================================================================
  42.  
  43. class Scene_Menu < Scene_Base
  44.   #--------------------------------------------------------------------------
  45.   # Include configuration data
  46.   #--------------------------------------------------------------------------
  47.   include PAC::MM
  48.   #--------------------------------------------------------------------------
  49.   # Alias listing
  50.   #--------------------------------------------------------------------------
  51.   alias pac_compact_start start
  52.   alias pac_compact_start_actor_selection start_actor_selection
  53.   alias pac_compact_end_actor_selection end_actor_selection
  54.   alias pac_compact_update update
  55.   #--------------------------------------------------------------------------
  56.   # * Start Processing
  57.   #--------------------------------------------------------------------------
  58.   def start
  59.     pac_compact_start
  60.     pac_compact_windows
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # * Make Windows Compact
  64.   #--------------------------------------------------------------------------
  65.   def pac_compact_windows
  66.     @command_window.x = Graphics.width / 2 - @command_window.width / 2
  67.     @gold_window.visible = START_GOLD_WINDOW
  68.     @gold_window.x = @command_window.x
  69.     @gold_window.openness = START_GOLD_WINDOW ? 255 : 0
  70.     @status_window.x = case COMPACT_SELECTION
  71.     when :left then Graphics.width - @status_window.width
  72.     when :right then 0
  73.     end
  74.     @status_window.visible = false
  75.     @status_window.openness = 0
  76.     if @gold_window.visible
  77.       @command_window.y = Graphics.height / 2 - (@command_window.height +
  78.       @gold_window.height) / 2
  79.     else
  80.       @command_window.y = Graphics.height / 2 - @command_window.height / 2
  81.     end
  82.     @gold_window.y = @command_window.y + @command_window.height
  83.     @check_x = @command_window.x
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # * Start Actor Selection
  87.   #--------------------------------------------------------------------------
  88.   def start_actor_selection
  89.     @status_window.visible = true
  90.     check = case COMPACT_SELECTION
  91.     when :left then 0
  92.     when :right then Graphics.width - @command_window.width
  93.     end
  94.     begin
  95.       @command_window.x -= case COMPACT_SELECTION
  96.       when :left then COMPACT_SCROLL_SPEED
  97.       when :right then -COMPACT_SCROLL_SPEED
  98.       end
  99.       @gold_window.x = @command_window.x
  100.       Graphics.update
  101.     end until @command_window.x == check
  102.     @status_window.open
  103.     begin
  104.       @status_window.update
  105.       Graphics.update
  106.     end until @status_window.openness == 255
  107.     pac_compact_start_actor_selection
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # * End Actor Selection
  111.   #--------------------------------------------------------------------------
  112.   def end_actor_selection
  113.     pac_compact_end_actor_selection
  114.     @status_window.close
  115.     begin
  116.       @status_window.update
  117.       Graphics.update
  118.     end until @status_window.openness == 0
  119.     @status_window.visible = false
  120.     begin
  121.       unless @command_window.x == @check_x
  122.         @command_window.x += case COMPACT_SELECTION
  123.         when :left then COMPACT_SCROLL_SPEED
  124.         when :right then -COMPACT_SCROLL_SPEED
  125.         end
  126.       end
  127.       @gold_window.x = @command_window.x
  128.       Graphics.update
  129.     end until @command_window.x == @check_x
  130.   end
  131.   #--------------------------------------------------------------------------
  132.   # * Frame Update
  133.   #--------------------------------------------------------------------------
  134.   def update
  135.     pac_compact_update
  136.     update_gold_visible
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # * Update Visibility of Gold Window (and scroll to cater)
  140.   #--------------------------------------------------------------------------
  141.   def update_gold_visible
  142.     @gold_window.x = @command_window.x if @gold_window.x != @command_window.x
  143.     if Input.trigger?(GOLD_BUTTON)
  144.       Sound.play_decision
  145.       if @gold_window.visible
  146.         @gold_window.close
  147.         begin
  148.           @gold_window.update
  149.           Graphics.update
  150.         end until @gold_window.openness == 0
  151.         @gold_window.visible = false
  152.         begin
  153.           @command_window.y += COMPACT_SCROLL_SPEED
  154.           @command_window.update
  155.           Graphics.update
  156.         end until @command_window.y == Graphics.height / 2 -
  157.          @command_window.height / 2
  158.        else
  159.         begin
  160.           @command_window.y -= COMPACT_SCROLL_SPEED
  161.           @command_window.update
  162.           Graphics.update
  163.         end until @command_window.y == Graphics.height / 2 -
  164.          (@command_window.height + @gold_window.height) / 2
  165.         @gold_window.visible = true
  166.         @gold_window.open
  167.         begin
  168.           @gold_window.update
  169.           Graphics.update
  170.         end until @gold_window.openness == 255
  171.       end
  172.     end
  173.   end
  174. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement