示例#1
0
 def backmenu(self, backmenu):
     if popuplib.exists(backmenu):
         self.popup.submenu(10, popuplib.find(backmenu))
         self.backpopup = popuplib.find(backmenu)
         es.dbgmsg(
             1, "Keymenulib: Set backmenu of '%s' to popup '%s'" %
             (self.name, self.backpopup))
         return True
     elif settinglib.exists(backmenu):
         self.popup.submenu(10, settinglib.find(backmenu).popup)
         self.backpopup = settinglib.find(backmenu).popup
         es.dbgmsg(
             1, "Keymenulib: Set backmenu of '%s' to setting '%s'" %
             (self.name, self.backpopup))
         return True
     elif exists(backmenu):
         self.popup.submenu(10, find(backmenu).popup)
         self.backpopup = find(backmenu).popup
         es.dbgmsg(
             1, "Keymenulib: Set backmenu of '%s' to keymenu '%s'" %
             (self.name, self.backpopup))
         return True
     else:
         es.dbgmsg(
             0, "keymenu: Could not set backmenu of '%s' to '%s'!" %
             (self.name, backmenu))
         return False
示例#2
0
def _send_menu():
    userid = es.getcmduserid()
    for setting in setting_object:
        setting_object[setting].rebuild(userid) # TODO: finish rebuild methods later
    xasettingmenu = popuplib.find("xasettingmenu")
    xasettingmenu.recache(userid)
    xasettingmenu.send(userid)
示例#3
0
def registerVoteMenu(shortName,
                     displayName,
                     returnFunction,
                     submenus=[],
                     serverCmdFunction=None,
                     permission='ADMIN'):
    if not vote_list.has_key(shortName):
        vote_list[shortName] = {}
        if serverCmdFunction:
            vote_list[shortName]['commandFunction'] = serverCmdFunction
            xavote.addCommand('xa_' + shortName + 'vote', voteCmd, 'xa_vote',
                              permission).register(('server', 'console'))
        vote_list[shortName]['display'] = displayName
        vote_list[shortName]['function'] = returnFunction
        vote_list[shortName]['type'] = 'mainmenu'
        votemenu = popuplib.find("xavotemenu")
        votemenu.addoption(shortName, displayName)
        if submenus:
            vote_list[shortName]['type'] = 'submenu'
            myPopup = popuplib.easymenu(shortName, 'vote_choice', returnMenu)
            for submenu in submenus:
                vote_list[submenu]['function'] = returnFunction
                myPopup.addoption(submenu, submenu)
            myPopup.settitle(displayName)
            myPopup.submenu(10, "xavotemenu")
def registerPunishment(module,
                       punishment,
                       name,
                       method,
                       argc=0,
                       activeOnDeadPlayers=False):
    if not punishment in punishment_method:
        punishment_method[punishment] = method
        punishment_display[punishment] = name
        punishment_argc[punishment] = argc
        punishment_ondead[punishment] = activeOnDeadPlayers
        punishment_cross_ref['xa_' + punishment] = punishment
        xapunishmentmenu = popuplib.find("xapunishmentmenu")
        xapunishmentmenu.addoption(punishment, name, 1)
        xapunishments.registerCapability("immune_" + punishment, "ADMIN",
                                         "IMMUNITY")
        if punishment_argc[punishment] > 0:
            xapunishments.addCommand('xa_' + punishment, _command_player,
                                     punishment + "_player", "ADMIN",
                                     name["en"] + " punishment",
                                     True).register(
                                         ('say', 'console', 'server'))
        return True
    else:
        return False
示例#5
0
 def __init__(self, setting, menu, texts):
     self.name = str(setting)
     self.texts = dict(texts)
     if popuplib.exists(menu):
         self.menu = menu
         self.menutype = "popup"
         self.menuobj = popuplib.find(self.menu)
     elif keymenulib.exists(menu):
         self.menu = menu
         self.menutype = "keymenu"
         self.menuobj = keymenulib.find(self.menu)
     elif settinglib.exists(menu):
         self.menu = menu
         self.menutype = "setting"
         self.menuobj = settinglib.find(self.menu)
     xasettingmenu = popuplib.find("xasettingmenu")
     xasettingmenu.addoption(setting, self.texts)
