本文整理汇总了Python中clientmenu.Menu类的典型用法代码示例。如果您正苦于以下问题:Python Menu类的具体用法?Python Menu怎么用?Python Menu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Menu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main(self):
single_player_menu = Menu([4030],
[(c.title, c) for c in campaigns()] +
[
([4055], self.training_menu),
([4113], self.restore_game),
([4118], END_LOOP),
])
server_menu = Menu([4043], [
([4044, 4045], (start_server_and_connect, "admin_only")),
([4046, 4047], (start_server_and_connect, "")),
([4121, 4122], (start_server_and_connect,
"admin_only no_metaserver")),
([4048], None),
])
options_menu = Menu([4086], [
([4087], self.modify_login),
([4319], self.modify_default_mods),
[[4323], self.manage_packages],
([4118], END_LOOP),
])
main_menu = Menu([4029, 4030], [
[[4031, 4032], single_player_menu.loop],
[[4033, 4034], self.multiplayer_menu],
[[4035, 4036], server_menu],
[[4315], self.replay_menu],
[[4037, 4038], options_menu.loop],
[[4041, 4042], END_LOOP],
])
if "connect_localhost" in sys.argv:
connect_and_play()
else:
main_menu.loop()
示例2: manage_packages
def manage_packages(self):
def add():
menu = Menu([4325])
for p in get_packages():
if not p.is_active:
menu.append([p.name], (p.add, voice))
menu.append([4118], None)
menu.run()
def deactivate():
menu = Menu([4326])
for p in get_packages():
if p.is_active:
menu.append([p.name], p.deactivate)
menu.append([4118], None)
menu.run()
def update():
menu = Menu([4327])
for p in get_packages():
if p.is_active:
menu.append([p.name], (p.update, voice))
menu.append([4118], None)
menu.run()
menu = Menu([4324], [
([4325], add),
([4326], deactivate),
([4327], update),
([4076], END_LOOP),
])
menu.loop()
reload_all()
示例3: multiplayer_menu
def multiplayer_menu():
if config.login == "player":
voice.alert(mp.ENTER_NEW_LOGIN)
modify_login()
menu = Menu(mp.MAKE_A_SELECTION, [
(mp.CHOOSE_SERVER_IN_LIST, choose_server_ip_in_a_list),
(mp.ENTER_SERVER_IP, enter_server_ip),
(mp.CANCEL, None),
])
menu.run()
示例4: multiplayer_menu
def multiplayer_menu(self):
revision_checker.start_if_needed()
if config.login == "player":
voice.alert([4235]) # type your new login
self.modify_login()
menu = Menu([4030], [
([4119], self.choose_server_ip_in_a_list),
([4120], self.enter_server_ip),
([4048], None),
])
menu.run()
示例5: mods_menu
def mods_menu():
mods_menu = Menu(mp.MODS)
mods_menu.append([0], (set_and_launch_mod, ""))
for mod in res.available_mods():
mods_menu.append([mod], (set_and_launch_mod, mod))
mods_menu.append(mp.BACK, CLOSE_MENU)
mods_menu.run()
return CLOSE_MENU
示例6: mods_menu
def mods_menu():
mods_menu = Menu(["Mods"])
mods_menu.append([0], (set_and_launch_mod, ""))
for mod in res.available_mods():
mods_menu.append([mod], (set_and_launch_mod, mod))
mods_menu.append([4118], END_LOOP)
mods_menu.run()
return END_LOOP
示例7: soundpacks_menu
def soundpacks_menu():
soundpacks_menu = Menu(["Soundpacks"])
soundpacks_menu.append([0], (set_and_launch_soundpack, ""))
for soundpack in res.available_soundpacks():
soundpacks_menu.append([soundpack], (set_and_launch_soundpack, soundpack))
soundpacks_menu.append([4118], END_LOOP)
soundpacks_menu.run()
return END_LOOP
示例8: soundpacks_menu
def soundpacks_menu():
soundpacks_menu = Menu(mp.SOUNDPACKS)
soundpacks_menu.append(mp.NOTHING, (set_and_launch_soundpack, ""))
for soundpack in res.available_soundpacks():
soundpacks_menu.append([soundpack],
(set_and_launch_soundpack, soundpack))
soundpacks_menu.append(mp.BACK, CLOSE_MENU)
soundpacks_menu.run()
return CLOSE_MENU
示例9: choose_server_ip_in_a_list
def choose_server_ip_in_a_list(self):
servers_list = None
try:
f = urllib.urlopen(SERVERS_LIST_URL)
if f.read(len(SERVERS_LIST_HEADER)) == SERVERS_LIST_HEADER:
servers_list = f.readlines()
except:
pass
if servers_list is None:
voice.alert([1029]) # hostile sound
warning("couldn't get the servers list from the metaserver"
" => using the default servers list")
servers_list = DEFAULT_SERVERS
nb = 0
menu = Menu()
for s in servers_list:
try:
ip, version, login, port = s.split()[1:]
# ignore the first parameter (time)
except:
warning("line not recognized from the metaserver: %s", s)
continue
nb += 1
if version == VERSION:
menu.append([login, 4073, login], (connect_and_play, ip, port))
menu.title = nb2msg(len(menu.choices)) + [4078] + nb2msg(nb) + [4079]
menu.append([4075, 4076], None)
menu.run()
示例10: build_training_menu_after_map
def build_training_menu_after_map(self):
menu = Menu()
if len(self.players) < self.map.nb_players_max:
menu.append([4058, 4258], (self.training_menu_invite, "easy"))
menu.append([4058, 4257], (self.training_menu_invite,
"aggressive"))
if len(self.players) >= self.map.nb_players_min:
menu.append([4059], self.start_training_game)
for pn, (p, pr) in enumerate(zip(self.players, self.factions)):
self._add_faction_menu(menu, pn, p, pr)
menu.append([4048, 4060], END_LOOP)
return menu
示例11: make_menu
def make_menu(self):
menu = Menu()
for g in self.invitations:
menu.append([4053] + g[1:], (self.server.write_line, "register %s" % g[0]))
menu.append([4055], self._get_creation_submenu())
menu.append([4041], (self.server.write_line, "quit"))
return menu
示例12: replay_menu
def replay_menu(self):
menu = Menu([4315])
for n in sorted(os.listdir(REPLAYS_PATH), reverse=True):
if n.endswith(".txt"):
menu.append([time.strftime("%c", time.localtime(int(n[:-4])))], (self.replay, n))
menu.append([4041], None)
menu.run()
示例13: update
def update():
menu = Menu([4327])
for p in get_packages():
if p.is_active:
menu.append([p.name], (p.update, voice))
menu.append([4118], None)
menu.run()
示例14: deactivate
def deactivate():
menu = Menu([4326])
for p in get_packages():
if p.is_active:
menu.append([p.name], p.deactivate)
menu.append([4118], None)
menu.run()
示例15: add
def add():
menu = Menu([4325])
for p in get_packages():
if not p.is_active:
menu.append([p.name], (p.add, voice))
menu.append([4118], None)
menu.run()