def getFontModeFromFileParams(self): errorFound = False retVal = self.ERROR_FONT_FILE_ARGS # by priority first get the extended files if available (then fallback to originals) if self.selCopyFontFile is not None and self.selCopyFontFile <> "" and self.selCopyPngFile is not None and self.selCopyPngFile: self.localGrabInstance.setCopyFontFileName(self.selCopyFontFile) self.localGrabInstance.setCopyPNGFileName(self.selCopyPngFile) retVal = self.EXTENDED_FONT_FILE_ARGS elif self.selOrigFontFile is not None and self.selOrigFontFile <> "" and self.selOrigPngFile is not None and self.selOrigPngFile: self.localGrabInstance.setDasOrigFontFilename(self.selOrigFontFile) self.localGrabInstance.setImageOriginalPNG(self.selOrigPngFile) retVal = self.ORIGINAL_FONT_FILE_ARGS else: errorFound = True msgBoxesStub.qMsgBoxCritical(self.ui, "Error", "No valid file for characters drawing!") retVal = self.ERROR_FONT_FILE_ARGS return retVal
def getFontModeFromFileParams(self): errorFound = False retVal = self.ERROR_FONT_FILE_ARGS # by priority first get the extended files if available (then fallback to originals) if self.selCopyFontFile is not None and self.selCopyFontFile != "" and self.selCopyPngFile is not None and self.selCopyPngFile: self.localGrabInstance.setCopyFontFileName(self.selCopyFontFile) self.localGrabInstance.setCopyPNGFileName(self.selCopyPngFile) retVal = self.EXTENDED_FONT_FILE_ARGS elif self.selOrigFontFile is not None and self.selOrigFontFile != "" and self.selOrigPngFile is not None and self.selOrigPngFile: self.localGrabInstance.setDasOrigFontFilename(self.selOrigFontFile) self.localGrabInstance.setImageOriginalPNG(self.selOrigPngFile) retVal = self.ORIGINAL_FONT_FILE_ARGS else: errorFound = True msgBoxesStub.qMsgBoxCritical( self.ui, "Error", "No valid file for characters drawing!") retVal = self.ERROR_FONT_FILE_ARGS return retVal
def __init__(self, custParent = None, pselectedEncoding=None, pselectedGameID=None, pselectedOrigFontFile=None, pselectedOrigPngFile = None,pselectedExtendedFontFile=None, pselectedExtendedPngFile=None): self.ui = None if custParent is not None: QtGui.QMainWindow.__init__(self, custParent) else: QtGui.QMainWindow.__init__(self) if getattr(sys, 'frozen', None): self.basedir = sys._MEIPASS else: self.basedir = os.path.dirname(__file__) if pselectedEncoding is None or pselectedGameID is None or \ ( (pselectedOrigFontFile is None or pselectedOrigFontFile == '' or pselectedOrigPngFile is None or pselectedOrigPngFile =='') \ and \ (pselectedExtendedFontFile is None or pselectedExtendedFontFile == '' or pselectedExtendedPngFile is None or pselectedExtendedPngFile =='') ): print "Invalid arguments were given for the initialization of preview Sentence dialogue" self.tryToCloseWin() return else: self.tryEncoding = pselectedEncoding self.selGameID = pselectedGameID self.selOrigFontFile = pselectedOrigFontFile self.selOrigPngFile = pselectedOrigPngFile self.selCopyFontFile = pselectedExtendedFontFile self.selCopyPngFile = pselectedExtendedPngFile self.DBFileNameAndRelPath = os.path.join(self.relPath,self.DBFileName) # Set up the user interface from Designer. uiSentencePreviewFilePath = os.path.join(self.relPath, self.uiFolderName, self.uiSentencePreviewFileName) #print uiFontDlgFilePath if not os.access(uiSentencePreviewFilePath, os.F_OK) : print "Could not find the required ui file %s for the Sentence Preview Dialogue." % (self.uiSentencePreviewFileName) self.tryToCloseWin() return self.ui = uic.loadUi(uiSentencePreviewFilePath) self.ui.show() if not os.access(self.DBFileNameAndRelPath, os.F_OK) : msgBoxesStub.qMsgBoxCritical(self.ui, "Database file missing!",\ "The database file %s could not be found. Cannot proceed without a database file. Quiting..." % (self.DBFileNameAndRelPath)) self.tryToCloseWin() return self.icon = QIcon(":/icons/iconsimple.ico") self.ui.setWindowIcon( self.icon ) self.setWindowIcon(self.icon ) # adds icons in dialog boxes self.ui.setWindowIcon( self.icon ) self.ui.closingFlag = False ##self.ui.installEventFilter(self) self.native = True #can be used to control some native-to-OS or not dialogs being utilised (should be a checkbox) self.ui.backgroundSelectionCmbx.addItem(self.availBackgroundsLst[0][0]) self.ui.backgroundSelectionCmbx.addItem(self.availBackgroundsLst[1][0]) self.ui.backgroundSelectionCmbx.addItem(self.availBackgroundsLst[2][0]) self.ui.backgroundSelectionCmbx.setCurrentIndex(0) self.dasPixMap = None self.scene = QtGui.QGraphicsScene() self.sceneBgBrush = QtGui.QBrush() self.sceneBgBrush.setStyle(QtCore.Qt.SolidPattern) #self.sceneBgBrush.setColor(QColor(self.availBackgroundsLst[0][1][0],self.availBackgroundsLst[0][1][1],self.availBackgroundsLst[0][1][2])) #self.scene.setBackgroundBrush(self.sceneBgBrush) self.ui.sentenceViewPngFont.setScene(self.scene) self.ui.sentenceViewPngFont.show() self.loadSelectedBGFromComboChanged(self.availBackgroundsLst[0][0]) ## Connect up the buttons. self.ui.customTextEdt.setAcceptRichText(False) self.ui.previewCustomTextBtn.clicked.connect(self.previewCustomText) self.ui.clearCustomTextBtn.clicked.connect(self.clearCustomText) QtCore.QObject.connect(self.ui.backgroundSelectionCmbx, QtCore.SIGNAL("currentIndexChanged(const QString)"), self.loadSelectedBGFromComboChanged) self.localGrabInstance = grabberFromPNG(self.tryEncoding, self.selGameID) self.activeEnc = self.localGrabInstance.getActiveEncoding() self.fontMode = self.getFontModeFromFileParams() if self.fontMode == self.ERROR_FONT_FILE_ARGS: print "Could not detect font file status. Quiting" self.tryToCloseWin() return self.getIndexFromAsciiOrdToPngIndex() self.getListOfOutlinesInPng() self.showDefaultText() return
def __init__(self, custParent=None, pselectedEncoding=None, pselectedGameID=None, pselectedOrigFontFile=None, pselectedOrigPngFile=None, pselectedExtendedFontFile=None, pselectedExtendedPngFile=None): self.ui = None if custParent is not None: QtGui.QMainWindow.__init__(self, custParent) else: QtGui.QMainWindow.__init__(self) if getattr(sys, 'frozen', None): self.basedir = sys._MEIPASS else: self.basedir = os.path.dirname(__file__) if pselectedEncoding is None or pselectedGameID is None or \ ( (pselectedOrigFontFile is None or pselectedOrigFontFile == '' or pselectedOrigPngFile is None or pselectedOrigPngFile =='') \ and \ (pselectedExtendedFontFile is None or pselectedExtendedFontFile == '' or pselectedExtendedPngFile is None or pselectedExtendedPngFile =='') ): print( "Invalid arguments were given for the initialization of preview Sentence dialogue" ) self.tryToCloseWin() return else: self.tryEncoding = pselectedEncoding self.selGameID = pselectedGameID self.selOrigFontFile = pselectedOrigFontFile self.selOrigPngFile = pselectedOrigPngFile self.selCopyFontFile = pselectedExtendedFontFile self.selCopyPngFile = pselectedExtendedPngFile self.DBFileNameAndRelPath = os.path.join(self.relPath, self.DBFileName) # Set up the user interface from Designer. uiSentencePreviewFilePath = os.path.join( self.relPath, self.uiFolderName, self.uiSentencePreviewFileName) #print(uiFontDlgFilePath) if not os.access(uiSentencePreviewFilePath, os.F_OK): print( "Could not find the required ui file %s for the Sentence Preview Dialogue." % (self.uiSentencePreviewFileName)) self.tryToCloseWin() return self.ui = QtCompat.uic.loadUi(uiSentencePreviewFilePath) self.ui.show() if not os.access(self.DBFileNameAndRelPath, os.F_OK): msgBoxesStub.qMsgBoxCritical(self.ui, "Database file missing!",\ "The database file %s could not be found. Cannot proceed without a database file. Quiting..." % (self.DBFileNameAndRelPath)) self.tryToCloseWin() return self.icon = QIcon(":/icons/iconsimple.ico") self.ui.setWindowIcon(self.icon) self.setWindowIcon(self.icon) # adds icons in dialog boxes self.ui.setWindowIcon(self.icon) self.ui.closingFlag = False ##self.ui.installEventFilter(self) self.native = True #can be used to control some native-to-OS or not dialogs being utilised (should be a checkbox) self.ui.backgroundSelectionCmbx.addItem(self.availBackgroundsLst[0][0]) self.ui.backgroundSelectionCmbx.addItem(self.availBackgroundsLst[1][0]) self.ui.backgroundSelectionCmbx.addItem(self.availBackgroundsLst[2][0]) self.ui.backgroundSelectionCmbx.setCurrentIndex(0) self.dasPixMap = None self.scene = QtGui.QGraphicsScene() self.sceneBgBrush = QtGui.QBrush() self.sceneBgBrush.setStyle(QtCore.Qt.SolidPattern) #self.sceneBgBrush.setColor(QColor(self.availBackgroundsLst[0][1][0],self.availBackgroundsLst[0][1][1],self.availBackgroundsLst[0][1][2])) #self.scene.setBackgroundBrush(self.sceneBgBrush) self.ui.sentenceViewPngFont.setScene(self.scene) self.ui.sentenceViewPngFont.show() self.loadSelectedBGFromComboChanged(self.availBackgroundsLst[0][0]) ## Connect up the buttons. self.ui.customTextEdt.setAcceptRichText(False) self.ui.previewCustomTextBtn.clicked.connect(self.previewCustomText) self.ui.clearCustomTextBtn.clicked.connect(self.clearCustomText) QtCore.QObject.connect( self.ui.backgroundSelectionCmbx, QtCore.SIGNAL("currentIndexChanged(const QString)"), self.loadSelectedBGFromComboChanged) self.localGrabInstance = grabberFromPNG(self.tryEncoding, self.selGameID) self.activeEnc = self.localGrabInstance.getActiveEncoding() self.fontMode = self.getFontModeFromFileParams() if self.fontMode == self.ERROR_FONT_FILE_ARGS: print("Could not detect font file status. Quiting") self.tryToCloseWin() return self.getIndexFromAsciiOrdToPngIndex() self.getListOfOutlinesInPng() self.showDefaultText() return