# HG changeset patch # User Stefano Rivera # Date 1282948098 -7200 # Node ID 86e3d5dd7fa64e637a3cf9e74a4f7229a8edffc5 # Parent 4a9f29bae9b05bf9f9753f234c9be700f45ca9d3 Added detergent bottle Item and InteractImageRect class diff -r 4a9f29bae9b0 -r 86e3d5dd7fa6 Resources/images/mess/detergent_lid.png Binary file Resources/images/mess/detergent_lid.png has changed diff -r 4a9f29bae9b0 -r 86e3d5dd7fa6 Resources/images/mess/mess_hall.png Binary file Resources/images/mess/mess_hall.png has changed diff -r 4a9f29bae9b0 -r 86e3d5dd7fa6 docs/walkthrough.rst --- a/docs/walkthrough.rst Sat Aug 28 00:25:26 2010 +0200 +++ b/docs/walkthrough.rst Sat Aug 28 00:28:18 2010 +0200 @@ -58,7 +58,7 @@ Cooling the superconductor -------------------------- -#. Collect the cryo-fluid canister from the Engine Room. +#. Collect an empty dishwashing liquid bottle from the Mess. #. Fill it from an empty cryo-chamber in the Cryo Chamber. #. Place it in the cryo-fluid receptacle in the Engine Room. #. The engine is now working. diff -r 4a9f29bae9b0 -r 86e3d5dd7fa6 gamelib/scenes/mess.py --- a/gamelib/scenes/mess.py Sat Aug 28 00:25:26 2010 +0200 +++ b/gamelib/scenes/mess.py Sat Aug 28 00:28:18 2010 +0200 @@ -6,7 +6,8 @@ from gamelib.cursor import CursorSprite from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage, InteractRectUnion, InteractImage, - InteractAnimated, GenericDescThing) + InteractImageRect, InteractAnimated, + GenericDescThing) class Mess(Scene): @@ -23,6 +24,8 @@ self.add_thing(CansOnShelf()) self.add_thing(Tubes()) self.add_thing(ToMap()) + self.add_thing(DetergentThing()) + self.add_item(DetergentBottle('detergent_bottle')) # Flavour items # extra cans on shelf self.add_thing(GenericDescThing('mess.cans', 1, @@ -37,10 +40,6 @@ (503, 89, 245, 282), (320, 324, 229, 142), ))) - self.add_thing(GenericDescThing('mess.cans', 2, - "Empty plastic containers. They used to hold dishwasher soap.", - ((565, 399, 62, 95),))) - class BaseCan(CloneableItem): @@ -198,6 +197,36 @@ " airtight and ready to hold pressure. Who'd've thought duct" " tape could actually be used to tape ducts?") +class DetergentThing(Thing): + + NAME = "mess.detergent" + + INTERACTS = { + 'present': InteractImageRect(581, 424, 'detergent_lid.png', 565, 399, 62, 95), + 'taken': InteractNoImage(565, 399, 62, 95), + } + + INITIAL = 'present' + + INITIAL_DATA = { + 'taken': False, + } + + def interact_without(self): + if self.get_data('taken'): + return Result("I think one dishwashing liquid bottle is enough for now") + self.set_data('taken', True) + self.set_interact('taken') + self.state.add_inventory_item('detergent_bottle') + return Result("You pick up an empty dishwashing liquid bottle. You can't find any sponges") + + def get_description(self): + return "Empty plastic containers. They used to hold dish washer soap." + +class DetergentBottle(Item): + INVENTORY_IMAGE = 'triangle.png' + CURSOR = CursorSprite('triangle.png', 25, 23) + class ToMap(Door): diff -r 4a9f29bae9b0 -r 86e3d5dd7fa6 gamelib/scenes/scene_widgets.py --- a/gamelib/scenes/scene_widgets.py Sat Aug 28 00:25:26 2010 +0200 +++ b/gamelib/scenes/scene_widgets.py Sat Aug 28 00:28:18 2010 +0200 @@ -81,6 +81,17 @@ self.interact_rect = self.rect +class InteractImageRect(InteractImage): + def __init__(self, x, y, image_name, r_x, r_y, r_w, r_h): + super(InteractImageRect, self).__init__(x, y, image_name) + self._r_pos = (r_x, r_y) + self._r_size = (r_w, r_h) + + def set_thing(self, thing): + super(InteractImageRect, self).set_thing(thing) + self.interact_rect = Rect(self._r_pos, self._r_size) + + class InteractAnimated(Interact): """Interactive with an animation rather than an image"""