示例#6
0
 def __init__(self, setting, menu, texts):
     self.name = str(setting)
     self.texts = dict(texts)
     if popuplib.exists(menu):
         self.menu = menu
         self.menutype = "popup"
         self.menuobj = popuplib.find(self.menu)
     elif keymenulib.exists(menu):
         self.menu = menu
         self.menutype = "keymenu"
         self.menuobj = keymenulib.find(self.menu)
     elif settinglib.exists(menu):
         self.menu = menu
         self.menutype = "setting"
         self.menuobj = settinglib.find(self.menu)
     xasettingmenu = popuplib.find("xasettingmenu")
     xasettingmenu.addoption(setting, self.texts)
示例#7
0
def _send_menu():
    userid = es.getcmduserid()
    for setting in setting_object:
        setting_object[setting].rebuild(
            userid)  # TODO: finish rebuild methods later
    xasettingmenu = popuplib.find("xasettingmenu")
    xasettingmenu.recache(userid)
    xasettingmenu.send(userid)
示例#8
0
def _submitGlobal(userid, value, popupid):
    es.dbgmsg(1, 'Settinglib: _submitGlobal(%s, %s, %s)' % (userid, value, popupid))
    page = popuplib.find(popupid)
    if page:
        if page.settingid in gSettings:
            gSettings[page.settingid].menuUserGlobalSubmit(userid, value)
        else:
            raise ValueError('Settinglib: Invalid setting %s submitted from popup'%page.settingid)
 def backmenu(self, backmenu):
     if popuplib.exists(backmenu):
         self.popup.submenu(10, popuplib.find(backmenu))
         self.backpopup = popuplib.find(backmenu)
         es.dbgmsg(1, f"Keymenulib: Set backmenu of '{self.name}' to popup '{self.backpopup}'")
         return True
     elif settinglib.exists(backmenu):
         self.popup.submenu(10, settinglib.find(backmenu).popup)
         self.backpopup = settinglib.find(backmenu).popup
         es.dbgmsg(1, f"Keymenulib: Set backmenu of '{self.name}' to setting '{self.backpopup}'")
         return True
     elif exists(backmenu):
         self.popup.submenu(10, find(backmenu).popup)
         self.backpopup = find(backmenu).popup
         es.dbgmsg(1, f"Keymenulib: Set backmenu of '{self.name}' to keymenu '{self.backpopup}'")
         return True
     else:
         es.dbgmsg(0, f"keymenu: Could not set backmenu of '{self.name}' to '{backmenu}'!")
         return False
示例#10
0
 def backmenu(self, backmenu):
     if popuplib.exists(backmenu):
         self.popup.submenu(10, popuplib.find(backmenu))
         self.backpopup = popuplib.find(backmenu)
         es.dbgmsg(1, "Keymenulib: Set backmenu of '%s' to popup '%s'"%(self.name, self.backpopup))
         return True
     elif settinglib.exists(backmenu):
         self.popup.submenu(10, settinglib.find(backmenu).popup)
         self.backpopup = settinglib.find(backmenu).popup
         es.dbgmsg(1, "Keymenulib: Set backmenu of '%s' to setting '%s'"%(self.name, self.backpopup))
         return True
     elif exists(backmenu):
         self.popup.submenu(10, find(backmenu).popup)
         self.backpopup = find(backmenu).popup
         es.dbgmsg(1, "Keymenulib: Set backmenu of '%s' to keymenu '%s'"%(self.name, self.backpopup))
         return True
     else:
         es.dbgmsg(0, "keymenu: Could not set backmenu of '%s' to '%s'!"%(self.name, backmenu))
         return False
示例#11
0
def _submit(userid, value, popupid):
    es.dbgmsg(1, 'Settinglib: _submit(%s, %s, %s)' % (userid, value, popupid))
    page = popuplib.find(popupid)
    if page:
        if page.settingid in gSettings:
            gSettings[page.settingid].menuUserSubmit(userid, value)
        else:
            raise ValueError(
                'Settinglib: Invalid setting %s submitted from popup' %
                page.settingid)
