Exemplo n.º 1
0
def update_coordinate_fund_abs(label, player=None, delta_x=0, delta_y=0):
    mongo = MongoManager()
    table_dict = mongo.get_table('GG_6TABLE')

    if player is not None:
        x1 = table_dict[label][str(player)]['x1'] + int(delta_x)
        y1 = table_dict[label][str(player)]['y1'] + int(delta_y)
        x2 = x1 + 88
        y2 = y1 + 23
        label = label + '.' + str(player)
    else:
        pass

    mongo.save_coordinates('GG_6TABLE', label, {
        'x1': x1,
        'y1': y1,
        'x2': x2,
        'y2': y2
    })
Exemplo n.º 2
0
    def save_coordinates(self, label, player=None):
        if not self.cropped:
            pop_up(
                "Image not yet cropped",
                "Before you can mark coordinates, you need to mark or load a top left corner, then crop the image."
            )
            return

        if self.x1 > self.x2 or self.y1 > self.y2:
            pop_up(
                "Invalid coordinates",
                "Top left corner of image is more to the right/bottom the lower right coordinates. Please try again."
            )
            return

        self.table_name = self.ui.table_name.currentText()

        log.info(
            f"Saving coordinates for {label} with coordinates {self.x1, self.y1, self.x2, self.y2}"
        )
        mongo = MongoManager()
        owner = mongo.get_table_owner(self.table_name)

        if owner != COMPUTER_NAME:
            pop_up(
                "Not authorized.",
                "You can only edit your own tables. Please create a new copy or start with a new blank table"
            )
            return

        if player:
            label = label + '.' + player
        mongo.save_coordinates(self.table_name, label, {
            'x1': self.x1,
            'y1': self.y1,
            'x2': self.x2,
            'y2': self.y2
        })