Addon Details

Watch - Add Favorite


1 out of 1 users claim this version works for them.
Does this version work for you?
3
w00ts
w00t!2

CheapPopup/CheapAdmin - Version 1

posted on 2010-11-11 23:01:11
by SuperDave


Tags: css popup

Description

[code]* Functions available through CheapPopup: NOTE: Each function below is also available through the CheapPopup class sendMenu(userid, duration, text, callback=None) " Sends a single menu to a player Optional callback will be called with menu selection " userid = player to send menu duration = integer number of seconds to display menu, 0 = until selection text = text to display in menu (\n = newline) callback = function to call when a selection is made: callback(userid, selection) where "userid" is the integer userid of the player making the selection and "selection" is the integer selection number (0 through 9 inclusive) or None for no selection (timeout/menu closed) sendSelectionMenu(userid, items, callback, langobj=SelectionLanguages, firstback=None, lastnext=None, nohighlight=None) " Sends a series of menus to a player prompting selection Returns selection through callback " userid = player to send series of menus items = object containing string items for selection when an instance of collections.Sequence (tuple, list, etc) is given, selections are displayed in order and an integer index selection is returned when an instance of collections.Set (set, frozenset, etc) is given, selections are displayed sorted and the string selection is returned when an instance of collections.Mapping (dictionary, etc) is given, selections are displayed sorted and the value corresponding to the key selected is returned if an object passed has the "order" attribute, that sequence will be used to dictate display order (see SelectionDict and SelectionSet below) callback = function to call when a selection is made: callback(userid, selection) where "userid" is the integer userid of the player making the selection and "selection" is an object determined by the object passed to "items" (above) or None for no selection (including menu closed) langobj = object containing language strings used to build menus when a string is given, that string is used for the "header" language item (see SelectionLanguages and SelectionLanguagesLanglib) firstback = function to call if the first "back" selection is made: firstback(userid) where "userid" is the integer userid of the player making the selection NOTE: When this argument is omitted this selection is replaced by a selection to go to the last page of items lastnext = function to call if the last "next" selection is made: lastnext(userid) where "userid" is the integer userid of the player making the selection NOTE: When this argument is omitted this selection is replaced by a selection to go to the first page of items nohighlight = container object dictating selections that should not be highlighted (appear yellow/orange on the menu) when omitted, given None or False all selections appear highlighted when given a container, selection items appearing in the container are not highlighted when True, no selection appears highlighted sendESCMenu(userid, duration, title, text) " Sends a menu of text to a player, ESC must be pressed to view " userid = player to send menu duration = integer number of seconds to display menu (10 <= duration <= 200, this limit is Valve-imposed) title = title to use for menu (this text also appears to alert the player of the menu) text = text to display in menu sendESCButtonMenu(userid, duration, title, text, items, callback) " Sends a multi-button GUI menu to the player, ESC must be pressed to view Returns selection through callback NOTE: This menu's input functionality conflicts with the popup menu's functionality. Therefore, if a popup is open when an ESCButtonMenu is sent, the popup will be closed, and vice-versa. " userid = player to send menu duration = integer number of seconds to display menu (10 <= duration <= 200, this limit is Valve-imposed) title = title to use for menu (this text also appears to alert the player of the menu) text = text to display in menu (prompt for selection) items = tuple or list of up to eight strings for button text callback = function to call when a selection is made: callback(userid, selection) where "userid" is the integer userid of the player making the selection and "selection" is the integer button number the player selected (1 through 8 inclusive) or None for no selection (timeout/menu closed) sendESCButtonSelectionMenu(userid, duration, items, callback, langobj=SelectionLanguages, firstback=None, lastnext=None) " Sends a series of multi-button GUI menus to the player prompting selection, ESC must be pressed to view Returns selection through callback NOTE: This function uses ESCButtonMenu and therefore suffers from the same conflicts with popups. See the notes for sendESCButtonMenu for further information. " userid = player to send series of menus duration = integer number of seconds to display each menu (10 <= duration <= 200, this limit is Valve-imposed) items = object containing string items for selection when an instance of collections.Sequence (tuple, list, etc) is given, selections are displayed in order and an integer index selection is returned when an instance of collections.Set (set, frozenset, etc) is given, selections are displayed sorted and the string selection is returned when an instance of collections.Mapping (dictionary, etc) is given, selections are displayed sorted and the value corresponding to the key selected is returned if an object passed has the "order" attribute, that sequence will be used to dictate display order (see SelectionDict and SelectionSet below) callback = function to call when a selection is made: callback(userid, selection) where "userid" is the integer userid of the player making the selection and "selection" is an object determined by the object passed to "items" (above) or None for no selection (including timeout or menu closed) langobj = object containing language strings used to build menus when a string is given, that string is used for the "title" and "text" language items (see SelectionLanguages and SelectionLanguagesLanglib) firstback = function to call if the first "back" selection is made: firstback(userid) where "userid" is the integer userid of the player making the selection NOTE: When this argument is omitted this selection is replaced by a selection to go to the last page of items lastnext = function to call if the last "next" selection is made: lastnext(userid) where "userid" is the integer userid of the player making the selection NOTE: When this argument is omitted this selection is replaced by a selection to go to the first page of items * Classes available through CheapPopup: CheapPopup() " Container class for associated menus The advantage of this class being the "close" functions only affect menus opened by the same instance On player_disconnect any popup delays associated with the disconnecting player are removed On es_map_start all popup delays associated with the instance are removed " sendMenu # function documented above sendSelectionMenu # function documented above sendESCMenu # function documented above sendESCInputMenu # function documented above sendESCButtonMenu # function documented above sendESCButtonSelectionMenu # function documented above sendCustomMenu(Menu, userid, *a, **kw) Sends a custom Popup implementation to the given userid sendCustomESCMenu(Menu, userid, *a, **kw) Sends a custom ESCMenu implementation to the given userid closeMenu(userid) Closes the non-ESC menu open to the given userid closeESCMenu(userid) Closes the ESC menu open to the given userid closeAll() Closes all menus associated with the CheapPopup instances clear() Removes all popup delays associated with the CheapPopup instance but DOES NOT CLOSE MENUS Popup() " Base Popup class All send*Menu functions return an instance of this class or a subclass " close() Closes the popup if it is active cancelDelay() Cancels any delay associated with the popup (useful if the popup is overwritten by another menu system) isActive() Returns True if the popup is active (displayed) otherwise returns False SelectionLanguages() " Container object for strings associated with a SelectionPopup " header = 'Make a selection:' noselections = 'No selections' separator1 = ' ' separator2 = ' ' back = 'Back' next = 'Next' firstback = 'Last page' lastnext = 'First page' exit = 'Exit' ESCSelectionLanguages() " Container object for strings associated with an ESCButtonSelectionMenu " title = 'Make a selection:' text = 'Please make a selection:' back = 'Back' next = 'Next' firstback = 'Last page' lastnext = 'First page' SelectionLanguagesLanglib(langobj=None, lang=None, knownas=None) " Container object that pulls strings for SelectionPopup or ESCButtonSelectionMenu from a langlib object When "knownas" is provided a mapping, string names will first be searched for in "knownas" Such that if "knownas" is provided: {'header': 'my header'} When "header" is displayed, the langlib item "my header" will be used " SelectionSet(itr=None) " Subclass of "set" that remembers the order items are added When initialized with an iterator, items are added in sorted(...) order " SelectionDict(itr=None) " Subclass of "dict" that remembers the order keys are added When initialized with an iterator, keys are added in sorted(...) order "[/code]

Installation

Install with:[syntax="es"]es_install cheappopup[/syntax]If you want to use the admin system:[syntax="es"]es_install cheappopup autoload[/syntax]

Version Notes For 1

Updated on: 2011-03-12 17:31:57 EST by SuperDave (View Zip Contents)


( Previous Versions )