示例#12
0
def prep_level_menu(userid, popupid):
    # Make sure the popup exists
    if not popuplib.exists('ggLevelMenu'):
        return

    ggLevelMenu = popuplib.find('ggLevelMenu')
    ggPlayer = Player(userid)

    # Get multikill count for the player's level
    multiKill = get_level_multikill(ggPlayer.level)

    # Use multikill style menu ?
    if multiKill > 1:
        ggLevelMenu.modline(2,
           '   * You are on level %s (%s)' % (ggPlayer.level, ggPlayer.weapon))
        ggLevelMenu.modline(3, '   * You have made %s' % ggPlayer.multikill +
        '/%s of your required kills' % multiKill)

    # Normal style menu
    else:
        ggLevelMenu.modline(2, '   * You are on level %s' % ggPlayer.level)
        ggLevelMenu.modline(3,
                        '   * You need a %s kill to advance' % ggPlayer.weapon)

    # Get leader's level
    leaderLevel = get_leader_level()

    # See if the leader is higher than level 1
    if leaderLevel > 1:

        # See if the player is a leader:
        if is_leader(userid):

            # See if there is more than 1 leader
            if get_leader_count() > 1:
                ggLevelMenu.modline(4,
                        '   * You are currently tied for the leader position')

            # Player is the only leader
            else:
                ggLevelMenu.modline(4, '   * You are currently the leader')

        # This player is not a leader
        else:
            ggLevelMenu.modline(4,
                '   * You are %s level(s)' % (leaderLevel - ggPlayer.level) +
                'behind the leader')

    # There are no leaders
    else:
        ggLevelMenu.modline(4, '   * There currently is no leader')

    # Wins information
    ggLevelMenu.modline(6, '   * You have won %s time(s)' % ggPlayer.wins)
示例#13
0
def _varmenu_select(userid, choice, popupid):
    if es.exists('variable', choice):
        parentmenu = popuplib.find(popupid)
        parent = parentmenu._xa[0]
        if str(parent) != 'core':
            if xa.exists(parent) and choice in xa.find(parent).variables:
                var = xa.find(parent).variables[choice]
                menu = _variableEditMenu(userid, parent, var, popupid)
                menu.send(userid)
        else:
            for var in xa.corevars():
                if var.getName() == choice:
                    menu = _variableEditMenu(userid, parent, var, popupid)
                    menu.send(userid)
def unregisterPunishment(module, punishment):
    if punishment in punishment_method:
        xapunishmentmenu = popuplib.find("xapunishmentmenu")
        xapunishmentmenu.addoption(punishment, 'Unloaded', 0)
        punishment_method[punishment] = None
        try:
            del punishment_display[punishment]
            del punishment_argc[punishment]
            del punishment_cross_ref['xa_' + punishment]
        except:
            pass
        return True
    else:
        return False
示例#15
0
def unregisterPunishment(module, punishment):
    if punishment in punishment_method:
        xapunishmentmenu = popuplib.find("xapunishmentmenu")
        xapunishmentmenu.addoption(punishment, 'Unloaded', 0)
        punishment_method[punishment] = None
        try:
            del punishment_display[punishment]
            del punishment_argc[punishment]
            del punishment_cross_ref['xa_'+punishment]
        except:
            pass
        return True
    else:
        return False
示例#16
0
def _varmenu_select(userid,choice,popupid):
    if es.exists('variable', choice):
        parentmenu = popuplib.find(popupid)
        parent = parentmenu._xa[0]
        if str(parent) != 'core':
            if xa.exists(parent) and choice in xa.find(parent).variables:
                var = xa.find(parent).variables[choice]
                menu = _variableEditMenu(userid, parent, var, popupid)
                menu.send(userid)
        else:
            for var in xa.corevars():
                if var.getName() == choice:
                    menu = _variableEditMenu(userid, parent, var, popupid)
                    menu.send(userid)
