当前位置: 首页>>代码示例>>Python>>正文


Python Menu.loop方法代码示例

本文整理汇总了Python中clientmenu.Menu.loop方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.loop方法的具体用法?Python Menu.loop怎么用?Python Menu.loop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clientmenu.Menu的用法示例。


在下文中一共展示了Menu.loop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from clientmenu import Menu [as 别名]
# 或者: from clientmenu.Menu import loop [as 别名]
 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()
开发者ID:Pragmapragma,项目名称:soundrts,代码行数:35,代码来源:clientmain.py

示例2: manage_packages

# 需要导入模块: from clientmenu import Menu [as 别名]
# 或者: from clientmenu.Menu import loop [as 别名]
    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()
开发者ID:Pragmapragma,项目名称:soundrts,代码行数:36,代码来源:clientmain.py

示例3: modify_default_mods

# 需要导入模块: from clientmenu import Menu [as 别名]
# 或者: from clientmenu.Menu import loop [as 别名]
    def modify_default_mods(self):

        def available_mods():
            result = []
            for path in get_all_packages_paths():
                mods_path = os.path.join(path, "mods")
                for mod in os.listdir(mods_path):
                    if os.path.isdir(os.path.join(mods_path, mod)) \
                       and mod not in result and mod not in mods:
                        result.append(mod)
            return result

        def select_next_mod(parent):

            def add_mod(mod):
                if mod not in mods:
                    mods.append(mod)
                    parent.title = mods

            menu = Menu([4320] + mods)
            for mod in available_mods():
                menu.append([mod], (add_mod, mod))
            menu.append([4118], None)
            menu.run()

        def save():
            previous_mods = config.mods
            config.config_mods = ",".join(mods)
            config.mods = config.config_mods
            config.save()
            if config.mods != previous_mods:
                reload_all()
            return END_LOOP

        mods = []
        menu = Menu([4321]) # the list is empty
        menu.append([4320], (select_next_mod, menu))
        menu.append([4096], save)
        menu.append([4098], END_LOOP)
        menu.loop()
开发者ID:Pragmapragma,项目名称:soundrts,代码行数:42,代码来源:clientmain.py


注:本文中的clientmenu.Menu.loop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。