³ò
šõÜNc           @   s‘   d  Z  d d k l Z d d k Z d d k l Z d d k l Z d d k l Z e e	 ƒ i
 Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d S(   sj   
$Rev: 575 $
$LastChangedBy: satoon101 $
$LastChangedDate: 2011-10-25 02:24:08 -0400 (Tue, 25 Oct 2011) $
iÿÿÿÿ(   t   pathN(   t   Popup_popup(   t   getUseridList(   t
   langstringt   MenuManagerc           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s"   
    Class for managing menus
    c         O   s9   d |  i  j o" t i |  ƒ |  _ h  |  i _ n |  i S(   Nt	   _gg_menus(   t   __dict__t   objectt   __new__R   t
   __loaded__(   t   clst   pt   k(    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyR   &   s    c         C   sA   t  i d t d ƒ ƒ x$ t i d ƒ D] } |  i | ƒ q& Wd  S(   Ni    t   Load_Commandss	   *_menu.py(   t   est   dbgmsgR   t   menu_foldert   filest   _load(   t   selft	   file_path(    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyt
   load_menus-   s     c         C   s~   | i  } | |  i j o t d | ƒ ‚ n | i ƒ  p t d | ƒ ‚ n |  i | ƒ } | |  i | <|  i | d ƒ d  S(   Ns#   GunGame menu "%s" is already loadeds   "%s" is not a valid menu name.t   load(   t   namebaseR	   t	   NameErrort   isfilet   get_menu_by_namet
   call_block(   R   R   t   namet   menuInstance(    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyR   2   s    	c         C   s+   x$ |  i  i ƒ  D] } |  i | ƒ q Wd  S(   N(   R	   t   keyst   _unload(   R   R   (    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyt   unload_menus>   s     c         C   s-   |  i  | ƒ } |  i | d ƒ |  i | =d  S(   Nt   unload(   R   R   R	   (   R   R   t   menu_instance(    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyR   B   s    c         C   s²   | |  i  j o t d | ƒ ‚ n‹ t | ƒ i ƒ  o& |  i | ƒ } |  i | d | ƒ nR t | ƒ i d ƒ o+ x8 t | ƒ D] } |  i | | ƒ q€ Wn t	 d | ƒ ‚ d  S(   Ns   "%s" is not a loaded menu name.t	   send_menut   #s!   "%s" is not a value filter/userid(
   R	   R   t   strt   isdigitR   R   t
   startswithR   t   sendt
   ValueError(   R   R   t   filter_typeR"   t   userid(    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyR(   G   s     c         C   sO   | |  i  j o |  i  | Sn t d | t ƒ  t ƒ  d g ƒ } t | ƒ | S(   s8   
        Returns the module of an addon by name
        s   gungame51.core.menus.%st    (   R	   t
   __import__t   globalst   localst   reload(   R   R   t
   loadedMenu(    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyR   V   s    

c         O   s@   | i  } | | j o& t | | ƒ o | | | | Ž  n d S(   s%    Calls a block in a loaded sub-addon N(   R   t   callable(   R   R"   t	   blocknamet   at   kwt   menu_globals(    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyR   f   s    	(   t   __name__t
   __module__t   __doc__R   R   R   R    R   R(   R   R   (    (    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyR   "   s   							t   OrderedMenuc           B   s2   e  Z d  Z g  d d d „ Z d „  Z d „  Z RS(   s—  
    Creates an ordered menu with continuous numbering throughout pages.
    This class only creates single page popups, for the page the player has
      requested. This way, it only makes a popup for requested pages. It stores
      all of the data for the menu in the list "items".

    Note: highlightIndex will highlight the item at it's number in the menu.
            Menu numbering starts at 1.
    i
   c         C   sf   | |  _  | |  _ | |  _ | |  _ | |  _ t | ƒ | t | ƒ | d j o d n d |  _ d  S(   Ni    i   (   R+   t   titlet   itemst   optionst   highlightIndext   lent
   totalPages(   R   R+   R;   R<   R=   R>   (    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyt   __init__w   s    					c         C   sÉ  | d j  o
 d } n | |  i  j o |  i  } n t d | ƒ } | d |  i } | i d |  i d | |  i  f ƒ | i d ƒ xŽ t | | |  i ƒ D]v } | t |  i ƒ j o | i d ƒ qœ n | d |  i j o d n d } | i d	 | | d |  i | f ƒ qœ W| i d ƒ | d j o | i d
 ƒ n | i d ƒ | |  i  j  o | i d ƒ n | i d ƒ | i d ƒ |  i	 | _	 | i
 d d ƒ | i
 d d ƒ | i |  i ƒ d  S(   Ni   s   OrderedMenu_p%ss   %s%s(%s/%s)t    i   s   -----------------------------s   ->R,   s   %s%s. %ss	   ->8. Backs	   ->9. Nexts   0. Exitt   viewi   R(   s        (   R@   R   R=   t   addlineR;   t   xrangeR?   R<   R>   t
   menuselectt   timeoutR(   R+   (   R   t   paget   popupt
   startIndext   indext	   highlight(    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyt	   send_page   s:    
 !c         C   sŽ   t  | i d d ƒ ƒ } | d j o d  Sn^ | d j o | d } |  i | ƒ n6 | d j o | d } |  i | ƒ n |  i | ƒ d  S(   Nt   OrderedMenu_pR,   i
   i   i   i	   (   t   intt   replaceRM   (   R   R+   t   choicet	   popupNamet   currentPaget   newPage(    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyRF   ¸   s    

N(   R7   R8   R9   t   NoneRA   RM   RF   (    (    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pyR:   m   s
   			7(   R9   R    R   t   popuplibR   t	   playerlibR   t"   gungame51.core.messaging.shortcutsR   t   __file__t   parentR   R   R   R:   (    (    (    sW   /home/saberrider/srcds/css/cstrike/addons/eventscripts/gungame51/core/menus/__init__.pys   <module>   s   K