示例#17
0
def registerPunishment(module, punishment, name, method, argc = 0):
    if not punishment in punishment_method:
        punishment_method[punishment] = method
        punishment_display[punishment] = name
        punishment_argc[punishment] = argc
        punishment_cross_ref['xa_'+punishment] = punishment
        xapunishmentmenu = popuplib.find("xapunishmentmenu")
        xapunishmentmenu.addoption(punishment, name, 1)
        xapunishments.registerCapability("immune_"+punishment, "ADMIN", "IMMUNITY")
        if punishment_argc[punishment] > 0:
            xapunishments.addCommand('xa_'+punishment, _command_player, punishment+"_player", "ADMIN", name["en"]+" punishment", True).register(('say', 'console','server'))
        return True
    else:
        return False
示例#18
0
def registerVoteMenu(shortName, displayName, returnFunction, submenus=[], serverCmdFunction=None, permission='ADMIN'):
    if not vote_list.has_key(shortName):
        vote_list[shortName] = {}
        if serverCmdFunction:
            vote_list[shortName]['commandFunction'] = serverCmdFunction 
            xavote.addCommand('xa_' + shortName + 'vote', voteCmd, 'vote_commands', permission).register(('server', 'console'))
        vote_list[shortName]['display']  = displayName
        vote_list[shortName]['function'] = returnFunction
        vote_list[shortName]['type']     = 'mainmenu'
        votemenu = popuplib.find("xavotemenu")
        votemenu.addoption(shortName, displayName)
        if submenus:
            vote_list[shortName]['type'] = 'submenu'
            myPopup = popuplib.easymenu(shortName, 'vote_choice', returnMenu)
            for submenu in submenus:
                vote_list[submenu]['function'] = returnFunction
                myPopup.addoption(submenu, submenu)
            myPopup.settitle(displayName)
            myPopup.submenu(10, "xavotemenu")
示例#19
0
def _keymenu_select(userid, choice, popupid):
    parentmenu = popuplib.find(popupid)
    parent = parentmenu._xa[0]
    if xa.exists(parent) and choice in xa.language.getLanguage(parent):
        menu = _stringEditMenu(userid, parent, choice, popupid)
        menu.send(userid)
示例#20
0
def _keymenu_select(userid,choice,popupid):
    parentmenu = popuplib.find(popupid)
    parent = parentmenu._xa[0]
    if xa.exists(parent) and choice in xa.language.getLanguage(parent):
        menu = _stringEditMenu(userid, parent, choice, popupid)
        menu.send(userid)
示例#21
0
def _changestring_select(userid,choice,popupid):
    menu = popuplib.find(popupid)
    if menu:
        _setconfig_handle(userid, menu._xa[0], menu._xa[1], str(choice), menu._xa[2])
示例#22
0
def _changestring_select(userid, choice, popupid):
    menu = popuplib.find(popupid)
    if menu:
        _setconfig_handle(userid, menu._xa[0], menu._xa[1], str(choice),
                          menu._xa[2])
示例#23
0
import es
示例#24
0
def _changesetting_select(userid,choice,popupid):
    menu = popuplib.find(popupid)
    module = menu._xa[0]
    variable = menu._xa[1]
    parent = menu._xa[2]
    if int(choice) == 1:
        _setconfig_handle(userid, module, variable, parent)
    elif int(choice) == 2:
        variable.set(variable._def)
        menu = _variableEditMenu(userid, module, variable, parent)
        menu.send(userid)
    elif (int(choice) > 2) and (int(choice) < 9):
        if menu._xatype == 'int':
            value = int(variable)
            if int(choice) == 3:
                variable.set(value+1)
            elif int(choice) == 4:
                variable.set(value-1)
            elif int(choice) == 5:
                variable.set(value+10)
            elif int(choice) == 6:
                variable.set(value-10)
            elif int(choice) == 7:
                variable.set(value+100)
            elif int(choice) == 8:
                variable.set(value-100)
            menu = _variableEditMenu(userid, module, variable, parent)
            menu.send(userid)
        elif menu._xatype == 'float':
            value = float(variable)
            if int(choice) == 3:
                variable.set(value+0.1)
            elif int(choice) == 4:
                variable.set(value-0.1)
            elif int(choice) == 5:
                variable.set(value+1.0)
            elif int(choice) == 6:
                variable.set(value-1.0)
            elif int(choice) == 7:
                variable.set(value+10.0)
            elif int(choice) == 8:
                variable.set(value-10.0)
            menu = _variableEditMenu(userid, module, variable, parent)
            menu.send(userid)
        else:
            popuplib.send(popupid, userid)
    elif int(choice) == 9:
        xaconfig.setting.writeConfiguration()
        parent = popuplib.find(parent)
        if str(module) != 'core':
            newparent = _variableListMenu(userid, module, str(parent._xa[1]))
        else:
            newparent = _variableCoreListMenu(userid, str(parent._xa[1]))
        newparent.send(userid)
    else:
        parent = popuplib.find(parent)
        if str(module) != 'core':
            newparent = _variableListMenu(userid, module, str(parent._xa[1]))
        else:
            newparent = _variableCoreListMenu(userid, str(parent._xa[1]))
        newparent.send(userid)
