本文整理汇总了Python中system.makemenus.MakeMenu.sort方法的典型用法代码示例。如果您正苦于以下问题:Python MakeMenu.sort方法的具体用法?Python MakeMenu.sort怎么用?Python MakeMenu.sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类system.makemenus.MakeMenu
的用法示例。
在下文中一共展示了MakeMenu.sort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateGoMenu
# 需要导入模块: from system.makemenus import MakeMenu [as 别名]
# 或者: from system.makemenus.MakeMenu import sort [as 别名]
def generateGoMenu():
locations = wolfpack.getdefinitions(WPDT_LOCATION)
gomenu = MakeMenu("GOMENU", None, "Go Menu")
submenus = {}
for location in locations:
if not location.hasattribute("category"):
continue
categories = location.getattribute("category").split("\\")
description = categories[len(categories) - 1] # Name of the action
categories = categories[: len(categories) - 1]
# Iterate trough the categories and see if they're all there
category = ""
if len(categories) > 0 and not submenus.has_key("\\".join(categories) + "\\"):
for subcategory in categories:
if not submenus.has_key(category + subcategory + "\\"):
# Category is our parent category
parent = None
if len(category) == 0:
parent = gomenu
elif category in submenus:
parent = submenus[category]
category += subcategory + "\\"
menu = MakeMenu("GOMENU_" + category, parent, subcategory)
submenus[category] = menu
else:
category += subcategory + "\\"
# Parse the position of this makemenu entry
if location.text.count(",") != 3:
raise RuntimeError, "Wrong position information for location %s." % location.getattribute("id")
(x, y, z, map) = location.text.split(",")
pos = wolfpack.coord(int(x), int(y), int(z), int(map))
if len(categories) == 0:
GoAction(gomenu, description, pos)
else:
GoAction(submenus["\\".join(categories) + "\\"], description, pos)
for menu in submenus.values():
menu.sort()
gomenu.sort()
return
示例2: generateGoMenu
# 需要导入模块: from system.makemenus import MakeMenu [as 别名]
# 或者: from system.makemenus.MakeMenu import sort [as 别名]
def generateGoMenu():
locations = wolfpack.getdefinitions(WPDT_LOCATION)
gomenu = MakeMenu('GOMENU', None, 'Go Menu')
submenus = {}
for location in locations:
if not location.hasattribute('category'):
continue
categories = location.getattribute('category').split('\\')
description = categories[len(categories)-1] # Name of the action
categories = categories[:len(categories)-1]
# Iterate trough the categories and see if they're all there
category = ''
if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'):
for subcategory in categories:
if not submenus.has_key(category + subcategory + '\\'):
# Category is our parent category
parent = None
if len(category) == 0:
parent = gomenu
elif submenus.has_key(category):
parent = submenus[category]
category += subcategory + '\\'
menu = MakeMenu('GOMENU_' + category, parent, subcategory)
submenus[category] = menu
else:
category += subcategory + '\\'
# Parse the position of this makemenu entry
if location.text.count(',') != 3:
raise RuntimeError, "Wrong position information for location %s." % location.getattribute('id')
(x, y, z, map) = location.text.split(',')
pos = wolfpack.coord(int(x), int(y), int(z), int(map))
if len(categories) == 0:
GoAction(gomenu, description, pos)
else:
GoAction(submenus['\\'.join(categories) + '\\'], description, pos)
for menu in submenus.values():
menu.sort()
gomenu.sort()
示例3: generateAddMenu
# 需要导入模块: from system.makemenus import MakeMenu [as 别名]
# 或者: from system.makemenus.MakeMenu import sort [as 别名]
def generateAddMenu():
items = wolfpack.getdefinitions(WPDT_ITEM)
addmenu= MakeMenu('ADDMENU', None, 'Add Menu')
submenus = {}
for item in items:
if not item.hasattribute('id'):
continue
child = item.findchild('category')
if not child:
continue
categories = ['Items'] + child.text.split('\\')
description = categories[len(categories)-1] # Name of the action
categories = categories[:len(categories)-1]
# Iterate trough the categories and see if they're all there
category = ''
if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'):
for subcategory in categories:
if not submenus.has_key(category + subcategory + '\\'):
# Category is our parent category
parent = None
if len(category) == 0:
parent = addmenu
elif submenus.has_key(category):
parent = submenus[category]
category += subcategory + '\\'
menu = MakeMenu('ADDMENU_' + category, parent, subcategory)
submenus[category] = menu
else:
category += subcategory + '\\'
child = item.findchild('id')
if child:
try:
id = int(child.value)
except:
id = 0
else:
id = 0
definition = item.getattribute('id')
# Parse the position of this makemenu entry
if len(categories) == 0:
additem = AddItemAction(addmenu, description, id, definition)
else:
additem = AddItemAction(submenus['\\'.join(categories) + '\\'], description, id, definition)
additem.description = 'Definition: ' + definition
for menu in submenus.values():
menu.sort()
npcs = wolfpack.getdefinitions(WPDT_NPC)
submenus = {}
for npc in npcs:
if not npc.hasattribute('id'):
continue
child = npc.findchild('category')
if not child:
continue
categories = ['NPCs'] + child.text.split('\\')
description = categories[len(categories)-1] # Name of the action
categories = categories[:len(categories)-1]
# Iterate trough the categories and see if they're all there
category = ''
if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'):
for subcategory in categories:
if not submenus.has_key(category + subcategory + '\\'):
# Category is our parent category
parent = None
if len(category) == 0:
parent = addmenu
elif submenus.has_key(category):
parent = submenus[category]
category += subcategory + '\\'
menu = MakeMenu('ADDMENU_' + category, parent, subcategory)
submenus[category] = menu
else:
category += subcategory + '\\'
definition = npc.getattribute('id')
# Parse the position of this makemenu entry
if len(categories) == 0:
addnpc = AddNpcAction(addmenu, description, definition)
else:
addnpc = AddNpcAction(submenus['\\'.join(categories) + '\\'], description, definition)
addnpc.description = 'Definition: ' + definition
for menu in submenus.values():
menu.sort()
#.........这里部分代码省略.........
示例4: generateAddMenu
# 需要导入模块: from system.makemenus import MakeMenu [as 别名]
# 或者: from system.makemenus.MakeMenu import sort [as 别名]
def generateAddMenu(serial=0, items=None):
char = wolfpack.findchar(serial)
if not char or not char.socket:
char = None
"""if not items:
items = wolfpack.getdefinitions(WPDT_ITEM)
if char:
char.socket.sysmessage('Done getting list of definitions.')
wolfpack.queuecode(generateAddMenu, (serial, items))
return"""
addmenu = MakeMenu("ADDMENU", None, "Add Menu")
submenus = {}
# Process 100 at a time
definitions = wolfpack.definitionsiterator(WPDT_ITEM)
item = definitions.first
while item:
if not item.hasattribute("id"):
item = definitions.next
continue
child = item.findchild("category")
if not child:
item = definitions.next
continue
categories = ["Items"] + child.text.split("\\")
description = categories[len(categories) - 1] # Name of the action
categories = categories[: len(categories) - 1]
# Iterate trough the categories and see if they're all there
category = ""
if len(categories) > 0 and not submenus.has_key("\\".join(categories) + "\\"):
for subcategory in categories:
if not submenus.has_key(category + subcategory + "\\"):
# Category is our parent category
parent = None
if len(category) == 0:
parent = addmenu
elif category in submenus:
parent = submenus[category]
category += subcategory + "\\"
menu = MakeMenu("ADDMENU_" + category, parent, subcategory)
submenus[category] = menu
else:
category += subcategory + "\\"
child = item.findchild("id")
if child:
try:
id = int(child.value)
except:
id = 0
else:
id = 0
definition = item.getattribute("id")
# Parse the position of this makemenu entry
if len(categories) == 0:
additem = AddItemAction(addmenu, description, id, definition)
else:
additem = AddItemAction(submenus["\\".join(categories) + "\\"], description, id, definition)
additem.otherhtml = "Definition: " + definition
item = definitions.next
for menu in submenus.values():
menu.sort()
npcs = wolfpack.definitionsiterator(WPDT_NPC)
submenus = {}
npc = npcs.first
while npc:
if not npc.hasattribute("id"):
npc = npcs.next
continue
child = npc.findchild("category")
if not child:
npc = npcs.next
continue
id = npc.findchild("id")
if id:
try:
if id.value.startswith("0x"):
id = wolfpack.bodyinfo(hex2dec(id.value))["figurine"]
else:
id = wolfpack.bodyinfo(int(id.value))["figurine"]
except:
id = 0
else:
id = 0
description = npc.findchild("desc")
if description:
description = description.value
#.........这里部分代码省略.........
示例5: generateAddMenu
# 需要导入模块: from system.makemenus import MakeMenu [as 别名]
# 或者: from system.makemenus.MakeMenu import sort [as 别名]
def generateAddMenu(serial = 0, items = None):
char = wolfpack.findchar(serial)
if not char or not char.socket:
char = None
"""if not items:
items = wolfpack.getdefinitions(WPDT_ITEM)
if char:
char.socket.sysmessage('Done getting list of definitions.')
wolfpack.queuecode(generateAddMenu, (serial, items))
return"""
addmenu= MakeMenu('ADDMENU', None, 'Add Menu')
submenus = {}
# Process 100 at a time
definitions = wolfpack.definitionsiterator(WPDT_ITEM)
item = definitions.first
while item:
if not item.hasattribute('id'):
item = definitions.next
continue
child = item.findchild('category')
if not child:
item = definitions.next
continue
categories = ['Items'] + child.text.split('\\')
description = categories[len(categories)-1] # Name of the action
categories = categories[:len(categories)-1]
# Iterate trough the categories and see if they're all there
category = ''
if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'):
for subcategory in categories:
if not submenus.has_key(category + subcategory + '\\'):
# Category is our parent category
parent = None
if len(category) == 0:
parent = addmenu
elif submenus.has_key(category):
parent = submenus[category]
category += subcategory + '\\'
menu = MakeMenu('ADDMENU_' + category, parent, subcategory)
submenus[category] = menu
else:
category += subcategory + '\\'
child = item.findchild('id')
if child:
try:
id = int(child.value)
except:
id = 0
else:
id = 0
definition = item.getattribute('id')
# Parse the position of this makemenu entry
if len(categories) == 0:
additem = AddItemAction(addmenu, description, id, definition)
else:
additem = AddItemAction(submenus['\\'.join(categories) + '\\'], description, id, definition)
additem.description = 'Definition: ' + definition
item = definitions.next
for menu in submenus.values():
menu.sort()
npcs = wolfpack.definitionsiterator(WPDT_NPC)
submenus = {}
npc = npcs.first
while npc:
if not npc.hasattribute('id'):
npc = npcs.next
continue
child = npc.findchild('category')
if not child:
npc = npcs.next
continue
categories = ['NPCs'] + child.text.split('\\')
description = categories[len(categories)-1] # Name of the action
categories = categories[:len(categories)-1]
# Iterate trough the categories and see if they're all there
category = ''
if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'):
for subcategory in categories:
if not submenus.has_key(category + subcategory + '\\'):
# Category is our parent category
parent = None
if len(category) == 0:
parent = addmenu
elif submenus.has_key(category):
parent = submenus[category]
#.........这里部分代码省略.........