Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #==============================================================================
  2. # YEA + Theolized ~ Global System Option
  3. # Version : 1.0
  4. # Language : Informal Indonesian
  5. # Requires : YEA System Option
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. # Contact :
  8. #------------------------------------------------------------------------------
  9. # *> http://www.rpgmakerid.com
  10. # *> http://www.rpgmakervxace.net
  11. # *> http://www.theolized.com
  12. #==============================================================================
  13. ($imported ||= {})[:Theo_GlobalOption] = true
  14. #==============================================================================
  15. # Change Logs:
  16. # -----------------------------------------------------------------------------
  17. # 2013.10.27 - Finished
  18. #==============================================================================
  19. %Q{
  20.  
  21.   =================
  22.   || Perkenalan ||
  23.   -----------------
  24.   Script ini adalah addon untuk YEA System Option dimana opsi yang kamu atur
  25.   nantinya akan disimpan secara global dan akan dipakai di setiap save file
  26.  
  27.   ======================
  28.   || Cara penggunaan ||
  29.   ----------------------
  30.   Pasang script ini di bawah YEA system option
  31.  
  32.   Script ini akan membuat file yang bernama 'OptionData.rvdata2' di folder
  33.   game kamu. Jika kamu ingin mereset system option, tinggal delete saja file
  34.   tersebut dan saat kamu jalankan kembali, maka semuanya akan direset dan file
  35.   akan dibuat kembali.
  36.  
  37.   ===================
  38.   || Terms of use ||
  39.   -------------------
  40.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  41.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  42.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  43.  
  44. }
  45. #==============================================================================
  46. # Tidak ada konfigurasi
  47. #==============================================================================
  48. if $imported["YEA-SystemOptions"]  
  49. #==============================================================================
  50. # * DataManager
  51. #==============================================================================
  52.  
  53. class << DataManager
  54.  
  55.   alias theo_globoption_load_db load_database
  56.   def load_database
  57.     theo_globoption_load_db
  58.     OptionData.init
  59.   end
  60.  
  61. end
  62.  
  63. #==============================================================================
  64. # * SceneManager
  65. #==============================================================================
  66.  
  67. class << SceneManager
  68.  
  69.   def from_title?
  70.     @stack[-1].is_a?(Scene_Title)
  71.   end
  72.  
  73. end
  74.  
  75. #==============================================================================
  76. # * OptionData
  77. #==============================================================================
  78.  
  79. class OptionData
  80.   attr_accessor :volume_bgm
  81.   attr_accessor :volume_bgs
  82.   attr_accessor :volume_sfx
  83.   attr_accessor :autodash
  84.   attr_accessor :instant_msg
  85.   attr_accessor :animations
  86.   attr_accessor :window_tone
  87.   attr_reader :switch_ids
  88.   attr_reader :var_ids
  89.   attr_reader :switches
  90.   attr_reader :variables
  91.  
  92.   FileName = 'OptionData.rvdata2'
  93.  
  94.   def self.init
  95.     if FileTest.exist?(FileName)
  96.       $option_data = load_data(FileName)
  97.       $option_data.refresh_switch_var
  98.     else
  99.       $option_data = OptionData.new
  100.       OptionData.save
  101.     end
  102.   end
  103.  
  104.   def self.save
  105.     File.open(FileName, 'w') do |file|
  106.       Marshal.dump($option_data, file)
  107.     end
  108.   end
  109.  
  110.   def initialize
  111.     @volume_bgm = 100
  112.     @volume_bgs = 100
  113.     @volume_sfx = 100
  114.     @autodash = YEA::SYSTEM::DEFAULT_AUTODASH
  115.     @instant_msg = YEA::SYSTEM::DEFAULT_INSTANTMSG
  116.     @animations = YEA::SYSTEM::DEFAULT_ANIMATIONS
  117.     @window_tone = $data_system.window_tone.clone
  118.     @switches = {}
  119.     @variables = {}
  120.     refresh_switch_var
  121.   end
  122.  
  123.   def refresh_switch_var
  124.     switch_keys = YEA::SYSTEM::COMMANDS & YEA::SYSTEM::CUSTOM_SWITCHES.keys
  125.     used_switches = switch_keys.collect {|k| YEA::SYSTEM::CUSTOM_SWITCHES[k]}
  126.     @switch_ids = used_switches.collect {|val| val[0]}
  127.    
  128.     var_keys = YEA::SYSTEM::COMMANDS & YEA::SYSTEM::CUSTOM_VARIABLES.keys
  129.     used_var = var_keys.collect {|k| YEA::SYSTEM::CUSTOM_VARIABLES[k]}
  130.     @var_ids = used_var.collect {|val| val[0]}
  131.    
  132.     used_var.each do |vari|
  133.       orival = (@variables[vari[0]] ||= 0)
  134.       min = vari[4]
  135.       max = vari[5]
  136.       @variables[vari[0]] = [[orival, min].max, max].min
  137.     end
  138.    
  139.   end
  140.  
  141. end
  142.  
  143. #==============================================================================
  144. # * Game_System
  145. #==============================================================================
  146.  
  147. class Game_System
  148.  
  149.   def window_tone
  150.     $option_data.window_tone
  151.   end
  152.  
  153.   def window_tone=(tone)
  154.     $option_data.window_tone = tone
  155.   end
  156.  
  157.   def volume(type)
  158.     case type
  159.     when :bgm
  160.       result = $option_data.volume_bgm
  161.     when :bgs
  162.       result = $option_data.volume_bgs
  163.     when :sfx
  164.       result = $option_data.volume_sfx
  165.     else
  166.       return 100
  167.     end
  168.     return [[result, 0].max, 100].min
  169.   end
  170.  
  171.   def volume_change(type, inc)
  172.     case type
  173.     when :bgm
  174.       $option_data.volume_bgm = [[$option_data.volume_bgm + inc, 0].max,100].min
  175.     when :bgs
  176.       $option_data.volume_bgs = [[$option_data.volume_bgs + inc, 0].max,100].min
  177.     when :sfx
  178.       $option_data.volume_sfx = [[$option_data.volume_sfx + inc, 0].max,100].min
  179.     end
  180.     OptionData.save
  181.   end
  182.  
  183.   def set_autodash(value)
  184.     $option_data.autodash = value
  185.     OptionData.save
  186.   end
  187.  
  188.   def autodash?
  189.     $option_data.autodash
  190.   end
  191.  
  192.   def set_instantmsg(value)
  193.     $option_data.instant_msg = value
  194.     OptionData.save
  195.   end
  196.  
  197.   def instantmsg?
  198.     $option_data.instant_msg
  199.   end
  200.  
  201.   def set_animations(value)
  202.     $option_data.animations = value
  203.     OptionData.save
  204.   end
  205.  
  206.   def animations?
  207.     $option_data.animations
  208.   end
  209.  
  210. end
  211.  
  212. #==============================================================================
  213. # * Game_Switches
  214. #==============================================================================
  215.  
  216. class Game_Switches
  217.  
  218.   alias :glob_switch :[]
  219.   alias :glob_switch_set :[]=
  220.  
  221.   def [](id)
  222.     if $option_data.switch_ids.include?(id)
  223.       return $option_data.switches[id] || false
  224.     end
  225.     return glob_switch(id)
  226.   end
  227.  
  228.   def []=(id, val)
  229.     if $option_data.switch_ids.include?(id)
  230.       $option_data.switches[id] = val
  231.       OptionData.save
  232.       on_change
  233.       return
  234.     end
  235.     return glob_switch_set(id, val)
  236.   end
  237.  
  238. end
  239.  
  240. #==============================================================================
  241. # * Game_Variables
  242. #==============================================================================
  243.  
  244. class Game_Variables
  245.  
  246.   alias :glob_var :[]
  247.   alias :glob_var_set :[]=
  248.  
  249.   def [](id)
  250.     if $option_data.var_ids.include?(id)
  251.       return $option_data.variables[id] ||= 0
  252.     end
  253.     return glob_var(id)
  254.   end
  255.  
  256.   def []=(id, val)
  257.     if $option_data.var_ids.include?(id)
  258.       $option_data.variables[id] = val
  259.       OptionData.save
  260.       on_change
  261.       return
  262.     end
  263.     return glob_var_set(id, val)
  264.   end
  265.  
  266. end
  267.  
  268. #==============================================================================
  269. # * Window_TitleCommand
  270. #==============================================================================
  271.  
  272. class Window_TitleCommand
  273.  
  274.   alias theo_globoption_init initialize
  275.   def initialize
  276.     theo_globoption_init
  277.     set_handler(:option, method(:goto_option))
  278.   end
  279.  
  280.   alias theo_globoption_make_command make_command_list
  281.   def make_command_list
  282.     theo_globoption_make_command
  283.     hash = {
  284.       :name => YEA::SYSTEM::COMMAND_NAME,
  285.       :symbol => :option,
  286.       :enabled=> true,
  287.       :ext=> nil
  288.     }
  289.     @list.insert(2, hash)
  290.   end
  291.  
  292.   def goto_option
  293.     SceneManager.call(Scene_System)
  294.   end
  295.  
  296. end
  297.  
  298. #==============================================================================
  299. # * Scene_System
  300. #==============================================================================
  301.  
  302. class Scene_System
  303.  
  304.   alias theo_globoption_terminate terminate
  305.   def terminate
  306.     theo_globoption_terminate
  307.     OptionData.save
  308.   end
  309.  
  310.   def command_to_title
  311.     fadeout_all unless SceneManager.from_title?
  312.     SceneManager.goto(Scene_Title)
  313.   end
  314.  
  315. end
  316.  
  317. end # $imported