def loadProjectBackup(self): for proxy in self.proxy.files: node = None if isinstance(proxy, AssemblyFileProxy): node = AssemblyFileNode() node.setIcon(0, QIcon(main.resource_path("resources/s.png"))) elif isinstance(proxy, CFileProxy): node = CFileNode() node.setIcon(0, QIcon(main.resource_path("resources/c.png"))) if node: proxy.parent = self.proxy node.setText(0, proxy.path) node.path = proxy.path node.proxy = proxy try: if proxy.text: with open(proxy.getFilePath(), 'w') as file: file.write(proxy.text) proxy.hasUnsavedChanges = False except: print("Could not write to file {}".format( proxy.getFilePath())) self.addChild(node) self.connectFileEventHandlers(node)
def __init__(self, fileProxy): super(TabSwithcerListItem, self).__init__() if isinstance(fileProxy, AssemblyFileProxy): self.setIcon(QIcon(main.resource_path("resources/s.png"))) elif isinstance(fileProxy, CFileProxy): self.setIcon(QIcon(main.resource_path("resources/c.png"))) self.setText("{}/{}".format(fileProxy.parent.path, fileProxy.path))
def __init__(self, configurationManager: ConfigurationManager): super(ToolBar, self).__init__() self.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.configurationManager = configurationManager self.setStyleSheet( "background-color: #2D2D30; color: white; font-weight: 500") self.setMovable(False) self.setWindowTitle("Toolbar") self.compile = QAction( QIcon(main.resource_path("resources/compile.png")), "Compile", self) self.compile.setShortcut(QKeySequence("Ctrl+Shift+B")) self.debug = QAction(QIcon(main.resource_path("resources/debug.png")), "Debug", self) self.debug.setShortcut(QKeySequence("Ctrl+F5")) self.run = QAction(QIcon(main.resource_path("resources/run.png")), "Run", self) self.label = QLabel("Select current project") self.label.setStyleSheet("padding-left: 5px;") icon = QIcon(main.resource_path("resources/current_folder.png")) self.currentIcon = QLabel() self.currentIcon.setPixmap(icon.pixmap(QSize(20, 20))) self.projectComboBox = ProjectComboBox(self.configurationManager) self.projectComboBox.setMinimumWidth(250) self.run.setShortcut(QKeySequence("F5")) self.addAction(self.compile) self.addAction(self.debug) self.addAction(self.run) self.addSeparator() self.addWidget(self.currentIcon) self.addWidget(self.label) self.addWidget(self.projectComboBox)
def __init__(self): super(WorkspaceNode, self).__init__() self.deleted = False self.eventManager = WorkspaceEventManager() self.menu = QMenu() self.menu.setStyleSheet("background-color: #3E3E42; color: white;") self.proxy = WorkspaceProxy() self.newProjectAction = QAction(QIcon(main.resource_path("resources/new_folder.png")), "New project") self.quickAssemblyProjectAction = QAction(QIcon(main.resource_path("resources/new_s.png")), "Quick assembly project") self.openFileAsAssemblyProjectAction = QAction(QIcon(main.resource_path("resources/open_s.png")), "Open file as assembly project") self.importProjectAction = QAction(QIcon(main.resource_path("resources/open_folder.png")), "Import project") self.saveAction = QAction(QIcon(main.resource_path("resources/save_folder.png")), "Save workspace") self.renameAction = QAction(QIcon(main.resource_path("resources/rename_folder.png")), "Rename workspace") self.switchAction = QAction(QIcon(main.resource_path("resources/switch_folder.png")), "Switch workspace") self.updateAction = QAction(QIcon(main.resource_path("resources/update_folder.png")), "Update workspace") self.showInfilesAction = QAction(QIcon(main.resource_path("resources/open_folder.png")), "Show in files") self.menu.addAction(self.newProjectAction) self.menu.addAction(self.importProjectAction) self.menu.addAction(self.showInfilesAction) self.menu.addSeparator() self.menu.addAction(self.quickAssemblyProjectAction) self.menu.addAction(self.openFileAsAssemblyProjectAction) self.menu.addSeparator() self.menu.addAction(self.saveAction) self.menu.addAction(self.switchAction) self.menu.addAction(self.renameAction) self.menu.addAction(self.updateAction) self.connectActions()
def play_eat_sound(self, multiplier): if self.score == 200 * multiplier: #http://soundbible.com/1601-Mario-Jumping.html eat_sound = pygame.mixer.Sound( main.resource_path("146726__leszek-szary__jumping.wav")) eat_sound.set_volume(.3) else: eat_sound = pygame.mixer.Sound( main.resource_path("GUI Sound Effects_038.wav")) eat_sound.play()
def createEditMenuItemActions(self): self.findAction = QAction(QIcon(resource_path("resources/find_and_replace.png")), "Find and Replace", self) self.findAction.setShortcut(QKeySequence("Ctrl+F")) self.edit.addAction(self.findAction) self.editDefaultWorkspace = QAction(QIcon(resource_path("resources/workspace.png")), "Edit default workspace", self) self.edit.addAction(self.editDefaultWorkspace) self.editCodeSnippets = QAction(QIcon(resource_path("resources/edit_snippets.png")), "Edit code snippets", self) self.edit.addAction(self.editCodeSnippets) self.editSettings = QAction(QIcon(resource_path("resources/settings.png")), "Edit IDE settings", self) self.edit.addAction(self.editSettings)
def createNewFile(self): if not os.path.exists(self.proxy.getProjectPath()): self.eventManager.invalidProject.emit(self) return dialog = NewFileDialog() dialog.exec_() if dialog.result: rootPath = os.path.join(self.parent().path, self.path, dialog.result) regex = re.compile('[@!#$%^&*()<>?/\|}{~:]') if " " in dialog.result or regex.search(dialog.result): msg = QMessageBox() msg.setStyleSheet("background-color: #2D2D30; color: white;") msg.setModal(True) msg.setIcon(QMessageBox.Critical) msg.setText( "File name cannot contain whitespace or special characters." ) msg.setWindowTitle("File creation error") msg.exec_() return if os.path.exists(rootPath): msg = QMessageBox() msg.setStyleSheet("background-color: #2D2D30; color: white;") msg.setModal(True) msg.setIcon(QMessageBox.Critical) msg.setText("File with the same name already exists.") msg.setWindowTitle("File creation error") msg.exec_() return node = None if dialog.result[-1] == "S": node = AssemblyFileNode() node.setIcon(0, QIcon(main.resource_path("resources/s.png"))) else: node = CFileNode() node.setIcon(0, QIcon(main.resource_path("resources/c.png"))) node.setText(0, dialog.result) node.path = dialog.result if isinstance(node, AssemblyFileNode): node.proxy = AssemblyFileProxy() elif isinstance(node, CFileNode): node.proxy = CFileProxy() node.proxy.path = dialog.result node.proxy.parent = self.proxy self.addChild(node) os.mknod(rootPath) self.proxy.addFile(node.proxy) self.connectFileEventHandlers(node) self.setExpanded(True) self.eventManager.newFile.emit(node.proxy)
def openFileAsAssemblyProject(self): if not os.path.exists(self.path): self.eventManager.invalidWorkspace.emit(self) return name, entered = QFileDialog.getOpenFileName(None, "Select assembly file to open", ".","Assembly files (*.S)") if not name: return regex = re.compile('[@!#$%^&*()<>?/\|}{~:]') fileName = os.path.basename(name) if " " in fileName or regex.search(fileName): msg = QMessageBox() msg.setStyleSheet("background-color: #2D2D30; color: white;") msg.setModal(True) msg.setIcon(QMessageBox.Critical) msg.setText("File name cannot contain whitespace or special characters.") msg.setWindowTitle("File import error") msg.exec_() return fileNode = AssemblyFileNode() fileNode.setIcon(0, QIcon(main.resource_path("resources/s.png"))) fileNode.setText(0, fileName) fileNode.path = fileName fileNode.proxy = AssemblyFileProxy() fileNode.proxy.path = fileName projectName = fileName.strip(".S") projectPath = os.path.join(self.path, projectName) while os.path.exists(projectPath): projectName += "_1" projectPath = os.path.join(self.path, projectName) os.mkdir(projectPath) project = ProjectNode() project.path = projectName project.proxy.path = projectName project.proxy.parent = self.proxy fileNode.proxy.parent = project.proxy project.setIcon(0, QIcon(main.resource_path("resources/project.png"))) project.setText(0, projectName) self.addChild(project) project.addChild(fileNode) project.proxy.addFile(fileNode.proxy) self.proxy.addProject(project.proxy) filePath = os.path.join(projectPath, fileName) shutil.copy2(name, filePath) project.connectFileEventHandlers(fileNode) self.saveWorkspace() self.connectProjectEventHandlers(project) project.setExpanded(True) self.eventManager.projectAdded.emit(project) self.eventManager.quickAssemblyFile.emit(fileNode.proxy)
def __init__(self, mainwindow): super().__init__() self.mainwindow = mainwindow self.setWindowTitle('Шаблоны') self.setWindowIcon(QIcon(resource_path('resources/main_ico.png'))) layout = QGridLayout() self.setLayout(layout) self.desc_text = TextEditor(placeholder='Описание') self.name_text = TextEditor(placeholder='Уникальное имя') self.path_file = QtWidgets.QLabel('Файл шаблон') btn_open = SimpleBtn(label='...', click_func=self.get_path, height=30, width=30) btn_except = SimpleBtn(label='Добавить', click_func=self.add_to_bd) layout.addWidget(self.name_text, 0, 0, 1, 3) layout.addWidget(self.path_file, 1, 0, 1, 2) layout.addWidget(btn_open, 1, 2, 1, 1) layout.addWidget(self.desc_text, 2, 0, 10, 3) layout.addWidget(btn_except, 12, 0, 1, 3) self.setLayout(layout) self.setMinimumHeight(500) self.setMinimumWidth(600)
def __init__(self): super(AboutDialog, self).__init__() self.setStyleSheet("background-color: #232323;") self.setWindowFlags(Qt.Window) self.setWindowFlag(Qt.WindowContextHelpButtonHint, False) self.setWindowFlag(Qt.WindowMinMaxButtonsHint, False) self.setWindowFlag(Qt.WindowStaysOnTopHint, True) self.setWindowIcon(QIcon(main.resource_path("resources/app_icon.ico"))) self.setWindowTitle("About i386ide") self.label = QLabel() self.label.setPixmap(QPixmap( main.resource_path("resources/about.png"))) self.hbox = QHBoxLayout() self.hbox.addWidget(self.label) self.setLayout(self.hbox) self.setFixedSize(520, 420)
def __init__(self, pages, current_row, prefix): super().__init__() self.prefix = prefix self.main_id = self.get_main_id(pages=pages) self.setWindowTitle('Кадры') self.setWindowIcon(QIcon(resource_path('resources/main_ico.png'))) self.tree = QtWidgets.QTreeWidget() self.tree.setHeaderLabels(['Кадры']) self.pages = pages self.current_row = current_row layout = QtWidgets.QVBoxLayout(self) layout.addWidget(self.tree) self.importData() self.setLayout(layout) # self.tree.selectionModel().selectionChanged.connect(self.onSelectionChanged) self.btn = SimpleBtn(label="Принять", click_func=self.buttonClicked) self.tree.doubleClicked.connect(self.buttonClicked) # self.btn.setFixedSize(80, 30) layout.addWidget(self.btn) self.tree.collapseAll() self.setLayout(layout) self.setMinimumHeight(500) self.setMinimumWidth(600)
def __init__(self, tooltipManager: TooltipManager): super(SettingsEditor, self).__init__() self.tooltipManager = tooltipManager self.setWindowFlag(Qt.WindowContextHelpButtonHint, False) self.setWindowTitle("Edit IDE settings") self.setStyleSheet("background-color: #2D2D30; color: white;") self.setFixedSize(500, 150) self.setWindowIcon(QIcon(main.resource_path("resources/app_icon"))) self.vbox = QVBoxLayout() self.hbox = QHBoxLayout() self.saveButton = QPushButton("Save settings") self.cancelButton = QPushButton("Cancel") self.resetButton = QPushButton("Reset to defaults") self.tooltipLabel = QLabel("<center>Tooltip configuration</centr>") self.instructionsTooltopCheckBox = QCheckBox( "Show instructions tooltips") self.instructionsTooltopCheckBox.setChecked( self.tooltipManager.showInstructionTooltips) self.numbersTooltipCheckBox = QCheckBox("Show converted numbers") self.numbersTooltipCheckBox.setChecked( self.tooltipManager.showNumberConversion) self.vbox.addWidget(self.tooltipLabel) self.vbox.addWidget(self.instructionsTooltopCheckBox) self.vbox.addWidget(self.numbersTooltipCheckBox) self.hbox.addWidget(self.cancelButton) self.hbox.addWidget(self.resetButton) self.hbox.addWidget(self.saveButton) self.vbox.addLayout(self.hbox) self.setLayout(self.vbox) self.saveButton.clicked.connect(self.saveButtonClicked) self.resetButton.clicked.connect(self.resetButtonClicked) self.cancelButton.clicked.connect(self.cancelButtonClicked)
def __init__(self, workspaceConfiguration): super(DefaultWorkspaceEditor, self).__init__() self.workspaceConfiguration: WorkspaceConfiguration = workspaceConfiguration self.setWindowFlag(Qt.WindowContextHelpButtonHint, False) self.setWindowTitle("Edit default workspace") self.setStyleSheet("background-color: #2D2D30; color: white;") self.setFixedSize(500, 150) self.label = QLabel("Default workspace") self.comboBox = QComboBox() self.setWindowIcon(QIcon(main.resource_path("resources/app_icon"))) self.comboBox.addItems( list(self.workspaceConfiguration.getWorkspaces())) defualt = self.workspaceConfiguration.getDefaultWorkspace() self.comboBox.addItem("No default workspace") if defualt: self.comboBox.setCurrentText(defualt) else: self.comboBox.setCurrentText("No default workspace") self.btnSave = QPushButton("Save workspace configuration") self.btnSave.clicked.connect(self.saveConfiguration) self.hbox1 = QHBoxLayout() self.hbox2 = QHBoxLayout() self.vbox = QVBoxLayout() self.hbox1.addWidget(self.label, 1) self.hbox1.addWidget(self.comboBox, 4) self.hbox2.addWidget(self.btnSave) self.vbox.addLayout(self.hbox1) self.vbox.addLayout(self.hbox2) self.setLayout(self.vbox)
def process_input(self): #Handle inputs and events self.game_snake.jumped = False for event in pygame.event.get(): if event.type == pygame.KEYDOWN and not self.direction_lock: if event.key == pygame.K_LEFT and self.direction != "east": self.direction_lock = True self.direction = "west" elif event.key == pygame.K_RIGHT and self.direction != "west": self.direction_lock = True self.direction = "east" elif event.key == pygame.K_DOWN and self.direction != "north": self.direction_lock = True self.direction = "south" elif event.key == pygame.K_UP and self.direction != "south": self.direction_lock = True self.direction = "north" elif event.key == pygame.K_SPACE: if self.jump_cooldown <= 0: self.game_snake.jumped = True jump_sound = pygame.mixer.Sound( main.resource_path( "Mario_Jumping-Mike_Koenig-989896458.wav")) jump_sound.play() if event.type == pygame.VIDEORESIZE: #handle the window resizing self.screen = pygame.display.set_mode((event.w, event.h), pygame.RESIZABLE) self.calc_tile_size() if event.type == pygame.QUIT: self.running = False sys.exit(0)
def __init__(self): super(FileNode, self).__init__() self.menu = QMenu() self.menu.setStyleSheet("background-color: #3E3E42; color: white;") self.eventManager = FileEventManager() self.proxy: FileProxy = None self.saveAction = QAction(QIcon(main.resource_path("resources/save_file.png")), "Save file") self.renameAction = QAction(QIcon(main.resource_path("resources/rename_file.png")), "Rename file") self.deleteAction = QAction(QIcon(main.resource_path("resources/delete_file.png")), "Delete file") self.showInfilesAction = QAction(QIcon(main.resource_path("resources/open_folder.png")), "Show in files") self.menu.addAction(self.showInfilesAction) self.menu.addAction(self.saveAction) self.menu.addAction(self.renameAction) self.menu.addAction(self.deleteAction) self.connectActions()
def __init__(self, workpsaceConfiguration, mainApplicatoin, switch=False): super(WorkspaceConfigurationEditor, self).__init__() self.setWindowIcon(QIcon(main.resource_path("resources/app_icon"))) self.workspaceConfiguration: WorkspaceConfiguration = workpsaceConfiguration self.mainApplication = mainApplicatoin self.switch = switch self.workspaceDirectory = None self.setWindowTitle("Choose a workspace directory") self.setStyleSheet("background-color: #2D2D30; color: white;") self.setWindowFlag(Qt.WindowContextHelpButtonHint, False) #self.setWindowFlag(Qt.WindowStaysOnTopHint, True) self.setFixedSize(500, 150) self.comboBox = QComboBox() self.updateComboBox() self.btnOpen = QPushButton("Open workspace") self.cbDefault = QCheckBox("Set as default workspace") self.btnBrowse = QPushButton("Browse...") self.vbox = QVBoxLayout() self.hbox = QHBoxLayout() self.hbox2 = QHBoxLayout() self.hbox2.addWidget(self.comboBox, 4) self.hbox2.addWidget(self.btnBrowse, 1) self.vbox.addLayout(self.hbox2) self.hbox.addWidget(self.cbDefault) self.hbox.addWidget(self.btnOpen) self.vbox.addSpacing(20) self.vbox.addLayout(self.hbox) self.setLayout(self.vbox) self.btnOpen.clicked.connect(self.loadWorkpace) self.btnBrowse.clicked.connect(self.browseWorkspace) self.btnOpen.setFocus() if len(self.workspaceConfiguration.getWorkspaces()) == 0: self.btnOpen.setEnabled(False)
def __init__(self, screen, difficulty="normal"): ''' Constructor ''' self.difficulty = difficulty if difficulty == "easy": self.game_speed = 4 elif difficulty == "normal": self.game_speed = 7 elif difficulty == "hard": self.game_speed = 10 logo = pygame.image.load(main.resource_path("SnakeIcon.jpg")) pygame.display.set_icon(logo) pygame.display.set_caption("SNAKE") self.screen = screen self.running = True white = (255, 255, 255) self.screen.fill(white) pygame.display.update() self.clock = pygame.time.Clock() self.tile_height = 20 self.tile_width = 20 self.calc_tile_size()
def loadWorkspace(self): toBeDeleted = [] for projectProxy in self.proxy.projects: if os.path.exists(projectProxy.getProjectPath()): projectProxy.parent = self.proxy project = ProjectNode() project.setIcon(0, QIcon(main.resource_path("resources/project.png"))) project.setText(0, projectProxy.path) project.path = projectProxy.path project.proxy = projectProxy project.loadProject() self.addChild(project) self.connectProjectEventHandlers(project) else: msg = QMessageBox() msg.setStyleSheet("background-color: #2D2D30; color: white;") msg.setModal(True) msg.setIcon(QMessageBox.Critical) msg.setText("Failed to import project '{}' because it is deleted from the disk.".format(projectProxy.path)) msg.setWindowTitle("Failed to load a project.") msg.exec_() toBeDeleted.append(projectProxy) for proxy in toBeDeleted: self.proxy.projects.remove(proxy) try: self.saveWorkspace() return True except: return False
def __init__(self, port:str): self.ahk = AHK(executable_path=resource_path("AutoHotkeyU64.exe")) self.pi = midi_driver.SerialController(port) self.__running = False with open("tiltconfig.json", "r") as file: self.config = json.loads(file.read())
def __init__(self, width, height, data): super().__init__() # data is either a tile id specifier (for lava, water, other tiles) # or it's just rock, and # uses list of neighbors to determine which kind of sprite to use # neighbors -> [above, right, below, left] rotate = 0 if data == 186: texture_file = "sprites/bad_lava.png" tile_id = "lava" elif data == 78: texture_file = "sprites/water_t.png" tile_id = "water" elif data == 35: texture_file = "sprites/water_u1.png" tile_id = "water_under" else: tile_id = "rock" if data == [0, 255, 255, 255] or data == [ 0, 78, 255, 255 ] or data == [0, 255, 255, 78]: # standard floor r = random.randint(1, 3) texture_file = "sprites/cave_f" + str(r) + ".png" elif data == [255, 255, 0, 255]: # ceiling r = random.randint(1, 2) texture_file = "sprites/cave_c" + str(r) + ".png" elif data == [255, 0, 255, 255]: # left wall texture_file = "sprites/cave_l1.png" elif data == [255, 255, 255, 0]: # right wall texture_file = "sprites/cave_r1.png" elif data == [0, 0, 255, 255]: # corner like ^^| texture_file = "sprites/cave_ur.png" rotate = 0 elif data == [0, 255, 255, 0]: # corner like |^^ texture_file = "sprites/cave_ur.png" rotate = 90 elif data == [255, 255, 0, 0]: # corner like |_ texture_file = "sprites/cave_ur.png" rotate = 180 elif data == [255, 0, 0, 255]: # corner like _| texture_file = "sprites/cave_ur.png" rotate = -90 else: r = random.randint(1, 5) if r < 3: texture_file = "sprites/cave_d" + str(r) + ".png" rrot = random.randint(0, 3) rots = [0, 90, 180, 270] rotate = rots[rrot] else: texture_file = "sprites/cave_d0.png" tile = pygame.image.load(resource_path(texture_file)).convert_alpha() tile = pygame.transform.scale(tile, [width, height]) if rotate != -1: tile = pygame.transform.rotate(tile, rotate) self.image = tile self.rect = self.image.get_rect() self.name = tile_id
def __init__(self, snippetManager: SnippetManager): super(SnippetEditor, self).__init__() self.snippetManager = snippetManager self.snippetDict = deepcopy(self.snippetManager.codeSnippets) self.setWindowFlag(Qt.WindowContextHelpButtonHint, False) self.setWindowTitle("Edit code snippets") self.setStyleSheet("background-color: #3E3E42; color: white;") self.setFixedSize(700, 400) self.setWindowIcon(QIcon(main.resource_path("resources/app_icon"))) self.listView = QListWidget() self.nameEdit = QLineEdit() self.nameEdit.setStyleSheet( "font-size: 14px; background-color: #1E1E1E; color: white; font-family: comic-sans; border: none;") self.editor = TextEditor() self.editor.setStyleSheet( "font-size: 14px; background-color: #1E1E1E; color: white; font-family: comic-sans; border: none;") self.editor.setTabStopWidth(4 * QFontMetrics(self.font()).width(' ')) self.listView.setStyleSheet("background-color: #2D2D30; color: white;") for snippet in self.snippetManager.getSnippetsAbbs(): self.listView.addItem(SnippetListWidgetItem(snippet)) self.hbox = QHBoxLayout() self.hbox2 = QHBoxLayout() self.hbox3 = QHBoxLayout() self.vbox = QVBoxLayout() self.vbox2 = QVBoxLayout() self.addButton = QPushButton("Add") self.addButton.setStyleSheet("background-color: #2D2D30; color: white;") self.removeButton = QPushButton("Remove") self.removeButton.setStyleSheet("background-color: #2D2D30; color: white;") self.applyButton = QPushButton("Apply") self.applyButton.setStyleSheet("background-color: #2D2D30; color: white;") self.cancelButton = QPushButton("Cancel") self.cancelButton.setStyleSheet("background-color: #2D2D30; color: white;") self.okButton = QPushButton("OK") self.okButton.setStyleSheet("background-color: #2D2D30; color: white;") self.resetButton = QPushButton("Reset to default") self.resetButton.setStyleSheet("background-color: #2D2D30; color: white;") self.vbox.addWidget(self.listView) self.hbox2.addWidget(self.addButton) self.hbox2.addWidget(self.removeButton) self.hbox2.addWidget(self.applyButton) self.vbox.addLayout(self.hbox2) self.vbox2.addWidget(self.nameEdit) self.vbox2.addWidget(self.editor) self.hbox3.addWidget(self.cancelButton) self.hbox3.addWidget(self.resetButton) self.hbox3.addWidget(self.okButton) self.vbox2.addLayout(self.hbox3) self.hbox.addLayout(self.vbox) self.hbox.addLayout(self.vbox2) self.setLayout(self.hbox) self.listView.currentItemChanged.connect(self.updateEditor) self.okButton.clicked.connect(self.okButtonClicked) self.removeButton.clicked.connect(self.removeButtonClicked) self.addButton.clicked.connect(self.addButtonClicked) self.applyButton.clicked.connect(self.appyButtonClicked) self.cancelButton.clicked.connect(self.cancelButtonClicked) self.resetButton.clicked.connect(self.resetButtonClicked)
def increase_multiplier(self): self.score_multiplier += 1 '''https://freesound.org/people/ProjectsU012/sounds/341695/''' multiplier_sound = pygame.mixer.Sound( main.resource_path("341695__projectsu012__coins-1.wav")) multiplier_sound.set_volume(.05) multiplier_sound.play() self.multiplier_animation_life = 15
def die(self): die_color = (128, 0, 0) death_sound = pygame.mixer.Sound( main.resource_path("Computer_Error_Alert.wav")) for body in self.q: body.color = die_color death_sound.play() self.alive = False
def reset(self): self.collides_x = True self.activation_box = pygame.rect.Rect(self.rect.left - 180, self.rect.top - 600, 500, 800) self.message = "" pic = pygame.image.load( resource_path("sprites/cerberus_a.png")).convert_alpha() pic = pygame.transform.scale(pic, [self.rect.width, self.rect.height]) self.image = pic self.triggered = False
def importProject(self, path=None): if not os.path.exists(self.path): self.eventManager.invalidWorkspace.emit(self) return if not path: name = QFileDialog.getExistingDirectory(None, "Import project", ".", QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks) else: name = path if name: projectName = os.path.basename(name) regex = re.compile('[@!#$%^&*()<>?/\|}{~:]') if " " in projectName or regex.search(projectName): msg = QMessageBox() msg.setStyleSheet("background-color: #2D2D30; color: white;") msg.setModal(True) msg.setIcon(QMessageBox.Critical) msg.setText("Project name cannot contain whitespace or special characters.") msg.setWindowTitle("Project import error") msg.exec_() return if os.path.exists(os.path.join(self.path, projectName)) and os.path.join(self.path, projectName) != name: msg = QMessageBox() msg.setStyleSheet("background-color: #2D2D30; color: white;") msg.setModal(True) msg.setIcon(QMessageBox.Critical) msg.setText("Folder with the same name already exists.") msg.setWindowTitle("Project import error") msg.exec_() return for projectProxy in self.proxy.projects: if projectProxy.getProjectPath() == name: msg = QMessageBox() msg.setStyleSheet("background-color: #2D2D30; color: white;") msg.setModal(True) msg.setIcon(QMessageBox.Critical) msg.setText("Project is already a part of the workspace.") msg.setWindowTitle("Project import error") msg.exec_() return project = ProjectNode() project.path = projectName project.proxy.path = projectName project.proxy.parent = self.proxy project.setIcon(0, QIcon(main.resource_path("resources/project.png"))) project.setText(0, projectName) self.addChild(project) newPath = os.path.join(self.path, projectName) if os.path.join(self.path, projectName) != name: os.mkdir(newPath) self.proxy.addProject(project.proxy) sourcePath = name if os.path.join(self.path, projectName) != name else None project.loadProject(sourcePath) self.saveWorkspace() self.connectProjectEventHandlers(project) self.eventManager.projectAdded.emit(project)
def activate(self, trigger): self.activated = True if (trigger): self.triggered = True pic = pygame.image.load( resource_path("sprites/cerberus_b.png")).convert_alpha() pic = pygame.transform.scale(pic, [self.rect.width, self.rect.height]) self.image = pic self.collides_x = False self.collides_y = False
def loadBackupWorkspace(self, ws_path=None): for projectProxy in self.proxy.projects: projectProxy.parent = self.proxy project = ProjectNode() project.setIcon(0, QIcon(main.resource_path("resources/project.png"))) project.setText(0, projectProxy.path) project.path = projectProxy.path project.proxy = projectProxy project.loadProjectBackup() self.addChild(project) self.connectProjectEventHandlers(project) return True
def __init__(self, width, height, texture, lev): super().__init__() self.activated = False self.collides_y = True self.collides_x = True self.landing_depth = 0 pic = pygame.image.load(resource_path(texture)).convert_alpha() pic = pygame.transform.scale(pic, [width, height]) self.image = pic self.rect = self.image.get_rect() self.level = lev
def createQuickAssemblyFile(self): fileName = self.path + ".S" node = AssemblyFileNode() node.setIcon(0, QIcon(main.resource_path("resources/s.png"))) node.setText(0, fileName) node.path = fileName node.proxy = AssemblyFileProxy() node.proxy.path = fileName node.proxy.parent = self.proxy self.addChild(node) os.mknod(os.path.join(self.proxy.getProjectPath(), fileName)) self.proxy.addFile(node.proxy) self.connectFileEventHandlers(node) self.setExpanded(True) return node
def __init__(self): super(NewFileDialog, self).__init__() self.comboBox = QComboBox() self.comboBox.addItem("Assembly file") self.comboBox.addItem("C file") self.lineEdit = QLineEdit() self.lineEdit.setPlaceholderText("Enter file name...") self.setStyleSheet("background-color: #2D2D30; color: white;") self.setWindowIcon(QIcon(main.resource_path("resources/app_icon.ico"))) self.hbox = QHBoxLayout() self.vbox = QVBoxLayout() self.create = QPushButton("Create") self.cancel = QPushButton("Cancel") self.setWindowTitle("New file") self.result = None self.initGUI()