TheoAllen

Theo - Custom Title Command

Aug 28th, 2013
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.86 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Custom Title Command
  3. # Version : 1.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_CustomTitle] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2013.08.23 - Finished script
  12. # =============================================================================
  13. =begin
  14.  
  15.   Perkenalan :
  16.   Script ini ngebikin kamu bisa ngebikin command dalam title screen pake
  17.   gambar (bukan window)
  18.  
  19.   Cara penggunaan :
  20.   Pasang dibawah material namun diatas main
  21.   Edit konfignya.
  22.  
  23.   Terms of use :
  24.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  25.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  26.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.  
  27.  
  28.   Note :
  29.   Script ini kemungkinan besar ngga kompet ama segala yg ngerubah title command
  30.   atau kontrol input dalam title screen (misalnya press start)
  31.  
  32. =end
  33. # =============================================================================
  34. # Konfigurasi :
  35. # =============================================================================
  36. module THEO
  37.   module Title
  38.     # ------------------------------------------------------------------------
  39.     # Grafis untuk command harus ada di Graphics/system
  40.     # ------------------------------------------------------------------------
  41.     module Start  # Untuk start
  42.       Unselect  = "new"
  43.       Select    = "new_selected"
  44.       Position  = [150,250] # posisi [x,y]
  45.     end
  46.    
  47.     module Continue # Untuk continue / load
  48.       Unselect  = "continue"
  49.       Select    = "continue_selected"
  50.       Position  = [150,300] # posisi [x,y]
  51.     end
  52.    
  53.     module Exit # Untuk exit / shutdown
  54.       Unselect  = "exit"
  55.       Select    = "exit_selected"
  56.       Position  = [150,350] # posisi [x,y]
  57.     end
  58.    
  59.   end
  60. end
  61. # =============================================================================
  62. # Akhir dari konfigurasi :
  63. # =============================================================================
  64. class TitleCommandset
  65.   attr_reader :commands
  66.  
  67.   include THEO::Title
  68.  
  69.   def initialize(viewport)
  70.     @index = 0
  71.     @viewport = viewport
  72.     @active = true
  73.     make_spriteset
  74.     update_selection
  75.   end
  76.  
  77.   def make_spriteset
  78.     @commands = []
  79.     @commands.push(TitleCommand.new(Start,@viewport))
  80.     @commands.push(TitleCommand.new(Continue,@viewport))
  81.     @commands.push(TitleCommand.new(Exit,@viewport))
  82.   end
  83.  
  84.   def update
  85.     return unless @active
  86.     update_index
  87.     update_scene if Input.trigger?(:C)
  88.   end
  89.  
  90.   def update_selection
  91.     @commands.each {|cmd| cmd.unselect}
  92.     @commands[@index].select
  93.   end
  94.  
  95.   def update_index
  96.     if Input.repeat?(:UP)
  97.       Sound.play_cursor
  98.       @index -= 1
  99.       wrap_index
  100.       update_selection
  101.     elsif Input.repeat?(:DOWN)
  102.       Sound.play_cursor
  103.       @index += 1
  104.       wrap_index
  105.       update_selection
  106.     end
  107.   end
  108.  
  109.   def wrap_index
  110.     @index = 0 if @index > max_index
  111.     @index = max_index if @index < 0
  112.   end
  113.  
  114.   def max_index
  115.     return 2
  116.   end
  117.  
  118.   def update_scene
  119.     @active = @commands[@index].call
  120.   end
  121.  
  122.   def dispose
  123.     @commands.each {|cmd| cmd.dispose}
  124.   end
  125.  
  126. end
  127.  
  128. class TitleCommand < Sprite
  129.  
  130.   def initialize(mod,viewport)
  131.     super(viewport)
  132.     @mod = mod
  133.     self.z = 200    
  134.     update_pos
  135.   end
  136.  
  137.   def set_handler(method, enable = true)
  138.     @handler = method
  139.     @enable = enable
  140.   end
  141.  
  142.   def unselect
  143.     self.bitmap = Cache.system(@mod::Unselect)
  144.   end
  145.  
  146.   def select
  147.     self.bitmap = Cache.system(@mod::Select)
  148.   end
  149.  
  150.   def update_pos
  151.     self.x = @mod::Position[0]
  152.     self.y = @mod::Position[1]
  153.   end
  154.  
  155.   def call
  156.     if @enable
  157.       Sound.play_ok
  158.       @handler.call
  159.       return false
  160.     else
  161.       Sound.play_buzzer
  162.       return true
  163.     end
  164.   end
  165.  
  166. end
  167.  
  168. class Scene_Title < Scene_Base
  169.  
  170.   def create_command_window
  171.     @sprites = TitleCommandset.new(@viewport)
  172.     @sprites.commands[0].set_handler(method(:command_new_game))
  173.     @sprites.commands[1].set_handler(method(:command_continue),load_enable?)
  174.     @sprites.commands[2].set_handler(method(:command_shutdown))
  175.   end
  176.  
  177.   def load_enable?
  178.     DataManager.save_file_exists?
  179.   end
  180.  
  181.   def close_command_window
  182.   end
  183.  
  184.   alias theo_custom_title_update update
  185.   def update
  186.     theo_custom_title_update
  187.     @sprites.update
  188.   end
  189.  
  190.   alias theo_custom_title_term terminate
  191.   def terminate
  192.     theo_custom_title_term
  193.     @sprites.dispose
  194.   end
  195.  
  196. end
Advertisement
Add Comment
Please, Sign In to add comment