Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions renpy/display/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4325,15 +4325,15 @@ def per_interact(i):
if ev.state & 2:
self.keyboard_focused = ev.gain

if not renpy.game.preferences.audio_when_unfocused:
if not renpy.game.preferences.audio_when_unfocused and not renpy.emscripten:
if not ev.gain:
renpy.audio.audio.pause_all()
else:
renpy.audio.audio.unpause_all()

# If the window becomes inactive as a result of this event
# pause the audio according to preference
if not renpy.game.preferences.audio_when_minimized:
if not renpy.game.preferences.audio_when_minimized and not renpy.emscripten:
if not pygame.display.get_active() and not self.audio_paused:
renpy.audio.audio.pause_all()
self.audio_paused = True
Expand Down
51 changes: 37 additions & 14 deletions renpy/display/im.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,14 +702,11 @@ def __init__(self, filename, **properties):
base = filename.rpartition(".")[0]
extras = base.partition("@")[2].split(",")

for i in extras:
try:
try:
for i in extras:
oversample = float(i)
properties.setdefault('oversample', oversample)
continue
except Exception:
pass

except Exception:
raise Exception("Unknown image modifier %r in %r." % (i, filename))

super(Image, self).__init__(filename, **properties)
Expand Down Expand Up @@ -787,8 +784,6 @@ def load(self, unscaled=False):
else:
return Image("_missing_image.png").load()

raise e

def predict_files(self):

if renpy.loader.loadable(self.filename):
Expand Down Expand Up @@ -891,6 +886,9 @@ def __init__(self, size, *args, **properties):
self.positions = args[0::2]
self.images = [ image(i) for i in args[1::2] ]

# Only supports all the images having the same oversample factor
self.oversample = self.images[0].get_oversample()

def get_hash(self):
rv = 0

Expand All @@ -906,10 +904,13 @@ def load(self):
else:
size = cache.get(self.images[0]).get_size()

os = self.oversample
size = [s*os for s in size]

rv = renpy.display.pgrender.surface(size, True)

for pos, im in zip(self.positions, self.images):
rv.blit(cache.get(im), pos)
rv.blit(cache.get(im), [p*os for p in pos])

return rv

Expand Down Expand Up @@ -944,6 +945,7 @@ def __init__(self, im, width, height, bilinear=True, **properties):
super(Scale, self).__init__(im, width, height, bilinear, **properties)

self.image = im
self.oversample = im.get_oversample()
self.width = int(width)
self.height = int(height)
self.bilinear = bilinear
Expand All @@ -954,17 +956,18 @@ def get_hash(self):
def load(self):

child = cache.get(self.image)
os = self.oversample

if self.bilinear:
try:
renpy.display.render.blit_lock.acquire()
rv = renpy.display.scale.smoothscale(child, (self.width, self.height))
rv = renpy.display.scale.smoothscale(child, (self.width*os, self.height*os))
finally:
renpy.display.render.blit_lock.release()
else:
try:
renpy.display.render.blit_lock.acquire()
rv = renpy.display.pgrender.transform_scale(child, (self.width, self.height))
rv = renpy.display.pgrender.transform_scale(child, (self.width*os, self.height*os))
finally:
renpy.display.render.blit_lock.release()

Expand Down Expand Up @@ -1002,6 +1005,7 @@ def __init__(self, im, width, height=None, bilinear=True, **properties):
super(FactorScale, self).__init__(im, width, height, bilinear, **properties)

self.image = im
self.oversample = im.get_oversample()
self.width = width
self.height = height
self.bilinear = bilinear
Expand Down Expand Up @@ -1063,6 +1067,7 @@ def __init__(self, im, horizontal=False, vertical=False, **properties):
super(Flip, self).__init__(im, horizontal, vertical, **properties)

self.image = im
self.oversample = im.get_oversample()
self.horizontal = horizontal
self.vertical = vertical

Expand Down Expand Up @@ -1105,6 +1110,7 @@ def __init__(self, im, angle, zoom, **properties):
super(Rotozoom, self).__init__(im, angle, zoom, **properties)

self.image = im
self.oversample = im.get_oversample()
self.angle = angle
self.zoom = zoom

Expand Down Expand Up @@ -1152,6 +1158,7 @@ def __init__(self, im, x, y=None, w=None, h=None, **properties):
super(Crop, self).__init__(im, x, y, w, h, **properties)

self.image = im
self.oversample = im.get_oversample()
self.x = x
self.y = y
self.w = w
Expand All @@ -1161,8 +1168,9 @@ def get_hash(self):
return self.image.get_hash()

def load(self):
return cache.get(self.image).subsurface((self.x, self.y,
self.w, self.h))
os = self.oversample
return cache.get(self.image).subsurface((self.x*os, self.y*os,
self.w*os, self.h*os))

