コード例 #1
0
ファイル: gamedefs.py プロジェクト: z199416/Miyamoto
    def GetLastLevel(self):
        """
        Returns the last loaded level
        """
        if not self.custom: return setting('LastLevel')
        name = 'LastLevel_' + self.name
        stg = setting(name)

        # Use the default if there are no settings for this yet
        if stg is None:
            return setting('LastLevel')
        else:
            return stg
コード例 #2
0
ファイル: gamedefs.py プロジェクト: z199416/Miyamoto
    def GetGamePath(self):
        """
        Returns the game path
        """
        if not self.custom: return str(setting('GamePath'))
        name = 'GamePath_' + self.name
        setname = setting(name)

        # Use the default if there are no settings for this yet
        if setname is None:
            return str(setting('GamePath'))
        else:
            return str(setname)
コード例 #3
0
def SetAppStyle(styleKey=''):
    """
    Set the application window color
    """
    # Change the color if applicable
    if globals.theme.color(
            'ui') is not None and not globals.theme.forceStyleSheet:
        globals.app.setPalette(QtGui.QPalette(globals.theme.color('ui')))

    # Change the style
    if not styleKey: styleKey = setting('uiStyle', "Fusion")
    style = QtWidgets.QStyleFactory.create(styleKey)
    globals.app.setStyle(style)

    # Apply the style sheet, if exists
    if globals.theme.styleSheet:
        globals.app.setStyleSheet(globals.theme.styleSheet)

    # Manually set the background color
    if globals.theme.forceUiColor and not globals.theme.forceStyleSheet:
        color = globals.theme.color('ui').getRgb()
        bgColor = "#%02x%02x%02x" % tuple(map(lambda x: x // 2, color[:3]))
        globals.app.setStyleSheet("""
            QListView, QTreeWidget, QLineEdit, QDoubleSpinBox, QSpinBox, QTextEdit{
                background-color: %s;
            }""" % bgColor)
コード例 #4
0
def LoadTheme():
    """
    Loads the theme
    """
    id = setting('Theme')
    if id is None: id = 'Classic'
    print('THEME ID: ' + str(id))
    globals.theme = MiyamotoTheme(id)
コード例 #5
0
ファイル: gamedefs.py プロジェクト: z199416/Miyamoto
    def GetGamePaths(self):
        """
        Returns game paths of this gamedef and its bases
        """
        mainpath = str(setting('GamePath'))
        if not self.custom: return [
                mainpath,
        ]

        name = 'GamePath_' + self.name
        stg = setting(name)
        if self.base is None:
            return [mainpath, stg]
        else:
            paths = self.base.GetGamePaths()
            paths.append(stg)
            return paths
コード例 #6
0
def LoadTranslation():
    """
    Loads the translation
    """
    name = setting('Translation')
    eng = (None, 'None', 'English', '', 0)
    if name in eng:
        globals.trans = MiyamotoTranslation(None)
    else:
        globals.trans = MiyamotoTranslation(name)

    if globals.generateStringsXML: globals.trans.generateXML()
コード例 #7
0
    def __init__(self):
        super().__init__()

        self.setTitle("Objects Path (optional)")
        self.setSubTitle("Choose the folder containing object folders")

        self.requireFinish = False
        self.isValidPathMethod = isValidObjectsPath

        path = setting('ObjPath')
        if path:
            self.pathLineEdit.setText(path)
コード例 #8
0
def isValidObjectsPath(path='ug'):
    if path == 'ug': path = setting('ObjPath')
    if not (path and os.path.isdir(path)):
        return False

    folders = os.listdir(path)
    for folder in folders:
        folderPath = os.path.join(path, folder)
        if not os.path.isdir(folderPath):
            continue

        files = [
            file for file in os.listdir(folderPath) if file[-5:] == ".json"
        ]

        for file in files:
            filePath = os.path.join(folderPath, file)
            if not os.path.isfile(filePath):
                continue

            with open(filePath) as inf:
                jsonData = json.load(inf)

            if not ("colls" in jsonData and "meta" in jsonData and "objlyt"
                    in jsonData and "img" in jsonData and "nml" in jsonData):
                continue

            found = True
            for f in ["colls", "meta", "objlyt", "img", "nml"]:
                if not os.path.isfile(os.path.join(folderPath, jsonData[f])):
                    found = False
                    break

            if found:
                return True

    return False