def enter(self, changeDisplaySettings, changeDisplayAPI): if self.isEntered == 1: return None self.isEntered = 1 if self.isLoaded == 0: self.load() self.applyDialog = None self.timeoutDialog = None self.restoreDialog = None self.revertDialog = None base.transitions.fadeScreen(0.5) properties = base.win.getProperties() self.screenSizeIndex = self.chooseClosestScreenSize(properties.getXSize(), properties.getYSize()) self.isFullscreen = properties.getFullscreen() if self.isCurrentlyEmbedded(): self.displayMode = self.EmbeddedMode elif self.isFullscreen: self.displayMode = self.FullscreenMode else: self.displayMode = self.WindowedMode self.updateApiMenu(changeDisplaySettings, changeDisplayAPI) self.updateWindowed() self.updateScreenSize() if changeDisplaySettings: self.introText.show() self.introTextSimple.hide() if changeDisplayAPI and len(self.apis) > 1: self.apiLabel.show() self.apiMenu.show() else: self.apiLabel.hide() self.apiMenu.hide() if DisplayOptions.isWindowedPossible(): self.c1b.show() self.windowedButton.show() else: self.c1b.hide() self.windowedButton.hide() self.c2b.show() self.fullscreenButton.show() if DisplayOptions.isEmbeddedPossible(): self.c3b.show() self.embeddedButton.show() else: self.c3b.hide() self.embeddedButton.hide() else: self.introText.hide() self.introTextSimple.show() self.apiLabel.hide() self.apiMenu.hide() self.windowedButton.hide() self.fullscreenButton.hide() self.c1b.hide() self.c2b.hide() self.c3b.hide() self.anyChanged = 0 self.apiChanged = 0 self.show() return
def __applyDone(self, command): self.applyDialog.cleanup() self.applyDialog = None self.setBin('gui-popup', 0) base.transitions.fadeScreen(0.5) if command != DGG.DIALOG_OK: return self.origPipe = base.pipe self.origProperties = base.win.getProperties() pipe = self.apiPipes[self.apiMenu.selectedIndex] properties = WindowProperties() xSize, ySize = self.screenSizes[self.screenSizeIndex] properties.setSize(xSize, ySize) properties.setFullscreen(self.displayMode == self.FullscreenMode) fullscreen = self.displayMode == self.FullscreenMode embedded = self.displayMode == self.EmbeddedMode if embedded: if DisplayOptions.isEmbeddedPossible(): pass else: self.notify.warning('how was the player able to choose embedded') embedded = False if not self.changeDisplayProperties(pipe, xSize, ySize, fullscreen, embedded): self.__revertBack(1) return self.clearBin() self.timeoutDialog = TTDialog.TTDialog(dialogName='DisplaySettingsTimeout', style=TTDialog.TwoChoice, text=TTLocalizer.DisplaySettingsAccept % self.ApplyTimeoutSeconds, text_wordwrap=15, command=self.__timeoutDone) self.timeoutDialog.setBin('gui-popup', 0) self.timeoutRemaining = self.ApplyTimeoutSeconds self.timeoutStart = None taskMgr.add(self.__timeoutCountdown, self.TimeoutCountdownTask) return
def _DisplaySettingsDialog__applyDone(self, command): self.applyDialog.cleanup() self.applyDialog = None self.setBin('gui-popup', 0) base.transitions.fadeScreen(0.5) if command != DGG.DIALOG_OK: return None self.origPipe = base.pipe self.origProperties = base.win.getProperties() pipe = self.apiPipes[self.apiMenu.selectedIndex] properties = WindowProperties() (xSize, ySize) = self.screenSizes[self.screenSizeIndex] properties.setSize(xSize, ySize) properties.setFullscreen(self.displayMode == self.FullscreenMode) fullscreen = self.displayMode == self.FullscreenMode embedded = self.displayMode == self.EmbeddedMode if embedded: if DisplayOptions.isEmbeddedPossible(): pass else: self.notify.warning('how was the player able to choose embedded') embedded = False if not self.changeDisplayProperties(pipe, xSize, ySize, fullscreen, embedded): self._DisplaySettingsDialog__revertBack(1) return None self.clearBin() self.timeoutDialog = TTDialog.TTDialog(dialogName = 'DisplaySettingsTimeout', style = TTDialog.TwoChoice, text = TTLocalizer.DisplaySettingsAccept % self.ApplyTimeoutSeconds, text_wordwrap = 15, command = self._DisplaySettingsDialog__timeoutDone) self.timeoutDialog.setBin('gui-popup', 0) self.timeoutRemaining = self.ApplyTimeoutSeconds self.timeoutStart = None taskMgr.add(self._DisplaySettingsDialog__timeoutCountdown, self.TimeoutCountdownTask)
def changeDisplayProperties(self, pipe, width, height, fullscreen = False, embedded = False): result = False self.notify.info('changeDisplayProperties') if embedded: if DisplayOptions.isEmbeddedPossible(): width = base.appRunner.windowProperties.getXSize() height = base.appRunner.windowProperties.getYSize() self.current_pipe = base.pipe self.current_properties = WindowProperties(base.win.getProperties()) properties = self.current_properties self.notify.debug('DISPLAY PREVIOUS:') self.notify.debug(' EMBEDDED: %s' % bool(properties.getParentWindow())) self.notify.debug(' FULLSCREEN: %s' % bool(properties.getFullscreen())) self.notify.debug(' X SIZE: %s' % properties.getXSize()) self.notify.debug(' Y SIZE: %s' % properties.getYSize()) self.notify.debug('DISPLAY REQUESTED:') self.notify.debug(' EMBEDDED: %s' % bool(embedded)) self.notify.debug(' FULLSCREEN: %s' % bool(fullscreen)) self.notify.debug(' X SIZE: %s' % width) self.notify.debug(' Y SIZE: %s' % height) if self.current_pipe == pipe and bool(self.current_properties.getParentWindow()) == bool(embedded) and self.current_properties.getFullscreen() == fullscreen and self.current_properties.getXSize() == width and self.current_properties.getYSize() == height: self.notify.info('DISPLAY NO CHANGE REQUIRED') state = True else: properties = WindowProperties() properties.setSize(width, height) properties.setFullscreen(fullscreen) properties.setParentWindow(0) if embedded: properties = base.appRunner.windowProperties original_sort = base.win.getSort() lastShader = base.cr.getLastShader() base.cr.useShader(None) if self.resetDisplayProperties(pipe, properties): self.notify.debug('DISPLAY CHANGE SET') properties = base.win.getProperties() self.notify.debug('DISPLAY ACHIEVED:') self.notify.debug(' EMBEDDED: %s' % bool(properties.getParentWindow())) self.notify.debug(' FULLSCREEN: %s' % bool(properties.getFullscreen())) self.notify.debug(' X SIZE: %s' % properties.getXSize()) self.notify.debug(' Y SIZE: %s' % properties.getYSize()) if bool(properties.getParentWindow()) == bool(embedded) and properties.getFullscreen() == fullscreen and properties.getXSize() == width and properties.getYSize() == height: self.notify.info('DISPLAY CHANGE VERIFIED') result = True else: self.notify.warning('DISPLAY CHANGE FAILED, RESTORING PREVIOUS DISPLAY') else: self.notify.warning('DISPLAY CHANGE FAILED') base.cr.useShader(lastShader) base.win.setSort(original_sort) base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() return result
def changeDisplayProperties(self, pipe, width, height, fullscreen = False, embedded = False): result = False self.notify.info('changeDisplayProperties') if embedded: if DisplayOptions.isEmbeddedPossible(): width = base.appRunner.windowProperties.getXSize() height = base.appRunner.windowProperties.getYSize() self.current_pipe = base.pipe self.current_properties = WindowProperties(base.win.getProperties()) properties = self.current_properties self.notify.debug('DISPLAY PREVIOUS:') self.notify.debug(' EMBEDDED: %s' % bool(properties.getParentWindow())) self.notify.debug(' FULLSCREEN: %s' % bool(properties.getFullscreen())) self.notify.debug(' X SIZE: %s' % properties.getXSize()) self.notify.debug(' Y SIZE: %s' % properties.getYSize()) self.notify.debug('DISPLAY REQUESTED:') self.notify.debug(' EMBEDDED: %s' % bool(embedded)) self.notify.debug(' FULLSCREEN: %s' % bool(fullscreen)) self.notify.debug(' X SIZE: %s' % width) self.notify.debug(' Y SIZE: %s' % height) if self.current_pipe == pipe and bool(self.current_properties.getParentWindow()) == bool(embedded) and self.current_properties.getFullscreen() == fullscreen and self.current_properties.getXSize() == width and self.current_properties.getYSize() == height: self.notify.info('DISPLAY NO CHANGE REQUIRED') state = True else: properties = WindowProperties() properties.setSize(width, height) properties.setFullscreen(fullscreen) properties.setParentWindow(0) if embedded: properties = base.appRunner.windowProperties original_sort = base.win.getSort() if self.resetDisplayProperties(pipe, properties): self.notify.debug('DISPLAY CHANGE SET') properties = base.win.getProperties() self.notify.debug('DISPLAY ACHIEVED:') self.notify.debug(' EMBEDDED: %s' % bool(properties.getParentWindow())) self.notify.debug(' FULLSCREEN: %s' % bool(properties.getFullscreen())) self.notify.debug(' X SIZE: %s' % properties.getXSize()) self.notify.debug(' Y SIZE: %s' % properties.getYSize()) if bool(properties.getParentWindow()) == bool(embedded) and properties.getFullscreen() == fullscreen and properties.getXSize() == width and properties.getYSize() == height: self.notify.info('DISPLAY CHANGE VERIFIED') result = True else: self.notify.warning('DISPLAY CHANGE FAILED, RESTORING PREVIOUS DISPLAY') else: self.notify.warning('DISPLAY CHANGE FAILED') base.win.setSort(original_sort) base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() return result