def displaySchematic(schematic): global _swv_app if QtGui.qApp is None: _swv_app = QtGui.QApplication([]) if hasattr(schematic, 'getDimension'): dim = schematic.getDimension() else: dim = schematic resourceLoader = minecraftinstall.getSelectedResourceLoader() # xxx select using dim.blocktypes blockModels = BlockModels(schematic.blocktypes, resourceLoader) textureAtlas = TextureAtlas(schematic, resourceLoader, blockModels) _swv_view = SchematicWorldView(dim, textureAtlas) loader = WorldLoader(_swv_view.worldScene) loader.timer.timeout.connect(_swv_view.update) loader.startLoader() centerWidgetInScreen(_swv_view, resize=0.75) _swv_view.show() _swv_app.exec_()
def toggleView(self): if self.isHidden(): centerWidgetInScreen(self, 0.8) self.show() self._toggleViewAction.setChecked(True) else: self.hide() self._toggleViewAction.setChecked(False)
def __init__(self, editorSession): """ :type editorSession: mcedit2.editorsession.EditorSession :rtype: PlayerPanel """ super(PlayerPanel, self).__init__(f=Qt.Tool) self.editorSession = editorSession self.selectedUUID = None load_ui("panels/player.ui", baseinstance=self) self.movePlayerButton.clicked.connect(self.movePlayerToCamera) self.viewPlayerButton.clicked.connect(self.showPlayerView) playerUUIDs = list(editorSession.worldEditor.listPlayers()) try: sp = editorSession.worldEditor.getPlayer("") singlePlayerUUID = sp.UUID except PlayerNotFound: log.info("No single-player.") singlePlayerUUID = None except KeyError: log.info("Failed to get single-player UUID.") singlePlayerUUID = None for UUID in playerUUIDs: # xxx live update? if UUID == "": displayName = "[Single-player](%s)" % singlePlayerUUID else: displayName = UUID # xxx mojang api here try: UUID = uuid.UUID(hex=UUID) if UUID == singlePlayerUUID: continue # Don't count single-player twice when it appears under playerData/ except ValueError: # badly formed uuid? log.warn("Could not get a UUID from %s", UUID) continue self.playerListBox.addItem(displayName, UUID) self.playerListBox.currentIndexChanged[int].connect(self.setSelectedPlayerIndex) if len(playerUUIDs): self.setSelectedPlayerIndex(0) icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png")) action = QtGui.QAction(icon, "Edit Player", self) action.setCheckable(True) action.triggered.connect(self.toggleView) self._toggleViewAction = action self.editorSession.revisionChanged.connect(self.revisionDidChange) self.initPropertiesWidget() self.nbtEditor.editorSession = self.editorSession self.nbtEditor.editMade.connect(self.nbtEditWasMade) centerWidgetInScreen(self)
def __init__(self, parent=None): super(WorldListWidget, self).__init__(parent, f=Qt.Tool) self.setWindowTitle("World List") self.setWindowModality(Qt.NonModal) load_ui('world_list.ui', baseinstance=self) self.worldView = None self.chunkLoader = None self.errorWidget = None self.blankWidget = QtGui.QWidget() self.stackedWidget.addWidget(self.blankWidget) self.editButton.clicked.connect(self.editClicked) self.cancelButton.clicked.connect(self.reject) self.showListAgainInput.setEnabled(False) self.viewButton.clicked.connect(self.viewClicked) self.viewButton.setEnabled(False) self.openWorldButton.clicked.connect(self.openWorldClicked) self.repairButton.clicked.connect(self.repairClicked) self.repairButton.setEnabled(False) self.backupButton.clicked.connect(self.backupClicked) self.backupButton.setEnabled(False) self.configureButton.clicked.connect(self.configureClicked) centerWidgetInScreen(self, 0.75) delegate = WorldListItemDelegate() self.worldListView.setItemDelegate(delegate) delegate.setParent( self.worldListView ) # PYSIDE-152: get the view widget to the drawPrimitive call self.worldListView.clicked.connect(self.worldListItemClicked) self.worldListView.doubleClicked.connect( self.worldListItemDoubleClicked) self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired) self.loadTimer.start() self._updateInstalls() self.savesFolderComboBox.currentIndexChanged.connect(self.reloadList) self.minecraftInstallBox.currentIndexChanged.connect( minecraftinstall.currentInstallOption.setValue) self.minecraftVersionBox.currentIndexChanged[str].connect( minecraftinstall.currentVersionOption.setValue) self.resourcePackBox.currentIndexChanged.connect( self.resourcePackChanged) self.worldListModel = None self.reloadList() self.reloadRecentWorlds()
def __init__(self, editorSession, *args, **kwargs): """ :type editorSession: mcedit2.editorsession.EditorSession :rtype: PlayerPanel """ super(PlayerPanel, self).__init__(QtGui.qApp.mainWindow, *args, f=Qt.Tool, **kwargs) self.editorSession = editorSession self.selectedUUID = None load_ui("panels/player.ui", baseinstance=self) self.movePlayerButton.clicked.connect(self.movePlayerToCamera) self.viewPlayerButton.clicked.connect(self.showPlayerView) playerUUIDs = list(editorSession.worldEditor.listPlayers()) try: sp = editorSession.worldEditor.getPlayer("") singlePlayerUUID = sp.UUID except PlayerNotFound: singlePlayerUUID = None for UUID in playerUUIDs: # xxx live update? if UUID == "": displayName = "[Single-player](%s)" % singlePlayerUUID else: displayName = UUID # xxx mojang api here UUID = uuid.UUID(hex=UUID) if UUID == singlePlayerUUID: continue # Don't count single-player twice when it appears under playerData/ self.playerListBox.addItem(displayName, UUID) self.playerListBox.currentIndexChanged[int].connect( self.setSelectedPlayerIndex) if len(playerUUIDs): self.setSelectedPlayerIndex(0) icon = QtGui.QIcon( resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png")) action = QtGui.QAction(icon, "Edit Player", self) action.setCheckable(True) action.triggered.connect(self.toggleView) self._toggleViewAction = action self.editorSession.revisionChanged.connect(self.revisionDidChange) self.initPropertiesWidget() self.nbtEditor.editorSession = self.editorSession self.nbtEditor.editMade.connect(self.nbtEditWasMade) centerWidgetInScreen(self)
def __init__(self, parent=None): super(WorldListWidget, self).__init__(parent, f=Qt.Tool) self.setWindowTitle("World List") self.setWindowModality(Qt.NonModal) self.setupUi(self) self.worldView = None self.chunkLoader = None self.errorWidget = None self.blankWidget = QtGui.QWidget() self.stackedWidget.addWidget(self.blankWidget) self.editButton.clicked.connect(self.editClicked) self.cancelButton.clicked.connect(self.reject) self.showListAgainInput.setEnabled(False) self.viewButton.clicked.connect(self.viewClicked) self.openWorldButton.clicked.connect(self.openWorldClicked) self.repairButton.clicked.connect(self.repairClicked) self.repairButton.setEnabled(False) self.backupButton.clicked.connect(self.backupClicked) self.backupButton.setEnabled(False) self.configureButton.clicked.connect(self.configureClicked) self.chooseSavesFolderButton.clicked.connect(self.chooseSavesFolder) centerWidgetInScreen(self, 0.75) delegate = WorldListItemDelegate() self.worldListView.setItemDelegate(delegate) delegate.setParent(self.worldListView) # PYSIDE-152: get the view widget to the drawPrimitive call self.worldListView.clicked.connect(self.worldListItemClicked) self.worldListView.doubleClicked.connect(self.worldListItemDoubleClicked) self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired) self.loadTimer.start() self._updateInstalls() self.savesFolderComboBox.currentIndexChanged.connect(self.reloadList) self.minecraftInstallBox.currentIndexChanged.connect(minecraftinstall.currentInstallOption.setValue) self.minecraftVersionBox.currentIndexChanged[str].connect(minecraftinstall.currentVersionOption.setValue) self.resourcePackBox.currentIndexChanged.connect(self.resourcePackChanged) self.worldListModel = None self.reloadList() self.reloadRecentWorlds()
def __init__(self, parent=None, f=0): super(WorldListWidget, self).__init__(parent, f) self.setWindowTitle("World List") load_ui('world_list.ui', baseinstance=self) self.worldView = None self.chunkLoader = None self.errorWidget = None self.blankWidget = QtGui.QWidget() self.stackedWidget.addWidget(self.blankWidget) self.editButton.clicked.connect(self.editClicked) self.cancelButton.clicked.connect(self.reject) self.showListAgainInput.setEnabled(False) self.viewButton.clicked.connect(self.viewClicked) self.viewButton.setEnabled(False) self.openWorldButton.clicked.connect(self.openWorldClicked) self.repairButton.clicked.connect(self.repairClicked) self.repairButton.setEnabled(False) self.backupButton.clicked.connect(self.backupClicked) self.backupButton.setEnabled(False) self.configureButton.clicked.connect(self.configureClicked) centerWidgetInScreen(self, 0.75) delegate = WorldListItemDelegate() self.worldListView.setItemDelegate(delegate) delegate.setParent(self.worldListView) # PYSIDE-152: get the view widget to the drawPrimitive call self.worldListView.clicked.connect(self.worldListItemClicked) self.worldListView.doubleClicked.connect(self.worldListItemDoubleClicked) self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired) self.loadTimer.start() self._updateInstalls() self.savesFolderComboBox.currentIndexChanged.connect(self.reloadList) self.worldListModel = None self.reloadList() self.reloadRecentWorlds()
def __init__(self, parent=None, f=0): super(WorldListWidget, self).__init__(parent, f) self.setWindowTitle("World List") self.saveFileDir = None self.worldView = None self.chunkLoader = None self.errorWidget = QtGui.QWidget() load_ui('world_list.ui', baseinstance=self) self.setLayout(Row(self)) self.editButton.clicked.connect(self.editClicked) self.cancelButton.clicked.connect(self.reject) self.showListAgainInput.setEnabled(False) self.viewButton.clicked.connect(self.viewClicked) self.viewButton.setEnabled(False) self.openWorldButton.clicked.connect(self.openWorldClicked) self.repairButton.clicked.connect(self.repairClicked) self.repairButton.setEnabled(False) self.backupButton.clicked.connect(self.backupClicked) self.backupButton.setEnabled(False) self.configureButton.clicked.connect(self.configureClicked) centerWidgetInScreen(self, 0.75) self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired) self.loadTimer.start() for install in minecraftinstall.listInstalls(): self.minecraftInstallBox.addItem(install.name) self.minecraftInstallBox.setCurrentIndex( minecraftinstall.selectedInstallIndex()) self._updateVersionsAndResourcePacks() self.reloadList()
def show(self, *args, **kwargs): super(ErrorDialog, self).show(*args, **kwargs) centerWidgetInScreen(self)
def __init__(self, editorSession): super(WorldInfoPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool) self.setupUi(self) self.editorSession = editorSession self.worldMeta = self.editorSession.worldEditor.adapter.metadata callIcon = QtGui.QIcon(resourcePath('mcedit2/assets/mcedit2/icons/edit_worldinfo.png')) callButton = QtGui.QAction(callIcon, self.tr('World Info'), self) callButton.setCheckable(True) callButton.triggered.connect(self.toggleView) self._toggleViewAction = callButton self.worldNBTEditor.editorSession = self.editorSession self.editorSession.revisionChanged.connect(self.revisionDidChange) self.gamemodes = [self.tr('Survival'), self.tr('Creative'), self.tr('Adventure'), self.tr('Spectator')] self.difficulties = [self.tr('Peaceful'), self.tr('Easy'), self.tr('Normal'), self.tr('Hard')] self.generatorTypes = [ (self.tr('Default'), 'default'), (self.tr('Flat'), 'flat'), (self.tr('Large Biomes'), 'largeBiomes'), (self.tr('Amplified'), 'amplified'), (self.tr('Customized'), 'customized'), (self.tr('Debug All Block States'), 'debug_all_block_states'), ] self.defaultGamemodeCombo.addItems(self.gamemodes) self.defaultGamemodeCombo.currentIndexChanged.connect(self.defaultGamemodeChanged) self.worldDifficultyCombo.addItems(self.difficulties) self.worldDifficultyCombo.currentIndexChanged.connect(self.worldDifficultyChanged) for name, data in self.generatorTypes: self.generatorTypeCombo.addItem(name, data) self.generatorTypeCombo.currentIndexChanged.connect(self.generatorTypeChanged) # Since QComboBox emits editTextChanged after every keystroke, # we connect to its QLineEdit's editingFinished to only get signaled # after the line edit loses focus (or the user presses return) self.generatorTypeCombo.lineEdit().editingFinished.connect(self.generatorTypeChanged) self.worldNameLineEdit.editingFinished.connect(self.worldNameChanged) self.generatorSeedLineEdit.editingFinished.connect(self.seedChanged) self.generatorOptionsLineEdit.editingFinished.connect(self.generatorOptionsChanged) self.spawnX.editingFinished.connect(self.spawnChanged) self.spawnY.editingFinished.connect(self.spawnChanged) self.spawnZ.editingFinished.connect(self.spawnChanged) self.timeDays.editingFinished.connect(self.timeChanged) self.timeSlider.sliderReleased.connect(self.timeChanged) self.dawnButton.setIcon(QtGui.QIcon(resourcePath('mcedit2/assets/mcedit2/clock/dawn.png'))) self.dawnButton.pressed.connect(self.setTimeDawn) self.noonButton.setIcon(QtGui.QIcon(resourcePath('mcedit2/assets/mcedit2/clock/noon.png'))) self.noonButton.pressed.connect(self.setTimeNoon) self.eveningButton.setIcon(QtGui.QIcon(resourcePath('mcedit2/assets/mcedit2/clock/evening.png'))) self.eveningButton.pressed.connect(self.setTimeEvening) self.nightButton.setIcon(QtGui.QIcon(resourcePath('mcedit2/assets/mcedit2/clock/night.png'))) self.nightButton.pressed.connect(self.setTimeNight) self.lockedDifficultyBool.stateChanged.connect(self.lockedDifficultyChanged) self.commandsBool.stateChanged.connect(self.allowCommandsChanged) self.hardcoreBool.stateChanged.connect(self.hardcoreChanged) self.updatePanel() self.updateNBTTree() centerWidgetInScreen(self)
def __init__(self, editorSession): """ :type editorSession: mcedit2.editorsession.EditorSession :rtype: PlayerPanel """ super(PlayerPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool) self.setupUi(self) self.editorSession = editorSession self.selectedUUID = None self.nbtEditor.editorSession = self.editorSession self.inventoryEditor = InventoryEditor(PLAYER_SLOT_LAYOUT) self.inventoryGroupBox.setLayout(Row(self.inventoryEditor)) self.movePlayerButton.clicked.connect(self.movePlayerToCamera) self.viewPlayerButton.clicked.connect(self.showPlayerView) playerUUIDs = list(editorSession.worldEditor.listPlayers()) try: sp = editorSession.worldEditor.getPlayer("") singlePlayerUUID = sp.UUID except PlayerNotFound: log.info("No single-player.") singlePlayerUUID = None except KeyError: log.info("Failed to get single-player UUID.") singlePlayerUUID = None if "" in playerUUIDs: # Move singleplayer to beginning of list playerUUIDs.remove("") playerUUIDs.insert(0, "") for UUID in playerUUIDs: # xxx live update? if UUID == "": displayName = "[Single-player](%s)" % singlePlayerUUID else: displayName = UUID # xxx mojang api here try: UUID = uuid.UUID(hex=UUID) if UUID == singlePlayerUUID: displayName = "[Multiplayer](%s)" % singlePlayerUUID except ValueError: # badly formed uuid? log.warn("Could not get a UUID from %s", UUID) continue self.playerListBox.addItem(displayName, UUID) self.playerListBox.currentIndexChanged[int].connect( self.setSelectedPlayerIndex) if len(playerUUIDs): self.setSelectedPlayerIndex(0) icon = QtGui.QIcon( resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png")) action = QtGui.QAction(icon, "Edit Player", self) action.setCheckable(True) action.triggered.connect(self.toggleView) self._toggleViewAction = action self.editorSession.revisionChanged.connect(self.revisionDidChange) self.initPropertiesWidget() centerWidgetInScreen(self)
def __init__(self, parent=None): super(WorldListWidget, self).__init__(parent, f=Qt.Tool) self.setWindowTitle("World List") self.setWindowModality(Qt.NonModal) self.setupUi(self) self.worldView = None self.chunkLoader = None self.errorWidget = None self.blankWidget = QtGui.QWidget() self.stackedWidget.addWidget(self.blankWidget) self.editButton.clicked.connect(self.editClicked) self.cancelButton.clicked.connect(self.reject) self.showListAgainInput.setEnabled(False) self.viewButton.clicked.connect(self.viewClicked) self.openWorldButton.clicked.connect(self.openWorldClicked) self.repairButton.clicked.connect(self.repairClicked) self.repairButton.setEnabled(False) self.backupButton.clicked.connect(self.backupClicked) self.backupButton.setEnabled(False) self.configureButton.clicked.connect(self.configureClicked) self.chooseSavesFolderButton.clicked.connect(self.chooseSavesFolder) centerWidgetInScreen(self, 0.75) delegate = WorldListItemDelegate() self.worldListView.setItemDelegate(delegate) delegate.setParent( self.worldListView ) # PYSIDE-152: get the view widget to the drawPrimitive call self.worldListView.clicked.connect(self.worldListItemClicked) self.worldListView.doubleClicked.connect( self.worldListItemDoubleClicked) self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired) self.loadTimer.start() self._updateInstalls() try: savesFolders = WorldListSettings.allSavesFolders.value() for filename in savesFolders: if not os.path.isdir(filename): continue dirname, basename = os.path.split(filename) displayName = os.sep.join( dirname.split(os.sep)[-2:] + [basename]) self.savesFolderComboBox.addItem(displayName, filename) except (ValueError, KeyError) as e: log.warn("Failed to load saves folder list.") currentFolder = WorldListSettings.currentSavesFolder.value() if os.path.isdir(currentFolder): index = self.savesFolderComboBox.findData(currentFolder) if index != -1: self.savesFolderComboBox.setCurrentIndex(index) self.savesFolderComboBox.currentIndexChanged.connect( self.savesFolderChanged) self.minecraftInstallBox.currentIndexChanged.connect( self.currentInstallChanged) self.minecraftVersionBox.currentIndexChanged[str].connect( minecraftinstall.currentVersionOption.setValue) self.resourcePackBox.currentIndexChanged.connect( self.resourcePackChanged) self.worldListModel = None self.reloadList() self.reloadRecentWorlds()
def __init__(self, editorSession): """ :type editorSession: mcedit2.editorsession.EditorSession :rtype: PlayerPanel """ super(PlayerPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool) self.setupUi(self) self.editorSession = editorSession self.selectedUUID = None self.nbtEditor.editorSession = self.editorSession self.inventoryEditor = InventoryEditor(PLAYER_SLOT_LAYOUT) self.inventoryGroupBox.setLayout(Row(self.inventoryEditor)) self.movePlayerButton.clicked.connect(self.movePlayerToCamera) self.viewPlayerButton.clicked.connect(self.showPlayerView) playerUUIDs = list(editorSession.worldEditor.listPlayers()) try: sp = editorSession.worldEditor.getPlayer("") singlePlayerUUID = sp.UUID except (PlayerNotFound, NBTFormatError): log.info("No single-player.") singlePlayerUUID = None except KeyError: log.info("Failed to get single-player UUID.") singlePlayerUUID = None if "" in playerUUIDs: # Move singleplayer to beginning of list playerUUIDs.remove("") playerUUIDs.insert(0, "") for UUID in playerUUIDs: if UUID == "": displayName = "[Single-player](%s)" % singlePlayerUUID else: displayName = UUID try: UUID = uuid.UUID(hex=UUID) if UUID == singlePlayerUUID: displayName = "[Multiplayer](%s)" % singlePlayerUUID except ValueError: # badly formed uuid? log.warn("Could not get a UUID from %s", UUID) continue idx = self.playerListBox.count() self.playerListBox.addItem(displayName, UUID) def _callback(idx, fmt="%s"): def callback(result, error): if result: name = result['name'] self.playerListBox.setItemText(idx, fmt % name) return callback if UUID == "": if singlePlayerUUID: PlayerDataCache.getPlayerInfo(singlePlayerUUID, _callback(idx, "[Single-player]%s")) else: if UUID == singlePlayerUUID: PlayerDataCache.getPlayerInfo(UUID, _callback(idx, "[Multiplayer]%s")) else: PlayerDataCache.getPlayerInfo(UUID, _callback(idx)) self.playerListBox.currentIndexChanged[int].connect(self.setSelectedPlayerIndex) if len(playerUUIDs): self.setSelectedPlayerIndex(0) icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png")) action = QtGui.QAction(icon, self.tr("Edit Player"), self) action.setCheckable(True) action.triggered.connect(self.toggleView) self._toggleViewAction = action self.editorSession.revisionChanged.connect(self.revisionDidChange) self.initPropertiesWidget() centerWidgetInScreen(self)
def __init__(self, editorSession): super(WorldInfoPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool) self.editorSession = editorSession self.worldMeta = self.editorSession.worldEditor.adapter.metadata callIcon = QtGui.QIcon(resourcePath('mcedit2/assets/mcedit2/icons/edit_worldinfo.png')) callButton = QtGui.QAction(callIcon, self.tr('World Info'), self) callButton.setCheckable(True) callButton.triggered.connect(self.toggleView) self._toggleViewAction = callButton load_ui('panels/worldinfo.ui', baseinstance=self) self.worldNBTEditor.editorSession = self.editorSession self.editorSession.revisionChanged.connect(self.revisionDidChange) self.gamemodes = [self.tr('Survival'), self.tr('Creative'), self.tr('Adventure'), self.tr('Spectator')] self.difficulties = [self.tr('Peaceful'), self.tr('Easy'), self.tr('Normal'), self.tr('Hard')] self.generatorTypes = [ (self.tr('Default'), 'default'), (self.tr('Flat'), 'flat'), (self.tr('Large Biomes'), 'largeBiomes'), (self.tr('Amplified'), 'amplified'), (self.tr('Customized'), 'customized'), (self.tr('Debug All Block States'), 'debug_all_block_states'), ] self.defaultGamemodeCombo.addItems(self.gamemodes) self.defaultGamemodeCombo.currentIndexChanged.connect(self.defaultGamemodeChanged) self.worldDifficultyCombo.addItems(self.difficulties) self.worldDifficultyCombo.currentIndexChanged.connect(self.worldDifficultyChanged) for name, data in self.generatorTypes: self.generatorTypeCombo.addItem(name, data) self.generatorTypeCombo.currentIndexChanged.connect(self.generatorTypeChanged) # Since QComboBox emits editTextChanged after every keystroke, # we connect to its QLineEdit's editingFinished to only get signaled # after the line edit loses focus (or the user presses return) self.generatorTypeCombo.lineEdit().editingFinished.connect(self.generatorTypeChanged) self.worldNameLineEdit.editingFinished.connect(self.worldNameChanged) self.generatorSeedLineEdit.editingFinished.connect(self.seedChanged) self.generatorOptionsLineEdit.editingFinished.connect(self.generatorOptionsChanged) self.spawnX.editingFinished.connect(self.spawnChanged) self.spawnY.editingFinished.connect(self.spawnChanged) self.spawnZ.editingFinished.connect(self.spawnChanged) self.timeDays.editingFinished.connect(self.timeChanged) self.timeSlider.sliderReleased.connect(self.timeChanged) self.dawnButton.setIcon(QtGui.QIcon(resourcePath('mcedit2/assets/mcedit2/clock/dawn.png'))) self.dawnButton.pressed.connect(self.setTimeDawn) self.noonButton.setIcon(QtGui.QIcon(resourcePath('mcedit2/assets/mcedit2/clock/noon.png'))) self.noonButton.pressed.connect(self.setTimeNoon) self.eveningButton.setIcon(QtGui.QIcon(resourcePath('mcedit2/assets/mcedit2/clock/evening.png'))) self.eveningButton.pressed.connect(self.setTimeEvening) self.nightButton.setIcon(QtGui.QIcon(resourcePath('mcedit2/assets/mcedit2/clock/night.png'))) self.nightButton.pressed.connect(self.setTimeNight) self.lockedDifficultyBool.stateChanged.connect(self.lockedDifficultyChanged) self.commandsBool.stateChanged.connect(self.allowCommandsChanged) self.hardcoreBool.stateChanged.connect(self.hardcoreChanged) self.updatePanel() self.updateNBTTree() centerWidgetInScreen(self)
def __init__(self, editorSession): """ :type editorSession: mcedit2.editorsession.EditorSession :rtype: PlayerPanel """ super(PlayerPanel, self).__init__(QtGui.qApp.mainWindow, f=Qt.Tool) self.editorSession = editorSession self.selectedUUID = None load_ui("panels/player.ui", baseinstance=self) self.inventoryEditor = InventoryEditor(PLAYER_SLOT_LAYOUT) self.inventoryGroupBox.setLayout(Row(self.inventoryEditor)) self.movePlayerButton.clicked.connect(self.movePlayerToCamera) self.viewPlayerButton.clicked.connect(self.showPlayerView) playerUUIDs = list(editorSession.worldEditor.listPlayers()) try: sp = editorSession.worldEditor.getPlayer("") singlePlayerUUID = sp.UUID except PlayerNotFound: log.info("No single-player.") singlePlayerUUID = None except KeyError: log.info("Failed to get single-player UUID.") singlePlayerUUID = None if "" in playerUUIDs: # Move singleplayer to beginning of list playerUUIDs.remove("") playerUUIDs.insert(0, "") for UUID in playerUUIDs: # xxx live update? if UUID == "": displayName = "[Single-player](%s)" % singlePlayerUUID else: displayName = UUID # xxx mojang api here try: UUID = uuid.UUID(hex=UUID) if UUID == singlePlayerUUID: displayName = "[Multiplayer](%s)" % singlePlayerUUID except ValueError: # badly formed uuid? log.warn("Could not get a UUID from %s", UUID) continue self.playerListBox.addItem(displayName, UUID) self.playerListBox.currentIndexChanged[int].connect(self.setSelectedPlayerIndex) if len(playerUUIDs): self.setSelectedPlayerIndex(0) icon = QtGui.QIcon(resourcePath("mcedit2/assets/mcedit2/icons/edit_player.png")) action = QtGui.QAction(icon, "Edit Player", self) action.setCheckable(True) action.triggered.connect(self.toggleView) self._toggleViewAction = action self.editorSession.revisionChanged.connect(self.revisionDidChange) self.initPropertiesWidget() self.nbtEditor.editorSession = self.editorSession centerWidgetInScreen(self)
def __init__(self, parent=None): super(WorldListWidget, self).__init__(parent, f=Qt.Tool) self.setWindowTitle("World List") self.setWindowModality(Qt.NonModal) self.setupUi(self) self.worldView = None self.chunkLoader = None self.errorWidget = None self.blankWidget = QtGui.QWidget() self.stackedWidget.addWidget(self.blankWidget) self.editButton.clicked.connect(self.editClicked) self.cancelButton.clicked.connect(self.reject) self.showListAgainInput.setEnabled(False) self.viewButton.clicked.connect(self.viewClicked) self.openWorldButton.clicked.connect(self.openWorldClicked) self.repairButton.clicked.connect(self.repairClicked) self.repairButton.setEnabled(False) self.backupButton.clicked.connect(self.backupClicked) self.backupButton.setEnabled(False) self.configureButton.clicked.connect(self.configureClicked) self.chooseSavesFolderButton.clicked.connect(self.chooseSavesFolder) centerWidgetInScreen(self, 0.75) delegate = WorldListItemDelegate() self.worldListView.setItemDelegate(delegate) delegate.setParent(self.worldListView) # PYSIDE-152: get the view widget to the drawPrimitive call self.worldListView.clicked.connect(self.worldListItemClicked) self.worldListView.doubleClicked.connect(self.worldListItemDoubleClicked) self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired) self.loadTimer.start() self._updateInstalls() try: savesFolders = WorldListSettings.allSavesFolders.value() for filename in savesFolders: if not os.path.isdir(filename): continue dirname, basename = os.path.split(filename) displayName = os.sep.join(dirname.split(os.sep)[-2:] + [basename]) self.savesFolderComboBox.addItem(displayName, filename) except (ValueError, KeyError) as e: log.warn("Failed to load saves folder list.") currentFolder = WorldListSettings.currentSavesFolder.value() if os.path.isdir(currentFolder): index = self.savesFolderComboBox.findData(currentFolder) if index != -1: self.savesFolderComboBox.setCurrentIndex(index) self.savesFolderComboBox.currentIndexChanged.connect(self.savesFolderChanged) self.minecraftInstallBox.currentIndexChanged.connect(self.currentInstallChanged) self.minecraftVersionBox.currentIndexChanged[str].connect(minecraftinstall.currentVersionOption.setValue) self.resourcePackBox.currentIndexChanged.connect(self.resourcePackChanged) self.worldListModel = None self.reloadList() self.reloadRecentWorlds()