def modename2display(modename): from gamepack import gamemodes gcls = gamemodes.get(modename) if not gcls: return u'未知模式' else: return gcls.ui_meta.name
def on_message(self, _type, *args): if _type == 'current_games': from gamepack import gamemodes as modes current_games = args[0] glist = self.gamelist glist.clear() for gi in current_games: gcls = modes.get(gi['type'], None) if gcls: gname = gcls.ui_meta.name n_persons = gcls.n_persons else: gname = u'未知游戏类型' n_persons = 0 li = glist.append([ gi['id'], gi['name'], gname, '%d/%d' % ( gi['nplayers'], n_persons, ), [u'等待中', u'游戏中'][gi['started']] ], color=(0, 0, 0, 255) if gi['started'] else (0xef, 0x75, 0x45, 0xff)) li.game_id = gi['id'] li.started = gi['started']
def on_message(self, _type, *args): if _type == "current_games": from gamepack import gamemodes as modes current_games = args[0] glist = self.gamelist glist.clear() for gi in current_games: gcls = modes.get(gi["type"], None) if gcls: gname = gcls.ui_meta.name n_persons = gcls.n_persons else: gname = u"未知游戏类型" n_persons = 0 li = glist.append( [ gi["id"], gi["name"], gname, "%d/%d" % (gi["nplayers"], n_persons), [u"等待中", u"游戏中"][gi["started"]], ], color=(0, 0, 0, 255) if gi["started"] else (0xEF, 0x75, 0x45, 0xFF), ) li.game_id = gi["id"] li.started = gi["started"]
def on_message(self, _type, *args): if _type == "server_dropped": ConfirmBox(u"已经与服务器断开链接,请重新启动游戏!", parent=Screen.cur_overlay) elif _type == "invite_request": uid, uname, gid, gtype = args[0] from gamepack import gamemodes as modes gtype = modes.get(gtype, None) gtype = gtype and gtype.ui_meta.name invite_text = u"%s 邀请你一起玩 %s 模式" % (uname, gtype) from utils import notify notify(u"东方符斗祭 - 邀请提醒", invite_text) box = ConfirmBox(invite_text, parent=self, buttons=((u"确定", True), (u"取消", False)), default=False) @box.event def on_confirm(val, uid=uid): Executive.call("invite_grant", ui_message, [gid, val]) else: Overlay.on_message(self, _type, *args)
def on_message(self, _type, *args): if _type == 'server_dropped': ConfirmBox(u'已经与服务器断开链接,请重新启动游戏!', parent=Screen.cur_overlay) elif _type == 'invite_request': uid, uname, gid, gtype = args[0] from gamepack import gamemodes as modes gtype = modes.get(gtype, None) gtype = gtype and gtype.ui_meta.name invite_text = u'%s 邀请你一起玩 %s 模式' % (uname, gtype) from utils import notify notify(u'东方符斗祭 - 邀请提醒', invite_text) box = ConfirmBox( invite_text, parent=self, buttons=((u'确定', True), (u'取消', False)), default=False ) @box.event def on_confirm(val, uid=uid): Executive.call('invite_grant', ui_message, [gid, val]) else: Overlay.on_message(self, _type, *args)