#===============================================================================# Sixth's Page Trigger Snippet Demonstration#===============================================================================#===============================================================================# Settings Below!#===============================================================================module YEA::SHOP MAX_PAGE = 3 # Maximum available pages to toggle # If you want only one page toggle button, set one of the triggers to 'nil'. PREV_TRIGGER = :kA # Button for the previous page trigger NEXT_TRIGGER = :kD # Button for the next page trigger # Depending on what do you want to show, and how many pages you have, it might # be helpful for the player to know where he is. # These icons can show, for example, a left arrow on the left side and a right # arrow at the right side. The left icon will get the disabled color if the # player is on the first page, and the right icon will get the disabled color # if the player navigates to the last page. USE_ICONS = true # You can enable/disable the icon display here. PAGE_HELP_ICON = [2824, 2826] # The left number is the left icon's ID. # The right number is the right icon's ID. LEFT_ICON_X = 10 # Every icon is different in size and appearance. RIGHT_ICON_X = 606 # These settings will help you to overcome weird placements. ICON_Y = 10 # Set up the X placements of each icon and the Y position. end#==============================================================================# Settings Ends Here! Ohh, noes!#==============================================================================#==============================================================================# ■ Window_ShopData#==============================================================================class Window_ShopData < Window_Base include YEA::SHOP #-------------------------------------------------------------------------- # new: public instance variables #-------------------------------------------------------------------------- attr_accessor :toggler, :enabler #-------------------------------------------------------------------------- # alias method: initialize #-------------------------------------------------------------------------- # We initialize the new variables for the page toggle effect here # New variables: @toggler - controls the page number # @enabler - enables/disables the page trigger buttons #-------------------------------------------------------------------------- alias sixth_ini121 initialize def initialize(dx, dy, item_window) @toggler = 0 @enabler = false sixth_ini121(dx, dy, item_window) end #-------------------------------------------------------------------------- # alias method: update #-------------------------------------------------------------------------- # Making the new button triggers effective on the shop scene. # See 'refresh_button_input_custom' for more info. #-------------------------------------------------------------------------- alias sixth_upi121 update def update sixth_upi121 refresh_button_input_custom end #-------------------------------------------------------------------------- # overwrite method: refresh #-------------------------------------------------------------------------- # This is where the most important part of our "magic" happens. # See all those 'if/elsif @toggler == X' conditional checks? # That decides what will be displayed in the window. # If the page number (@toggler) is equal to 0, it shows the basic data. # If it is higher, it draws something else. # # For the sake of example, I just added 2 very basic text display for the # other pages, but you can display anything, as long as you can code it. # You can add as many pages as you want with simply adding more 'elsif' # conditions and raising the MAX_PAGE setup above. # # Caution: This is an overwrite method! #-------------------------------------------------------------------------- def refresh contents.clear reset_font_settings return draw_empty if @item.nil? contents.font.size = YEA::SHOP::STATUS_FONT_SIZE if @toggler == 0 draw_item_image draw_item_stats draw_item_effects elsif @toggler == 1 draw_something_else1 elsif @toggler == 2 draw_something_else2 end draw_toggle_icons if YEA::SHOP::USE_ICONS == true end #-------------------------------------------------------------------------- # new method: draw_toggle_icons #-------------------------------------------------------------------------- # This method draws the page icons if they are enabled. #-------------------------------------------------------------------------- def draw_toggle_icons x = YEA::SHOP::LEFT_ICON_X w = YEA::SHOP::RIGHT_ICON_X y = YEA::SHOP::ICON_Y if @toggler == YEA::SHOP::MAX_PAGE - 1 draw_icon(YEA::SHOP:

AGE_HELP_ICON[0],x,y) draw_icon(YEA::SHOP:

AGE_HELP_ICON[1],w-24,y,false) elsif @toggler == 0 draw_icon(YEA::SHOP:

AGE_HELP_ICON[1],w-24,y) draw_icon(YEA::SHOP:

AGE_HELP_ICON[0],x,y,false) else draw_icon(YEA::SHOP:

AGE_HELP_ICON[0],x,y) draw_icon(YEA::SHOP:

AGE_HELP_ICON[1],w-24,y) end end #-------------------------------------------------------------------------- # new method: draw_something_else1 #-------------------------------------------------------------------------- # Just to demonstrate the page changing. # Feel free to delete/change this however you like. #-------------------------------------------------------------------------- def draw_something_else1 draw_text(0,contents.height/2,contents.width-12,line_height,"This is something else version 1!",1) end #-------------------------------------------------------------------------- # new method: draw_something_else2 #-------------------------------------------------------------------------- # Just to demonstrate the page changing. # Feel free to delete/change this however you like. #-------------------------------------------------------------------------- def draw_something_else2 draw_text(0,contents.height/2,contents.width-12,line_height,"This is something else version 2!",1) end #-------------------------------------------------------------------------- # new method: refresh_button_input_custom #-------------------------------------------------------------------------- # This is where we define what happens when the player press the defined # button. # If the page number goes lower than 0, it will be set to the last page. # If the page number is higher than the maximum page setup number, it will # go to the first page. # If it can go to the next/previous page without any of the above conditions # described, it simply switches to the next/previous page. # # The 'print ...' lines are there for debugging only. # Feel free to change/delete them. #-------------------------------------------------------------------------- def refresh_button_input_custom if YEA::SHOP:

