def edge_finish(x, y): self.point_2 = self.scene.walkpath.path_point_near_point((x, y)) if self.point_2 and self.point_1 != self.point_2: self.editor.change_selection(self) self.set_selected_item( self.scene.walkpath.add_edge(self.point_1, self.point_2)) editorstate.set_status_message('')
def new_camera_point(self, button=None): editorstate.set_status_message("Click to place a camera point") def point_placer(x, y): self.editor.change_selection(self) self.set_selected_item(self.scene.camera.add_point(x, y)) editorstate.set_status_message('') self.editor.click_actions.append(point_placer)
def edge_finish(x, y): self.point_2 = self.scene.walkpath.path_point_near_point((x, y)) if self.point_2: self.editor.change_selection(self) self.set_selected_item(None) self.scene.walkpath.remove_edge(self.point_1, self.point_2) editorstate.set_status_message('')
def actor_button_action(self, button=None): def actor_placer(x, y): self.dragging_item = self.scene.new_actor(button.text, attrs = {'x': x, 'y': y}) editorstate.set_status_message('') self.editor.click_actions.append(actor_placer) editorstate.set_status_message("Click to place %s" % button.text)
def edge_setup(x, y): self.point_1 = self.scene.walkpath.path_point_near_point((x, y)) if self.point_1: editorstate.set_status_message('Click the destination point') else: # empty the queue, never mind self.click_actions = collections.deque() editorstate.set_status_message('')
def edge_setup(x, y): self.point_1 = self.scene.walkpath.path_point_near_point((x, y)) if self.point_1: editorstate.set_status_message('Click the destination point') else: # empty the queue, never mind self.editor.empty_click_actions() editorstate.set_status_message('')
def edge_finish(x, y): self.point_2 = self.scene.walkpath.path_point_near_point((x, y)) if not self.point_2: self.point_2 = self.scene.walkpath.add_point(x, y) if self.point_1 != self.point_2: self.editor.change_selection(self.editor.edge_ed) new_edge = self.scene.walkpath.add_edge(self.point_1, self.point_2) self.editor.edge_ed.set_selected_item(new_edge) editorstate.set_status_message('')
def wants_drag(self, x, y): if self.placing_point: self.editor.change_selection(self) self.set_selected_item(self.scene.walkpath.add_point(x, y)) editorstate.set_status_message('') return True else: self.dragging_item = self.scene.walkpath.path_point_near_point((x, y)) return self.dragging_item is not None
def wants_drag(self, x, y): if self.placing_point: self.editor.change_selection(self) self.set_selected_item(self.scene.walkpath.add_point(x, y)) editorstate.set_status_message('') return True else: self.dragging_item = self.scene.walkpath.path_point_near_point( (x, y)) return self.dragging_item is not None
def point_deleter(x, y): identifier = self.scene.walkpath.path_point_near_point((x, y)) self.scene.walkpath.remove_point(identifier) to_delete = set() for (a, b) in self.scene.walkpath.edges.viewkeys(): if a == identifier or b == identifier: to_delete.add((a, b)) for x in to_delete: print 'deleting', x del self.scene.walkpath.edges[x] editorstate.set_status_message('')
def delete_point(self, button=None): self.selected_item = None def point_deleter(x, y): identifier = self.scene.walkpath.path_point_near_point((x, y)) self.scene.walkpath.remove_point(identifier) to_delete = set() for (a, b) in self.scene.walkpath.edges.viewkeys(): if a == identifier or b == identifier: to_delete.add((a, b)) for x in to_delete: print 'deleting', x del self.scene.walkpath.edges[x] editorstate.set_status_message('') self.editor.click_actions.append(point_deleter) editorstate.set_status_message("Click a point to delete it")
def new_edge_from_point(self, button=None): if not self.selected_item: return self.point_1 = self.selected_item def edge_finish(x, y): self.point_2 = self.scene.walkpath.path_point_near_point((x, y)) if not self.point_2: self.point_2 = self.scene.walkpath.add_point(x, y) if self.point_1 != self.point_2: self.editor.change_selection(self.editor.edge_ed) new_edge = self.scene.walkpath.add_edge(self.point_1, self.point_2) self.editor.edge_ed.set_selected_item(new_edge) editorstate.set_status_message('') editorstate.set_status_message('Click to place the destination point') self.editor.click_actions.append(edge_finish)
def new_edge(self, button=None): editorstate.set_status_message('Click the source point') def edge_setup(x, y): self.point_1 = self.scene.walkpath.path_point_near_point((x, y)) if self.point_1: editorstate.set_status_message('Click the destination point') else: # empty the queue, never mind self.editor.empty_click_actions() editorstate.set_status_message('') def edge_finish(x, y): self.point_2 = self.scene.walkpath.path_point_near_point((x, y)) if self.point_2 and self.point_1 != self.point_2: self.editor.change_selection(self) self.set_selected_item(self.scene.walkpath.add_edge(self.point_1, self.point_2)) editorstate.set_status_message('') self.editor.click_actions.append(edge_setup) self.editor.click_actions.append(edge_finish)
def new_edge_from_point(self, button=None): if not self.selected_item: return self.point_1 = self.selected_item def edge_finish(x, y): self.point_2 = self.scene.walkpath.path_point_near_point((x, y)) if not self.point_2: self.point_2 = self.scene.walkpath.add_point(x, y) if self.point_1 != self.point_2: self.editor.change_selection(self.editor.edge_ed) new_edge = self.scene.walkpath.add_edge( self.point_1, self.point_2) self.editor.edge_ed.set_selected_item(new_edge) editorstate.set_status_message('') editorstate.set_status_message('Click to place the destination point') self.editor.click_actions.append(edge_finish)
def new_edge(self, button=None): editorstate.set_status_message('Click the source point') def edge_setup(x, y): self.point_1 = self.scene.walkpath.path_point_near_point((x, y)) if self.point_1: editorstate.set_status_message('Click the destination point') else: # empty the queue, never mind self.editor.empty_click_actions() editorstate.set_status_message('') def edge_finish(x, y): self.point_2 = self.scene.walkpath.path_point_near_point((x, y)) if self.point_2 and self.point_1 != self.point_2: self.editor.change_selection(self) self.set_selected_item( self.scene.walkpath.add_edge(self.point_1, self.point_2)) editorstate.set_status_message('') self.editor.click_actions.append(edge_setup) self.editor.click_actions.append(edge_finish)
def point_placer(x, y): self.editor.change_selection(self) self.set_selected_item(self.scene.camera.add_point(x, y)) editorstate.set_status_message('')
def point_deleter(x, y): self.scene.camera.remove_point(self.scene.camera.camera_point_near_point((x, y))) editorstate.set_status_message('')
def delete_camera_point(self, button=None): def point_deleter(x, y): self.scene.camera.remove_point(self.scene.camera.camera_point_near_point((x, y))) editorstate.set_status_message('') self.editor.click_actions.append(point_deleter) editorstate.set_status_message("Click a camera point to delete it")
def new_point(self, button=None): editorstate.set_status_message("Click to place a point") self.placing_point = True
def actor_placer(x, y): self.dragging_item = self.scene.new_actor(button.text, attrs = {'x': x, 'y': y}) editorstate.set_status_message('')