fixed zero division with async total

This commit is contained in:
Louis Heredero 2024-06-30 22:10:36 +02:00
parent 6351381789
commit 3e3dbcdda8
Signed by: HEL
GPG Key ID: 8D83DE470F8544E7

View File

@ -219,8 +219,9 @@ class Editor:
h2 = self.height / 2 h2 = self.height / 2
x0 = w2 - width / 2 x0 = w2 - width / 2
y0 = h2 - height / 2 y0 = h2 - height / 2
loaded_width = 0 if total == 0 else width * count / total
pygame.draw.rect(self.win, (160, 160, 160), [x0, y0, width, height]) pygame.draw.rect(self.win, (160, 160, 160), [x0, y0, width, height])
pygame.draw.rect(self.win, (90, 250, 90), [x0, y0, width * count / total, height]) pygame.draw.rect(self.win, (90, 250, 90), [x0, y0, loaded_width, height])
self.win.blit(txt, [w2 - txt.get_width() / 2, y0 - txt.get_height() - 5]) self.win.blit(txt, [w2 - txt.get_width() / 2, y0 - txt.get_height() - 5])
pygame.display.flip() pygame.display.flip()