Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5196a970a0 | |||
| efcbc92e7a |
+10
-4
@@ -181,7 +181,7 @@ class Channel(object):
|
||||
This stores information about the currently-playing music.
|
||||
"""
|
||||
|
||||
def __init__(self, name, default_loop, stop_on_mute):
|
||||
def __init__(self, name, default_loop, stop_on_mute, tight):
|
||||
|
||||
# The name assigned to this channel. This is used to look up
|
||||
# information about the channel in the MusicContext object.
|
||||
@@ -237,6 +237,9 @@ class Channel(object):
|
||||
|
||||
# Should we stop playing on mute?
|
||||
self.stop_on_mute = stop_on_mute
|
||||
|
||||
# Is this channel tight?
|
||||
self.tight = tight
|
||||
|
||||
if default_loop is None:
|
||||
# By default, should we loop the music?
|
||||
@@ -431,7 +434,7 @@ class Channel(object):
|
||||
pss.fadeout(self.number, int(secs * 1000))
|
||||
|
||||
|
||||
def enqueue(self, filenames, loop=True, synchro_start=False, fadein=0, tight=False):
|
||||
def enqueue(self, filenames, loop=True, synchro_start=False, fadein=0, tight=None):
|
||||
|
||||
for filename in filenames:
|
||||
renpy.game.persistent._seen_audio[filename] = True
|
||||
@@ -439,6 +442,9 @@ class Channel(object):
|
||||
if not pcm_ok:
|
||||
return
|
||||
|
||||
if tight is None:
|
||||
tight = self.tight
|
||||
|
||||
for filename in filenames:
|
||||
qe = QueueEntry(filename, int(fadein * 1000), tight)
|
||||
self.queue.append(qe)
|
||||
@@ -496,11 +502,11 @@ all_channels = [ ]
|
||||
channels = { }
|
||||
|
||||
|
||||
def register_channel(name, mixer=None, loop=None, stop_on_mute=True):
|
||||
def register_channel(name, mixer=None, loop=None, stop_on_mute=True, tight=False):
|
||||
if not renpy.game.init_phase:
|
||||
raise Exception("Can't register channel outside of init phase.")
|
||||
|
||||
c = Channel(name, loop, stop_on_mute)
|
||||
c = Channel(name, loop, stop_on_mute, tight)
|
||||
c.mixer = mixer
|
||||
all_channels.append(c)
|
||||
channels[name] = c
|
||||
|
||||
@@ -35,7 +35,7 @@ from renpy.audio.audio import get_channel, get_serial
|
||||
# Part of the public api:
|
||||
from renpy.audio.audio import register_channel, alias_channel
|
||||
|
||||
def play(filenames, channel="music", loop=None, fadeout=None, synchro_start=False, fadein=0, tight=False, if_changed=False):
|
||||
def play(filenames, channel="music", loop=None, fadeout=None, synchro_start=False, fadein=0, tight=None, if_changed=False):
|
||||
"""
|
||||
This stops the music currently playing on the numbered channel, dequeues
|
||||
any queued music, and begins playing the specified file or files. If loop
|
||||
@@ -108,7 +108,7 @@ def play(filenames, channel="music", loop=None, fadeout=None, synchro_start=Fals
|
||||
raise
|
||||
|
||||
|
||||
def queue(filenames, channel="music", loop=None, clear_queue=True, fadein=0, tight=False):
|
||||
def queue(filenames, channel="music", loop=None, clear_queue=True, fadein=0, tight=None):
|
||||
"""
|
||||
This queues the given filenames on the specified channel. If
|
||||
clear_queue is True, then the queue is cleared, making these files
|
||||
|
||||
@@ -1024,7 +1024,7 @@ class Display(object):
|
||||
contents of the window.
|
||||
"""
|
||||
|
||||
surf = renpy.display.module.scale(self.window, scale)
|
||||
surf = renpy.display.scale.smoothscale(self.window, scale)
|
||||
|
||||
sio = cStringIO.StringIO()
|
||||
renpy.display.module.save_png(surf, sio, 0)
|
||||
|
||||
+2
-2
@@ -775,7 +775,7 @@ class Scale(ImageBase):
|
||||
if self.bilinear:
|
||||
try:
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
rv = pygame.transform.smoothscale(child, (self.width, self.height))
|
||||
rv = renpy.display.scale.smoothscale(child, (self.width, self.height))
|
||||
finally:
|
||||
renpy.display.render.blit_lock.release()
|
||||
else:
|
||||
@@ -820,7 +820,7 @@ class FactorScale(ImageBase):
|
||||
if self.bilinear:
|
||||
try:
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
rv = pygame.transform.smoothscale(surf, (width, height))
|
||||
rv = renpy.display.scale.smoothscale(surf, (width, height))
|
||||
finally:
|
||||
renpy.display.render.blit_lock.release()
|
||||
|
||||
|
||||
+64
-6
@@ -67,7 +67,6 @@ def real_bilinear(src, size):
|
||||
def real_transform_scale(surf, size):
|
||||
global real_transform_scale
|
||||
real_transform_scale = pygame.transform.scale
|
||||
|
||||
return real_transform_scale(surf, size)
|
||||
|
||||
# Loads an image, without scaling it.
|
||||
@@ -88,6 +87,50 @@ def image_save_unscaled(surf, dest):
|
||||
pygame.image.save(surf, dest)
|
||||
|
||||
|
||||
if _renpy:
|
||||
real_renpy_pixellate = _renpy.pixellate
|
||||
real_renpy_bilinear = _renpy.bilinear
|
||||
|
||||
def real_smoothscale(src, size, dest=None):
|
||||
"""
|
||||
This scales src up or down to size. This uses both the pixellate
|
||||
and the bilinear operations to handle the scaling.
|
||||
"""
|
||||
|
||||
width, height = size
|
||||
srcwidth, srcheight = src.get_size()
|
||||
iwidth, iheight = srcwidth, srcheight
|
||||
|
||||
if dest is None:
|
||||
dest = PygameSurface(size, src.get_flags(), src)
|
||||
|
||||
if width == 0 or height == 0:
|
||||
return dest
|
||||
|
||||
xshrink = 1
|
||||
yshrink = 1
|
||||
|
||||
while iwidth >= width * 2:
|
||||
xshrink *= 2
|
||||
iwidth /= 2
|
||||
|
||||
while iheight >= height * 2:
|
||||
yshrink *= 2
|
||||
iheight /= 2
|
||||
|
||||
if iwidth != srcwidth or iheight != srcheight:
|
||||
inter = PygameSurface((iwidth, iheight), src.get_flags(), src)
|
||||
real_renpy_pixellate(src, inter, xshrink, yshrink, 1, 1)
|
||||
src = inter
|
||||
|
||||
real_renpy_bilinear(src, dest)
|
||||
|
||||
return dest
|
||||
|
||||
else:
|
||||
real_smoothscale = pygame.transform.smoothscale
|
||||
|
||||
smoothscale = real_smoothscale
|
||||
|
||||
|
||||
def init():
|
||||
@@ -191,7 +234,7 @@ def load_scaling():
|
||||
if scale_fast:
|
||||
scaled = old_transform_scale(full, v2p(full.get_size()))
|
||||
else:
|
||||
scaled = old_transform_smoothscale(full, v2p(full.get_size()))
|
||||
scaled = real_smoothscale(full, v2p(full.get_size()))
|
||||
|
||||
return Surface(scaled, wh=full.get_size())
|
||||
|
||||
@@ -469,11 +512,14 @@ def load_scaling():
|
||||
|
||||
full = old_image_load(*args, **kwargs)
|
||||
|
||||
if full.get_bitsize() < 24:
|
||||
full = full.convert() # Less than 24 bits means no alpha.
|
||||
|
||||
if full.get_masks()[3] == 0:
|
||||
full = full.convert()
|
||||
else:
|
||||
full = full.convert_alpha()
|
||||
|
||||
return surface_scale(full)
|
||||
|
||||
|
||||
pygame.image.load = image_load
|
||||
|
||||
old_transform_scale = pygame.transform.scale
|
||||
@@ -526,7 +572,7 @@ def load_scaling():
|
||||
|
||||
# Ignoring scale2x and chop. The former due to a pending api change,
|
||||
# the latter due to general uselessness.
|
||||
|
||||
|
||||
PygameFont = font_module.Font
|
||||
|
||||
class Font(object):
|
||||
@@ -763,7 +809,19 @@ def load_scaling():
|
||||
pygame.draw.aaline = draw_wrap(pygame.draw.aaline)
|
||||
pygame.draw.aalines = draw_wrap(pygame.draw.aalines)
|
||||
|
||||
# Smoothscale:
|
||||
|
||||
def smoothscale(surf, size, dest=None):
|
||||
if dest is not None:
|
||||
dest = dest.surface
|
||||
|
||||
rv = real_smoothscale(surf.surface, v2p(size), dest)
|
||||
|
||||
if rv is None:
|
||||
return rv
|
||||
else:
|
||||
return Surface(rv, wh=size)
|
||||
|
||||
# Now, put everything from this function's namespace into the
|
||||
# module namespace.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user