def toolTip(self, button, dummyTile): """decorate the action button which will send this message""" maySay = button.client.sayable[self] if not maySay: return '', False, '' myself = button.client.game.myself txt = [] warn = False if myself.originalCall and myself.mayWin: warn = True txt.append(m18n('saying Kong for %1 violates Original Call', Meld.tileName(maySay[0]))) if not txt: txt = [m18n('You may say Kong for %1', Meld.tileName(maySay[0][0]))] return '<br><br>'.join(txt), warn, ''
def toolTip(self, button, dummyTile): """decorate the action button which will send this message""" maySay = button.client.sayable[self] if not maySay: return '', False, '' myself = button.client.game.myself txt = [] warn = False if myself.originalCall and myself.mayWin: warn = True txt.append(m18n('saying %1 violates Original Call', self.i18nName)) dangerousMelds = button.client.maybeDangerous(self) if dangerousMelds: lastDiscardName = Meld.tileName(button.client.game.lastDiscard.element) warn = True if Debug.dangerousGame and len(dangerousMelds) != len(maySay): button.client.game.debug('only some claimable melds are dangerous: %s' % dangerousMelds) if len(dangerousMelds) == 1: txt.append(m18n( 'claiming %1 is dangerous because you will have to discard a dangerous tile', lastDiscardName)) else: for meld in dangerousMelds: txt.append(m18n( 'claiming %1 for %2 is dangerous because you will have to discard a dangerous tile', lastDiscardName, str(meld))) if not txt: txt = [m18n('You may say %1', self.i18nName)] return '<br><br>'.join(txt), warn, ''
def toolTip(self, button, tile): """decorate the action button which will send this message""" game = button.client.game myself = game.myself txt = [] warn = False if myself.violatesOriginalCall(tile): txt.append(m18n('discarding %1 violates Original Call', Meld.tileName(tile.element))) warn = True if game.dangerousFor(myself, tile): txt.append(m18n('discarding %1 is Dangerous Game', Meld.tileName(tile.element))) warn = True if not txt: txt = [m18n('discard the least useful tile')] txt = '<br><br>'.join(txt) return txt, warn, txt
def speak(what): """this is what the user of this module will call.""" if not Sound.enabled: return game = Internal.field.game reactor = Internal.reactor if game and not game.autoPlay and Sound.playProcesses: # in normal play, wait a moment between two speaks. Otherwise # sometimes too many simultaneous speaks make them ununderstandable lastSpeakStart = max(x.startTime for x in Sound.playProcesses) if datetime.datetime.now() - lastSpeakStart < datetime.timedelta( seconds=0.3): reactor.callLater(1, Sound.speak, what) return if os.path.exists(what): if Sound.findOgg(): if os.name == 'nt': name, ext = os.path.splitext(what) assert ext == '.ogg' wavName = name + '.wav' if not os.path.exists(wavName): args = [r'c:\vorbis\oggdec', '--quiet', what] process = subprocess.Popen(args) os.waitpid(process.pid, 0) winsound.PlaySound(wavName, winsound.SND_FILENAME) else: args = ['ogg123', '-q', what] if Debug.sound: game.debug(' '.join(args)) process = subprocess.Popen(args) process.startTime = datetime.datetime.now() process.name = what Sound.playProcesses.append(process) reactor.callLater(3, Sound.cleanProcesses) reactor.callLater(6, Sound.cleanProcesses) elif False: text = os.path.basename(what) text = os.path.splitext(text)[0] # If this ever works, we need to translate all texts # we need package jovie and mbrola voices # KSpeech setLanguage de # KSpeech.showManagerDialog lets me define voices but # how do I use them? it is always the same voice, # setDefaultTalker "namefrommanager" does not change anything # although defaultTalker returns what we just set even if no talker # with that name exists # getTalkerCodes returns nothing # this all feels immature if len(text) == 2 and text[0] in 'sdbcw': text = Meld.tileName(text) args = ['qdbus', 'org.kde.jovie', '/KSpeech', 'say', text, '1'] subprocess.Popen(args)
def speak(what): """this is what the user of this module will call.""" if not Sound.enabled: return game = Internal.field.game reactor = Internal.reactor if game and not game.autoPlay and Sound.playProcesses: # in normal play, wait a moment between two speaks. Otherwise # sometimes too many simultaneous speaks make them ununderstandable lastSpeakStart = max(x.startTime for x in Sound.playProcesses) if datetime.datetime.now() - lastSpeakStart < datetime.timedelta(seconds=0.3): reactor.callLater(1, Sound.speak, what) return if os.path.exists(what): if Sound.findOgg(): if os.name == 'nt': name, ext = os.path.splitext(what) assert ext == '.ogg' wavName = name + '.wav' if not os.path.exists(wavName): args = [r'c:\vorbis\oggdec', '--quiet', what] process = subprocess.Popen(args) os.waitpid(process.pid, 0) winsound.PlaySound(wavName, winsound.SND_FILENAME) else: args = ['ogg123', '-q', what] if Debug.sound: game.debug(' '.join(args)) process = subprocess.Popen(args) process.startTime = datetime.datetime.now() process.name = what Sound.playProcesses.append(process) reactor.callLater(3, Sound.cleanProcesses) reactor.callLater(6, Sound.cleanProcesses) elif False: text = os.path.basename(what) text = os.path.splitext(text)[0] # If this ever works, we need to translate all texts # we need package jovie and mbrola voices # KSpeech setLanguage de # KSpeech.showManagerDialog lets me define voices but # how do I use them? it is always the same voice, # setDefaultTalker "namefrommanager" does not change anything # although defaultTalker returns what we just set even if no talker # with that name exists # getTalkerCodes returns nothing # this all feels immature if len(text) == 2 and text[0] in 'sdbcw': text = Meld.tileName(text) args = ['qdbus', 'org.kde.jovie', '/KSpeech', 'say', text, '1'] subprocess.Popen(args)
def toolTip(self, button, tile): """decorate the action button which will send this message""" myself = button.client.game.myself isCalling = bool((myself.hand - tile.element).callingHands()) if not isCalling: txt = m18n('discarding %1 and declaring Original Call makes this hand unwinnable', Meld.tileName(tile.element)) return txt, True, txt else: return (m18n( 'Discard a tile, declaring Original Call meaning you need only one ' 'tile to complete the hand and will not alter the hand in any way (except bonus tiles)'), False, '')
def __init__(self, kongs, deferred): DialogIgnoringEscape.__init__(self) self.setWindowTitle('Kajongg') self.kongs = kongs self.selectedKong = None self.deferred = deferred layout = QVBoxLayout(self) layout.addWidget(QLabel(m18n('Which kong do you want to declare?'))) self.buttons = [] for kong in kongs: button = QRadioButton(Meld.tileName(kong[0]), self) self.buttons.append(button) layout.addWidget(button) button.toggled.connect(self.toggled)