本文整理汇总了Python中Scene.SceneClient.keyPressed方法的典型用法代码示例。如果您正苦于以下问题:Python SceneClient.keyPressed方法的具体用法?Python SceneClient.keyPressed怎么用?Python SceneClient.keyPressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene.SceneClient
的用法示例。
在下文中一共展示了SceneClient.keyPressed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyPressed
# 需要导入模块: from Scene import SceneClient [as 别名]
# 或者: from Scene.SceneClient import keyPressed [as 别名]
def keyPressed(self, key, unicode):
ret = SceneClient.keyPressed(self, key, unicode)
c = self.controls.keyPressed(key)
if self.song and (c in [Player.KEY1, Player.KEY2, Player.CANCEL, Player.ACTION1, Player.ACTION2] or key == pygame.K_RETURN):
scores = self.song.info.getHighscores(self.player.difficulty)
if not scores or self.player.score > scores[-1][0] or len(scores) < 5:
if self.player.cheating:
Dialogs.showMessage(self.engine, _("No highscores for cheaters!"))
else:
name = Dialogs.getText(self.engine, _("%d points is a new high score! Please enter your name:") % self.player.score, self.player.name)
if name:
self.player.name = name
self.highscoreIndex = self.song.info.addHighscore(self.player.difficulty, self.player.score, self.stars, self.player.name)
self.song.info.save()
if self.engine.config.get("game", "uploadscores"):
self.uploadingScores = True
fn = lambda: self.song.info.uploadHighscores(self.engine.config.get("game", "uploadurl"), self.song.getHash())
self.engine.resource.load(self, "uploadResult", fn)
self.showHighscores = True
self.engine.view.pushLayer(self.menu)
return True
return ret
示例2: keyPressed
# 需要导入模块: from Scene import SceneClient [as 别名]
# 或者: from Scene.SceneClient import keyPressed [as 别名]
def keyPressed(self, key, unicode):
ret = SceneClient.keyPressed(self, key, unicode)
c = self.controls.keyPressed(key)
if self.song and (c in [Player.KEY1, Player.KEY2, Player.CANCEL, Player.ACTION1, Player.ACTION2, Player.DRUM1A, Player.DRUM4A] or key == pygame.K_RETURN):
for i,player in enumerate(self.playerList):
scores = self.song.info.getHighscores(player.difficulty, part = player.part)
if not scores or player.score > scores[-1][0] or len(scores) < 5:
if player.cheating:
Dialogs.showMessage(self.engine, _("No highscores for cheaters!"))
elif player.score == 0: #trinidude4
Dialogs.showMessage(self.engine, _("No highscore")) #trinidude4
else:
#alarian name = Dialogs.getText(self.engine, _("%d points is a new high score! Player " + str(i+1) + " enter your name") % player.score, player.name)
name = Dialogs.getText(self.engine, _("%d points is a new high score! Enter your name") % player.score, player.name)
if name:
player.name = name
#myfingershurt: don't separate chords for drum part totals:
if player.part.text == "Drums":
notesTotal = len([1 for time, event in self.song.track[i].getAllEvents() if isinstance(event, Song.Note)])
else:
notesTotal = len(set(time for time, event in self.song.track[i].getAllEvents() if isinstance(event, Song.Note)))
modOptions1 = self.engine.config.getModOptions1(player.twoChord, 0)
modOptions2 = self.engine.config.getModOptions2()
scoreExt = (player.notesHit, notesTotal, player.longestStreak, Version.branchVersion(), modOptions1, modOptions2)
self.highscoreIndex[i] = self.song.info.addHighscore(player.difficulty, player.score, self.stars[i], player.name, part = player.part, scoreExt = scoreExt)
self.song.info.save()
if self.engine.config.get("game", "uploadscores") and not player.cheating:
self.uploadingScores = True
#myfingershurt: ensuring new SP highscore upload URL is used from Divra (set to default in gameengine.py)
# evilynux - New url starting 20080902
fn = lambda: self.song.info.uploadHighscores(self.engine.config.get("game", "uploadurl_w67_starpower"), self.song.getHash(), part = player.part)
self.engine.resource.load(self, "uploadResult", fn)
if len(self.playerList) > 1 and self.playerList[0].part == self.playerList[1].part and self.playerList[0].difficulty == self.playerList[1].difficulty and self.highscoreIndex[0] != -1 and self.highscoreIndex[1] != -1 and self.highscoreIndex[1] <= self.highscoreIndex[0]:
self.highscoreIndex[0] += 1
if self.song.info.count:
count = int(self.song.info.count)
else:
count = 0
count += 1
self.song.info.count = "%d" % count
self.song.info.save()
self.showHighscores = True
self.engine.view.pushLayer(self.menu)
return True
return ret
示例3: keyPressed
# 需要导入模块: from Scene import SceneClient [as 别名]
# 或者: from Scene.SceneClient import keyPressed [as 别名]
def keyPressed(self, key, unicode):
ret = SceneClient.keyPressed(self, key, unicode)
c = self.controls.keyPressed(key)
if self.song and (c in [Player.KEY1, Player.KEY2, Player.CANCEL, Player.ACTION1, Player.ACTION2] or key == pygame.K_RETURN):
for i,player in enumerate(self.playerList):
scores = self.song.info.getHighscores(player.difficulty, part = player.part)
if not scores or player.score > scores[-1][0] or len(scores) < 5:
if player.cheating:
Dialogs.showMessage(self.engine, _("No highscores for cheaters!"))
else:
name = Dialogs.getText(self.engine, _("%d points is a new high score! Player " + str(i+1) + " enter your name") % player.score, player.name)
if name:
player.name = name
notesTotal = len([1 for time, event in self.song.track[i].getAllEvents() if isinstance(event, Song.Note)])
modOptions1 = self.engine.config.getModOptions1(player.twoChord, 0)
modOptions2 = self.engine.config.getModOptions2()
scoreExt = (player.notesHit, notesTotal, player.longestStreak, Version.branchVersion(), modOptions1, modOptions2)
self.highscoreIndex[i] = self.song.info.addHighscore(player.difficulty, player.score, self.stars[i], player.name, part = player.part, scoreExt = scoreExt)
self.song.info.save()
if self.engine.config.get("game", "uploadscores"):
self.uploadingScores = True
fn = lambda: self.song.info.uploadHighscores(self.engine.config.get("game", "uploadurl"), self.song.getHash(), part = player.part)
self.engine.resource.load(self, "uploadResult", fn)
if len(self.playerList) > 1 and self.playerList[0].part == self.playerList[1].part and self.playerList[0].difficulty == self.playerList[1].difficulty and self.highscoreIndex[0] != None and self.highscoreIndex[1] != None and self.highscoreIndex[1] <= self.highscoreIndex[0]:
self.highscoreIndex[0] += 1
if self.song.info.count:
count = int(self.song.info.count)
else:
count = 0
count += 1
self.song.info.count = "%d" % count
self.song.info.save()
self.showHighscores = True
self.engine.view.pushLayer(self.menu)
return True
return ret