Update inventory.py
parent
5be699c21e
commit
05a789d4ce
16
inventory.py
16
inventory.py
|
|
@ -53,14 +53,13 @@ class Inventory:
|
||||||
start_x = self.x + self.padding
|
start_x = self.x + self.padding
|
||||||
start_y = self.y + 70
|
start_y = self.y + 70
|
||||||
|
|
||||||
# Convert slots to list for display
|
|
||||||
items_list = list(self.slots.items())
|
items_list = list(self.slots.items())
|
||||||
|
|
||||||
index = 0
|
index = 0
|
||||||
mouse = pygame.mouse.get_pos()
|
mouse = pygame.mouse.get_pos()
|
||||||
|
|
||||||
for row in range(self.grid_rows):
|
for row in range(self.grid_rows):
|
||||||
for col in range(self.grid_cols):
|
for col in range(self.grid_cols):
|
||||||
|
|
||||||
cell_rect = pygame.Rect(
|
cell_rect = pygame.Rect(
|
||||||
start_x + col * (self.cell_size + self.cell_padding),
|
start_x + col * (self.cell_size + self.cell_padding),
|
||||||
start_y + row * (self.cell_size + self.cell_padding),
|
start_y + row * (self.cell_size + self.cell_padding),
|
||||||
|
|
@ -85,19 +84,12 @@ class Inventory:
|
||||||
)
|
)
|
||||||
pygame.draw.rect(screen, item.color, icon_rect)
|
pygame.draw.rect(screen, item.color, icon_rect)
|
||||||
|
|
||||||
# Draw amount
|
# Draw amount if stack > 1
|
||||||
|
if amount > 1:
|
||||||
amount_text = font.render(str(amount), True, (255, 255, 255))
|
amount_text = font.render(str(amount), True, (255, 255, 255))
|
||||||
screen.blit(amount_text, (cell_rect.x + 2, cell_rect.y + 2))
|
screen.blit(amount_text, (cell_rect.x + 2, cell_rect.y + 2))
|
||||||
|
|
||||||
# Tooltip on hover
|
# Tooltip when hovering
|
||||||
if cell_rect.collidepoint(mouse):
|
|
||||||
tooltip = font.render(item.name, True, (255, 255, 0))
|
|
||||||
screen.blit(tooltip, (mouse[0] + 10, mouse[1] + 10))
|
|
||||||
|
|
||||||
index += 1
|
|
||||||
screen.blit(amount_text, (cell_rect.x + 2, cell_rect.y + 2))
|
|
||||||
|
|
||||||
# Tooltip on hover
|
|
||||||
if cell_rect.collidepoint(mouse):
|
if cell_rect.collidepoint(mouse):
|
||||||
tooltip = font.render(item.name, True, (255, 255, 0))
|
tooltip = font.render(item.name, True, (255, 255, 0))
|
||||||
screen.blit(tooltip, (mouse[0] + 10, mouse[1] + 10))
|
screen.blit(tooltip, (mouse[0] + 10, mouse[1] + 10))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue