Advertisement
Guest User

XS - Records

a guest
Apr 5th, 2012
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.46 KB | None | 0 0
  1. #==============================================================================
  2. #   XaiL System - Records
  3. #   Author: Nicke
  4. #   Created: 31/03/2012
  5. #   Edited: 03/04/2012
  6. #   Version: 1.0c
  7. #==============================================================================
  8. # Instructions
  9. # -----------------------------------------------------------------------------
  10. # To install this script, open up your script editor and copy/paste this script
  11. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  12. #
  13. # To call this scene in a menu or on the map simply use one the following codes:
  14. # SceneManager.call(Scene_Records)
  15. # SceneManager.goto(Scene_Records)
  16.  
  17. # To use this script simply use one of these methods to modify the records.
  18. # Add/delete a record.
  19. # record(id, type)
  20. # Examples:
  21. # record(1, :add)
  22. # record(2, :add)
  23. # record(2, :del)
  24. #
  25. # Use one of these methods in a conditional branch to check if they are added
  26. # or enabled. Can be useful for certain quests or other things.
  27. # record_enabled?(id)
  28. # record_added?(id)
  29. #
  30. # record_enable(id, enabled)
  31. # Examples:
  32. # record_enabled(1, false) # // Will make id 1 disabled.
  33. # record_enabled(2, true)  # // Will make id 2 enabled.
  34. #
  35. # To add all records in the list, use the following code:
  36. # record_all       # // This will add all records in R_LIST.
  37. # record_all(:del) # // To delete every added record.
  38. #
  39. ## *** Only for RPG Maker VX Ace. ***
  40. #==============================================================================
  41. ($imported ||= {})["XS-RECORD-SCENE"] = true
  42.  
  43. module XAIL
  44.   module RECORDS
  45.     #--------------------------------------------------------------------------#
  46.     # * Settings
  47.     #--------------------------------------------------------------------------#
  48.     # FONT = [ name, size, color, bold, italic, shadow ]
  49.     FONT = [["Verdana"], 20, Color.new(255,200,2), true, false, true]
  50.  
  51.     # The windowskin to use for the windows. Set to nil to disable.
  52.     # SKIN = string
  53.     SKIN = nil
  54.  
  55.     # Disable all of the icons if you don't need them.
  56.     # ICON_ENABLE = true/false
  57.     ICON_ENABLE = true
  58.  
  59.     # Records that you will be able to enable/disable/added/removed ingame.
  60.     # Also make sure you don't use the same variable twice in a record.
  61.     # The variable is there to change the value of a record.
  62.     # R_LIST[ID] = [RECORD_TEXT, VARIABLE_ID, ICON_INDEX(can be nil), ENABLED]
  63.     R_LIST = [] # Don't remove!
  64.     R_LIST[0] = ["Acquired gold", 1, 361, true]
  65.     R_LIST[1] = ["Save times", 2, 225, true]
  66.     R_LIST[2] = ["Monsters slained", 3, nil, true]
  67.     R_LIST[3] = ["Treasures found", 4, 261, true]
  68.     R_LIST[4] = ["Locations discovered", 5, 231, true]
  69.     R_LIST[5] = ["Letters received", 6, 234, true]
  70.     R_LIST[6] = ["Artifacts found", 7, 245, true]
  71.     R_LIST[7] = ["Gems", 8, 358, true]
  72.     R_LIST[8] = ["Puzzle solved", 9, nil, true]
  73.     R_LIST[9] = ["Steps walked", 10, 172, true]
  74.     R_LIST[10] = ["Deaths", 11, 1, true]
  75.     R_LIST[11] = ["Jail times", 12,280, true]
  76.     R_LIST[12] = ["Sailed", 13, nil, true]
  77.     R_LIST[13] = ["Shrines found", 14, 188, true]
  78.     R_LIST[14] = ["Orbs obtained", 15, 359, true]
  79.     R_LIST[15] = ["Test", 16, 362, true]
  80.     R_LIST[16] = ["Test2", 17, 363, true]
  81.     R_LIST[17] = ["Test3", 18, 364, true]
  82.    
  83.     # LINE_COLOR = Color.new(rgba)
  84.     LINE_COLOR = Color.new(255,255,255)
  85.  
  86.     # Transition, nil to use default.
  87.     # TRANSITION [ SPEED, TRANSITION, OPACITY ]
  88.     TRANSITION = nil
  89.  
  90.     # Background image (System folder)
  91.     # Note: You might want to decrease the opacity as well as arrange
  92.     # the windows so that you can properly see the background.
  93.     # Set to nil to use default.
  94.     BACK = nil
  95.  
  96.     # Return scene.
  97.     # Can be anything you like. Default is return to the map.
  98.     # RETURN_SCENE = Scene
  99.     RETURN_SCENE = Scene_Map
  100.  
  101.   end
  102. end
  103. # *** Don't edit below unless you know what you are doing. ***
  104. #==============================================================================#
  105. # ** Game_System
  106. #------------------------------------------------------------------------------
  107. #  Class for checking the record list.
  108. #==============================================================================#
  109. class Game_System
  110.  
  111.   attr_accessor :records
  112.  
  113.   alias xail_record_sys_initialize initialize
  114.   def initialize(*args, &block)
  115.     xail_record_sys_initialize(*args, &block)
  116.     @records = []
  117.   end
  118.  
  119. end
  120. #==============================================================================#
  121. # ** Game_Interpreter
  122. #------------------------------------------------------------------------------
  123. #  Class to modify a record.
  124. #==============================================================================#
  125. class Game_Interpreter
  126.  
  127.   def record(id, type)  
  128.     # // Method to add a record to the list.  
  129.     case type
  130.       when :add # // Add record id.
  131.       unless $game_system.records.include?(XAIL::RECORDS::R_LIST[id])
  132.         $game_system.records.push(XAIL::RECORDS::R_LIST[id])
  133.       end unless XAIL::RECORDS::R_LIST[id].nil?
  134.       when :del # // Remove record id.
  135.       unless XAIL::RECORDS::R_LIST[id].nil?
  136.         $game_system.records.delete(XAIL::RECORDS::R_LIST[id])
  137.       end
  138.     end
  139.   end
  140.  
  141.   def record_enabled?(id)
  142.     # // Method to check if record is enabled.
  143.     # (Must be added in the list or else it returns nil).
  144.     return if $game_system.records[id].nil?
  145.     return $game_system.records[id][3]
  146.   end
  147.  
  148.   def record_added?(id)
  149.     # // Method to check if record is added.
  150.     return $game_system.records[id]
  151.   end
  152.  
  153.   def record_enable(id, enabled)
  154.     # // Method to enable/disable a record.
  155.     $game_system.records[id][3] = enabled
  156.   end
  157.  
  158.   def record_all(type = :add)
  159.     # // Method to add/delete all record id's.
  160.     # This was made for convenient matters only.
  161.     id = 0
  162.     while id < XAIL::RECORDS::R_LIST.size
  163.       case type
  164.       when :add
  165.         record(id, :add)
  166.       when :del
  167.         record(id, :del)
  168.       end
  169.       id += 1
  170.     end
  171.   end
  172.  
  173. end
  174. #==============================================================================#
  175. # ** Window_Record
  176. #==============================================================================#
  177. class Window_Record < Window_Selectable
  178.  
  179.   def initialize(x, y)
  180.     # // Method to initialize the window.
  181.     super(x, y, window_width, window_height)
  182.     @records = $game_system.records
  183.     @data = []
  184.     refresh
  185.   end
  186.  
  187.   def standard_padding
  188.     # // Method to set the padding for text.
  189.     return 16
  190.   end
  191.  
  192.   def window_width
  193.     # // Method to width the window.
  194.     return Graphics.width
  195.   end
  196.  
  197.   def window_height
  198.     # // Method to height the window.
  199.     return Graphics.height
  200.   end
  201.  
  202.   def refresh
  203.     # // Method to refresh the window.
  204.     contents.clear
  205.     make_item_list
  206.     create_contents
  207.     draw_all_items
  208.   end
  209.  
  210.   def make_item_list
  211.     for r in @records
  212.       @data.push(r)
  213.     end
  214.   end
  215.  
  216.   def menu_color(color, enabled = true)
  217.      # // Method to set the color and alpha if not enabled.
  218.     contents.font.color.set(color)
  219.     contents.font.color.alpha = 150 unless enabled
  220.   end
  221.  
  222.   def draw_item(index)
  223.     r = @data[index]
  224.     # // Method to draw the record text to the window.
  225.     contents.font = Font.new(XAIL::RECORDS::FONT[0], XAIL::RECORDS::FONT[1])
  226.     menu_color(XAIL::RECORDS::FONT[2], r[3])
  227.     contents.font.bold = XAIL::RECORDS::FONT[3]
  228.     contents.font.italic = XAIL::RECORDS::FONT[4]
  229.     contents.font.shadow = XAIL::RECORDS::FONT[5]
  230.     y = index * 25
  231.     y += 10 * index/17
  232.     # // Draw Record.
  233.     draw_text(26, y - 3, window_width, 32, r[0], 0)
  234.     # // Draw Variable.
  235.     draw_text(0, y - 3, window_width - 36, 32, $game_variables[r[1]], 2)
  236.     # // Draw lines.
  237.     draw_line(0, y + 24)
  238.     # // Draw icons.
  239.     draw_icon(r[2], 0, y, r[3]) unless r[2].nil? if XAIL::RECORDS::ICON_ENABLE
  240.     reset_font_settings
  241.   end
  242.  
  243.   def draw_line(x, y)
  244.     # // Method to draw a line with a shadow.
  245.     line = Rect.new
  246.     line.height = 1
  247.     line.width = Graphics.width
  248.     line.x = x
  249.     line.y = y
  250.     contents.fill_rect(line,XAIL::RECORDS::LINE_COLOR)
  251.     line.y += 1
  252.     contents.fill_rect(line,Color.new(0,0,0,200))
  253.   end
  254.  
  255.   def item_max
  256.     # // Method to get item_max.
  257.     @data ? @data.size : 1
  258.   end
  259.  
  260.   def row_max
  261.     # // Method to get row_max.
  262.     item_max
  263.   end
  264.  
  265.   def update_cursor
  266.     # // Method to update cursor.
  267.   end
  268.  
  269. end
  270. #==============================================================================#
  271. # ** Scene_RecordBase
  272. #------------------------------------------------------------------------------
  273. #  New Scene :: Scene_RecordBase - The Record scene.
  274. #==============================================================================#
  275. class Scene_RecordBase < Scene_Base
  276.  
  277.   alias xail_record_base_start start
  278.   def start(*args, &block)
  279.     # // Method to start the scene
  280.     xail_record_base_start(*args, &block)
  281.     @records = $game_system.records
  282.     create_background
  283.   end
  284.  
  285.   alias xail_record_base_terminate terminate
  286.   def terminate(*args, &block)
  287.     # // Method to terminate the scene.
  288.     xail_record_base_terminate(*args, &block)
  289.   end
  290.  
  291.   def create_background
  292.     # // Method to create the background.
  293.     @background_sprite = Sprite.new
  294.     if XAIL::RECORDS::BACK.nil?
  295.       @background_sprite.bitmap = SceneManager.background_bitmap
  296.       @background_sprite.color.set(16, 16, 16, 128)
  297.     else
  298.       @background_sprite.bitmap = Cache.system(XAIL::RECORDS::BACK)
  299.     end
  300.   end
  301.  
  302.   alias xail_record_base_transition perform_transition
  303.   def perform_transition(*args, &block)
  304.     # // Method to create the transition.´
  305.     if XAIL::RECORDS::TRANSITION.nil?
  306.       Graphics.transition(15)
  307.     else
  308.       Graphics.transition(XAIL::RECORDS::TRANSITION[0],XAIL::RECORDS::TRANSITION[1],XAIL::RECORDS::TRANSITION[2])
  309.     end
  310.     xail_record_base_transition(*args, &block)
  311.   end
  312.  
  313.   alias xail_record_base_re_scene return_scene
  314.   def return_scene(*args, &block)
  315.     # // Return to map.
  316.     xail_record_base_re_scene(*args, &block)
  317.     SceneManager.call(XAIL::RECORDS::RETURN_SCENE)
  318.   end
  319.  
  320. end
  321. #==============================================================================#
  322. # ** Scene_Records
  323. #------------------------------------------------------------------------------
  324. #  New Scene :: Scene_Records - The Record scene.
  325. #==============================================================================#
  326. class Scene_Records < Scene_RecordBase
  327.  
  328.   alias xail_record_init initialize
  329.   def initialize(*args, &block)
  330.     # // Method to initialize record scene.
  331.     xail_record_init(*args, &block)
  332.     @records = $game_system.records
  333.   end
  334.  
  335.   alias xail_record_start start
  336.   def start(*args, &block)
  337.     # // Method to start record scene.
  338.     xail_record_start(*args, &block)
  339.     create_records
  340.   end
  341.  
  342.   def create_records
  343.     # // Method to create the record window.
  344.     @record_window = Window_Record.new(0, 0)
  345.     @record_window.windowskin = Cache.system(XAIL::RECORDS::SKIN) unless XAIL::RECORDS::SKIN.nil?
  346.   end
  347.  
  348.   def update
  349.     # // Method to update the record window.
  350.     super
  351.     if Input.trigger?(:B)
  352.       return_scene
  353.     end
  354.     if Input.trigger?(:DOWN)
  355.       @record_window.cursor_pagedown
  356.     end
  357.     if Input.trigger?(:UP)
  358.       @record_window.cursor_pageup
  359.     end
  360.   end
  361.  
  362. end # END OF FILE
  363.  
  364. #=*==========================================================================*=#
  365. # ** END OF FILE
  366. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement