comparison pyntnclick/state.py @ 586:cf65e91b30b1 pyntnclick

Use load_image where possible
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 11 Feb 2012 16:56:01 +0200
parents 1b1ab71535bd
children f20d211d2c91
comparison
equal deleted inserted replaced
585:ec13a5a0b213 586:cf65e91b30b1
1 """Utilities and base classes for dealing with scenes.""" 1 """Utilities and base classes for dealing with scenes."""
2 2
3 import copy 3 import copy
4 4
5 from albow.resource import get_image
6 from albow.utils import frame_rect 5 from albow.utils import frame_rect
7 from widgets import BoomLabel 6 from widgets import BoomLabel
8 from pygame.rect import Rect 7 from pygame.rect import Rect
9 from pygame.color import Color 8 from pygame.color import Color
10 9
279 Rect(400 - w / 2, 5, w, h)) 278 Rect(400 - w / 2, 5, w, h))
280 description.draw_all(sub) 279 description.draw_all(sub)
281 280
282 def _cache_background(self): 281 def _cache_background(self):
283 if self.BACKGROUND and not self._background: 282 if self.BACKGROUND and not self._background:
284 self._background = get_image(self.FOLDER, self.BACKGROUND) 283 self._background = self.state.gd.resource.load_image(
284 (self.FOLDER, self.BACKGROUND))
285 285
286 def draw_background(self, surface): 286 def draw_background(self, surface):
287 self._cache_background() 287 self._cache_background()
288 if self._background is not None: 288 if self._background is not None:
289 surface.blit(self._background, self.OFFSET, None) 289 surface.blit(self._background, self.OFFSET, None)
502 self.tool_name = self.TOOL_NAME 502 self.tool_name = self.TOOL_NAME
503 self.inventory_image = None 503 self.inventory_image = None
504 504
505 def _cache_inventory_image(self): 505 def _cache_inventory_image(self):
506 if not self.inventory_image: 506 if not self.inventory_image:
507 self.inventory_image = get_image('items', self.INVENTORY_IMAGE) 507 self.inventory_image = self.state.resource.load_image(
508 'items', self.INVENTORY_IMAGE)
508 509
509 def set_state(self, state): 510 def set_state(self, state):
510 assert self.state is None 511 assert self.state is None
511 self.state = state 512 self.state = state
512 513