Advertisement
TheSixth

Global Setting Addon for Yanfly's System Options

Oct 20th, 2016
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 27.05 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Global Setting Addon for Yanfly's System Options
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.1
  6. # * Updated: 22/10/2016
  7. # * Requires: Yanfly's System Options
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (21/10/2016)
  12. #   - Initial release.
  13. # * Version 1.1 (22/10/2016)
  14. #   - Reworked/optimized the code.
  15. #   - Now the script will automatically read the default values from
  16. #     Yanfly's System Options and from my PC Timer Display Options script.
  17. #     You can still set all the default values up in this script if you prefer
  18. #     to keep all of them at the same place.
  19. #   - Also automatically makes the switches and variables used in
  20. #     Yanfly's System Options global. You can still set the default values for
  21. #     them in this script, otherwise, they will default to false.
  22. #   - Fixed a bug with the "Revert Changes" option.
  23. #-------------------------------------------------------------------------------
  24. # * < Description >
  25. #-------------------------------------------------------------------------------
  26. # * This script will change the settings from Yanfly's System Options script to
  27. #   be a global setting read from a file. This means that it will not reset
  28. #   after starting a new game anymore, all games will share the same settings!
  29. # * Okay, the last bit is not entirely correct... You can make user specific
  30. #   setting files, so depending on who is logged in on your PC (as a Windows
  31. #   user), a different one can be loaded.
  32. # * Set up all the default values for your settings in this script!
  33. # * Switches and variables included in the default settings here will also
  34. #   become global ones! So, if they are changed in one game, they will be
  35. #   changed in all of the other games and save files! Keep this in mind!
  36. # * Adds the option to add 2 new buttons for the options menu:
  37. #   - Revert Changes: Reverts the changes made to the last saved settings.
  38. #   - Default Settings: Loads the default settings.
  39. # * Adds the possibility to add a button for the options menu on the title
  40. #   screen. Because the settings are global now, they will work on the
  41. #   title screen without any issues. Before making them global, all of the
  42. #   settings the player may have changed on the title screen were reseted once
  43. #   the game was started/loaded, so adding the button to the title screen was
  44. #   not really a good move until now.
  45. # * You can also make global switches, variables and even self-switches with
  46. #   this script, and these do not need to be connected with any settings at all.
  47. #   Might be good for some extra secret scenes, or unlocking secret areas, etc.
  48. #   Also, these switches, variables and self-switches can be used on the
  49. #   title screen too! You can make New Game+ button with these, for example
  50. #   (as long as you know how to add custom buttons to the title commands).
  51. # * Includes compatibility for my PC Clock Display - YF System Options Addon
  52. #   script as well.
  53. #-------------------------------------------------------------------------------
  54. # * < Installation >
  55. #-------------------------------------------------------------------------------
  56. # * In the script editor, place this script below Yanfly's System Options
  57. #   but above Main!
  58. # * If you are using my PC Clock Display - YF System Options Addon script, you
  59. #   must place this one below that script too!
  60. #-------------------------------------------------------------------------------
  61. # * < Compatibility Info >
  62. #-------------------------------------------------------------------------------
  63. # * No known incompatibilities.
  64. #-------------------------------------------------------------------------------
  65. # * < Known Issues >
  66. #-------------------------------------------------------------------------------
  67. # * No known issues.
  68. #-------------------------------------------------------------------------------
  69. # * < Terms of Use >
  70. #-------------------------------------------------------------------------------
  71. # * Free to use for whatever purposes you want.
  72. # * Credit me (Sixth) in your game, pretty please! :P
  73. # * Posting modified versions of this script is allowed as long as you notice me
  74. #   about it with a link to it!
  75. #===============================================================================
  76. $imported = {} if $imported.nil?
  77. $imported["SixthYanSysOptAdd"] = true
  78. #===============================================================================
  79. # Settings:
  80. #===============================================================================
  81. module YanSysOptAdd
  82.   #-----------------------------------------------------------------------------
  83.   # Debug Setting:
  84.   #-----------------------------------------------------------------------------  
  85.   # Just a debug setting.
  86.   # If this is true, every time you start the game, the file used to store your
  87.   # settings will be reloaded with the default settings you set up in this
  88.   # script!
  89.   # true = reload, false = no reload.
  90.   # Use it if you want to quickly reload the settings for some reason (most
  91.   # probably for debugging).
  92.   # WARNING:
  93.   # You must set this to false for your public game relase, otherwise it will
  94.   # break your options menu!
  95.   #-----------------------------------------------------------------------------  
  96.   Reload = false
  97.  
  98.   #-----------------------------------------------------------------------------  
  99.   # Environmental Path Settings:
  100.   #-----------------------------------------------------------------------------  
  101.   # The environmental path of the folder for your file.
  102.   # This path can differ from PC to PC, and that is why it should use the
  103.   # 'ENV' module to get the correct path to the desired folder(s).
  104.   # In any case, you can edit the text inside the [brackets] to get different
  105.   # folder paths. You can use these values:
  106.   #
  107.   # "AppData" = Will get: "C\\Users\\*Username*\\AppData\\Roaming"
  108.   # "LOCALAPPDATA" = Will get: "C\\Users\\*Username*\\AppData\\Local"
  109.   # "ProgramFiles" = Will get: "C\\ProgramFiles (x86)"
  110.   # "CommonProgramFiles" = Will get: "C\\ProgramFiles (x86)\\Common Files"
  111.   #
  112.   # Again, these folder paths might differ, especially on different OS.
  113.   # The examples I gave are for a Windows 7 PC with the windows installed on
  114.   # the C partition.
  115.   #
  116.   # If you use the environmental path, depending on which one you choose, the
  117.   # setting file can be a separate file for different users logged in on the
  118.   # PC (as Windows users).
  119.   #
  120.   # Also, some of these might require your game to be "Run as Administrator"!
  121.   #
  122.   # If you don't want to use these environmental folder paths, you can use an
  123.   # empty string for this setting, which looks like this:
  124.   #   DPath = ""
  125.   # In this case, the root of the path will be your project's folder, so if you
  126.   # just enter this, it will be in your project's folder.
  127.   # This also means that all users of the PC (as Windows users) will share the
  128.   # same settings. Might not be a good idea, if you ask me. :P
  129.   #-----------------------------------------------------------------------------  
  130.   DPath = ENV["LOCALAPPDATA"]
  131.  
  132.   #-----------------------------------------------------------------------------
  133.   # Static Path Settings:
  134.   #-----------------------------------------------------------------------------  
  135.   # This is the static sub-folder path to the actual file. These are the
  136.   # non-environmental parts of your folder path to your file.
  137.   # Each string you add into the array will be a sub-folder created, nested in
  138.   # each other.
  139.   # The sample settings will place the used files to the following folder:
  140.   # "C\\Users\\*Username*\\AppData\\Local\\MyProject\\GameSettings\\"
  141.   # Again, this path might differ for different PC/OS version.
  142.   #-----------------------------------------------------------------------------  
  143.   SPath = ["MyProject","GameSettings"]
  144.  
  145.   #-----------------------------------------------------------------------------
  146.   # File Name Settings:
  147.   #-----------------------------------------------------------------------------  
  148.   # And finally, the last setting for your setting file, it's name.
  149.   # You can name it however you like.
  150.   # It's extension can also be anything you like, such as .ini/.txt/.rvdata2 ...
  151.   # Note that some minor encoding will be used on the file, so you will not be
  152.   # able to edit the file directly, regardless of what kind of extension you
  153.   # use for it!
  154.   #-----------------------------------------------------------------------------  
  155.   FileName = "GameOptions.ini"
  156.  
  157.   #-----------------------------------------------------------------------------
  158.   # Extra Button Settings:
  159.   #-----------------------------------------------------------------------------  
  160.   # These are the settings for the new options you can use in
  161.   # Yanfly's System Options script.
  162.   # You can set up their name and description.
  163.   # To use these new buttons in your game, just enter the following symbols
  164.   # into the COMMANDS array found in Yanfly's System Options script:
  165.   # :revert - Adds the "Revert Changes" button.
  166.   # :default - Adds the "Default Settings" button.
  167.   #-----------------------------------------------------------------------------  
  168.   NewButtons = {
  169.     :revert => { # Revert Changes:
  170.       :name => "Revert Changes",
  171.       :description => "This will revert the changes you made in the settings\n"+
  172.                       "to the last saved one.",
  173.     },
  174.     :default => { # Default Settings:
  175.       :name => "Default Settings",
  176.       :description => "This will load the default settings.",
  177.     },
  178.   }
  179.  
  180.   #-----------------------------------------------------------------------------
  181.   # Title Button Settings:
  182.   #-----------------------------------------------------------------------------  
  183.   # This will add the button for the options menu on the title screen.
  184.   # Details:
  185.   # :enable - Set this to true if you want to enable the options menu on the
  186.   #           title screen, otherwise set it to false.
  187.   # :index - The position of the new button. 0 = 1st button, 1 = 2nd button,
  188.   #          and so on.
  189.   # :name - The name of the options button.
  190.   # :remove_title - This will remove the "Return to Title" option from the
  191.   #                 settings menu if it is accessed from the title screen
  192.   #                 (only then!).
  193.   #                 true will enable this feature, false will disable.
  194.   # :remove_exit - This will remove the "Shutdown Game" option from the settings
  195.   #                menu if it is accessed from the title screen (only then!).
  196.   #                true will enable this feature, false will disable.
  197.   # NOTE:
  198.   # In case the last command is a blank one on the settings menu, that last
  199.   # blank space will be also removed if you use the above 2 settings.
  200.   #-----------------------------------------------------------------------------  
  201.   TitleAdd = {
  202.     :enable => true,
  203.     :index => 2,
  204.     :name => "Options",
  205.     :remove_title => false,
  206.     :remove_exit => true,
  207.   }
  208.  
  209.   #-----------------------------------------------------------------------------
  210.   # Default Settings:
  211.   #-----------------------------------------------------------------------------  
  212.   # And this is where you will setup all the default settings for your game.
  213.   # The game will start with these settings when it is launched at the 1st time.
  214.   # The "Default Settings" button in the options menu will also load these
  215.   # settings (if you use that button).
  216.   #
  217.   # NOTE:
  218.   # All of the default settings you may have set up in Yanfly's script are now
  219.   # discarded! The ones you setup here will be used instead!
  220.   # Same for my PC Clock Display script, the starting settings will be loaded
  221.   # from here now!
  222.   #
  223.   # NOTE2:
  224.   # From v1.1, all of these settings are optional! If you don't set up them,
  225.   # the default values for them will be loaded from the related scripts instead!
  226.   # Switches and variables used on the settings scene will default to false,
  227.   # all the volume control options will default to 100 (meaning 100%), and
  228.   # the other settings will read their default value from the relevant sources
  229.   # (windowskin from the database settings, Yanfly options from his script and
  230.   # PC clock options from my script).
  231.   # If you enter new values for them here, those will be used instead!
  232.   #
  233.   # I think, all of the settings are obvious enough. But just to make sure, I
  234.   # will write some details here:
  235.   #
  236.   # - Yanfly's Default Options:
  237.   # :bgm, :bgs, :sfx - Values: 0 - 100 (percentages).
  238.   # :autodash, :instantmsg, :animations - Values: true/false (enabled/disabled).
  239.   # :window_tone - Format: Tone.new(R,G,B,0), Color values: -255 - 255.
  240.   #
  241.   # - PC Clock Display Options:
  242.   # :timer_pos - Related Setting: Position_Setup
  243.   # :timer_skin - Related Setting: Windowskin_Setup
  244.   # :timer_color - Related Setting: Color_Setup
  245.   # :timer_back - Related Setting: Background_Setup
  246.   # Check the details for these in my PC Clock Display - YF System Options Addon
  247.   # script! You can find information about these settings at the above marked
  248.   # related settings explanations.
  249.   # Even if you don't use my PC Clock Display script, you don't need to remove
  250.   # these settings if you don't want to, they won't do anything in your game.
  251.   #
  252.   # - Switch Options:
  253.   # You must enter all the switches you want to use as a global setting here!
  254.   # The format is:
  255.   #   switch_id => true/false,
  256.   # Replace the switch_id with any switch ID you want.
  257.   # true means that it will turned ON, false means that it will be turned OFF.
  258.   # You should NOT use these switches for anything else in your game or weird
  259.   # things might happen! You have been warned! :P
  260.   # I added some switch settings as samples already. They use the same IDs like
  261.   # my PC Clock Display script (for toggling some HUD elements). Disabled them
  262.   # because it's not really necessary to add them here anymore, but if you
  263.   # want to change their default value (which is false), you can still use them.
  264.   # Aside from that, any switch you add here will become a global one,
  265.   # regardless if you use them for your settings or not. Imagine that something
  266.   # happens in one of your game, turns on a global switch, and that something
  267.   # now affected all games started too, regardless if they are saved in a
  268.   # different save slot or if it's a new game entirely. Some cool stuffs can
  269.   # be made with this for sure, right? :P
  270.   #
  271.   #
  272.   # - Variable Options:
  273.   # Much like the switch settings, you must enter all the variables you want to
  274.   # use as global settings here!
  275.   # The format is:
  276.   #   variable_id => value,
  277.   # Replace the variable_id with the ID of the variable you want to use.
  278.   # And the value can be any numeric value, just make sure that it is within
  279.   # the minimum and maximum value limits you have set up in Yanfly's script for
  280.   # the variable option or weird things will happen!
  281.   # Again, do NOT use these variables for anything else in your game!
  282.   # And just like global switches, these can be used even if they don't appear
  283.   # on the settings scene for eventing purposes.
  284.   #
  285.   # - Self Switch Options:
  286.   # Hahh, gotcha! No, currently, there is no way to add a setting based on self
  287.   # switches. However, if you want to start your game with some self-switches
  288.   # already enabled, or if you want to disable some self-switches already
  289.   # enabled in a saved game, but you don't want to edit your events, you can
  290.   # use this if you want.
  291.   # The format is:
  292.   #   [map_id,event_id,'sswitch_letter'] = true/false,
  293.   # Replace the map_id with the ID of the map the event is on.
  294.   # Replace event_id with the ID of the event you want to change.
  295.   # Replace 'sswitch_letter' with the self-switch letter: 'A'/'B'/'C'/'D'.
  296.   # true means that it will be turned ON, false means that it will be turned
  297.   # OFF. You can enter as many as you want!
  298.   # Note that if you want to use this, you must turn the 'Reload' setting to
  299.   # true, or else the newly added self-switch settings will NOT be effective!
  300.   # Also, make sure to remove these settings when you ship your game or else...
  301.   # Yeah, weird things may happen in your game! :P
  302.   # Or if you would like to actually save these self-switches across all games
  303.   # (saved games or newly started ones), don't remove them, and they will
  304.   # become global self-switches for your eventing purposes.
  305.   #-----------------------------------------------------------------------------  
  306.   Defaults = {
  307.     # Default options:
  308. #~     :volume_bgm => 100,
  309. #~     :volume_bgs => 100,
  310. #~     :volume_sfx => 100,
  311. #~     :bgm => 80,
  312. #~     :bgs => 70,
  313. #~     :sfx => 60,
  314. #~     :autodash => true,
  315. #~     :instantmsg => true,
  316. #~     :animations => true,
  317. #~     :window_tone => Tone.new(-100,-50,-100,0),
  318.     # --- Requires my PC Timer Display - YF System Options Addon script! ---
  319. #~     :timer_pos => [0,0],
  320. #~     :timer_skin => "Window",
  321. #~     :timer_color => 17,
  322. #~     :timer_back => "timerbackv1",
  323.     # --- End of timer display options! ---
  324.     :switches => { # Switch settings:
  325. #~       33 => true,
  326. #~       134 => true,
  327. #~       135 => true,
  328.       # Add new switch settings here!
  329.     },
  330.     :variables => { # Variable settings:
  331.       # Add new variable settings here!
  332.     },
  333.     :selfswitches => { # Self-switch settings:
  334.       # Add new self-switch settings here!
  335.     },
  336.   }
  337.  
  338. #===============================================================================
  339. # End of settings! O.o
  340. #===============================================================================
  341.  
  342.   def self.init
  343.     file = self.check_sys_file
  344.     if File.exist?(file) && !Reload
  345.       $data_options = load_data(file)
  346.     else
  347.       self.load_defaults
  348.       save_data($data_options, file)
  349.     end
  350.   end
  351.  
  352.   def self.check_sys_file
  353.     file = ""
  354.     file += DPath + "\\" unless DPath.empty?
  355.     SPath.each do |path|
  356.       file += path + "\\"
  357.       Dir.mkdir(file) if !FileTest.exist?(file)
  358.     end
  359.     file += FileName
  360.     return file
  361.   end
  362.  
  363.   def self.load_system_settings
  364.     file = self.check_sys_file
  365.     $data_options = load_data(file)
  366.   end
  367.  
  368.   def self.load_defaults
  369.     $data_options = Marshal.load(Marshal.dump(Defaults))
  370.     load_def_data(:bgm,100,$data_options[:bgm].nil?)
  371.     load_def_data(:bgs,100,$data_options[:bgs].nil?)
  372.     load_def_data(:sfx,100,$data_options[:sfx].nil?)
  373.     load_def_data(:autodash,YEA::SYSTEM::DEFAULT_AUTODASH,$data_options[:autodash].nil?)
  374.     load_def_data(:instantmsg,YEA::SYSTEM::DEFAULT_INSTANTMSG,$data_options[:instantmsg].nil?)
  375.     load_def_data(:animations,YEA::SYSTEM::DEFAULT_ANIMATIONS,$data_options[:animations].nil?)
  376.     if $imported["SixthPCTimerYFOptions"]
  377.       load_def_data(:timer_pos,Sixth_RTime_HUD::Position_Setup.values[0],$data_options[:timer_pos].nil?)
  378.       load_def_data(:timer_skin,Sixth_RTime_HUD::Windowskin_Setup.values[0],$data_options[:timer_skin].nil?)
  379.       load_def_data(:timer_color,Sixth_RTime_HUD::Color_Setup.values[0],$data_options[:timer_color].nil?)
  380.       load_def_data(:timer_back,Sixth_RTime_HUD::Background_Setup.values[0],$data_options[:timer_back].nil?)
  381.     end
  382.     if $data_options[:window_tone].nil?
  383.       ori_sys = $BTEST ? load_data("Data/BT_System.rvdata2") : load_data("Data/System.rvdata2")
  384.       $data_options[:window_tone] = ori_sys.window_tone
  385.     end
  386.   end
  387.  
  388.   def self.load_def_data(type,data,cond)
  389.     $data_options[type] = data if cond
  390.   end
  391.  
  392.   def self.save_system_settings
  393.     file = self.check_sys_file
  394.     save_data($data_options, file)
  395.   end
  396.      
  397. end
  398.  
  399. module DataManager
  400.  
  401.   class << self; alias add_def_sys_values5598 create_game_objects; end
  402.   def self.create_game_objects
  403.     add_def_sys_values5598
  404.     set_def_sys_values
  405.   end
  406.  
  407.   def self.set_def_sys_values
  408.     self.add_stuffs_from_yf_opts
  409.     $data_options[:switches].each do |id,val|
  410.       if id.is_a?(Array)
  411.         id.each {|iid| $game_switches[iid] = val }
  412.       else
  413.         $game_switches[id] = val
  414.       end
  415.     end
  416.     $data_options[:variables].each do |id,val|
  417.       if id.is_a?(Array)
  418.         id.each {|iid| $game_variables[iid] = val }
  419.       else
  420.         $game_variables[id] = val
  421.       end
  422.     end
  423.     $data_options[:selfswitches].each do |id,val|
  424.       $game_self_switches[id] = val
  425.     end
  426.   end
  427.  
  428.   def self.add_stuffs_from_yf_opts
  429.     YEA::SYSTEM::CUSTOM_SWITCHES.each do |sym,data|
  430.       next unless $data_options[:switches][data[0]].nil?
  431.       $data_options[:switches][data[0]] = false
  432.     end
  433.     YEA::SYSTEM::CUSTOM_VARIABLES.each do |sym,data|
  434.       next unless $data_options[:variables][data[0]].nil?
  435.       $data_options[:variables][data[0]] = false
  436.     end
  437.   end
  438.  
  439. end
  440.  
  441. module SceneManager
  442.  
  443.   class << self; alias init_sys_settings1287 run; end
  444.   def self.run
  445.     YanSysOptAdd.init
  446.     init_sys_settings1287
  447.   end
  448.  
  449. end
  450.  
  451. class Game_Switches
  452.    
  453.   alias make_em_global1092 []=
  454.   def []=(id, value)
  455.     make_em_global1092(id, value)
  456.     if $data_options[:switches].include?(id)
  457.       $data_options[:switches][id] = value
  458.       YanSysOptAdd.save_system_settings unless SceneManager.scene_is?(Scene_System)
  459.     end
  460.   end
  461.  
  462. end
  463.  
  464. class Game_Variables
  465.    
  466.   alias make_em_global2232 []=
  467.   def []=(id, value)
  468.     make_em_global2232(id, value)
  469.     if $data_options[:variables].include?(id)
  470.       $data_options[:variables][id] = value
  471.       YanSysOptAdd.save_system_settings unless SceneManager.scene_is?(Scene_System)
  472.     end
  473.   end
  474.  
  475. end
  476.  
  477. class Game_SelfSwitches
  478.    
  479.   alias make_em_global1092 []=
  480.   def []=(id, value)
  481.     make_em_global1092(id, value)
  482.     if $data_options[:selfswitches].include?(id)
  483.       $data_options[:selfswitches][id] = value
  484.       YanSysOptAdd.save_system_settings unless SceneManager.scene_is?(Scene_System)
  485.     end
  486.   end
  487.  
  488. end
  489.  
  490. class Game_System
  491.    
  492.   def volume(type)
  493.     return $data_options[type]
  494.   end
  495.  
  496.   def volume_change(type, increment)
  497.     $data_options[type] += increment
  498.     $data_options[type] = [[$data_options[type], 0].max, 100].min
  499.   end
  500.  
  501.   def window_tone
  502.     return $data_options[:window_tone]
  503.   end
  504.  
  505.   def window_tone=(window_tone)
  506.     $data_options[:window_tone] = window_tone
  507.   end
  508.    
  509.   def autodash?
  510.     return $data_options[:autodash]
  511.   end
  512.  
  513.   def instantmsg?
  514.     return $data_options[:instantmsg]
  515.   end
  516.  
  517.   def animations?
  518.     return $data_options[:animations]
  519.   end
  520.  
  521.   def set_autodash(value)
  522.     $data_options[:autodash] = value
  523.   end
  524.    
  525.   def set_instantmsg(value)
  526.     $data_options[:instantmsg] = value
  527.   end
  528.  
  529.   def set_animations(value)
  530.     $data_options[:animations] = value
  531.   end
  532.  
  533.   def rtime_pos
  534.     return $data_options[:timer_pos]
  535.   end
  536.  
  537.   def rtime_color
  538.     return $data_options[:timer_color]
  539.   end
  540.  
  541.   def rtime_skin
  542.     return $data_options[:timer_skin]
  543.   end
  544.  
  545.   def rtime_back
  546.     return $data_options[:timer_back]
  547.   end
  548.  
  549.   def rtime_pos=(val)
  550.     $data_options[:timer_pos] = val
  551.   end
  552.  
  553.   def rtime_color=(val)
  554.     $data_options[:timer_color] = val
  555.   end
  556.  
  557.   def rtime_skin=(val)
  558.     $data_options[:timer_skin] = val
  559.   end
  560.  
  561.   def rtime_back=(val)
  562.     $data_options[:timer_back] = val
  563.   end  
  564.  
  565. end
  566.  
  567. class Window_SystemOptions < Window_Command
  568.  
  569.   alias fix_new_btns8811 ok_enabled?
  570.   def ok_enabled?
  571.     return true if [:revert, :default].include?(current_symbol)
  572.     return fix_new_btns8811
  573.   end
  574.  
  575.   alias hide_some_opts6615 make_command_list
  576.   def make_command_list
  577.     hide_some_opts6615
  578.     hide_exit_opts if SceneManager.scene.on_title
  579.   end
  580.  
  581.   def hide_exit_opts
  582.     flags = SceneManager.scene.on_title
  583.     if flags[0]
  584.       op = {:name => YEA::SYSTEM::COMMAND_VOCAB[:to_title][0],
  585.             :symbol=> :to_title, :enabled => true, :ext => nil}
  586.       @list.delete(op)
  587.     end
  588.     if flags[1]
  589.       op = {:name => YEA::SYSTEM::COMMAND_VOCAB[:shutdown][0],
  590.             :symbol=> :shutdown, :enabled => true, :ext => nil}
  591.       @list.delete(op)
  592.     end
  593.     @list.pop if (flags[0] || flags[1]) && @list[-1][:symbol] == :blank
  594.   end
  595.    
  596.   alias add_new_commands2218 process_custom_switch
  597.   def process_custom_switch(sym)
  598.     case sym
  599.     when :revert, :default
  600.       add_command(YanSysOptAdd::NewButtons[sym][:name], sym)
  601.       @help_descriptions[sym] = YanSysOptAdd::NewButtons[sym][:description]
  602.     else
  603.       add_new_commands2218(sym)
  604.     end
  605.   end
  606.  
  607.   alias sixth_add_new_btns9917 draw_item
  608.   def draw_item(index)
  609.     rect = item_rect(index)
  610.     sixth_add_new_btns9917(index)
  611.     case @list[index][:symbol]
  612.     when :revert, :default;   draw_new_opt_buttons(rect,index)
  613.     end
  614.   end
  615.  
  616.   def draw_new_opt_buttons(rect,index)
  617.     change_color(normal_color, command_enabled?(index))
  618.     draw_text(rect, command_name(index), 1)
  619.   end
  620.    
  621. end
  622.  
  623. class Scene_System < Scene_MenuBase
  624.  
  625.   def on_title
  626.     return @on_title
  627.   end
  628.  
  629.   alias backup_settings7715 start
  630.   def start
  631.     @old_settings = Marshal.load(Marshal.dump($data_options))
  632.     backup_settings7715
  633.   end
  634.  
  635.   def prepare(title_flag=false,exit_flag=false)
  636.     @on_title = [title_flag,exit_flag]
  637.   end
  638.  
  639.   alias add_new_buttons7761 create_command_window
  640.   def create_command_window
  641.     add_new_buttons7761
  642.     @command_window.set_handler(:revert, method(:revert_changes))
  643.     @command_window.set_handler(:default, method(:set_defaults))
  644.   end
  645.  
  646.   def revert_changes
  647.     $data_options = Marshal.load(Marshal.dump(@old_settings))
  648.     DataManager.set_def_sys_values
  649.     @command_window.refresh
  650.     @command_window.activate
  651.   end
  652.  
  653.   def set_defaults
  654.     YanSysOptAdd.load_defaults
  655.     DataManager.set_def_sys_values
  656.     @command_window.refresh
  657.     @command_window.activate
  658.   end
  659.  
  660.   def dispose_all_windows
  661.     YanSysOptAdd.save_system_settings if @old_settings != $data_options
  662.     super
  663.   end
  664.  
  665.   alias save_settings6151 command_to_title
  666.   def command_to_title
  667.     if @on_title
  668.       return_scene
  669.     else
  670.       save_settings6151
  671.     end
  672.   end
  673.  
  674. end
  675.  
  676. class Window_TitleCommand < Window_Command
  677.  
  678.   alias add_opt_btn9917 make_command_list
  679.   def make_command_list
  680.     add_opt_btn9917
  681.     add_options_button if YanSysOptAdd::TitleAdd[:enable]
  682.   end
  683.  
  684.   def add_options_button
  685.     cmd = {
  686.       :name => YanSysOptAdd::TitleAdd[:name],
  687.       :symbol=> :options, :enabled => true, :ext => nil
  688.     }
  689.     @list.insert(YanSysOptAdd::TitleAdd[:index],cmd)
  690.   end
  691.  
  692. end
  693.  
  694. class Scene_Title < Scene_Base
  695.  
  696.   alias add_opt_button8871 create_command_window
  697.   def create_command_window
  698.     add_opt_button8871
  699.     @command_window.set_handler(:options, method(:command_options))
  700.   end
  701.  
  702.   def command_options
  703.     SceneManager.call(Scene_System)
  704.     rem1 = YanSysOptAdd::TitleAdd[:remove_title]
  705.     rem2 = YanSysOptAdd::TitleAdd[:remove_exit]
  706.     SceneManager.scene.prepare(rem1,rem2)
  707.   end
  708.    
  709. end
  710. #==============================================================================
  711. # !!END OF SCRIPT - OHH, NOES!!
  712. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement