diff --git a/data/themes/MegaLight V4/CustomRMLayers.py b/data/themes/MegaLight V4/CustomRMLayers.py new file mode 100644 index 000000000..4db048699 --- /dev/null +++ b/data/themes/MegaLight V4/CustomRMLayers.py @@ -0,0 +1,38 @@ + +from Rockmeter import * + +class Spinner(ImageLayer): + def __init__(self, stage, section): + + self.stage = stage + super(Spinner, self).__init__(stage, section, os.path.join("themes", self.stage.themename, "rockmeter", "platinum.png")) + + self.xposexpr = ".80" + self.yposexpr = ".80" + + self.condition = "True" + + def updateLayer(self, playerNum): + super(ImageLayer, self).updateLayer(playerNum) + + self.angle += 2 + + def render(self, visibility, playerNum): + + self.updateLayer(playerNum) + + coord = self.position + scale = self.scale + rot = self.angle + color = self.color + alignment = self.alignment + valignment = self.valignment + drawing = self.drawing + rect = self.rect + + #frameX = self.frameX + #frameY = self.frameY + + if bool(eval(self.condition)): + self.engine.drawImage(drawing, scale, coord, rot, color, rect, + alignment = alignment, valignment = valignment) diff --git a/data/themes/MegaLight V4/rockmeter.ini b/data/themes/MegaLight V4/rockmeter.ini index 552666c21..ea903cc40 100644 --- a/data/themes/MegaLight V4/rockmeter.ini +++ b/data/themes/MegaLight V4/rockmeter.ini @@ -176,5 +176,7 @@ transitionTime = 1.0 transitionTimeOut = 1000.0 condition = streak % 50 == 0 and streak > 0 and self.triggerPick() +[layer20:Custom] +classname = Spinner diff --git a/data/themes/MegaLight V4/rockmeter/platinum.png b/data/themes/MegaLight V4/rockmeter/platinum.png new file mode 100755 index 000000000..632717955 Binary files /dev/null and b/data/themes/MegaLight V4/rockmeter/platinum.png differ diff --git a/src/Rockmeter.py b/src/Rockmeter.py index 55a4cb938..6f6374652 100644 --- a/src/Rockmeter.py +++ b/src/Rockmeter.py @@ -41,9 +41,15 @@ import math from math import * +import Version + from Theme import halign, valign from constants import * + +import imp +import Log + #these are the variables for setting the alignment of text and images #when setting them up in the rockmeter.ini you do not have #to put it in all caps, the code will take care of that @@ -150,6 +156,7 @@ def __init__(self, stage, section): self.a = self.getexpr("a", "1.0") self.color = [1.0,1.0,1.0,1.0] + self.shared = False #determines if the element is shared between players in multiplayer modes self.condition = True #when should the image be shown (by default it will always be shown) self.alignment = halign(self.get("alignment", str, "center")) @@ -160,7 +167,8 @@ def __init__(self, stage, section): #makes sure to properly scale/position the images in pixels instead of percent self.effects = [] #various effects associated with the layer - + + # all variables that should be updated during the rendering process # should be in here just for sake of readablity and organization def updateLayer(self, playerNum): @@ -885,14 +893,24 @@ def __init__(self, guitarScene, configFileName, coOp = False): self.config.read(configFileName) self.themename = self.engine.data.themeLabel - + + try: + themepath = os.path.join(Version.dataPath(), "themes", self.themename) + fp, pathname, description = imp.find_module("CustomRMLayers",[themepath]) + self.customRMLayers = imp.load_module("CustomRMLayers", fp, pathname, description) + except ImportError: + self.customRMLayers = None + Log.notice("Custom Rockmeter layers are not available") + # Build the layers for i in range(Rockmeter._layerLimit): types = [ "Image", "Text", - "Circle" + "Circle", + "Custom" ] + for t in types: self.section = "layer%d:%s" % (i, t) if not self.config.has_section(self.section): @@ -902,6 +920,8 @@ def __init__(self, guitarScene, configFileName, coOp = False): self.createFont(self.section, i) elif t == types[2]: self.createCircle(self.section, i) + elif t == types[3]: + self.createCustom(self.section, i) else: self.createImage(self.section, i) break @@ -955,6 +975,14 @@ def loadLayerFX(self, layer, section): break + def createCustom(self, section, number): + + if self.customRMLayers: + classname = self.get("classname") + + layer = eval("self.customRMLayers."+classname+"(self, section)") + self.addLayer(layer, number, layer.shared) + def createFont(self, section, number): font = self.get("font", str, "font")