annotate bGrease/__init__.py @ 115:26e65f27dbd7

"Open" will now not be shown in the context menu when the lockable is locked. "Lock" will not not be shown in the context menu when the lockable is open.
author KarstenBock@gmx.net
date Mon, 03 Oct 2011 14:12:17 +0200
parents ff3e395abf91
children a6bbb732b27b
rev   line source
5
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
1 #############################################################################
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
2 #
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
3 # Copyright (c) 2010 by Casey Duncan and contributors
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
4 # All Rights Reserved.
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
5 #
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
6 # This software is subject to the provisions of the MIT License
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
7 # A copy of the license should accompany this distribution.
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
8 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
9 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
10 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
11 #
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
12 #############################################################################
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
13
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
14 __versioninfo__ = (0, 3, 0)
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
15 __version__ = '.'.join(str(n) for n in __versioninfo__)
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
16
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
17 __all__ = ('BaseWorld', 'Entity', 'System', 'Renderer')
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
18
7
710f299ed275 Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents: 5
diff changeset
19 import component
710f299ed275 Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents: 5
diff changeset
20 import geometry
710f299ed275 Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents: 5
diff changeset
21 import collision
710f299ed275 Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents: 5
diff changeset
22 from entity import Entity
710f299ed275 Made sure that the modules in the current directory are imported, and not those
KarstenBock@gmx.net
parents: 5
diff changeset
23 from world import BaseWorld
5
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
24
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
25 import abc
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
26
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
27 class System(object):
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
28 """Grease system abstract base class. Systems define behaviorial aspects
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
29 of a |World|. All systems must define a :meth:`step`
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
30 method that is invoked by the world each timestep. User-defined systems
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
31 are not required to subclass this class.
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
32
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
33 See :ref:`an example system from the tutorial <tut-system-example>`.
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
34 """
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
35 __metaclass__ = abc.ABCMeta
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
36
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
37 world = None
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
38 """The |World| this system belongs to"""
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
39
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
40 def set_world(self, world):
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
41 """Bind the system to a world"""
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
42 self.world = world
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
43
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
44 @abc.abstractmethod
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
45 def step(self, dt):
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
46 """Execute a time step for the system. Must be defined
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
47 by all system classes.
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
48
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
49 :param dt: Time since last step invocation
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
50 :type dt: float
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
51 """
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
52
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
53 class Renderer(object):
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
54 """Grease renderer abstract base class. Renderers define the presentation
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
55 of a |World|. All renderers must define a :meth:`draw`
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
56 method that is invoked by the world when the display needs to be redrawn.
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
57 User-defined renderers are not required to subclass this class.
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
58
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
59 See :ref:`an example renderer from the tutorial <tut-renderer-example>`.
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
60 """
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
61 __metaclass__ = abc.ABCMeta
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
62
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
63 world = None
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
64 """The |World| this renderer belongs to"""
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
65
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
66 def set_world(self, world):
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
67 """Bind the system to a world"""
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
68 self.world = world
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
69
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
70 @abc.abstractmethod
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
71 def draw(self):
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
72 """Issue drawing commands for this renderer. Must be defined
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
73 for all renderer classes.
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
74 """
bc88f7d5ca8b Added base files for grease
KarstenBock@gmx.net
parents:
diff changeset
75