Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/properties.py
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-11-19 14:38:39 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-11-24 04:21:55 (GMT)
commit6a390f667cca2b78ede0db7ca4877201462b886e (patch)
tree37eb22eb8a8e0341513888daae332e4fa49ffa1f /tutorius/properties.py
parentf3bd8e06e2cd0acebad6dbd77ff32ff3de1c2860 (diff)
LP 448319 : Addition of resource properties, insertion of BubbleMessageWImg from Dave, modification of Engine to get action_addresses
Diffstat (limited to 'tutorius/properties.py')
-rw-r--r--tutorius/properties.py50
1 files changed, 49 insertions, 1 deletions
diff --git a/tutorius/properties.py b/tutorius/properties.py
index aab6a0c..a462782 100644
--- a/tutorius/properties.py
+++ b/tutorius/properties.py
@@ -24,7 +24,9 @@ from copy import copy, deepcopy
from .constraints import Constraint, \
UpperLimitConstraint, LowerLimitConstraint, \
MaxSizeConstraint, MinSizeConstraint, \
- ColorConstraint, FileConstraint, BooleanConstraint, EnumConstraint
+ ColorConstraint, FileConstraint, BooleanConstraint, EnumConstraint, \
+ ResourceConstraint
+
from .propwidgets import PropWidget, \
StringPropWidget, \
UAMPropWidget, \
@@ -96,6 +98,21 @@ class TPropContainer(object):
except AttributeError:
return object.__setattr__(self, name, value)
+ def replace_property(self, prop_name, new_prop):
+ """
+ Changes the content of a property. This is done in order to support
+ the insertion of executable properties in the place of a portable
+ property. The typical exemple is that a resource property needs to
+ be changed into a file property with the correct file name, since the
+ installation location will be different on every platform.
+
+ @param prop_name The name of the property to be changed
+ @param new_prop The new property to insert
+ @raise AttributeError of the mentionned property doesn't exist
+ """
+ props = object.__getattribute__(self, "_props")
+ props.__setitem__(prop_name, new_prop)
+
def get_properties(self):
"""
Return the list of property names.
@@ -284,6 +301,37 @@ class TFileProperty(TutoriusProperty):
self.default = self.validate(path)
+class TResourceProperty(TutoriusProperty):
+ """
+ Represents a resource in the tutorial. A resource is a file with a specific
+ name that exists under the tutorials folder. It is distributed alongside the
+ tutorial itself.
+
+ When the system encounters a resource, it knows that it refers to a file in
+ the resource folder and that it should translate this resource name to an
+ absolute file name before it is executed.
+
+ E.g. An image is added to a tutorial in an action. On doing so, the creator
+ adds a resource to the tutorial, then saves its name in the resource
+ property of that action. When this tutorial is executed, the Engine
+ replaces all the TResourceProperties inside the action by their equivalent
+ TFileProperties with absolute paths, so that they can be used on any
+ machine.
+ """
+ def __init__(self, resource_name=""):
+ """
+ Creates a new resource pointing to an existing resource.
+
+ @param resource_name The file name of the resource (should be only the
+ file name itself, no directory information)
+ """
+ TutoriusProperty.__init__(self)
+ self.type = "resource"
+
+ self.resource_cons = ResourceConstraint()
+
+ self.default = self.validate("")
+
class TEnumProperty(TutoriusProperty):
"""
Represents a value in a given enumeration. This means that the value will