示例#25
0
 def __init__(self, setting, method, texts):
     self.name = str(setting)
     self.texts = dict(texts)
     self.method = method
     xasettingmenu = popuplib.find("xasettingmenu")
     xasettingmenu.addoption(setting, self.texts)
示例#26
0
import es
示例#27
0
 def __init__(self, setting, method, texts):
     self.name = str(setting)
     self.texts = dict(texts)
     self.method = method
     xasettingmenu = popuplib.find("xasettingmenu")
     xasettingmenu.addoption(setting, self.texts)
示例#28
0
import es
示例#29
0
import es
示例#30
0
def _changesetting_select(userid, choice, popupid):
    menu = popuplib.find(popupid)
    module = menu._xa[0]
    variable = menu._xa[1]
    parent = menu._xa[2]
    if int(choice) == 1:
        _setconfig_handle(userid, module, variable, parent)
    elif int(choice) == 2:
        variable.set(variable._def)
        menu = _variableEditMenu(userid, module, variable, parent)
        menu.send(userid)
    elif (int(choice) > 2) and (int(choice) < 9):
        if menu._xatype == 'int':
            value = int(variable)
            if int(choice) == 3:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value + 1))
                variable.set(value + 1)
            elif int(choice) == 4:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value - 1))
                variable.set(value - 1)
            elif int(choice) == 5:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value + 10))
                variable.set(value + 10)
            elif int(choice) == 6:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value - 10))
                variable.set(value - 10)
            elif int(choice) == 7:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value + 100))
                variable.set(value + 100)
            elif int(choice) == 8:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value - 100))
                variable.set(value - 100)
            menu = _variableEditMenu(userid, module, variable, parent)
            menu.send(userid)
        elif menu._xatype == 'float':
            value = float(variable)
            if int(choice) == 3:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value + 0.1))
                variable.set(value + 0.1)
            elif int(choice) == 4:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value - 0.1))
                variable.set(value - 0.1)
            elif int(choice) == 5:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value + 1.0))
                variable.set(value + 1.0)
            elif int(choice) == 6:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value - 1.0))
                variable.set(value - 1.0)
            elif int(choice) == 7:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value + 10.0))
                variable.set(value + 10.0)
            elif int(choice) == 8:
                xaconfig.logging.log(
                    "Admin %s just changed config %s from %s to %s" %
                    (es.getplayername(userid), variable.getName(), value,
                     value - 10.0))
                variable.set(value - 10.0)
            menu = _variableEditMenu(userid, module, variable, parent)
            menu.send(userid)
        else:
            popuplib.send(popupid, userid)
    elif int(choice) == 9:
        xaconfig.setting.writeConfiguration()
        parent = popuplib.find(parent)
        if str(module) != 'core':
            newparent = _variableListMenu(userid, module, str(parent._xa[1]))
        else:
            newparent = _variableCoreListMenu(userid, str(parent._xa[1]))
        newparent.send(userid)
    else:
        parent = popuplib.find(parent)
        if str(module) != 'core':
            newparent = _variableListMenu(userid, module, str(parent._xa[1]))
        else:
            newparent = _variableCoreListMenu(userid, str(parent._xa[1]))
        newparent.send(userid)