Skip to content

Commit

Permalink
Sometimes the numbers could be a little iffy with pixels so now I'm s…
Browse files Browse the repository at this point in the history
…aying the if you're going to use pixel sizes then say so in the layer.
  • Loading branch information
erodozer committed Jul 11, 2010
1 parent 8c643b9 commit b012bd5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 13 deletions.
17 changes: 17 additions & 0 deletions data/themes/MegaLight V4/rockmeter.ini
Expand Up @@ -3,6 +3,7 @@ text = "Score:"
font = loadingFont
xpos = 425
ypos = 0.15
inPixels = xpos

[layer1:Text]
text = score
Expand All @@ -11,6 +12,7 @@ xpos = 620
ypos = 0.15
useComma = True
alignment = right
inPixels = xpos

[layer2:Text]
text = "%d Combo" % streak
Expand All @@ -26,6 +28,7 @@ font = loadingFont
xpos = 400
ypos = 0.1875
alignment = right
inPixels = xpos

[layer4:Text]
text = "%d Stars" % stars
Expand All @@ -41,6 +44,7 @@ xpos = 620
ypos = .75
alignment = right
rect = (0,1,0,.2)
inPixels = xpos

[layer6:Image]
texture = dots.png
Expand All @@ -51,6 +55,7 @@ yscale = .15
rect = (1.0 - (streak%10/10.0), 1, .2 + .2*(streak/10), .4 + .2*(streak/10))
alignment = right
condition = streak <= streakMax
inPixels = xpos

[layer7:Image]
texture = dots.png
Expand All @@ -61,6 +66,7 @@ ypos = .75
rect = (0, 1, .8, 1)
alignment = right
condition = streak >= streakMax
inPixels = xpos

[layer9:Image]
texture = bars.png
Expand All @@ -70,6 +76,7 @@ xpos = 370
ypos = .7
rect = (0, 1, 0, .33)
alignment = left
inPixels = xscale|yscale|xpos

[layer10:Image]
texture = bars.png
Expand All @@ -79,6 +86,7 @@ xpos = 370
ypos = .7
rect = (0, rock, .33, .67)
alignment = left
inPixels = xscale|yscale|xpos

[layer11:Image]
texture = bars.png
Expand All @@ -88,6 +96,7 @@ xpos = 500
ypos = .7
rect = (0, 1, 0, .33)
alignment = left
inPixels = xscale|yscale|xpos

[layer12:Image]
texture = bars.png
Expand All @@ -97,6 +106,7 @@ xpos = 500
ypos = .7
rect = (0, power, .67, 1)
alignment = left
inPixels = xscale|yscale|xpos

[layer13:Image]
texture = timerhud.png
Expand All @@ -110,6 +120,7 @@ startY = -20
endX = .5
endY = 15
transitionTime = 60
inPixels = startY|endX|endY

[layer14:Image]
texture = timerbar.png
Expand All @@ -120,11 +131,13 @@ ypos = 8
rect = (0, 1,0,.5)
alignment = left
shared = True
inPixels = xscale|yscale|xpos|ypos

[layer14:fx0:Slide]
startX = 0
startY = -20
TransitionTime = 60
inPixels = startX|startY

[layer15:Image]
texture = timerbar.png
Expand All @@ -135,11 +148,13 @@ ypos = 8
rect = (0.0,1.0,.5,1.0)
alignment = left
shared = True
inPixels = yscale|xpos|ypos

[layer15:fx0:Slide]
startX = 0
startY = -20
TransitionTime = 60
inPixels = startX|startY

[layer16:Text]
text = "%d:%02d" % (minutes, seconds)
Expand All @@ -148,6 +163,7 @@ xpos = 50
ypos = 0.7
alignment = center
shared = True
inPixels = xpos

[layer17:Text]
text = "%d:%02d" % (minutesSongLength, secondsSongLength)
Expand All @@ -156,4 +172,5 @@ xpos = 620
ypos = 0.7
alignment = right
shared = True
inPixels = xpos

