Esempio n. 1
0
 def set_str(self, key, value):
     if key == 'framecount':
         i = validInt(value, 1, 0x7FFFFFFF)
         if i != self.framecount:
             self.framecount = i
             for x in self.tex_animations:
                 x.set_frame_count(i)
             self.mark_modified()
     elif key == 'loop':
         loop = validBool(value)
         if self.loop != loop:
             self.loop = loop
             self.mark_modified()
     elif key == 'layerenable':
         if value.startswith('[') or value.startswith('('):  # list/iterable
             items = parseValStr(value)
             for i in range(len(items)):
                 val = validBool(items[i])
                 if val:
                     self.tex_enable(i)
                 else:
                     self.tex_disable(i)
         else:
             key, value = splitKeyVal(value)
             key = validInt(key, 0, 8)
             value = validBool(value)
             if value != self.tex_is_enabled(key):
                 self.tex_enable(key) if value else self.tex_disable(key)
                 self.mark_modified()
Esempio n. 2
0
 def __setitem__(self, key, value):
     key = validFloat(key, 0, self.framecount + .0001)
     if value in ('disabled', 'none', 'remove'):
         self.removeKeyFrame(key)
     else:
         delta = None
         if ':' in value:
             value, delta = splitKeyVal(value)
             delta = validFloat(value, -0x7FFFFFFF, 0x7FFFFFFF)
         value = validFloat(value, -0x7FFFFFFF, 0x7FFFFFFF)
         self.setKeyFrame(value, key, delta)
Esempio n. 3
0
 def set_str(self, key, value):
     if value in ('disabled', 'none', 'remove'):
         is_scale = True if 'scale' in key else False
         self.animations[key].clearFrames(is_scale)
     else:
         keyframes = value.strip('()').split(',')
         anim = self.animations[key]
         for x in keyframes:
             key2, value = splitKeyVal(x)
             anim[key2] = value
     self.mark_modified()
Esempio n. 4
0
 def set_str(self, key, value):
     if key == 'framecount':
         i = validInt(value, 1, 0x7FFFFFFF)
         if i != self.framecount:
             self.framecount = i
             for x in self.tex_animations:
                 x.setFrameCount(i)
             self.mark_modified()
     elif key == 'loop':
         loop = validBool(value)
         if self.loop != loop:
             self.loop = loop
             self.mark_modified()
     elif key == 'layerenable':
         key, value = splitKeyVal(value)
         key = validInt(key, 0, 8)
         value = validBool(value)
         if value != self.texIsEnabled(key):
             self.texEnable(key) if value else self.texDisable(key)
             self.mark_modified()
Esempio n. 5
0
 def __setitem__(self, key, value):
     is_color = True if "color" in key else False
     if "control" in key:
         key2, value = splitKeyVal(value)
         if not key2:
             raise ValueError(self.LC_ERROR.format(key))
         if is_color:
             self.colorLightControl[key2] = value
         else:
             self.alphaLightControl[key2] = value
     elif 'enable' in key:
         val = validBool(value)
         if "material" in key:
             if is_color:
                 self.materialColorEnabled = val
             else:
                 self.materialAlphaEnabled = val
         elif "ambient" in key:
             if is_color:
                 self.ambientColorEnabled = val
             else:
                 self.ambientAlphaEnabled = val
         elif "raster" in key:
             if is_color:
                 self.rasterColorEnabled = val
             else:
                 self.rasterAlphaEnabled = val
     else:
         int_vals = parse_color(value)
         if not int_vals:
             raise ValueError(self.LC_ERROR.format(key))
         if "material" in key:
             self.materialColor = int_vals
         elif "ambient" in key:
             self.ambientColor = int_vals
         else:
             raise ValueError(self.LC_ERROR.format(key))
Esempio n. 6
0
 def set_str(self, key, value):
     if key == 'loop':
         loop = validBool(value)
         if loop != self.loop:
             self.loop = loop
             self.mark_modified()
     elif key == 'framecount':
         framecount = validInt(value, 0, 0x7FFFFFFF)
         if framecount != self.framecount:
             self.framecount = framecount
             self.mark_modified()
     elif key == 'keyframe':
         frame_ids = []
         names = []
         # gather/validate ids and names
         keyframes = value.strip('()').split(',')
         max = self.framecount + .001
         for x in keyframes:
             frame_id, tex_name = splitKeyVal(x)
             frame_ids.append(validFloat(frame_id, 0, max))
             names.append(tex_name)
         for i in range(len(frame_ids)):
             self.set_frame(frame_ids[i], names[i])
         self.mark_modified()