timofey260 / RWE-Plus

Better version of official rain world editor
MIT License
27 stars 8 forks source link

Paste to mouse cursor #18

Closed ddemile closed 1 year ago

ddemile commented 1 year ago

Hello, it would be cool if when we do ctrl+v the selection is copied to the mouse cursor

ddemile commented 1 year ago

I fixed it by doing that :

def pastegeo(self):
    try:
        pos = [math.floor((pg.mouse.get_pos()[0] - self.field.rect.x) / self.size),
               math.floor((pg.mouse.get_pos()[1] - self.field.rect.y) / self.size)]
        self.emptyarea()
        geodata = eval(pyperclip.paste())
        if type(geodata) != list:
            return
        for xi, x in enumerate(geodata):
            for yi, y in enumerate(x):
                xpos = -self.xoffset + xi
                ypos = -self.yoffset + yi
                if (self.replaceair and y[0] == 0) or not self.canplaceit(xpos, ypos, xpos, ypos):
                    continue
                self.data["GE"][-self.xoffset + xi + pos[0]][-self.yoffset + yi + pos[1]][self.layer] = y
                self.area[-self.xoffset + xi + pos[0]][-self.yoffset + yi + pos[1]] = 0
        self.detecthistory(["GE"])
        self.renderer.geo_render_area(self.area, self.layer)
        self.rfa()
    except:
        print("Error pasting data!")
timofey260 commented 1 year ago

good idea! will be added to all copy-paste parts