58 changes: 45 additions & 13 deletions src/Rockmeter.py
Expand Up @@ -93,6 +93,7 @@ def __init__(self, stage, section):
self.color = "#FFFFFF" #color of the image (#FFFFFF is white on text, on images it is full color)
self.rect = (0,1,0,1) #how much of the image do you want rendered (left, right, top, bottom)
self.condition = True #when should the image be shown (by default it will always be shown)
self.inPixels = [] #makes sure to properly scale/position the images in pixels instead of percent

self.effects = []

Expand Down Expand Up @@ -147,21 +148,30 @@ def get(value, type = str, default = None):

self.alignment = eval(get("alignment", str, "center").upper())

#this allows you to scale images in relation to pixels instead
#of percentage of the size of the image.
self.scale[0] *= (self.rect[1] - self.rect[0])
self.scale[1] *= (self.rect[3] - self.rect[2])
if self.scale[0] > 1.0:
#this allows you to scale images in relation to pixels instead
#of percentage of the size of the image.
if "xscale" in self.inPixels:
self.scale[0] /= texture.pixelSize[0]
if self.scale[1] > 1.0:
if "yscale" in self.inPixels:
self.scale[1] /= texture.pixelSize[1]

self.scale[1] = -self.scale[1]
self.scale[0] *= w/640.0
self.scale[1] *= h/480.0

if self.position[0] <= 1.0:
if "xpos" in self.inPixels:
self.position[0] *= w/640.0
else:
self.position[0] *= w
if self.position[1] <= 1.0:

if "ypos" in self.inPixels:
self.position[1] *= h/480.0
else:
self.position[1] *= h


#try:
# self.frameX = get("currentFrameX", int, 1)
#except:
Expand Down Expand Up @@ -236,10 +246,10 @@ def get(value, type = str, default = None):

self.useComma = get("useComma", bool, False)

if self.position[0] > 1.0:
self.position[0] /= w
if self.position[1] > 1.0:
self.position[1] /= h
if "xpos" in self.inPixels:
self.position[0] *= w/640.0
if "ypos" in self.inPixels:
self.position[1] *= h/480.0

def render(self, visibility, playerNum):
w, h, = self.stage.engine.view.geometry[2:4]
Expand Down Expand Up @@ -279,12 +289,32 @@ def get(value, type = str, default = None):
self.endCoord = [eval(get("endX", str, "0.0")), eval(get("endY", str, "0.0"))]

self.position = [eval(get("startX", str, "0.0")), eval(get("startY", str, "0.0"))]

self.inPixels = get("inPixels", str, "").split("|")

w, h, = self.layer.engine.view.geometry[2:4]
if abs(self.startCoord[0]) <= 1.0:

if "startX" in self.inPixels:
self.position[0] *= w/640.0
else:
self.position[0] *= w
if abs(self.startCoord[1]) <= 1.0:

if "startY" in self.inPixels:
self.position[1] *= h/480.0
else:
self.position[1] *= h

if "endX" in self.inPixels:
self.endCoord[0] *= w/640.0
else:
self.endCoord[0] *= w

if "endY" in self.inPixels:
self.endCoord[1] *= h/480.0
else:
self.endCoord[1] *= h


self.reverse = bool(eval(get("reverse", str, "True")))

#how long it takes for the transition to take place
Expand Down Expand Up @@ -367,8 +397,9 @@ def get(value, type = str, default = None):
layer = FontLayer(self, section, font)

layer.text = get("text")
layer.shared = get("shared", bool, False)
layer.shared = get("shared", bool, False)
layer.condition = get("condition", str, "True")
layer.inPixels = get("inPixels", str, "").split("|")

section = section.split(":")[0]
types = ["Slide", "Rotate", "Fade"]
Expand Down Expand Up @@ -403,6 +434,7 @@ def get(value, type = str, default = None):

layer.shared = get("shared", bool, False)
layer.condition = get("condition", str, "True")
layer.inPixels = get("inPixels", str, "").split("|")

layer.rect = eval(get("rect", str, "(0,1,0,1)"))

Expand Down

0 comments on commit b012bd5

Please sign in to comment.