
Pc           @   s  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z e i   e  i   Z	 d e	 _
 d e	 _ d e	 _ d e	 _ d e	 _ d Z d a h  e d	 f d
 <e d	 f d <e d f d <e d	 f d <e d	 f d <e d	 f d <e d f d <e d f d <Z d Z h  Z h  Z h  Z h  d d <d d <d d <d d <e d <h  d d <d d <d d <d d <e d <h  d d <d  d <d! d <d" d <e d# <h  d$ d <d% d <d& d <d' d <e d( <h  d) d <d* d <d+ d <d, d <e d- <h  Z h  d. d <d/ d0 <d1 d2 <d3 d4 <e d
 <h  d. d <d/ d0 <d5 d2 <d6 d4 <e d <h  d7 d <d8 d0 <Z h  d9 d <d: d0 <Z e e  Z d; e f d<     YZ d= e f d>     YZ  d? f  d@     YZ! dA e f dB     YZ" dC e" f dD     YZ# dE e f dF     YZ$ dG e f dH     YZ% e%   Z& dI   Z' dJ   Z( e) dK  Z* dL   Z+ dM   Z, dN   Z- e) dO dP  Z. dQ   Z/ dR   Z0 dS   Z1 dT   Z2 dU   Z3 d9 dV  Z4 d9 d9 dW  Z5 e dX  Z6 dY   Z7 dZ   Z8 d[   Z9 d\   Z: d]   Z; d^   Z< d_   Z= d`   Z> da   Z? db   Z@ dc   ZA e  iB iC e dd e@  e  iD de df  e=   e@ e)  e  iE dg d dh  di   ZF dj   ZG dk   ZH e> dl eH  e aI e iJ d0 eG  d S(m   iNs!   Popup EventScripts Python libraryt   oy30ms$   GODJonez + EventScripts release teams-   http://python.eventscripts.com/pages/Popuplibs2   Provides menu and pop-up handling for Source gamest   ent   unknowni   t   cstriket   dodi    t   hl2mpt   tft   synergyt   pvkiit   nonet   Backt   prevt   Nextt   nextt   Cancelt   quitt   Pendingt   pendingt   Retourt   Suivantt   Annulers
   En attentet   frs   Zurückt   Weiters
   Schließent	   Wechselndt   det	   Edellinent   Seuraavat   Suljet   Odottaat   fit   Tilbaket   Nestet   Avslutts   I påvente avt   not   UNt   SPECi   t   Ti   t   CTi   t   ALt   AXt   HUMANt   BOTt    t   DEADt
   Popup_basec           B   sk   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 e
 d  Z d	   Z d
   Z RS(   s   
    Popup_base class is the base of all popup types,
    do not use this class directly from anywhere except for
    checking variable type
    c         C   sp   | |  _  | |  _ d |  _ d |  _ d |  _ t |  _ d |  _ d |  _ t |  _	 d |  _
 t |  _ d |  _ d S(   sG   
        Initialize the popup by creating necessary attributes
        i    R*   t   defaultt   normalN(   t   namet	   vguititlet   timeoutsendt   timeoutviewt   prepusert   Falset   oldskooltovt   editlangt   displaymodet
   processingt   visualstylet   Truet   _cached_radio_menut
   enablekeys(   t   selft   pPopupid(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   __init__G   s    											c         C   s   t  t d } t d @o
 t } n t d @o
 t } n t d @o | Sn |  i d @o
 t } n |  i d @o
 t } n | S(   s{   
        Performs prioritized checking on whether the menu is to be displayed
        as radio menu or VGUI dialog
        i    i   i   i   (   t   gameSupportt	   gGamenamet   gameSupportAdminR4   R:   R9   (   R=   t   isradio(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   isRadioMenuW   s    



c         C   s   t  t |  } | ou | i } |  i i |  pQ |  i i t  o t Sq |  i i   } t |  d j o d Sq | d Sn | Sn d S(   s   
        INTERNAL
        Returns a usable language code from cache,
        tries to conform to the language the user itself is using
        i    N(	   t   gUserst   intt   languaget   cachet   has_keyt	   gLanguaget   keyst   lent   None(   R=   t   useridt   usert   userlangt   k(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   i_userlangh   s    	c         C   s   |  i  t t |  i  S(   s>   
        INTERNAL
        User wrapper for i_endlangg
        (   t
   i_endlanggRE   RF   RG   (   R=   RN   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt	   i_endlang|   s    c         C   s_   t  i |  pK t  i t  o t Sq[ t  i   } t |  d j o d Sq[ | d Sn | S(   s   
        INTERNAL
        Returns usable language code for constructable strings,
        tries to conform to the language passed in
        i    N(   t   langdataRI   RJ   RK   RL   RM   (   R=   RP   RQ   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRS      s    c         C   s   t  |  i  d S(   sA   
        delete this popup, calls global delete function
        N(   t   deleteR/   (   R=   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRV      s    c         C   su   | d j oN | d j o | |  _  qq | d j o | |  _ qq t d t |    n t d t |    d S(   s'   
        set send/view timeout
        i    t   sendt   views$   Popuplib: Unsupported timeout mode: s*   Popuplib: Invalid time value for timeout: N(   R1   R2   t
   ValueErrort   str(   R=   t   modet   time(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   timeout   s    c   	      C   s  t  i d d |  i t |  t |  f  y t |  } | g } Wn t j
 o n Xx>| D]6} t t |  } | p qb n t  i d d t |  d t |   |  i   ot  i d d t | i   | i oft	 o_y t  i d d  t t  i
 d   } t  i d d |  | | j oy t  i d d	  t t  i
 d
   } t  i d d |  | d j o
 t } n t t  i
 d   d j o
 t } qn Wn t t f j
 o n Xt  i d d  yG t  i d d  t  i d d  | t t  i    j o
 t } n Wn t j
 o n Xt  i d d  n d } |  i d j o | i |   } n t  i d d |  | o t  i d d  | i op t  i d d  | i | i | i <| d j o3 | o | i | =n | i d } |  | i | <n d! | _ n t } t | _ t  i d d  t i t |  n | pJ t  i d d  | d j o) | i } | i d 7_ |  | i | <qn | i p. t  i d d  t  i d d  | i   n t  i d d  |  i d j oP t  i d d | t |  f  t i |  i d |  i t | t |  f  qqb t  i d d   | i o |  | i | i <d! | _ n |  | i | i <| i   qb Wd! S("   s0   
        send this popup to users queue
        i   s$   Popuplib: send %s to %s with prio=%ss   Popuplib: send to s    with prio=s   Popuplib: user.prioritized=s   Popuplib2: trying...RN   s   Popuplib2: testuserid=%ds   Popuplib2: userid matcht   texts   Popuplib2: cevent="%s"R*   t   es_eventt   es_client_commands    Popuplib2: Done trying eventinfos   Popuplib2: trying cmduserid...t
   testuseridt   0s    Popuplib2: Done trying cmduseridi    t   stickys   Popuplib: myqueuepos = %ds   Popuplib2: prio == Trues   Popuplib2: user.active != Nones   Popuplib2: gamethread.queues   Popuplib2: prio == Falses"   Popuplib2: user.closemode == Falses   Popuplib2: user.handleQueue()s"   Popuplib2: user.closemode == TRUE!s<   Popuplib2: self.timeoutsend > 0, gamethread.delayed (%s, %s)t   _popup_s   Popuplib: Using VGUI dialogN(   t   est   dbgmsgR/   RZ   RF   t	   TypeErrorRE   RD   t   prioritizedt   _allow_event_infot   getEventInfoR:   RY   t   sett   getcmduseridR7   t   isqueuedt   activet   queuet   activeidRM   R4   t
   gamethreadt   gt_priofinisht	   nextindext	   closemodet   handleQueueR1   t   delayednamet   unsend(	   R=   t   pUserst   prioRN   RO   Ra   t   ceventt
   myqueuepost   index(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRW      s    , (

		
 4
c         C   s   y/ t  t |  } | o | i |  t  n WnO t j
 oC x> | D]1 } t  t |  } | o | i |  t  qG qG Wn Xd S(   s@   
        remove this popup from users queue and display
        N(   RE   RF   Rw   R:   Rg   (   R=   Rx   RO   RN   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRw     s     c         C   s   t  i d d t |  t t |   d  y, t t |  } | o | i |   n WnL t j
 o@ x; | D]. } t t |  } | o | i |   qr qr Wn Xd S(   s=   
        redisplay this popup if its the visible one
        i   s   Popuplib: update(t   )N(   Re   Rf   RZ   t   typeRE   RF   t   updatePopupRg   (   R=   Rx   RO   RN   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   update  s    . (   t   __name__t
   __module__t   __doc__R?   RD   RR   RT   RS   RV   R]   R4   RW   Rw   R   (    (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR,   A   s   							]	t   Popup_popupc           B   s   e  Z d  Z d   Z d   Z d d  Z d   Z d   Z d   Z	 d d  Z
 d d  Z d d	  Z d d
  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z g  d  Z d   Z d   Z d   Z RS(   s   
    Popup_popup is the normal popup class that inherits Popup_base
    by this it has automatically access to the methods and variables
    defined in Popup_base class
    c         C   s   t  i |  |  h  |  _ d |  _ d |  _ h  |  _ h  |  _ h  |  _ h  |  _ d |  _	 h  |  _
 h  |  _ d |  _ h  |  i d <d |  i |  i
 d <t |  i d <d |  _ d S(   sm   
        Initialize the popup by creating all necessary attributes
        with their default values
        R*   t   globalR-   s   Uncached %st   popupN(   R,   R?   t   linest
   menuselectt   menuselectfbt   p_selectt	   p_submenut   menuvart   menuvalt	   cachemodeRH   t   cachereR6   R/   R4   R~   (   R=   R>   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR?   !  s     											c         C   s   d |  i  S(   s    
        Representation
        s   Popup("%s")(   R/   (   R=   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   __repr__:  s    c         C   s   | p |  i  } n t |  } t i d d |  |  i i |  pb t i d d  |  i d i   |  i | <t |  i d  |  i | <t |  i	 d  |  i	 | <n d S(   sv   
        INTERNAL
        Checks if the current editlang exists and if not,
        creates structures for it
        i   s   Popuplib: checklang %ss   Popuplib:  NOT FOUND!R-   N(
   R6   RZ   Re   Rf   R   RI   t   copyRH   t   boolR   (   R=   t   langR6   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt	   checklang?  s    c         C   s  | d j o t  i d d  n t  i d |  i  | d j o t  i d d t |  i   t  i d d t t |  i    t  i d d t |  i   t  i d d t |  i   t  i d d t |  i	   n | d	 j o t  i d d
 t t |  i
    x@ |  i
 D]5 } t  i d d t |  d t |  i
 |   qWt  i d d t t |  i    xD |  i D]5 } t  i d d t |  d t |  i |   q|Wn | d j o t  i d d t t |  i    x] |  i D]N } t  i d d t |  d t |  i |  d t |  i |  d  qWn | d	 j o[ t  i d d t |  i   t  i d d t |  i   t  i d d t |  i   n | d j ou t  i d d  xb |  i D]S } t  i d d |  x6 |  i | D]' } t  i d t |  i | |   q WqWn | d j os t  i d d  x` |  i D]Q } t  i d d |  |  i | i d  } x | D] } t  i d |  qWqZWn d S(   sG   
        Output information about this popup to server console
        i   i    t    s     Type:         s     Lines:        s     Prepuser:     s     Menuselect:   s     Menuselectfb: i   s     Select:       s       [s   ]:  s     Submenu:      i   s     Menuvalue:    s   ="t   "s     Cachemode:    s     Cachere:      s     Displaymode:  s     Current content:s      Language: %si   s"     Current globally cached content:s   
N(   Re   Rf   R/   RZ   R~   RL   R   R3   R   R   R   R   R   R   R   R   R7   RH   t   split(   R=   t	   listlevelt   itemR   t   linet   cc(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   informationO  sX    #!#
 3#
 7#
 P!
  -
  c         C   s;   | d j  o t  Sn | t |  i |  j o t  Sn t S(   sV   
        INTERNAL
        checks if the line in question is valid for editing
        i   (   R4   RL   R   R:   (   R=   R   R6   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   isValidLinex  s    "c         C   s.   | d j  o t  Sn | d j o t  Sn t S(   sV   
        INTERNAL
        checks if the item in question is valid menu choice
        i   i
   (   R4   R:   (   R=   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   isValidItem  s    c         C   s   t  | t  o[ x | D]L } |  i |  t | |  |  i | t |  i |  d <t |  i | <q Wnc | p |  i } n t	 |  } |  i |  t |  |  i | t |  i |  d <t |  i | <d S(   s;   
        add a line of text to the end of the list
        i   N(
   t
   isinstancet   dictR   t
   strutfcodeR   RL   R:   R   R6   RZ   (   R=   R^   R   R6   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   addline  s     ,(c         C   s   | p |  i  } n t |  } |  i |  |  i | |  ol t |  i |  } x7 t | |  D]& } |  i | | d |  i | | <qc W|  i | | =t |  i | <n t	 d | |  i
 f   d S(   sA   
        delete a line of text and move subsequent lines
        i   s(   Popuplib: Cannot delete line #%d from %sN(   R6   RZ   R   R   RL   R   t   rangeR:   R   t
   IndexErrorR/   (   R=   R   R   R6   R   t   thisline(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   delline  s     $c         C   s  t  | t  o x| D] } |  i |  t |  i |  } | | d j p |  i | |  om x> t | d | d  D]& } |  i | | d |  i | | <qx Wt | |  |  i | | <t |  i	 | <q t
 d | |  i | f   q Wn | p |  i } n t |  } |  i |  t |  i |  } | | d j p |  i | |  oi x> t | d | d  D]& } |  i | | d |  i | | <qmWt |  |  i | | <t |  i	 | <n t
 d | |  i f   d S(   s4   
        insert a line and make room for it
        i   is5   Popuplib: Cannot insert line #%d to %s in language %ss&   Popuplib: Cannot insert line #%d to %sN(   R   R   R   RL   R   R   R   R   R:   R   R   R/   R6   RZ   (   R=   R   R^   R   R6   R   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   insline  s0     $ $$$ $c         C   s  t  | t  o} x | D]n } |  i |  |  i | |  o, t | |  |  i | | <t |  i | <q t d | |  i	 | f   q Wn | p |  i
 } n t |  } |  i |  |  i | |  o( t |  |  i | | <t |  i | <n t d | |  i	 f   d S(   s)   
        modify an existing line
        s5   Popuplib: Cannot modify line #%d in %s in language %ss&   Popuplib: Cannot modify line #%d in %sN(   R   R   R   R   R   R   R:   R   R   R/   R6   RZ   (   R=   R   R^   R   R6   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   modline  s      $c         C   s(   x! |  i  D] } |  i | |  q
 Wd  S(   N(   R   R   (   R=   R^   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   addlineAll  s    
 c         C   sB   x; |  i  D]0 } y |  i | |  Wq
 t j
 o q
 Xq
 Wd  S(   N(   R   R   R   (   R=   R   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   dellineAll  s    
 c         C   sE   x> |  i  D]3 } y |  i | | |  Wq
 t j
 o q
 Xq
 Wd  S(   N(   R   R   R   (   R=   R   R^   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   inslineAll  s    
 c         C   sE   x> |  i  D]3 } y |  i | | |  Wq
 t j
 o q
 Xq
 Wd  S(   N(   R   R   R   (   R=   R   R^   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   modlineAll  s    
 c         C   s>   |  i  |  o | |  i | <n t d | |  i f   d S(   s$   
        set a select block
        s/   Popuplib: Invalid menu item %d for select in %sN(   R   R   R   R/   (   R=   R   t   block(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   select  s    !c         C   sg   |  i  |  o: | o | |  i | <qc | |  i j o |  i | =qc n t d | |  i f   d S(   s   
        set a submenu
        s0   Popuplib: Invalid menu item %d for submenu in %sN(   R   R   R   R/   (   R=   R   t   menuname(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   submenu  s    c         C   s}   t  | t  p" t |  } t |  } | } n |  i |  o | |  i | <| |  i | <n t d | |  i f   d S(   s   
        set menuvalue
        s2   Popuplib: Invalid menu item %d for menuvalue in %sN(   R   RF   RZ   R   R   R   R   R/   (   R=   t   varnR   t   varvt   a(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt	   menuvalue  s    
c         C   s<  t  i d d t |  t t |   d  yh t |  } |  i |  } | oB |  i |  |  i | <t |  i	 | <|  i | t
 | i |  i <n Wn t j
 o g  } x | D]{ } |  i t |   } | oY | | j o' |  i |  |  i | <| i |  n |  i | t
 t |  i |  i <q q Wn Xd S(   s#   
        recache the popup
        i   s   Popuplib: recache(users=R}   N(   Re   Rf   RZ   R~   RF   RR   t	   i_recacheRH   R4   R   RE   R/   Rg   t   append(   R=   t   usersRO   RP   t   cachedlangs(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   recache  s$    .# c   	      C   s  |  i    o t i d d |  d } x. |  i | D] } | |  i | | d 7} q5 Wt |  d j o | d d !} n t i d d | d  | Snt i d d	 |  t   } d } x$|  i | D]} |  i | | } y | d
  d j o7 t t | d
 d !  } | d t t |   } n1 t t | d
    } | d t t |   } | d j  p | d j o t	 d  n | d j o
 d } n h  | d <d | d <| | <Wq t	 j
 o | | d 7} q Xq Wt |  d j o | d d !} n t |  o` t
 i d |  i d | d t
 i i  } x. | D]& } | i | | d | | d  qEW| Sn, t
 i d |  i d | d t
 i i  } | Sd S(   s=   
        INTERNAL
        do the actual construction
        i   s   Popuplib: i_recache menu (%s)R*   s   
i    is   Popuplib: i_recache returns "R   s   Popuplib: i_recache vgui (%s)i   s   ->i   i   i
   s   Only range 0..10 allowedR^   s   menuselect %dt   commandt   titlet   msgR[   N(   RD   Re   Rf   R   RL   R   RF   t   floatRZ   RY   t   msglibt
   VguiDialogR0   t   VguiModet   MENUt	   addOptiont   TEXT(	   R=   RP   t   buildR   t	   menuitemsR^   t   choiceR   t   dlg(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR   *  s\     	 
	 c      	   C   sy  t  i d d t |  t t |   d  |  i t |   } | p d Sn t  i d d |  t  i d d t |  i  t t |  i   d  t  i d d t |  i |  t t |  i |   d  |  i   } t  i d d	 |  t  i d d
 |  i	  |  i	 | j o` x$ |  i i
   D] } t |  i | <q-W|  i t | i j o t | i |  i =n | |  _	 n |  i d j o3 |  i | o% t  i d d |  |  i |  n |  i d j oK t  i d d t |  i |  d t t |  i |    |  i | Sn[ t  i d d  |  i t | i j o! t  i d d  |  i |  n t | i |  i Sd S(   sY   
        INTERNAL (semi)
        check the cache status and recache as necessary
        i   s   Popuplib: checkCache(userid=R}   s   Empty popup!s   Popuplib: userlang="%s"s   Popuplib: cachemode="R   s   Popuplib: cachere="s   Popuplib: new_radio_menu = %ss!   Popuplib: _cached_radio_menu = %sR   s5   Popuplib: Issuing recache on global popup language %sRO   s.   Popuplib: Not user-specific, returning cache="s   Popuplib: User specific popups,   Popuplib: Popup not in user cache, recachingN(   Re   Rf   RZ   R~   RR   RF   R   R   RD   R;   RK   R:   R/   RE   RH   R   (   R=   RN   RP   t   new_radio_menut   l(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   checkCachea  s8    .4< <c   	      C   s  t  i d d t |  t t |   d t |  t t |   d  t | } |  | _ t |  _ t  i d d t |  i  d t t |  i    | i } |  i d j o
 t } n t	 } t  i
 d | d	  t  i
 d
 | d  t  i
 d |  i d  | |  i j o" t  i
 |  i | |  i |  n d% } | |  i j o |  i | } | o t  i d d  t  i d d t |  d t t |    t |  o t | | | |  i d  n t  i |  t	 } qn |  i ox t  i d d t |  i  d t t |  i    t |  i  o  t |  i | | |  i d  qbt  i |  i  n | o |  i ox t  i d d t |  i  d t t |  i    t |  i  o  t |  i | | |  i d  qt  i |  i  n | |  i j o |  i | } t  i d d  t  i d d t |  d t t |    t | t  o
 | } n t |  } | o | | i | <n$ t  i d d t |  |  i f  t	 } n d% | _ t	 |  _ | oD t  i d d  t  i | d t |   t i d | i |   n t  i d d  t  i d d d |  t  i d  d d! |  i  t  i d d d" |  t  i d# d  | i |  j o' t  i d d$  d% | _ | i    n= | | i j o | i | =n | i o | i | i  n d% S(&   sB   
        handle menu choice as a result of client command
        i   s   Popuplib: popup.handleChoice (s   , R}   s   Popuplib: displaymode='t   'Rc   t   _popup_userids   User of the popupt   _popup_choices   Menu item chosent   _popup_names   Active menu names   Popuplib: Select founds   Popuplib: select block='R   s   Popuplib: menuselect='R   s   Popuplib: menuselectfb='R   s   Popuplib: Submenu founds   Popuplib: submenu='i    s0   Popuplib: Submenu "%s" for popup "%s" not found!s   Popuplib: Sending sticky keyt   slotg?t
   initializet   popup_selectt   setintRN   t	   setstringt
   popup_namet   popup_choicet   fires   Popuplib: Redoing user queueN(!   Re   Rf   RZ   R~   RE   R8   R:   R7   Rp   R4   Rk   R/   R   R   RM   R   t   callablet
   _call_funct   doblockR   R   R   R   R,   t   findRo   t   cexecRq   t   delayedR   t   eventRn   Ru   (	   R=   R   RN   RO   Rp   t   isstickyt   pselectt   psubmenut   subp(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   handleChoice  s    L
		4	
".
4 4 .

			
N(   R   R   R   R?   R   RM   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s,   			)										7	$t   Easymenu_optionc           B   s   e  Z d  Z d   Z RS(   s-   
    A helper class for easymenu options
    c         C   s.   | |  _  t |  |  _ | |  _ | |  _ d  S(   N(   t   valueR   R^   t   stateR|   (   R=   R   R^   R   R|   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR?     s    		(   R   R   R   R?   (    (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s   t   Popup_easymenuc           B   s  e  Z d  Z d   Z d   Z d d  Z d d d  Z d d  Z d   Z	 d d d  Z
 d d	  Z d d d d
  Z d   Z d d  Z g  d d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d d  Z d   Z d   Z RS(   sG   
    Popup easymenu allowing easy construction of multi-page menus
    c         C   sh  t  i |  |  h  |  _ | |  _ h  |  _ h  |  _ |  i   oB d |  i t <d |  i t <t	 | d  |  _
 d |  _ d |  _ n? d |  i t <d |  i t <t	 | d  |  _
 d |  _ d |  _ h  |  _ d |  _ d |  _ d	 |  _ d |  _ d	 |  _ | |  _ d
 |  _ h  |  _ h  |  _ d
 |  _ d |  _ d |  _ d |  _ d |  _ d |  _ h  |  _ |  i   d S(   si   
        Initialize the popup by creating necessary attributes
        with their default values
        s   %1. %2s   ->%1. %2i   s   0. %2s   (%2)s   %2i   s   -----------------------------R*   t   easymenui	   i   i   i   i   N(    R,   R?   t   optionst	   c_savevart   descriptiondt   c_stateformatRD   R4   R:   t	   _pnformatt   c_titleformatt   c_pageformatt   c_exitformatt   l_titleformatt
   c_beginsept	   c_pagesept   c_endsepRM   R   R   R   R   RH   R   R~   t   radio_options_1t   radio_optionst   vgui_options_1t   vgui_optionst   default_statet
   activepageR   (   R=   R>   t   pVart   pBlock(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR?     sD    																								c         C   s   d |  i  S(   s    
        Representation
        s   Easymenu("%s")(   R/   (   R=   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s    c         C   s   t  | t  o9 xv | D]* } |  i |  t | |  |  i | <q WnA | p |  i } n t |  } |  i |  t |  |  i | <d S(   s6   
        Set the description for the easymenu
        N(   R   R   R   RZ   R   R6   (   R=   t   descR   R6   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   setdescription"  s     i   c         C   s   t  | t  oH x | D]9 } t t | |  t |   |  i | <|  i |  q WnP | p |  i } n t |  } t t |  t |   |  i | <|  i |  d S(   s0   
        Set the title for the easymenu
        N(   R   R   R   RZ   RF   R   R   R6   (   R=   R   t   pagenumbersR   R6   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   settitle2  s     &"c         C   s  | p |  i  } n t |  } t i d d |  i | f  t i d d t |  i   |  i i |  p#t i d d  | d j oA h  |  i | <h  |  i | <h  t	 d <|  i
 | <d |  i | <q|  i d i   |  i | <h  |  i | <h  |  i
 | <x2 t |  i |   D] } t	 |  i
 | | d <qWt |  i d  |  i | <| |  i j o. d |  i j o t |  i d  |  i | <qn d S(   sc   
        INTERNAL
        Checks if the current language exists and create it as necessary
        i   s$   Popuplib: easymenu(%s).checklang(%s)s   Popuplib: c_titleformat="%s"s,   Popuplib: language not used yet, creating...R-   R*   N(   R6   RZ   Re   Rf   R/   R   R   RI   RH   R:   R   R   R   R   t   getPageCountR   (   R=   R   R6   t   pagenum(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR   D  s*      c         C   s   t  i d |  i  | d j o t  i d d t |  i   t  i d d t |  i   t  i d d t t |  i t    t  i d d t |  i	   t  i d d t |  i
   n d S(	   s>   
        Print out some information to server console
        i    i   s     Type:         s     Variable:     s     Options:      s     Menuselect:   s     Menuselectfb: N(   Re   Rf   R/   RZ   R~   R   RL   R   RJ   R   R   (   R=   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR   `  s    'c         C   s-  t  | t  pC t i d d  | p |  i } n t |  } h  | | <} n t i d d  x | D] } |  i |  t |  i |  d } | d j o |  i
 } n t | | | | |  |  i | | <t |  i | |  i t |  i |  |  <| |  i d j o t |  i | d <qj qj Wd S(   s.   
        Add a new option to the menu
        i   s+   Popuplib.py: addoption detected text objects/   Popuplib.py: addoption detected language objectN(   R   R   Re   Rf   R6   RZ   R   RL   R   RM   R   R   R:   R   t   getPageNumberR   (   R=   R   R^   R   R   R6   R|   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt	   addoptionl  s"     $*c         C   sr   | p |  i  } n t |  } |  i |  x> |  i | D]/ } |  i | | } | i | j o | Sq; q; Wd S(   s;   
        INTERNAL
        Find option by its value
        N(   R6   RZ   R   R   R   RM   (   R=   R   R   R6   t   it   opt(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   findOption  s     c   	      C   s  | p |  i  } n t |  } | d j o# |  i i   } t |  d } n | g } d } x | D] } |  i |  |  i | |  } | oR t |  i | |  i	 | i
 |  <| o t |  | _ n | o | | _ qqf | p t d | |  i f   qf | d 8} qf Wd S(   s)   
        Edit an existing option
        R-   i   i    s1   Popuplib: Option %s does not exist in easymenu %sN(   R6   RZ   R   RK   RL   R   R  R:   R   R  R|   R   R^   R   R   R/   (	   R=   R   R^   R   R   R6   t   langst   ignore_errorR  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt	   setoption  s*    	  c         C   s   t  |  i |  } |  i   o< | |  i j o d Sn t t i t |  |  i   Sn9 | |  i	 j o d Sn t t i t |  |  i
   Sd S(   s\   
        INTERNAL
        Returns the page number on which the option is present in
        i   N(   RL   R   RD   R   RF   t   matht   ceilR   R   R   R   (   R=   t   optionRG   t   opts(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR    s    $c         C   s   | p
 | } n | |  _  d S(   s1   
        set a submenu for menuselect 10
        N(   R   (   R=   R   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s    
c      	   C   s  t  i d d t |  t t |   d  y t |  } |  i |  } t  i d d t |   | of | p0 t d |  i t |  i	 |  |  d  } n |  i
 | |  |  i | t | i |  i <n Wn t j
 o g  } x | D] } |  i t |   } t  i d d t |  t |  f  | o | | j oa | p0 t d |  i t |  i	 |  |  d  } n |  i
 | |  |  i | <| i |  n |  i | t t |  i |  i <q q Wn Xd S(   s#   
        recache the popup
        i   s   Popuplib: recache(users=R}   s&   Popuplib: compatible user language: %ss)   Popuplib: compatible user %d language: %sN(   Re   Rf   RZ   R~   RF   RR   R   R  RL   R   R   RH   RE   R/   Rg   R   (   R=   R   t   pagesRO   RP   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s.    .0# &0c         C   s   | |  i  j o t |  i  |  i  | <n t i d d |  i | f  t |  i |  } |  i | |  } |  i	   o |  i
 | | | |  n |  i | | | |  d S(   s=   
        INTERNAL
        do the actual construction
        i   s#   Popuplib: %s easymenu i_recache(%s)N(   R   RZ   R   Re   Rf   R/   RL   R   R  RD   t   i_recacheRadiot   i_recacheVGUI(   R=   R  RP   t   maxindext
   totalpages(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s    c         C   s  | d j o |  i  } n
 |  i } xX| D]P} t |  i |  i d t |   } | i d t |   } |  i | o t |  i |  } n | } t i d | d | d t i i	  }	 x t
 d | d  D] }
 | d |  i |
 } | | j or |  i | | } t |  i t | i   } | i d t |
   i d t | i   } |	 i | d	 |
  q |	 i d
 d	 |
  q W| d j o= |	 i t |  i  i d d  i d t | d  d  n" | d j o |	 i d
 d  n | | j  o= |	 i t |  i  i d d  i d t | d  d  n" | d j o |	 i d
 d  n |	 |  i | | <t |  i | | <q* Wd S(   s8   
        INTERNAL
        recache VGUI easymenu
        i   s   %ps   %tR   R   R[   s   %1s   %2s   menuselect %dR*   t   7R   s   menuselect 8t   8R   s   menuselect 9N(   R   R   RZ   R   t   replaceR   R   R   R   R   R   R   R   R   R   R^   R   R   RU   RH   R4   R   (   R=   R  RP   R  R  t   maxlinet   pageR   t   descriptionR   R   R|   R  t
   thisformat(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR    sH    	 % -,,c      	   C   sG  | d j o |  i  } n
 |  i } x| D]} |  i | | |  } x t d | d  D] } | d |  i | }	 |	 | j ol |  i | |	 }
 t |  i t |
 i   } | i	 d t |   i	 d t |
 i
   } | | d 7} qY | d 7} qY W| |  i | | |  i |   7} | |  i | | <t |  i | | <q* Wd S(   s?   
        INTERNAL
        Recache RADIO style easymenu
        i   s   %1s   %2s   
s    
N(   R   R   t   pageformatstartR   R   RZ   R   R   R   R  R^   t   pageformatendRS   RH   R4   R   (   R=   R  RP   R  R  R  R  R   R   R|   R  R  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR    s$    	  -"c         C   s   t  i d d | | | f  t |  i |  i d t |   } | i d t |   d } |  i | o | t |  i |  d 7} n |  i o | t |  i  d 7} n | S(   s>   
        INTERNAL
        Formats the start of a page
        i   s3   Popuplib: pageformatstart for page %d/%d in lang %ss   %ps   %ts   
(   Re   Rf   RZ   R   R  R   R   (   R=   R  t   totalRG   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR  4  s    %
c         C   s^  | d j o
 t  } n t } d } |  i o | t |  i  d 7} n | d j o; | t |  i  i d d  i d t | d  d 7} n | p | d 7} n | | j  o; | t |  i  i d d	  i d t | d
  d 7} n | p | d 7} n |  i o | t |  i  d 7} n | t |  i  i d d  i d t | d  7} | S(   s<   
        INTERNAL
        Formats the end of a page
        i   R*   s   
s   %1R  s   %2R   s    
t   9R   t   10R   (	   R4   R:   R   RZ   R   R  RU   R   R   (   R=   R  R  RG   t   tightR   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR  A  s    

HH
3c         C   s{   | oc y t  |  } | g } Wn t j
 o t |  } n Xx% | D] } | |  i t  |  <qI Wn |  i |  d S(   s>   
        Sets active page and sends the menu to users
        N(   RF   Rg   t   listR   RW   (   R=   R   t
   pagenumberRN   t   userlist(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   sendPageU  s     c         C   s   |  i  t |  S(   s=   
        Returns the page number the user has active
        (   R   RF   (   R=   RN   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   getPageb  s    c         C   s{   y t  |  } | g } Wn t j
 o t |  } n Xx9 | D]1 } |  i t  |  | j o |  i |  qB qB Wd S(   sU   
        Unsends the easymenu from users that have the specified page active
        N(   RF   Rg   R   R   Rw   (   R=   R   R!  RN   R"  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   unsendPageg  s     c         C   sH   | p |  i  } n | d j o
 t } n |  i t |  i |  |  S(   s-   
        Returns the number of pages
        R-   (   R6   RJ   R  RL   R   (   R=   RP   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR   s  s    c      
   C   s  t  t |  p d Sn t |  |  i j o |  i t |  } n d } d |  i t |  <t i d d t |  t t |   d  t i d d t |  t t |   d  t i d d t |  i  t t |  i   d  |  i	 t |   } t i d d |  |  i
   } |  i | j ov x: |  i D]/ } x& |  i | D] } t |  i | | <qRWq>W|  i t  | i j o t  | i |  i =n | |  _ n |  i d j o9 |  i | | o' t i d d	  |  i | | g  nF |  i d
 j o5 t i d d  |  i |   o |  i |  q8n |  i t |  i |  |  } | d j  o
 d } n | | j o
 | } n | |  i t |  <|  i d j oi t i d d t |  i | t |   t t |  i | t |    d  |  i | t |  Snk t i d d  |  i t  | i j o' t i d d  |  i | | g  n t  | i |  i t |  Sd S(   sY   
        INTERNAL (semi)
        check the cache status and recache as necessary
        i   s   Popuplib: checkCache(userid=R}   s   Popuplib: checkCache(page=s   Popuplib: cachemode="R   s   Popuplib: effective language=%sR   s   Popuplib: recachet	   constructs   Popuplib: recache CONSTRUCT!RO   s.   Popuplib: Not user-specific, returning cache="s   Popuplib: User specific popups,   Popuplib: Popup not in user cache, recachingN(   RE   RF   RM   R   Re   Rf   RZ   R~   R   RR   RD   R;   R   R:   R/   RH   R   R&  R  RL   R   (   R=   RN   R  RP   R   R   R  R  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR   {  sT    ..4
  "

Pc         C   sk  t  i d d t |  t t |   d t |  t t |   d  |  i t |   } t | } |  | _ t |  _ | i	 } |  i
 t |  } |  i t |  i |  |  } t  i d d t |  d t |   t |  i |  } t  i d d t |  d t |   |  i | d | }	 t  i d d t |	   t }
 t  i d	 | d
  t  i d | d  t  i d |  i d  |	 | j ot |  i | |	 } | i oU | i } | d j o | d j  o
 t }
 q	| d j o | d j  o
 t }
 q	qn |
 p
 | } n; |  i o  t  i |  i t |  d  n |  i
 t |  =|  i ox t  i d d t |  i  d t t |  i    t |  i  o  t |  i | | |  i d  qt  i |  i  n |
 o |  i ox t  i d d t |  i  d t t |  i    t |  i  o  t |  i | | |  i d  qct  i |  i  n |
 o | d j  o | d j o{ | d j oj | d j o% | d 8} | d j o
 d } qn" | d 7} | | j o
 | } n | |  i
 t |  <q n |  | i | <nm | d j o_ |  i
 t |  =|  i oA t |  i t  o |  i | i | <qyt |  i  | i | <q}n t  i d d  t  i d d d |  t  i d d d |  i  t  i d d d |  t  i d  d  d" | _ t |  _ | i! |  j o' t  i d d!  d" | _! | i"   n= | | i j o | i | =n | i! o | i# | i!  n d" S(#   sB   
        handle menu choice as a result of client command
        i   s!   Popuplib: easymenu.handleChoice (s   , R}   s   Popuplib: page t   /s   Popuplib: choice s   Popuplib: index=R   s   User of the popupR   s   Menu item chosenR   s   Active menu namei   i
   s   Chosen objects   Popuplib: menuselect='R   R   s   Popuplib: menuselectfb='R   i   i    R   R   R   RN   R   R   R   R   s   Popuplib: Redoing user queueN($   Re   Rf   RZ   R~   RR   RF   RE   R8   R:   Rp   R   R  RL   R   R   R4   Rk   R/   R   R   R   R   R   R   R   R   Ro   R   R   R,   R   R   RM   Rn   Ru   R   (   R=   R   RN   RP   RO   Rp   R  R  t   choicest   varvalindext   validchoiceR  t	   choiceval(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s    L
			((
	


 
4 4 



			
N(   R   R   R   R?   R   RM   R   R   R   R   R  R  R	  R  R   R   R   R  R  R  R  R#  R$  R%  R   R   R   (    (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s0   	*					,							2t
   Popup_listc           B   s5   e  Z d  Z d d  Z d d d d  Z d   Z RS(   sV   
    Easymenu like structure that shows 10 non-selectable numbered items per page
    i
   c         C   sV   t  t |   i | d d  | |  _ | |  _ | |  _ | |  _ d |  _ d |  _	 d S(   s%   
        Initialize easylist
        t   easylisti    N(
   t   superR,  R?   RM   R   R   R   R   R~   R   (   R=   R>   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR?     s    					c         C   s   |  i  | | | |  d S(   s-   
        Add an item to the easylist
        N(   R  (   R=   R^   R   R   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   additem  s    c      
   C   sh  | d j o |  i  } n
 |  i } x>| D]6} t |  i |  i d t |   } | i d t |   } |  i | o t |  i |  } n | } x t d | d  D] }	 | d |  i |	 }
 |
 | j ol |  i | |
 } t |  i t	 | i
   } | i d t |	   i d t | i   } | d | 7} q q Wt i d | d | d	 t i i  } | d j o= | i t |  i  i d d
  i d t | d  d  n" | d j o | i d d  n | | j  o= | i t |  i  i d d  i d t | d  d  n" | d j o | i d d  n | |  i | | <t |  i | | <q* Wd S(   sT   
        INTERNAL
        recache VGUI easylist (overrides easymenu method)
        i   s   %ps   %ts   %1s   %2s   
R   R   R[   R  R   s   menuselect 8R*   R  R   s   menuselect 9N(   R   R   RZ   R   R  R   R   R   R   R   R   R^   R   R   R   R   R   R   RU   RH   R4   R   (   R=   R  RP   R  R  R  R  R   R  R   R|   R  R  R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR  !  sF    	 % -,,N(   R   R   R   R?   RM   R/  R  (    (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR,    s   t
   Popup_userc           B   sk   e  Z d  Z d   Z d   Z d   Z d   Z d   Z e d  Z	 d   Z
 d   Z d	   Z d
   Z RS(   s]   
    INTERNAL class
    that stores information about a player, mainly their popup queue
    c         C   sh   | |  _  h  |  _ d |  _ d |  _ d |  _ h  |  _ t |  _ t	 |  _
 |  i   t |  _ d |  _ d S(   s,   
        Initialize the player info
        i    i   N(   RN   Ro   RM   Rn   Rp   Rs   RH   R4   Rh   RJ   RG   t   updateLanguageRt   R8   (   R=   RN   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR?   R  s    								
	c         C   sV   t  i |  i  } | i d  } t i d d |  i | f  | o | |  _ n d S(   s*   
        Update the language info
        R   i   s   Popuplib: User %d language="%s"N(   t	   playerlibt	   getPlayerRN   t   getRe   Rf   RG   (   R=   t
   userobjectRG   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR1  b  s    c   	      C   s  t  i d d t |  i  d  t  i d d t |  i  t t |  i    t  i d d t |  i  d t t |  i   d  |  i d% j ot |  i  d j ot
 i |   t |  i  } |  i | } t  i d d	 t |  d
 t t |    t  i d d t |  d
 t t |    |  i | =t  i d d t |  i  d t t |  i   d  | i } t  i d d t |  d
 t t |    t |  o | |  i | i  n_ | d j oQ t  i d |  i  t  i d | i  t  i i d t |   t | i } n | i |  i  } | i } | i   oat |  i  } | d j o4 d d d d t t d d t |  d } n d } | | 7} t  i d d t |  d
 t t |    | i o  t  i | |  i | | i  n t  i | |  i |  t  i d d | |  i | | i f  | d j o- t i | d | i t | | |  i f  n t t d } | o t i  | |  i! |  qn | i" |  i  | |  _ | |  _ t  i# d d  t  i# d d d |  i  t  i# d  d d! | i  t  i# d" d d# |  t  i# d$ d  n9 |  i o! t
 i |   |  i$ |  i  n t
 i% |   d% S(&   sB   
        Display the next popup in player's queue!!!11!!1
        i   s"   Popuplib: User.handleQueue(userid:R}   s   Popuplib: activeid=s   Popuplib: queue=t   (s    items)i    s   Popuplib: qindex='R   s   Popuplib: qpopup='s   Popuplib: queue after=s   Popuplib: prepuser='R*   R   R   s   es_xdoblock s   
t   -i   s   
 (R   s   : s   ) s   Popuplib: menudisplay='s   es.menu(%f, %d, "%s", %s)Rd   R   t   popup_displayR   RN   R   R   t   setfloatt   popup_timeoutR   N(&   Re   Rf   RZ   RN   Rp   R~   Ro   RL   Rn   RM   RE   t   haspopupt   minR3   R   R/   Rk   t   servert   cmdt   gPopupsR   R2   RD   RU   RJ   R<   t   menuRq   Rv   t   unsendidR@   RA   R   t   refreshPopupRW   R   R   t
   hasnopopup(	   R=   t   qindext   qpopupR3   t   menudisplayR]   t   pendingcountt   pendingtextt   refreshtime(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRu   k  sd    !08&..
8	.	4
.
 &-		
c         C   sb   | |  i  j oN | |  i j o> |  i i o |  i i d |  i  q^ d |  _ |  i   n d S(   sF   
        remove popup from display if the queue index matches
        i
   N(   Rp   Rn   R5   R   RN   RM   Ru   (   R=   R|   t   pobject(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   unsendView  s
     	c         C   sM   | |  i  j o9 |  i  | =|  i o! |  i |  i  |  i <|  i   qI n d S(   s8   
        remove popup from queue by queue index
        N(   Ro   Rn   Rp   Ru   (   R=   R|   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   unsendSend  s
    

c         C   s   t  | } |  i | |  d S(   s6   
        remove popups from queue by the name
        N(   R?  Rw   (   R=   t   popupidt   closet   compopup(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   unsendName  s    
c         C   s   t  |  i  } x0 | D]( } | |  i | j o |  i | =q q W|  i | j o |  i |  i j o | on d |  _ t |  i  d j o |  i   q | i   o0 t i	 d d  t
 |  _ t i |  i d  q q t i |  i d  n d S(   s?   
        remove popups from queue by the class handler
        i    i   s#   Popuplib: setting closemode to Truet   slot10N(   R   Ro   Rn   R8   RM   RL   Ru   RD   Re   Rf   R:   Rt   R   RN   (   R=   RO  RN  t	   tempqueueR|   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRw     s     #		c         C   s   |  i  | j o d Sn d } |  i on xk t t |  i  t |  i  d  D]@ } | |  i j o* | d 7} |  i | | j o | Sq qN qN Wn d S(   s:   
        return first queue position of the popup
        i   i    (   Rn   Ro   R   R<  t   max(   R=   t   pt   goR|   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRm     s    
& 
c         C   s   t  i d d t |  i  d t |  t t |   d  t  i d d t |  i  t t |  i    |  i oK |  i | j o; t  i d d  | |  i |  i <d |  _ |  i	   t
 Sn t S(   s3   
        redisplay the popup if its active
        i   s   Popuplib: Userids   .updatePopup(R}   s   Popuplib: active = s   Popuplib: match!N(   Re   Rf   RZ   RN   R~   Rn   Ro   Rp   RM   Ru   R:   R4   (   R=   RT  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s    ?0	
c         C   s   |  i  |  S(   s.   
        Orange Box popup refreshment
        (   R   (   R=   RT  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRB  	  s    (   R   R   R   R?   R1  Ru   RK  RL  R4   RP  Rw   Rm   R   RB  (    (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR0  M  s   				J					t   UserHolderClassc           B   sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s=   
    This is an internal class for handling user objects
    c         C   sh   h  |  _  t   |  _ t i d  } x* | D]" } t t |   |  t |  <q+ Wt i i	 t
 d  d S(   sA   
        Create attributes and steal players from server
        s   #humanR`   N(   t   userdictRk   t   activepopupsR2  t   getUseridListR0  RF   Re   t   addonst   unregisterForEventt
   selfmodule(   R=   R"  RN   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR?     s    	  c         C   s6   y t  i |  t SWn t  i j
 o t Sn Xd S(   s8   
        x.__contains__(userid) <-> userid in x
        N(   R2  R3  R:   t   UseridErrorR4   (   R=   RN   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   __contains__  s
    c         C   s   | |  i  t |  <d S(   sD   
        x.__setitem__(userid, value) <-> x[userid] = value
        N(   RW  RF   (   R=   RN   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   __setitem__&  s    c         C   s{   |  i  i t |   pQ t i |  } t | i d  d j o  t t |   |  t |  <qj d Sn |  i  t |  S(   s=   
        a = x.__getitem__(userid) <-> a = x[userid]
        t   isboti    N(   RW  RI   RF   R2  R3  t
   attributesR0  RM   (   R=   RN   t   nuser(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   __getitem__+  s     c         C   s1   |  i  i t |   o |  i  t |  =n d S(   s9   
        x.__delitem__(userid) <-> del x[userid]
        N(   RW  RI   RF   (   R=   RN   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   __delitem__6  s    c         C   sd   t  i d d  t |  i  d j o* t  i d d  t  i i t d t  n |  i i |  d S(   s   
        Some player instructs that he has popups in queue or active.
        If this is the first report, register es_client_command event handler
        i   s   Popuplib: haspopup!i    s$   Popuplib: register es_client_commandR`   N(	   Re   Rf   RL   RX  RZ  t   registerForEventR\  R`   t   add(   R=   RO   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR;  <  s
    c         C   se   t  i d d  | |  i j oA |  i i |  t |  i  d j o t i d |  i  qa n d S(   s   
        Some player instructs that he no longer has any popups in queue or active.
        If this is the last report, unregister es_client_command event handler
        i   s   Popuplib: hasnopopup!i    N(   Re   Rf   RX  t   removeRL   Rq   R   t   checkeventneed(   R=   RO   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRC  F  s
    c         C   sA   t  |  i  d j o' t i d d  t i i t d  n d S(   sA   
        Checks if the es_client_command is still needed
        i    i   s&   Popuplib: unregister es_client_commandR`   N(   RL   RX  Re   Rf   RZ  R[  R\  (   R=   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRh  P  s    (   R   R   R   R?   R^  R_  Rc  Rd  R;  RC  Rh  (    (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRV    s   	
						
	
c         C   s   h  d d <d d <d d <} t t |   } | p d Sn | i o8 | i i | d <t | i  d | d <| i | d <n | S(   s?   
    check which popup is active and how many are in queue
    Rb   R/   i    t   countt   objecti   N(   RM   RE   RF   Rn   R/   RL   Ro   (   RN   t   plRO   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRn   d  s    !
c         C   s   t  |  t  p" x |  D] } t | |  q Wn y5 t |  } t | } | o | i |  t  n WnO t j
 oC x> | D]1 } t t |  } | o | i |  t  q q Wn Xd S(   sQ   
    remove queued popups by the popup name but do not trigger menuselect 10
    N(   R   t
   basestringRN  RF   RE   RP  R:   Rg   (   R>   Rx   RT  RN   RO   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRN  r  s     
 c         C   s   t  |  t  p; g  } x* |  D]" } | i t | | | |   q W| SnA | t j o& t | |  | |  t |  <t |  Sn t d |  d S(   s&   
    create a new construct popup
    s   Construct "%s" not availableN(   R   Rl  R   R&  t   gConstructsR?  t	   NameError(   R>   t   pListt   pFlagsR   t   rvRT  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR&    s      c         C   s   t  |  t  p2 g  } x! |  D] } | i t |   q W| Snc |  t j o= t |  i d j o t |  i |   q t |   t |  <n t |   t |  <t |  Sd S(   s#   
    create a new normal popup
    R   N(   R   Rl  R   t   createR?  R~   R?   R   (   R>   Rq  RT  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRr    s     c         C   s   t  |  t  p xz |  D] } t |  q Wn_ |  t j oA t i d |   t |  i o t i t |   q t |   n t	 d |    d S(   s   
    delete a popup
    Rd   s3   Popuplib: Cannot delete popup %s, it does not existN(
   R   Rl  RV   R?  Rq   t   cancelDelayedR8   Ro   t   _deleteRY   (   R>   RT  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRV     s     c         C   s   |  t  j o t  |  =n d S(   s(   
    internal delete a popup method
    N(   R?  (   R>   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRt    s    i
   c         C   s   t  |  t  p5 g  } x$ |  D] } | i t | |   q W| Sn |  t j oI t |  i d j o t |  i |  |  } q t |  |  } t |  <n t |  |  } t |  <| o" x | D] } | i |  q Wn | Sd S(   s%   
    create a new easylist popup
    R-  N(	   R   Rl  R   R-  R?  R~   R?   R,  R/  (   R>   t   dataR   Rq  RT  R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR-    s       c         C   s   t  |  t  p8 g  } x' |  D] } | i t | | |   q W| Snu |  t j oI t |  i d j o t |  i |  | |  q t |  | |  t |  <n t |  | |  t |  <t |  Sd S(   s%   
    create a new easymenu popup
    R   N(   R   Rl  R   R   R?  R~   R?   R   (   R>   t   pVarnR   Rq  RT  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s     c         C   so   y* t  |  } t |  i t  |  |  Wn> t j
 o2 x- | D]  } t |  i t  |  |  qB Wn Xd S(   s[   
    emulate user doing a menu choice from any existing popup.
    use with caution...
    N(   RF   R?  R   Rg   (   R>   t   pItemRx   RN   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   emulate  s     c         C   s   t  |  t j  S(   s    
    does named popup exist
    (   R   R?  (   R>   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   exists  s    c         C   s   |  t  j o t  |  Sn d S(   s.   
    return class instance of named popup
    N(   R?  RM   (   R>   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR     s    c         C   s|   t  |  t  p5 g  } x$ |  D] } | i t | |   q W| Sn4 t | } | o" |  t j o | i t |   Sn d S(   s7   
    returns the queue position of the named popup
    N(   R   Rl  R   Rm   RE   R?  (   R>   t   pUseridRq  RT  RO   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRm     s     
c         C   s9   t    } x) | D]! } d |  | | | f | | <q W| S(   sQ   
    constructs a language dict by adding prefix and suffix for each element
    s   %s%s%s(   R   (   t   prefixt
   langobjectt   suffixt   newcR   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   langstring  s
    	 c         C   sE   t  d  } |  | _ | | i d <| | _ | | _ | i |  d S(   s,   
    like es.menu, but uses popup queue
    t	   quicksendR-   N(   R   R2   RH   R   R<   RW   (   t	   pViewtimeRz  t   pTextR   t   pKeyst   qs(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR    s    			c         C   s   t  |  t  p8 g  } x' |  D] } | i t | | |   q W| Sn6 |  t j o t |  i | |  n t d |    d S(   s*   
    send a named popup to user/users
    s1   Popuplib: Cannot send popup %s, it does not existN(   R   Rl  R   RW   R?  RY   (   R>   Rz  Ry   Rq  RT  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRW   #  s     c         C   s&   | t  j o t  | i |   n d S(   sH   
    INTERNAL (mostly)
    remove a queued popup by its queue index
    N(   RE   RL  (   t   pIndexRz  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRw   2  s    c         C   s)   | t  j o t  | i |  |  n d S(   sI   
    INTERNAL (mostly)
    remove a visible popup by its queue index
    N(   RE   RK  (   R  t   pObjectRz  (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRA  :  s    c         C   s   t  |  t  p+ x |  D] } t i t | |   q Wnq y! t |  } t | i |   WnL t j
 o@ x; | D]. } t t |  } | o | i |   qt qt Wn Xd S(   s0   
    remove queued popups by the popup name
    N(	   R   Rl  Rq  R   t
   unsendmaneRF   RE   RP  Rg   (   R>   Rx   RT  RN   RO   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt
   unsendnameB  s      c         C   sR   | d j oA t  |   } t d | | f  } d |  d | d f } | Sn |  S(   sE   
    INTERNAL function for formatting title using page numbering
    i    i   s   %s%s(%s)R   s   %p/%t(   RL   RS  (   t   st   nR   R   t   x(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR   R  s    c         C   s_  y |  | | |  WnDt  j
 o } t |  t |  i d   } | |  i j o t i d d | | | f  t i d d  t i d d  t i d d |  i  t i d d t |    t i d	 d
 t |   q[t i d d |  i | f  t i t i     nF t	 j
 o9 } t i d d |  i | f  t i t i     n Xd S(   s9   
    INTERNAL function for calling external function
    R6  i    s'   Invalid %s function "%s" for popup "%s"s.   Callback function must accept three parametersi   s   Details:s    Function name: s    Function info: i   s    Full error: s>   Popuplib: Exception when calling function "%s" for popup "%s":N(
   Rg   RZ   R   t	   func_nameRe   Rf   t   exceptert   syst   exc_infot   BaseException(   t   ft   ut   cRT  t   tt   et
   infuncname(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR   ]  s     c         C   s1   t  |   i d j o |  i d  Sn t |   S(   sW    converts value into utf-8 coded string if it is unicode,
    otherwise forces __str__ t   unicodes   utf-8(   R~   R   t   encodeRZ   (   R   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR   s  s    c          C   s   t  t i d   i d d  i d  d i   }  |  t j o
 |  a n d a t i d d |   t i d d t  t i d d	 t  t t   d
 S(   sh   
    checks which Source game server this is and adjusts menu behavior
    based on the game engine
    t   eventscripts_gamedirs   \R'  i   R   i   s$   Popuplib: Detected game folder: "%s"s$   Popuplib: Selected game folder: "%s"s"   Popuplib: Game support status : %sN(	   RZ   Re   t	   ServerVarR  t
   rpartitiont   lowerR@   RA   Rf   (   t   gamename(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   updateGameNamez  s    4
c         C   s   | t  |  <d S(   sH   
    Registers a new construct function to be used with construct()
    N(   Rm  (   R/   t   function(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   registerConstruct  s    c         C   s$   |  t  j o t  |  =t Sn t Sd S(   s;   
    Removes the named construct function registration
    N(   Rm  R:   R4   (   R/   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   unregisterConstruct  s    c         C   s   t  i d  t i   d S(   sD   
event es_map_start is fired when a map is loaded on the server
    s#   addons/eventscripts/popup/popup.resN(   Re   t
   loadeventsRE   R?   (   t	   event_var(    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   es_map_start  s    c         C   s   t  i d d  |  d } | d j o y t |  d  } t |  d  } t | } | i o' t  i d d  t | _ | i   n% | i } | o | i | |  n Wq t	 j
 o q Xn d S(	   sH   
event es_client_command is fired when the user chooses a menu item
    i   s   Popuplib: es_client_commandR   R   t   commandstringRN   s$   Popuplib: setting closemode to FalseN(
   Re   Rf   RF   RE   Rt   R4   Ru   Rn   R   RY   (   R  R   R   RN   RO   Rn   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyR`     s     


		R  t   declares#   addons/eventscripts/popup/popup.resR   s    Userid of the current popup userc         C   s   t  |  _ d  S(   N(   R4   Rh   (   RO   (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyRr     s    c           C   s   t  i d  t a d  S(   NR_   (   Re   Rj   R:   Ri   (    (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   gt_event_info_check  s    c            s@     f d   } t  |  d |  } d | _ | | _ d | _ | S(   s!   
    Constructs a playerlist
    c   	         s   t  i    } g  } | D] } | t |  q ~ } | |  i j o | |  _ |  i i   } |  i |  i } | i   x+ | D]# } |  i t |  | i	 d  q Wx | D] } | |  i | <q Wt
 Sn t Sd  S(   NR/   (   R2  t   getPlayerListRF   t   construct_checkR   RK   R6   t   clearR  Ra  R:   R4   (	   RT  t
   playerlistt   _[1]R  t
   useridlistR  t   mainoptt   playerR   (   t   flags(    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   updatelisting  s    '	
 ! R&  N(   R   RM   R   R&  R  (   RM  R  R   R  t
   thenewmenu(    (   R  sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pyt   ConstructPlayerList  s    			t   players(K   Re   R2  R
  Rq   R   R  t   psycot   fullt	   AddonInfot   infoR/   t   versiont   authort   urlR  RJ   RA   R:   R4   R@   RB   R?  Rm  RU   t   teamdatat   cbotdatat	   cdeaddatat
   __import__R   R\  Rj  R,   R   R   R   R,  R0  RV  RE   Rn   RN  RM   R&  Rr  RV   Rt  R-  R   Rx  Ry  R   Rm   R  R  RW   Rw   RA  R  R   R   R   R  R  R  R  R`   RZ  Re  R  Rk   Rr   R  R  Ri   R   (    (    (    sO   /home/saberrider/srcds/css/cstrike/addons/eventscripts/_libs/python/popuplib.pys   <module>   s   
					....... 
  BK	
																						
				