def GetGamePath(self): """ Returns the game path """ if not self.custom: return 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 setting('GamePath') else: return str(setname)
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
def __init__(self): """ Creates and initializes the menu """ QtWidgets.QMenu.__init__(self) # Add the globals_.gamedef viewer widget self.currentView = GameDefViewer() self.currentView.setMinimumHeight(100) self.gameChanged.connect(self.currentView.updateLabels) v = QtWidgets.QWidgetAction(self) v.setDefaultWidget(self.currentView) self.addAction(v) self.addSeparator() # Add entries for each globals_.gamedef self.GameDefs = getAvailableGameDefs() self.actGroup = QtWidgets.QActionGroup(self) loadedDef = setting('LastGameDef') for folder in self.GameDefs: def_ = ReggieGameDefinition(folder) act = QtWidgets.QAction(self) act.setText(def_.name) act.setToolTip(def_.description) act.setData(folder) act.setActionGroup(self.actGroup) act.setCheckable(True) if folder == loadedDef: act.setChecked(True) act.toggled.connect(self.handleGameDefClicked) self.addAction(act)
def SetAppStyle(styleKey=''): """ Set the application window color """ # # global theme, app # 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, QPlainTextEdit{ background-color: %s; }""" % bgColor)
def GetGamePaths(self): """ Returns game paths of this globals_.gamedef and its bases """ mainpath = 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
def GetTexturePaths(self): """ Returns the texture game paths of this globals_.gamedef and its bases """ paths = [setting('TextureGamePath')] if not self.custom: return paths stg = setting('TextureGamePath_' + self.name) if self.base is not None: paths = self.base.GetTexturePaths() paths.append(stg) return paths
def LoadTheme(): """ Loads the theme """ id = setting('Theme') if id is None: id = 'Classic' # global theme globals_.theme = ReggieTheme(id)
def handleGameDefClicked(self, checked): """ Handles the user clicking a gamedef """ if not checked or self.update_flag: return name = self.actGroup.checkedAction().data() success = loadNewGameDef(name) if success: self.gameChanged.emit() return # Setting the new gamedef failed for some reason, so load back the old # game def. real_gamedef = setting('LastGameDef') success = loadNewGameDef(real_gamedef) if not success: raise Exception("Restoring the previous game def (%r) failed after failing to load new game def (%r)" % (real_gamedef, name)) self.update_flag = True for act in self.actGroup.actions(): act.setChecked(act.data() == real_gamedef) self.update_flag = False
def __init__(self): """ Initializes the widget """ QtWidgets.QWidget.__init__(self) # Populate a list of globals_.gamedefs self.GameDefs = getAvailableGameDefs() # Add them to the main layout self.group = QtWidgets.QButtonGroup() self.group.setExclusive(True) L = QtWidgets.QGridLayout() row = 0 col = 0 current = setting('LastGameDef') id = 0 for folder in self.GameDefs: def_ = ReggieGameDefinition(folder) btn = QtWidgets.QRadioButton() if folder == current: btn.setChecked(True) btn.toggled.connect(self.HandleRadioButtonClick) self.group.addButton(btn, id) btn.setToolTip(def_.description) id += 1 L.addWidget(btn, row, col) name = QtWidgets.QLabel(def_.name) name.setToolTip(def_.description) L.addWidget(name, row, col + 1) row += 1 if row > 2: row = 0 col += 2 self.setLayout(L)
def LoadTheme(): """ Loads the theme """ globals_.theme = ReggieTheme(setting("Theme", "Classic"))