REV_TRIGGER != nil && Input.trigger?(YEA::SHOP:

REV_TRIGGER) && @enabler == true if @toggler <= 0 @toggler = YEA::SHOP::MAX_PAGE - 1 else @toggler -= 1 end print "Prev: "; p @toggler Sound.play_ok update_item(@item_window.item) refresh elsif YEA::SHOP::NEXT_TRIGGER != nil && Input.trigger?(YEA::SHOP::NEXT_TRIGGER) && @enabler == true if @toggler < YEA::SHOP::MAX_PAGE - 1 @toggler += 1 else @toggler = 0 end print "Next: "; p @toggler Sound.play_ok update_item(@item_window.item) refresh end endend#==============================================================================# ■ Scene_Shop#==============================================================================class Scene_Shop < Scene_MenuBase #-------------------------------------------------------------------------- # alias method: activate_buy_window #-------------------------------------------------------------------------- # This part is important. We will enable/disable the page toggle effect in # the following aliased methods, as well as set the page number to the first # if the cancel button is being pressed. # # This method happens when the player presses the confirm button on the "Buy" # command. We want to enable the page toggle effect then, so we do just that. #-------------------------------------------------------------------------- alias sixth_enabler121 activate_buy_window def activate_buy_window sixth_enabler121 @data_window.enabler = true end #-------------------------------------------------------------------------- # alias method: activate_sell_window #-------------------------------------------------------------------------- # This method happens when the player presses the confirm button on the # "Item Categories" selection window, which happens after the player presses # the confirm button on the "Sell" command. # We want to enable the page toggle effect then, so we do just that. #-------------------------------------------------------------------------- alias sixth_ac_sell121 activate_sell_window def activate_sell_window sixth_ac_sell121 @data_window.enabler = true end #-------------------------------------------------------------------------- # alias method: on_buy_ok #-------------------------------------------------------------------------- # This method happens when the player presses the confirm button on any # enabled item in the "Buy" window, aka when the number selection comes up. # If you are like me, and want to set the button triggers to "left" and "right", # then having the page toggle effect activated will make some weird effects. # That is why I choose to disable the effect here. # # This part, as well as any of the following methods, will first disable the # page toggle effect, then set the page number to the first page, and after # that, it will refresh the info window to reflect the changes (if any). #-------------------------------------------------------------------------- alias sixth_on_buy121 on_buy_ok def on_buy_ok @data_window.enabler = false @data_window.toggler = 0 @data_window.refresh sixth_on_buy121 end #-------------------------------------------------------------------------- # alias method: on_buy_cancel #-------------------------------------------------------------------------- # Happens when the player cancels the number input window while buying. # Same effect as above. #-------------------------------------------------------------------------- alias sixth_on_buy_c121 on_buy_cancel def on_buy_cancel @data_window.enabler = false @data_window.toggler = 0 @data_window.refresh sixth_on_buy_c121 end #-------------------------------------------------------------------------- # alias method: on_sell_ok #-------------------------------------------------------------------------- # Happens when the player presses the confirm button on any enabled item # while selling stuffsl, aka when the number input window shows up. # Same effect as above. #-------------------------------------------------------------------------- alias sixth_on_sell_o121 on_sell_ok def on_sell_ok @data_window.enabler = false @data_window.toggler = 0 @data_window.refresh sixth_on_sell_o121 end #-------------------------------------------------------------------------- # alias method: on_sell_cancel #-------------------------------------------------------------------------- # Happens when the player cancels the number input window while selling. # Same effect as above. #-------------------------------------------------------------------------- alias sixth_sell_cancel121 on_sell_cancel def on_sell_cancel @data_window.enabler = false @data_window.toggler = 0 @data_window.refresh sixth_sell_cancel121 endend