Advertisement
Guest User

Untitled

a guest
Apr 26th, 2011
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.56 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Sky's Command Window Menu's
  4. # Started May 5, 2010
  5. # Completed May 6, 2010
  6. # Updated July 3, 2010
  7. #
  8. #===========================================================================
  9. #
  10. # Features :
  11. #    Version 1.0 - May 6, 2010
  12. #       - Make up a whole scene based around choice menu's
  13. #       - Easy to make your own command menu, and places
  14. #         choice number into a variable of your choice
  15. #    Version 1.1 -
  16. #       - Choices can be set to a default "Text" if they
  17. #         require a switch that is not on(Switches not required, so only
  18. #                                           if you use a switch)
  19. #    Version 1.2 - July 3, 2010
  20. #       - Can now use icons
  21. #
  22. #===========================================================================
  23. #
  24. # Credit (be sure to credit the following and rpgmakervx.net)
  25. # Sky00Valentine :creator and editor (You aren't required to include me, but I wouldn't mind if you did.)
  26. #    Celianna :for requesting the script here, http://www.rpgmakervx.net/index.php?showtopic=29557
  27. #
  28. #===========================================================================
  29. #
  30. # Terms of Use
  31. # ------------
  32. #
  33. #     Crediting Rpgmakervx.net and Celianna is the only thing I ask.
  34. #     However feel free to credit Sky00Valentine if you
  35. #     see fit.
  36. #
  37. #===========================================================================
  38. # Instructions
  39. # ------------
  40. # requires the SAATW script, I use it for some of my scripts so you may
  41. # or may not already have it.
  42. #
  43. # for each different scene you want you will have to make another hash.
  44. # what that means is you must make a new
  45. #
  46. #   Choice_Command_Text = {
  47. #      "Layout"      =>     0,
  48. #    "Variable"      =>     1,          
  49. #       "Title"      =>    "Title of Menu",  
  50. #      "Column"      =>    ["Left Column","Right Column"],
  51. #        "Next"      =>    Scene_Map.new,
  52. #             0      =>    ["1st command", "Right side of command",Switch #],
  53. #             1      =>    ["2nd command", "Right side of 2nd command"],
  54. #   }  NOTE: SWITCH NUMBER IS NOT REQUIRED ONLY USE IF YOU WANT THE CHOICE
  55. #            ACTIVATED BY A SWITCH
  56. #
  57. # Variable will be the variable you want to tie to your choice.  If you say
  58. # The Variable is 3,  When the menu pops up if you choose choice 6 then the
  59. # number 6 will be stored in the game variable 3.
  60. #
  61. # When you create a new hash add a new index to the Menu_Index hash which
  62. # includes the newly created hash.  Here is a before and after example,
  63. #
  64. # Before creating a new Menu Hash:
  65. #
  66. # Menu_Index = {
  67. #             0      =>     Test_Menu
  68. # }
  69. #
  70. # After I made a new hash called Example_Menu I get:
  71. #
  72. # Menu_Index = {
  73. #             0      =>       Test_Menu
  74. #             1      =>    Example_Menu
  75. # }
  76. #
  77. # Now to call a menu in game use the call script
  78. # $scene = Scene_Command.new(Menu_Index)
  79. # In the above example the Menu_Index for Test_Menu would be 0
  80. # and the Menu_Index for Example_Menu would be 1.
  81. # So if i use the call script
  82. #       $scene = Scene_Command.new(0)
  83. # then it will call the Test_Menu.
  84. #
  85. # Other than that it should explain itself.
  86. # Enjoy...
  87. #          
  88. # To use icons in the Command String use the following setup.
  89. #      /i[icon index number]
  90. # where icon number is the index of the icon
  91. # ex. /i[4] will show icon number 4
  92. #
  93. #===============================================================================
  94. module Sky
  95.   module Text    
  96.  
  97.     SWITCH_OFF =  "Switch not activated" # If a switch isn't activated this text will be displayed
  98.                               #              and if no switch was listed this will be ignored.
  99.  
  100.     Test_Menu = {
  101.       "Layout"      =>    0,           # The Layout you want to use
  102.     "Variable"      =>    1,           # Variable the choice will be stored in
  103.        "Title"      =>    "Title of Menu",  #The Title of the Menu
  104.       "Column"      =>    ["Left Column","Right Column"], # Names for the Columns
  105.         "Next"      =>    Scene_Map.new,  #What scene do you want after you leave this one.
  106.              0      =>    ["Super Potion",  "Right side of command",1], # Left command, Right Command, Switch(if needed)
  107.              1      =>    ["2nd command",  "Right side of 2nd command"],
  108.              2      =>    ["Just Make More", "You can leave this side empty."],
  109.              3      =>    ["If you need",  "" ],   #empty quotes will make it blank.
  110.              4      =>    ["A","This /i[1] Me"],
  111.              5      =>    ["/i[20]",""],
  112.              6      =>    ["A",""],
  113.              7      =>    ["A",""],
  114.              8      =>    ["A",""],
  115.              9      =>    ["A",""],
  116.             10      =>    ["A",""],
  117.             11      =>    ["A",""],
  118.             12      =>    ["A",""],
  119.     }
  120.  
  121.     Other_Menu = {
  122.       "Layout"      =>    1,          
  123.     "Variable"      =>    1,           # Variables can be the same if you like or different
  124.        "Title"      =>    "Another Title",  #The Title of the Menu
  125.       "Column"      =>    ["This Column","That Column"], # Names for the Columns
  126.         "Next"      =>    Scene_Menu.new(0),  #What scene do you want after you leave this one.
  127.              0      =>    ["I am command 1",  "Right side of command"], # Left command, Right Command. See no switch
  128.              1      =>    ["I am command 2",  ""],
  129.              2      =>    ["", "You can leave the other side empty too."],
  130.              3      =>    ["Do you get",  "it now?" ],   #empty quotes will make it blank.
  131.     }
  132.  
  133.     Next_Menu = {
  134.       "Layout"      =>    1,          
  135.     "Variable"      =>    1,           # Variables can be the same if you like or different
  136.        "Title"      =>    "Synthesis Shop",  #The Title of the Menu
  137.       "Column"      =>    ["Item","Ingredients"], # Names for the Columns
  138.         "Next"      =>    Scene_Map.new,  #What scene do you want after you leave this one.
  139.              0      =>    ["/i[64] Super Potion",  "2x /i[65] Potion"],
  140.              1      =>    ["/i[3] Mana Sword", "/i[64] Super Potion /i[1] Sword"],
  141.     }
  142.  
  143.     Question_Menu = {
  144.       "Layout"      =>    1,          
  145.     "Variable"      =>    1,           # Variables can be the same if you like or different
  146.        "Title"      =>    "What is 5 x 8",  #The Title of the Menu
  147.       "Column"      =>    ["",""], # Names for the Columns
  148.         "Next"      =>    Scene_Map.new,  #What scene do you want after you leave this one.
  149.              0      =>    ["A.",  "12"],
  150.              1      =>    ["B", "58"],
  151.              2      =>    ["C", "13"],
  152.              3      =>    ["D", "3"],
  153.              4      =>    ["E", "Im stupid to still be looking"],
  154.              5      =>    ["Trick", "What the heck is x?"],
  155.              6      =>    ["T?", "T? Wait what?"],
  156.     }
  157.     Menu_Index = {
  158.             0       =>   Test_Menu,
  159.             1       =>   Other_Menu,
  160.             2       =>   Next_Menu,
  161.             3       =>   Question_Menu,
  162.     }
  163.   end
  164. end
  165.  
  166. class SCommand_Window < Window_Selectable
  167.   def initialize(commands)
  168.     super(0,114,544,WLH*page_row_max+32)
  169.     @commands = commands
  170.     @item_max = commands.size - 5
  171.     @index = 0
  172.     create_contents
  173.     refresh
  174.     @normal = self.windowskin
  175.     self.windowskin = Bitmap.new("Graphics/System/No_Arrow_Window") rescue self.windowskin = @normal
  176.   end
  177.  
  178.   def refresh
  179.     for i in 0...@item_max
  180.       draw_item(i)
  181.     end
  182.   end
  183.  
  184.   def page_row_max
  185.     return 11
  186.   end
  187.  
  188.   def draw_item(index)
  189.     rect = item_rect(index)
  190.     rect.x += 4
  191.     rect.width -= 8
  192.     self.contents.clear_rect(rect)
  193.     if @commands[index].size == 3
  194.       self.contents.icon_text(rect.x,rect.y,rect.width,rect.height, @commands[index][0]) if $game_switches[@commands[index][2]]
  195.       self.contents.icon_text_right(rect.y,rect.width,24, @commands[index][1]) if $game_switches[@commands[index][2]]
  196.       self.contents.draw_text(rect, Sky::Text::SWITCH_OFF) unless $game_switches[@commands[index][2]]
  197.     else
  198.       self.contents.icon_text(rect.x,rect.y,rect.width,rect.height, @commands[index][0])
  199.       self.contents.icon_text_right(rect.y,rect.width,24, @commands[index][1])
  200.     end
  201.   end    
  202. end
  203.  
  204. class Scene_Command < Scene_Base
  205.  
  206.   def initialize(index)
  207.     @menu = Sky::Text::Menu_Index[index]
  208.   end
  209.  
  210.   def start
  211.     if @menu["Layout"] == 0
  212.       @veiwport = Viewport.new(0,0,544,416)
  213.       @header = Window_Base.new(0,0,544,56)
  214.       @header.contents.draw_text(0,0,508,24,@menu["Title"],1)
  215.       @window = Window_Base.new(0,56,544,360)
  216.       @window.contents.font.size = 32
  217.       @window.contents.draw_text(4,16,512,36,@menu["Column"][0])
  218.       @window.contents.draw_text(4,16,504,36,@menu["Column"][1],2)
  219.       @window.contents.font.size = 20    
  220.       @command_window = SCommand_Window.new(@menu)
  221.       @command_window.z = 101
  222.       @command_window.opacity = 0
  223.       create_menu_background
  224.     else
  225.       @veiwport = Viewport.new(0,0,544,416)
  226.       @header = Window_Base.new(0,0,544,64)
  227.       @header.contents.font.size = 32
  228.       @header.contents.draw_text(0,0,508,34,@menu["Title"],1)
  229.       @header.contents.font.size = 20
  230.       @window = Window_Base.new(0,64,544,352)
  231.       @window.contents.font.bold = true
  232.       @window.contents.draw_text(4,8,512,24,@menu["Column"][0])
  233.       @window.contents.draw_text(4,8,504,24,@menu["Column"][1],2)
  234.       @window.contents.font.bold = false    
  235.       @command_window = SCommand_Window.new(@menu)
  236.       @command_window.z = 101
  237.       @command_window.opacity = 0
  238.       create_menu_background
  239.     end
  240.   end
  241.  
  242.   def update
  243.     @header.update
  244.     @command_window.update
  245.     if Input.trigger?(Input::B)
  246.       Sound.play_cancel
  247.       $game_variables[@menu["Variable"]] = -1
  248.       dispose_windows
  249.     elsif Input.trigger?(Input::C)
  250.       if @menu[@command_window.index].size == 3
  251.         if $game_switches[@menu[@command_window.index][2]]
  252.           Sound.play_decision
  253.           $game_variables[@menu["Variable"]] = @command_window.index + 1
  254.           dispose_menu_background
  255.           @header.dispose
  256.           @command_window.dispose
  257.           @window.dispose
  258.           $scene = @menu["Next"]
  259.         else
  260.           Sound.play_buzzer
  261.         end
  262.       else
  263.         Sound.play_decision
  264.         $game_variables[@menu["Variable"]] = @command_window.index + 1
  265.         @header.dispose
  266.         @command_window.dispose
  267.         @window.dispose
  268.         $scene = @menu["Next"]
  269.       end
  270.     end
  271.   end
  272.  
  273.  
  274.   def dispose_windows
  275.     dispose_menu_background
  276.     @header.dispose
  277.     @command_window.dispose
  278.     @window.dispose
  279.     $scene = Scene_Map.new
  280.   end
  281. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement