Guest User

Untitled

a guest
Aug 25th, 2013
9
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # ** Window_ChangeClass
  3. #------------------------------------------------------------------------------
  4. #  Change dem classes!
  5. #==============================================================================
  6.  
  7. class Window_ChangeClass < Window_Command
  8.   #--------------------------------------------------------------------------
  9.   # * Public Instance Variables
  10.   #--------------------------------------------------------------------------
  11.   attr_reader   :lightupnum            
  12.   #--------------------------------------------------------------------------
  13.   # * Initialize Command Selection Position (Class Method)
  14.   #--------------------------------------------------------------------------
  15.   def self.init_command_position
  16.     @@last_command_symbol = nil
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # * Object Initialization
  20.   #--------------------------------------------------------------------------
  21.   def initialize(x, y, actor)
  22.     @list = []
  23.     @actor=actor
  24.     @targclass = 0
  25.     super(x, y)
  26.     #initialise_specialBG
  27.     printf "actor is %s\n",actor.name
  28.     #create_sprites
  29.     activate
  30.     select_current
  31.     refresh
  32.   end
  33.  
  34.   #--------------------------------------------------------------------------
  35.   # * create class list
  36.   #--------------------------------------------------------------------------
  37.   # I know! It's a monster!
  38.   # generates three arrays that record the command data (@list)
  39.   # image names I'll need for later (currently unused) and @occupied classes
  40.   # as far as I can tell all this is now completely WAI
  41.  
  42.   def make_command_list
  43.     @list = []
  44.     @classimages = []
  45.     @occupied = []
  46.     @actor.classes.each do |entry|
  47.       if $game_variables[entry+20] > 0
  48.         n=0
  49.         pushit = -1
  50.         while n<$game_party.members.size
  51.           order = [0,1,2] if n==0
  52.           order = [-1,0,1] if n==1
  53.           order = [-2,-1,0] if n==2
  54.           order.each do |i|
  55.             if entry == ($game_party.members[n].class_id+i) and $game_party.members[n].class_id > 1 and $game_party.members[n].class_id < 29
  56.               pushit = n
  57.               #printf "IDs match: entry = %d, class_id = %d, n = %d, i = %d\n",entry,$game_party.members[n].class_id,n,i
  58.             elsif pushit == -1
  59.               #printf "no  match: entry = %d, class_id = %d, n = %d, i = %d\n",entry,$game_party.members[n].class_id,n,i
  60.             end
  61.           end
  62.           n += 1
  63.         end
  64.         @occupied.push(pushit)
  65.         printf "pushing %d for %d\n",@occupied.last,entry
  66.         #printf "%d found\n",entry
  67.         add_command($data_classes[entry].name,   :on_ok, @occupied.last, entry)
  68.        
  69.        
  70.         $data_classes[entry].note.split( /\n */ ).each do |line|
  71.           #printf "Class Notes: %s\n",line
  72.           bits=line.split( /= */ )
  73.           case
  74.           when bits[0]=="face"
  75.             @classimages.push(bits[1].chomp)
  76.            
  77.           when bits[0]=="facenum"
  78.             bobs=bits[1].split(",")
  79.             if @actor.index == (bobs[0].to_i - 1)
  80.               @classimages.push(bobs[1].chomp)
  81.             end
  82.           end
  83.         end
  84.       end
  85.  
  86.     end
  87.   end
  88.  
  89.   def am_i_class?(index)
  90.     true
  91.   end
  92.  
  93.   #--------------------------------------------------------------------------
  94.   # * create sprites
  95.   #--------------------------------------------------------------------------
  96.   def create_sprites
  97.     @images = []
  98.     n=0
  99.     while n<@classes.length
  100.       @images[n] = Sprite_MenuBack.new(n*10,n*10,@classimages[n],255,"Front")
  101.       n += 1
  102.     end
  103.    
  104.   end
  105.  
  106.   def am_i_char?(index)
  107.     false
  108.   end
  109.  
  110.   #--------------------------------------------------------------------------
  111.   # * Get Window Width
  112.   #--------------------------------------------------------------------------
  113.   def window_width
  114.     Graphics.width
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # * Get Window Height
  118.   #--------------------------------------------------------------------------
  119.   def window_height
  120.     Graphics.height
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # * Get Number of Items
  124.   #--------------------------------------------------------------------------
  125.   def item_max
  126.     @list.length
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # * Get Item Height
  130.   #--------------------------------------------------------------------------
  131.   def item_height
  132.     line_height
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * Draw Item
  136.   #--------------------------------------------------------------------------
  137.   #def draw_item(index)
  138.     #just using the default window_command one for now
  139.   #end
  140.  
  141.   #--------------------------------------------------------------------------
  142.   # * Processing When OK Button Is Pressed
  143.   #--------------------------------------------------------------------------
  144.   def process_ok
  145.     @targclass = current_data[:ext]
  146.     super
  147.     make_command_list
  148.     refresh
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # * Restore Previous Selection Position
  152.   #--------------------------------------------------------------------------
  153.   def select_current
  154.     select(0)
  155.   end
  156.  
  157.  
  158.   def draw_sprites
  159.     n=0
  160.     @images[@lightupnum].update
  161.     @images[@lightupnum].blt_to_target(@backgroundimg)
  162.     while n<@images.size do
  163.       if n != @lightupnum
  164.         @images[n].update
  165.         @images[n].blt_to_target(@backgroundimg)
  166.       end
  167.       n +=1
  168.     end
  169.   end
  170.  
  171.   def targclass?
  172.     @targclass
  173.   end
  174.  
  175.   def occupied?
  176.     @occupied[index]
  177.   end
  178.  
  179.  
  180. end
RAW Paste Data