Advertisement
TheSixth

PC Clock HUD - System Option Addon by Sixth

Sep 2nd, 2015
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 17.93 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] PC Timer Display - YF System Options Addon
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.1
  6. # * Updated: 21/10/2016
  7. # * Requires: Sixth's PC Timer Display
  8. #             Yanfly's System Options
  9. #-------------------------------------------------------------------------------
  10. # * < Change Log >
  11. #-------------------------------------------------------------------------------
  12. # * Version 1.0 (05/02/2015)
  13. #   - Initial release.
  14. # * Version 1.1 (21/10/2016)
  15. #   - Reworked some code, fixed some descriptions.
  16. #-------------------------------------------------------------------------------
  17. # * < Description >
  18. #-------------------------------------------------------------------------------
  19. # * This script adds some extra options to Yanfly's System Options script.
  20. #   These options are, obviously, related to the timer display.
  21. #   Available options:
  22. #   - Timer Format change (12-hours, 24-hours).
  23. #   - Enable/disable the timer on the map.
  24. #   - Enable/disable the timer in the menu.
  25. #   - Timer window position settings.
  26. #   - Timer window windowskin settings.
  27. #   - Timer window background image settings.
  28. #   - Timer window color settings.
  29. #-------------------------------------------------------------------------------
  30. # * < Instructions >
  31. #-------------------------------------------------------------------------------
  32. # * For adding the switch settings for the clock format and for the
  33. #   enable/disable options, you must do the following:
  34. #
  35. #   In the 'CUSTOM_SWITCHES' hash in Yanfly's script, add these lines:
  36. #
  37. #   # -------------------------------------------------------------------------
  38. #      :switch_1  => [Sixth_RTime_HUD::Enable_Switch_Map, "Time Display (Map)",
  39. #                     "OFF", "ON",
  40. #                     "Turns the time display ON/OFF on the map."
  41. #                    ],
  42. #   # -------------------------------------------------------------------------
  43. #      :switch_2  => [Sixth_RTime_HUD::Enable_Switch_Menu, "Time Display (Menu)",
  44. #                     "OFF", "ON",
  45. #                     "Turns the time display ON/OFF in the menu."
  46. #                    ],
  47. #   # -------------------------------------------------------------------------
  48. #      :switch_3  => [Sixth_RTime_HUD::Format_Switch, "Time Display Format",
  49. #                     "12-hours", "24-hours",
  50. #                     "Sets the format of the time displayed."
  51. #                    ],
  52. #   # -------------------------------------------------------------------------
  53. #
  54. #   Adjust the settings of them however you want, but make sure to leave the
  55. #   switch setting alone (meaning the Sixth_RTime_HUD::XX part). This way you
  56. #   only need to change the switch settings in my script and it will be
  57. #   automatically changed in Yanfly's script as well.
  58. #
  59. #   After this, you can add :switch_1, :switch_2 and :switch_3 to the 'COMMANDS'
  60. #   array in Yanfly's script.
  61. #   This will make the player be able to set the time format and to
  62. #   enable/disable the timer display in the game options menu anytime.
  63. #
  64. # * For the rest of the options, you can simply add the following symbols to
  65. #   the 'COMMANDS' array in Yanfly's script:
  66. #
  67. #   :timer_pos   # <-- For adding position options for the timer to the menu.
  68. #   :timer_skin  # <-- For adding windowskin options for the timer to the menu.
  69. #   :timer_back  # <-- For adding background options for the timer to the menu.
  70. #   :timer_color # <-- For adding text color options for the timer to the menu.
  71. #
  72. #   Before you add any of these, you must configure the settings below to avoid
  73. #   any crashes! If you get a NoMethod error, it is most probably because of an
  74. #   incorrect setup, so double-check every settings before reporting any issue!
  75. #  
  76. #   To avoid weird changes happening with the timer display upon entering the
  77. #   system options menu, for each of these 4 settings the first option available
  78. #   should have the same settings like in the Timer Display script!
  79. #-------------------------------------------------------------------------------
  80. # * < Installation >
  81. #-------------------------------------------------------------------------------
  82. # * Place this script below Yanfly's System Options script and below
  83. #   my PC Timer Display script but above Main!
  84. #-------------------------------------------------------------------------------
  85. # * < Compatibility Info >
  86. #-------------------------------------------------------------------------------
  87. # * No known incompatibilities.
  88. #-------------------------------------------------------------------------------
  89. # * < Known Issues >
  90. #-------------------------------------------------------------------------------
  91. # * No known issues.
  92. #-------------------------------------------------------------------------------
  93. # * < Terms of Use >
  94. #-------------------------------------------------------------------------------
  95. # * Free to use for whatever purposes you want.
  96. # * Credit me (Sixth) in your game, pretty please! :P
  97. # * Posting modified versions of this script is allowed as long as you notice me
  98. #   about it with a link to it!
  99. #===============================================================================
  100. $imported = {} if $imported.nil?
  101. $imported["SixthPCTimerYFOptions"] = true
  102. #===============================================================================
  103. # Settings:
  104. #===============================================================================
  105. module Sixth_RTime_HUD
  106.   #-----------------------------------------------------------------------------
  107.   # Arrow Settings:
  108.   #-----------------------------------------------------------------------------
  109.   # You can setup the icons used for displaying the arrows here as well as their
  110.   # positions.
  111.   # These icons will serve as the indicators which will show whether the player
  112.   # can scroll more in a direction or not.
  113.   # If there are no more options to the left, the left icon will disappear, and
  114.   # if there are no more options to the right, the right icon will disappear.
  115.   # In any other cases, both of the icons will be displayed.
  116.   #-----------------------------------------------------------------------------
  117.   Arrow_Setup = { # <-- No touchy-touchy!
  118.     :left => {
  119.       :icon_id => 543,
  120.       :x_pos => 318,
  121.     },
  122.     :right => {
  123.       :icon_id => 542,
  124.       :x_pos => 582,
  125.     },
  126.   } # <-- No touchy-touchy!
  127.  
  128.   #-----------------------------------------------------------------------------
  129.   # Color Preview Settings:
  130.   #-----------------------------------------------------------------------------
  131.   # If you set this to true, the text color for the color change option for the
  132.   # timer window will be colored with the same color like the setup, effectively
  133.   # making this as a color preview function.
  134.   # If you disable it, the color will remain normal and won't change ever.
  135.   #-----------------------------------------------------------------------------
  136.   Color_Change = true
  137.  
  138.   #-----------------------------------------------------------------------------
  139.   # Vocab Settings:
  140.   #-----------------------------------------------------------------------------
  141.   # These are various texts used for the position settings in the options menu.
  142.   # :name = Text used for the name of the setting.
  143.   # :description = Text used in the help window.
  144.   # You can use message codes in the description texts!
  145.   #-----------------------------------------------------------------------------
  146.   Options_Vocab = { # <-- No touchy-touchy!
  147.     :position => {
  148.       :name => "Timer Position",
  149.       :description => "Sets the position of the timer display on the map.",
  150.     },
  151.     :windowskin => {
  152.       :name => "Timer Window",
  153.       :description => "Sets the windowskin of the timer display on the map.",
  154.     },
  155.     :background => {
  156.       :name => "Timer Background",
  157.       :description => "Sets the background of the timer display on the map.",
  158.     },
  159.     :color => {
  160.       :name => "Timer Color",
  161.       :description => "Sets the color of the text for the timer display.",
  162.     },
  163.   } # <-- No touchy-touchy!
  164.    
  165.   #-----------------------------------------------------------------------------
  166.   # Position Options:
  167.   #-----------------------------------------------------------------------------
  168.   # Setup the positions of the timer window for the position options here.
  169.   # These settings will be paired with the settings below (Position_Names).
  170.   # So, if the player selects the first option on the list, the position of the
  171.   # timer window will be the first position setup in this settings.
  172.   # You can add as many setups as you want!
  173.   #-----------------------------------------------------------------------------
  174.   Position_Setup = { # <-- No touchy-touchy!
  175.     0 => [0,0],
  176.     1 => [[-Window_Setup_Map[:size][0]],0],
  177.     2 => [0,[-Window_Setup_Map[:size][1]]],
  178.     3 => [[-Window_Setup_Map[:size][0]],[-Window_Setup_Map[:size][1]]],
  179.     4 => [:center,0],
  180.     5 => [:center,[-Window_Setup_Map[:size][1]]],
  181.   } # <-- No touchy-touchy!
  182.  
  183.   #-----------------------------------------------------------------------------
  184.   # Position Name Options:
  185.   #-----------------------------------------------------------------------------
  186.   # The display names for each position setup option.
  187.   # Must have the same amount of names set up like the amount of positions
  188.   # set up in the above settings.
  189.   #-----------------------------------------------------------------------------
  190.   Position_Names = { # <-- No touchy-touchy!
  191.     0 => "Top Left",
  192.     1 => "Top Right",
  193.     2 => "Bottom Left",
  194.     3 => "Bottom Right",
  195.     4 => "Top Center",
  196.     5 => "Bottom Center",
  197.   } # <-- No touchy-touchy!
  198.  
  199.   #-----------------------------------------------------------------------------
  200.   # Color Options:
  201.   #-----------------------------------------------------------------------------
  202.   # Setup the color options of the text for the timer window here.
  203.   # This operates the same way like the position option setup above.
  204.   # Two ways to setup the colors:
  205.   # 1. Use an integer number and the color will be drawn directly from your
  206.   #    windowskin used for the timer window! The number you enter this way means
  207.   #    the ID of the color from the windowskin's color palette.
  208.   # 2. Use an array of 4 numbers and the color will be defined using an RGBA code.
  209.   #    This means your windowskin won't affect this color at all.
  210.   #    Valid values for the numbers in the array range from 0 to 255!
  211.   #    Format: [Red,Green,Blue,Alpha]
  212.   #    Alpha is the opacity value, 0 means fully transparent!
  213.   # You can add as many color options as you want!
  214.   #-----------------------------------------------------------------------------
  215.   Color_Setup = { # <-- No touchy-touchy!
  216.     0 => 17,
  217.     1 => 1,
  218.     2 => 3,
  219.     3 => 0,
  220.     4 => [200,100,255,255],
  221.     5 => [255,200,100,255],
  222.     6 => [100,255,200,255],
  223.   } # <-- No touchy-touchy!
  224.  
  225.   #-----------------------------------------------------------------------------
  226.   # Color Name Options:
  227.   #-----------------------------------------------------------------------------
  228.   # The name of each color options.
  229.   # Must have the same amount of color names setup here like the amount of
  230.   # color setup in the above settings!
  231.   #-----------------------------------------------------------------------------
  232.   Color_Names = { # <-- No touchy-touchy!
  233.     0 => "Yellow",
  234.     1 => "Blue",
  235.     2 => "Green",
  236.     3 => "White",
  237.     4 => "Purple",
  238.     5 => "Orange",
  239.     6 => "Emerald",
  240.   } # <-- No touchy-touchy!
  241.  
  242.   #-----------------------------------------------------------------------------
  243.   # Windowskin Options:
  244.   #-----------------------------------------------------------------------------
  245.   # This controls the windowskin options for the timer window.
  246.   # Add as many as you want following the same format.
  247.   # The name of the file will be displayed for each option!
  248.   # Any windowskin used must be in /Graphics/System/ folder!
  249.   #-----------------------------------------------------------------------------
  250.   Windowskin_Setup = { # <-- No touchy-touchy!
  251.     0 => "Window",
  252.     1 => "MySkin1",
  253.     2 => "MySkin2",
  254.     3 => "MySkin3",
  255.   } # <-- No touchy-touchy!
  256.  
  257.   #-----------------------------------------------------------------------------
  258.   # Background Options:
  259.   #-----------------------------------------------------------------------------
  260.   # This controls the background options for the timer window.
  261.   # Add as many as you want following the same format.
  262.   # The name of the file will be displayed for each option!
  263.   # Any background used must be in /Graphics/Picture/ folder!
  264.   #-----------------------------------------------------------------------------
  265.   Background_Setup = { # <-- No touchy-touchy!
  266.     0 => "timerbackv1",
  267.     1 => "timerbackv2",
  268.     2 => "timerbackv3",
  269.     3 => "timerbackv4",
  270.   } # <-- No touchy-touchy!
  271.  
  272. end # <-- No touchy-touchy!
  273. #===============================================================================
  274. # End of Settings! Editing anything below may lead to... You know what, right?
  275. #===============================================================================
  276.  
  277. class Window_SystemOptions < Window_Command
  278.    
  279.   alias add_new_commands0018 process_custom_switch
  280.   def process_custom_switch(sym)
  281.     case sym
  282.     when :timer_pos
  283.       add_command(Sixth_RTime_HUD::Options_Vocab[:position][:name], sym)
  284.       @help_descriptions[sym] = Sixth_RTime_HUD::Options_Vocab[:position][:description]
  285.     when :timer_skin
  286.       add_command(Sixth_RTime_HUD::Options_Vocab[:windowskin][:name], sym)
  287.       @help_descriptions[sym] = Sixth_RTime_HUD::Options_Vocab[:windowskin][:description]
  288.     when :timer_back
  289.       add_command(Sixth_RTime_HUD::Options_Vocab[:background][:name], sym)
  290.       @help_descriptions[sym] = Sixth_RTime_HUD::Options_Vocab[:background][:description]
  291.     when :timer_color
  292.       add_command(Sixth_RTime_HUD::Options_Vocab[:color][:name], sym)
  293.       @help_descriptions[sym] = Sixth_RTime_HUD::Options_Vocab[:color][:description]
  294.     else
  295.       add_new_commands0018(sym)
  296.     end
  297.   end
  298.    
  299.   alias sixth_rtime_opt2223 draw_item
  300.   def draw_item(index)
  301.     rect = item_rect(index)
  302.     contents.clear_rect(rect)
  303.     sixth_rtime_opt2223(index)
  304.     case @list[index][:symbol]
  305.     when :timer_pos;   draw_timer_opt(rect,index,:pos)
  306.     when :timer_skin;  draw_timer_opt(rect,index,:skin)
  307.     when :timer_back;  draw_timer_opt(rect,index,:back)
  308.     when :timer_color; draw_timer_opt(rect,index,:color)
  309.     end
  310.   end
  311.  
  312.   def draw_timer_opt(rect,index,type)
  313.     case type
  314.     when :pos
  315.       cur_pos = Sixth_RTime_HUD::Position_Setup.index($game_system.rtime_pos)
  316.       max = Sixth_RTime_HUD::Position_Setup.length-1
  317.       txt = Sixth_RTime_HUD::Position_Names[cur_pos]
  318.     when :skin
  319.       cur_pos = Sixth_RTime_HUD::Windowskin_Setup.index($game_system.rtime_skin)
  320.       max = Sixth_RTime_HUD::Windowskin_Setup.length-1
  321.       txt = Sixth_RTime_HUD::Windowskin_Setup[cur_pos]
  322.     when :back
  323.       cur_pos = Sixth_RTime_HUD::Background_Setup.index($game_system.rtime_back)
  324.       max = Sixth_RTime_HUD::Background_Setup.length-1
  325.       txt = Sixth_RTime_HUD::Background_Setup[cur_pos]
  326.     when :color
  327.       cur_pos = Sixth_RTime_HUD::Color_Setup.index($game_system.rtime_color)
  328.       max = Sixth_RTime_HUD::Color_Setup.length-1
  329.       txt = Sixth_RTime_HUD::Color_Names[cur_pos]
  330.     end
  331.     name = @list[index][:name]
  332.     dx = contents.width/2
  333.     draw_text(0, rect.y, dx, line_height, name, 1)
  334.     lic = Sixth_RTime_HUD::Arrow_Setup[:left][:icon_id]
  335.     ric = Sixth_RTime_HUD::Arrow_Setup[:right][:icon_id]
  336.     lip = Sixth_RTime_HUD::Arrow_Setup[:left][:x_pos]
  337.     rip = Sixth_RTime_HUD::Arrow_Setup[:right][:x_pos]
  338.     if cur_pos == 0
  339.       draw_icon(ric,rip,rect.y)
  340.     elsif cur_pos >= max
  341.       draw_icon(lic,lip,rect.y)
  342.     else
  343.       draw_icon(ric,rip,rect.y)
  344.       draw_icon(lic,lip,rect.y)
  345.     end
  346.     if Sixth_RTime_HUD::Color_Change == true && type == :color
  347.       change_color(get_color_sixth(Sixth_RTime_HUD::Color_Setup[cur_pos]))
  348.     end
  349.     draw_text(dx, rect.y, dx, line_height, txt, 1)
  350.   end
  351.  
  352.   alias sixth_rtime_opt1224 cursor_change
  353.   def cursor_change(direction)
  354.     sixth_rtime_opt1224(direction)
  355.     case current_symbol
  356.     when :timer_pos;   change_timer_pos(direction,:pos)
  357.     when :timer_skin;  change_timer_pos(direction,:skin)
  358.     when :timer_back;  change_timer_pos(direction,:back)
  359.     when :timer_color; change_timer_pos(direction,:color)
  360.     end
  361.   end
  362.  
  363.   def change_timer_pos(direction,type)
  364.     case type
  365.     when :pos
  366.       cur_pos = Sixth_RTime_HUD::Position_Setup.index($game_system.rtime_pos)
  367.       maxx = Sixth_RTime_HUD::Position_Setup.length-1
  368.     when :skin
  369.       cur_pos = Sixth_RTime_HUD::Windowskin_Setup.index($game_system.rtime_skin)
  370.       maxx = Sixth_RTime_HUD::Windowskin_Setup.length-1
  371.     when :back
  372.       cur_pos = Sixth_RTime_HUD::Background_Setup.index($game_system.rtime_back)
  373.       maxx = Sixth_RTime_HUD::Background_Setup.length-1
  374.     when :color
  375.       cur_pos = Sixth_RTime_HUD::Color_Setup.index($game_system.rtime_color)
  376.       maxx = Sixth_RTime_HUD::Color_Setup.length-1
  377.     end
  378.     value = direction == :left ? cur_pos-1 : cur_pos+1
  379.     value = [[value,0].max,maxx].min
  380.     Sound.play_cursor if value != cur_pos
  381.     case type
  382.     when :pos
  383.       $game_system.rtime_pos = Sixth_RTime_HUD::Position_Setup[value]
  384.     when :skin
  385.       $game_system.rtime_skin = Sixth_RTime_HUD::Windowskin_Setup[value]
  386.     when :back
  387.       $game_system.rtime_back = Sixth_RTime_HUD::Background_Setup[value]
  388.     when :color
  389.       $game_system.rtime_color = Sixth_RTime_HUD::Color_Setup[value]
  390.     end
  391.     draw_item(index)
  392.   end
  393.  
  394. end
  395. #==============================================================================
  396. # !!END OF SCRIPT - OHH, NOES!!
  397. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement