adiktuzmiko

Shared Storage Version 2.40

Sep 25th, 2014
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 55.78 KB | None | 0 0
  1. =begin
  2. ======================================================
  3.  
  4.   Shared Storage v2.40
  5.   by Adiktuzmiko                  
  6.  
  7.   Date Created: 09/25/2014
  8.   Date Last Updated: 10/03/2015
  9.   Requires: N/A
  10.   Difficulty: Easy
  11.  
  12. ======================================================
  13.  Overview
  14. ======================================================
  15.  
  16.  This script allows you to have shared storages
  17.  where you can put/take items. The storage is accessible
  18.  to all save files of your game or even another game as
  19.  long as you set them to use the same storage file.
  20.  
  21.  You can modify most of the properties of each window
  22.  involved in the scene, and also where to put the
  23.  storage file.
  24.  
  25.  You could also set a different max item limit for the
  26.  storage than that of the normal limit for the party
  27.  inventory
  28.  
  29.  All window settings and limitations can now be set
  30.  separately for each storage. Any storage opened
  31.  that doesn't have it's own settings will use
  32.  the default.
  33.  
  34.  Allows multiple storages in one file
  35. ======================================================
  36.  Usage
  37. ======================================================
  38.  
  39.  Put this script into your scripts editor and modify
  40.  the settings below
  41.  
  42.  Then to open up the storage window
  43.  
  44.  Script call:
  45.  
  46.  SceneManager.open_shared_storage(number)
  47.  
  48.  Where number is the number of the storage that you will open.
  49.  
  50.  If you want to open multiple storages that can be switched
  51.  right on the scene via button inputs (configurable below)
  52.  
  53.  you can use
  54.  
  55.  SceneManager.open_shared_storage(min,max)
  56.  
  57.  where:
  58.  
  59.  min => storage to open right away, also the minimum that can be switched
  60.  max => the maximum storage number that can be switched into
  61.  
  62.  example: If I want to open storages 3,4,5 and 6
  63.  
  64.  SceneManager.open_shared_storage(3,6)
  65.  
  66.  I don't know the limit of how many storages you can make,
  67.  possibly hundreds or thousands.
  68.  
  69.  If you want to directly modify the contents of a storage
  70.  (like if you want a certain storage to start with an item
  71.  already in it)
  72.  
  73.  you can do this
  74.  
  75.  $shared_storage[[storage_number,item_class,item_id]] = amount
  76.  ADIK::SHARED_STORAGE.save_storage
  77.  
  78.  item_class could be "RPG::Item", "RPG::Weapon", "RPG::Armor"
  79.  
  80.  the "" is important by the way
  81.  
  82.  For gold,
  83.  
  84.  $shared_storage[[:gold,storage_number]] = amount
  85.  ADIK::SHARED_STORAGE.save_storage
  86.  
  87.  Take note that you must do it only ONCE per item that you wanna
  88.  add to the storage.
  89.  
  90.  Better do it during the title screen script,
  91.  test play so that it runs,
  92.  then delete the script lines afterward
  93.  
  94.  I'd also advice only doing it when you're going to ship the
  95.  game already, else you might actually need to redo it before
  96.  shipping out your game.
  97.  
  98.  On configuring multiple storages:
  99.  
  100.  Important: The 0 indexed setting will be the one used by default
  101.  by any storage that you open that doesn't have it's own
  102.  settings defined. So don't remove it.
  103.  
  104.  Copy paste the setting constants and modify the index to the
  105.  storage number that you want, then modify the values
  106.  
  107.  For example:
  108.  
  109.  This would be the settings for the custom window
  110.  of storage number 1
  111.  
  112.  CUSTOM_WINDOW[1] = blahblah
  113.  
  114.  Do that for every setting that you want to change
  115.  for a particular storage
  116.  
  117. ======================================================
  118.  Compatibility
  119. ======================================================
  120.  
  121.  Aliases DataManager's load_game and save_game_without_rescue
  122.  methods, Scene_Title's start method
  123.  
  124.  Inherits Window_Selectable, Window_HorzCommand,
  125.  Window_Base and Scene_Base
  126.  
  127. ======================================================
  128.  Terms and Conditions
  129. ======================================================
  130.  
  131.  View it here: http://lescripts.wordpress.com/terms-and-conditions/
  132.  
  133. ======================================================
  134. =end
  135.  
  136. module ADIK
  137.   module SHARED_STORAGE
  138.    
  139.   # Primary folder where the save data will be placed
  140.   # based on the default paths in your computer
  141.   # set to nil if you don't want to use this
  142.   DATA_PATH = 'CURRENT'
  143.    
  144. #~  Heres a list of parameters you can set the DATA_PATH into
  145. #~  
  146. #~  AppData = Contains the full path to the Application Data directory of the logged-in user
  147. #~  LOCALAPPDATA = This variable is the temporary files of Applications.
  148. #~  CURRENT = Folder where the game is run from
  149.  
  150. #~  !!!The following might require your game to run in admin mode!!!
  151.  
  152. #~  ProgramFiles = This variable points to Program Files directory
  153. #~  CommonProgramFiles = This variable points to Common Files directory
  154.    
  155.     #Enter each subfolder paths after the primary folder here
  156.     #The script automatically creates the folder path specified
  157.    
  158.     #FOLDER = [FOLDER1,FOLDER2,and so on]
  159.     FOLDER = ["Storage"]
  160.    
  161.     #Filename for the storage file
  162.     NAME = "storage.rvdata2"
  163.    
  164.     #Does it autosave when you put items into it?
  165.     #If False, then it only saves the storage once
  166.     #the player saves his game
  167.    
  168.     #You'd pretty much want to set this to false
  169.     #unless you're also autosaving the game
  170.     AUTOSAVE = true
  171.    
  172.     #Tag to make items not placeable in storage
  173.     NON_STORAGE_TAG = /<non_storage>/
  174.    
  175.     #Important:  Do not remove!
  176.     #======================================================
  177.     BACKGROUND = []
  178.     #======================================================
  179.    
  180.     #Background picture for the scene
  181.     #Must be inside your Graphics\System folder
  182.     BACKGROUND[0] = ""
  183.    
  184.     #Important:  Do not remove!
  185.     #======================================================
  186.     SS_CATEGORY_WINDOW = []
  187.     SS_CATEGORY_FONT = []
  188.     #======================================================
  189.    
  190.     #Settings for the Deposit/Withdraw window
  191.     #x,y,width,height,Windowskin,Deposit Text, Withdraw Text
  192.     SS_CATEGORY_WINDOW[0] = [0,0,164,32,"Window.png","Deposit","Withdraw"]
  193.     #Font name, font size, color (based on windowskin)
  194.     SS_CATEGORY_FONT[0] = [Font.default_name,24,0]
  195.    
  196.     #Important:  Do not remove!
  197.     #======================================================
  198.     CATEGORY_WINDOW = []
  199.     CATEGORY_FONT = []
  200.     #======================================================
  201.    
  202.     #Settings for the Item/Weapon/Armor/Key Item window
  203.     #x,y,width,height,Windowskin,Item text, weapon text, armor text, key item text, gold text
  204.     #set text to nil if you don't want it to show
  205.     CATEGORY_WINDOW[0] = [164,0,380,32,"Window.png","Item","Weapon","Armor","Key Item","Gold"]
  206.     #Font name, font size, color (based on windowskin)
  207.     CATEGORY_FONT[0] = [Font.default_name,24,0]
  208.    
  209.     #Important:  Do not remove!
  210.     #======================================================
  211.     PLAYER_WINDOW = []
  212.     PLAYER_FONT = []
  213.     #======================================================
  214.    
  215.     #Settings for the Player Item Header window
  216.     #x,y,width,height,Windowskin, Player inventory text
  217.     PLAYER_WINDOW[0] = [0,48,226,48,"Window.png","Player Inventory"]
  218.     #Font name, font size, color (based on windowskin)
  219.     PLAYER_FONT[0] = [Font.default_name,18,1]
  220.    
  221.     #Important:  Do not remove!
  222.     #======================================================
  223.     STORAGE_WINDOW = []
  224.     STORAGE_FONT = []
  225.     #======================================================
  226.    
  227.     #Settings for the Storage Header window
  228.     #x,y,width,height,Windowskin, Storage text
  229.     STORAGE_WINDOW[0] = [318,48,226,48,"Window.png","Storage"]
  230.     #Font name, font size, color (based on windowskin)
  231.     STORAGE_FONT[0] = [Font.default_name,18,1]
  232.    
  233.     #Important:  Do not remove!
  234.     #======================================================
  235.     ITEM_LIST_PLAYER_WINDOW = []
  236.     ITEM_LIST_PLAYER_FONT = []
  237.     #======================================================
  238.    
  239.     #Settings for the player item window
  240.     #x,y,width,height,Windowskin
  241.     #You could set width and height to 0 to "remove"
  242.     #the window
  243.     ITEM_LIST_PLAYER_WINDOW[0] = [0,208,272,208,"Window.png"]
  244.     #Font name, font size, color (based on windowskin)
  245.     ITEM_LIST_PLAYER_FONT[0] = [Font.default_name,24,0]
  246.    
  247.     #Important:  Do not remove!
  248.     #======================================================
  249.     ITEM_LIST_STORAGE_WINDOW = []
  250.     ITEM_LIST_STORAGE_FONT = []
  251.     #======================================================
  252.    
  253.     #Settings for the storage item window
  254.     #x,y,width,height,Windowskin
  255.     #You could set width and height to 0 to "remove"
  256.     #the window
  257.     ITEM_LIST_STORAGE_WINDOW[0]= [272,208,272,208,"Window.png"]
  258.     #Font name, font size, color (based on windowskin)
  259.     ITEM_LIST_STORAGE_FONT[0] = [Font.default_name,24,0]
  260.    
  261.    
  262.    
  263.     #Important:  Do not remove!
  264.     #======================================================
  265.     NUMBER_MAX = []
  266.     #======================================================
  267.    
  268.     #Maximum digits for item number selection
  269.     NUMBER_MAX[0] = 2
  270.    
  271.    
  272.     #Important:  Do not remove!
  273.     #======================================================
  274.     MAX_ITEM_NUMBER = []
  275.     #======================================================
  276.    
  277.     #Formula for obtaining the maximum number
  278.     #that each item can be placed in the storage
  279.     MAX_ITEM_NUMBER[0] = "$game_party.max_item_number(item)"
  280.     MAX_ITEM_NUMBER[1] = "SceneManager.scene.get_item_limit"
  281.    
  282.     #Important:  Do not remove!
  283.     #======================================================
  284.     ITEM_NUMBER_WINDOW = []
  285.     ITEM_NUMBER_FONT = []
  286.     #======================================================
  287.    
  288.     #Settings for item number window
  289.     #x,y,width,height,Windowskin
  290.     ITEM_NUMBER_WINDOW[0] = [240,156,32,32,"Window.png"]
  291.     #Font name, font size, color (based on windowskin)
  292.     ITEM_NUMBER_FONT[0] = [Font.default_name,18,0]
  293.    
  294.     #Important:  Do not remove!
  295.     #======================================================
  296.     HELP_WINDOW = []
  297.     HELP_FONT = []
  298.     #======================================================
  299.    
  300.     #Settings for help window
  301.     #x,y,width,height,Windowskin
  302.     HELP_WINDOW[0] = [0,96,Graphics.width,64,"Window.png"]
  303.     #Font name, font size, color (based on windowskin)
  304.     HELP_FONT[0] = [Font.default_name,18,0]
  305.    
  306.    
  307.     #Important:  Do not remove!
  308.     #======================================================
  309.     CUSTOM_WINDOW = []
  310.     CUSTOM_FONT = []
  311.     CUSTOM_TEXT = []
  312.     #======================================================
  313.    
  314.     #Settings for Custom Window
  315.     #x,y,width,height,Windowskin
  316.     #You could set width and height to 0 to "remove"
  317.     #the window
  318.     CUSTOM_WINDOW[0] = [226,48,96,48,"Window.png"]
  319.     #Font name, font size, color (based on windowskin)
  320.     CUSTOM_FONT[0] = [Font.default_name,18,0]
  321.     #Formula/Method to determine what is shown on the custom
  322.     #window
  323.     CUSTOM_TEXT[0] = "$game_actors[1].name"
  324.     CUSTOM_TEXT[1] = "SceneManager.scene.get_remaining_slots"
  325.    
  326.     #Important:  Do not remove!
  327.     #======================================================
  328.     GOLD_WINDOW = []
  329.     GOLD_FONT = []
  330.     #======================================================
  331.    
  332.     #Settings for Gold Window of storage
  333.     #x,y,width,height,Windowskin,Text
  334.     #You could set width and height to 0 to "remove"
  335.     #the window
  336.     GOLD_WINDOW[0] = [272,160,272,48,"Window.png","Gold: "]
  337.     #Font name, font size, color (based on windowskin)
  338.     GOLD_FONT[0] = [Font.default_name,18,0]
  339.    
  340.     #Important:  Do not remove!
  341.     #======================================================
  342.     GOLD_P_WINDOW = []
  343.     GOLD_P_FONT = []
  344.     #======================================================
  345.    
  346.     #Settings for Gold Window ofparty
  347.     #x,y,width,height,Windowskin,Text
  348.     #You could set width and height to 0 to "remove"
  349.     #the window
  350.     GOLD_P_WINDOW[0] = [0,160,272,48,"Window.png","Gold: "]
  351.     #Font name, font size, color (based on windowskin)
  352.     GOLD_P_FONT[0] = [Font.default_name,18,0]
  353.    
  354.     #Important:  Do not remove!
  355.     #======================================================
  356.     GOLD_LIMIT = []
  357.     GOLD_P_LIMIT = []
  358.     #======================================================
  359.    
  360.     #Limit for storage gold
  361.     GOLD_LIMIT[0] = "$game_party.max_gold"
  362.     GOLD_P_LIMIT[0] = "$game_party.max_gold"
  363.    
  364.     #Important:  Do not remove!
  365.     #======================================================
  366.     GOLD_NUMBER_WINDOW = []
  367.     GOLD_NUMBER_FONT = []
  368.     #======================================================
  369.    
  370.     #Settings for gold number window
  371.     #x,y,width,height,Windowskin
  372.     GOLD_NUMBER_WINDOW[0] = [240,156,32,32,"Window.png"]
  373.     #Font name, font size, color (based on windowskin)
  374.     GOLD_NUMBER_FONT[0] = [Font.default_name,18,0]
  375.    
  376.     #Key input for next storage
  377.     NEXT_KEY = :c
  378.     #Key input for prev storage
  379.     PREV_KEY = :z
  380.    
  381.     #======================================================
  382.     #  Do not edit below this line
  383.     #======================================================
  384.    
  385.     #======================================================
  386.     #  Do not edit below this line
  387.     #======================================================
  388.    
  389.     #======================================================
  390.     #  Do not edit below this line
  391.     #======================================================
  392.  
  393.    
  394. #========================================================================#    
  395.     def self.check_storage
  396.       @path = ""
  397.       if not DATA_PATH == 'CURRENT'
  398.         @path = ENV[DATA_PATH] + "\\"
  399.       end
  400.       FOLDER.each do |path|
  401.         @path += path + "\\"
  402.         Dir.mkdir(@path) if !FileTest.exist?(@path)
  403.       end
  404.       @path += NAME
  405.       begin
  406.         load_storage
  407.       rescue
  408.         $shared_storage = {}
  409.         save_storage
  410.       end
  411.     end
  412.    
  413.     def self.save_storage
  414.       File.open(@path, "wb") do |file|
  415.         Marshal.dump($shared_storage, file)
  416.       end
  417.     end
  418.    
  419.     def self.load_storage
  420.       File.open(@path, "rb") do |file|
  421.         $shared_storage = Marshal.load(file)
  422.       end
  423.     end
  424.    
  425.   end
  426. end
  427.  
  428. class Scene_Title
  429.   alias shared_storage_start start
  430.   def start
  431.    shared_storage_start
  432.    #loads storage from disk (or create it if it isn't yet)
  433.    #everytime you go to the title screen
  434.    ADIK::SHARED_STORAGE.check_storage
  435.  end
  436. end
  437.  
  438. class Window_SS_Category < Window_HorzCommand
  439.  
  440.   def initialize(x, y)
  441.     super(x,y)
  442.     categ = ADIK::SHARED_STORAGE::SS_CATEGORY_WINDOW[$shared_storage_number]
  443.     categ = ADIK::SHARED_STORAGE::SS_CATEGORY_WINDOW[0] if categ.nil?
  444.     self.windowskin = Cache.system(categ[4])
  445.     categ = ADIK::SHARED_STORAGE::SS_CATEGORY_FONT[$shared_storage_number]
  446.     categ = ADIK::SHARED_STORAGE::SS_CATEGORY_FONT[0] if categ.nil?
  447.     contents.font.name = categ[0]
  448.     contents.font.size = categ[1]
  449.     contents.font.color = text_color(categ[2])
  450.   end
  451.  
  452.   def col_max
  453.     return 2
  454.   end
  455.  
  456.   def window_width
  457.     categ = ADIK::SHARED_STORAGE::SS_CATEGORY_WINDOW[$shared_storage_number]
  458.     categ = ADIK::SHARED_STORAGE::SS_CATEGORY_WINDOW[0] if categ.nil?
  459.     return categ[2]
  460.   end
  461.  
  462.   def window_heigth
  463.     categ = ADIK::SHARED_STORAGE::SS_CATEGORY_WINDOW[$shared_storage_number]
  464.     categ = ADIK::SHARED_STORAGE::SS_CATEGORY_WINDOW[0] if categ.nil?
  465.     return categ[3]
  466.   end
  467.  
  468.   def make_command_list
  469.     categ = ADIK::SHARED_STORAGE::SS_CATEGORY_WINDOW[$shared_storage_number]
  470.     categ = ADIK::SHARED_STORAGE::SS_CATEGORY_WINDOW[0] if categ.nil?
  471.     add_command(categ[5],   :deposit, true)
  472.     add_command(categ[6],   :withdraw, true)
  473.   end
  474.  
  475. end
  476.  
  477. class Window_Category_SS < Window_HorzCommand
  478.  
  479.   def initialize(x, y)
  480.     super(x,y)
  481.     categ = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[$shared_storage_number]
  482.     categ = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[0] if categ.nil?
  483.     self.windowskin = Cache.system(categ[4])
  484.     categ = ADIK::SHARED_STORAGE::CATEGORY_FONT[$shared_storage_number]
  485.     categ = ADIK::SHARED_STORAGE::CATEGORY_FONT[0] if categ.nil?
  486.     contents.font.name = categ[0]
  487.     contents.font.size = categ[1]
  488.     contents.font.color = text_color(categ[2])
  489.   end
  490.  
  491.   def col_max
  492.     count = 0
  493.     categ = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[$shared_storage_number]
  494.     categ = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[0] if categ.nil?
  495.     [5,6,7,8,9].each {|x| count+=1 unless categ[x].nil? }
  496.     return count
  497.   end
  498.  
  499.   def window_width
  500.     categ = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[$shared_storage_number]
  501.     categ = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[0] if categ.nil?
  502.     return categ[2]
  503.   end
  504.  
  505.   def window_heigth
  506.     categ = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[$shared_storage_number]
  507.     categ = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[0] if categ.nil?
  508.     return categ[3]
  509.   end
  510.  
  511.   def make_command_list
  512.     categ = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[$shared_storage_number]
  513.     categ = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[0] if categ.nil?
  514.     add_command(categ[5],   :item, true) unless categ[5].nil?
  515.     add_command(categ[6],   :weapon, true) unless categ[6].nil?
  516.     add_command(categ[7],   :armor, true) unless categ[7].nil?
  517.     add_command(categ[8],   :key_item, true) unless categ[8].nil?
  518.     add_command(categ[9],   :gold, true) unless categ[9].nil?
  519.   end
  520.  
  521.   def process_ok
  522.     if current_item_enabled?
  523.       if current_symbol == :gold
  524.         Input.update
  525.         deactivate
  526.         call_ok_handler
  527.       else
  528.         Sound.play_ok
  529.         Input.update
  530.         deactivate
  531.         call_ok_handler
  532.       end
  533.     else
  534.       Sound.play_buzzer
  535.     end
  536.   end
  537.  
  538. end
  539.  
  540. class Window_ItemList_SS_Player < Window_Selectable
  541.   #--------------------------------------------------------------------------
  542.   # * Object Initialization
  543.   #--------------------------------------------------------------------------
  544.   def initialize(x, y, width, height)
  545.     super
  546.     @category = :none
  547.     @data = []
  548.     categ = ADIK::SHARED_STORAGE::ITEM_LIST_PLAYER_WINDOW[$shared_storage_number]
  549.     categ = ADIK::SHARED_STORAGE::ITEM_LIST_PLAYER_WINDOW[0] if categ.nil?
  550.     self.windowskin = Cache.system(categ[4])
  551.     categ = ADIK::SHARED_STORAGE::ITEM_LIST_PLAYER_FONT[$shared_storage_number]
  552.     categ = ADIK::SHARED_STORAGE::ITEM_LIST_PLAYER_FONT[0] if categ.nil?
  553.     contents.font.name = categ[0]
  554.     contents.font.size = categ[1]
  555.     contents.font.color = text_color(categ[2])
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # * Set Category
  559.   #--------------------------------------------------------------------------
  560.   def category=(category)
  561.     return if @category == category
  562.     @category = category
  563.     refresh
  564.     self.oy = 0
  565.     select_last
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # * Get Digit Count
  569.   #--------------------------------------------------------------------------
  570.   def col_max
  571.     return 1
  572.   end
  573.   #--------------------------------------------------------------------------
  574.   # * Get Number of Items
  575.   #--------------------------------------------------------------------------
  576.   def item_max
  577.     @data ? @data.size : 0
  578.   end
  579.   #--------------------------------------------------------------------------
  580.   # * Get Item
  581.   #--------------------------------------------------------------------------
  582.   def item
  583.     @data && index >= 0 ? @data[index] : nil
  584.   end
  585.   #--------------------------------------------------------------------------
  586.   # * Get Activation State of Selection Item
  587.   #--------------------------------------------------------------------------
  588.   def current_item_enabled?
  589.     enable?(@data[index])
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # * Include in Item List?
  593.   #--------------------------------------------------------------------------
  594.   def include?(item)
  595.     return false if item.nil?
  596.     return false if item.note =~ ADIK::SHARED_STORAGE::NON_STORAGE_TAG
  597.     case @category
  598.     when :item
  599.       item.is_a?(RPG::Item) && !item.key_item?
  600.     when :weapon
  601.       item.is_a?(RPG::Weapon)
  602.     when :armor
  603.       item.is_a?(RPG::Armor)
  604.     when :key_item
  605.       item.is_a?(RPG::Item) && item.key_item?
  606.     else
  607.       false
  608.     end
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # * Display in Enabled State?
  612.   #--------------------------------------------------------------------------
  613.   def enable?(item)
  614.     if SceneManager.scene.ss_category == :withdraw
  615.       false
  616.     else
  617.       SceneManager.scene.can_store(item)
  618.     end
  619.   end
  620.   #--------------------------------------------------------------------------
  621.   # * Create Item List
  622.   #--------------------------------------------------------------------------
  623.   def make_item_list
  624.     @data = $game_party.all_items.select {|item| include?(item) }
  625.     @data.push(nil) if include?(nil)
  626.   end
  627.   #--------------------------------------------------------------------------
  628.   # * Restore Previous Selection Position
  629.   #--------------------------------------------------------------------------
  630.   def select_last
  631.     select(@data.index($game_party.last_item.object) || 0)
  632.   end
  633.   #--------------------------------------------------------------------------
  634.   # * Draw Item
  635.   #--------------------------------------------------------------------------
  636.   def draw_item(index)
  637.     item = @data[index]
  638.     if item
  639.       rect = item_rect(index)
  640.       rect.width -= 4
  641.       draw_item_name(item, rect.x, rect.y, enable?(item))
  642.       draw_item_number(rect, item)
  643.     end
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # * Draw Number of Items
  647.   #--------------------------------------------------------------------------
  648.   def draw_item_number(rect, item)
  649.     draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
  650.   end
  651.   #--------------------------------------------------------------------------
  652.   # * Update Help Text
  653.   #--------------------------------------------------------------------------
  654.   def update_help
  655.     @help_window.set_item(item)
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   # * Refresh
  659.   #--------------------------------------------------------------------------
  660.   def refresh
  661.     make_item_list
  662.     create_contents
  663.     draw_all_items
  664.   end
  665.  
  666.   def process_ok
  667.     if current_item_enabled?
  668.       Input.update
  669.       deactivate
  670.       call_ok_handler
  671.     else
  672.       Sound.play_buzzer
  673.     end
  674.   end
  675.  
  676. end
  677.  
  678. class Window_ItemList_SS_Storage < Window_Selectable
  679.   #--------------------------------------------------------------------------
  680.   # * Object Initialization
  681.   #--------------------------------------------------------------------------
  682.   def initialize(x, y, width, height)
  683.     super
  684.     @category = :none
  685.     @data = []
  686.     categ = ADIK::SHARED_STORAGE::ITEM_LIST_STORAGE_WINDOW[$shared_storage_number]
  687.     categ = ADIK::SHARED_STORAGE::ITEM_LIST_STORAGE_WINDOW[0] if categ.nil?
  688.     self.windowskin = Cache.system(categ[4])
  689.     categ = ADIK::SHARED_STORAGE::ITEM_LIST_STORAGE_FONT[$shared_storage_number]
  690.     categ = ADIK::SHARED_STORAGE::ITEM_LIST_STORAGE_FONT[0] if categ.nil?
  691.     contents.font.name = categ[0]
  692.     contents.font.size = categ[1]
  693.     contents.font.color = text_color(categ[2])
  694.   end
  695.  
  696.   def process_ok
  697.     if current_item_enabled?
  698.       Input.update
  699.       deactivate
  700.       call_ok_handler
  701.     else
  702.       Sound.play_buzzer
  703.     end
  704.   end
  705.  
  706.   #--------------------------------------------------------------------------
  707.   # * Set Category
  708.   #--------------------------------------------------------------------------
  709.   def category=(category)
  710.     return if @category == category
  711.     @category = category
  712.     refresh
  713.     self.oy = 0
  714.     select_last
  715.   end
  716.   #--------------------------------------------------------------------------
  717.   # * Get Digit Count
  718.   #--------------------------------------------------------------------------
  719.   def col_max
  720.     return 1
  721.   end
  722.   #--------------------------------------------------------------------------
  723.   # * Get Number of Items
  724.   #--------------------------------------------------------------------------
  725.   def item_max
  726.     @data ? @data.size : 0
  727.   end
  728.   #--------------------------------------------------------------------------
  729.   # * Get Item
  730.   #--------------------------------------------------------------------------
  731.   def item
  732.     @data && index >= 0 ? @data[index] : nil
  733.   end
  734.   #--------------------------------------------------------------------------
  735.   # * Get Activation State of Selection Item
  736.   #--------------------------------------------------------------------------
  737.   def current_item_enabled?
  738.     enable?(@data[index])
  739.   end
  740.   #--------------------------------------------------------------------------
  741.   # * Include in Item List?
  742.   #--------------------------------------------------------------------------
  743.   def include?(item)
  744.     return false if item.nil?
  745.     case @category
  746.     when :item
  747.       item.is_a?(RPG::Item) && !item.key_item?
  748.     when :weapon
  749.       item.is_a?(RPG::Weapon)
  750.     when :armor
  751.       item.is_a?(RPG::Armor)
  752.     when :key_item
  753.       item.is_a?(RPG::Item) && item.key_item?
  754.     else
  755.       false
  756.     end
  757.   end
  758.   #--------------------------------------------------------------------------
  759.   # * Display in Enabled State?
  760.   #--------------------------------------------------------------------------
  761.   def enable?(item)
  762.     if SceneManager.scene.ss_category == :deposit
  763.       false
  764.     else
  765.       SceneManager.scene.can_store(item)
  766.     end
  767.   end
  768.   #--------------------------------------------------------------------------
  769.   # * Create Item List
  770.   #--------------------------------------------------------------------------
  771.   def make_item_list
  772.     @data = []
  773.     $shared_storage.each_key do |key|
  774.       next if key[0] != @storage_number
  775.       case key[1]
  776.       when "RPG::Item"
  777.         item = $data_items[key[2]]
  778.         @data.push(item) if include?(item)
  779.       when "RPG::Weapon"
  780.         item = $data_weapons[key[2]]
  781.         @data.push(item) if include?(item)
  782.       when "RPG::Armor"
  783.         item = $data_armors[key[2]]
  784.         @data.push(item) if include?(item)
  785.       end
  786.     end
  787.   end
  788.  
  789.   def set_number(sn)
  790.     @storage_number = sn
  791.   end
  792.  
  793.   #--------------------------------------------------------------------------
  794.   # * Restore Previous Selection Position
  795.   #--------------------------------------------------------------------------
  796.   def select_last
  797.     select(@data.index($game_party.last_item.object) || 0)
  798.   end
  799.   #--------------------------------------------------------------------------
  800.   # * Draw Item
  801.   #--------------------------------------------------------------------------
  802.   def draw_item(index)
  803.     item = @data[index]
  804.     if item
  805.       rect = item_rect(index)
  806.       rect.width -= 4
  807.       draw_item_name(item, rect.x, rect.y, enable?(item))
  808.       draw_item_number(rect, item)
  809.     end
  810.   end
  811.   #--------------------------------------------------------------------------
  812.   # * Draw Number of Items
  813.   #--------------------------------------------------------------------------
  814.   def draw_item_number(rect, item)
  815.     draw_text(rect, sprintf(":%2d", $shared_storage[[@storage_number,item.class.to_s,item.id]]), 2)
  816.   end
  817.   #--------------------------------------------------------------------------
  818.   # * Update Help Text
  819.   #--------------------------------------------------------------------------
  820.   def update_help
  821.     @help_window.set_item(item)
  822.   end
  823.   #--------------------------------------------------------------------------
  824.   # * Refresh
  825.   #--------------------------------------------------------------------------
  826.   def refresh
  827.     make_item_list
  828.     create_contents
  829.     draw_all_items
  830.   end
  831. end
  832.  
  833.  
  834. class Window_Player_Header < Window_Base
  835.  
  836.   def initialize(x, y, width, height)
  837.     super
  838.     categ = ADIK::SHARED_STORAGE::PLAYER_WINDOW[$shared_storage_number]
  839.     categ = ADIK::SHARED_STORAGE::PLAYER_WINDOW[0] if categ.nil?
  840.     self.windowskin = Cache.system(categ[4])
  841.     categ1 = ADIK::SHARED_STORAGE::PLAYER_FONT[$shared_storage_number]
  842.     categ1 = ADIK::SHARED_STORAGE::PLAYER_FONT[0] if categ1.nil?
  843.     contents.font.name = categ1[0]
  844.     contents.font.size = categ1[1]
  845.     contents.font.color = text_color(categ1[2])
  846.     contents.draw_text(0,0,categ[2],categ1[1],categ[5],1)
  847.   end
  848.  
  849. end
  850.  
  851. class Window_Storage_Header < Window_Base
  852.  
  853.   def initialize(x, y, width, height)
  854.     super
  855.     categ = ADIK::SHARED_STORAGE::STORAGE_WINDOW[$shared_storage_number]
  856.     categ = ADIK::SHARED_STORAGE::STORAGE_WINDOW[0] if categ.nil?
  857.     self.windowskin = Cache.system(categ[4])
  858.     categ1 = ADIK::SHARED_STORAGE::STORAGE_FONT[$shared_storage_number]
  859.     categ1 = ADIK::SHARED_STORAGE::STORAGE_FONT[0] if categ1.nil?
  860.     contents.font.name = categ1[0]
  861.     contents.font.size = categ1[1]
  862.     contents.font.color = text_color(categ1[2])
  863.     contents.draw_text(0,0,categ[2],categ1[1],categ[5],1)
  864.   end
  865.  
  866. end
  867.  
  868. class Window_NumberInput_SS < Window_Base
  869.   #--------------------------------------------------------------------------
  870.   # * Object Initialization
  871.   #--------------------------------------------------------------------------
  872.   def initialize
  873.     categ = ADIK::SHARED_STORAGE::ITEM_NUMBER_WINDOW[$shared_storage_number]
  874.     categ = ADIK::SHARED_STORAGE::ITEM_NUMBER_WINDOW[0] if categ.nil?
  875.     super(categ[0],categ[1],categ[2],categ[3])
  876.     @number = 0
  877.     @digits_max = 1
  878.     @index = 0
  879.     @item = nil
  880.     self.windowskin = Cache.system(categ[4])
  881.     categ = ADIK::SHARED_STORAGE::ITEM_NUMBER_FONT[$shared_storage_number]
  882.     categ = ADIK::SHARED_STORAGE::ITEM_NUMBER_FONT[0] if categ.nil?
  883.     contents.font.name = categ[0]
  884.     contents.font.size = categ[1]
  885.     contents.font.color = text_color(categ[2])
  886.     self.openness = 0
  887.     deactivate
  888.   end
  889.   #--------------------------------------------------------------------------
  890.   # * Start Input Processing
  891.   #--------------------------------------------------------------------------
  892.   def start(item,category)
  893.     @digits_max = ADIK::SHARED_STORAGE::NUMBER_MAX[$shared_storage_number]
  894.     @digits_max = ADIK::SHARED_STORAGE::NUMBER_MAX[0] if @digits_max.nil?
  895.     @index = @digits_max - 1
  896.     @item = item
  897.     @category = category
  898.     update_placement
  899.     create_contents
  900.     refresh
  901.     open
  902.     activate
  903.   end
  904.   #--------------------------------------------------------------------------
  905.   # * Update Window Position
  906.   #--------------------------------------------------------------------------
  907.   def update_placement
  908.     self.width = @digits_max * 20 + padding * 2
  909.     self.height = fitting_height(1)
  910.   end
  911.   #--------------------------------------------------------------------------
  912.   # * Move Cursor Right
  913.   #     wrap : Wraparound allowed
  914.   #--------------------------------------------------------------------------
  915.   def cursor_right(wrap)
  916.     if @index < @digits_max - 1 || wrap
  917.       @index = (@index + 1) % @digits_max
  918.     end
  919.   end
  920.   #--------------------------------------------------------------------------
  921.   # * Move Cursor Left
  922.   #     wrap : Wraparound allowed
  923.   #--------------------------------------------------------------------------
  924.   def cursor_left(wrap)
  925.     if @index > 0 || wrap
  926.       @index = (@index + @digits_max - 1) % @digits_max
  927.     end
  928.   end
  929.   #--------------------------------------------------------------------------
  930.   # * Frame Update
  931.   #--------------------------------------------------------------------------
  932.   def update
  933.     super
  934.     process_cursor_move
  935.     process_digit_change
  936.     process_handling
  937.     update_cursor
  938.   end
  939.   #--------------------------------------------------------------------------
  940.   # * Cursor Movement Processing
  941.   #--------------------------------------------------------------------------
  942.   def process_cursor_move
  943.     return unless active
  944.     last_index = @index
  945.     cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
  946.     cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
  947.     Sound.play_cursor if @index != last_index
  948.   end
  949.   #--------------------------------------------------------------------------
  950.   # * Change Processing for Digits
  951.   #--------------------------------------------------------------------------
  952.   def process_digit_change
  953.     return unless active
  954.     if Input.repeat?(:UP) || Input.repeat?(:DOWN)
  955.       Sound.play_cursor
  956.       place = 10 ** (@digits_max - 1 - @index)
  957.       n = @number / place % 10
  958.       @number -= n * place
  959.       n = (n + 1) % 10 if Input.repeat?(:UP)
  960.       n = (n + 9) % 10 if Input.repeat?(:DOWN)
  961.       @number += n * place
  962.       if @category == :deposit
  963.         item = @item
  964.         numb = ADIK::SHARED_STORAGE::MAX_ITEM_NUMBER[$shared_storage_number]
  965.         numb = ADIK::SHARED_STORAGE::MAX_ITEM_NUMBER[0] if numb.nil?
  966.         numb = eval(numb)
  967.         begin
  968.           numb -= $shared_storage[[$shared_storage_number,@item.class.to_s,@item.id]]
  969.         rescue
  970.         end
  971.         @number = [@number,$game_party.item_number(@item),numb].min
  972.       else
  973.         amount = $shared_storage[[$shared_storage_number,@item.class.to_s,@item.id]]
  974.         limit = $game_party.max_item_number(@item)- $game_party.item_number(@item)
  975.         @number = [@number,amount,limit].min
  976.       end
  977.       refresh
  978.     end
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # * Handling Processing for OK and Cancel
  982.   #--------------------------------------------------------------------------
  983.   def process_handling
  984.     return unless active
  985.     return process_ok     if Input.trigger?(:C)
  986.     return process_cancel if Input.trigger?(:B)
  987.   end
  988.   #--------------------------------------------------------------------------
  989.   # * Processing When OK Button Is Pressed
  990.   #--------------------------------------------------------------------------
  991.   def process_ok
  992.     Sound.play_ok
  993.     SceneManager.scene.set_number(@number)
  994.     deactivate
  995.     close
  996.   end
  997.   #--------------------------------------------------------------------------
  998.   # * Processing When Cancel Button Is Pressed
  999.   #--------------------------------------------------------------------------
  1000.   def process_cancel
  1001.     SceneManager.scene.set_number(0)
  1002.     deactivate
  1003.     close
  1004.   end
  1005.   #--------------------------------------------------------------------------
  1006.   # * Get Rectangle for Displaying Item
  1007.   #--------------------------------------------------------------------------
  1008.   def item_rect(index)
  1009.     Rect.new(index * 20, 0, 20, line_height)
  1010.   end
  1011.   #--------------------------------------------------------------------------
  1012.   # * Refresh
  1013.   #--------------------------------------------------------------------------
  1014.   def refresh
  1015.     contents.clear
  1016.     change_color(normal_color)
  1017.     s = sprintf("%0*d", @digits_max, @number)
  1018.     @digits_max.times do |i|
  1019.       rect = item_rect(i)
  1020.       rect.x += 1
  1021.       draw_text(rect, s[i,1], 1)
  1022.     end
  1023.   end
  1024.   #--------------------------------------------------------------------------
  1025.   # * Update Cursor
  1026.   #--------------------------------------------------------------------------
  1027.   def update_cursor
  1028.     cursor_rect.set(item_rect(@index))
  1029.   end
  1030. end
  1031.  
  1032. class Window_NumberInput_Gold < Window_Base
  1033.   #--------------------------------------------------------------------------
  1034.   # * Object Initialization
  1035.   #--------------------------------------------------------------------------
  1036.   def initialize
  1037.     categ = ADIK::SHARED_STORAGE::GOLD_NUMBER_WINDOW[$shared_storage_number]
  1038.     categ = ADIK::SHARED_STORAGE::GOLD_NUMBER_WINDOW[0] if categ.nil?
  1039.     super(categ[0],categ[1],categ[2],categ[3])
  1040.     @number = 0
  1041.     @digits_max = 1
  1042.     @index = 0
  1043.     @item = nil
  1044.     self.windowskin = Cache.system(categ[4])
  1045.     categ = ADIK::SHARED_STORAGE::GOLD_NUMBER_FONT[$shared_storage_number]
  1046.     categ = ADIK::SHARED_STORAGE::GOLD_NUMBER_FONT[0] if categ.nil?
  1047.     contents.font.name = categ[0]
  1048.     contents.font.size = categ[1]
  1049.     contents.font.color = text_color(categ[2])
  1050.     self.openness = 0
  1051.     deactivate
  1052.   end
  1053.   #--------------------------------------------------------------------------
  1054.   # * Start Input Processing
  1055.   #--------------------------------------------------------------------------
  1056.   def start(category)
  1057.     if category == :deposit
  1058.       if ADIK::SHARED_STORAGE::GOLD_LIMIT[$shared_storage_number].nil?
  1059.         @digits_max = eval(ADIK::SHARED_STORAGE::GOLD_LIMIT[0]).to_s.length
  1060.       else
  1061.         @digits_max = eval(ADIK::SHARED_STORAGE::GOLD_LIMIT[$shared_storage_number]).to_s.length
  1062.       end
  1063.     else
  1064.       if ADIK::SHARED_STORAGE::GOLD_P_LIMIT[$shared_storage_number].nil?
  1065.         @digits_max = eval(ADIK::SHARED_STORAGE::GOLD_P_LIMIT[0]).to_s.length
  1066.       else
  1067.         @digits_max = eval(ADIK::SHARED_STORAGE::GOLD_P_LIMIT[$shared_storage_number]).to_s.length
  1068.       end
  1069.     end
  1070.     @index = @digits_max - 1
  1071.     @category = category
  1072.     update_placement
  1073.     create_contents
  1074.     refresh
  1075.     open
  1076.     activate
  1077.   end
  1078.   #--------------------------------------------------------------------------
  1079.   # * Update Window Position
  1080.   #--------------------------------------------------------------------------
  1081.   def update_placement
  1082.     self.width = @digits_max * 20 + padding * 2
  1083.     self.height = fitting_height(1)
  1084.   end
  1085.   #--------------------------------------------------------------------------
  1086.   # * Move Cursor Right
  1087.   #     wrap : Wraparound allowed
  1088.   #--------------------------------------------------------------------------
  1089.   def cursor_right(wrap)
  1090.     if @index < @digits_max - 1 || wrap
  1091.       @index = (@index + 1) % @digits_max
  1092.     end
  1093.   end
  1094.   #--------------------------------------------------------------------------
  1095.   # * Move Cursor Left
  1096.   #     wrap : Wraparound allowed
  1097.   #--------------------------------------------------------------------------
  1098.   def cursor_left(wrap)
  1099.     if @index > 0 || wrap
  1100.       @index = (@index + @digits_max - 1) % @digits_max
  1101.     end
  1102.   end
  1103.   #--------------------------------------------------------------------------
  1104.   # * Frame Update
  1105.   #--------------------------------------------------------------------------
  1106.   def update
  1107.     super
  1108.     process_cursor_move
  1109.     process_digit_change
  1110.     process_handling
  1111.     update_cursor
  1112.   end
  1113.   #--------------------------------------------------------------------------
  1114.   # * Cursor Movement Processing
  1115.   #--------------------------------------------------------------------------
  1116.   def process_cursor_move
  1117.     return unless active
  1118.     last_index = @index
  1119.     cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
  1120.     cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
  1121.     Sound.play_cursor if @index != last_index
  1122.   end
  1123.   #--------------------------------------------------------------------------
  1124.   # * Change Processing for Digits
  1125.   #--------------------------------------------------------------------------
  1126.   def process_digit_change
  1127.     return unless active
  1128.     if Input.repeat?(:UP) || Input.repeat?(:DOWN)
  1129.       Sound.play_cursor
  1130.       place = 10 ** (@digits_max - 1 - @index)
  1131.       n = @number / place % 10
  1132.       @number -= n * place
  1133.       n = (n + 1) % 10 if Input.repeat?(:UP)
  1134.       n = (n + 9) % 10 if Input.repeat?(:DOWN)
  1135.       @number += n * place
  1136.       if @category == :deposit
  1137.         numb = ADIK::SHARED_STORAGE::GOLD_LIMIT[$shared_storage_number]
  1138.         numb = ADIK::SHARED_STORAGE::GOLD_LIMIT[0] if numb.nil?
  1139.         numb = eval(numb)
  1140.         begin
  1141.           numb -= $shared_storage[[:gold,$shared_storage_number]]
  1142.         end
  1143.         @number = [@number,$game_party.gold,numb].min
  1144.       else
  1145.         numb = ADIK::SHARED_STORAGE::GOLD_P_LIMIT[$shared_storage_number]
  1146.         numb = ADIK::SHARED_STORAGE::GOLD_P_LIMIT[0] if numb.nil?
  1147.         numb = eval(numb)
  1148.         begin
  1149.           numb -= $game_party.gold
  1150.         end
  1151.         @number = [@number,$shared_storage[[:gold,$shared_storage_number]],numb].min
  1152.       end
  1153.       refresh
  1154.     end
  1155.   end
  1156.   #--------------------------------------------------------------------------
  1157.   # * Handling Processing for OK and Cancel
  1158.   #--------------------------------------------------------------------------
  1159.   def process_handling
  1160.     return unless active
  1161.     return process_ok     if Input.trigger?(:C)
  1162.     return process_cancel if Input.trigger?(:B)
  1163.   end
  1164.   #--------------------------------------------------------------------------
  1165.   # * Processing When OK Button Is Pressed
  1166.   #--------------------------------------------------------------------------
  1167.   def process_ok
  1168.     Sound.play_ok
  1169.     SceneManager.scene.adjust_gold(@number)
  1170.     deactivate
  1171.     close
  1172.   end
  1173.   #--------------------------------------------------------------------------
  1174.   # * Processing When Cancel Button Is Pressed
  1175.   #--------------------------------------------------------------------------
  1176.   def process_cancel
  1177.     SceneManager.scene.set_number(0)
  1178.     deactivate
  1179.     close
  1180.   end
  1181.   #--------------------------------------------------------------------------
  1182.   # * Get Rectangle for Displaying Item
  1183.   #--------------------------------------------------------------------------
  1184.   def item_rect(index)
  1185.     Rect.new(index * 20, 0, 20, line_height)
  1186.   end
  1187.   #--------------------------------------------------------------------------
  1188.   # * Refresh
  1189.   #--------------------------------------------------------------------------
  1190.   def refresh
  1191.     contents.clear
  1192.     change_color(normal_color)
  1193.     s = sprintf("%0*d", @digits_max, @number)
  1194.     @digits_max.times do |i|
  1195.       rect = item_rect(i)
  1196.       rect.x += 1
  1197.       draw_text(rect, s[i,1], 1)
  1198.     end
  1199.   end
  1200.   #--------------------------------------------------------------------------
  1201.   # * Update Cursor
  1202.   #--------------------------------------------------------------------------
  1203.   def update_cursor
  1204.     cursor_rect.set(item_rect(@index))
  1205.   end
  1206. end
  1207.  
  1208. class Custom_Text_SS < Window_Base
  1209.  
  1210.   def update_text
  1211.     category = ADIK::SHARED_STORAGE::CUSTOM_WINDOW[SceneManager.scene.storage_number]
  1212.     category = ADIK::SHARED_STORAGE::CUSTOM_WINDOW[0] if category.nil?
  1213.     return if category[2] == 0 or category[3] == 0
  1214.     contents.clear
  1215.     category = ADIK::SHARED_STORAGE::CUSTOM_TEXT[SceneManager.scene.storage_number]
  1216.     category = ADIK::SHARED_STORAGE::CUSTOM_TEXT[0] if category.nil?
  1217.     contents.draw_text(0,0,contents.width,contents.font.size,eval(category).to_s,1)
  1218.   end
  1219.  
  1220. end
  1221.  
  1222. class Gold_Window_SS < Window_Base
  1223.  
  1224.   def update_text
  1225.     category = ADIK::SHARED_STORAGE::GOLD_WINDOW[SceneManager.scene.storage_number]
  1226.     category = ADIK::SHARED_STORAGE::GOLD_WINDOW[0] if category.nil?
  1227.     return if category[2] == 0 or category[3] == 0
  1228.     contents.clear
  1229.     $shared_storage[[:gold,SceneManager.scene.storage_number]] = 0 if $shared_storage[[:gold,SceneManager.scene.storage_number]].nil?
  1230.     text = category[5].to_s + $shared_storage[[:gold,SceneManager.scene.storage_number]].to_s
  1231.     contents.draw_text(0,0,contents.width,contents.font.size,text,0)
  1232.   end
  1233.  
  1234. end
  1235.  
  1236. class Gold_Window_P < Window_Base
  1237.  
  1238.   def update_text
  1239.     category = ADIK::SHARED_STORAGE::GOLD_P_WINDOW[SceneManager.scene.storage_number]
  1240.     category = ADIK::SHARED_STORAGE::GOLD_P_WINDOW[0] if category.nil?
  1241.     return if category[2] == 0 or category[3] == 0
  1242.     contents.clear
  1243.     text = category[5].to_s + $game_party.gold.to_s
  1244.     contents.draw_text(0,0,contents.width,contents.font.size,text,0)
  1245.   end
  1246.  
  1247. end
  1248.  
  1249. class Scene_SharedStorage < Scene_Base
  1250.  
  1251.   attr_accessor :ss_category
  1252.   attr_accessor :category
  1253.   attr_accessor :storage_number
  1254.   attr_accessor :storage_number_max
  1255.   attr_accessor :storage_number_min
  1256.  
  1257.   def start
  1258.     super
  1259.     @storage_number = $shared_storage_number
  1260.     @background_sprite = Sprite.new
  1261.     begin
  1262.       @background_sprite.bitmap = Cache.system(ADIK::SHARED_STORAGE::BACKGROUND[@storage_number])
  1263.     rescue
  1264.       @background_sprite.bitmap = Cache.system(ADIK::SHARED_STORAGE::BACKGROUND[0])
  1265.     end
  1266.     create_ss_category_window
  1267.     create_category_window
  1268.     create_header_windows
  1269.     create_window_item_list_ss_player
  1270.     create_window_item_list_ss_storage
  1271.     create_help_window
  1272.     create_custom_text_window
  1273.     create_gold_window
  1274.     @ss_category_window.activate
  1275.   end
  1276.  
  1277.   def terminate
  1278.     @background_sprite.dispose
  1279.     super
  1280.   end
  1281.  
  1282.   def create_custom_text_window
  1283.     category = ADIK::SHARED_STORAGE::CUSTOM_WINDOW[@storage_number]
  1284.     category = ADIK::SHARED_STORAGE::CUSTOM_WINDOW[0] if category.nil?
  1285.     @custom_text_window = Custom_Text_SS.new(category[0],category[1],category[2],category[3])
  1286.     @custom_text_window.x = category[0]
  1287.     @custom_text_window.y = category[1]
  1288.     @custom_text_window.width = category[2]
  1289.     @custom_text_window.height = category[3]
  1290.     @custom_text_window.windowskin = Cache.system(category[4])
  1291.     category = ADIK::SHARED_STORAGE::CUSTOM_FONT[@storage_number]
  1292.     category = ADIK::SHARED_STORAGE::CUSTOM_FONT[0] if category.nil?
  1293.     @custom_text_window.contents.font.name = category[0]
  1294.     @custom_text_window.contents.font.size = category[1]
  1295.     @custom_text_window.contents.font.color = @help_window.text_color(category[2])
  1296.     @custom_text_window.update_text
  1297.   end
  1298.  
  1299.   def create_gold_window
  1300.     category = ADIK::SHARED_STORAGE::GOLD_WINDOW[@storage_number]
  1301.     category = ADIK::SHARED_STORAGE::GOLD_WINDOW[0] if category.nil?
  1302.     @gold_window_ss = Gold_Window_SS.new(category[0],category[1],category[2],category[3])
  1303.     @gold_window_ss.x = category[0]
  1304.     @gold_window_ss.y = category[1]
  1305.     @gold_window_ss.width = category[2]
  1306.     @gold_window_ss.height = category[3]
  1307.     @gold_window_ss.windowskin = Cache.system(category[4])
  1308.     category = ADIK::SHARED_STORAGE::GOLD_FONT[@storage_number]
  1309.     category = ADIK::SHARED_STORAGE::GOLD_FONT[0] if category.nil?
  1310.     @gold_window_ss.contents.font.name = category[0]
  1311.     @gold_window_ss.contents.font.size = category[1]
  1312.     @gold_window_ss.contents.font.color = @help_window.text_color(category[2])
  1313.     @gold_window_ss.update_text
  1314.     category = ADIK::SHARED_STORAGE::GOLD_P_WINDOW[@storage_number]
  1315.     category = ADIK::SHARED_STORAGE::GOLD_P_WINDOW[0] if category.nil?
  1316.     @gold_window_p = Gold_Window_P.new(category[0],category[1],category[2],category[3])
  1317.     @gold_window_p.x = category[0]
  1318.     @gold_window_p.y = category[1]
  1319.     @gold_window_p.width = category[2]
  1320.     @gold_window_p.height = category[3]
  1321.     @gold_window_p.windowskin = Cache.system(category[4])
  1322.     category = ADIK::SHARED_STORAGE::GOLD_P_FONT[@storage_number]
  1323.     category = ADIK::SHARED_STORAGE::GOLD_P_FONT[0] if category.nil?
  1324.     @gold_window_p.contents.font.name = category[0]
  1325.     @gold_window_p.contents.font.size = category[1]
  1326.     @gold_window_p.contents.font.color = @help_window.text_color(category[2])
  1327.     @gold_window_p.update_text
  1328.   end
  1329.  
  1330.   def create_help_window
  1331.     @help_window = Window_Help.new
  1332.     category = ADIK::SHARED_STORAGE::HELP_WINDOW[@storage_number]
  1333.     category = ADIK::SHARED_STORAGE::HELP_WINDOW[0] if category.nil?
  1334.     @help_window.x = category[0]
  1335.     @help_window.y = category[1]
  1336.     @help_window.width = category[2]
  1337.     @help_window.height = category[3]
  1338.     @help_window.windowskin = Cache.system(category[4])
  1339.     category = ADIK::SHARED_STORAGE::HELP_FONT[@storage_number]
  1340.     category = ADIK::SHARED_STORAGE::HELP_FONT[0] if category.nil?
  1341.     @help_window.contents.font.name = category[0]
  1342.     @help_window.contents.font.size = category[1]
  1343.     @help_window.contents.font.color = @help_window.text_color(category[2])
  1344.     @list_storage_window.help_window = @help_window
  1345.     @list_player_window.help_window = @help_window
  1346.   end
  1347.  
  1348.   def create_header_windows
  1349.     category = ADIK::SHARED_STORAGE::PLAYER_WINDOW[@storage_number]
  1350.     category = ADIK::SHARED_STORAGE::PLAYER_WINDOW[0] if category.nil?
  1351.     @player_header = Window_Player_Header.new(category[0],category[1],category[2],category[3])
  1352.     category = ADIK::SHARED_STORAGE::STORAGE_WINDOW[@storage_number]
  1353.     category = ADIK::SHARED_STORAGE::STORAGE_WINDOW[0] if category.nil?
  1354.     @storage_header = Window_Storage_Header.new(category[0],category[1],category[2],category[3])
  1355.   end
  1356.  
  1357.   def create_ss_category_window
  1358.     category = ADIK::SHARED_STORAGE::SS_CATEGORY_WINDOW[@storage_number]
  1359.     category = ADIK::SHARED_STORAGE::SS_CATEGORY_WINDOW[0] if category.nil?
  1360.     @ss_category_window = Window_SS_Category.new(category[0],category[1])
  1361.     @ss_category_window.set_handler(:cancel, method(:return_scene))
  1362.     @ss_category_window.set_handler(:deposit, method(:on_deposit))
  1363.     @ss_category_window.set_handler(:withdraw, method(:on_withdraw))
  1364.   end
  1365.  
  1366.   def create_category_window
  1367.     category = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[@storage_number]
  1368.     category = ADIK::SHARED_STORAGE::CATEGORY_WINDOW[0] if category.nil?
  1369.     @category_window = Window_Category_SS.new(category[0],category[1])
  1370.     @category_window.set_handler(:cancel, method(:return_ss_category))
  1371.     @category_window.set_handler(:item, method(:on_item))
  1372.     @category_window.set_handler(:weapon, method(:on_weapon))
  1373.     @category_window.set_handler(:armor, method(:on_armor))
  1374.     @category_window.set_handler(:key_item, method(:on_key_item))
  1375.     @category_window.set_handler(:gold, method(:on_gold))
  1376.     @category_window.deactivate
  1377.   end
  1378.  
  1379.   def create_window_item_list_ss_player
  1380.     category = ADIK::SHARED_STORAGE::ITEM_LIST_PLAYER_WINDOW[@storage_number]
  1381.     category = ADIK::SHARED_STORAGE::ITEM_LIST_PLAYER_WINDOW[0] if category.nil?
  1382.     @list_player_window = Window_ItemList_SS_Player.new(category[0],category[1],category[2],category[3])
  1383.     @list_player_window.set_handler(:cancel, method(:return_list))
  1384.     @list_player_window.set_handler(:ok, method(:on_player_ok))
  1385.     @list_player_window.deactivate
  1386.   end
  1387.  
  1388.   def create_window_item_list_ss_storage
  1389.     category = ADIK::SHARED_STORAGE::ITEM_LIST_STORAGE_WINDOW[@storage_number]
  1390.     category = ADIK::SHARED_STORAGE::ITEM_LIST_STORAGE_WINDOW[0] if category.nil?
  1391.     @list_storage_window = Window_ItemList_SS_Storage.new(category[0],category[1],category[2],category[3])
  1392.     @list_storage_window.set_handler(:cancel, method(:return_list))
  1393.     @list_storage_window.set_handler(:ok, method(:on_player_ok))
  1394.     @list_storage_window.set_number(@storage_number)
  1395.     @list_storage_window.deactivate
  1396.   end
  1397.  
  1398.   def on_deposit
  1399.     @ss_category = :deposit
  1400.     @category_window.activate
  1401.   end
  1402.  
  1403.   def on_withdraw
  1404.     @ss_category = :withdraw
  1405.     @category_window.activate
  1406.   end
  1407.  
  1408.   def return_ss_category
  1409.     @ss_category_window.activate
  1410.   end
  1411.  
  1412.   def return_list
  1413.     @category_window.activate
  1414.   end
  1415.  
  1416.   def select_window
  1417.     @list_player_window.category = @category
  1418.     @list_storage_window.category = @category
  1419.     if @ss_category == :deposit
  1420.       @list_player_window.refresh
  1421.       @list_storage_window.refresh
  1422.       @list_player_window.activate
  1423.     else
  1424.       @list_player_window.refresh
  1425.       @list_storage_window.refresh
  1426.       @list_storage_window.activate
  1427.     end
  1428.   end
  1429.  
  1430.   def on_item
  1431.     @category = :item
  1432.     select_window
  1433.   end
  1434.  
  1435.   def on_weapon
  1436.     @category = :weapon
  1437.     select_window
  1438.   end
  1439.  
  1440.   def on_armor
  1441.     @category = :armor
  1442.     select_window
  1443.   end
  1444.  
  1445.   def on_key_item
  1446.     @category = :key_item
  1447.     select_window
  1448.   end
  1449.  
  1450.   def on_gold
  1451.     @category = :gold
  1452.     if @ss_category == :deposit
  1453.       if $game_party.gold < 1
  1454.         Sound.play_buzzer
  1455.         @category_window.activate
  1456.         return
  1457.       end
  1458.     else
  1459.       $shared_storage[[:gold,SceneManager.scene.storage_number]] = 0 if $shared_storage[[:gold,SceneManager.scene.storage_number]].nil?
  1460.       if $shared_storage[[:gold,SceneManager.scene.storage_number]] == 0
  1461.         Sound.play_buzzer
  1462.         @category_window.activate
  1463.         return
  1464.       end
  1465.     end
  1466.     Sound.play_ok
  1467.     @number_g_window = Window_NumberInput_Gold.new
  1468.     @number_g_window.start(@ss_category)
  1469.   end
  1470.  
  1471.   def adjust_gold(amount)
  1472.     if @ss_category == :deposit
  1473.       $shared_storage[[:gold,SceneManager.scene.storage_number]] += amount
  1474.       $game_party.gain_gold(-amount)
  1475.     else
  1476.       $game_party.gain_gold(amount)
  1477.       $shared_storage[[:gold,SceneManager.scene.storage_number]] -= amount
  1478.     end
  1479.     @gold_window_ss.update_text
  1480.     @gold_window_p.update_text
  1481.     ADIK::SHARED_STORAGE.save_storage if ADIK::SHARED_STORAGE::AUTOSAVE
  1482.     @category_window.activate
  1483.   end
  1484.  
  1485.   def on_player_ok
  1486.     if has_item_to_pick
  1487.       Sound.play_ok
  1488.       @number_window = Window_NumberInput_SS.new
  1489.       @number_window.start(get_item,@ss_category)
  1490.     else
  1491.       Sound.play_buzzer
  1492.       select_window
  1493.     end
  1494.   end
  1495.  
  1496.   def has_item_to_pick
  1497.     if @ss_category == :deposit
  1498.       return @list_player_window.item_max > 0
  1499.     else
  1500.       return @list_storage_window.item_max > 0
  1501.     end
  1502.   end
  1503.  
  1504.   def get_item
  1505.     if @ss_category == :deposit
  1506.       return @list_player_window.item
  1507.     else
  1508.       return @list_storage_window.item
  1509.     end
  1510.   end
  1511.  
  1512.   def can_store(item)
  1513.     if @ss_category == :deposit
  1514.       numb = ADIK::SHARED_STORAGE::MAX_ITEM_NUMBER[@storage_number]
  1515.       numb = ADIK::SHARED_STORAGE::MAX_ITEM_NUMBER[0] if numb.nil?
  1516.       numb = eval(numb)
  1517.       begin
  1518.         numb -= $shared_storage[[@storage_number,item.class.to_s,item.id]]
  1519.       rescue
  1520.       end
  1521.       return numb > 0
  1522.     else
  1523.       numb = $game_party.item_number(item)
  1524.       return numb < $game_party.max_item_number(item)
  1525.     end
  1526.   end
  1527.  
  1528.   def set_number(number)
  1529.     @number = number
  1530.     item = get_item
  1531.     if @ss_category == :deposit
  1532.       if number > 0
  1533.         $shared_storage[[@storage_number,item.class.to_s,item.id]] = 0 if $shared_storage[[@storage_number,item.class.to_s,item.id]].nil?
  1534.         $game_party.lose_item(item,number)
  1535.         $shared_storage[[@storage_number,item.class.to_s,item.id]] += number
  1536.         @list_player_window.refresh
  1537.         @list_storage_window.refresh
  1538.         ADIK::SHARED_STORAGE.save_storage if ADIK::SHARED_STORAGE::AUTOSAVE
  1539.       end
  1540.     else
  1541.       if number > 0
  1542.         $game_party.gain_item(item,number)
  1543.         $shared_storage[[@storage_number,item.class.to_s,item.id]] -= number
  1544.         if $shared_storage[[@storage_number,item.class.to_s,item.id]] == 0
  1545.           $shared_storage.delete([@storage_number,item.class.to_s,item.id])
  1546.         end
  1547.         @list_player_window.refresh
  1548.         @list_storage_window.refresh
  1549.         ADIK::SHARED_STORAGE.save_storage if ADIK::SHARED_STORAGE::AUTOSAVE
  1550.       end
  1551.     end
  1552.     @custom_text_window.update_text
  1553.     select_window
  1554.   end
  1555.  
  1556.   def update
  1557.     super
  1558.     return if @storage_number_max.nil?
  1559.     if Input.trigger?(ADIK::SHARED_STORAGE::NEXT_KEY)
  1560.       if @storage_number < @storage_number_max
  1561.         @storage_number += 1
  1562.       else
  1563.         @storage_number = @storage_number_min
  1564.       end
  1565.       SceneManager.next_storage(@storage_number,@storage_number_min,@storage_number_max)
  1566.     elsif Input.trigger?(ADIK::SHARED_STORAGE::PREV_KEY)
  1567.       if @storage_number > @storage_number_min
  1568.         @storage_number -= 1
  1569.       else
  1570.         @storage_number = @storage_number_max
  1571.       end
  1572.       SceneManager.next_storage(@storage_number,@storage_number_min,@storage_number_max)
  1573.     end
  1574.   end
  1575.  
  1576. end
  1577.  
  1578. module DataManager
  1579.  
  1580.   class <<self; alias load_game_shared_storage load_game; end
  1581.   def self.load_game(index)
  1582.     load_game_shared_storage(index)
  1583.     ADIK::SHARED_STORAGE.load_storage
  1584.   end
  1585.  
  1586.   class <<self; alias save_game_without_rescue_sharedstorage save_game_without_rescue; end
  1587.   def self.save_game_without_rescue(index)
  1588.     save_game_without_rescue_sharedstorage(index)
  1589.     ADIK::SHARED_STORAGE.save_storage
  1590.     return true
  1591.   end
  1592.  
  1593. end
  1594.  
  1595. module SceneManager
  1596.  
  1597.   def self.open_shared_storage(number,limit=nil)
  1598.     @stack.push(@scene)
  1599.     @scene = Scene_SharedStorage.new
  1600.     $shared_storage_number = number
  1601.     @scene.storage_number_min = number
  1602.     @scene.storage_number_max = limit
  1603.   end
  1604.  
  1605.   def self.next_storage(number,min,max)
  1606.     #doesn't add the last scene to stack and that
  1607.     #is just the old storage scene
  1608.     @scene = Scene_SharedStorage.new
  1609.     $shared_storage_number = number
  1610.     @scene.storage_number_min = min
  1611.     @scene.storage_number_max = max
  1612.   end
  1613.  
  1614. end
Advertisement
Add Comment
Please, Sign In to add comment