def __init__(self, title, menu=None): SCElement.__init__(self) self.title = title scGui = loader.loadModel(SCMenu.GuiModelName) self.scArrow = scGui.find('**/chatArrow') self.menu = None self.setMenu(menu)
def privSetSettingsRef(self, settingsRef): SCElement.privSetSettingsRef(self, settingsRef) if self._handleWhisperModeFC is None: self._handleWhisperModeFC = FunctionCall( self._handleWhisperModeSVChanged, self._handleWhisperModeSV) self._handleWhisperModeFC.pushCurrentState() self._handleWhisperModeSV.set(self.settingsRef is not None and not self.isWhisperable())
def __init__(self, linkedEmote=None): SCElement.__init__(self) self.setLinkedEmote(linkedEmote) scGui = loader.loadModel(SCMenu.GuiModelName) self.emotionIcon = scGui.find('**/emotionIcon') self.setDisabled(False) self.__numCharges = -1 self._handleWhisperModeSV = StateVar(False) self._handleWhisperModeFC = None
def enterActive(self): SCElement.enterActive(self) self.showMenu() if hasattr(self, 'button'): r, g, b = self.getColorScheme().getMenuHolderActiveColor() a = self.getColorScheme().getAlpha() self.button.frameStyle[DGG.BUTTON_READY_STATE].setColor(r, g, b, a) self.button.updateFrameStyle() else: self.notify.warning( 'SCMenuHolder has no button (has finalize been called?).')
def finalize(self, dbArgs={}): if not self.isDirty(): return r, g, b = self.getColorScheme().getArrowColor() a = self.getColorScheme().getAlpha() self.scArrow.setColorScale(r, g, b, a) if self.menu is not None: self.menu.setPos(self.getMenuOffset()) if self.isActive(): r, g, b = self.getColorScheme().getMenuHolderActiveColor() a = self.getColorScheme().getAlpha() frameColor = (r, g, b, a) else: frameColor = SCMenuHolder.DefaultFrameColor args = { 'image': self.scArrow, 'image_pos': (self.width - 0.5, 0, -self.height * 0.5), 'frameColor': frameColor } args.update(dbArgs) SCElement.finalize(self, dbArgs=args)
def enterVisible(self): SCElement.enterVisible(self) if hasattr(self, 'lastEmoteIconColor'): if self.getEmoteIconColor() != self.lastEmoteIconColor: self.invalidate() def handleWhisperModeChange(whisperMode, self=self): if self.hasLinkedEmote(): if self.isVisible() and not self.isWhispering(): self.updateEmoteIcon() self.accept(self.getEventName(SCWhisperModeChangeEvent), handleWhisperModeChange) def handleEmoteEnableStateChange(self=self): if self.hasLinkedEmote(): if self.isVisible() and not self.isWhispering(): self.updateEmoteIcon() if self.hasLinkedEmote(): if Emote.globalEmote: self.accept(Emote.globalEmote.EmoteEnableStateChanged, handleEmoteEnableStateChange)
def finalize(self, dbArgs={}): if not self.isDirty(): return args = {} if self.hasLinkedEmote(): self.lastEmoteIconColor = self.getEmoteIconColor() self.emotionIcon.setColorScale(*self.lastEmoteIconColor) args.update({ 'image': self.emotionIcon, 'image_pos': (self.width - 0.6, 0, -self.height * 0.5) }) if self.isDisabled(): args.update({ 'rolloverColor': (0, 0, 0, 0), 'pressedColor': (0, 0, 0, 0), 'rolloverSound': None, 'clickSound': None, 'text_fg': self.getColorScheme().getTextDisabledColor() + (1, ) }) args.update(dbArgs) SCElement.finalize(self, dbArgs=args)
def exitActive(self): SCElement.exitActive(self) self.hideMenu() self.button.frameStyle[DGG.BUTTON_READY_STATE].setColor( *SCMenuHolder.DefaultFrameColor) self.button.updateFrameStyle()
def onMouseClick(self, event): SCElement.enterActive(self) self.parentMenu.memberSelected(self)
def destroy(self): if self.menu is not None: self.menu.destroy() self.menu = None SCElement.destroy(self)
def invalidate(self): SCElement.invalidate(self) if self.menu is not None: self.menu.invalidate()
def getMinDimensions(self): width, height = SCElement.getMinDimensions(self) width += 1.0 return (width, height)
def getMinDimensions(self): width, height = SCElement.getMinDimensions(self) if self.hasLinkedEmote(): width += 1.3 return (width, height)
def onMouseClick(self, event): if not self.isDisabled(): SCElement.onMouseClick(self, event) self.handleSelect()
def destroy(self): self._handleWhisperModeSV.set(False) if self._handleWhisperModeFC: self._handleWhisperModeFC.destroy() self._handleWhisperModeSV.destroy() SCElement.destroy(self)
def exitVisible(self): SCElement.exitVisible(self) self.ignore(self.getEventName(SCWhisperModeChangeEvent)) if Emote.globalEmote: self.ignore(Emote.globalEmote.EmoteEnableStateChanged)