#=============================================================================== # # Yanfly Engine RD - Common Event Menu # Last Date Updated: 2009.06.12 # Level: Normal, Hard # # Similar to the Common Event Shop, the Common Event Menu lets you create your # menus to list various common event options. Now, you don't have to use all of # those obnoxiously tedious Show Choice branches and conditional branches just # to let the player get somewhere in range. # # This script lets you create your own generated common event menus with ease. # Set the style of the menu, the nature of the menu, and the contents of the # menu. Afterwards, set the switches (if required) for the common events to # even appear, any pictures to go along with it, and descriptions on what the # common event can do for the player. # #=============================================================================== # Updates: # ---------------------------------------------------------------------------- # o 2009.06.12 - Finished script. # o 2009.06.11 - Started script. #=============================================================================== # Instructions #=============================================================================== # # First, bind CE_MENU_VARIABLE to the variable you wish to launch common event # menus with. # # Scroll down and edit the CE_MENU_HASH. This will reflect what common events # appear in those menus, the style of the menu, and the title associated with # the menu. # # Scroll down and edit the CE_MENU_ITEMS. This will determine how common events # can be shown, what switches they require, and if it will display any pictures # along with it. # # Then, to launch the menu, just change the CE_MENU_VARIABLE variable to the # menu ID you want to launch. Simple as that. # #=============================================================================== # Style Names # "General" - A very normal kind of menu. # "Compact" - A smaller version of the General style. # "Double" - Displays two columns for the menu. # "Bottom" - Aligns the choices at the bottom of the screen. # "Lefty" - Aligns the choices to the left side of the screen. # "Righty" - Aligns the choices to the right side of the screen. # "Gimmick" - A pretty gimmicky style. #=============================================================================== # # Compatibility # - Alias: Game_Interpreter: command_122 # #=============================================================================== $imported = {} if $imported == nil $imported["CommonEventMenu"] = true module YE module EVENT # This is the variable that triggers the kind of shop you want to open. CE_MENU_VARIABLE = 70 #------------------------------------------------------------------------- # Use the following hash to determine what common events you can launch # from that menu ID. You can set the style, whether or not the player can # cancel out of the menu, and the title of the menu. Of course, you also # set what common events can be launched from this menu, too. # # Style Name - Style name used. Look in the instructions to view styles. # Cancel - Can the player cancel out of the menu? # Title - Title used for the menu. # [Array] - Common events allowed to be choosen in the menu. #------------------------------------------------------------------------- CE_MENU_HASH ={ # Follow the example. # MenuID => [ Style Name, Cancel, Title 1 => [ "Gimmick", true, "Common Event Teleporter", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ], # The above array lists the common events selectable. 2 => [ "General", true, "Yet another common event launcher.", [1, 2, 3, 4, 5, 6] ], # The above array lists the common events selectable. 3 => [ "Double", true, "Double the columns!", [1, 2, 3, 4] ], # The above array lists the common events selectable. } # Do not remove this. #------------------------------------------------------------------------- # Use the following hash to determine how you want your common events to # appear. To hide some items, set a switch number to the value shown. To # display a picture along with the common event, include the picture name. # To change the font size used, set the size. And finally, you can adjust # the description given to the common event to be launched. # # Switch - Switch required to be on for it to appear. nil for no switch. # Picture - Picture shown in the display window. nil for no picture shown. # Size - Font size used for the display window. # Descrip - Description used for event. Use | to create a new line. #------------------------------------------------------------------------- CE_MENU_ITEMS ={ # Follow the example. # ItemID => [Switch, Picture, Size, Description] 1 => [ nil, "warp01", 16, "Teleports you to Capitalia!"], 2 => [ nil, nil, 16, "Teleports you to Subclassia!"], 3 => [ nil, nil, 16, "Teleports you to Eqskislo-|vatia!"], 4 => [ nil, nil, 16, "Teleports you to Magma-|molten!"], 5 => [ nil, nil, 16, "Teleports you to Yerd Town!"], 6 => [ nil, nil, 16, "Teleports you to Alternate|Capitalia!"], 7 => [ 2, nil, 16, "Teleports you to The|Beyond!"], 8 => [ 3, nil, 16, "Teleports you to Anibat|Constria!"], 9 => [ 4, nil, 16, "Teleports you to Wonganistan!"], 10 => [ 5, nil, 16, "Teleports you to Margaret's|Castle!"], } # Do not remove this. end # EVENT end # YE #=============================================================================== # Editting anything past this point may potentially result in causing computer # damage, incontinence, explosion of user's head, coma, death, and/or halitosis. # Therefore, edit at your own risk. #=============================================================================== #=============================================================================== # Game_Interpreter #=============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # alias control variables #-------------------------------------------------------------------------- alias command_122_cemenu command_122 unless $@ def command_122 n = command_122_cemenu if @params[0] == YE::EVENT::CE_MENU_VARIABLE and !$game_temp.in_battle and $game_variables[YE::EVENT::CE_MENU_VARIABLE] != 0 $scene = Scene_Common_Event_Menu.new end return n end end # Game_Interpreter #=============================================================================== # Scene_Common_Event_Menu #=============================================================================== class Scene_Common_Event_Menu < Scene_Base #-------------------------------------------------------------------------- # initialize #-------------------------------------------------------------------------- def initialize menu_id = $game_variables[YE::EVENT::CE_MENU_VARIABLE] @style = YE::EVENT::CE_MENU_HASH[menu_id][0] @cancel = YE::EVENT::CE_MENU_HASH[menu_id][1] @title = YE::EVENT::CE_MENU_HASH[menu_id][2] @items = YE::EVENT::CE_MENU_HASH[menu_id][3] end #-------------------------------------------------------------------------- # start #-------------------------------------------------------------------------- def start super @spriteset = Spriteset_Map.new create_windows refresh_display end #-------------------------------------------------------------------------- # create_windows #-------------------------------------------------------------------------- def create_windows #--- if @style == "General" # General Style @title_window = Window_Base.new(0, 0, 544, 56) @title_window.contents.draw_text(4, 0, 504, 24, @title, 1) @command_width = 272 @columns = 1 create_command_window @command_window.x = 0 @command_window.y = 56 @command_window.height = 360 @display_window = Window_Event_Display.new(272, 56, 272, 360, "tall") return end #--- if @style == "Compact" # Compact Style @title_window = Window_Base.new(48, 48, 448, 56) @title_window.contents.draw_text(4, 0, 408, 24, @title, 1) @command_width = 224 @columns = 1 create_command_window @command_window.x = 48 @command_window.y = 104 @command_window.height = 264 @display_window = Window_Event_Display.new(272, 104, 224, 264, "tall") return end #--- if @style == "Double" # Double Style @title_window = Window_Base.new(0, 0, 544, 56) @title_window.contents.draw_text(4, 0, 504, 24, @title, 1) @command_width = Graphics.width @columns = 2 create_command_window @command_window.x = 0 @command_window.y = 56 @command_window.height = 232 @display_window = Window_Event_Display.new(0, 288, 544, 128, "wide") return end #--- if @style == "Bottom" # Bottom Style @title_window = Window_Base.new(0, 0, Graphics.width, 56) @title_window.contents.draw_text(4, 0, Graphics.width-40, 24, @title, 1) @command_width = Graphics.width @columns = 2 create_command_window @command_window.x = 0 @command_window.y = Graphics.height - 128 @command_window.height = 128 return end #--- if @style == "Lefty" # Lefty Style @title_window = Window_Base.new(0, 0, 200, 56) @title_window.contents.draw_text(4, 0, 160, 24, @title, 1) @command_width = 200 @columns = 1 create_command_window @command_window.x = 0 @command_window.y = 56 @command_window.height = Graphics.height - 56 - 128 @display_window = Window_Event_Display.new(0, 288, 200, 128, "no text") return end #--- if @style == "Righty" # Righty Style @title_window = Window_Base.new(344, 0, 200, 56) @title_window.contents.draw_text(4, 0, 160, 24, @title, 1) @command_width = 200 @columns = 1 create_command_window @command_window.x = 344 @command_window.y = 56 @command_window.height = Graphics.height - 56 - 128 @display_window = Window_Event_Display.new(344, 288, 200, 128, "no text") return end #--- if @style == "Gimmick" # Compact Style @title_window = Window_Base.new(48, 48, 448, 56) @title_window.contents.draw_text(4, 0, 408, 24, @title, 1) @dummy_window = Window_Base.new(48, 104, 448, 264) @command_width = 224 @columns = 1 create_command_window @command_window.x = 48 @command_window.y = 104 @command_window.height = 264 @display_window = Window_Event_Display.new(272, 104, 224, 264, "tall") @command_window.opacity = 0 @display_window.opacity = 0 return end end #-------------------------------------------------------------------------- # create_command_window #-------------------------------------------------------------------------- def create_command_window commands = [] @data = [] for item_id in @items next unless YE::EVENT::CE_MENU_ITEMS.include?(item_id) next if YE::EVENT::CE_MENU_ITEMS[item_id][0] != nil and !$game_switches[YE::EVENT::CE_MENU_ITEMS[item_id][0]] item_name = $data_common_events[item_id].name commands.push(item_name) @data.push(item_id) end @command_window = Window_Command.new(@command_width, commands, @columns) @last_id = commands.size + 1 end #-------------------------------------------------------------------------- # terminate #-------------------------------------------------------------------------- def terminate super @spriteset.dispose @title_window.dispose if @title_window != nil @command_window.dispose if @command_window != nil @display_window.dispose if @display_window != nil @dummy_window.dispose if @dummy_window != nil end #-------------------------------------------------------------------------- # update #-------------------------------------------------------------------------- def update super @spriteset.update $game_map.update update_input end #-------------------------------------------------------------------------- # update_input #-------------------------------------------------------------------------- def update_input @command_window.update if @last_id != @command_window.index @last_id = @command_window.index refresh_display end if Input.trigger?(Input::B) and @cancel Sound.play_cancel $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 0 $scene = Scene_Map.new elsif Input.trigger?(Input::C) if @data == [] Sound.play_buzzer return end Sound.play_decision $game_temp.common_event_id = @data[@command_window.index] $game_variables[YE::EVENT::CE_MENU_VARIABLE] = 0 $scene = Scene_Map.new end end #-------------------------------------------------------------------------- # refresh_display #-------------------------------------------------------------------------- def refresh_display return if @display_window == nil @display_window.refresh(@data[@command_window.index]) end end # Scene_Common_Event_Menu #=============================================================================== # Window_Event_Display #=============================================================================== class Window_Event_Display < Window_Base #-------------------------------------------------------------------------- # initialize #-------------------------------------------------------------------------- def initialize(x, y, w, h, type = "tall") super(x, y, w, h) @type = type menu_id = $game_variables[YE::EVENT::CE_MENU_VARIABLE] first_item = YE::EVENT::CE_MENU_VARIABLE[menu_id] end #-------------------------------------------------------------------------- # refresh #-------------------------------------------------------------------------- def refresh(id = nil) self.contents.clear return if id == nil return unless YE::EVENT::CE_MENU_ITEMS.include?(id) txsize = YE::EVENT::CE_MENU_ITEMS[id][2] self.contents.font.size = txsize if YE::EVENT::CE_MENU_ITEMS[id][1] != nil # Draw a picture. name = YE::EVENT::CE_MENU_ITEMS[id][1] bitmap = Cache.picture(name) rect = Rect.new(0, 0, bitmap.width, bitmap.height) self.contents.blt(0, 6, bitmap, rect) if @type == "tall" dy = bitmap.height + (txsize / 2) dx = 0 elsif @type == "wide" dx = bitmap.width + (txsize / 2) dy = 0 end bitmap.dispose else dy = 0 dx = 0 end return if @type == "no text" text = YE::EVENT::CE_MENU_ITEMS[id][3] nwidth = Graphics.width buf = text.gsub(/\\N(\[\d+\])/i) { "\\__#{$1}" } lines = buf.split(/(?:[|]|\\n)/i) lines.each_with_index { |l, i| l.gsub!(/\\__(\[\d+\])/i) { "\\N#{$1}" } self.contents.draw_text(dx, i * txsize + dy, nwidth, WLH, l, 0) } end end # Window_Event_Display #=============================================================================== # # END OF FILE # #===============================================================================