def predict_files(self):
return self.image.predict_files()
Expand Down Expand Up @@ -1212,6 +1220,7 @@ def __init__(self, im, rmap=identity, gmap=identity, bmap=identity,
super(Map, self).__init__(im, rmap, gmap, bmap, amap, force_alpha, **properties)

self.image = im
self.oversample = im.get_oversample()
self.rmap = rmap
self.gmap = gmap
self.bmap = bmap
Expand Down Expand Up @@ -1257,6 +1266,7 @@ def __init__(self, im, white, black, force_alpha=False, **properties):
super(Twocolor, self).__init__(im, white, black, force_alpha, **properties)

self.image = im
self.oversample = im.get_oversample()
self.white = white
self.black = black

Expand Down Expand Up @@ -1295,6 +1305,7 @@ def __init__(self, im, rmul=255, gmul=255, bmul=255,
super(Recolor, self).__init__(im, rmul, gmul, bmul, amul, force_alpha, **properties)

self.image = im
self.oversample = im.get_oversample()
self.rmul = rmul + 1
self.gmul = gmul + 1
self.bmul = bmul + 1
Expand Down Expand Up @@ -1344,6 +1355,7 @@ def __init__(self, im, xrad, yrad=None, **properties):
super(Blur, self).__init__(im, xrad, yrad, **properties)

self.image = im
self.oversample = im.get_oversample()
self.rx = xrad
self.ry = xrad if yrad is None else yrad

Expand All @@ -1357,7 +1369,7 @@ def load(self):
ws = renpy.display.pgrender.surface(surf.get_size(), True)
rv = renpy.display.pgrender.surface(surf.get_size(), True)

renpy.display.module.blur(surf, ws, rv, self.rx, self.ry)
renpy.display.module.blur(surf, ws, rv, self.rx*self.oversample, self.ry*self.oversample)

return rv

Expand Down Expand Up @@ -1408,6 +1420,7 @@ def __init__(self, im, matrix, **properties):
super(MatrixColor, self).__init__(im, matrix, **properties)

self.image = im
self.oversample = im.get_oversample()
self.matrix = matrix

def get_hash(self):
Expand Down Expand Up @@ -1831,6 +1844,7 @@ def __init__(self, im, size=None, **properties):

super(Tile, self).__init__(im, size, **properties)
self.image = im
self.oversample = im.get_oversample()
self.size = size

def get_hash(self):
Expand All @@ -1843,6 +1857,10 @@ def load(self):
if size is None:
size = (renpy.config.screen_width, renpy.config.screen_height)

os = self.oversample

size = [round(v*os) for v in size]

surf = cache.get(self.image)

rv = renpy.display.pgrender.surface(size, True)
Expand Down Expand Up @@ -1875,6 +1893,8 @@ class AlphaMask(ImageBase):

Note that this takes different arguments from :func:`AlphaMask`,
which uses the mask's alpha channel.

The two images need to have the same size, and the same oversampling factor.
"""

def __init__(self, base, mask, **properties):
Expand All @@ -1883,6 +1903,9 @@ def __init__(self, base, mask, **properties):
self.base = image(base)
self.mask = image(mask)

# The two images already need to be the same size, they now also need the same oversample.
self.oversample = self.base.get_oversample()

def get_hash(self):
return self.base.get_hash() + self.mask.get_hash()

Expand Down
4 changes: 2 additions & 2 deletions sphinx/source/character_callbacks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The callback is called with at least one keyword argument:
This is true if the dialogue causes an interaction to occur.

Other values of the positional argument and additional keyword arguments may
be supplied in the future. The callback should written to ignore arguments it
be supplied in the future. The callback should be written to ignore arguments it
does not understand.

Example
Expand Down Expand Up @@ -74,6 +74,6 @@ characters::
renpy.sound.play(boopfile)
elif event == "slow_done":
renpy.sound.stop()

define nagata = Character("Naomi", callback=functools.partial(boopy_voice, boopfile="belter_boop.ogg"))
define chrisjen = Character("Chrisjen", callback=boopy_voice)
4 changes: 2 additions & 2 deletions sphinx/source/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@ Occasionally Used

.. var:: config.font_name_map = { }

This is a map from (font name) to (font filepath). It's used to
simplify and shorten ``{font}`` tags, and to give them access to the
This is a map from (font name) to (font filepath/fontgroup). Font names
simplify and shorten ``{font}`` tags, and gives them access to the
:ref:`fontgroup` feature.

.. var:: config.font_replacement_map = { }
Expand Down
3 changes: 0 additions & 3 deletions sphinx/source/im.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ past should no longer be used, as they suffer from inherent problems.
In any case except for `im.Data`, the :func:`Transform` displayable provides
similar functionality in a more general manner, while fixing the problems.

Image manipulators should not be used with oversampled images, or svg images
that might be automatically oversampled, as the size may be incorrect.

.. include:: inc/im_im

im.MatrixColor
Expand Down