def clearselections(self, clearpanel = True, clearstatus = True, clearheal = True, clearcut = True): if self.target is not None: self.target.setbranchstatus() self.target = None self.parttobuild = None self.iconclicked = None panels.selecticon() if clearheal: if self.healmode: game.state.body.core.setbranchstatus() self.healmode = False if clearcut: self.cutmode = False
def handleleftclick(self, mousepos): # TODO: handle dragging vs clicking more reliably if self.clickat is None: # It's a drag return (x0, y0), (x1, y1) = self.clickat, mousepos if abs(x0-x1) + abs(y0-y1) > 25: return vicon = vista.iconhit(mousepos) # Any vista icons pointed to if vicon is not None: self.handleiconclick(vicon) return bicon = panels.iconpoint(mousepos) # Any panel tile or icon pointed to if bicon is not None: panels.selecticon(bicon) return # Click on the main gameplay area if vista.vrect.collidepoint(mousepos): if self.cutmode and self.target is not None: self.target.die() self.clearselections() elif self.healmode and self.target is not None: self.target.autoheal = not self.target.autoheal elif self.parttobuild is not None and self.canbuild and game.state.body.canaddpart(self.parttobuild): if panels.selectedtile is not None: panels.claimtile() if panels.selectedorgan is not None: panels.claimorgan() game.state.body.addpart(self.parttobuild) self.clearselections() else: worldpos = vista.screentoworld(mousepos) if vista.HexGrid.nearesttile(worldpos) == (0,0): settings.showtips = not settings.showtips noise.play("addpart") return # Click on one of the panels self.clearselections()