³ò
t™Oc           @   sµ   d  Z  d d k Z d d k l Z d d k l Z d d k l Z d d k l Z d d k	 l
 Z
 d d k l Z d d	 k l Z d d
 k l Z d e f d „  ƒ  YZ e ƒ  Z d S(   sj   
$Rev: 612 $
$LastChangedBy: satoon101 $
$LastChangedDate: 2012-01-17 15:53:11 -0500 (Tue, 17 Jan 2012) $
iÿÿÿÿN(   t   delayed(   t   gungame_info(   t   AddonConflicts(   t   ConflictError(   t   DependentAddons(   t   AddonInstances(   t   LoadedAddons(   t   AddonManagert   _AddonQueuec           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s7   Class used to hold a queue of addons to load and unloadc         C   s   |  i  | ƒ S(   s3   Redirects to __getitem__ since this is a dictionary(   t   __getitem__(   t   selft   attr(    (    sU   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/addons/queue.pyt   __getattr__#   s    c         C   sa   | |  j o t  t |  ƒ i | ƒ Sn | d j o t d | d ƒ ‚ n t ƒ  } |  | <| S(   s+   Returns a set of addons in the wanted queuet   loadt   unloads   "%s" s!   is not a valid key for AddonQueue(   s   loads   unload(   t   superR   R	   t   KeyErrort   set(   R
   t
   queue_typet   value(    (    sU   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/addons/queue.pyR	   )   s    
c         C   s   t  d ƒ |  i ƒ  d S(   s)   Updates GunGame info and clears the queuet   updateN(   R   t   clear(   R
   (    (    sU   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/addons/queue.pyt   _finish?   s    
c         C   s0   |  p t  d |  i ƒ n |  | i | ƒ d S(   s)   Adds an addon to the load or unload queuei    N(   R    t   _loop_through_queuet   add(   R
   R   t   addon(    (    sU   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/addons/queue.pyt   add_to_queueH   s    c         C   sD   d |  j o |  i  ƒ  n d |  j o |  i ƒ  n |  i ƒ  d S(   s&   Unload and load addons from the queuesR   R   N(   t   _unload_addonst   _load_addonsR   (   R
   (    (    sU   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/addons/queue.pyR   T   s
    c         C   s(   x! |  i  D] } t ƒ  i | ƒ q
 Wd S(   s&   Unloads all addons in the unload queueN(   R   R   t   _unload_addon(   R
   R   (    (    sU   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/addons/queue.pyR   f   s    
 c         C   s  h  |  _  x |  i D] } |  i | ƒ q WyÓ xÌ |  i  D]Á } | t j o3 t d | d d d i t t | ƒ ƒ ƒ ‚ n xx |  i  | i i D]c } | t	 j o  t d | d | d ƒ ‚ n | |  i  j o  t d | d | d ƒ ‚ q‘ q‘ Wq7 WWn8 x! |  i D] } t
 i | d	 ƒ qW|  i ƒ  ‚  n XxB |  i D]7 } | t j o t t | _ qBn t ƒ  i | ƒ qBWd
 S(   s-   Attempts to load all addons in the load queues!   Sub-addon "%s" can not be loaded.s/     It is listed as a conflict with Sub-addon(s) s   "%s"s   ", "s     Sub-addon "%s" s&   is loaded and is listed as a conflict.s     Sub-addon "%s" is set s0   to be loaded as well and is listed as a conflicti    N(   t   _current_instancesR   t   _add_addon_instanceR   R   t   joint   listt   infot	   conflictsR   t   est
   forcevalueR   R   t   Truet   remain_loadedR   t   _load_addon(   R
   R   t   conflict(    (    sU   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/addons/queue.pyR   o   sB    	
 
 % 
 

 c         C   sX   | |  i  j o d Sn t | |  i  | <x( |  i  | i i D] } |  i | ƒ q= Wd S(   s<   Method used to store all addon instances that will be loadedN(   R   R   R"   t   requiresR   (   R
   R   t   required_addon(    (    sU   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/addons/queue.pyR   ¿   s     (   t   __name__t
   __module__t   __doc__R   R	   R   R   R   R   R   R   (    (    (    sU   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/addons/queue.pyR       s   									P(   R.   R$   t
   gamethreadR    t   gungame51.coreR   R#   R   R   t
   dependencyR   t   instanceR   t   loadedR   t   managerR   t   dictR   t
   AddonQueue(    (    (    sU   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/addons/queue.pys   <module>   s   ²