Advertisement
roninator2

Mr Trivel Crafting Addon - Crafting popup confirm

Nov 3rd, 2020 (edited)
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.24 KB | Source Code | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: Crafting Confirmed Popup     ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║ Mr Trivel Crafting                  ╠════════════════════╣
  7. # ║ Create a popup window for crafting  ║    01 Nov 2020     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Shows a window to show that the item was cratfed         ║
  11. # ║ States the name of the item and what you specify         ║
  12. # ╚══════════════════════════════════════════════════════════╝
  13. # ╔═════════════════════════════════════╗
  14. # ║ Terms of use:                       ║
  15. # ║ Follow the Original Authors terms   ║
  16. # ╚═════════════════════════════════════╝
  17. module R2_Trivel_craft_message
  18.   CONFIRM = " crafted!"
  19. end
  20. class Window_Craft_ConfirmPopup < Window_Selectable
  21.   def initialize
  22.     super(320, 300, window_width, window_height)
  23.     self.openness = 0
  24.   end
  25.   def window_width; 320; end
  26.   def window_height; 48; end
  27.   def refresh; end
  28.   def craft_item(item)
  29.     contents.clear
  30.     text1, text2 = item.name, R2_Trivel_craft_message::CONFIRM
  31.     width = contents.text_size(text1 + text2).width + 30
  32.     create_contents
  33.     draw_text(24,1,contents.width,24,text1)
  34.     change_color(normal_color)
  35.     draw_text(24+contents.text_size(text1).width,1,contents.width,24,text2)
  36.     draw_icon(item.icon_index,0,0)
  37.     open
  38.   end
  39.   def process_ok
  40.     if current_item_enabled?
  41.       Input.update
  42.       deactivate
  43.       call_ok_handler
  44.     end
  45.   end
  46. end
  47.  
  48. class MrTS_Scene_Crafting < Scene_Base
  49.   def create_all_windows
  50.     create_help_window
  51.     create_main_command_window
  52.     create_discipline_info_window
  53.     create_item_list_window
  54.     create_requirements_window
  55.     create_disciplines_command_window
  56.     create_craft_success_window
  57.     @command_window.deactivate
  58.     @discipline_command_window.open
  59.     @discipline_command_window.activate
  60.   end
  61.   def create_craft_success_window
  62.     @craft_success = Window_Craft_ConfirmPopup.new
  63.     @craft_success.set_handler(:ok, method(:craft_ok))
  64.     @craft_success.set_handler(:cancel, method(:craft_ok))
  65.     @craft_success.deactivate
  66.   end
  67.   def craft_ok
  68.     @craft_success.deactivate
  69.     @craft_success.close
  70.     @item_window.activate
  71.   end
  72.   def item_list_ok_on
  73.     check = @requirements_window.check_item
  74.     if !check
  75.       Sound.play_buzzer
  76.       @item_window.activate
  77.     else
  78.       @requirements_window.craft_item
  79.       @requirements_window.refresh
  80.       @discipline_info_window.refresh
  81.       @item_window.refresh
  82.       item = @requirements_window.find_item
  83.       @item_window.deactivate
  84.       @craft_success.craft_item(item)
  85.       @craft_success.activate
  86.       Sound.play_use_item
  87.     end
  88.   end
  89. end
  90.  
  91. class MrTS_Requirements_Window < Window_Base
  92.   def find_item
  93.     geto = get_true_item(MrTS::Crafting::RECIPES[@recipe][:item])
  94.     return geto[0]
  95.   end
  96.   def check_item
  97.     @item_list.each do |il|
  98.       if $game_party.item_number(il[0]) < il[1]
  99.         return false
  100.       end
  101.     end
  102.     return true
  103.   end
  104. end
  105.  
  106. class MrTS_Item_Window < Window_Selectable
  107.   def process_ok
  108.     if current_item_enabled?
  109.       Input.update
  110.       deactivate
  111.       call_ok_handler
  112.     end
  113.   end
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement