Compare commits
139 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f9d9f9dee | |||
| 293508969a | |||
| 5908546828 | |||
| b80f6a1e8e | |||
| d3434400cd | |||
| 11a20e21d1 | |||
| 0de0aa292a | |||
| aa0d357bdc | |||
| ca16c24fc4 | |||
| d32db0c9a3 | |||
| 60b9f0522c | |||
| d3c58da216 | |||
| e81044465d | |||
| 75a0741c33 | |||
| a68f4af35d | |||
| 9e0932af5a | |||
| 112c0bce66 | |||
| d640759ab8 | |||
| bb628bd9cd | |||
| ed3c0937d9 | |||
| 48cf0cd50a | |||
| a39934d0c4 | |||
| 2a9eaf9dea | |||
| 0d07b4dcb6 | |||
| 76fbce3304 | |||
| 510eba1628 | |||
| c37fede2f1 | |||
| 3ccb522e33 | |||
| a067d0c830 | |||
| 2f82c7466d | |||
| 9e9a6b7f8e | |||
| 9db36905c6 | |||
| e5ae260c33 | |||
| 4e3a579eed | |||
| 4cd1e62978 | |||
| babd95540d | |||
| 905de15883 | |||
| 00f31ca351 | |||
| cb82cfae3e | |||
| 1a36f1feb7 | |||
| d1893c6e17 | |||
| 330ec0e68c | |||
| 830304b79e | |||
| dc5940ac56 | |||
| 437cc8784f | |||
| 8e08e6647a | |||
| 60a21a7bbe | |||
| 6251a86cfe | |||
| 580ea88cd0 | |||
| c93734cd9c | |||
| f7e2f0dd1a | |||
| 943b505ec2 | |||
| 75304e781a | |||
| d73326af11 | |||
| 670eca455d | |||
| ab38c2e521 | |||
| 1ded9b2959 | |||
| 7c67db202f | |||
| ba4321956b | |||
| 79e4b5a2fa | |||
| 5b84b0507c | |||
| c15d13e543 | |||
| 3ef27787b4 | |||
| e84e8102b6 | |||
| ee8d1a531a | |||
| 2d4d1903b2 | |||
| d1cc2015ac | |||
| be44f0805c | |||
| 612207510c | |||
| c2875e4a7d | |||
| b8d2433a79 | |||
| 43cc8b425a | |||
| 7962073926 | |||
| 281a35bc66 | |||
| a4f6a18bb8 | |||
| f50adf3ed2 | |||
| f1b78b4a05 | |||
| 7953f8adf1 | |||
| f3062e6f22 | |||
| fe4eda2661 | |||
| 2be10ba84c | |||
| 82b3d0e78e | |||
| 079180f4ce | |||
| 9a3369c27c | |||
| b87e10cdcf | |||
| 229c542d68 | |||
| 3478d079d6 | |||
| a7fc70402e | |||
| 5df6419a59 | |||
| 8b03bc5072 | |||
| 6ca8a37cc6 | |||
| 9fbf1ee1b2 | |||
| 84b7741fa4 | |||
| e6efaa5f9f | |||
| 330c2e247e | |||
| 923f56273c | |||
| 8b761aa689 | |||
| fa538db11f | |||
| e4dff364e1 | |||
| 5d7faf0274 | |||
| ee0cafcf67 | |||
| 94506ad601 | |||
| f0b54ea7f9 | |||
| 11dbf23952 | |||
| 8957aa4f2f | |||
| 7e206549fd | |||
| f365408bbc | |||
| 0bdf5cd904 | |||
| 9ba28e5cd2 | |||
| 49ae49a82e | |||
| 23e9fffd68 | |||
| 1c6df6230d | |||
| 88584747e4 | |||
| d77d1c266b | |||
| d9738a2809 | |||
| a40d997413 | |||
| d444558b06 | |||
| 07164c156b | |||
| 625df4c7ac | |||
| 75a047e18d | |||
| ade3d4f935 | |||
| a0bc604d92 | |||
| 10743adcee | |||
| 4e9af0789c | |||
| 83f7ef6fd7 | |||
| b2850cc6ac | |||
| e41c71da98 | |||
| 0e3468872b | |||
| cd6a49e679 | |||
| 494e1a944b | |||
| 1361825f5d | |||
| b977e20156 | |||
| ff858e599d | |||
| 4c7bdede29 | |||
| 4208836d77 | |||
| 592341f5b1 | |||
| bc41ebadce | |||
| 0deadb41ee | |||
| 076624c4c2 |
+8
-4
@@ -5,10 +5,6 @@ renpy.app
|
||||
**/*.rpyc
|
||||
**/*.rpyb
|
||||
**/*.rpymc
|
||||
_renpy.c
|
||||
nativemidi.c
|
||||
sound.c
|
||||
winmixer.c
|
||||
jedit
|
||||
lint.txt
|
||||
renpy.code
|
||||
@@ -54,3 +50,11 @@ speedtest
|
||||
styles.txt
|
||||
renpygame-demo/game/saves
|
||||
./lib
|
||||
Lucy Sprites.zip
|
||||
translate
|
||||
close_bugs.py
|
||||
.logplayer
|
||||
scite-6.10.zip
|
||||
scite-renpy-20090803.zip
|
||||
module/cython.sh
|
||||
old_demo
|
||||
|
||||
+216
@@ -1,3 +1,215 @@
|
||||
New in Ren'Py 6.10.1
|
||||
--------------------
|
||||
|
||||
Images and other surfaces are now created with a 1px transparent border
|
||||
around them. This change allows transform to work correctly with a 1:1
|
||||
scale, where as previously Ren'Py would blur the image slightly, while
|
||||
trying to ensure it never accessed a pixel outside of the original
|
||||
image bounds.
|
||||
|
||||
|
||||
ATL now has a "function" statement, which allows an ATL transform to
|
||||
use the same functions that are supplied to Transform.
|
||||
|
||||
|
||||
The layout.imagemap_main_menu and layout.imagemap_load_save functions
|
||||
now allow one to define variant screens. This allows one to select an
|
||||
imagemap main menu screen to use, or to define different screens for
|
||||
loading and saving.
|
||||
|
||||
|
||||
The overlay semantics were changed such that transitions apply to overlays
|
||||
in the same way they apply to everything else. (So, for example, dissolves
|
||||
will apply to overlays.)
|
||||
|
||||
|
||||
The image text tag can now take any textual image representation. So
|
||||
something like {image=eileen happy} is legal, if odd.
|
||||
|
||||
|
||||
The following numbered bugs were fixed:
|
||||
|
||||
lp:366412 - Ren'Py could crash on shift+R at the main menu, under some circumstances.
|
||||
|
||||
lp:485631 - The transfer of state from a transfrom to a transform supplied as part of an image didn't work.
|
||||
|
||||
lp:487688 - non-ASCII characters didn't display in the window title bar.
|
||||
|
||||
lp:487701 - Ren'Py didn't work when in a directory containing non-ASCII characters.
|
||||
|
||||
lp:488814 - Scaling to the same size could blur an image.
|
||||
|
||||
lp:489212 - Interpolation didn't work when the starting value was None.
|
||||
|
||||
lp:493062 - One could roll back into an imagemap main menu.
|
||||
|
||||
lp:494779 - The window shown state wasn't being tracked correctly.
|
||||
|
||||
lp:494820 - Error handling in ATL hid too many error messages.
|
||||
|
||||
A major bug that caused Ren'Py to fail as scaling was enabled was fixed.
|
||||
|
||||
A number of minor bugs revealed by pyflakes were fixed.
|
||||
|
||||
|
||||
|
||||
New in Ren'Py 6.10.0
|
||||
--------------------
|
||||
|
||||
The demo game is in the process of being converted into a new tutorial
|
||||
game, which shows recommended Ren'Py code examples rather than
|
||||
requiring the user to learn from the game itself's source code.
|
||||
|
||||
|
||||
Ren'Py now supports an Animation and Transformation language
|
||||
(ATL). This provides a convenient syntax for animating an image, or
|
||||
transforming it by positioning it, rotating it, zooming it, and
|
||||
adjusting its opacity.
|
||||
|
||||
To a large extent, ATL supersedes the Animation, TransitionAnimation,
|
||||
anim.SMAnimation, anim.Blink, Zoom, FactorZoom, RotoZoom, SizeZoom,
|
||||
LiveCrop, Move, Pan, Position, Motion, and Revolve functions, and
|
||||
perhaps others. As it allows properties to be scripted, ATL is more
|
||||
powerful that all of these functions. (For example, many of these
|
||||
functions can only do relatively simple repeats, while ATL allows
|
||||
complex patterns to be easily specified.)
|
||||
|
||||
ATL can be used in the new transform statement, and new variants of
|
||||
the image, scene, and show statements.
|
||||
|
||||
|
||||
When an image is shown, Ren'Py checks to see if there was a previous
|
||||
image with that tag, and if that image used a transform. If this is
|
||||
true, Ren'Py does two things:
|
||||
|
||||
# If the new image is not a transform, it wraps it in a transform.
|
||||
# The transform is initialized to have the properties of the old transform.
|
||||
|
||||
The generally has the effect of "remembering" the position of images
|
||||
shown on the screen. In some cases, this memory effect may override a
|
||||
position encoded into an image. In that case, the image must be hidden
|
||||
and shown again.
|
||||
|
||||
|
||||
The default positions (left, right, center, truecenter, offscreenleft,
|
||||
and offscreenright) are now defined as ATL transforms. This means that showing
|
||||
an image at such a position will cause the position to be remembered.
|
||||
|
||||
|
||||
Support for Arabic and Hebrew has been added to Ren'Py. To enable this
|
||||
support, config.rtl needs to be set to True. It may also be necessary
|
||||
to set various style properties to do a credible job of right-to-left
|
||||
layout.)
|
||||
|
||||
|
||||
The freetype library has been updated, and we have added support for
|
||||
the use of TrueType collections. Using a name of 0@font.ttc will get
|
||||
the first font in the collection, 1@font.ttc will get the second font,
|
||||
and so on.
|
||||
|
||||
|
||||
The displayable code has been adjusted to consider strings that do not
|
||||
contain at least one dot as image references. Now, one can write
|
||||
"eileen happy" to refer to an image with that name.
|
||||
|
||||
|
||||
A pause statement has been added to Ren'Py.
|
||||
|
||||
|
||||
The new config.auto_load variable allows you to specify a save file
|
||||
that is automatically loaded when Ren'Py starts. For example, setting
|
||||
this to "1" loads the game in save slot 1. This is intended for use by
|
||||
developers, so they can easily return to a point in the game after
|
||||
restarting Ren'Py.
|
||||
|
||||
|
||||
The layout.imagemap_yesno_prompt now supports a prompt_images
|
||||
argument, which is can be used to specify images to replace the
|
||||
text of a yes/no prompt.
|
||||
|
||||
|
||||
The new ui.tag function allows one to specify the image tag of a UI
|
||||
widget. This can have positive interactions with transforms.
|
||||
|
||||
|
||||
Ren'Py now has a define statement, which combines into a single
|
||||
statement running code at init time, and assigning it to a
|
||||
variable. Ren'Py keeps track of these definitions, which may in the
|
||||
future make it easier for editors to determine where something is
|
||||
defined.
|
||||
|
||||
|
||||
The new config.window_overlay_functions variable contains a list of
|
||||
functions that should be called only when once the dialogue window has
|
||||
been shown.
|
||||
|
||||
|
||||
The new config.automatic_images variable, when set correctly, will
|
||||
cause Ren'Py to automatically define images for appropriately-named
|
||||
image files found in the archives and game directory.
|
||||
|
||||
|
||||
Python blocks are now compiled in a mode that allows the python "with"
|
||||
statement. Container displayables now support the context manager
|
||||
protocol, automatically closing at the end of a with block. (Note
|
||||
that the python with statement postdates the Ren'Py with statement,
|
||||
and has totally different semantics.)
|
||||
|
||||
|
||||
The play and queue statements now take optional loop and noloop
|
||||
modifiers, which force looping (or lack of looping) on that channel.
|
||||
The play statement takes an if_changed modifier, which prevents a song
|
||||
from being restarted if it is already playing on the channel. [doc]
|
||||
|
||||
|
||||
Ren'Py now allows save games to be deleted. To do this, select a save
|
||||
game (either with the keyboard, or by hovering the mouse over it), and
|
||||
hit delete.
|
||||
|
||||
|
||||
Buttons now take a keymap argument, which specifies an alternate
|
||||
keymap that is used when the button is focused.
|
||||
|
||||
|
||||
Added the Image Location Picker to the Developer (shift+D) menu. This
|
||||
tool lets the user pick an image, and then pick locations that
|
||||
image. It displays the mouse coordinates, imagemap rectangle, and
|
||||
cropping rectangle.
|
||||
|
||||
|
||||
Added a FPS meter to the Developer (shift+D) menu.
|
||||
|
||||
Added a .001s sleep for frames that are framerate-limited. This should
|
||||
prevent Ren'Py from consuming all CPU unless the game is CPU-bound.
|
||||
|
||||
|
||||
Added config.file_open_callback, which allows Ren'Py to load files
|
||||
from user-definable archive types.
|
||||
|
||||
|
||||
Added the renpy.get_roll_forward function, which is the infrastructure
|
||||
needed to create a button that lets the user roll forward.
|
||||
|
||||
|
||||
Changed MoveTransition to preserve the timebases of the thing being moved
|
||||
in all circumstances.
|
||||
|
||||
|
||||
Ren'Py is now built using SDL-1.2.13. On Linux systems with pulseaudio
|
||||
support, it will use pulseaudio for audio output.
|
||||
|
||||
|
||||
Fixed a bug with archive files that could cause crashing in some
|
||||
circumstances.
|
||||
|
||||
Fixed a bug that prevented {w=1} from working.
|
||||
|
||||
Fixed a bug that prevented style.rebuild from working.
|
||||
|
||||
Fixed a potential segfault bug with certain transforms, zooms, and
|
||||
rotations.
|
||||
|
||||
|
||||
New in Ren'Py 6.9.3
|
||||
-------------------
|
||||
|
||||
@@ -41,6 +253,10 @@ Allow config.layer_clipping to specify layers that are larger than the
|
||||
screen.
|
||||
|
||||
|
||||
The various layouts now change the mouse to the gamemenu or mainmenu
|
||||
mouse, as appropriate.
|
||||
|
||||
|
||||
This distribution include a new NVL-mode tutorial, teaching people how
|
||||
to make NVL-mode games.
|
||||
|
||||
|
||||
+4
-2
@@ -22,8 +22,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
Please see each individual source file for a list of copyright
|
||||
holders. The pictures of Eileen in the demo are Copyright 2006
|
||||
Piroshki, under the same terms.
|
||||
holders. The artwork in the demo is released by various copyright
|
||||
holders, under the same terms.
|
||||
|
||||
|
||||
The Ren'Py module, the Ren'Py windows binaries, and the various Ren'Py
|
||||
launchers may contain code taken from the following projects:
|
||||
@@ -36,6 +37,7 @@ launchers may contain code taken from the following projects:
|
||||
* SDL_mixer (LGPL)
|
||||
* Freetype (LGPL)
|
||||
* FFmpeg (LGPL)
|
||||
* Fribidi (LGPL)
|
||||
* jpeg (JPEG License)
|
||||
* libpng (PNG license)
|
||||
* zlib (Zlib License)
|
||||
|
||||
Regular → Executable
+2
-2
@@ -1,4 +1,4 @@
|
||||
1#!/usr/bin/env python
|
||||
#!/usr/bin/env python
|
||||
|
||||
import collections
|
||||
import glob
|
||||
@@ -73,7 +73,7 @@ init python:
|
||||
# print "#:", v
|
||||
# print "#, python-format"
|
||||
|
||||
print >>f, " %r," % unicode(k)
|
||||
print >>f, " u\"%s\"," % unicode(k)
|
||||
|
||||
print >>f, """\
|
||||
]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# This file contains warpers that are used by ATL. They need to be defined
|
||||
# early, so Ren'Py knows about them when parsing other files.
|
||||
|
||||
python early hide:
|
||||
|
||||
# pause is defined internally, but would look like:
|
||||
#
|
||||
# @renpy.atl_warper
|
||||
# def pause(t):
|
||||
# if t >= 1.0:
|
||||
# return 1.0
|
||||
# else:
|
||||
# return 0.0
|
||||
|
||||
@renpy.atl_warper
|
||||
def linear(t):
|
||||
return t
|
||||
|
||||
@renpy.atl_warper
|
||||
def easeout(x):
|
||||
import math
|
||||
return 1.0 - math.cos(x * math.pi / 2.0)
|
||||
|
||||
@renpy.atl_warper
|
||||
def easein(x):
|
||||
import math
|
||||
return math.cos((1.0 - x) * math.pi / 2.0)
|
||||
|
||||
@renpy.atl_warper
|
||||
def ease(x):
|
||||
import math
|
||||
return .5 - math.cos(math.pi * x) / 2.0
|
||||
@@ -15,6 +15,18 @@ init -1210 python:
|
||||
|
||||
if version <= (6, 9, 1):
|
||||
store.library = store.config
|
||||
|
||||
if version <= (6, 9, 3):
|
||||
|
||||
# Before 6.10, these were positions, rather than transforms.
|
||||
store.left = Position(xalign=0.0)
|
||||
store.center = Position(xalign=0.5)
|
||||
store.truecenter = Position(xalign=0.5, yalign=0.5)
|
||||
store.right = Position(xalign=1.0)
|
||||
store.offscreenleft = Position(xpos=0.0, xanchor=1.0)
|
||||
store.offscreenright = Position(xpos=1.0, xanchor=0.0)
|
||||
|
||||
|
||||
|
||||
init 1210 python hide::
|
||||
|
||||
|
||||
+25
-14
@@ -3,24 +3,37 @@
|
||||
# directory so that it's easy for an updated version of all of these
|
||||
# definitions.
|
||||
|
||||
init -1110:
|
||||
# These are positions that can be used inside at clauses. We set
|
||||
# them up here so that they can be used throughout the program.
|
||||
transform left:
|
||||
xpos 0.0 xanchor 0.0 ypos 1.0 yanchor 1.0
|
||||
|
||||
transform right:
|
||||
xpos 1.0 xanchor 1.0 ypos 1.0 yanchor 1.0
|
||||
|
||||
transform center:
|
||||
xpos 0.5 xanchor 0.5 ypos 1.0 yanchor 1.0
|
||||
|
||||
transform truecenter:
|
||||
xpos 0.5 xanchor 0.5 ypos 0.5 yanchor 0.5
|
||||
|
||||
# Offscreen positions for use with the move transition. Images at
|
||||
# these positions are still shown (and consume
|
||||
# resources)... remember to hide the image after the transition.
|
||||
transform offscreenleft:
|
||||
xpos 0.0 xanchor 1.0 ypos 1.0 yanchor 1.0
|
||||
|
||||
transform offscreenright:
|
||||
xpos 1.0 xanchor 0.0 ypos 1.0 yanchor 1.0
|
||||
|
||||
|
||||
init -1110 python:
|
||||
|
||||
_define = define = object()
|
||||
|
||||
# Positions ##############################################################
|
||||
|
||||
# These are positions that can be used inside at clauses. We set
|
||||
# them up here so that they can be used throughout the program.
|
||||
left = Position(xalign=0.0)
|
||||
center = Position(xalign=0.5)
|
||||
truecenter = Position(xalign=0.5, yalign=0.5)
|
||||
right = Position(xalign=1.0)
|
||||
|
||||
# Offscreen positions for use with the move transition. Images at
|
||||
# these positions are still shown (and consume
|
||||
# resources)... remember to hide the image after the transition.
|
||||
offscreenleft = Position(xpos=0.0, xanchor=1.0)
|
||||
offscreenright = Position(xpos=1.0, xanchor=0.0)
|
||||
|
||||
# Transitions ############################################################
|
||||
|
||||
@@ -140,8 +153,6 @@ init -1110 python:
|
||||
zoomin = MoveTransition(0.5, enter_factory=ZoomInOut(0.01, 1.0))
|
||||
zoomout = MoveTransition(0.5, leave_factory=ZoomInOut(1.0, 0.01))
|
||||
zoominout = MoveTransition(0.5, enter_factory=ZoomInOut(0.01, 1.0), leave_factory=ZoomInOut(1.0, 0.01))
|
||||
|
||||
|
||||
|
||||
# These shake the screen up and down for a quarter second.
|
||||
# The delay needs to be an integer multiple of the period.
|
||||
|
||||
+23
-13
@@ -288,13 +288,14 @@ init -1105 python hide:
|
||||
|
||||
|
||||
@layout
|
||||
def imagemap_main_menu(ground, selected, hotspots):
|
||||
def imagemap_main_menu(ground, selected, hotspots, idle=None, variant=None):
|
||||
renpy.load_module("_layout/imagemap_main_menu")
|
||||
|
||||
config.main_menu_ground = ground
|
||||
config.main_menu_selected = selected
|
||||
config.main_menu_hotspots = hotspots
|
||||
|
||||
config.main_menu_ground[variant] = ground
|
||||
config.main_menu_selected[variant] = selected
|
||||
config.main_menu_hotspots[variant] = hotspots
|
||||
config.main_menu_idle[variant] = idle
|
||||
|
||||
@layout
|
||||
def imagemap_navigation(ground, idle, hover, selected_idle, selected_hover,
|
||||
hotspots):
|
||||
@@ -322,7 +323,7 @@ init -1105 python hide:
|
||||
config.preferences_hotspots = hotspots
|
||||
|
||||
@layout
|
||||
def imagemap_yesno_prompt(ground, idle, hover, hotspots):
|
||||
def imagemap_yesno_prompt(ground, idle, hover, hotspots, prompt_images={ }):
|
||||
|
||||
renpy.load_module("_layout/imagemap_yesno_prompt")
|
||||
|
||||
@@ -330,16 +331,25 @@ init -1105 python hide:
|
||||
config.yesno_prompt_idle = idle
|
||||
config.yesno_prompt_hover = hover
|
||||
config.yesno_prompt_hotspots = hotspots
|
||||
config.yesno_prompt_message_images = prompt_images
|
||||
|
||||
@layout
|
||||
def imagemap_load_save(ground, idle, hover, selected_idle, selected_hover,
|
||||
hotspots):
|
||||
hotspots, variant=None):
|
||||
|
||||
renpy.load_module("_layout/imagemap_load_save")
|
||||
|
||||
config.load_save_ground = ground
|
||||
config.load_save_idle = idle
|
||||
config.load_save_hover = hover
|
||||
config.load_save_selected_idle = selected_idle
|
||||
config.load_save_selected_hover = selected_hover
|
||||
config.load_save_hotspots = hotspots
|
||||
config.load_save_ground[variant] = ground
|
||||
config.load_save_idle[variant] = idle
|
||||
config.load_save_hover[variant] = hover
|
||||
config.load_save_selected_idle[variant] = selected_idle
|
||||
config.load_save_selected_hover[variant] = selected_hover
|
||||
config.load_save_hotspots[variant] = hotspots
|
||||
|
||||
|
||||
layout.ARE_YOU_SURE = u"Are you sure?"
|
||||
layout.DELETE_SAVE = u"Are you sure you want to delete this save?"
|
||||
layout.OVERWRITE_SAVE = u"Are you sure you want to overwrite your save?"
|
||||
layout.LOADING = u"Loading will lose unsaved progress.\nAre you sure you want to do this?"
|
||||
layout.QUIT = u"Are you sure you want to quit?"
|
||||
layout.MAIN_MENU = u"Are you sure you want to return to the main menu?\nThis will lose unsaved progress."
|
||||
|
||||
+83
-10
@@ -49,6 +49,12 @@ init -1180 python:
|
||||
# preference when the game is first run.
|
||||
config.default_text_cps = None
|
||||
|
||||
# Should we automatically define images?
|
||||
config.automatic_images = None
|
||||
|
||||
# A save to automatically load, if it exists.
|
||||
config.auto_load = None
|
||||
|
||||
# This is updated to give the user an idea of where a save is
|
||||
# taking place.
|
||||
save_name = ''
|
||||
@@ -330,6 +336,8 @@ label _save_reload_game:
|
||||
renpy.pause(0)
|
||||
renpy.save("reload", "reload save game")
|
||||
|
||||
renpy.music.stop()
|
||||
|
||||
persistent._reload_save = "reload"
|
||||
|
||||
ui.add(Solid((0, 0, 0, 255)))
|
||||
@@ -662,9 +670,11 @@ label _start:
|
||||
for i in config.start_callbacks:
|
||||
i()
|
||||
|
||||
# call _check_module from _call__check_module_1
|
||||
call _load_reload_game from _call__load_reload_game_1
|
||||
|
||||
if not _restart and config.auto_load and renpy.can_load(config.auto_load):
|
||||
$ renpy.load(config.auto_load)
|
||||
|
||||
scene black
|
||||
|
||||
if not _restart:
|
||||
@@ -692,18 +702,24 @@ label _start:
|
||||
# Clean out any residual scene from the splashscreen.
|
||||
scene black
|
||||
|
||||
if _restart is None:
|
||||
$ renpy.transition(config.end_splash_transition)
|
||||
else:
|
||||
$ renpy.transition(_restart[0])
|
||||
jump expression _restart[1]
|
||||
|
||||
# This has to be python, to deal with a case where _restart may
|
||||
# change across a shift-reload.
|
||||
python:
|
||||
if _restart is None:
|
||||
renpy.transition(config.end_splash_transition)
|
||||
else:
|
||||
renpy.transition(_restart[0])
|
||||
renpy.jump(_restart[1])
|
||||
|
||||
label _invoke_main_menu:
|
||||
|
||||
if _restart:
|
||||
$ renpy.call_in_new_context(_restart[2])
|
||||
else:
|
||||
$ renpy.call_in_new_context("_main_menu")
|
||||
# Again, this has to be python.
|
||||
python:
|
||||
if _restart:
|
||||
renpy.call_in_new_context(_restart[2])
|
||||
else:
|
||||
renpy.call_in_new_context("_main_menu")
|
||||
|
||||
|
||||
# If the main menu returns, then start the game.
|
||||
@@ -741,3 +757,60 @@ label _main_menu_screen:
|
||||
jump expression "_library_main_menu"
|
||||
|
||||
return
|
||||
|
||||
init 1180 python hide:
|
||||
|
||||
def create_automatic_images():
|
||||
|
||||
seps = config.automatic_images
|
||||
|
||||
if seps is True:
|
||||
seps = [ ' ', '/', '_' ]
|
||||
|
||||
for dir, fn in renpy.loader.listdirfiles():
|
||||
|
||||
if fn.startswith("_"):
|
||||
continue
|
||||
|
||||
# Only .png and .jpg
|
||||
if not fn.lower().endswith(".png") and not fn.lower().endswith(".jpg"):
|
||||
continue
|
||||
|
||||
# Strip the extension, replace slashes.
|
||||
shortfn = fn[:-4].replace("\\", "/")
|
||||
|
||||
# Determine the name.
|
||||
name = ( shortfn, )
|
||||
for sep in seps:
|
||||
name = tuple(j for i in name for j in i.split(sep))
|
||||
|
||||
# Only names of 2 components or more.
|
||||
if len(name) < 2:
|
||||
continue
|
||||
|
||||
# Reject if it already exists.
|
||||
if name in renpy.exports.images:
|
||||
continue
|
||||
|
||||
renpy.image(name, fn)
|
||||
|
||||
if config.automatic_images:
|
||||
create_automatic_images()
|
||||
|
||||
|
||||
# Load the developer screen, if necessary.
|
||||
init 1180 python hide:
|
||||
|
||||
if config.developer:
|
||||
renpy.load_module("_developer")
|
||||
|
||||
# Entry point for the developer screen. The rest of it is loaded from
|
||||
# _developer.rpym
|
||||
label _developer:
|
||||
|
||||
if not config.developer:
|
||||
return
|
||||
|
||||
call _enter_menu from _call__enter_menu_4
|
||||
|
||||
jump expression "_developer_screen"
|
||||
|
||||
+2
-2
@@ -31,13 +31,13 @@ init -1150 python:
|
||||
label _quit_prompt:
|
||||
$ renpy.loadsave.force_autosave()
|
||||
|
||||
if layout.yesno_prompt(None, u"Are you sure you want to quit?"):
|
||||
if layout.yesno_prompt(None, layout.QUIT):
|
||||
jump _quit
|
||||
else:
|
||||
return
|
||||
|
||||
label _main_menu_prompt:
|
||||
if layout.yesno_prompt(None, u"Are you sure you want to return to the main menu?\nThis will lose unsaved progress."):
|
||||
if layout.yesno_prompt(None, layout.MAIN_MENU):
|
||||
$ renpy.full_restart(transition=config.game_main_transition)
|
||||
else:
|
||||
return
|
||||
|
||||
@@ -255,6 +255,8 @@ init -1100 python:
|
||||
|
||||
return rv
|
||||
|
||||
NVLSpeaker = NVLCharacter
|
||||
|
||||
config.nvl_adv_transition = None
|
||||
config.adv_nvl_transition = None
|
||||
|
||||
|
||||
@@ -63,15 +63,19 @@ init -1080 python:
|
||||
|
||||
def init_values(self, sizes):
|
||||
def to_abs_(value, size):
|
||||
if isinstance(value, float):
|
||||
if type(value) == float:
|
||||
return value * size
|
||||
else:
|
||||
return value
|
||||
|
||||
def coord_(c):
|
||||
|
||||
if len(c) == 2:
|
||||
c = c + (0, 0)
|
||||
|
||||
return ( to_abs_(c[0], sizes[0]) - to_abs_(c[2], sizes[2]),
|
||||
to_abs_(c[1], sizes[1]) - to_abs_(c[3], sizes[3]) )
|
||||
|
||||
|
||||
for p in self.points:
|
||||
for i in range(1, len(p)):
|
||||
p[i] = coord_(p[i])
|
||||
@@ -122,8 +126,8 @@ init -1080 python:
|
||||
t3 = t**3
|
||||
|
||||
result = [ t_ppp * start[i] + t_pp * self.points[segment][2][i] + t_p * self.points[segment][3][i] + t3 * end[i] for i in 0,1 ]
|
||||
|
||||
return ( int(result[0]), int(result[1]), 0, 0 )
|
||||
|
||||
return ( absolute(result[0]), absolute(result[1]), 0, 0 )
|
||||
|
||||
def SplineMotion(points, time, child=None, anchors=(0.5, 0.5), repeat=False, bounce=False, anim_timebase=False, style='default', time_warp=None, **properties):
|
||||
return Motion(_SplineInterpolator(points, anchors), time, child, repeat=repeat, bounce=bounce, anim_timebase=anim_timebase, style=style, time_warp=time_warp, add_sizes=True, **properties)
|
||||
|
||||
+79
-13
@@ -67,6 +67,8 @@ python early hide:
|
||||
fadeout = "None"
|
||||
fadein = "0"
|
||||
channel = None
|
||||
loop = None
|
||||
if_changed = False
|
||||
|
||||
while True:
|
||||
|
||||
@@ -93,13 +95,27 @@ python early hide:
|
||||
renpy.error('expected simple expression')
|
||||
|
||||
continue
|
||||
|
||||
|
||||
if l.keyword('loop'):
|
||||
loop = True
|
||||
continue
|
||||
|
||||
if l.keyword('noloop'):
|
||||
loop = False
|
||||
continue
|
||||
|
||||
if l.keyword('if_changed'):
|
||||
if_changed = True
|
||||
continue
|
||||
|
||||
renpy.error('could not parse statement.')
|
||||
|
||||
return dict(file=file,
|
||||
fadeout=fadeout,
|
||||
fadein=fadein,
|
||||
channel=channel)
|
||||
channel=channel,
|
||||
loop=loop,
|
||||
if_changed=if_changed)
|
||||
|
||||
def execute_play_music(p):
|
||||
|
||||
@@ -111,7 +127,9 @@ python early hide:
|
||||
renpy.music.play(eval(p["file"]),
|
||||
fadeout=eval(p["fadeout"]),
|
||||
fadein=eval(p["fadein"]),
|
||||
channel=channel)
|
||||
channel=channel,
|
||||
loop=p.get("loop", None),
|
||||
if_changed=p.get("if_changed", False))
|
||||
|
||||
def predict_play_music(p):
|
||||
return [ ]
|
||||
@@ -145,16 +163,26 @@ python early hide:
|
||||
renpy.error("queue requires a file")
|
||||
|
||||
channel = None
|
||||
|
||||
if l.keyword('channel'):
|
||||
channel = l.simple_expression()
|
||||
if channel is None:
|
||||
renpy.error('expected simple expression')
|
||||
loop = None
|
||||
|
||||
while not l.eol():
|
||||
|
||||
if l.keyword('channel'):
|
||||
channel = l.simple_expression()
|
||||
if channel is None:
|
||||
renpy.error('expected simple expression')
|
||||
|
||||
if not l.eol():
|
||||
renpy.error("expected end of line")
|
||||
if l.keyword('loop'):
|
||||
loop = True
|
||||
continue
|
||||
|
||||
if l.keyword('noloop'):
|
||||
loop = False
|
||||
continue
|
||||
|
||||
return dict(file=file, channel=channel)
|
||||
renpy.error('expected end of line')
|
||||
|
||||
return dict(file=file, channel=channel, loop=loop)
|
||||
|
||||
def execute_queue_music(p):
|
||||
if p["channel"] is not None:
|
||||
@@ -162,7 +190,11 @@ python early hide:
|
||||
else:
|
||||
channel = 7
|
||||
|
||||
renpy.music.queue(eval(p["file"]), channel=channel)
|
||||
renpy.music.queue(
|
||||
eval(p["file"]),
|
||||
channel=channel,
|
||||
loop=p.get("loop", None))
|
||||
|
||||
|
||||
renpy.statements.register('queue music',
|
||||
parse=parse_queue_music,
|
||||
@@ -324,7 +356,9 @@ python early hide:
|
||||
lint=lint_stop_generic)
|
||||
|
||||
|
||||
# The "window show" and "window hide" statements.
|
||||
##########################################################################
|
||||
# "window show" and "window hide" statements.
|
||||
|
||||
def parse_window(l):
|
||||
p = l.simple_expression()
|
||||
if not l.eol():
|
||||
@@ -371,7 +405,39 @@ python early hide:
|
||||
parse=parse_window,
|
||||
execute=execute_window_hide,
|
||||
lint=lint_window)
|
||||
|
||||
##########################################################################
|
||||
# Pause statement.
|
||||
|
||||
def parse_pause(l):
|
||||
|
||||
delay = l.simple_expression()
|
||||
|
||||
if not l.eol():
|
||||
renpy.error("expected end of line.")
|
||||
|
||||
return { "delay" : delay }
|
||||
|
||||
def lint_pause(p):
|
||||
|
||||
if p["delay"]:
|
||||
_try_eval(p["delay"], 'pause statement')
|
||||
|
||||
def execute_pause(p):
|
||||
|
||||
if p["delay"]:
|
||||
delay = eval(p["delay"])
|
||||
renpy.with_statement(Pause(delay))
|
||||
else:
|
||||
renpy.pause()
|
||||
|
||||
|
||||
renpy.statements.register('pause',
|
||||
parse=parse_pause,
|
||||
lint=lint_pause,
|
||||
execute=execute_pause)
|
||||
|
||||
|
||||
|
||||
init -1200 python:
|
||||
|
||||
|
||||
@@ -203,6 +203,8 @@ init -1090 python:
|
||||
# Motions, zooms, rotozooms, and transforms.
|
||||
style.motion.xanchor = 0
|
||||
style.motion.yanchor = 0
|
||||
style.motion.xpos = 0
|
||||
style.motion.ypos = 0
|
||||
|
||||
# Windows.
|
||||
style.window.background = Solid((0, 0, 0, 192))
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. Glyphs imported from Arev fonts are (c) Tavmjung Bah (see below)
|
||||
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
|
||||
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
|
||||
|
||||
Bitstream Vera Fonts Copyright
|
||||
------------------------------
|
||||
@@ -95,4 +96,4 @@ dealings in this Font Software without prior written authorization
|
||||
from Tavmjong Bah. For further information, contact: tavmjong @ free
|
||||
. fr.
|
||||
|
||||
$Id: LICENSE 778 2006-04-20 18:14:24Z moyogo $
|
||||
$Id: LICENSE 2133 2007-11-28 02:46:28Z lechimp $
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
# Entry point for the developer console.
|
||||
label _developer:
|
||||
|
||||
if not config.developer:
|
||||
return
|
||||
|
||||
call _enter_menu from _call__enter_menu_4
|
||||
# This file contains the developer screen, which contains tools that might
|
||||
# be of interest to people making Ren'Py games.
|
||||
|
||||
label _developer_screen:
|
||||
|
||||
@@ -19,11 +15,13 @@ label _developer_screen:
|
||||
|
||||
sg = "developer_menu"
|
||||
|
||||
layout.button("Return", None, clicked=ui.returns(True), size_group=sg)
|
||||
layout.button("Reload Game (Shift+R)", None, clicked=ui.callsinnewcontext("_save_reload_game"), size_group=sg)
|
||||
layout.button("Variable Viewer", None, clicked=ui.jumps("_debugger_screen"), size_group=sg)
|
||||
layout.button("Theme Test", None, clicked=ui.jumps("_theme_test"), size_group=sg)
|
||||
layout.button("Style Hierarchy", None, clicked=ui.jumps("_style_hierarchy"), size_group=sg)
|
||||
layout.button(u"Return", None, clicked=ui.returns(True), size_group=sg)
|
||||
layout.button(u"Reload Game (Shift+R)", None, clicked=ui.callsinnewcontext("_save_reload_game"), size_group=sg)
|
||||
layout.button(u"Variable Viewer", None, clicked=ui.jumps("_debugger_screen"), size_group=sg)
|
||||
layout.button(u"Theme Test", None, clicked=ui.jumps("_theme_test"), size_group=sg)
|
||||
layout.button(u"Style Hierarchy", None, clicked=ui.jumps("_style_hierarchy"), size_group=sg)
|
||||
layout.button(u"FPS Meter", None, clicked=ui.jumps("_fps_meter"), size_group=sg)
|
||||
layout.button(u"Image Location Picker", None, clicked=ui.jumps("_image_location_picker"), size_group=sg)
|
||||
|
||||
ui.close()
|
||||
ui.interact()
|
||||
@@ -287,3 +285,185 @@ init 1050 python:
|
||||
config.missing_show = __missing_show_callback
|
||||
config.missing_hide = __missing_hide_callback
|
||||
config.overlay_functions.append(__missing_overlay)
|
||||
|
||||
init -1050 python:
|
||||
|
||||
class __FPSMeter(object):
|
||||
|
||||
def __init__(self):
|
||||
self.last_frames = None
|
||||
self.last_time = None
|
||||
|
||||
def __call__(self, st, at):
|
||||
|
||||
if self.last_time is not None:
|
||||
frames = config.frames - self.last_frames
|
||||
time = st - self.last_time
|
||||
|
||||
text = "FPS: %.1f" % (frames / time)
|
||||
|
||||
else:
|
||||
text = "FPS: --.-"
|
||||
|
||||
self.last_frames = config.frames
|
||||
self.last_time = st
|
||||
|
||||
return Text(text, xalign=1.0), .5
|
||||
|
||||
label _fps_meter:
|
||||
|
||||
python hide:
|
||||
def fps_overlay():
|
||||
ui.add(DynamicDisplayable(__FPSMeter()))
|
||||
|
||||
# We normally don't want to change this at runtime... but here
|
||||
# it's okay, because we don't want to save the FPS meter anyway.
|
||||
#
|
||||
# Do as I say, not as I do.
|
||||
config.overlay_functions.append(fps_overlay)
|
||||
|
||||
return
|
||||
|
||||
init python:
|
||||
|
||||
# This is a displayable that can keep track of the mouse coordinates,
|
||||
# and show them to the user.
|
||||
class __ImageLocationPicker(renpy.Displayable):
|
||||
|
||||
def __init__(self, fn, **kwargs):
|
||||
super(__ImageLocationPicker, self).__init__(**kwargs)
|
||||
|
||||
self.child = Image(fn)
|
||||
|
||||
self.mouse = None
|
||||
self.point1 = None
|
||||
self.point2 = None
|
||||
|
||||
def render(self, width, height, st, at):
|
||||
rv = renpy.Render(width, height)
|
||||
|
||||
cr = renpy.render(self.child, width, height, st, at)
|
||||
rv.blit(cr, (0, 0))
|
||||
|
||||
text = [ ]
|
||||
|
||||
|
||||
if self.point1 and self.point2 and not self.point1 == self.point2:
|
||||
x1, y1 = self.point1
|
||||
x2, y2 = self.point2
|
||||
|
||||
x1 = min(x1, cr.width)
|
||||
x2 = min(x2, cr.width)
|
||||
y1 = min(y1, cr.height)
|
||||
y2 = min(y2, cr.height)
|
||||
|
||||
minx = min(x1, x2)
|
||||
miny = min(y1, y2)
|
||||
maxx = max(x1, x2)
|
||||
maxy = max(y1, y2)
|
||||
|
||||
w = maxx - minx
|
||||
h = maxy - miny
|
||||
|
||||
if w and h:
|
||||
|
||||
sr = renpy.render(Solid("#0ff4"), w, h, st, at)
|
||||
rv.blit(sr, (minx, miny))
|
||||
|
||||
text.append("Imagemap rectangle: %r" % ((minx, miny, maxx, maxy),))
|
||||
text.append("Cropping rectangle: %r" % ((minx, miny, w, h),))
|
||||
|
||||
if self.mouse:
|
||||
mx, my = self.mouse
|
||||
if mx < cr.width and my < cr.height:
|
||||
text.append(_("Mouse position: %r") % (self.mouse,))
|
||||
|
||||
text.append(_("Right-click or escape to quit."))
|
||||
|
||||
td = Text("\n".join(text), size=14, color="#fff", outlines=[ (1, "#000", 0, 0 ) ])
|
||||
tr = renpy.render(td, width, height, st, at)
|
||||
|
||||
rv.blit(tr, (0, height - tr.height))
|
||||
|
||||
return rv
|
||||
|
||||
def event(self, ev, x, y, st):
|
||||
import pygame
|
||||
|
||||
self.mouse = (x, y)
|
||||
renpy.redraw(self, 0)
|
||||
|
||||
if ev.type == pygame.MOUSEBUTTONDOWN and ev.button == 1:
|
||||
self.point1 = (x, y)
|
||||
self.point2 = (x, y)
|
||||
|
||||
elif ev.type == pygame.MOUSEMOTION and ev.buttons[0]:
|
||||
self.point2 = (x, y)
|
||||
|
||||
elif ev.type == pygame.MOUSEBUTTONUP and ev.button == 1:
|
||||
self.point2 = (x, y)
|
||||
|
||||
|
||||
label _image_location_picker:
|
||||
|
||||
scene black
|
||||
|
||||
python hide:
|
||||
|
||||
image_files = [
|
||||
fn
|
||||
for dir, fn in renpy.loader.listdirfiles()
|
||||
if fn.lower().endswith(".jpg") or fn.lower().endswith(".png")
|
||||
if not fn[0] == "_"
|
||||
]
|
||||
|
||||
image_files.sort()
|
||||
|
||||
|
||||
xadjustment = ui.adjustment()
|
||||
yadjustment = ui.adjustment()
|
||||
|
||||
|
||||
while True:
|
||||
|
||||
ui.frame()
|
||||
ui.vbox()
|
||||
|
||||
layout.label(u"Image Location Picker", None)
|
||||
|
||||
ui.textbutton(_(u"Done"), clicked=ui.returns(False), size_group="files")
|
||||
|
||||
ui.side(['c', 'b', 'r'], spacing=5)
|
||||
vp = ui.viewport(xadjustment=xadjustment, yadjustment=yadjustment, mousewheel=True)
|
||||
|
||||
ui.vbox()
|
||||
|
||||
for fn in image_files:
|
||||
ui.button(clicked=ui.returns(fn), size_group="files", xminimum=1.0)
|
||||
ui.text(fn, style="button_text", xalign=0.0)
|
||||
|
||||
ui.close()
|
||||
|
||||
ui.bar(adjustment=xadjustment, style='scrollbar')
|
||||
ui.bar(adjustment=yadjustment, style='vscrollbar')
|
||||
ui.close()
|
||||
|
||||
ui.close()
|
||||
|
||||
rv = ui.interact()
|
||||
|
||||
if rv is False:
|
||||
renpy.jump("_developer_screen")
|
||||
|
||||
# Now, allow the user to pick the image.
|
||||
|
||||
ui.keymap(game_menu=ui.returns(True))
|
||||
ui.add(__ImageLocationPicker(rv))
|
||||
ui.interact()
|
||||
|
||||
|
||||
|
||||
# ...
|
||||
|
||||
renpy.jump("_image_location_picker")
|
||||
|
||||
@@ -75,7 +75,7 @@ init python:
|
||||
ui.close()
|
||||
|
||||
_joystick_get_binding()
|
||||
binding = ui.interact()
|
||||
binding = ui.interact(mouse="gamemenu")
|
||||
_joystick_take_binding(binding, key)
|
||||
|
||||
return True
|
||||
@@ -100,7 +100,7 @@ label joystick_preferences_screen:
|
||||
python:
|
||||
layout.navigation("joystick_preferences")
|
||||
_joystick_preferences()
|
||||
ui.interact()
|
||||
ui.interact(mouse="gamemenu")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -73,7 +73,9 @@ init python:
|
||||
|
||||
ui.button(style=style.file_picker_entry[index],
|
||||
clicked=clicked,
|
||||
role=("selected_" if newest else ""))
|
||||
role=("selected_" if newest else ""),
|
||||
keymap={ "save_delete" : ui.returns(("unlink", name)) }
|
||||
)
|
||||
|
||||
ui.hbox(style=style.file_picker_entry_box[index])
|
||||
|
||||
@@ -193,36 +195,45 @@ init python:
|
||||
# the list of save files.
|
||||
def _file_picker(screen, save):
|
||||
|
||||
# The number of slots in a page.
|
||||
file_page_length = config.file_page_cols * config.file_page_rows
|
||||
|
||||
saved_games = renpy.list_saved_games(regexp=r'(auto-|quick-)?[0-9]+')
|
||||
|
||||
newest = None
|
||||
newest_mtime = None
|
||||
save_info = { }
|
||||
|
||||
for fn, extra_info, screenshot, mtime in saved_games:
|
||||
screenshot = _file_picker_process_screenshot(screenshot)
|
||||
save_info[fn] = (extra_info, screenshot, mtime)
|
||||
|
||||
if not fn.startswith("auto-") and mtime > newest_mtime:
|
||||
newest = fn
|
||||
newest_mtime = mtime
|
||||
|
||||
# The index of the first entry in the page.
|
||||
fpp = __scratch.file_picker_page
|
||||
|
||||
if fpp is None:
|
||||
|
||||
if newest:
|
||||
fpp = _file_picker_file_page(newest)
|
||||
else:
|
||||
fpp = _file_picker_file_page("1")
|
||||
|
||||
|
||||
# Should we update the list of saved games?
|
||||
update = True
|
||||
|
||||
while True:
|
||||
|
||||
|
||||
if update:
|
||||
|
||||
update = False
|
||||
|
||||
# The number of slots in a page.
|
||||
file_page_length = config.file_page_cols * config.file_page_rows
|
||||
|
||||
# The list of saved games.
|
||||
saved_games = renpy.list_saved_games(regexp=r'(auto-|quick-)?[0-9]+')
|
||||
|
||||
# Figure out which game is the newest and so on.
|
||||
newest = None
|
||||
newest_mtime = None
|
||||
save_info = { }
|
||||
|
||||
for fn, extra_info, screenshot, mtime in saved_games:
|
||||
screenshot = _file_picker_process_screenshot(screenshot)
|
||||
save_info[fn] = (extra_info, screenshot, mtime)
|
||||
|
||||
if not fn.startswith("auto-") and mtime > newest_mtime:
|
||||
newest = fn
|
||||
newest_mtime = mtime
|
||||
|
||||
# The index of the first entry in the page.
|
||||
fpp = __scratch.file_picker_page
|
||||
|
||||
if fpp is None:
|
||||
if newest:
|
||||
fpp = _file_picker_file_page(newest)
|
||||
else:
|
||||
fpp = _file_picker_file_page("1")
|
||||
|
||||
|
||||
if fpp < 0:
|
||||
fpp = 0
|
||||
|
||||
@@ -291,9 +302,14 @@ init python:
|
||||
ui.close() # slots
|
||||
ui.close() # whole thing
|
||||
|
||||
result = ui.interact()
|
||||
result = ui.interact(mouse="gamemenu")
|
||||
type, value = result
|
||||
|
||||
if type == "unlink":
|
||||
if layout.yesno_prompt(screen, layout.DELETE_SAVE):
|
||||
renpy.unlink_save(value)
|
||||
update = True
|
||||
|
||||
if type == "return":
|
||||
return value
|
||||
|
||||
@@ -311,7 +327,7 @@ label save_screen:
|
||||
fn = _file_picker("save", True)
|
||||
|
||||
if renpy.can_load(fn):
|
||||
if not layout.yesno_prompt("save", u"Are you sure you want to overwrite your save?"):
|
||||
if not layout.yesno_prompt("save", layout.OVERWRITE_SAVE):
|
||||
continue
|
||||
|
||||
renpy.save(fn, extra_info=store.save_name)
|
||||
@@ -325,7 +341,7 @@ label load_screen:
|
||||
fn = _file_picker("load", False)
|
||||
|
||||
if _load_prompt:
|
||||
if not layout.yesno_prompt("load", u"Loading will lose unsaved progress.\nAre you sure you want to do this?"):
|
||||
if not layout.yesno_prompt("load", layout.LOADING):
|
||||
continue
|
||||
|
||||
renpy.load(fn)
|
||||
|
||||
@@ -50,7 +50,7 @@ label main_menu_screen:
|
||||
|
||||
ui.close()
|
||||
|
||||
ui.interact()
|
||||
ui.interact(mouse="mainmenu")
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ init python:
|
||||
|
||||
ui.close()
|
||||
|
||||
ui.interact()
|
||||
ui.interact(mouse="gamemenu")
|
||||
|
||||
class _Preference(object):
|
||||
"""
|
||||
|
||||
@@ -49,7 +49,7 @@ init python hide:
|
||||
ui.close()
|
||||
ui.close()
|
||||
|
||||
rv = ui.interact()
|
||||
rv = ui.interact(mouse="gamemenu")
|
||||
renpy.transition(config.intra_transition)
|
||||
return rv
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ label main_menu_screen:
|
||||
|
||||
ui.close() # outer box
|
||||
|
||||
ui.interact()
|
||||
ui.interact(mouse="mainmenu")
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -2,45 +2,65 @@ init python:
|
||||
|
||||
class _ImageMapper(object):
|
||||
|
||||
def __init__(self, screen, ground, idle, hover, selected_idle, selected_hover, hotspots):
|
||||
def __init__(self, screen, ground, idle, hover, selected_idle, selected_hover, hotspots, navigation=True, variant=None):
|
||||
|
||||
self.idle = idle
|
||||
self.hover = hover
|
||||
self.selected_idle = selected_idle
|
||||
self.selected_hover = selected_hover
|
||||
# If the argument is a dict, look up the screen in that dict, and
|
||||
# return the result. Otherwise, just return the result.
|
||||
def maybe_variant(a):
|
||||
if isinstance(a, dict):
|
||||
if variant in a:
|
||||
return a[variant]
|
||||
else:
|
||||
return a[None]
|
||||
return a
|
||||
|
||||
ground = maybe_variant(ground)
|
||||
|
||||
self.idle = maybe_variant(idle) or ground
|
||||
self.hover = maybe_variant(hover) or self.idle
|
||||
self.selected_idle = maybe_variant(selected_idle) or self.idle
|
||||
self.selected_hover = maybe_variant(selected_hover) or self.hover
|
||||
|
||||
self.hotspots = { }
|
||||
for (x1, y1, x2, y2, name) in hotspots:
|
||||
for (x1, y1, x2, y2, name) in maybe_variant(hotspots):
|
||||
self.hotspots[name] = (x1, y1, x2, y2)
|
||||
|
||||
# Display the layout navigation only if there are no
|
||||
# game menu buttons defined.
|
||||
for i in config.game_menu:
|
||||
if i[1] in self.hotspots:
|
||||
break
|
||||
else:
|
||||
layout.navigation(screen)
|
||||
self.remaining_hotspots = set(self.hotspots.keys())
|
||||
|
||||
if navigation:
|
||||
|
||||
# Display the layout navigation only if there are no
|
||||
# game menu buttons defined.
|
||||
for i in config.game_menu:
|
||||
if i[1] in self.hotspots:
|
||||
break
|
||||
else:
|
||||
layout.navigation(screen)
|
||||
|
||||
ui.fixed(style='imagemap')
|
||||
ui.image(ground)
|
||||
|
||||
if navigation:
|
||||
|
||||
# Display any navigation buttons that exist.
|
||||
for e in config.game_menu:
|
||||
screen_ = e[0]
|
||||
name = e[1]
|
||||
act = e[2]
|
||||
enable = e[3]
|
||||
# Display any navigation buttons that exist.
|
||||
for e in config.game_menu:
|
||||
screen_ = e[0]
|
||||
name = e[1]
|
||||
act = e[2]
|
||||
enable = e[3]
|
||||
|
||||
if not eval(enable):
|
||||
continue
|
||||
if not eval(enable):
|
||||
continue
|
||||
|
||||
self.button(name, act, screen == screen_)
|
||||
self.button(name, act, screen == screen_)
|
||||
|
||||
def button(self, name, clicked, selected):
|
||||
def button(self, name, clicked, selected, keymap={}):
|
||||
|
||||
if name not in self.hotspots:
|
||||
return None
|
||||
|
||||
self.remaining_hotspots.discard(name)
|
||||
|
||||
x1, y1, x2, y2 = self.hotspots[name]
|
||||
|
||||
if clicked is None:
|
||||
@@ -63,6 +83,7 @@ init python:
|
||||
clicked=clicked,
|
||||
focus_mask=True,
|
||||
style='imagemap_button',
|
||||
keymap=keymap,
|
||||
)
|
||||
|
||||
return (x1, y1, x2, y2)
|
||||
@@ -73,6 +94,8 @@ init python:
|
||||
if name not in self.hotspots:
|
||||
return
|
||||
|
||||
self.remaining_hotspots.discard(name)
|
||||
|
||||
x1, y1, x2, y2 = self.hotspots[name]
|
||||
|
||||
ui.bar(
|
||||
@@ -93,6 +116,9 @@ init python:
|
||||
thumb=None,
|
||||
thumb_shadow=None,
|
||||
thumb_offset=0)
|
||||
|
||||
def nothing(self, name):
|
||||
self.remaining_hotspots.discard(name)
|
||||
|
||||
def close(self):
|
||||
ui.close()
|
||||
|
||||
@@ -4,19 +4,19 @@ init python:
|
||||
renpy.load_module("_layout/imagemap_common")
|
||||
|
||||
# The ground image.
|
||||
config.load_save_ground = None
|
||||
config.load_save_ground = { }
|
||||
|
||||
# The idle image.
|
||||
config.load_save_idle = None
|
||||
config.load_save_idle = { }
|
||||
|
||||
# The hover image.
|
||||
config.load_save_hover = None
|
||||
config.load_save_hover = { }
|
||||
|
||||
# The selected idle image.
|
||||
config.load_save_selected_idle = None
|
||||
config.load_save_selected_idle = { }
|
||||
|
||||
# The selected hover image.
|
||||
config.load_save_selected_hover = None
|
||||
config.load_save_selected_hover = { }
|
||||
|
||||
# The hotspots. Each hotspot is defined by a tuple giving:
|
||||
# - The x-coordinate of the left side.
|
||||
@@ -24,7 +24,7 @@ init python:
|
||||
# - The x-coordinate of the right side.
|
||||
# - The y-coordinate of the bottoms side.
|
||||
# - The name of the button or slider this is equivalent to.
|
||||
config.load_save_hotspots = None
|
||||
config.load_save_hotspots = { }
|
||||
|
||||
# Define styles
|
||||
style.file_picker_text = Style(style.large_button_text, help="text inside a file picker entry")
|
||||
@@ -61,7 +61,9 @@ init python:
|
||||
|
||||
import time
|
||||
|
||||
(x1, y1, x2, y2) = ime.button("slot_%d" % index, clicked, newest)
|
||||
(x1, y1, x2, y2) = ime.button(
|
||||
"slot_%d" % index, clicked, newest,
|
||||
keymap={ "save_delete" : ui.returns(("unlink", name)) })
|
||||
|
||||
ui.fixed(xpos=x1, ypos=y1, xmaximum=x2-x1, ymaximum=y2-y1)
|
||||
|
||||
@@ -157,8 +159,13 @@ init python:
|
||||
|
||||
hotspots = set()
|
||||
|
||||
for (x1, y1, x2, y2, name) in config.load_save_hotspots:
|
||||
hotspots.add(name)
|
||||
if isinstance(config.load_save_hotspots, dict):
|
||||
for d in config.load_save_hotspots.values():
|
||||
for (x1, y1, x2, y2, name) in d:
|
||||
hotspots.add(name)
|
||||
else:
|
||||
for (x1, y1, x2, y2, name) in config.load_save_hotspots:
|
||||
hotspots.add(name)
|
||||
|
||||
__scratch.has_autosave = ("page_auto" in hotspots)
|
||||
__scratch.has_quicksave = ("page_quick" in hotspots)
|
||||
@@ -202,32 +209,39 @@ init python:
|
||||
# The number of slots in a page.
|
||||
file_page_length = __scratch.per_page
|
||||
|
||||
saved_games = renpy.list_saved_games(regexp=r'(auto-|quick-)?[0-9]+')
|
||||
|
||||
newest = None
|
||||
newest_mtime = None
|
||||
save_info = { }
|
||||
|
||||
for fn, extra_info, screenshot, mtime in saved_games:
|
||||
screenshot = _file_picker_process_screenshot(screenshot)
|
||||
save_info[fn] = (extra_info, screenshot, mtime)
|
||||
|
||||
if not fn.startswith("auto-") and mtime > newest_mtime:
|
||||
newest = fn
|
||||
newest_mtime = mtime
|
||||
|
||||
# The index of the first entry in the page.
|
||||
fpp = __scratch.file_picker_page
|
||||
|
||||
if fpp is None:
|
||||
|
||||
if newest:
|
||||
fpp = _file_picker_file_page(newest)
|
||||
else:
|
||||
fpp = _file_picker_file_page("1")
|
||||
|
||||
update = True
|
||||
|
||||
while True:
|
||||
|
||||
if update:
|
||||
|
||||
update = False
|
||||
|
||||
saved_games = renpy.list_saved_games(regexp=r'(auto-|quick-)?[0-9]+')
|
||||
|
||||
newest = None
|
||||
newest_mtime = None
|
||||
save_info = { }
|
||||
|
||||
for fn, extra_info, screenshot, mtime in saved_games:
|
||||
screenshot = _file_picker_process_screenshot(screenshot)
|
||||
save_info[fn] = (extra_info, screenshot, mtime)
|
||||
|
||||
if not fn.startswith("auto-") and mtime > newest_mtime:
|
||||
newest = fn
|
||||
newest_mtime = mtime
|
||||
|
||||
# The index of the first entry in the page.
|
||||
fpp = __scratch.file_picker_page
|
||||
|
||||
if fpp is None:
|
||||
|
||||
if newest:
|
||||
fpp = _file_picker_file_page(newest)
|
||||
else:
|
||||
fpp = _file_picker_file_page("1")
|
||||
|
||||
|
||||
if fpp < 0:
|
||||
fpp = 0
|
||||
|
||||
@@ -240,7 +254,8 @@ init python:
|
||||
config.load_save_hover,
|
||||
config.load_save_selected_idle,
|
||||
config.load_save_selected_hover,
|
||||
config.load_save_hotspots)
|
||||
config.load_save_hotspots,
|
||||
variant=screen)
|
||||
|
||||
|
||||
def tb(enabled, label, clicked, selected):
|
||||
@@ -289,9 +304,14 @@ init python:
|
||||
|
||||
ime.close()
|
||||
|
||||
result = ui.interact()
|
||||
result = ui.interact(mouse="gamemenu")
|
||||
type, value = result
|
||||
|
||||
if type == "unlink":
|
||||
if layout.yesno_prompt(screen, layout.DELETE_SAVE):
|
||||
renpy.unlink_save(value)
|
||||
update = True
|
||||
|
||||
if type == "return":
|
||||
return value
|
||||
|
||||
@@ -309,7 +329,7 @@ label save_screen:
|
||||
fn = _file_picker("save", True)
|
||||
|
||||
if renpy.can_load(fn):
|
||||
if not layout.yesno_prompt("save", u"Are you sure you want to overwrite your save?"):
|
||||
if not layout.yesno_prompt("save", layout.OVERWRITE_SAVE):
|
||||
continue
|
||||
|
||||
renpy.save(fn, extra_info=store.save_name)
|
||||
@@ -322,7 +342,7 @@ label load_screen:
|
||||
fn = _file_picker("load", False)
|
||||
|
||||
if _load_prompt:
|
||||
if not layout.yesno_prompt("load", u"Loading will lose unsaved progress.\nAre you sure you want to do this?"):
|
||||
if not layout.yesno_prompt("load", layout.LOADING):
|
||||
continue
|
||||
|
||||
renpy.load(fn)
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
init python:
|
||||
|
||||
layout.provides('main_menu')
|
||||
|
||||
renpy.load_module("_layout/imagemap_common")
|
||||
|
||||
# The ground image.
|
||||
config.main_menu_ground = None
|
||||
config.main_menu_ground = { }
|
||||
|
||||
# The selected image.
|
||||
config.main_menu_selected = None
|
||||
# The selected/hover image.
|
||||
config.main_menu_selected = { }
|
||||
|
||||
# The idle image.
|
||||
config.main_menu_idle = { }
|
||||
|
||||
# The hotspots. Each hotspot is defined by a tuple giving:
|
||||
# - The x-coordinate of the left side.
|
||||
# - The y-coordinate of the top side.
|
||||
@@ -16,7 +20,10 @@ init python:
|
||||
# - Either the (untranslated) name of the main menu button this hotspot
|
||||
# is equivalent to, or, a label in the program to jump to when this
|
||||
# hotspot is clicked.
|
||||
config.main_menu_hotspots = [ ]
|
||||
config.main_menu_hotspots = { }
|
||||
|
||||
# This can be set from user code to define the main menu variant to use.
|
||||
_main_menu_variant = None
|
||||
|
||||
label main_menu_screen:
|
||||
|
||||
@@ -28,27 +35,42 @@ label main_menu_screen:
|
||||
# Show the background.
|
||||
ui.window(style='mm_root')
|
||||
ui.null()
|
||||
|
||||
rv = renpy.imagemap(
|
||||
|
||||
ime = _ImageMapper(
|
||||
None,
|
||||
config.main_menu_ground,
|
||||
config.main_menu_idle,
|
||||
config.main_menu_selected,
|
||||
config.main_menu_hotspots)
|
||||
|
||||
for e in config.main_menu:
|
||||
name = e[0]
|
||||
act = e[1]
|
||||
enable = e[2]
|
||||
config.main_menu_idle,
|
||||
config.main_menu_selected,
|
||||
config.main_menu_hotspots,
|
||||
navigation=False,
|
||||
variant=_main_menu_variant)
|
||||
|
||||
if name == rv:
|
||||
for e in config.main_menu:
|
||||
if len(e) == 4:
|
||||
name, act, enabled, shown = e
|
||||
else:
|
||||
name, act, enabled = e
|
||||
shown = "True"
|
||||
|
||||
if not eval(shown):
|
||||
ime.nothing(name)
|
||||
|
||||
if isinstance(act, basestring):
|
||||
act = ui.jumpsoutofcontext(act)
|
||||
act()
|
||||
if not eval(enabled):
|
||||
act = None
|
||||
|
||||
break
|
||||
else:
|
||||
ui.jumpsoutofcontext(rv)()
|
||||
if isinstance(act, basestring):
|
||||
act = ui.jumpsoutofcontext(act)
|
||||
|
||||
ime.button(name, act, False)
|
||||
|
||||
for i in list(ime.remaining_hotspots):
|
||||
ime.button(i, ui.jumpsoutofcontext(i), None)
|
||||
|
||||
ime.close()
|
||||
ui.interact(mouse='mainmenu')
|
||||
|
||||
jump main_menu_screen
|
||||
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ init python:
|
||||
ime.bar("Voice Volume", 128, int(_preferences.get_volume('voice') * 128), set_voice)
|
||||
|
||||
ime.close()
|
||||
ui.interact()
|
||||
ui.interact(mouse="gamemenu")
|
||||
|
||||
label preferences_screen:
|
||||
|
||||
|
||||
@@ -8,15 +8,18 @@ init python hide:
|
||||
style.yesno_prompt = Style(style.prompt, help="a yes/no prompt")
|
||||
style.yesno_prompt_text = Style(style.prompt_text, help="a yes/no prompt (text)")
|
||||
|
||||
# Configuration variables
|
||||
# Define config variables.
|
||||
config.yesno_prompt_ground = None
|
||||
config.yesno_prompt_idle = None
|
||||
config.yesno_prompt_hover = None
|
||||
config.yesno_prompt_hotspots = None
|
||||
config.yesno_prompt_hotspots = None
|
||||
|
||||
config.yesno_prompt_message_images = { }
|
||||
|
||||
|
||||
def yesno_prompt(screen, message):
|
||||
renpy.transition(config.intra_transition)
|
||||
|
||||
|
||||
ime = _ImageMapper(
|
||||
screen,
|
||||
config.yesno_prompt_ground,
|
||||
@@ -31,9 +34,15 @@ init python hide:
|
||||
|
||||
ime.close()
|
||||
|
||||
layout.prompt(message, "yesno")
|
||||
default = config.yesno_prompt_message_images.get(layout.ARE_YOU_SURE, None)
|
||||
message_image = config.yesno_prompt_message_images.get(message, default)
|
||||
|
||||
if message_image:
|
||||
ui.add(message_image)
|
||||
else:
|
||||
layout.prompt(message, "yesno")
|
||||
|
||||
rv = ui.interact()
|
||||
rv = ui.interact(mouse="gamemenu")
|
||||
renpy.transition(config.intra_transition)
|
||||
return rv
|
||||
|
||||
|
||||
@@ -69,125 +69,134 @@ init python:
|
||||
|
||||
def _file_picker(screen):
|
||||
|
||||
@renpy.curry
|
||||
def hovered(thumbnail):
|
||||
if __session.thumbnail is not thumbnail:
|
||||
__session.thumbnail = thumbnail
|
||||
renpy.restart_interaction()
|
||||
while True:
|
||||
|
||||
@renpy.curry
|
||||
def unhovered(thumbnail):
|
||||
if __session.thumbnail is thumbnail:
|
||||
__session.thumbnail = None
|
||||
renpy.restart_interaction()
|
||||
@renpy.curry
|
||||
def hovered(thumbnail):
|
||||
if __session.thumbnail is not thumbnail:
|
||||
__session.thumbnail = thumbnail
|
||||
renpy.restart_interaction()
|
||||
|
||||
__session.thumbnail = None
|
||||
|
||||
layout.navigation(screen)
|
||||
|
||||
newest = None
|
||||
newest_time = None
|
||||
@renpy.curry
|
||||
def unhovered(thumbnail):
|
||||
if __session.thumbnail is thumbnail:
|
||||
__session.thumbnail = None
|
||||
renpy.restart_interaction()
|
||||
|
||||
info = { }
|
||||
|
||||
for name, extra_info, thumbnail, time in renpy.list_saved_games():
|
||||
|
||||
info[name] = (extra_info, thumbnail, time)
|
||||
|
||||
if not name[0] in "0123456789":
|
||||
continue
|
||||
|
||||
if time > newest_time:
|
||||
newest = name
|
||||
newest_time = time
|
||||
|
||||
slots = [ ]
|
||||
|
||||
for i in range(1, config.load_save_slots + 1):
|
||||
slots.append((str(i), str(i)))
|
||||
|
||||
if config.has_quicksave:
|
||||
for i in range(1, config.load_save_quick_slots + 1):
|
||||
slots.append(('quick-'+ str(i), _(u'q') + str(i)))
|
||||
|
||||
if config.has_autosave:
|
||||
for i in range(1, config.load_save_auto_slots + 1):
|
||||
slots.append(('auto-' + str(i), _(u'a') + str(i)))
|
||||
|
||||
ui.frame(style=style.file_picker_frame)
|
||||
ui.side(['c', 'r'], style=style.file_picker_side)
|
||||
|
||||
|
||||
|
||||
if __session.scrollbar_position is None:
|
||||
if newest is None:
|
||||
yoffset = 0
|
||||
else:
|
||||
yoffset = 1.0 * (int(newest) - 1) / len(slots)
|
||||
value = 0
|
||||
|
||||
else:
|
||||
value = __session.scrollbar_position
|
||||
yoffset = None
|
||||
|
||||
adj = ui.adjustment(value=value)
|
||||
ui.viewport(yadjustment=adj, offsets=(0, yoffset), style=style.file_picker_viewport, mousewheel=True)
|
||||
|
||||
ui.vbox(style=style.file_picker_box, focus=renpy.time.time())
|
||||
|
||||
|
||||
for i, (fn, n) in enumerate(slots):
|
||||
|
||||
clicked = ui.returns(fn)
|
||||
|
||||
if screen == "save" and fn.startswith("auto-"):
|
||||
clicked = None
|
||||
|
||||
if screen == "load" and fn not in info:
|
||||
clicked = None
|
||||
|
||||
if fn in info:
|
||||
extra_info, thumbnail, time = info[fn]
|
||||
|
||||
ui.button(style=style.file_picker_entry[i],
|
||||
clicked=clicked,
|
||||
hovered=hovered(thumbnail),
|
||||
unhovered=unhovered(thumbnail),
|
||||
role = "selected_" if (fn == newest) else "")
|
||||
|
||||
s = config.file_entry_format % dict(
|
||||
time=renpy.time.strftime(
|
||||
config.time_format,
|
||||
renpy.time.localtime(time)),
|
||||
save_name=extra_info)
|
||||
|
||||
ui.text(n + ". " + s, style=style.file_picker_text[i])
|
||||
|
||||
else:
|
||||
ui.button(style=style.file_picker_entry[i],
|
||||
clicked=clicked,
|
||||
role = "selected_" if (fn == newest) else "")
|
||||
|
||||
ui.text(n + ". " + _(u"Empty Slot."),
|
||||
style=style.file_picker_text[i])
|
||||
|
||||
ui.close() # vbox/viewport
|
||||
|
||||
ui.bar(adjustment=adj, style=style.file_picker_scrollbar)
|
||||
|
||||
ui.close() # side/window
|
||||
|
||||
# Thumbnail.
|
||||
ui.frame(style=style.thumbnail_frame)
|
||||
ui.add(DynamicDisplayable(_file_picker_thumbnail))
|
||||
|
||||
try:
|
||||
rv = ui.interact()
|
||||
finally:
|
||||
__session.scrollbar_position = adj.value
|
||||
__session.thumbnail = None
|
||||
|
||||
return rv
|
||||
layout.navigation(screen)
|
||||
|
||||
newest = None
|
||||
newest_time = None
|
||||
|
||||
info = { }
|
||||
|
||||
for name, extra_info, thumbnail, time in renpy.list_saved_games():
|
||||
|
||||
info[name] = (extra_info, thumbnail, time)
|
||||
|
||||
if not name[0] in "0123456789":
|
||||
continue
|
||||
|
||||
if time > newest_time:
|
||||
newest = name
|
||||
newest_time = time
|
||||
|
||||
slots = [ ]
|
||||
|
||||
for i in range(1, config.load_save_slots + 1):
|
||||
slots.append((str(i), str(i)))
|
||||
|
||||
if config.has_quicksave:
|
||||
for i in range(1, config.load_save_quick_slots + 1):
|
||||
slots.append(('quick-'+ str(i), _(u'q') + str(i)))
|
||||
|
||||
if config.has_autosave:
|
||||
for i in range(1, config.load_save_auto_slots + 1):
|
||||
slots.append(('auto-' + str(i), _(u'a') + str(i)))
|
||||
|
||||
ui.frame(style=style.file_picker_frame)
|
||||
ui.side(['c', 'r'], style=style.file_picker_side)
|
||||
|
||||
|
||||
|
||||
if __session.scrollbar_position is None:
|
||||
if newest is None:
|
||||
yoffset = 0
|
||||
else:
|
||||
yoffset = 1.0 * (int(newest) - 1) / len(slots)
|
||||
value = 0
|
||||
|
||||
else:
|
||||
value = __session.scrollbar_position
|
||||
yoffset = None
|
||||
|
||||
adj = ui.adjustment(value=value)
|
||||
ui.viewport(yadjustment=adj, offsets=(0, yoffset), style=style.file_picker_viewport, mousewheel=True)
|
||||
|
||||
ui.vbox(style=style.file_picker_box, focus=renpy.time.time())
|
||||
|
||||
|
||||
for i, (fn, n) in enumerate(slots):
|
||||
|
||||
clicked = ui.returns(("select", fn))
|
||||
|
||||
if screen == "save" and fn.startswith("auto-"):
|
||||
clicked = None
|
||||
|
||||
if screen == "load" and fn not in info:
|
||||
clicked = None
|
||||
|
||||
if fn in info:
|
||||
extra_info, thumbnail, time = info[fn]
|
||||
|
||||
ui.button(style=style.file_picker_entry[i],
|
||||
clicked=clicked,
|
||||
hovered=hovered(thumbnail),
|
||||
unhovered=unhovered(thumbnail),
|
||||
role = "selected_" if (fn == newest) else "",
|
||||
keymap = { "save_delete" : ui.returns(("unlink", fn)) },
|
||||
)
|
||||
|
||||
s = config.file_entry_format % dict(
|
||||
time=renpy.time.strftime(
|
||||
config.time_format,
|
||||
renpy.time.localtime(time)),
|
||||
save_name=extra_info)
|
||||
|
||||
ui.text(n + ". " + s, style=style.file_picker_text[i])
|
||||
|
||||
else:
|
||||
ui.button(style=style.file_picker_entry[i],
|
||||
clicked=clicked,
|
||||
role = "selected_" if (fn == newest) else "")
|
||||
|
||||
ui.text(n + ". " + _(u"Empty Slot."),
|
||||
style=style.file_picker_text[i])
|
||||
|
||||
ui.close() # vbox/viewport
|
||||
|
||||
ui.bar(adjustment=adj, style=style.file_picker_scrollbar)
|
||||
|
||||
ui.close() # side/window
|
||||
|
||||
# Thumbnail.
|
||||
ui.frame(style=style.thumbnail_frame)
|
||||
ui.add(DynamicDisplayable(_file_picker_thumbnail))
|
||||
|
||||
try:
|
||||
action, arg = ui.interact(mouse="gamemenu")
|
||||
finally:
|
||||
__session.scrollbar_position = adj.value
|
||||
__session.thumbnail = None
|
||||
|
||||
if action == "select":
|
||||
return arg
|
||||
|
||||
elif action == "unlink":
|
||||
if layout.yesno_prompt("save", layout.DELETE_SAVE):
|
||||
renpy.unlink_save(arg)
|
||||
|
||||
|
||||
label save_screen:
|
||||
@@ -197,7 +206,7 @@ label save_screen:
|
||||
fn = _file_picker("save")
|
||||
|
||||
if renpy.can_load(fn):
|
||||
if not layout.yesno_prompt("save", u"Are you sure you want to overwrite your save?"):
|
||||
if not layout.yesno_prompt("save", layout.OVERWRITE_SAVE):
|
||||
continue
|
||||
|
||||
renpy.save(fn, extra_info=store.save_name)
|
||||
@@ -211,7 +220,7 @@ label load_screen:
|
||||
fn = _file_picker("load")
|
||||
|
||||
if _load_prompt:
|
||||
if not layout.yesno_prompt("load", u"Loading will lose unsaved progress.\nAre you sure you want to do this?"):
|
||||
if not layout.yesno_prompt("load", layout.LOADING):
|
||||
continue
|
||||
|
||||
renpy.load(fn)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 85 KiB |
@@ -1,106 +0,0 @@
|
||||
# This file contains the code that demonstrates animation.
|
||||
|
||||
init:
|
||||
|
||||
# A simple animation. We interleave the displayables we want to
|
||||
# show with the times we want to show them for.
|
||||
image eileen animated = Animation(
|
||||
"eileen_vhappy.png", 1.0,
|
||||
"eileen_happy.png", 1.0)
|
||||
|
||||
image transanimation = anim.TransitionAnimation(
|
||||
im.Scale("whitehouse.jpg", 400, 300), 1.0, dissolve,
|
||||
im.Scale("washington.jpg", 400, 300), 1.0, dissolve)
|
||||
|
||||
# The blink animation.
|
||||
image blinking text = anim.Blink(Text("Blink", color="#ff0", size=72))
|
||||
|
||||
# A state machine-based animation.
|
||||
image smanim = anim.SMAnimation(
|
||||
|
||||
# The name of the starting state.
|
||||
"r",
|
||||
|
||||
# The states we use, and the displayables we show during those
|
||||
# states.
|
||||
anim.State("r", "#f00"),
|
||||
anim.State("g", "#0f0"),
|
||||
anim.State("b", "#00f"),
|
||||
|
||||
# The edges, given as a state, a time we remain in that state for,
|
||||
# the new state, and the time it takes to transition between the
|
||||
# two of them.
|
||||
#
|
||||
# dissolve only works with solid images. move is also useful here.
|
||||
anim.Edge("r", .5, "g", dissolve),
|
||||
anim.Edge("r", .5, "b", dissolve),
|
||||
|
||||
anim.Edge("g", .5, "r", dissolve),
|
||||
anim.Edge("g", .5, "b", dissolve),
|
||||
|
||||
anim.Edge("b", .5, "r", dissolve),
|
||||
anim.Edge("b", .5, "g", dissolve),
|
||||
)
|
||||
|
||||
label demo_animation:
|
||||
|
||||
|
||||
|
||||
e "Ren'Py supports a number of ways of creating animations."
|
||||
|
||||
e "These animations let you vary images, independent of the user's clicks."
|
||||
|
||||
show eileen animated
|
||||
|
||||
e "For example, I'm switching my expression back and forth, once a second."
|
||||
|
||||
e "Even though you clicked, I'm still doing it."
|
||||
|
||||
e "This is an example of the Animation function at work."
|
||||
|
||||
show eileen happy
|
||||
|
||||
e "The Animation function is limited to simple lists of images, with fixed delays between them."
|
||||
|
||||
e "The sequence can repeat, or can stop after one go-through."
|
||||
|
||||
show eileen happy at right
|
||||
show transanimation at Position(xpos=50, ypos=50, xanchor=0, yanchor=0)
|
||||
with moveinleft
|
||||
|
||||
e "The anim.TransitionAnimation function is similar, but it lets you specify a transition between frames."
|
||||
|
||||
show eileen happy
|
||||
hide transanimation
|
||||
with moveoutleft
|
||||
|
||||
e "If you want more control, you can use the anim.SMAnimation function."
|
||||
|
||||
e "It can randomly change images, and even apply transitions to changes."
|
||||
|
||||
scene smanim
|
||||
show eileen happy
|
||||
with dissolve
|
||||
|
||||
e "Here, we are randomly dissolving the background between red, green, and blue images."
|
||||
|
||||
e "Psychadelic."
|
||||
|
||||
scene bg washington
|
||||
show eileen happy
|
||||
with dissolve
|
||||
|
||||
e "It's probably best if we stop here, before somebody's brain explodes."
|
||||
|
||||
show blinking text at Position(xalign=.5, yalign=.7)
|
||||
|
||||
e "Finally, there's anim.Blink, which can be used to blink things in and out."
|
||||
|
||||
e "I don't know why you'd want to do that to a character, but blinking text seems reasonable for signs and things like that."
|
||||
|
||||
hide blinking text
|
||||
with dissolve
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
# This file contains some of the basics of Ren'Py. This is stuff you'll use in
|
||||
# just about every game.
|
||||
|
||||
# First, we have an init block that contains many of the definitions we
|
||||
# use in the game
|
||||
init:
|
||||
|
||||
# Here we define the backgrounds that are used by the demo.
|
||||
image bg washington = "washington.jpg"
|
||||
image bg whitehouse = "whitehouse.jpg"
|
||||
|
||||
# And this is the character art we use in the demo.
|
||||
image eileen happy = "eileen_happy.png"
|
||||
image eileen vhappy = "eileen_vhappy.png"
|
||||
image eileen concerned = "eileen_concerned.png"
|
||||
|
||||
# Now, we declare the characters.
|
||||
$ e = Character('Eileen', color="#c8ffc8")
|
||||
|
||||
|
||||
# In a real game, we would have:
|
||||
#
|
||||
# label start:
|
||||
#
|
||||
# here. But since we are inside the demo game, we have to use a different
|
||||
# label.
|
||||
|
||||
label demo_basics:
|
||||
|
||||
e "This is our demonstration of the basics of using Ren'Py. You may want to click the button at the upper-right of the screen, to follow along."
|
||||
|
||||
"Somehow, I realize that Ren'Py supports narration."
|
||||
|
||||
e "Ren'Py supports dialogue, as long as you declare a character first. If it didn't I wouldn't be able to talk to you."
|
||||
|
||||
e "Ren'Py also supports menus, which let you make decisions based on user input."
|
||||
|
||||
|
||||
menu:
|
||||
|
||||
e "Do you think you'd ever use menus in a game?"
|
||||
|
||||
"Yes.":
|
||||
|
||||
jump about_menus_yes
|
||||
|
||||
"No.":
|
||||
|
||||
jump about_menus_no
|
||||
|
||||
"I'm not ready to make that decision yet.":
|
||||
|
||||
jump about_menus_unsure
|
||||
|
||||
label about_menus_yes:
|
||||
|
||||
$ about_menus_choice = "yes"
|
||||
|
||||
e "Menus are the most important way of providing interactivity to a game."
|
||||
|
||||
jump about_menus_done
|
||||
|
||||
label about_menus_no:
|
||||
|
||||
$ about_menus_choice = "no"
|
||||
|
||||
e "That's okay, Ren'Py has been used to make a number of linear games, which we call kinetic novels."
|
||||
|
||||
jump about_menus_done
|
||||
|
||||
label about_menus_unsure:
|
||||
|
||||
$ about_menus_choice = "unsure"
|
||||
|
||||
e "Well, it doesn't really matter. Whatever you decide, Ren'Py is ready for you."
|
||||
|
||||
jump about_menus_done
|
||||
|
||||
|
||||
label about_menus_done:
|
||||
|
||||
e "Ren'Py wouldn't be much of a visual novel engine if it didn't support images."
|
||||
|
||||
scene bg whitehouse
|
||||
with dissolve
|
||||
|
||||
e "The scene statement clears the screen, and optionally lets you place a single new image on the screen."
|
||||
|
||||
show eileen happy
|
||||
with dissolve
|
||||
|
||||
e "The show statement shows images to the user."
|
||||
|
||||
show eileen vhappy
|
||||
with dissolve
|
||||
|
||||
e "Showing an image with the same tag, the same first part of the name, as an already-show image replaces that image."
|
||||
|
||||
show eileen happy at right
|
||||
with dissolve
|
||||
|
||||
e "Images can be shown at different locations on the screen, and you can show as many images on the screen as you want."
|
||||
|
||||
hide eileen happy
|
||||
with dissolve
|
||||
|
||||
e "The hide statement hides images, although with scene statement clearing the screen and the show statement replacing images, it's rarely necessary to do so."
|
||||
|
||||
scene bg washington
|
||||
show eileen happy
|
||||
with dissolve
|
||||
|
||||
e "Finally, the with statement is what we use to perform a transition from one screen to the next."
|
||||
|
||||
e "That's all you need to make a simple game, like a kinetic novel."
|
||||
|
||||
e "But I would be remiss if I didn't mention that Ren'Py can store data, and make decisions based on it."
|
||||
|
||||
if about_menus_choice == "yes":
|
||||
|
||||
e "For example, I remember you wanted to use menus in your game."
|
||||
|
||||
elif about_menus_choice == "no":
|
||||
|
||||
e "For example, I remember you didn't want to use menus."
|
||||
|
||||
else:
|
||||
|
||||
e "For example, I remember you weren't sure about menus."
|
||||
|
||||
e "Ren'Py embeds the Python programming language, which lets you do some very sophisticated things."
|
||||
|
||||
e "But you don't need learn Python if you don't want to."
|
||||
|
||||
return
|
||||
@@ -1,103 +0,0 @@
|
||||
# This file demonstrates the Ren'Py User Experience... the features you get
|
||||
# for free by choosing to use Ren'Py as a visual novel engine.
|
||||
|
||||
init:
|
||||
image popup prefs = "prefs.png"
|
||||
image popup save = "save.png"
|
||||
|
||||
label demo_experience:
|
||||
|
||||
e "One of the goals of Ren'Py is to provide visual novel players with a good user experience."
|
||||
|
||||
e "To ensure this, there are a number of features that are included as part of every Ren'Py game. Here, we'll show off some of these features."
|
||||
|
||||
e "Skipping can be turned on from the game menu, or when the user presses the Tab key. It is also enabled while the user holds down either Ctrl key."
|
||||
|
||||
e "By default it only skips read text, so if it's your first time reading this, it won't do anything. That can be changed from the game menu."
|
||||
|
||||
e "On the second and later times reading a screen of text, it will skip right through it."
|
||||
|
||||
e "Rollback is a feature that lets you go back in time to previous screens, letting you re-read text."
|
||||
|
||||
menu:
|
||||
|
||||
e "Would you like to hear more about rollback?"
|
||||
|
||||
"Yes.":
|
||||
|
||||
jump demo_rollback
|
||||
|
||||
"No.":
|
||||
|
||||
jump demo_rollback_done
|
||||
|
||||
|
||||
label demo_rollback:
|
||||
|
||||
e "You can invoke a rollback by scrolling the mouse wheel up, or by pushing the page up key. That'll bring you back to the previous screen."
|
||||
|
||||
e "While at a previous screen, you can roll forward by scrolling the mouse wheel down, or pushing the page down key."
|
||||
|
||||
e "Rolling forward through a menu will make the same choice you did last time. You can also make a different choice, if you change your mind."
|
||||
|
||||
e "You can try it by rolling back through the last menu, and saying 'No'."
|
||||
|
||||
e "Press page up, or scroll up the mouse wheel."
|
||||
|
||||
show eileen concerned
|
||||
|
||||
e "Well, are you going to try it?"
|
||||
|
||||
e "Your loss."
|
||||
|
||||
e "Moving on."
|
||||
|
||||
show eileen happy
|
||||
|
||||
label demo_rollback_done:
|
||||
|
||||
e "Now, let me show off the game menu. You can access the game menu by right clicking, or by hitting escape. You can get back by doing the same thing, or by clicking \"Return\"."
|
||||
|
||||
e "The game menu lets you do many things."
|
||||
|
||||
show popup save at Position(ypos=.1, yanchor=0, xpos=0, xanchor=1.0)
|
||||
with None
|
||||
|
||||
show popup save at Position(xpos=.1, ypos=.1, xanchor=0, yanchor=0)
|
||||
show eileen happy at right
|
||||
with move
|
||||
|
||||
e "The save screen lets you save a game, while the load screen lets you load the game back in."
|
||||
|
||||
e "Unlike many game engines, Ren'Py supports an unlimited number of save slots."
|
||||
|
||||
show popup prefs at Position(xpos=.1, ypos=.1, xanchor=0, yanchor=0)
|
||||
with dissolve
|
||||
|
||||
e "The preferences screen lets the end-user change some aspects of the behavior of Ren'Py."
|
||||
|
||||
e "The user can choose if the game runs in a window, or fullscreen."
|
||||
|
||||
e "By setting transitions to None, a user can eliminate transitions entirely."
|
||||
|
||||
e "A user can choose if the skipping feature skips all messages, or only seen messages, and if it stops when an in-game menu is selected."
|
||||
|
||||
e "When the text speed setting isn't the maximum, text will be drawn onto the screen one character at a time."
|
||||
|
||||
e "The auto-forward time setting controls how long we will wait before automatically advancing through text."
|
||||
|
||||
e "The auto-forward time is adjusted by the length of the text being shown."
|
||||
|
||||
e "Finally, we allow the user to choose the volume for music, voice, and sound effects."
|
||||
|
||||
e "From the game menu, the user can return to the game, begin skipping, return to the main menu, or quit entirely."
|
||||
|
||||
show popup save at Position(ypos=.1, yanchor=0, xpos=0, xanchor=1.0)
|
||||
show eileen happy at center
|
||||
with move
|
||||
|
||||
hide popup save
|
||||
|
||||
e "And that's part of how Ren'Py gives end-users the experience they expect."
|
||||
|
||||
return
|
||||
@@ -1,166 +0,0 @@
|
||||
init:
|
||||
# Defines a big image we can pan over.
|
||||
image bg onememorial = "1memorial.jpg"
|
||||
|
||||
# Defines a SnowBlossom object, which uses particle motion to show falling
|
||||
# cherry blossom petals.
|
||||
image snowblossom = SnowBlossom(anim.Filmstrip("sakura.png", (20, 20), (2, 1), .15), fast=True)
|
||||
|
||||
# Defines the magic circle image.
|
||||
image magic_circle = "magic.png"
|
||||
|
||||
# Defines an image that zooms between various sizes.
|
||||
image logo sizezoom = Animation(
|
||||
At("logo.png", SizeZoom((100, 300), (300, 100), 1, opaque=False)), 1,
|
||||
At("logo.png", SizeZoom((300, 100), (100, 300), 1, opaque=False)), 1,
|
||||
)
|
||||
|
||||
# Defines a spline motion.
|
||||
init python:
|
||||
spline = SplineMotion([
|
||||
((-0.042, 0.523,),),
|
||||
((0.768, 0.296,), (0.082, 0.507,), (0.772, 0.573,),),
|
||||
((0.292, 0.304,), (0.766, 0.112,), (0.296, 0.123,),),
|
||||
((1.152, 0.509,), (0.288, 0.555,), (1.076, 0.499,),),
|
||||
], 3.0, anchors=(0.5, 0.5))
|
||||
|
||||
label demo_movement:
|
||||
|
||||
|
||||
e "I'm not stuck standing in the middle of the screen, even though I like being the center of attention."
|
||||
|
||||
e "Positions, given with an at clause, specify where I'm standing, while the 'move' transition moves around images that have changed position."
|
||||
|
||||
e "For example..."
|
||||
|
||||
show eileen happy at left
|
||||
with move
|
||||
|
||||
e "The left position has my left side border the left side of the screen."
|
||||
|
||||
show eileen happy at center
|
||||
with move
|
||||
|
||||
e "I can also move to the center..."
|
||||
|
||||
show eileen happy at right
|
||||
with move
|
||||
|
||||
e "and the right."
|
||||
|
||||
e "We don't limit you to these positions either. You can always create your own Position objects."
|
||||
|
||||
# This is necessary to restart the time at which we are
|
||||
# shown.
|
||||
hide eileen happy
|
||||
|
||||
show eileen happy at Move((1.0, 1.0, 1.0, 1.0),
|
||||
(0.0, 1.0, 0.0, 1.0),
|
||||
4.0, repeat=True, bounce=True)
|
||||
|
||||
e "It's also possible to have a movement happen while showing dialogue on the screen, using the Move function."
|
||||
|
||||
e "Move can repeat a movement, and even have it bounce back and forth, like I'm doing now."
|
||||
|
||||
|
||||
show eileen happy at Move((.25, 1.0, 0.0, 1.0),
|
||||
(.75, 1.0, 1.0, 1.0),
|
||||
10.0, repeat=True, bounce=True, subpixel=True)
|
||||
|
||||
with dissolve
|
||||
|
||||
e "Our subpixel mode allows slow moves, of less than a few pixels a second, to be very accurate."
|
||||
|
||||
scene bg onememorial at Pan((0, 800), (0, 0), 10.0)
|
||||
with dissolve
|
||||
|
||||
e "We can pan around an image larger than the screen, using the Pan function in an at clause. That's what we're doing now."
|
||||
|
||||
scene bg whitehouse
|
||||
with dissolve
|
||||
|
||||
# spline is defined near the top of this file.
|
||||
show logo base at spline
|
||||
|
||||
e "SplineMotion allows for more complex movements to be defined."
|
||||
|
||||
hide logo base
|
||||
|
||||
scene bg whitehouse at Zoom((800, 600), (0, 0, 800, 600), (225, 150, 400, 300), 1.0)
|
||||
|
||||
e "We can zoom into images..."
|
||||
|
||||
scene bg whitehouse at Zoom((800, 600), (225, 150, 400, 300), (0, 0, 800, 600), 1.0)
|
||||
|
||||
e "... and zoom back out of them again."
|
||||
|
||||
scene bg whitehouse
|
||||
show eileen happy at FactorZoom(1.0, 0.5, 1.0, opaque=False), center
|
||||
|
||||
e "We can also zoom images by a factor..."
|
||||
|
||||
show eileen happy at FactorZoom(0.5, 1.0, 1.0, opaque=False), center
|
||||
|
||||
e "... and zoom {i}them{/i} out again."
|
||||
|
||||
show eileen happy at left
|
||||
# logo sizezoom is defined at the top of this file.
|
||||
show logo sizezoom at Position(xalign=.75, yalign=.4)
|
||||
with moveinright
|
||||
|
||||
e "We can scale images to arbitrary sizes."
|
||||
|
||||
show eileen happy at center
|
||||
hide logo sizezoom
|
||||
with moveoutright
|
||||
|
||||
with Pause(.5)
|
||||
|
||||
$ renpy.layer_at_list([ Zoom((800, 600), (0, 0, 800, 600), (200, 0, 400, 300), 1)])
|
||||
with Pause(1)
|
||||
$ renpy.layer_at_list([ Zoom((800, 600), (200, 0, 400, 300), (0, 0, 800, 600), 1)])
|
||||
with Pause(1)
|
||||
$ renpy.layer_at_list([ ])
|
||||
|
||||
e "We can apply motions to a layer as a whole."
|
||||
|
||||
show eileen happy
|
||||
show magic_circle at RotoZoom(0, 360, 5, 0, 1, 1, rot_repeat=True, rot_anim_timebase=True, opaque=False, xalign=0.5, yalign=0.5)
|
||||
|
||||
with Pause(1)
|
||||
|
||||
e "We can rotate and zoom images in a single operation."
|
||||
|
||||
e "And when we're no longer feeling so occult, we can zoom them back out again."
|
||||
|
||||
show magic_circle at RotoZoom(0, 360, 5, 1, 0, 1, rot_repeat=True, rot_anim_timebase=True, opaque=False, xalign=0.5, yalign=0.5)
|
||||
|
||||
with Pause(1)
|
||||
|
||||
hide magic_circle
|
||||
|
||||
show eileen happy
|
||||
show logo base at Position(xpos=250, ypos=300, xanchor=0.5, yanchor=0.5), Revolve(0, 360, 4, repeat=True) behind eileen
|
||||
with dissolve
|
||||
|
||||
"We can also revolve an image around in a circle."
|
||||
|
||||
show bg washington
|
||||
hide logo base
|
||||
show snowblossom
|
||||
with dissolve
|
||||
|
||||
e "Finally, Ren'Py has a particle motion system, that can be used for things like falling cherry blossoms, falling snow, and rising bubbles."
|
||||
|
||||
e "The particle motion system uses a factory to create particles over the course of an interaction."
|
||||
|
||||
e "While the SnowBlossom function wraps a factory that provides convenient support for things rising and falling in straight lines, it's also possible to define your own."
|
||||
|
||||
e "The sky's the limit."
|
||||
|
||||
e "Or the ground, in the case of these cherry blossoms."
|
||||
|
||||
hide snowblossom
|
||||
with dissolve
|
||||
|
||||
return
|
||||
@@ -1,57 +0,0 @@
|
||||
# This file contains demonstrations of Ren'Py's multimedia
|
||||
# support. Right now, this is just showing off sound and music, but
|
||||
# Ren'Py does support movies, and we'll add them sometime later.
|
||||
|
||||
image movie = Movie(size=(320, 240), xpos=475, ypos=50, xanchor=0, yanchor=0)
|
||||
|
||||
label demo_multimedia:
|
||||
|
||||
e "Ren'Py supports a number of multimedia functions."
|
||||
|
||||
e "You're probably hearing music playing in the background."
|
||||
|
||||
# This stops the music, and fades it out.
|
||||
stop music fadeout 0.5
|
||||
|
||||
e "We can stop it, with a fadeout..."
|
||||
|
||||
# This plays music.
|
||||
play music "mozart.ogg"
|
||||
|
||||
e "... and start it playing again."
|
||||
|
||||
# This plays a sound effect.
|
||||
play sound "18005551212.ogg"
|
||||
|
||||
e "We can play sound effects on top of the music."
|
||||
|
||||
$ renpy.music.set_pan(-1, 0)
|
||||
$ renpy.music.set_pan( 1, 2)
|
||||
|
||||
e "We can pan the music back and forth."
|
||||
|
||||
$ renpy.music.set_pan(0, .5)
|
||||
|
||||
e "Voice support is included as part of Ren'Py, although we don't yet have a demonstration."
|
||||
|
||||
$ renpy.music.set_volume(0, .5)
|
||||
|
||||
e "Finally, we support playing movie files."
|
||||
|
||||
show movie behind eileen
|
||||
play movie "shuttle.ogv"
|
||||
|
||||
e "We can put a movie on the screen with text and other images."
|
||||
|
||||
stop movie
|
||||
hide movie
|
||||
|
||||
e "We can also play the movie in fullscreen... but with this tiny movie we're using as an example, it's going to look bad."
|
||||
|
||||
$ renpy.movie_cutscene("shuttle.ogv", stop_music=False)
|
||||
|
||||
$ renpy.music.set_volume(1, 1.0)
|
||||
|
||||
e "That's about it for multimedia."
|
||||
|
||||
return
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 95 KiB |
Binary file not shown.
@@ -1,58 +0,0 @@
|
||||
# This file contains the script for the Ren'Py demo game. Execution starts at
|
||||
# the start label.
|
||||
#
|
||||
# Declarations of characters and images used throughout the game can be found
|
||||
# in demo_basics.rpy. Options can be set in options.rpy.
|
||||
|
||||
# The game starts here.
|
||||
label start:
|
||||
|
||||
scene bg washington
|
||||
show eileen vhappy
|
||||
with dissolve
|
||||
|
||||
# Start the background music playing.
|
||||
play music "mozart.ogg"
|
||||
|
||||
window show
|
||||
|
||||
e "Hi, and welcome to the Ren'Py demo game."
|
||||
|
||||
show eileen happy
|
||||
|
||||
e "My name is Eileen, and I'm here to demonstrate some of the features of the Ren'Py visual novel engine."
|
||||
|
||||
# Show the editor button, which is defined in editor.rpy.
|
||||
$ show_editor_button = True
|
||||
|
||||
e "See that button in the upper-right corner of the screen?"
|
||||
|
||||
e "It shows where we are in the script. You can click it, and we'll try to open the file in a text editor."
|
||||
|
||||
e "It's an easy way to see how you can use the features I'm showing off."
|
||||
|
||||
e "We'll only show it for code that's intended to be easy to understand."
|
||||
|
||||
call demos from _call_demos_1
|
||||
|
||||
e "Thank you for viewing the Ren'Py demo."
|
||||
|
||||
e "If you'd like to see a full Ren'Py game, go to the launcher and choose \"Select Project\", then \"the_question\"."
|
||||
|
||||
e "You can download new versions of Ren'Py from http://www.renpy.org/. For help and discussion, check out the Lemma Soft Forums, at http://lemmasoft.renai.us/."
|
||||
|
||||
e "We'd like to thank Piroshki for contributing character art... I've never looked better. We also thank Jake for the magic circle."
|
||||
|
||||
e "The background music was generated using a Musikalisches Würfelspiel attributed to Mozart... even though that's probably wrong."
|
||||
|
||||
show eileen vhappy
|
||||
|
||||
e "We look forward to seeing what you can make with this! Good luck!"
|
||||
|
||||
window hide
|
||||
|
||||
# Returning from the top level quits the game.
|
||||
return
|
||||
|
||||
|
||||
|
||||
+6
-2
@@ -121,7 +121,7 @@ def main():
|
||||
os.chmod("./renpy.app/Contents/MacOS/Ren'Py Launcher", 0755)
|
||||
|
||||
# Compile the various games
|
||||
for i in [ 'demo/game', 'launcher', 'template/game', 'the_question/game' ]:
|
||||
for i in [ 'tutorial/game', 'launcher', 'template/game', 'the_question/game' ]:
|
||||
os.system("./renpy.sh --compile --game " + i)
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ def main():
|
||||
files.extend(tree("common"))
|
||||
more_files.append("console.exe")
|
||||
files.extend(tree("launcher"))
|
||||
files.extend(tree("demo"))
|
||||
files.extend(tree("tutorial"))
|
||||
# files.extend(tree("dse"))
|
||||
files.extend(tree("the_question"))
|
||||
|
||||
@@ -172,6 +172,9 @@ def main():
|
||||
"subpixel.c",
|
||||
"winmixer.c",
|
||||
"winmixer.pyx",
|
||||
"_renpybidi.c",
|
||||
"renpybidicore.c",
|
||||
"_renpybidi.pyx",
|
||||
]
|
||||
|
||||
for i in module_files:
|
||||
@@ -229,6 +232,7 @@ def main():
|
||||
print "Did you run me with renpython -OO?"
|
||||
print "Was ming using the right crt?"
|
||||
print "Did you update renpy.py and launcher/script_version.rpy?"
|
||||
print "Did you run with a RENPY_SCALE_FACTOR?"
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -2,19 +2,16 @@
|
||||
<head>
|
||||
<title>README</title>
|
||||
<style>
|
||||
HTML {
|
||||
background: #eed;
|
||||
}
|
||||
|
||||
BODY {
|
||||
background: #fff;
|
||||
margin: 0px 10% 0px 10%;
|
||||
border-left: 1px solid #888;
|
||||
border-right: 1px solid #888;
|
||||
padding-left: 4em;
|
||||
color: #444;
|
||||
padding-left: 20%;
|
||||
padding-top: 1em;
|
||||
padding-bottom: 1em;
|
||||
padding-right: 1em;
|
||||
padding-right: 20%;
|
||||
font-family: sans-serif;
|
||||
line-height: 1.6em;
|
||||
}
|
||||
|
||||
DT {
|
||||
@@ -22,92 +19,110 @@ font-weight: bold;
|
||||
margin-top: .33em;
|
||||
}
|
||||
|
||||
H3 {
|
||||
color: #600;
|
||||
H2 {
|
||||
color: #000;
|
||||
margin-left: -2.5em;
|
||||
}
|
||||
|
||||
H3 {
|
||||
color: #000;
|
||||
margin-left: -1.5em;
|
||||
}
|
||||
|
||||
.editsection {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="renpy_help"></div>
|
||||
<p><a name="Basic_Help" id="Basic_Help"></a></p>
|
||||
<h2><span class="mw-headline">Basic Help</span></h2>
|
||||
<p>To advance through the game, <tt>left-click</tt> or press the <tt>space</tt> or <tt>enter</tt> keys. When at a menu, <tt>left-click</tt> to make a choice, or use the arrow keys to select a choice and <tt>enter</tt> to activate it.</p>
|
||||
<p><a name="Game_Menu" id="Game_Menu"></a></p>
|
||||
<h3><span class="mw-headline">Game Menu</span></h3>
|
||||
<p>When playing a game, <tt>right-click</tt> or press the <tt>escape</tt> key to enter the game menu. The game menu gives the following choices:</p>
|
||||
<dl>
|
||||
<dt>Return</dt>
|
||||
<dd>Returns to the game.</dd>
|
||||
<dt>Save Game</dt>
|
||||
<dd>Allows you to save a game by clicking on a save slot.</dd>
|
||||
<dt>Load Game</dt>
|
||||
<dd>Allows you to load a game by clicking on a save slot. Clicking on "Auto" accesses the automatic save slots.</dd>
|
||||
<dt>Preferences</dt>
|
||||
|
||||
|
||||
|
||||
|
||||
<p><a name="Basic_Help" id="Basic_Help"></a></p>
|
||||
<h2><span class="editsection">[<a href="/w/index.php?title=renpy/Help&action=edit&section=1" title="Edit section: Basic Help">edit</a>]</span> <span class="mw-headline">Basic Help</span></h2>
|
||||
<p>To advance through the game, <tt>left-click</tt> or press the <tt>space</tt> or <tt>enter</tt> keys. When at a menu, <tt>left-click</tt> to make a choice, or use the arrow keys to select a choice and <tt>enter</tt> to activate it.</p>
|
||||
<p><a name="Game_Menu" id="Game_Menu"></a></p>
|
||||
<h3><span class="editsection">[<a href="/w/index.php?title=renpy/Help&action=edit&section=2" title="Edit section: Game Menu">edit</a>]</span> <span class="mw-headline">Game Menu</span></h3>
|
||||
<p>When playing a game, <tt>right-click</tt> or press the <tt>escape</tt> key to enter the game menu. The game menu gives the following choices:</p>
|
||||
<dl>
|
||||
<dt>Return</dt>
|
||||
<dd>Returns to the game.</dd>
|
||||
<dt>Save Game</dt>
|
||||
<dd>Allows you to save a game by clicking on a save slot.</dd>
|
||||
<dt>Load Game</dt>
|
||||
<dd>Allows you to load a game by clicking on a save slot. Clicking on "Auto" accesses the automatic save slots.</dd>
|
||||
<dt>Preferences</dt>
|
||||
<dd>Changes the game preferences (options/configuration):
|
||||
<dl>
|
||||
<dt>Display</dt>
|
||||
<dd>Switches between fullscreen and windowed mode.</dd>
|
||||
<dt>Transitions</dt>
|
||||
<dd>Controls the display of transitions between game screens.</dd>
|
||||
<dt>Text Speed</dt>
|
||||
<dd>Controls the rate at which text displays. The further to the right this slider is, the faster the text will display. All the way to the right causes text to be shown instantly.</dd>
|
||||
<dt>Joystick</dt>
|
||||
<dd>Lets you control the game using a joystick.</dd>
|
||||
<dt>Skip</dt>
|
||||
<dd>Chooses between skipping messages that have been already seen (in any play through the game), and skipping all messages.</dd>
|
||||
<dt>Begin Skipping</dt>
|
||||
<dd>Returns to the game, while skipping.</dd>
|
||||
<dt>After Choices</dt>
|
||||
<dd>Controls if skipping stops upon reaching a menu.</dd>
|
||||
<dt>Auto-Forward Time</dt>
|
||||
<dd>Controls automatic advance. The further to the left this slider is, the shorter the amount of time before the game advances. All the way to the right means text will never auto-forward.</dd>
|
||||
<dt>Music, Sound, and Voice Volume</dt>
|
||||
<dd>Controls the volume of the Music, Sound effect, and Voice channels, respectively. The further to the right these are, the louder the volume.</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>Main Menu</dt>
|
||||
<dd>Returns to the main menu, ending the current game.</dd>
|
||||
<dt>Help</dt>
|
||||
<dd>Shows this help screen.</dd>
|
||||
<dt>Quit</dt>
|
||||
<dd>Exits the game; the game will be closed and ended.</dd>
|
||||
</dl>
|
||||
<p><a name="Key_and_Mouse_Bindings" id="Key_and_Mouse_Bindings"></a></p>
|
||||
<h3><span class="mw-headline">Key and Mouse Bindings</span></h3>
|
||||
<dl>
|
||||
<dt>Left-click, Enter</dt>
|
||||
<dd>Advances through the game, activates menu choices, buttons, and sliders.</dd>
|
||||
<dt>Space</dt>
|
||||
<dd>Advances through the game, but does not activate choices.</dd>
|
||||
<dt>Arrow Keys</dt>
|
||||
<dd>Selects menu choices, buttons, and sliders.</dd>
|
||||
<dt>Ctrl</dt>
|
||||
<dd>Causes skipping to occur while the ctrl key is held down.</dd>
|
||||
<dt>Tab</dt>
|
||||
<dd>Toggles skipping, causing it to occur until tab is pressed again.</dd>
|
||||
<dt>Mousewheel-Up, PageUp</dt>
|
||||
<dd>Causes rollback to occur. Rollback reverses the game back in time, showing prior text and even allowing menu choices to be changed.</dd>
|
||||
<dt>Mousewheel-Down, PageDown</dt>
|
||||
<dd>Causes rollforward to occur, cancelling out a previous rollback.</dd>
|
||||
<dt>Right-click, Escape</dt>
|
||||
<dd>Enters the game menu. When in the game menu, returns to the game.</dd>
|
||||
<dt>Middle-click, H</dt>
|
||||
<dd>Hides the text window and other transient displays.</dd>
|
||||
<dt>F</dt>
|
||||
<dd>Toggles fullscreen mode</dd>
|
||||
<dt>S</dt>
|
||||
<dd>Takes a screenshot, saving it in a file named screenshotxxxx.png, where xxxx is a serial number.</dd>
|
||||
<dt>Alt-H, Command-H</dt>
|
||||
<dd>Hides (iconifies) the window.</dd>
|
||||
<dt>Alt-F4, Command-Q</dt>
|
||||
<dd>Quits the game.</dd>
|
||||
</dl>
|
||||
<p><a name="Legal_Notice" id="Legal_Notice"></a></p>
|
||||
<h2><span class="mw-headline">Legal Notice</span></h2>
|
||||
<p>This game uses source code from a number of open source projects. For a list, and a location where the source code can be downloaded from, please view the <a href="./renpy/LICENSE.txt">LICENSE.txt</a> file in the renpy directory.</p>
|
||||
<dl>
|
||||
<dt>Display</dt>
|
||||
<dd>Switches between fullscreen and windowed mode.</dd>
|
||||
<dt>Transitions</dt>
|
||||
<dd>Controls the display of transitions between game screens.</dd>
|
||||
<dt>Text Speed</dt>
|
||||
<dd>Controls the rate at which text displays. The further to the right this slider is, the faster the text will display. All the way to the right causes text to be shown instantly.</dd>
|
||||
<dt>Joystick</dt>
|
||||
<dd>Lets you control the game using a joystick.</dd>
|
||||
<dt>Skip</dt>
|
||||
<dd>Chooses between skipping messages that have been already seen (in any play through the game), and skipping all messages.</dd>
|
||||
<dt>Begin Skipping</dt>
|
||||
<dd>Returns to the game, while skipping.</dd>
|
||||
<dt>After Choices</dt>
|
||||
<dd>Controls if skipping stops upon reaching a menu.</dd>
|
||||
<dt>Auto-Forward Time</dt>
|
||||
<dd>Controls automatic advance. The further to the left this slider is, the shorter the amount of time before the game advances. All the way to the right means text will never auto-forward.</dd>
|
||||
<dt>Music, Sound, and Voice Volume</dt>
|
||||
<dd>Controls the volume of the Music, Sound effect, and Voice channels, respectively. The further to the right these are, the louder the volume.</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>Main Menu</dt>
|
||||
<dd>Returns to the main menu, ending the current game.</dd>
|
||||
<dt>Help</dt>
|
||||
<dd>Shows this help screen.</dd>
|
||||
<dt>Quit</dt>
|
||||
<dd>Exits the game; the game will be closed and ended.</dd>
|
||||
</dl>
|
||||
<p><a name="Key_and_Mouse_Bindings" id="Key_and_Mouse_Bindings"></a></p>
|
||||
<h3><span class="editsection">[<a href="/w/index.php?title=renpy/Help&action=edit&section=3" title="Edit section: Key and Mouse Bindings">edit</a>]</span> <span class="mw-headline">Key and Mouse Bindings</span></h3>
|
||||
<dl>
|
||||
<dt>Left-click, Enter</dt>
|
||||
<dd>Advances through the game, activates menu choices, buttons, and sliders.</dd>
|
||||
<dt>Space</dt>
|
||||
<dd>Advances through the game, but does not activate choices.</dd>
|
||||
<dt>Arrow Keys</dt>
|
||||
<dd>Selects menu choices, buttons, and sliders.</dd>
|
||||
<dt>Ctrl</dt>
|
||||
<dd>Causes skipping to occur while the ctrl key is held down.</dd>
|
||||
<dt>Tab</dt>
|
||||
<dd>Toggles skipping, causing it to occur until tab is pressed again.</dd>
|
||||
<dt>Mousewheel-Up, PageUp</dt>
|
||||
<dd>Causes rollback to occur. Rollback reverses the game back in time, showing prior text and even allowing menu choices to be changed.</dd>
|
||||
<dt>Mousewheel-Down, PageDown</dt>
|
||||
<dd>Causes rollforward to occur, cancelling out a previous rollback.</dd>
|
||||
<dt>Right-click, Escape</dt>
|
||||
<dd>Enters the game menu. When in the game menu, returns to the game.</dd>
|
||||
<dt>Middle-click, H</dt>
|
||||
<dd>Hides the text window and other transient displays.</dd>
|
||||
<dt>F</dt>
|
||||
<dd>Toggles fullscreen mode</dd>
|
||||
<dt>S</dt>
|
||||
<dd>Takes a screenshot, saving it in a file named screenshotxxxx.png, where xxxx is a serial number.</dd>
|
||||
<dt>Alt-H, Command-H</dt>
|
||||
<dd>Hides (iconifies) the window.</dd>
|
||||
<dt>Alt-F4, Command-Q</dt>
|
||||
<dd>Quits the game.</dd>
|
||||
<dt>Delete</dt>
|
||||
<dd>When a save slot is selected, deletes that save slot.</dd>
|
||||
</dl>
|
||||
<p><a name="Legal_Notice" id="Legal_Notice"></a></p>
|
||||
<h2><span class="editsection">[<a href="/w/index.php?title=renpy/Help&action=edit&section=4" title="Edit section: Legal Notice">edit</a>]</span> <span class="mw-headline">Legal Notice</span></h2>
|
||||
<p>This game uses source code from a number of open source projects. For a list, and a location where the source code can be downloaded from, please view the LICENSE.txt file in the renpy directory, or visit <a href="http://www.renpy.org/wiki/renpy/License" class="external free" title="http://www.renpy.org/wiki/renpy/License" rel="nofollow">http://www.renpy.org/wiki/renpy/License</a> .</p>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
init -1 python:
|
||||
style_backup = renpy.style.backup()
|
||||
|
||||
init python:
|
||||
|
||||
import codecs
|
||||
|
||||
+14
-4
@@ -130,8 +130,11 @@ init python:
|
||||
|
||||
dirs[:] = [ i for i in dirs if include(i, is_root) ]
|
||||
|
||||
rv = [ (a.replace("\\", "/"), b.replace("\\", "/")) for a, b in rv ]
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
def make_zip(t, filename, files, file_data):
|
||||
"""
|
||||
This creates `filename`.zip, containing `files`, placed in the
|
||||
@@ -156,7 +159,7 @@ init python:
|
||||
zi = zipfile.ZipInfo(filename + an)
|
||||
|
||||
s = os.stat(fn)
|
||||
zi.date_time = time.gmtime(s.st_mtime)[:6]
|
||||
zi.date_time = time.gmtime(s.st_mtime)[:6]
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.create_system = 3
|
||||
|
||||
@@ -365,6 +368,11 @@ label distribute:
|
||||
|
||||
project.save()
|
||||
|
||||
base_name = base_name.encode("utf-8")
|
||||
executable_name = executable_name.encode("utf-8")
|
||||
ignore_extensions = ignore_extensions.encode("utf-8")
|
||||
documentation_extensions = documentation_extensions.encode("utf-8")
|
||||
|
||||
# Convert some of these to more useful formats.
|
||||
ignore_extensions = [ i.strip() for i in ignore_extensions.split() ]
|
||||
documentation_extensions = [ i.strip() for i in documentation_extensions.split() ]
|
||||
@@ -386,8 +394,11 @@ label distribute:
|
||||
######################################################################
|
||||
# Multi files.
|
||||
|
||||
rb = config.renpy_base + "/"
|
||||
|
||||
rb = config.renpy_base.replace("\\", "/") + "/"
|
||||
|
||||
|
||||
|
||||
|
||||
# Project files.
|
||||
multi_files.extend(tree(project.path, "/", root=True, exclude_suffix=ignore_extensions))
|
||||
multi_files.append((rb + "renpy.py", "/" + executable_name + ".py"))
|
||||
@@ -509,7 +520,6 @@ label distribute:
|
||||
break
|
||||
else:
|
||||
macapp_files.append((fn, an))
|
||||
|
||||
|
||||
make_zip(
|
||||
_(u"Building Macintosh..."),
|
||||
|
||||
+10
-2
@@ -26,7 +26,12 @@ init python:
|
||||
# Should we set up the editor? How about the transient editor?
|
||||
set_editor = "RENPY_EDITOR" not in os.environ
|
||||
set_editor_transient = "RENPY_EDITOR_TRANSIENT" not in os.environ
|
||||
|
||||
|
||||
if set_editor and not set_editor_transient:
|
||||
config.editor_transient = config.editor
|
||||
os.environ['RENPY_EDITOR_TRANSIENT'] = config.editor
|
||||
set_editor_transient = False
|
||||
|
||||
def scan_editor(ef):
|
||||
"""
|
||||
Scans a single editor file to get the meta-information. If it
|
||||
@@ -84,6 +89,9 @@ init python:
|
||||
Sets the system up to respect the value containined in
|
||||
persistent.editor.
|
||||
"""
|
||||
|
||||
if not set_editor:
|
||||
return
|
||||
|
||||
ef = None
|
||||
|
||||
@@ -100,7 +108,7 @@ init python:
|
||||
"persistent" : persistent,
|
||||
"base" : os.path.dirname(ef),
|
||||
}
|
||||
|
||||
|
||||
execfile(ef, ctx, ctx)
|
||||
|
||||
if set_editor:
|
||||
|
||||
+49
-19
@@ -1,12 +1,50 @@
|
||||
# This file contains the various components of the launcher interface.
|
||||
|
||||
init python:
|
||||
init -11 python:
|
||||
style.launcher_base = Style(style.default)
|
||||
|
||||
style.launcher_text = Style(style.launcher_base)
|
||||
style.launcher_text.size = 15
|
||||
style.launcher_text.color = "#333"
|
||||
style.launcher_text.justify = True
|
||||
|
||||
style.launcher_title = Style(style.launcher_base)
|
||||
style.launcher_title.size = 26
|
||||
style.launcher_title.color = "#333"
|
||||
|
||||
style.launcher_button_text = Style(style.launcher_base)
|
||||
style.launcher_button_text.size = 20
|
||||
style.launcher_button_text.color = "#03c"
|
||||
style.launcher_button_text.hover_color = "#088"
|
||||
style.launcher_button_text.insensitive_color = "#aaa"
|
||||
style.launcher_button_text.minwidth = 250
|
||||
|
||||
style.launcher_small_button_text = Style(style.launcher_button_text)
|
||||
style.launcher_small_button_text.size = 15
|
||||
|
||||
style.launcher_tooltip = Style(style.default)
|
||||
style.launcher_tooltip.color = "#fff"
|
||||
style.launcher_tooltip.size = 14
|
||||
|
||||
|
||||
init 11 python hide:
|
||||
|
||||
props = { }
|
||||
for i in style.default.properties:
|
||||
props.update(i)
|
||||
|
||||
if props["font"] == "DejaVuSans.ttf":
|
||||
style.launcher_base.setdefault(font="DejaVuSerif.ttf")
|
||||
|
||||
init 11 python:
|
||||
|
||||
import time
|
||||
|
||||
|
||||
# Settings.
|
||||
config.developer = True
|
||||
|
||||
# Make backup of styles.
|
||||
style_backup = renpy.style.backup()
|
||||
|
||||
# Style customizations. These need to be in a function so that we can
|
||||
# change them when we're choosing a theme.
|
||||
@@ -18,9 +56,7 @@ init python:
|
||||
style.hyperlink_text.hover_color = "#00c"
|
||||
style.hyperlink_text.size = 15
|
||||
style.hyperlink_text.underline = False
|
||||
style.hyperlink_text.font = "DejaVuSerif.ttf"
|
||||
|
||||
|
||||
|
||||
customize_styles()
|
||||
|
||||
tooltip = _(u"Welcome!")
|
||||
@@ -75,16 +111,16 @@ init python:
|
||||
"""
|
||||
|
||||
ui.window(style="default", bottom_margin=4, top_margin=12)
|
||||
ui.text(s, size=26, color="#333", font="DejaVuSerif.ttf")
|
||||
ui.text(s, style="launcher_title")
|
||||
|
||||
def text(s):
|
||||
"""
|
||||
Display text on the screen.
|
||||
"""
|
||||
|
||||
ui.text(s, size=15, color="#333", font="DejaVuSerif.ttf", justify=True)
|
||||
ui.text(s, style="launcher_text")
|
||||
|
||||
def button(s, clicked=None, subtitle="", hovered=None, unhovered=None, size=20):
|
||||
def button(s, clicked=None, subtitle="", hovered=None, unhovered=None):
|
||||
"""
|
||||
Displays a button with caption `s`.
|
||||
"""
|
||||
@@ -100,9 +136,7 @@ init python:
|
||||
hovered=hovered, unhovered=unhovered,
|
||||
top_padding=3, bottom_padding=3)
|
||||
|
||||
ui.text(s, style="default", size=size,
|
||||
color="#03c", hover_color="00c", insensitive_color="#aaa",
|
||||
font="DejaVuSerif.ttf", minwidth=250)
|
||||
ui.text(s, style="launcher_button_text")
|
||||
|
||||
def small_button(s, clicked=None, subtitle="", hovered=None, unhovered=None):
|
||||
"""
|
||||
@@ -119,9 +153,7 @@ init python:
|
||||
hovered=hovered, unhovered=unhovered,
|
||||
top_padding=0, bottom_padding=0)
|
||||
|
||||
ui.text(s, style="default", size=15,
|
||||
color="#03c", hover_color="00c", insensitive_color="#aaa",
|
||||
font="DejaVuSerif.ttf", minwidth=250)
|
||||
ui.text(s, style="launcher_small_button_text")
|
||||
|
||||
def toggle_button(s, checked, clicked=None, subtitle=""):
|
||||
"""
|
||||
@@ -132,17 +164,15 @@ init python:
|
||||
unhovered = untooltips(subtitle)
|
||||
|
||||
if checked:
|
||||
s = u"\u25a3 " + s
|
||||
s = u"{font=DejaVuSans.ttf}\u25a3{/font} " + s
|
||||
else:
|
||||
s = u"\u25a1 " + s
|
||||
s = u"{font=DejaVuSans.ttf}\u25a1{/font} " + s
|
||||
|
||||
ui.button(style="default", clicked=clicked,
|
||||
hovered=hovered, unhovered=unhovered,
|
||||
top_padding=0, bottom_padding=0)
|
||||
|
||||
ui.text(s, style="default", size=15,
|
||||
color="#03c", hover_color="00c", insensitive_color="#aaa",
|
||||
font="DejaVuSerif.ttf", minwidth=250)
|
||||
ui.text(s, style="launcher_small_button_text")
|
||||
|
||||
def scrolled(cancel, yadj=None):
|
||||
|
||||
|
||||
+4
-1
@@ -9,8 +9,11 @@ label options:
|
||||
|
||||
title(_(u"Launcher Options"))
|
||||
|
||||
editor = persistent.editor
|
||||
if not set_editor:
|
||||
editor = _(u"Using RENPY_EDITOR")
|
||||
|
||||
text_variable(_("Text Editor"), persistent.editor, "editor",
|
||||
text_variable(_("Text Editor"), editor, "editor",
|
||||
_(u"Change the default text editor."))
|
||||
|
||||
ui.null(height=15)
|
||||
|
||||
+19
-3
@@ -110,7 +110,7 @@ init python:
|
||||
|
||||
project_dirs = [ config.renpy_base ]
|
||||
|
||||
if persistent.projects_directory:
|
||||
if persistent.projects_directory and persistent.projects_directory not in project_dirs:
|
||||
project_dirs.append(persistent.projects_directory)
|
||||
|
||||
for d in project_dirs:
|
||||
@@ -148,7 +148,7 @@ init python:
|
||||
return
|
||||
|
||||
for i in projects:
|
||||
if i.name == "demo":
|
||||
if i.name == "tutorial":
|
||||
i.select()
|
||||
return
|
||||
|
||||
@@ -193,6 +193,21 @@ label select_project:
|
||||
|
||||
interact()
|
||||
|
||||
label launch_tutorial:
|
||||
|
||||
|
||||
python hide:
|
||||
|
||||
if sys.platform == "win32" and sys.argv[0].lower().endswith(".exe"):
|
||||
proc = subprocess.Popen([sys.argv[0], tutorial_path])
|
||||
else:
|
||||
proc = subprocess.Popen([sys.executable, sys.argv[0], tutorial_path])
|
||||
|
||||
set_tooltip(_(u"Tutorial game has been launched."))
|
||||
|
||||
jump top
|
||||
|
||||
|
||||
label launch:
|
||||
|
||||
python hide:
|
||||
@@ -269,7 +284,8 @@ label lint:
|
||||
lf = file("lint.txt", "w+")
|
||||
|
||||
if hasattr(sys, "winver") and sys.argv[0].lower().endswith(".exe"):
|
||||
proc = subprocess.Popen([config.renpy_base + "/console.exe", "--lint", project.path], stdin=lf, stdout=lf, stderr=lf)
|
||||
CREATE_NO_WINDOW=0x08000000
|
||||
proc = subprocess.Popen([config.renpy_base + "/console.exe", "--lint", project.path], stdin=lf, stdout=lf, stderr=lf, creationflags=CREATE_NO_WINDOW)
|
||||
else:
|
||||
proc = subprocess.Popen([sys.executable, sys.argv[0], "--lint", project.path], stdout=lf)
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
init python:
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
try:
|
||||
import EasyDialogs
|
||||
except ImportError:
|
||||
@@ -37,8 +38,12 @@ label choose_projects_directory:
|
||||
|
||||
try:
|
||||
|
||||
env = os.environ.copy()
|
||||
if 'RENPY_OLD_LD_LIBRARY_PATH' in env:
|
||||
env['LD_LIBRARY_PATH'] = env['RENPY_OLD_LD_LIBRARY_PATH']
|
||||
|
||||
zen = subprocess.Popen([ "zenity", "--title=Select Projects Directory", "--file-selection", "--directory", "--filename=" + path ],
|
||||
stdout=subprocess.PIPE)
|
||||
env=env, stdout=subprocess.PIPE)
|
||||
|
||||
choice = zen.stdout.read()
|
||||
zen.wait()
|
||||
|
||||
+15
-1
@@ -1,3 +1,7 @@
|
||||
init python:
|
||||
tutorial_path = config.renpy_base + "/tutorial"
|
||||
tutorial_exists = os.path.isdir(tutorial_path)
|
||||
|
||||
label main_menu:
|
||||
return
|
||||
|
||||
@@ -86,7 +90,17 @@ label top:
|
||||
ui.jumps("documentation"),
|
||||
_(u"Open the Ren'Py documentation in a web browser."))
|
||||
|
||||
ui.null()
|
||||
if tutorial_exists:
|
||||
|
||||
button(_(u"Tutorial Game"),
|
||||
ui.jumps("launch_tutorial"),
|
||||
_(u"Launches the Ren'Py tutorial game."))
|
||||
|
||||
else:
|
||||
|
||||
ui.null()
|
||||
|
||||
|
||||
|
||||
ui.close()
|
||||
ui.close()
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
init -999:
|
||||
$ config.script_version = (6, 9, 3)
|
||||
$ config.script_version = (6, 10, 1)
|
||||
|
||||
|
||||
+179
-174
@@ -3,190 +3,195 @@ init python:
|
||||
|
||||
TRANSLATION_STRINGS = [
|
||||
|
||||
u'Developer Menu',
|
||||
u'Return to the developer menu',
|
||||
u'Skip Mode',
|
||||
u'Fast Skip Mode',
|
||||
u'Please click to continue.',
|
||||
u'Start Game',
|
||||
u'Load Game',
|
||||
u'Preferences',
|
||||
u'Help',
|
||||
u'Quit',
|
||||
u'Return',
|
||||
u'Save Game',
|
||||
u'Main Menu',
|
||||
u'Are you sure you want to quit?',
|
||||
u'Are you sure you want to return to the main menu?\\nThis will lose unsaved progress.',
|
||||
u'Begin Skipping',
|
||||
u'Empty Slot.',
|
||||
u'Previous',
|
||||
u'Next',
|
||||
u'Yes',
|
||||
u'No',
|
||||
u'Loading will lose unsaved progress.\\nAre you sure you want to do this?',
|
||||
u'Are you sure you want to overwrite your save?',
|
||||
u'The error message was:',
|
||||
u'You may want to try saving in a different slot, or playing for a while and trying again later.',
|
||||
u'Save Failed.',
|
||||
u'Continue Game',
|
||||
u'Test',
|
||||
u'Left',
|
||||
u'Right',
|
||||
u'Up',
|
||||
u'Down',
|
||||
u'Not Assigned',
|
||||
u'Select/Dismiss',
|
||||
u'Rollback',
|
||||
u'Hold to Skip',
|
||||
u'Joystick Mapping',
|
||||
u'Move the joystick or press a joystick button to create the mapping. Click the mouse to remove the mapping.',
|
||||
u'Toggle Skip',
|
||||
u'Hide Text',
|
||||
u'Menu',
|
||||
u'Display',
|
||||
u'Window',
|
||||
u'Fullscreen',
|
||||
u'Transitions',
|
||||
u'All',
|
||||
u'Some',
|
||||
u'None',
|
||||
u'Skip',
|
||||
u'Seen Messages',
|
||||
u'All Messages',
|
||||
u'After Choices',
|
||||
u'Stop Skipping',
|
||||
u'Keep Skipping',
|
||||
u'Text Speed',
|
||||
u'Auto-Forward Time',
|
||||
u'Music Volume',
|
||||
u'Sound Volume',
|
||||
u'Joystick...',
|
||||
u'Joystick Configuration',
|
||||
u'Voice Volume',
|
||||
u'Auto',
|
||||
u'Quick',
|
||||
u'The patterns did not match any files, so no archive was created.',
|
||||
u'Archiving Files...',
|
||||
u'Success',
|
||||
u'The files have been added to the archive, and moved into the \\"archived\\" directory. Future runs of the archiver will archive files in both the \\"game\\" and \\"archived\\" directories.',
|
||||
u'Archiver',
|
||||
u'The archiver allows you to obfuscate your game by including files in an archive file.',
|
||||
u'Archive Name:',
|
||||
u'The name of the archive to create.',
|
||||
u'Include Patterns:',
|
||||
u'Files matching these patterns are included in the archive.',
|
||||
u'Exclude Patterns:',
|
||||
u'Files matching these patterns are excluded from the archive.',
|
||||
u'Archive',
|
||||
u'Build the archive.',
|
||||
u'Cancel',
|
||||
u'Archive Name',
|
||||
u'The name of the archive file to create, without the .rpa extension.\\n\\nThe \\"data\\" archive is loaded automatically. Other archives must be added to config.archives.',
|
||||
u'Include Patterns',
|
||||
u'This is a space-separated list of file patterns. Files matching these patterns are added to the archive.\\n\\nAsterisks (*) can be used as a wildcard.',
|
||||
u'This is a space-separated list of file patterns. Files matching these patterns are excluded from the archive. If a file is matched by both an exclude and include pattern, the exclude takes precedence.\\n\\nAsterisks (*) can be used as a wildcard.',
|
||||
u'Scanning Files...',
|
||||
u'Could not modify options.rpy. Perhaps it was changed too much.',
|
||||
u'Theme changed to %s.',
|
||||
u'Planetarium',
|
||||
u'The options.rpy file does not exist in the game directory, so this launcher cannot change the theme.',
|
||||
u"Are you sure?",
|
||||
u"Are you sure you want to delete this save?",
|
||||
u"Are you sure you want to overwrite your save?",
|
||||
u"Loading will lose unsaved progress.\nAre you sure you want to do this?",
|
||||
u"Are you sure you want to quit?",
|
||||
u"Are you sure you want to return to the main menu?\nThis will lose unsaved progress.",
|
||||
u"Skip Mode",
|
||||
u"Fast Skip Mode",
|
||||
u"Please click to continue.",
|
||||
u"Start Game",
|
||||
u"Load Game",
|
||||
u"Preferences",
|
||||
u"Help",
|
||||
u"Quit",
|
||||
u"Return",
|
||||
u"Save Game",
|
||||
u"Main Menu",
|
||||
u"Begin Skipping",
|
||||
u"Empty Slot.",
|
||||
u"Previous",
|
||||
u"Next",
|
||||
u"Yes",
|
||||
u"No",
|
||||
u"The error message was:",
|
||||
u"You may want to try saving in a different slot, or playing for a while and trying again later.",
|
||||
u"Save Failed.",
|
||||
u"Continue Game",
|
||||
u"Test",
|
||||
u"Left",
|
||||
u"Right",
|
||||
u"Up",
|
||||
u"Down",
|
||||
u"Not Assigned",
|
||||
u"Select/Dismiss",
|
||||
u"Rollback",
|
||||
u"Hold to Skip",
|
||||
u"Joystick Mapping",
|
||||
u"Move the joystick or press a joystick button to create the mapping. Click the mouse to remove the mapping.",
|
||||
u"Toggle Skip",
|
||||
u"Hide Text",
|
||||
u"Menu",
|
||||
u"Display",
|
||||
u"Window",
|
||||
u"Fullscreen",
|
||||
u"Transitions",
|
||||
u"All",
|
||||
u"Some",
|
||||
u"None",
|
||||
u"Skip",
|
||||
u"Seen Messages",
|
||||
u"All Messages",
|
||||
u"After Choices",
|
||||
u"Stop Skipping",
|
||||
u"Keep Skipping",
|
||||
u"Text Speed",
|
||||
u"Auto-Forward Time",
|
||||
u"Music Volume",
|
||||
u"Sound Volume",
|
||||
u"Joystick...",
|
||||
u"Joystick Configuration",
|
||||
u"Voice Volume",
|
||||
u"Auto",
|
||||
u"Quick",
|
||||
u"The patterns did not match any files, so no archive was created.",
|
||||
u"Archiving Files...",
|
||||
u"Success",
|
||||
u"The files have been added to the archive, and moved into the \"archived\" directory. Future runs of the archiver will archive files in both the \"game\" and \"archived\" directories.",
|
||||
u"Archiver",
|
||||
u"The archiver allows you to obfuscate your game by including files in an archive file.",
|
||||
u"Archive Name:",
|
||||
u"The name of the archive to create.",
|
||||
u"Include Patterns:",
|
||||
u"Files matching these patterns are included in the archive.",
|
||||
u"Exclude Patterns:",
|
||||
u"Files matching these patterns are excluded from the archive.",
|
||||
u"Archive",
|
||||
u"Build the archive.",
|
||||
u"Cancel",
|
||||
u"Archive Name",
|
||||
u"The name of the archive file to create, without the .rpa extension.\n\nThe \"data\" archive is loaded automatically. Other archives must be added to config.archives.",
|
||||
u"Include Patterns",
|
||||
u"This is a space-separated list of file patterns. Files matching these patterns are added to the archive.\n\nAsterisks (*) can be used as a wildcard.",
|
||||
u"This is a space-separated list of file patterns. Files matching these patterns are excluded from the archive. If a file is matched by both an exclude and include pattern, the exclude takes precedence.\n\nAsterisks (*) can be used as a wildcard.",
|
||||
u"Scanning Files...",
|
||||
u"Could not modify options.rpy. Perhaps it was changed too much.",
|
||||
u"Theme changed to %s.",
|
||||
u"Planetarium",
|
||||
u"The options.rpy file does not exist in the game directory, so this launcher cannot change the theme.",
|
||||
u"Themes control the basic look of interface elements. You'll be able to pick a color scheme next.",
|
||||
u'Choose Theme',
|
||||
u'Please choose a color scheme for your project.',
|
||||
u'Choose Color Scheme',
|
||||
u'Building Distributions',
|
||||
u'Base Name:',
|
||||
u'Used to generate the names of directories and archive files.',
|
||||
u'Executable Name:',
|
||||
u'Used to generate the names of executables and runnable programs.',
|
||||
u'Ignore Extensions:',
|
||||
u'Files with these extensions will not be included in the distributions.',
|
||||
u'Documentation Extensions:',
|
||||
u'Files with these extensions will be treated as documentation, when building the Macintosh application.',
|
||||
u'Distributions to Build:',
|
||||
u'Windows x86',
|
||||
u'Zip distribution for the 32-bit Windows platform.',
|
||||
u'Linux x86',
|
||||
u'Tar.Bz2 distribution for the Linux x86 platform.',
|
||||
u'Macintosh Universal',
|
||||
u'Single application distribution for the Macintosh x86 and ppc platforms.',
|
||||
u'Windows/Linux/Mac Combined',
|
||||
u'Zip distribution for the Windows x86, Linux x86, Macintosh x86 and Macintosh ppc platforms.',
|
||||
u'Build',
|
||||
u'Start building the distributions.',
|
||||
u'Base Name',
|
||||
u'Please enter in the base name for your distribution. This name is used to generate the names of directories and archive files. Usually, this is the name of your game, plus a version number, like \\"moonlight-1.0\\".',
|
||||
u'Executable Name',
|
||||
u'Please enter a name for the executables in your distribution. This should not include an extension, as that will be added automatically.',
|
||||
u'Ignore Extensions',
|
||||
u'Please enter a space-separated list of file extensions. Files with these extensions will not be included in the built distributions.',
|
||||
u'Documentation Extensions',
|
||||
u'Please enter a space separated list of documentation extensions. Files in the base directory with these extensions will have a second copy stored outside of the Macintosh application.',
|
||||
u'Scanning...',
|
||||
u'Building Windows...',
|
||||
u'Building Linux...',
|
||||
u'Building Macintosh...',
|
||||
u'Building Combined...',
|
||||
u"Choose Theme",
|
||||
u"Please choose a color scheme for your project.",
|
||||
u"Choose Color Scheme",
|
||||
u"Building Distributions",
|
||||
u"I've just performed a lint on your project. If it contains errors, you should say no and fix them.\nPlease also check {a=http://www.renpy.org/wiki/renpy/Download_Ren'Py}www.renpy.org{/a} to see if updates or fixes are available.\n\nDo you want to continue?",
|
||||
u"Base Name:",
|
||||
u"Used to generate the names of directories and archive files.",
|
||||
u"Executable Name:",
|
||||
u"Used to generate the names of executables and runnable programs.",
|
||||
u"Ignore Extensions:",
|
||||
u"Files with these extensions will not be included in the distributions.",
|
||||
u"Documentation Extensions:",
|
||||
u"Files with these extensions will be treated as documentation, when building the Macintosh application.",
|
||||
u"Distributions to Build:",
|
||||
u"Windows x86",
|
||||
u"Zip distribution for the 32-bit Windows platform.",
|
||||
u"Linux x86",
|
||||
u"Tar.Bz2 distribution for the Linux x86 platform.",
|
||||
u"Macintosh Universal",
|
||||
u"Single application distribution for the Macintosh x86 and ppc platforms.",
|
||||
u"Windows/Linux/Mac Combined",
|
||||
u"Zip distribution for the Windows x86, Linux x86, Macintosh x86 and Macintosh ppc platforms.",
|
||||
u"Build",
|
||||
u"Start building the distributions.",
|
||||
u"Base Name",
|
||||
u"Please enter in the base name for your distribution. This name is used to generate the names of directories and archive files. Usually, this is the name of your game, plus a version number, like \"moonlight-1.0\".",
|
||||
u"Executable Name",
|
||||
u"Please enter a name for the executables in your distribution. This should not include an extension, as that will be added automatically.",
|
||||
u"Ignore Extensions",
|
||||
u"Please enter a space-separated list of file extensions. Files with these extensions will not be included in the built distributions.",
|
||||
u"Documentation Extensions",
|
||||
u"Please enter a space separated list of documentation extensions. Files in the base directory with these extensions will have a second copy stored outside of the Macintosh application.",
|
||||
u"Scanning...",
|
||||
u"Building Windows...",
|
||||
u"Building Linux...",
|
||||
u"Building Macintosh...",
|
||||
u"Building Combined...",
|
||||
u"Thank you for choosing Ren'Py.",
|
||||
u"The distributions have been built. Be sure to test them before release.\\n\\nNote that unpacking and repacking the Macintosh, Linux, or Combined distributions on Windows is not supported.\\n\\nPlease announce your release at the {a=http://lemmasoft.renai.us/forums/}Lemma Soft Forums{/a}, so we can add it to the Ren'Py web site.",
|
||||
u'The editor has been set from the RENPY_EDITOR environment variable, and cannot be changed.',
|
||||
u'Choose Editor',
|
||||
u"The distributions have been built. Be sure to test them before release.\n\nNote that unpacking and repacking the Macintosh, Linux, or Combined distributions on Windows is not supported.\n\nPlease announce your release at the {a=http://lemmasoft.renai.us/forums/}Lemma Soft Forums{/a}, so we can add it to the Ren'Py web site.",
|
||||
u"The editor has been set from the RENPY_EDITOR environment variable, and cannot be changed.",
|
||||
u"Choose Editor",
|
||||
u"Please choose the editor that will be use to edit scripts and display errors. More editors can be downloaded from {a=http://www.renpy.org/wiki/renpy/Editors}the Ren'Py website{/a}.",
|
||||
u'Error',
|
||||
u'Press enter when done.',
|
||||
u'Welcome!',
|
||||
u'The string cannot be empty. Please enter some text.',
|
||||
u'Non-ASCII filenames are not allowed. This is because Zip files cannot reliably represent non-ASCII filenames.',
|
||||
u'Processed %d of %d files.',
|
||||
u'New Project',
|
||||
u'Please type the name of your new project.',
|
||||
u'Something with that name already exists in the projects directory.',
|
||||
u'Creating Project',
|
||||
u'Please wait while we create the project.',
|
||||
u'%s Launcher',
|
||||
u'Launcher Options',
|
||||
u'Change the default text editor.',
|
||||
u'Projects Directory',
|
||||
u"Error",
|
||||
u"Press enter when done.",
|
||||
u"The string cannot be empty. Please enter some text.",
|
||||
u"Non-ASCII filenames are not allowed. This is because Zip files cannot reliably represent non-ASCII filenames.",
|
||||
u"Processed %d of %d files.",
|
||||
u"Welcome!",
|
||||
u"New Project",
|
||||
u"Please type the name of your new project.",
|
||||
u"Something with that name already exists in the projects directory.",
|
||||
u"Creating Project",
|
||||
u"Please wait while we create the project.",
|
||||
u"%s Launcher",
|
||||
u"Launcher Options",
|
||||
u"Using RENPY_EDITOR",
|
||||
u"Change the default text editor.",
|
||||
u"Projects Directory",
|
||||
u"Select the directory Ren'Py searches for projects.",
|
||||
u'Select Project',
|
||||
u'%s has been launched.',
|
||||
u'Opening game directory:\\n%s',
|
||||
u'No editor has been selected.',
|
||||
u'No files to edit.',
|
||||
u'Launching the editor failed.',
|
||||
u'Launched editor with %d script files.',
|
||||
u'Lint',
|
||||
u'Lint in progress.',
|
||||
u'Lint complete.',
|
||||
u'Deleting persistent data.',
|
||||
u'Delete Persistent',
|
||||
u'Persistent data has been deleted.',
|
||||
u'Choose Projects Directory',
|
||||
u'Please choose the directory containing your projects.',
|
||||
u"Select Project",
|
||||
u"Tutorial game has been launched.",
|
||||
u"%s has been launched.",
|
||||
u"Opening game directory:\n%s",
|
||||
u"No editor has been selected.",
|
||||
u"No files to edit.",
|
||||
u"Launching the editor failed.",
|
||||
u"Launched editor with %d script files.",
|
||||
u"Lint",
|
||||
u"Lint in progress.",
|
||||
u"Lint complete.",
|
||||
u"Deleting persistent data.",
|
||||
u"Delete Persistent",
|
||||
u"Persistent data has been deleted.",
|
||||
u"Choose Projects Directory",
|
||||
u"Please choose the directory containing your projects.",
|
||||
u"Could not run zenity. The projects directory has been set to the directory immediately above the directory containing Ren'Py.",
|
||||
u"Now showing the Ren'Py documentation in your web browser.",
|
||||
u'Launch',
|
||||
u'Launches the project.',
|
||||
u'Edit Script',
|
||||
u'Edits the script of the project.',
|
||||
u'Game Directory',
|
||||
u"Launch",
|
||||
u"Launches the project.",
|
||||
u"Edit Script",
|
||||
u"Edits the script of the project.",
|
||||
u"Game Directory",
|
||||
u"Opens the project's game directory.",
|
||||
u'Check Script (Lint)',
|
||||
u'Checks the script of the project for likely errors.',
|
||||
u'Changes the theme used by the project.',
|
||||
u'Deletes the persistent data associated with the project.',
|
||||
u'Archive Files',
|
||||
u'Archives files found in the game and archived directories.',
|
||||
u'Build Distributions',
|
||||
u'Builds distributions of the project.',
|
||||
u"Check Script (Lint)",
|
||||
u"Checks the script of the project for likely errors.",
|
||||
u"Changes the theme used by the project.",
|
||||
u"Deletes the persistent data associated with the project.",
|
||||
u"Archive Files",
|
||||
u"Archives files found in the game and archived directories.",
|
||||
u"Build Distributions",
|
||||
u"Builds distributions of the project.",
|
||||
u"Ren'Py",
|
||||
u'Select a project to work with.',
|
||||
u'Create a new project.',
|
||||
u'Causes the launcher to exit.',
|
||||
u'Options',
|
||||
u"Select a project to work with.",
|
||||
u"Create a new project.",
|
||||
u"Causes the launcher to exit.",
|
||||
u"Options",
|
||||
u"Change Ren'Py launcher options.",
|
||||
u"Ren'Py Help",
|
||||
u"Open the Ren'Py documentation in a web browser.",
|
||||
u"Tutorial Game",
|
||||
u"Launches the Ren'Py tutorial game.",
|
||||
]
|
||||
|
||||
|
||||
+5742
File diff suppressed because it is too large
Load Diff
+9
-8
@@ -62,7 +62,8 @@ cdef extern from "renpy.h":
|
||||
|
||||
void scale32_core(object, object,
|
||||
float, float, float, float,
|
||||
float, float, float, float)
|
||||
float, float, float, float,
|
||||
int)
|
||||
|
||||
void scale24_core(object, object,
|
||||
float, float, float, float,
|
||||
@@ -70,7 +71,7 @@ cdef extern from "renpy.h":
|
||||
|
||||
void transform32_core(object, object,
|
||||
float, float, float, float, float, float,
|
||||
int, float)
|
||||
int, float, int)
|
||||
|
||||
void blend32_core(object, object, object, int)
|
||||
|
||||
@@ -94,9 +95,8 @@ import pygame
|
||||
|
||||
PygameSurface = pygame.Surface
|
||||
|
||||
# Update this in 00library.rpy as well!
|
||||
def version():
|
||||
return 6009000
|
||||
return (6, 10, 1)
|
||||
|
||||
def save_png(surf, file, compress=-1):
|
||||
|
||||
@@ -284,7 +284,8 @@ def alpha_munge(pysrc, pydst, srcchan, dstchan, amap):
|
||||
|
||||
def bilinear(pysrc, pydst,
|
||||
source_xoff=0.0, source_yoff=0.0, source_width=None, source_height=None,
|
||||
dest_xoff=0.0, dest_yoff=0.0, dest_width=None, dest_height=None):
|
||||
dest_xoff=0.0, dest_yoff=0.0, dest_width=None, dest_height=None,
|
||||
precise=0):
|
||||
|
||||
if not isinstance(pysrc, PygameSurface):
|
||||
raise Exception("bilinear requires a pygame Surface as its first argument.")
|
||||
@@ -310,7 +311,7 @@ def bilinear(pysrc, pydst,
|
||||
if pysrc.get_bitsize() == 32:
|
||||
scale32_core(pysrc, pydst,
|
||||
source_xoff, source_yoff, source_width, source_height,
|
||||
dest_xoff, dest_yoff, dest_width, dest_height)
|
||||
dest_xoff, dest_yoff, dest_width, dest_height, precise)
|
||||
|
||||
else:
|
||||
scale24_core(pysrc, pydst,
|
||||
@@ -332,7 +333,7 @@ def check(surf):
|
||||
|
||||
def transform(pysrc, pydst,
|
||||
corner_x, corner_y,
|
||||
xdx, ydx, xdy, ydy, a=1.0):
|
||||
xdx, ydx, xdy, ydy, a=1.0, precise=0):
|
||||
|
||||
check(pysrc)
|
||||
check(pydst)
|
||||
@@ -344,7 +345,7 @@ def transform(pysrc, pydst,
|
||||
corner_x, corner_y,
|
||||
xdx, ydx,
|
||||
xdy, ydy,
|
||||
pysrc.get_shifts()[3], a)
|
||||
pysrc.get_shifts()[3], a, precise)
|
||||
|
||||
# pydst.unlock()
|
||||
# pysrc.unlock()
|
||||
|
||||
+1446
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
cdef extern from "fribidi/fribidi.h":
|
||||
int FRIBIDI_TYPE_LTR
|
||||
int FRIBIDI_TYPE_ON
|
||||
int FRIBIDI_TYPE_RTL
|
||||
int FRIBIDI_TYPE_WR
|
||||
int FRIBIDI_TYPE_WL
|
||||
|
||||
cdef extern object renpybidi_log2vis(object, int *)
|
||||
|
||||
WLTR = FRIBIDI_TYPE_WL
|
||||
LTR = FRIBIDI_TYPE_LTR
|
||||
ON = FRIBIDI_TYPE_ON
|
||||
RTL = FRIBIDI_TYPE_RTL
|
||||
WRTL = FRIBIDI_TYPE_WR
|
||||
|
||||
def log2vis(s, int direction=FRIBIDI_TYPE_ON):
|
||||
|
||||
s = s.encode("utf8")
|
||||
s = renpybidi_log2vis(s, &direction)
|
||||
return s.decode("utf8"), direction
|
||||
|
||||
+247
-142
@@ -773,7 +773,9 @@ void scale32_core(PyObject *pysrc, PyObject *pydst,
|
||||
float source_xoff, float source_yoff,
|
||||
float source_width, float source_height,
|
||||
float dest_xoff, float dest_yoff,
|
||||
float dest_width, float dest_height) {
|
||||
float dest_width, float dest_height,
|
||||
int precise
|
||||
) {
|
||||
|
||||
|
||||
SDL_Surface *src;
|
||||
@@ -803,9 +805,25 @@ void scale32_core(PyObject *pysrc, PyObject *pydst,
|
||||
srch = src->h;
|
||||
dsth = dst->h;
|
||||
|
||||
xdelta = 255.0 * (source_width - 1) / dest_width;
|
||||
ydelta = 255.0 * (source_height - 1) / dest_height;
|
||||
if (precise) {
|
||||
|
||||
if (dest_width > 1) {
|
||||
xdelta = 256.0 * (source_width - 1) / (dest_width - 1);
|
||||
} else {
|
||||
xdelta = 0;
|
||||
}
|
||||
|
||||
if (dest_height > 1) {
|
||||
ydelta = 256.0 * (source_height - 1) / (dest_height - 1);
|
||||
} else {
|
||||
ydelta = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
xdelta = 255.0 * (source_width - 1) / dest_width;
|
||||
ydelta = 255.0 * (source_height - 1) / dest_height;
|
||||
}
|
||||
|
||||
for (y = 0; y < dsth; y++) {
|
||||
|
||||
unsigned char *s0;
|
||||
@@ -821,14 +839,14 @@ void scale32_core(PyObject *pysrc, PyObject *pydst,
|
||||
d = dstpixels + dstpitch * y;
|
||||
dend = d + 4 * dstw; // bpp
|
||||
|
||||
sline = source_yoff * 255 + (y + dest_yoff) * ydelta;
|
||||
sline = source_yoff * 256 + (y + dest_yoff) * ydelta;
|
||||
s1frac = (int) sline & 255;
|
||||
s0frac = 256 - s1frac;
|
||||
|
||||
s0 = srcpixels + (sline >> 8) * srcpitch;
|
||||
s1 = s0 + srcpitch;
|
||||
|
||||
scol = source_xoff * 255 + dest_xoff * xdelta;
|
||||
scol = source_xoff * 256 + dest_xoff * xdelta;
|
||||
|
||||
while (d < dend) {
|
||||
|
||||
@@ -960,15 +978,22 @@ void scale24_core(PyObject *pysrc, PyObject *pydst,
|
||||
}
|
||||
|
||||
#define I(a, b, mul) ((((((b - a) * mul)) >> 8) + a) & 0xff00ff)
|
||||
|
||||
|
||||
/** This appears to limit the expansion, such that 1/x yields a max
|
||||
expansion of lg x */
|
||||
#define EPSILON (1.0 / 256.0)
|
||||
|
||||
/****************************************************************************/
|
||||
/* A similar concept to rotozoom, but implemented differently, so we
|
||||
can limit the target area. */
|
||||
void transform32_std(PyObject *pysrc, PyObject *pydst,
|
||||
float corner_x, float corner_y,
|
||||
float xdx, float ydx,
|
||||
float xdy, float ydy,
|
||||
int ashift, float a) {
|
||||
int transform32_std(PyObject *pysrc, PyObject *pydst,
|
||||
float corner_x, float corner_y,
|
||||
float xdx, float ydx,
|
||||
float xdy, float ydy,
|
||||
int ashift,
|
||||
float a,
|
||||
int precise
|
||||
) {
|
||||
|
||||
SDL_Surface *src;
|
||||
SDL_Surface *dst;
|
||||
@@ -978,12 +1003,13 @@ void transform32_std(PyObject *pysrc, PyObject *pydst,
|
||||
int srcw, srch;
|
||||
int dstw, dsth;
|
||||
|
||||
// The x and y source pixel coordinates, times 65536. And their
|
||||
// delta-per-dest-x-pixel.
|
||||
int sxi = 0, syi = 0, dsxi = 0, dsyi = 0;
|
||||
|
||||
unsigned char *srcpixels;
|
||||
unsigned char *dstpixels;
|
||||
|
||||
float lsx, lsy; // The position of the current line in the source.
|
||||
float sx, sy; // The position of the current pixel in the source.
|
||||
|
||||
src = PySurface_AsSurface(pysrc);
|
||||
dst = PySurface_AsSurface(pydst);
|
||||
|
||||
@@ -998,81 +1024,113 @@ void transform32_std(PyObject *pysrc, PyObject *pydst,
|
||||
srch = src->h;
|
||||
dsth = dst->h;
|
||||
|
||||
unsigned int amul = (int) (a * 256);
|
||||
// Compute the coloring multiplier.
|
||||
unsigned int amul = (unsigned int) (a * 256);
|
||||
|
||||
// Compute the maximum x and y coordinates.
|
||||
double maxsx = srcw - 1;
|
||||
double maxsy = srch - 1;
|
||||
|
||||
lsx = corner_x * 65536;
|
||||
lsy = corner_y * 65536;
|
||||
// Deal with pre-6.10.1 versions of Ren'Py, which didn't give us
|
||||
// that 1px border that allows us to be precise.
|
||||
if (! precise) {
|
||||
maxsx -= EPSILON;
|
||||
maxsy -= EPSILON;
|
||||
|
||||
// If a delta is too even, subtract epsilon (towards 0) from it.
|
||||
if (xdx && fabs(fmodf(1.0 / xdx, 1)) < EPSILON) {
|
||||
xdx -= (xdx / fabs(xdx)) * EPSILON;
|
||||
}
|
||||
if (xdy && fabs(fmodf(1.0 / xdy, 1)) < EPSILON) {
|
||||
xdy -= (xdy / fabs(xdy)) * EPSILON;
|
||||
}
|
||||
if (ydx && fabs(fmodf(1.0 / ydx, 1)) < EPSILON) {
|
||||
ydx -= (ydx / fabs(ydx)) * EPSILON;
|
||||
}
|
||||
if (ydy && fabs(fmodf(1.0 / ydy, 1)) < EPSILON) {
|
||||
ydy -= (ydy / fabs(ydy)) * EPSILON;
|
||||
}
|
||||
}
|
||||
|
||||
xdx *= 65536;
|
||||
ydx *= 65536;
|
||||
xdy *= 65536;
|
||||
ydy *= 65536;
|
||||
|
||||
|
||||
// Scaled subtracted srcw and srch.
|
||||
float fsw = (srcw - 1) * 65536 - 1;
|
||||
float fsh = (srch - 1) * 65536 - 1;
|
||||
|
||||
for (y = 0; y < dsth; y++, lsx += xdy, lsy += ydy) {
|
||||
|
||||
sx = lsx;
|
||||
sy = lsy;
|
||||
|
||||
// Loop through every line.
|
||||
for (y = 0; y < dsth; y++) {
|
||||
|
||||
// unsigned char *d = dstpixels + dstpitch * y;
|
||||
// unsigned char *dend = d + 4 * dstw;
|
||||
// The source coordinates of the leftmost pixel in the line.
|
||||
double leftsx = corner_x + y * xdy;
|
||||
double leftsy = corner_y + y * ydy;
|
||||
|
||||
float minx = 0;
|
||||
float maxx = dstw - 1;
|
||||
// Min and max x-extent to draw on the current line.
|
||||
double minx = 0;
|
||||
double maxx = dstw - 1;
|
||||
|
||||
if (xdx != 0) {
|
||||
float d1 = -lsx / xdx;
|
||||
float d2 = (fsw - lsx) / xdx;
|
||||
// Figure out the x-extent based on xdx.
|
||||
if (xdx) {
|
||||
double x1 = (0.0 - leftsx) / xdx;
|
||||
double x2 = (maxsx - leftsx) / xdx;
|
||||
|
||||
minx = fmaxf(minx, fminf(d1, d2));
|
||||
maxx = fminf(maxx, fmaxf(d1, d2));
|
||||
if (x1 < x2) {
|
||||
minx = fmax(x1, minx);
|
||||
maxx = fmin(x2, maxx);
|
||||
} else {
|
||||
minx = fmax(x2, minx);
|
||||
maxx = fmin(x1, maxx);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (leftsx < 0 || leftsx > maxsx) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out the x-extent based on ydx.
|
||||
if (ydx) {
|
||||
double x1 = (0.0 - leftsy) / ydx;
|
||||
double x2 = (maxsy - leftsy) / ydx;
|
||||
|
||||
if (x1 < x2) {
|
||||
minx = fmax(x1, minx);
|
||||
maxx = fmin(x2, maxx);
|
||||
} else {
|
||||
minx = fmax(x2, minx);
|
||||
maxx = fmin(x1, maxx);
|
||||
}
|
||||
|
||||
} else if ( lsx < 0 || lsx >= fsw) {
|
||||
continue;
|
||||
} else {
|
||||
if (leftsy < 0 || leftsy > maxsy) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (ydx != 0) {
|
||||
float d1 = -lsy / ydx;
|
||||
float d2 = (fsh - lsy) / ydx;
|
||||
|
||||
minx = fmaxf(minx, fminf(d1, d2));
|
||||
maxx = fminf(maxx, fmaxf(d1, d2));
|
||||
} else if ( lsy < 0 || lsy >= fsh) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (minx > maxx) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
minx = ceil(minx);
|
||||
maxx = floor(maxx);
|
||||
|
||||
if (minx >= maxx) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The start and end of line pointers.
|
||||
unsigned char *d = dstpixels + dstpitch * y;
|
||||
unsigned char *dend = d + 4 * (int) maxx;
|
||||
|
||||
// Advance start of line by 4.
|
||||
d += 4 * (int) minx;
|
||||
|
||||
sx = lsx + minx * xdx;
|
||||
sy = lsy + minx * ydx;
|
||||
|
||||
int sxi = (int) sx;
|
||||
int syi = (int) sy;
|
||||
int xdxi = (int) xdx;
|
||||
int ydxi = (int) ydx;
|
||||
// Starting coordinates and deltas.
|
||||
sxi = (int) ((leftsx + minx * xdx) * 65536);
|
||||
syi = (int) ((leftsy + minx * ydx) * 65536);
|
||||
dsxi = (int) (xdx * 65536);
|
||||
dsyi = (int) (ydx * 65536);
|
||||
|
||||
while (d <= dend) {
|
||||
int px, py;
|
||||
px = sxi >> 16;
|
||||
py = syi >> 16;
|
||||
|
||||
|
||||
int px = sxi >> 16;
|
||||
int py = syi >> 16;
|
||||
|
||||
unsigned char *sp = srcpixels + py * srcpitch + px * 4;
|
||||
|
||||
int yfrac = (syi >> 8) & 0xff; // ((short) sy) & 0xff;
|
||||
int xfrac = (sxi >> 8) & 0xff; // ((short) sx) & 0xff;
|
||||
unsigned int yfrac = (syi >> 8) & 0xff; // ((short) sy) & 0xff;
|
||||
unsigned int xfrac = (sxi >> 8) & 0xff; // ((short) sx) & 0xff;
|
||||
|
||||
unsigned int pal = *(unsigned int *) sp;
|
||||
unsigned int pbl = *(unsigned int *) (sp + 4);
|
||||
@@ -1104,46 +1162,53 @@ void transform32_std(PyObject *pysrc, PyObject *pydst,
|
||||
dh = I(dh, rh, alpha);
|
||||
|
||||
* (unsigned int *) d = (dh << 8) | dl;
|
||||
|
||||
|
||||
d += 4;
|
||||
sxi += xdxi;
|
||||
syi += ydxi;
|
||||
sxi += dsxi;
|
||||
syi += dsyi;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Py_END_ALLOW_THREADS
|
||||
Py_END_ALLOW_THREADS;
|
||||
|
||||
|
||||
// This is bogus, and only serves to ensure that the FPU
|
||||
// computes these variables at the right times.
|
||||
return sxi + syi + dsxi + dsyi;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef GCC_MMX
|
||||
|
||||
/****************************************************************************/
|
||||
/* A similar concept to rotozoom, but implemented differently, so we
|
||||
can limit the target area. */
|
||||
int transform32_mmx(PyObject *pysrc, PyObject *pydst,
|
||||
float corner_x, float corner_y,
|
||||
float xdx, float ydx,
|
||||
float xdy, float ydy,
|
||||
int ashift,
|
||||
float a) {
|
||||
float corner_x, float corner_y,
|
||||
float xdx, float ydx,
|
||||
float xdy, float ydy,
|
||||
int ashift,
|
||||
float a,
|
||||
int precise
|
||||
) {
|
||||
|
||||
SDL_Surface *src;
|
||||
SDL_Surface *dst;
|
||||
|
||||
int y;
|
||||
int srcpitch, dstpitch;
|
||||
|
||||
int srcw, srch;
|
||||
int dstw, dsth;
|
||||
|
||||
// The x and y source pixel coordinates, times 65536. And their
|
||||
// delta-per-dest-x-pixel.
|
||||
int sxi = 0, syi = 0, dsxi = 0, dsyi = 0;
|
||||
|
||||
unsigned char *srcpixels;
|
||||
unsigned char *dstpixels;
|
||||
|
||||
float lsx, lsy; // The position of the current line in the source.
|
||||
float sx, sy; // The position of the current pixel in the source.
|
||||
unsigned int px, py;
|
||||
unsigned int sxi, syi;
|
||||
unsigned int xdxi, ydxi;
|
||||
|
||||
src = PySurface_AsSurface(pysrc);
|
||||
dst = PySurface_AsSurface(pydst);
|
||||
|
||||
@@ -1163,63 +1228,101 @@ int transform32_mmx(PyObject *pysrc, PyObject *pydst,
|
||||
|
||||
// Compute the coloring multiplier.
|
||||
unsigned int amul = (unsigned int) (a * 256);
|
||||
|
||||
// Compute the maximum x and y coordinates.
|
||||
double maxsx = srcw - 1;
|
||||
double maxsy = srch - 1;
|
||||
|
||||
lsx = corner_x * 65536;
|
||||
lsy = corner_y * 65536;
|
||||
|
||||
xdx *= 65536;
|
||||
ydx *= 65536;
|
||||
xdy *= 65536;
|
||||
ydy *= 65536;
|
||||
|
||||
// Scaled subtracted srcw and srch.
|
||||
float fsw = (srcw - 1) * 65536 - 1;
|
||||
float fsh = (srch - 1) * 65536 - 1;
|
||||
|
||||
for (y = 0; y < dsth; y++, lsx += xdy, lsy += ydy) {
|
||||
|
||||
float minx = 0;
|
||||
float maxx = dstw - 1;
|
||||
|
||||
if (xdx != 0) {
|
||||
float d1 = -lsx / xdx;
|
||||
float d2 = (fsw - lsx) / xdx;
|
||||
|
||||
minx = fmaxf(minx, fminf(d1, d2));
|
||||
maxx = fminf(maxx, fmaxf(d1, d2));
|
||||
|
||||
} else if ( lsx < 0 || lsx >= fsw) {
|
||||
continue;
|
||||
// Deal with pre-6.10.1 versions of Ren'Py, which didn't give us
|
||||
// that 1px border that allows us to be precise.
|
||||
if (! precise) {
|
||||
maxsx -= EPSILON;
|
||||
maxsy -= EPSILON;
|
||||
|
||||
// If a delta is too even, subtract epsilon (towards 0) from it.
|
||||
if (xdx && fabs(fmodf(1.0 / xdx, 1)) < EPSILON) {
|
||||
xdx -= (xdx / fabs(xdx)) * EPSILON;
|
||||
}
|
||||
|
||||
if (ydx != 0) {
|
||||
float d1 = -lsy / ydx;
|
||||
float d2 = (fsh - lsy) / ydx;
|
||||
|
||||
minx = fmaxf(minx, fminf(d1, d2));
|
||||
maxx = fminf(maxx, fmaxf(d1, d2));
|
||||
} else if ( lsy < 0 || lsy >= fsh) {
|
||||
continue;
|
||||
if (xdy && fabs(fmodf(1.0 / xdy, 1)) < EPSILON) {
|
||||
xdy -= (xdy / fabs(xdy)) * EPSILON;
|
||||
}
|
||||
|
||||
if (minx > maxx) {
|
||||
continue;
|
||||
if (ydx && fabs(fmodf(1.0 / ydx, 1)) < EPSILON) {
|
||||
ydx -= (ydx / fabs(ydx)) * EPSILON;
|
||||
}
|
||||
if (ydy && fabs(fmodf(1.0 / ydy, 1)) < EPSILON) {
|
||||
ydy -= (ydy / fabs(ydy)) * EPSILON;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Loop through every line.
|
||||
for (y = 0; y < dsth; y++) {
|
||||
|
||||
// The source coordinates of the leftmost pixel in the line.
|
||||
double leftsx = corner_x + y * xdy;
|
||||
double leftsy = corner_y + y * ydy;
|
||||
|
||||
// Min and max x-extent to draw on the current line.
|
||||
double minx = 0;
|
||||
double maxx = dstw - 1;
|
||||
|
||||
// Figure out the x-extent based on xdx.
|
||||
if (xdx) {
|
||||
double x1 = (0.0 - leftsx) / xdx;
|
||||
double x2 = (maxsx - leftsx) / xdx;
|
||||
|
||||
if (x1 < x2) {
|
||||
minx = fmax(x1, minx);
|
||||
maxx = fmin(x2, maxx);
|
||||
} else {
|
||||
minx = fmax(x2, minx);
|
||||
maxx = fmin(x1, maxx);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (leftsx < 0 || leftsx > maxsx) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out the x-extent based on ydx.
|
||||
if (ydx) {
|
||||
double x1 = (0.0 - leftsy) / ydx;
|
||||
double x2 = (maxsy - leftsy) / ydx;
|
||||
|
||||
if (x1 < x2) {
|
||||
minx = fmax(x1, minx);
|
||||
maxx = fmin(x2, maxx);
|
||||
} else {
|
||||
minx = fmax(x2, minx);
|
||||
maxx = fmin(x1, maxx);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (leftsy < 0 || leftsy > maxsy) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
minx = ceil(minx);
|
||||
maxx = floor(maxx);
|
||||
|
||||
if (minx >= maxx) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The start and end of line pointers.
|
||||
unsigned char *d = dstpixels + dstpitch * y;
|
||||
unsigned char *dend = d + 4 * (int) maxx;
|
||||
|
||||
// Advance start of line by 4.
|
||||
d += 4 * (int) minx;
|
||||
|
||||
sx = (lsx + minx * xdx);
|
||||
sy = (lsy + minx * ydx);
|
||||
|
||||
sxi = (unsigned int) sx;
|
||||
syi = (unsigned int) sy;
|
||||
xdxi = (int) xdx;
|
||||
ydxi = (int) ydx;
|
||||
// Starting coordinates and deltas.
|
||||
sxi = (int) ((leftsx + minx * xdx) * 65536);
|
||||
syi = (int) ((leftsy + minx * ydx) * 65536);
|
||||
dsxi = (int) (xdx * 65536);
|
||||
dsyi = (int) (ydx * 65536);
|
||||
|
||||
// No floating point allowed between here and the end of the
|
||||
// while loop.
|
||||
@@ -1235,8 +1338,8 @@ int transform32_mmx(PyObject *pysrc, PyObject *pydst,
|
||||
|
||||
while (d <= dend) {
|
||||
|
||||
px = sxi >> 16;
|
||||
py = syi >> 16;
|
||||
int px = sxi >> 16;
|
||||
int py = syi >> 16;
|
||||
|
||||
unsigned char *sp = srcpixels + py * srcpitch + px * 4;
|
||||
|
||||
@@ -1310,19 +1413,19 @@ int transform32_mmx(PyObject *pysrc, PyObject *pydst,
|
||||
movd_r2m(mm1, *(unsigned int *)d);
|
||||
|
||||
d += 4;
|
||||
sxi += xdxi;
|
||||
syi += ydxi;
|
||||
sxi += dsxi;
|
||||
syi += dsyi;
|
||||
}
|
||||
|
||||
emms();
|
||||
}
|
||||
|
||||
Py_END_ALLOW_THREADS
|
||||
Py_END_ALLOW_THREADS;
|
||||
|
||||
|
||||
// This is bogus, and only serves to ensure that the FPU
|
||||
// computes these variables at the right times.
|
||||
return sxi + syi + xdxi + ydxi;
|
||||
// This is bogus, and only serves to ensure that the FPU
|
||||
// computes these variables at the right times.
|
||||
return sxi + syi + dsxi + dsyi;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1332,7 +1435,9 @@ void transform32_core(PyObject *pysrc, PyObject *pydst,
|
||||
float xdx, float ydx,
|
||||
float xdy, float ydy,
|
||||
int ashift,
|
||||
float a) {
|
||||
float a,
|
||||
int precise
|
||||
) {
|
||||
|
||||
#ifdef GCC_MMX
|
||||
static int checked_mmx = 0;
|
||||
@@ -1345,14 +1450,14 @@ void transform32_core(PyObject *pysrc, PyObject *pydst,
|
||||
|
||||
if (has_mmx) {
|
||||
transform32_mmx(pysrc, pydst, corner_x, corner_y,
|
||||
xdx, ydx, xdy, ydy, ashift, a);
|
||||
xdx, ydx, xdy, ydy, ashift, a, precise);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
transform32_std(pysrc, pydst, corner_x, corner_y,
|
||||
xdx, ydx, xdy, ydy, ashift, a);
|
||||
xdx, ydx, xdy, ydy, ashift, a, precise);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -75,7 +75,8 @@ void alphamunge_core(PyObject *pysrc,
|
||||
void scale32_core(PyObject *pysrc,
|
||||
PyObject *pydst,
|
||||
float, float, float, float,
|
||||
float, float, float, float);
|
||||
float, float, float, float,
|
||||
int);
|
||||
|
||||
void scale24_core(PyObject *pysrc,
|
||||
PyObject *pydst,
|
||||
@@ -87,7 +88,7 @@ void transform32_core(PyObject *pysrc,
|
||||
float, float,
|
||||
float, float,
|
||||
float, float,
|
||||
int, float);
|
||||
int, float, int);
|
||||
|
||||
void blend32_core(PyObject *pysrca,
|
||||
PyObject *pysrcb,
|
||||
|
||||
+3
-2
@@ -601,12 +601,13 @@ static void font_dealloc(PyFontObject* self)
|
||||
|
||||
static int font_init(PyFontObject *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
int index = 0;
|
||||
int fontsize;
|
||||
RENPY_TTF_Font* font = NULL;
|
||||
PyObject* fileobj;
|
||||
|
||||
self->font = NULL;
|
||||
if(!PyArg_ParseTuple(args, "Oi|iff", &fileobj, &fontsize))
|
||||
if(!PyArg_ParseTuple(args, "Oi|i", &fileobj, &fontsize, &index))
|
||||
return -1;
|
||||
|
||||
if(!font_initialized)
|
||||
@@ -674,7 +675,7 @@ static int font_init(PyFontObject *self, PyObject *args, PyObject *kwds)
|
||||
return -1;
|
||||
}
|
||||
// Py_BEGIN_ALLOW_THREADS
|
||||
font = RENPY_TTF_OpenFontIndexRW(rw, 1, fontsize, 0);
|
||||
font = RENPY_TTF_OpenFontIndexRW(rw, 1, fontsize, index);
|
||||
// Py_END_ALLOW_THREADS
|
||||
#else
|
||||
Py_DECREF(fileobj);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#include <Python.h>
|
||||
#include <fribidi/fribidi.h>
|
||||
|
||||
/* This is easier than trying to figure out the header that alloca is */
|
||||
/* defined in. */
|
||||
void *alloca(size_t size);
|
||||
|
||||
PyObject *renpybidi_log2vis(PyObject *s, int *direction) {
|
||||
char *src;
|
||||
int size;
|
||||
FriBidiChar *srcuni;
|
||||
int unisize;
|
||||
FriBidiChar *dstuni;
|
||||
char *dst;
|
||||
|
||||
src = PyString_AsString(s);
|
||||
|
||||
if (src == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size = PyString_Size(s);
|
||||
|
||||
srcuni = (FriBidiChar *) alloca(size * 4);
|
||||
dstuni = (FriBidiChar *) alloca(size * 4);
|
||||
dst = (char *) alloca(size * 4);
|
||||
|
||||
unisize = fribidi_charset_to_unicode(FRIBIDI_CHAR_SET_UTF8, src, size, srcuni);
|
||||
|
||||
fribidi_log2vis(
|
||||
srcuni,
|
||||
unisize,
|
||||
direction,
|
||||
dstuni,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
fribidi_unicode_to_charset(FRIBIDI_CHAR_SET_UTF8, dstuni, unisize, dst);
|
||||
|
||||
return PyString_FromString(dst);
|
||||
}
|
||||
+26
-9
@@ -16,7 +16,6 @@ extra_compile_args = [ "-O3", "-funroll-loops" ]
|
||||
# extra_compile_args = [ "-O0", "-ggdb" ]
|
||||
# extra_compile_args = [ "-O0", "-gstabs" ]
|
||||
|
||||
|
||||
# This environment variable should have the full path to the installed
|
||||
# Ren'Py dependencies.
|
||||
install = os.environ.get("RENPY_DEPS_INSTALL", None)
|
||||
@@ -75,7 +74,7 @@ def add_include(prefix, file):
|
||||
if dir not in include_dirs:
|
||||
include_dirs.append(dir)
|
||||
|
||||
def add_library(name):
|
||||
def add_library(name, optional=False):
|
||||
"""
|
||||
This looks for a library named name in the <i> and <i>/lib, for all
|
||||
<i> in install. When found, it adds it to library_dirs.
|
||||
@@ -96,8 +95,11 @@ def add_library(name):
|
||||
|
||||
if dir not in library_dirs:
|
||||
library_dirs.append(dir)
|
||||
return
|
||||
return True
|
||||
|
||||
if optional:
|
||||
return False
|
||||
|
||||
print "Couldn't find library %s." % name
|
||||
print "The paths searched were:"
|
||||
for i in checked:
|
||||
@@ -115,21 +117,24 @@ add_include("", "libavcodec/avcodec.h")
|
||||
add_include("", "libswscale/swscale.h")
|
||||
|
||||
add_library("libSDL")
|
||||
add_library("libz")
|
||||
add_library("libpng")
|
||||
add_library("libavformat")
|
||||
add_library("libavcodec")
|
||||
add_library("libavutil")
|
||||
has_swscale = add_library("libswscale", True)
|
||||
add_library("libfreetype")
|
||||
|
||||
|
||||
add_library("libfribidi")
|
||||
add_library("libz")
|
||||
|
||||
extra_link_args = [ ]
|
||||
|
||||
sdl_libraries = [ 'SDL' ]
|
||||
sound_libraries = [ "avformat", "avcodec", "avutil", "z" ]
|
||||
png_libraries = [ 'png', "z" ]
|
||||
|
||||
sound_libraries = [ "avformat", "avcodec", "avutil", "z" ]
|
||||
if has_swscale:
|
||||
sound_libraries.insert(0, "swscale")
|
||||
|
||||
# The following turn on optional modules.
|
||||
winmixer = None
|
||||
linmixer = None
|
||||
@@ -168,7 +173,7 @@ renpy_font = distutils.core.Extension(
|
||||
library_dirs=library_dirs,
|
||||
extra_compile_args=extra_compile_args,
|
||||
extra_link_args=extra_link_args,
|
||||
libraries=sdl_libraries + [ 'freetype' ],
|
||||
libraries=sdl_libraries + [ 'freetype', 'z' ],
|
||||
)
|
||||
|
||||
extensions.append(renpy_font)
|
||||
@@ -197,9 +202,21 @@ if winmixer:
|
||||
if linmixer:
|
||||
py_modules.append('pysdlsound.linmixer')
|
||||
|
||||
|
||||
renpybidi = distutils.core.Extension(
|
||||
"_renpybidi",
|
||||
["_renpybidi.c", "renpybidicore.c"],
|
||||
include_dirs=include_dirs,
|
||||
library_dirs=library_dirs,
|
||||
libraries=['fribidi'],
|
||||
)
|
||||
|
||||
extensions.append(renpybidi)
|
||||
|
||||
|
||||
distutils.core.setup(
|
||||
name = "renpy_module",
|
||||
version = "6.9.1",
|
||||
version = "6.10.1",
|
||||
ext_modules = extensions,
|
||||
py_modules = py_modules,
|
||||
package_dir = { '' : 'lib' },
|
||||
|
||||
+3453
File diff suppressed because it is too large
Load Diff
+1825
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 86 KiB |
@@ -25,6 +25,7 @@ import os
|
||||
import os.path
|
||||
import sys
|
||||
import platform
|
||||
import warnings
|
||||
|
||||
# Functions to be customized by distributors. ################################
|
||||
|
||||
@@ -81,9 +82,9 @@ def path_to_renpy_base():
|
||||
|
||||
##############################################################################
|
||||
|
||||
# The version of the Mac Launcher and py4renpy that we use.
|
||||
macos_version = (6, 9, 3)
|
||||
linux_version = (6, 9, 3)
|
||||
# The version of the Mac Launcher and py4renpy that we require.
|
||||
macos_version = (6, 10, 1)
|
||||
linux_version = (6, 10, 1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -91,7 +92,7 @@ if __name__ == "__main__":
|
||||
|
||||
# Check for mac compatibility.
|
||||
if "mac_version" in globals():
|
||||
mac_version(macos_version)
|
||||
globals()["mac_version"](macos_version)
|
||||
|
||||
# Check py4renpy compatibility.
|
||||
try:
|
||||
@@ -116,6 +117,9 @@ if __name__ == "__main__":
|
||||
if os.path.exists(renpy_base + "/renpy.zip"):
|
||||
sys.path.append(renpy_base + "/renpy.zip")
|
||||
|
||||
# Ignore warnings that happen.
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
|
||||
|
||||
# Start Ren'Py proper.
|
||||
try:
|
||||
|
||||
+15
-6
@@ -27,7 +27,7 @@
|
||||
# ***** ***** ***** ***** ***** ***** **** ***** ***** ***** *****
|
||||
# Be sure to change script_version in launcher/script_version.rpy, too!
|
||||
# Also check to see if we have to update renpy.py.
|
||||
version = "Ren'Py 6.9.3a"
|
||||
version = "Ren'Py 6.10.1a"
|
||||
script_version = 5003000
|
||||
savegame_suffix = "-LT1.save"
|
||||
|
||||
@@ -42,6 +42,7 @@ def import_all():
|
||||
import renpy.loader
|
||||
|
||||
import renpy.ast
|
||||
import renpy.atl
|
||||
import renpy.curry
|
||||
import renpy.easy
|
||||
import renpy.execution
|
||||
@@ -55,7 +56,8 @@ def import_all():
|
||||
|
||||
import renpy.display
|
||||
import renpy.display.presplash
|
||||
import renpy.display.iliad # Must be before scale.
|
||||
import renpy.display.iliad # Must be before scale and pgrender.
|
||||
import renpy.display.pgrender
|
||||
import renpy.display.scale # Must be before module.
|
||||
import renpy.display.module
|
||||
import renpy.display.render # Most display stuff depends on this.
|
||||
@@ -101,15 +103,22 @@ def import_all():
|
||||
|
||||
# This reloads all modules.
|
||||
def reload_all():
|
||||
|
||||
# Shut down the cache thread.
|
||||
display.im.cache.quit()
|
||||
|
||||
import renpy
|
||||
|
||||
# Shut down the cache thread.
|
||||
renpy.display.im.cache.quit()
|
||||
|
||||
# Cleans out the RenpyImporter.
|
||||
import sys
|
||||
sys.meta_path.pop()
|
||||
|
||||
blacklist = [ "renpy", "renpy.bootstrap", "renpy.display", "renpy.display.iliad", "renpy.display.scale" ]
|
||||
blacklist = [ "renpy",
|
||||
"renpy.bootstrap",
|
||||
"renpy.display",
|
||||
"renpy.display.iliad",
|
||||
"renpy.display.pgrender",
|
||||
"renpy.display.scale" ]
|
||||
|
||||
for i in sys.modules.keys():
|
||||
if i.startswith("renpy") and i not in blacklist:
|
||||
|
||||
+147
-37
@@ -185,7 +185,6 @@ class Node(object):
|
||||
"""
|
||||
|
||||
self.filename, self.linenumber = loc
|
||||
|
||||
self.name = None
|
||||
|
||||
def diff_info(self):
|
||||
@@ -600,9 +599,10 @@ class Image(Node):
|
||||
__slots__ = [
|
||||
'imgname',
|
||||
'code',
|
||||
'atl',
|
||||
]
|
||||
|
||||
def __init__(self, loc, name, expr):
|
||||
def __init__(self, loc, name, expr=None, atl=None):
|
||||
"""
|
||||
@param name: The name of the image being defined.
|
||||
|
||||
@@ -613,35 +613,94 @@ class Image(Node):
|
||||
super(Image, self).__init__(loc)
|
||||
|
||||
self.imgname = name
|
||||
self.code = PyCode(expr, loc=loc, mode='eval')
|
||||
|
||||
if expr:
|
||||
self.code = PyCode(expr, loc=loc, mode='eval')
|
||||
self.atl = None
|
||||
else:
|
||||
self.code = None
|
||||
self.atl = atl
|
||||
|
||||
def diff_info(self):
|
||||
return (Image, tuple(self.imgname))
|
||||
|
||||
def get_pycode(self):
|
||||
return [ self.code ]
|
||||
|
||||
def execute(self):
|
||||
if self.code:
|
||||
return [ self.code ]
|
||||
else:
|
||||
return [ ]
|
||||
|
||||
img = renpy.python.py_eval_bytecode(self.code.bytecode)
|
||||
def execute(self):
|
||||
|
||||
# Note: We should always check that self.code is None before
|
||||
# accessing self.atl, as self.atl may not always exist.
|
||||
|
||||
if self.code is not None:
|
||||
img = renpy.python.py_eval_bytecode(self.code.bytecode)
|
||||
else:
|
||||
img = renpy.display.motion.ATLTransform(self.atl)
|
||||
|
||||
renpy.exports.image(self.imgname, img)
|
||||
|
||||
return self.next
|
||||
|
||||
|
||||
|
||||
class Transform(Node):
|
||||
|
||||
__slots__ = [
|
||||
|
||||
# The name of the transform.
|
||||
'varname',
|
||||
|
||||
# The block of ATL associated with the transform.
|
||||
'atl',
|
||||
|
||||
# The parameters associated with the transform, if any.
|
||||
'parameters',
|
||||
]
|
||||
|
||||
default_parameters = ParameterInfo([ ], [ ], None, None)
|
||||
|
||||
def __init__(self, loc, name, atl=None, parameters=default_parameters):
|
||||
|
||||
super(Transform, self).__init__(loc)
|
||||
|
||||
self.varname = name
|
||||
self.atl = atl
|
||||
self.parameters = parameters
|
||||
|
||||
def diff_info(self):
|
||||
return (Transform, self.varname)
|
||||
|
||||
def execute(self):
|
||||
|
||||
parameters = getattr(self, "parameters", None)
|
||||
|
||||
if parameters is None:
|
||||
parameters = Transform.default_parameters
|
||||
|
||||
trans = renpy.display.motion.ATLTransform(self.atl, parameters=parameters)
|
||||
renpy.exports.definitions[self.varname].append((self.filename, self.linenumber, "transform"))
|
||||
setattr(renpy.store, self.varname, trans)
|
||||
|
||||
return self.next
|
||||
|
||||
|
||||
def predict_imspec(imspec, callback, scene=False):
|
||||
"""
|
||||
Call this to use the given callback to predict the image named
|
||||
in imspec.
|
||||
"""
|
||||
|
||||
if len(imspec) == 3:
|
||||
name, at_list, layer = imspec
|
||||
if len(imspec) == 7:
|
||||
name, expression, tag, at_list, layer, zorder, behind = imspec
|
||||
|
||||
elif len(imspec) == 6:
|
||||
name, expression, tag, at_list, layer, zorder = imspec
|
||||
elif len(imspec) == 7:
|
||||
name, expression, tag, at_list, layer, zorder, behind = imspec
|
||||
|
||||
elif len(imspec) == 3:
|
||||
name, at_list, layer = imspec
|
||||
|
||||
|
||||
if expression:
|
||||
@@ -666,20 +725,23 @@ def predict_imspec(imspec, callback, scene=False):
|
||||
renpy.game.context().predict_info.images.predict_show(tag or name, layer)
|
||||
|
||||
img.predict(callback)
|
||||
|
||||
def show_imspec(imspec):
|
||||
|
||||
if len(imspec) == 3:
|
||||
|
||||
def show_imspec(imspec, atl=None):
|
||||
|
||||
if len(imspec) == 7:
|
||||
name, expression, tag, at_list, layer, zorder, behind = imspec
|
||||
|
||||
elif len(imspec) == 6:
|
||||
name, expression, tag, at_list, layer, zorder = imspec
|
||||
behind = [ ]
|
||||
|
||||
elif len(imspec) == 3:
|
||||
name, at_list, layer = imspec
|
||||
expression = None
|
||||
tag = None
|
||||
zorder = None
|
||||
behind = [ ]
|
||||
elif len(imspec) == 6:
|
||||
name, expression, tag, at_list, layer, zorder = imspec
|
||||
behind = [ ]
|
||||
elif len(imspec) == 7:
|
||||
name, expression, tag, at_list, layer, zorder, behind = imspec
|
||||
|
||||
if zorder is not None:
|
||||
zorder = renpy.python.py_eval(zorder)
|
||||
@@ -692,17 +754,23 @@ def show_imspec(imspec):
|
||||
|
||||
at_list = [ renpy.python.py_eval(i) for i in at_list ]
|
||||
|
||||
|
||||
renpy.config.show(name, at_list=at_list, layer=layer,
|
||||
what=expression, zorder=zorder, tag=tag, behind=behind)
|
||||
renpy.config.show(name,
|
||||
at_list=at_list,
|
||||
layer=layer,
|
||||
what=expression,
|
||||
zorder=zorder,
|
||||
tag=tag,
|
||||
behind=behind,
|
||||
atl=atl)
|
||||
|
||||
class Show(Node):
|
||||
|
||||
__slots__ = [
|
||||
'imspec',
|
||||
'atl',
|
||||
]
|
||||
|
||||
def __init__(self, loc, imspec):
|
||||
def __init__(self, loc, imspec, atl=None):
|
||||
"""
|
||||
@param imspec: A triple consisting of an image name (itself a
|
||||
tuple of strings), a list of at expressions, and a layer.
|
||||
@@ -711,13 +779,14 @@ class Show(Node):
|
||||
super(Show, self).__init__(loc)
|
||||
|
||||
self.imspec = imspec
|
||||
|
||||
self.atl = atl
|
||||
|
||||
def diff_info(self):
|
||||
return (Show, tuple(self.imspec[0]))
|
||||
|
||||
def execute(self):
|
||||
|
||||
show_imspec(self.imspec)
|
||||
show_imspec(self.imspec, atl=getattr(self, "atl", None))
|
||||
|
||||
return self.next
|
||||
|
||||
@@ -731,9 +800,10 @@ class Scene(Node):
|
||||
__slots__ = [
|
||||
'imspec',
|
||||
'layer',
|
||||
'atl',
|
||||
]
|
||||
|
||||
def __init__(self, loc, imgspec, layer):
|
||||
def __init__(self, loc, imgspec, layer, atl=None):
|
||||
"""
|
||||
@param imspec: A triple consisting of an image name (itself a
|
||||
tuple of strings), a list of at expressions, and a layer, or
|
||||
@@ -744,6 +814,7 @@ class Scene(Node):
|
||||
|
||||
self.imspec = imgspec
|
||||
self.layer = layer
|
||||
self.atl = atl
|
||||
|
||||
def diff_info(self):
|
||||
|
||||
@@ -759,20 +830,18 @@ class Scene(Node):
|
||||
renpy.config.scene(self.layer)
|
||||
|
||||
if self.imspec:
|
||||
|
||||
show_imspec(self.imspec)
|
||||
show_imspec(self.imspec, atl=getattr(self, "atl", None))
|
||||
|
||||
return self.next
|
||||
|
||||
def predict(self, callback):
|
||||
|
||||
|
||||
|
||||
if self.imspec:
|
||||
predict_imspec(self.imspec, callback, scene=True)
|
||||
|
||||
return [ self.next ]
|
||||
|
||||
|
||||
class Hide(Node):
|
||||
|
||||
__slots__ = [
|
||||
@@ -829,6 +898,7 @@ class Hide(Node):
|
||||
|
||||
return self.next
|
||||
|
||||
|
||||
class With(Node):
|
||||
|
||||
__slots__ = [
|
||||
@@ -836,7 +906,6 @@ class With(Node):
|
||||
'paired',
|
||||
]
|
||||
|
||||
|
||||
def __setstate__(self, state):
|
||||
self.paired = None
|
||||
setstate(self, state)
|
||||
@@ -879,7 +948,6 @@ class With(Node):
|
||||
|
||||
return [ self.next ]
|
||||
|
||||
|
||||
|
||||
class Call(Node):
|
||||
|
||||
@@ -909,6 +977,9 @@ class Call(Node):
|
||||
if self.expression:
|
||||
label = renpy.python.py_eval(label)
|
||||
|
||||
rv = renpy.game.context().call(label, return_site=self.next.name)
|
||||
renpy.game.context().abnormal = True
|
||||
|
||||
if self.arguments:
|
||||
|
||||
args = [ ]
|
||||
@@ -941,8 +1012,6 @@ class Call(Node):
|
||||
renpy.store._kwargs = kwargs
|
||||
|
||||
|
||||
rv = renpy.game.context().call(label, return_site=self.next.name)
|
||||
renpy.game.context().abnormal = True
|
||||
return rv
|
||||
|
||||
|
||||
@@ -956,7 +1025,8 @@ class Call(Node):
|
||||
rv = Node.scry(self)
|
||||
rv._next = None
|
||||
return rv
|
||||
|
||||
|
||||
|
||||
class Return(Node):
|
||||
|
||||
__slots__ = [ 'expression']
|
||||
@@ -999,6 +1069,7 @@ class Return(Node):
|
||||
rv = Node.scry(self)
|
||||
rv._next = None
|
||||
return rv
|
||||
|
||||
|
||||
class Menu(Node):
|
||||
|
||||
@@ -1008,7 +1079,6 @@ class Menu(Node):
|
||||
'with_',
|
||||
]
|
||||
|
||||
|
||||
def __init__(self, loc, items, set, with_):
|
||||
super(Menu, self).__init__(loc)
|
||||
|
||||
@@ -1086,6 +1156,7 @@ class Menu(Node):
|
||||
|
||||
setattr(Menu, "with", Menu.with_)
|
||||
|
||||
|
||||
# Goto is considered harmful. So we decided to name it "jump"
|
||||
# instead.
|
||||
class Jump(Node):
|
||||
@@ -1134,7 +1205,8 @@ class Jump(Node):
|
||||
rv._next = renpy.game.script.lookup(self.target)
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
|
||||
# GNDN
|
||||
class Pass(Node):
|
||||
|
||||
@@ -1146,6 +1218,7 @@ class Pass(Node):
|
||||
def execute(self):
|
||||
return self.next
|
||||
|
||||
|
||||
class While(Node):
|
||||
|
||||
__slots__ = [
|
||||
@@ -1232,6 +1305,7 @@ class If(Node):
|
||||
rv._next = None
|
||||
return rv
|
||||
|
||||
|
||||
class UserStatement(Node):
|
||||
|
||||
__slots__ = [ 'line', 'parsed' ]
|
||||
@@ -1283,3 +1357,39 @@ class UserStatement(Node):
|
||||
return rv
|
||||
|
||||
|
||||
class Define(Node):
|
||||
|
||||
__slots__ = [
|
||||
'varname',
|
||||
'code',
|
||||
]
|
||||
|
||||
def __init__(self, loc, name, expr):
|
||||
"""
|
||||
@param name: The name of the image being defined.
|
||||
|
||||
@param expr: An expression yielding a Displayable that is
|
||||
assigned to the image.
|
||||
"""
|
||||
|
||||
super(Define, self).__init__(loc)
|
||||
|
||||
self.varname = name
|
||||
self.code = PyCode(expr, loc=loc, mode='eval')
|
||||
|
||||
def diff_info(self):
|
||||
return (Define, tuple(self.varname))
|
||||
|
||||
def get_pycode(self):
|
||||
if self.code:
|
||||
return [ self.code ]
|
||||
else:
|
||||
return [ ]
|
||||
|
||||
def execute(self):
|
||||
|
||||
value = renpy.python.py_eval_bytecode(self.code.bytecode)
|
||||
renpy.exports.definitions[self.varname].append((self.filename, self.linenumber, "define"))
|
||||
setattr(renpy.store, self.varname, value)
|
||||
|
||||
return self.next
|
||||
|
||||
+1469
File diff suppressed because it is too large
Load Diff
@@ -26,10 +26,10 @@
|
||||
|
||||
import renpy
|
||||
|
||||
import time
|
||||
import pygame
|
||||
import os
|
||||
import atexit
|
||||
import time
|
||||
|
||||
# Import the appropriate modules, or set them to None if we cannot.
|
||||
|
||||
@@ -48,15 +48,18 @@ if 'pss' not in disable:
|
||||
|
||||
if 'mix' not in disable:
|
||||
try:
|
||||
import winmixer as mix
|
||||
import winmixer as mix; mix
|
||||
except:
|
||||
try:
|
||||
import linmixer as mix
|
||||
import linmixer as mix; mix
|
||||
except:
|
||||
pass
|
||||
|
||||
# Save the mixer, and restore it at exit.
|
||||
|
||||
old_wave = None
|
||||
old_midi = None
|
||||
|
||||
if mix:
|
||||
|
||||
mixer_enabled = False
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
# The public API for music in games.
|
||||
|
||||
import time
|
||||
import renpy
|
||||
|
||||
# A list of music channels.
|
||||
@@ -34,6 +33,7 @@ from renpy.audio.audio import get_channel, get_serial
|
||||
|
||||
# Part of the public api:
|
||||
from renpy.audio.audio import register_channel, alias_channel
|
||||
register_channel; alias_channel
|
||||
|
||||
def play(filenames, channel="music", loop=None, fadeout=None, synchro_start=False, fadein=0, tight=None, if_changed=False):
|
||||
"""
|
||||
@@ -333,7 +333,7 @@ def channel_defined(channel):
|
||||
"""
|
||||
|
||||
try:
|
||||
c = renpy.audio.audio.get_channel(channel)
|
||||
renpy.audio.audio.get_channel(channel)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
+30
-23
@@ -26,7 +26,7 @@ import sys
|
||||
|
||||
# Extra things used for distribution.
|
||||
def extra_imports():
|
||||
import datetime
|
||||
import datetime; datetime
|
||||
import encodings.ascii
|
||||
import encodings.utf_8
|
||||
import encodings.zlib_codec
|
||||
@@ -35,29 +35,29 @@ def extra_imports():
|
||||
import encodings.raw_unicode_escape
|
||||
import encodings.mbcs
|
||||
import encodings.utf_16_be
|
||||
import encodings.utf_16_le
|
||||
import math
|
||||
import glob
|
||||
import pickle
|
||||
import platform
|
||||
import encodings.utf_16_le; encodings.utf_16_le
|
||||
import math; math
|
||||
import glob; glob
|
||||
import pickle; pickle
|
||||
import platform; platform
|
||||
import pysdlsound
|
||||
import pysdlsound.sound
|
||||
import pysdlsound.winmixer
|
||||
import pysdlsound.linmixer
|
||||
import difflib
|
||||
import shutil
|
||||
import pysdlsound.linmixer; pysdlsound.linmixer
|
||||
import difflib; difflib
|
||||
import shutil; shutil
|
||||
import renpy.tools.archiver
|
||||
import renpy.tools.add_from
|
||||
import tarfile
|
||||
import bz2
|
||||
import webbrowser
|
||||
import renpy.tools.add_from; renpy.tools.add_from
|
||||
import tarfile; tarfile
|
||||
import bz2; bz2
|
||||
import webbrowser; webbrowser
|
||||
import pygame.locals
|
||||
import pygame.color
|
||||
import pygame.colordict
|
||||
import posixpath
|
||||
import pygame.colordict; pygame.colordict
|
||||
import posixpath; posixpath
|
||||
import ctypes
|
||||
import ctypes.wintypes
|
||||
import EasyDialogs
|
||||
import ctypes.wintypes; ctypes.wintypes
|
||||
import EasyDialogs; EasyDialogs
|
||||
|
||||
trace_file = None
|
||||
trace_local = None
|
||||
@@ -100,6 +100,8 @@ def bootstrap(renpy_base):
|
||||
|
||||
global renpy
|
||||
|
||||
os.environ["RENPY_BASE"] = os.path.abspath(renpy_base)
|
||||
|
||||
# If environment.txt exists, load it into the os.environ dictionary.
|
||||
if os.path.exists(renpy_base + "/environment.txt"):
|
||||
evars = { }
|
||||
@@ -264,7 +266,7 @@ def bootstrap(renpy_base):
|
||||
break
|
||||
|
||||
except renpy.game.UtterRestartException:
|
||||
|
||||
|
||||
# Only works after a full restart.
|
||||
report_error = renpy.display.error.ReportError()
|
||||
|
||||
@@ -292,6 +294,8 @@ def bootstrap(renpy_base):
|
||||
if options.leak:
|
||||
memory_profile()
|
||||
|
||||
renpy.display.im.cache.quit()
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
@@ -309,6 +313,8 @@ def report_tb(out, tb):
|
||||
elif 'self' in f.f_locals:
|
||||
obj = f.f_locals['self']
|
||||
|
||||
import renpy
|
||||
|
||||
if isinstance(obj, renpy.execution.Context):
|
||||
obj.report_tb(out)
|
||||
|
||||
@@ -323,12 +329,15 @@ def report_exception(e):
|
||||
type, value, tb = sys.exc_info()
|
||||
|
||||
def safe_utf8(e):
|
||||
m = e.message
|
||||
|
||||
try:
|
||||
m = unicode(e)
|
||||
except:
|
||||
m = str(e)
|
||||
|
||||
if isinstance(m, unicode):
|
||||
return m.encode("utf-8")
|
||||
else:
|
||||
return str(m)
|
||||
return m
|
||||
|
||||
# Outside of the file.
|
||||
traceback.print_tb(tb, None, sys.stdout)
|
||||
@@ -387,8 +396,6 @@ def report_exception(e):
|
||||
|
||||
def memory_profile():
|
||||
|
||||
import renpy
|
||||
|
||||
print "Memory Profile"
|
||||
print
|
||||
print "Showing all objects in memory at program termination."
|
||||
|
||||
+12
-3
@@ -54,6 +54,7 @@ def show_display_say(who, what, who_args={}, what_args={}, window_args={},
|
||||
two_window_vbox_properties={},
|
||||
who_window_properties={},
|
||||
say_vbox_properties={},
|
||||
transform=None,
|
||||
variant=None,
|
||||
**kwargs):
|
||||
"""
|
||||
@@ -141,6 +142,10 @@ def show_display_say(who, what, who_args={}, what_args={}, window_args={},
|
||||
who_args = style_args(who_args)
|
||||
what_args = style_args(what_args)
|
||||
window_args = style_args(window_args)
|
||||
|
||||
# Apply the transform.
|
||||
if transform:
|
||||
renpy.ui.at(transform)
|
||||
|
||||
if two_window:
|
||||
|
||||
@@ -210,7 +215,6 @@ def display_say(show_function,
|
||||
type,
|
||||
checkpoint=True):
|
||||
|
||||
ctc = renpy.easy.displayable_or_none(ctc)
|
||||
|
||||
# If we're in fast skipping mode, don't bother with say
|
||||
# statements at all.
|
||||
@@ -287,7 +291,12 @@ def display_say(show_function,
|
||||
what_ctc = ctc_pause
|
||||
else:
|
||||
what_ctc = ctc
|
||||
|
||||
|
||||
what_ctc = renpy.easy.displayable_or_none(what_ctc)
|
||||
|
||||
if what_ctc is not None:
|
||||
what_ctc = ctc.parameterize(('ctc',), ())
|
||||
|
||||
# This object is called when the slow text is done.
|
||||
slow_done = SlowDone(what_ctc, ctc_position, callback, interact, type, cb_args)
|
||||
|
||||
@@ -311,7 +320,7 @@ def display_say(show_function,
|
||||
|
||||
for c in callback:
|
||||
c("show_done", interact=interact, type=type, **cb_args)
|
||||
|
||||
|
||||
if behavior and afm:
|
||||
behavior.set_afm_length(what_text.get_simple_length() - slow_start)
|
||||
|
||||
|
||||
+14
-1
@@ -194,6 +194,7 @@ keymap = dict(
|
||||
focus_down = [ 'K_DOWN', 'joy_down' ],
|
||||
|
||||
# Button.
|
||||
button_ignore = [ 'mousedown_1' ],
|
||||
button_select = [ 'mouseup_1', 'K_RETURN', 'K_KP_ENTER', 'joy_dismiss' ],
|
||||
|
||||
# Input.
|
||||
@@ -216,6 +217,9 @@ keymap = dict(
|
||||
bar_deactivate = [ 'mouseup_1', 'K_RETURN', 'K_KP_ENTER', 'joy_dismiss' ],
|
||||
bar_decrease = [ 'K_LEFT', 'joy_left' ],
|
||||
bar_increase = [ 'K_RIGHT', 'joy_right' ],
|
||||
|
||||
# Delete a save.
|
||||
save_delete = [ 'K_DELETE' ],
|
||||
)
|
||||
|
||||
# Should we try to support joysticks?
|
||||
@@ -388,9 +392,18 @@ label_callback = None
|
||||
# A function that is called when the window needs to be shown.
|
||||
empty_window = None
|
||||
|
||||
# A list of functions that are called when the window is shown.
|
||||
window_overlay_functions = [ ]
|
||||
|
||||
# Do we support right-to-left languages?
|
||||
rtl = False
|
||||
|
||||
# A callback for file opening.
|
||||
file_open_callback = None
|
||||
|
||||
del renpy
|
||||
|
||||
def init():
|
||||
import renpy
|
||||
global properties
|
||||
global style_properties
|
||||
style_properties = renpy.style.style_properties
|
||||
|
||||
+3
-26
@@ -22,7 +22,6 @@
|
||||
# This file contains support for state-machine controlled animations.
|
||||
|
||||
import renpy
|
||||
import pygame
|
||||
import random
|
||||
|
||||
class State(object):
|
||||
@@ -557,34 +556,12 @@ class Blink(renpy.display.core.Displayable):
|
||||
|
||||
|
||||
rend = renpy.display.render.render(self.image, height, width, st, at)
|
||||
|
||||
if not renpy.display.module.can_linmap:
|
||||
return rend
|
||||
|
||||
w, h = rend.get_size()
|
||||
rv = renpy.display.render.Render(w, h)
|
||||
|
||||
if renpy.game.less_updates:
|
||||
alpha = 1.0
|
||||
|
||||
oldsurf = rend.pygame_surface()
|
||||
|
||||
if not (oldsurf.get_masks()[3]):
|
||||
oldsurf = oldsurf.convert_alpha(renpy.game.interface.display.window)
|
||||
|
||||
newsurf = pygame.Surface(oldsurf.get_size(), oldsurf.get_flags(), oldsurf)
|
||||
|
||||
# amap = renpy.display.im.ramp(0, int(alpha * 255.0))
|
||||
# identity = renpy.display.im.identity
|
||||
|
||||
renpy.display.module.linmap(oldsurf, newsurf,
|
||||
256, 256, 256, int(alpha * 256.0))
|
||||
|
||||
renpy.display.render.mutated_surface(newsurf)
|
||||
|
||||
rv.blit(newsurf, (0, 0))
|
||||
rv.depends_on(rend)
|
||||
|
||||
rv.blit(rend, (0, 0))
|
||||
rv.alpha = alpha
|
||||
|
||||
if not renpy.game.less_updates:
|
||||
renpy.display.render.redraw(self, delay)
|
||||
|
||||
|
||||
+137
-23
@@ -26,7 +26,6 @@ import renpy
|
||||
from renpy.display.render import render
|
||||
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
|
||||
def compile_event(key, keydown):
|
||||
"""
|
||||
@@ -330,9 +329,11 @@ class SayBehavior(renpy.display.layout.Null):
|
||||
|
||||
class Button(renpy.display.layout.Window):
|
||||
|
||||
keymap = { }
|
||||
|
||||
def __init__(self, child, style='button', clicked=None,
|
||||
hovered=None, unhovered=None, role='',
|
||||
time_policy=None,
|
||||
time_policy=None, keymap={},
|
||||
**properties):
|
||||
|
||||
super(Button, self).__init__(child, style=style, **properties)
|
||||
@@ -343,7 +344,8 @@ class Button(renpy.display.layout.Window):
|
||||
self.unhovered = unhovered
|
||||
self.focusable = clicked is not None
|
||||
self.role = role
|
||||
|
||||
self.keymap = keymap
|
||||
|
||||
self.time_policy_data = None
|
||||
|
||||
|
||||
@@ -393,31 +395,59 @@ class Button(renpy.display.layout.Window):
|
||||
if self.activated:
|
||||
return None
|
||||
|
||||
rv = None
|
||||
|
||||
if self.hovered and not default:
|
||||
return self.hovered()
|
||||
rv = self.hovered()
|
||||
|
||||
self.set_transform_event(self.role + "hover")
|
||||
self.child.set_transform_event(self.role + "hover")
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
def unfocus(self):
|
||||
super(Button, self).unfocus()
|
||||
|
||||
if self.activated:
|
||||
return None
|
||||
|
||||
|
||||
if self.unhovered:
|
||||
self.unhovered()
|
||||
|
||||
self.set_transform_event(self.role + "idle")
|
||||
self.child.set_transform_event(self.role + "idle")
|
||||
|
||||
|
||||
def per_interact(self):
|
||||
if not self.clicked:
|
||||
self.set_style_prefix(self.role + "insensitive_")
|
||||
self.set_style_prefix(self.role + "insensitive_", True)
|
||||
|
||||
super(Button, self).per_interact()
|
||||
|
||||
def event(self, ev, x, y, st):
|
||||
|
||||
# If we have a child, try passing the event to it.
|
||||
rv = super(Button, self).event(ev, x, y, st)
|
||||
if rv is not None:
|
||||
return rv
|
||||
|
||||
# If not focused, ignore all events.
|
||||
if not self.is_focused():
|
||||
return None
|
||||
|
||||
|
||||
# Check the keymap.
|
||||
for name, action in self.keymap.iteritems():
|
||||
if map_event(ev, name):
|
||||
rv = action()
|
||||
|
||||
if rv is not None:
|
||||
return rv
|
||||
|
||||
# Ignore as appropriate:
|
||||
if map_event(ev, "button_ignore") and self.clicked:
|
||||
raise renpy.display.core.IgnoreEvent()
|
||||
|
||||
# If clicked,
|
||||
if map_event(ev, "button_select") and self.clicked:
|
||||
|
||||
@@ -435,15 +465,20 @@ class Button(renpy.display.layout.Window):
|
||||
self.activated = False
|
||||
|
||||
if self.is_focused():
|
||||
self.set_style_prefix(self.role + "hover_")
|
||||
self.set_style_prefix(self.role + "hover_", True)
|
||||
else:
|
||||
self.set_style_prefix(self.role + "idle_")
|
||||
self.set_style_prefix(self.role + "idle_", True)
|
||||
|
||||
raise renpy.display.core.IgnoreEvent()
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def set_style_prefix(self, prefix, root):
|
||||
if root:
|
||||
super(Button, self).set_style_prefix(prefix, root)
|
||||
|
||||
|
||||
# Reimplementation of the TextButton widget as a Button and a Text
|
||||
# widget.
|
||||
def TextButton(text, style='button', text_style='button_text',
|
||||
@@ -452,39 +487,108 @@ def TextButton(text, style='button', text_style='button_text',
|
||||
text = renpy.display.text.Text(text, style=text_style)
|
||||
return Button(text, style=style, clicked=clicked, **properties)
|
||||
|
||||
|
||||
# This is used for an input that takes its focus from a button.
|
||||
class HoveredProxy(object):
|
||||
def __init__(self, a, b):
|
||||
self.a = a
|
||||
self.b = b
|
||||
|
||||
def __call__(self):
|
||||
self.a()
|
||||
if self.b:
|
||||
return self.b()
|
||||
|
||||
|
||||
class Input(renpy.display.text.Text):
|
||||
"""
|
||||
This is a Displayable that takes text as input.
|
||||
"""
|
||||
|
||||
changed = None
|
||||
prefix = ""
|
||||
suffix = ""
|
||||
|
||||
def __init__(self, default, length=None,
|
||||
style='input_text',
|
||||
allow=None,
|
||||
exclude=None,
|
||||
prefix="",
|
||||
suffix="",
|
||||
changed=None,
|
||||
button=None,
|
||||
**properties):
|
||||
|
||||
super(Input, self).__init__(default.replace("{", "{{") + "_", style=style, **properties)
|
||||
super(Input, self).__init__("", style=style, **properties)
|
||||
|
||||
self.content = unicode(default)
|
||||
self.length = length
|
||||
|
||||
self.allow = allow
|
||||
self.exclude = exclude
|
||||
self.prefix = prefix
|
||||
self.suffix = suffix
|
||||
|
||||
self.changed = changed
|
||||
|
||||
self.editable = True
|
||||
|
||||
caretprops = { 'color' : None}
|
||||
for i in properties:
|
||||
if i.endswith("color"):
|
||||
caretprops[i] = properties[i]
|
||||
|
||||
self.caret = renpy.display.image.Solid(xmaximum=1, style=style, **caretprops)
|
||||
|
||||
if button:
|
||||
self.editable = False
|
||||
button.hovered = HoveredProxy(self.enable, button.hovered)
|
||||
button.unhovered = HoveredProxy(self.disable, button.unhovered)
|
||||
|
||||
self.update_text(self.content, self.editable)
|
||||
|
||||
def update_text(self, content, editable):
|
||||
|
||||
if content != self.content or editable != self.editable:
|
||||
renpy.display.render.redraw(self, 0)
|
||||
|
||||
if content != self.content:
|
||||
self.content = content
|
||||
|
||||
if self.changed:
|
||||
self.change(content)
|
||||
|
||||
self.editable = editable
|
||||
|
||||
if editable:
|
||||
self.set_text([self.prefix, content.replace("{", "{{"), self.suffix, self.caret])
|
||||
else:
|
||||
self.set_text([self.prefix, content.replace("{", "{{"), self.suffix ])
|
||||
|
||||
def enable(self):
|
||||
self.update_text(self.content, True)
|
||||
|
||||
def disable(self):
|
||||
self.update_text(self.content, False)
|
||||
|
||||
def event(self, ev, x, y, st):
|
||||
|
||||
if not self.editable:
|
||||
return None
|
||||
|
||||
if map_event(ev, "input_backspace"):
|
||||
if self.content:
|
||||
self.content = self.content[:-1]
|
||||
|
||||
self.set_text(self.content.replace("{", "{{") + "_")
|
||||
if self.content:
|
||||
content = self.content[:-1]
|
||||
self.update_text(content, self.editable)
|
||||
|
||||
renpy.display.render.redraw(self, 0)
|
||||
|
||||
elif map_event(ev, "input_enter"):
|
||||
return self.content
|
||||
if not self.changed:
|
||||
return self.content
|
||||
|
||||
elif ev.type == KEYDOWN and ev.unicode:
|
||||
elif ev.type == pygame.KEYDOWN and ev.unicode:
|
||||
if ord(ev.unicode[0]) < 32:
|
||||
return None
|
||||
|
||||
@@ -497,10 +601,9 @@ class Input(renpy.display.text.Text):
|
||||
if self.exclude and ev.unicode in self.exclude:
|
||||
raise renpy.display.core.IgnoreEvent()
|
||||
|
||||
self.content += ev.unicode
|
||||
content = self.content + ev.unicode
|
||||
|
||||
self.set_text(self.content.replace("{", "{{") + "_")
|
||||
renpy.display.render.redraw(self, 0)
|
||||
self.update_text(content, self.editable)
|
||||
|
||||
raise renpy.display.core.IgnoreEvent()
|
||||
|
||||
@@ -595,7 +698,7 @@ class Bar(renpy.display.core.Displayable):
|
||||
|
||||
__version__ = 1
|
||||
|
||||
def after_upgrade(version):
|
||||
def after_upgrade(self, version):
|
||||
|
||||
if version < 1:
|
||||
self.adjustment = Adjustment(self.range, self.value, changed=self.changed)
|
||||
@@ -652,7 +755,7 @@ class Bar(renpy.display.core.Displayable):
|
||||
self.hidden = True
|
||||
return renpy.display.render.Render(width, height)
|
||||
elif self.style.unscrollable == "insensitive":
|
||||
self.set_style_prefix("insensitive_")
|
||||
self.set_style_prefix("insensitive_", True)
|
||||
|
||||
self.hidden = False
|
||||
|
||||
@@ -745,8 +848,18 @@ class Bar(renpy.display.core.Displayable):
|
||||
rv.add_focus(self, None, 0, 0, width, height)
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
def focus(self, default=False):
|
||||
super(Bar, self).focus(default)
|
||||
self.set_transform_event("hover")
|
||||
|
||||
|
||||
def unfocus(self):
|
||||
super(Bar, self).unfocus()
|
||||
self.set_transform_event("idle")
|
||||
|
||||
|
||||
|
||||
def event(self, ev, x, y, st):
|
||||
|
||||
if not self.focusable:
|
||||
@@ -782,7 +895,7 @@ class Bar(renpy.display.core.Displayable):
|
||||
if map_event(ev, "bar_increase"):
|
||||
value += self.adjustment.step
|
||||
|
||||
if ev.type in (MOUSEMOTION, MOUSEBUTTONUP, MOUSEBUTTONDOWN):
|
||||
if ev.type in (pygame.MOUSEMOTION, pygame.MOUSEBUTTONUP, pygame.MOUSEBUTTONDOWN):
|
||||
|
||||
if self.style.bar_vertical:
|
||||
|
||||
@@ -822,7 +935,8 @@ class Bar(renpy.display.core.Displayable):
|
||||
return self.adjustment.change(value)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
||||
class Conditional(renpy.display.layout.Container):
|
||||
"""
|
||||
This class renders its child if and only if the condition is
|
||||
|
||||
+293
-93
@@ -25,7 +25,6 @@
|
||||
import renpy
|
||||
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
@@ -44,10 +43,13 @@ cpu_idle = threading.Event()
|
||||
cpu_idle.clear()
|
||||
|
||||
# Need to be +4, so we don't interfere with FFMPEG's events.
|
||||
TIMEEVENT = USEREVENT + 4
|
||||
PERIODIC = USEREVENT + 5
|
||||
JOYEVENT = USEREVENT + 6
|
||||
REDRAW = USEREVENT + 7
|
||||
TIMEEVENT = pygame.USEREVENT + 4
|
||||
PERIODIC = pygame.USEREVENT + 5
|
||||
JOYEVENT = pygame.USEREVENT + 6
|
||||
REDRAW = pygame.USEREVENT + 7
|
||||
|
||||
# All events except for TIMEEVENT and REDRAW
|
||||
ALL_EVENTS = [ i for i in range(0, REDRAW + 1) if i != TIMEEVENT and i != REDRAW ]
|
||||
|
||||
# The number of msec between periodic events.
|
||||
PERIODIC_INTERVAL = 50
|
||||
@@ -91,6 +93,12 @@ class Displayable(renpy.object.Object):
|
||||
focusable = False
|
||||
full_focus_name = None
|
||||
role = ''
|
||||
|
||||
# The event we'll pass on to our parent transform.
|
||||
transform_event = None
|
||||
|
||||
# Can we change our look in response to transform_events?
|
||||
transform_event_responder = False
|
||||
|
||||
def __init__(self, focus=None, default=False, style='default', **properties):
|
||||
self.style = renpy.style.Style(style, properties, heavy=True)
|
||||
@@ -110,13 +118,14 @@ class Displayable(renpy.object.Object):
|
||||
|
||||
i.find_focusable(callback, focus_name)
|
||||
|
||||
|
||||
def focus(self, default=False):
|
||||
"""
|
||||
Called to indicate that this widget has the focus.
|
||||
"""
|
||||
|
||||
if not self.activated:
|
||||
self.set_style_prefix(self.role + "hover_")
|
||||
self.set_style_prefix(self.role + "hover_", True)
|
||||
|
||||
if not default and not self.activated:
|
||||
if self.style.sound:
|
||||
@@ -128,23 +137,27 @@ class Displayable(renpy.object.Object):
|
||||
"""
|
||||
|
||||
if not self.activated:
|
||||
self.set_style_prefix(self.role + "idle_")
|
||||
self.set_style_prefix(self.role + "idle_", True)
|
||||
|
||||
def is_focused(self):
|
||||
|
||||
if renpy.display.focus.grab and renpy.display.focus.grab is not self:
|
||||
return
|
||||
|
||||
return renpy.game.context().scene_lists.focused is self
|
||||
|
||||
def set_style_prefix(self, prefix):
|
||||
def set_style_prefix(self, prefix, root):
|
||||
"""
|
||||
Called to set the style prefix of this widget and its child
|
||||
widgets, if any.
|
||||
|
||||
`root` - True if this is the root of a style tree, False if this
|
||||
hass been passed on to a child.
|
||||
"""
|
||||
|
||||
if prefix == self.style.prefix:
|
||||
return
|
||||
|
||||
# if prefix == self.style_prefix:
|
||||
# return
|
||||
|
||||
self.style.set_prefix(prefix)
|
||||
renpy.display.render.redraw(self, 0)
|
||||
|
||||
@@ -208,7 +221,7 @@ class Displayable(renpy.object.Object):
|
||||
|
||||
while worklist:
|
||||
d = worklist.pop(0)
|
||||
|
||||
|
||||
if d is None:
|
||||
continue
|
||||
|
||||
@@ -324,6 +337,7 @@ class Displayable(renpy.object.Object):
|
||||
xoff += xoffset
|
||||
yoff += yoffset
|
||||
|
||||
|
||||
if subpixel:
|
||||
dest.subpixel_blit(surf, (xoff, yoff), main=main)
|
||||
else:
|
||||
@@ -331,6 +345,43 @@ class Displayable(renpy.object.Object):
|
||||
|
||||
return xoff, yoff
|
||||
|
||||
def set_transform_event(self, event):
|
||||
"""
|
||||
Sets the transform event of this displayable to event.
|
||||
"""
|
||||
|
||||
if event == self.transform_event:
|
||||
return
|
||||
|
||||
self.transform_event = event
|
||||
if self.transform_event_responder:
|
||||
renpy.display.render.redraw(self, 0)
|
||||
|
||||
def hide(self, st, at):
|
||||
"""
|
||||
Returns None if this displayable is ready to be hidden, or
|
||||
a replacement displayable if it doesn't want to be hidden
|
||||
quite yet.
|
||||
"""
|
||||
|
||||
return None
|
||||
|
||||
def show(self):
|
||||
"""
|
||||
Called when the displayable is added to a scene list.
|
||||
"""
|
||||
|
||||
def get_parameterized(self):
|
||||
"""
|
||||
If this is a ImageReference to a parameterized image, return
|
||||
the get_parameterized() of the parameterized image. Otherwise,
|
||||
return this displayable.
|
||||
"""
|
||||
|
||||
return self
|
||||
|
||||
|
||||
|
||||
class ImagePredictInfo(renpy.object.Object):
|
||||
"""
|
||||
This stores information involved in image prediction.
|
||||
@@ -382,7 +433,7 @@ class SceneLists(renpy.object.Object):
|
||||
things to the user.
|
||||
"""
|
||||
|
||||
__version__ = 2
|
||||
__version__ = 3
|
||||
|
||||
def after_setstate(self):
|
||||
for i in renpy.config.layers + renpy.config.top_layers:
|
||||
@@ -401,16 +452,23 @@ class SceneLists(renpy.object.Object):
|
||||
self.at_list[i] = { }
|
||||
self.layer_at_list[i] = (None, [ ])
|
||||
|
||||
if version < 3:
|
||||
self.shown_window = False
|
||||
|
||||
|
||||
def __init__(self, oldsl, ipi):
|
||||
|
||||
# Has a window been shown as part of these scene lists?
|
||||
self.shown_window = False
|
||||
|
||||
|
||||
# A map from layer name -> list of
|
||||
# (key, zorder, show time, animation time, displayable)
|
||||
self.layers = { }
|
||||
self.at_list = { }
|
||||
self.layer_at_list = { }
|
||||
|
||||
self.image_predict_info = ipi
|
||||
|
||||
|
||||
if oldsl:
|
||||
|
||||
for i in renpy.config.layers + renpy.config.top_layers:
|
||||
@@ -447,10 +505,7 @@ class SceneLists(renpy.object.Object):
|
||||
"""
|
||||
|
||||
for i in renpy.config.transient_layers:
|
||||
self.layers[i] = [ ]
|
||||
self.at_list[i].clear()
|
||||
self.image_predict_info.images[i].clear()
|
||||
self.layer_at_list[i] = (None, [ ])
|
||||
self.clear(i, True)
|
||||
|
||||
def transient_is_empty(self):
|
||||
"""
|
||||
@@ -467,7 +522,25 @@ class SceneLists(renpy.object.Object):
|
||||
|
||||
return True
|
||||
|
||||
def add(self, layer, thing, key=None, zorder=0, behind=[ ], at_list=[ ], name=None):
|
||||
def transform_state(self, old_thing, new_thing):
|
||||
"""
|
||||
If the old thing is a transform, then move the state of that transform
|
||||
to the new thing.
|
||||
"""
|
||||
|
||||
old_transform = old_thing.get_parameterized()
|
||||
if not isinstance(old_transform, renpy.display.motion.Transform):
|
||||
return new_thing
|
||||
|
||||
new_transform = new_thing.get_parameterized()
|
||||
if not isinstance(new_transform, renpy.display.motion.Transform):
|
||||
new_thing = new_transform = renpy.display.motion.Transform(child=new_thing)
|
||||
|
||||
new_transform.take_state(old_transform)
|
||||
return new_thing
|
||||
|
||||
|
||||
def add(self, layer, thing, key=None, zorder=0, behind=[ ], at_list=[ ], name=None, atl=None):
|
||||
"""
|
||||
This is called to add something to a layer. Layer is
|
||||
the name of the layer that we need to add the thing to,
|
||||
@@ -503,17 +576,44 @@ class SceneLists(renpy.object.Object):
|
||||
at = None
|
||||
st = None
|
||||
|
||||
if atl:
|
||||
thing = renpy.display.motion.ATLTransform(atl, child=thing)
|
||||
|
||||
if key is not None:
|
||||
|
||||
hidekey = "hide$" + key
|
||||
|
||||
for index, (k, zo, st, at, d) in enumerate(l):
|
||||
if k == key:
|
||||
break
|
||||
|
||||
# If we're adding something with the same name as something
|
||||
# that's hiding, remove the hiding thing.
|
||||
if k == hidekey:
|
||||
l.pop(index)
|
||||
index = None
|
||||
at = None
|
||||
|
||||
else:
|
||||
index = None
|
||||
at = None
|
||||
|
||||
|
||||
st = None
|
||||
|
||||
if index is not None:
|
||||
|
||||
old_thing = l[index][4]
|
||||
|
||||
# If the old thing was a transform, make sure the new thing
|
||||
# is a transform, and then take the transform state.
|
||||
|
||||
thing = self.transform_state(old_thing, thing)
|
||||
|
||||
|
||||
thing.set_transform_event("replace")
|
||||
thing.show()
|
||||
|
||||
if zorder == zo:
|
||||
l[index] = (key, zorder, st, at, thing)
|
||||
return
|
||||
@@ -530,8 +630,10 @@ class SceneLists(renpy.object.Object):
|
||||
else:
|
||||
index = len(l)
|
||||
|
||||
thing.set_transform_event("show")
|
||||
thing.show()
|
||||
l.insert(index, (key, zorder, st, at, thing))
|
||||
|
||||
|
||||
def remove(self, layer, thing):
|
||||
"""
|
||||
Thing is either a key or a displayable. This iterates through the
|
||||
@@ -546,22 +648,67 @@ class SceneLists(renpy.object.Object):
|
||||
raise Exception("Trying to remove something from non-existent layer '%s'." % layer)
|
||||
|
||||
l = self.layers[layer]
|
||||
l = [ (k, zo, st, at, d) for k, zo, st, at, d in l if k != thing if d is not thing ]
|
||||
self.layers[layer] = l
|
||||
newl = [ ]
|
||||
|
||||
now = get_time()
|
||||
|
||||
for i in l:
|
||||
k, zo, st, at, d = i
|
||||
|
||||
if k == thing or d is thing:
|
||||
|
||||
# Should we keep this around while hiding it?
|
||||
if k:
|
||||
st = st or now
|
||||
at = at or now
|
||||
|
||||
d = d.hide(now - st, now - at)
|
||||
|
||||
if d is not None:
|
||||
k = "hide$" + k
|
||||
newl.append((k, zo, st, at, d))
|
||||
|
||||
continue
|
||||
|
||||
newl.append(i)
|
||||
|
||||
self.layers[layer] = newl
|
||||
|
||||
self.at_list[layer].pop(thing, None)
|
||||
self.image_predict_info.images[layer].pop(thing, None)
|
||||
|
||||
|
||||
def clear(self, layer):
|
||||
def clear(self, layer, hide=False):
|
||||
"""
|
||||
Clears the named layer, making it empty.
|
||||
|
||||
If hide is True, then objects are hidden. Otherwise, they are
|
||||
totally wiped out.
|
||||
"""
|
||||
|
||||
if layer not in self.layers is None:
|
||||
raise Exception("Trying to clear non-existent layer '%s'." % layer)
|
||||
now = get_time()
|
||||
|
||||
l = self.layers[layer]
|
||||
newl = [ ]
|
||||
|
||||
self.layers[layer] = [ ]
|
||||
for i in l:
|
||||
k, zo, st, at, d = i
|
||||
|
||||
# Should we keep this around while hiding it?
|
||||
if hide and k:
|
||||
|
||||
st = st or now
|
||||
at = at or now
|
||||
|
||||
d = d.hide(now - st, now - at)
|
||||
|
||||
if d is not None:
|
||||
k = "hide$" + k
|
||||
newl.append((k, zo, st, at, d))
|
||||
|
||||
continue
|
||||
|
||||
self.layers[layer] = newl
|
||||
self.at_list[layer].clear()
|
||||
self.image_predict_info.images[layer].clear()
|
||||
self.layer_at_list[layer] = (None, [ ])
|
||||
@@ -586,7 +733,7 @@ class SceneLists(renpy.object.Object):
|
||||
ll.append((k, zo, st or time, at or time, d))
|
||||
|
||||
l[:] = ll
|
||||
|
||||
|
||||
|
||||
def showing(self, layer, name):
|
||||
"""
|
||||
@@ -608,7 +755,11 @@ class SceneLists(renpy.object.Object):
|
||||
|
||||
if at_list:
|
||||
for a in at_list:
|
||||
rv = a(rv)
|
||||
|
||||
if isinstance(a, renpy.display.motion.Transform):
|
||||
rv = a(child=rv)
|
||||
else:
|
||||
rv = a(rv)
|
||||
|
||||
f = renpy.display.layout.MultiBox(layout='fixed')
|
||||
f.add(rv, time, time)
|
||||
@@ -616,8 +767,36 @@ class SceneLists(renpy.object.Object):
|
||||
|
||||
rv.layer_name = layer
|
||||
return rv
|
||||
|
||||
|
||||
def remove_hidden(self):
|
||||
"""
|
||||
Goes through all of the layers, and removes things that are
|
||||
hidden and are no longer being kept alive by their hide
|
||||
methods.
|
||||
"""
|
||||
|
||||
now = get_time()
|
||||
|
||||
for l in self.layers:
|
||||
newl = [ ]
|
||||
|
||||
for i in self.layers[l]:
|
||||
name, zo, st, at, d = i
|
||||
|
||||
if name and name.startswith("hide$") and st and at:
|
||||
d = d.hide(now - st, now - at)
|
||||
|
||||
if d is None:
|
||||
continue
|
||||
|
||||
i = (name, zo, st, at, d)
|
||||
|
||||
newl.append(i)
|
||||
|
||||
self.layers[l] = newl
|
||||
|
||||
|
||||
|
||||
class Display(object):
|
||||
"""
|
||||
This is responsible for managing the display window.
|
||||
@@ -626,10 +805,6 @@ class Display(object):
|
||||
|
||||
@ivar window: The window that is being presented to the user.
|
||||
|
||||
@ivar sample_surface: A sample surface that is optimized for fast
|
||||
blitting to the window, with alpha. Used to create other surfaces
|
||||
from.
|
||||
|
||||
@ivar fullscreen: Is the window in fullscreen mode?
|
||||
|
||||
@ivar mouse: The mouse image, if we have one, or None if
|
||||
@@ -653,7 +828,6 @@ class Display(object):
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, interface):
|
||||
|
||||
self.interface = interface
|
||||
@@ -700,7 +874,7 @@ class Display(object):
|
||||
# Convert the aspect ratio to be square.
|
||||
iw, ih = im.get_size()
|
||||
imax = max(iw, ih)
|
||||
square_im = renpy.display.scale.PygameSurface((imax, imax), pygame.SRCALPHA, depth=32)
|
||||
square_im = renpy.display.pgrender.surface_unscaled((imax, imax), True)
|
||||
square_im.blit(im, ( (imax-iw)/2, (imax-ih)/2 ))
|
||||
im = square_im
|
||||
|
||||
@@ -715,7 +889,7 @@ class Display(object):
|
||||
# If we're in fullscreen mode, and changing to another mode, go to
|
||||
# windowed mode first.
|
||||
s = pygame.display.get_surface()
|
||||
if s and (s.get_flags() & FULLSCREEN):
|
||||
if s and (s.get_flags() & pygame.FULLSCREEN):
|
||||
fullscreen = False
|
||||
|
||||
self.fullscreen = fullscreen
|
||||
@@ -748,37 +922,31 @@ class Display(object):
|
||||
if w < renpy.config.screen_width or h < renpy.config.screen_height:
|
||||
continue
|
||||
|
||||
fsflag = FULLSCREEN
|
||||
fsflag = pygame.FULLSCREEN
|
||||
width = w
|
||||
height = h
|
||||
self.screen_xoffset = (width - renpy.config.screen_width) / 2
|
||||
self.screen_yoffset = (height - renpy.config.screen_height) / 2
|
||||
|
||||
elif fullscreen:
|
||||
fsflag = FULLSCREEN
|
||||
fsflag = pygame.FULLSCREEN
|
||||
|
||||
# If a window exists of the right size and flags, use it. Otherwise,
|
||||
# make our own window.
|
||||
old_window = pygame.display.get_surface()
|
||||
if ((old_window is not None) and
|
||||
(old_window.get_size() == (width, height)) and
|
||||
(old_window.get_flags() & FULLSCREEN == fsflag)):
|
||||
(old_window.get_flags() & pygame.FULLSCREEN == fsflag)):
|
||||
|
||||
self.window = old_window
|
||||
|
||||
else:
|
||||
self.window = pygame.display.set_mode((width, height), fsflag, 32)
|
||||
|
||||
|
||||
self.window = renpy.display.pgrender.set_mode((width, height), fsflag, 32)
|
||||
|
||||
# Window title.
|
||||
self.window_caption = None
|
||||
self.set_window_caption()
|
||||
|
||||
# Sample surface that all surfaces are created based on.
|
||||
sample = pygame.Surface((10, 10), 0, self.window)
|
||||
self.sample_surface = sample.convert_alpha(self.window)
|
||||
|
||||
pygame.event.set_grab(False)
|
||||
|
||||
# Load the mouse image, if any.
|
||||
@@ -810,6 +978,7 @@ class Display(object):
|
||||
# Setup periodic event.
|
||||
pygame.time.set_timer(PERIODIC, PERIODIC_INTERVAL)
|
||||
|
||||
|
||||
def set_window_caption(self):
|
||||
caption = renpy.config.window_title + renpy.store._window_subtitle
|
||||
if caption == self.window_caption:
|
||||
@@ -818,8 +987,10 @@ class Display(object):
|
||||
self.window_caption = caption
|
||||
pygame.display.set_caption(caption.encode("utf-8"))
|
||||
|
||||
|
||||
def iconify(self):
|
||||
pygame.display.iconify()
|
||||
|
||||
|
||||
def can_redraw(self, first_pass):
|
||||
"""
|
||||
@@ -854,11 +1025,13 @@ class Display(object):
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def mouse_event(self, ev):
|
||||
|
||||
if ev.type == pygame.MOUSEMOTION or pygame.MOUSEBUTTONDOWN or pygame.MOUSEBUTTONUP:
|
||||
self.mouse_event_time = get_time()
|
||||
|
||||
|
||||
|
||||
def show_mouse(self, pos, info):
|
||||
"""
|
||||
Actually shows the mouse.
|
||||
@@ -878,13 +1051,14 @@ class Display(object):
|
||||
by = my - myo
|
||||
|
||||
self.mouse_backing_pos = (bx, by)
|
||||
self.mouse_backing = pygame.Surface((mw, mh), self.window.get_flags(), self.window)
|
||||
self.mouse_backing = renpy.display.pgrender.surface((mw, mh), False)
|
||||
self.mouse_backing.blit(self.window, (0, 0), (bx, by, mw, mh))
|
||||
|
||||
self.window.blit(mouse, (bx, by))
|
||||
|
||||
return bx, by, mw, mh
|
||||
|
||||
|
||||
def hide_mouse(self):
|
||||
"""
|
||||
Actually hides the mouse.
|
||||
@@ -901,6 +1075,7 @@ class Display(object):
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
def draw_mouse(self, show_mouse=True):
|
||||
"""
|
||||
This draws the mouse to the screen, if necessary. It uses the
|
||||
@@ -961,6 +1136,7 @@ class Display(object):
|
||||
|
||||
return updates
|
||||
|
||||
|
||||
def update_mouse(self):
|
||||
"""
|
||||
Draws the mouse, and then updates the screen.
|
||||
@@ -1007,6 +1183,7 @@ class Display(object):
|
||||
|
||||
self.suppressed_blit = suppress_blit
|
||||
self.surftree = surftree
|
||||
|
||||
|
||||
def save_screenshot(self, filename):
|
||||
"""
|
||||
@@ -1019,7 +1196,6 @@ class Display(object):
|
||||
if renpy.config.debug:
|
||||
raise
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def screenshot(self, scale):
|
||||
@@ -1027,9 +1203,9 @@ class Display(object):
|
||||
Returns a string containing the contents of the window, as a PNG.
|
||||
"""
|
||||
|
||||
surf = self.window.convert_alpha()
|
||||
surf = renpy.display.pgrender.copy_surface(self.window, True)
|
||||
surf = renpy.display.scale.smoothscale(surf, scale)
|
||||
surf = surf.convert()
|
||||
surf = renpy.display.pgrender.copy_surface(surf, False)
|
||||
|
||||
sio = cStringIO.StringIO()
|
||||
renpy.display.module.save_png(surf, sio, 0)
|
||||
@@ -1112,6 +1288,7 @@ class Interface(object):
|
||||
self.timeout_time = None
|
||||
self.last_event = None
|
||||
self.current_context = None
|
||||
self.roll_forward = None
|
||||
|
||||
# Should we reset the display?
|
||||
self.display_reset = False
|
||||
@@ -1168,6 +1345,7 @@ class Interface(object):
|
||||
|
||||
self.screenshot = self.display.screenshot(scale)
|
||||
|
||||
|
||||
def get_screenshot(self):
|
||||
"""
|
||||
Gets the current screenshot, as a string. Returns None if there isn't
|
||||
@@ -1179,6 +1357,7 @@ class Interface(object):
|
||||
|
||||
return self.screenshot
|
||||
|
||||
|
||||
def lose_screenshot(self):
|
||||
"""
|
||||
This deallocates the saved screenshot.
|
||||
@@ -1186,17 +1365,19 @@ class Interface(object):
|
||||
|
||||
self.screenshot = None
|
||||
|
||||
|
||||
def show_window(self):
|
||||
|
||||
if not renpy.store._window:
|
||||
return
|
||||
|
||||
if self.shown_window:
|
||||
if renpy.game.context().scene_lists.shown_window:
|
||||
return
|
||||
|
||||
if renpy.config.empty_window:
|
||||
renpy.config.empty_window()
|
||||
|
||||
|
||||
def do_with(self, trans, paired, clear=False):
|
||||
|
||||
if renpy.config.with_callback:
|
||||
@@ -1218,21 +1399,21 @@ class Interface(object):
|
||||
be transitioning from.
|
||||
"""
|
||||
|
||||
# Show the window, if that's necessary.
|
||||
self.show_window()
|
||||
|
||||
|
||||
# Compute the overlay.
|
||||
self.compute_overlay()
|
||||
|
||||
scene_lists = renpy.game.context().scene_lists
|
||||
|
||||
old_old_scene = self.old_scene
|
||||
|
||||
# Compute the scene.
|
||||
self.old_scene = self.compute_scene(scene_lists)
|
||||
|
||||
if renpy.config.overlay_during_with and old_old_scene:
|
||||
for i in renpy.config.overlay_layers:
|
||||
self.old_scene[i] = old_old_scene[i]
|
||||
|
||||
scene_lists = renpy.game.context().scene_lists
|
||||
# Get rid of transient things.
|
||||
scene_lists.replace_transient()
|
||||
self.shown_window = False
|
||||
scene_lists.shown_window = False
|
||||
|
||||
|
||||
def set_transition(self, transition, layer=None, force=False):
|
||||
"""
|
||||
@@ -1256,7 +1437,9 @@ class Interface(object):
|
||||
|
||||
ev = pygame.event.poll()
|
||||
|
||||
if ev.type == NOEVENT:
|
||||
if ev.type == pygame.NOEVENT:
|
||||
# Seems to prevent the CPU from speeding up.
|
||||
time.sleep(0.001)
|
||||
return None
|
||||
|
||||
self.pushed_event = ev
|
||||
@@ -1299,7 +1482,25 @@ class Interface(object):
|
||||
self.last_event = ev
|
||||
return ev
|
||||
|
||||
|
||||
def compute_overlay(self):
|
||||
|
||||
if renpy.store.suppress_overlay:
|
||||
return
|
||||
|
||||
# Figure out what the overlay layer should look like.
|
||||
renpy.ui.layer("overlay")
|
||||
|
||||
for i in renpy.config.overlay_functions:
|
||||
i()
|
||||
|
||||
if renpy.game.context().scene_lists.shown_window:
|
||||
for i in renpy.config.window_overlay_functions:
|
||||
i()
|
||||
|
||||
renpy.ui.close()
|
||||
|
||||
|
||||
def compute_scene(self, scene_lists):
|
||||
"""
|
||||
This converts scene lists into a dictionary mapping layer
|
||||
@@ -1334,6 +1535,7 @@ class Interface(object):
|
||||
else:
|
||||
raise renpy.game.QuitException()
|
||||
|
||||
|
||||
def interact(self, clear=True, suppress_window=False, **kwargs):
|
||||
"""
|
||||
This handles an interaction, restarting it if necessary. All of the
|
||||
@@ -1344,17 +1546,15 @@ class Interface(object):
|
||||
if not suppress_window:
|
||||
self.show_window()
|
||||
|
||||
|
||||
# These things can be done once per interaction.
|
||||
|
||||
import time
|
||||
start = time.time()
|
||||
|
||||
preloads = self.preloads
|
||||
self.preloads = [ ]
|
||||
|
||||
try:
|
||||
renpy.game.after_rollback = False
|
||||
|
||||
|
||||
for i in renpy.config.start_interact_callbacks:
|
||||
i()
|
||||
|
||||
@@ -1378,8 +1578,10 @@ class Interface(object):
|
||||
|
||||
self.restart_interaction = True
|
||||
|
||||
self.shown_window = False
|
||||
renpy.game.context().scene_lists.shown_window = False
|
||||
|
||||
|
||||
|
||||
def interact_core(self,
|
||||
show_mouse=True,
|
||||
trans_pause=False,
|
||||
@@ -1404,7 +1606,8 @@ class Interface(object):
|
||||
@param suppress_underlay: This suppresses the display of the underlay.
|
||||
"""
|
||||
|
||||
suppress_overlay = suppress_overlay or renpy.store.suppress_overlay
|
||||
self.roll_forward = roll_forward
|
||||
|
||||
suppress_transition = renpy.config.skipping or renpy.game.less_updates
|
||||
|
||||
# The global one.
|
||||
@@ -1462,8 +1665,10 @@ class Interface(object):
|
||||
renpy.display.layout.size_groups.clear()
|
||||
|
||||
# Clear some events.
|
||||
pygame.event.clear((MOUSEMOTION, PERIODIC,
|
||||
TIMEEVENT, REDRAW))
|
||||
pygame.event.clear((pygame.MOUSEMOTION,
|
||||
PERIODIC,
|
||||
TIMEEVENT,
|
||||
REDRAW))
|
||||
|
||||
# Add a single TIMEEVENT to the queue.
|
||||
pygame.event.post(self.time_event)
|
||||
@@ -1471,14 +1676,12 @@ class Interface(object):
|
||||
# Figure out the scene list we want to show.
|
||||
scene_lists = renpy.game.context().scene_lists
|
||||
|
||||
# Figure out what the overlay layer should look like.
|
||||
renpy.ui.layer("overlay")
|
||||
# Remove the now-hidden things.
|
||||
scene_lists.remove_hidden()
|
||||
|
||||
# Compute the overlay.
|
||||
if not suppress_overlay:
|
||||
for i in renpy.config.overlay_functions:
|
||||
i()
|
||||
|
||||
renpy.ui.close()
|
||||
self.compute_overlay()
|
||||
|
||||
# The root widget of everything that is displayed on the screen.
|
||||
root_widget = renpy.display.layout.MultiBox(layout='fixed')
|
||||
@@ -1548,11 +1751,7 @@ class Interface(object):
|
||||
old_root.layers = { }
|
||||
|
||||
for layer in renpy.config.layers:
|
||||
if layer in renpy.config.overlay_layers:
|
||||
d = scene[layer]
|
||||
else:
|
||||
d = self.transition_from[None].layers[layer]
|
||||
|
||||
d = self.transition_from[None].layers[layer]
|
||||
old_root.layers[layer] = d
|
||||
old_root.add(d)
|
||||
|
||||
@@ -1562,9 +1761,10 @@ class Interface(object):
|
||||
|
||||
if not isinstance(trans, Displayable):
|
||||
raise Exception("Expected transition to be a displayable, not a %r" % trans)
|
||||
|
||||
trans.show()
|
||||
|
||||
transition_time = self.transition_time.get(None, None)
|
||||
|
||||
root_widget.add(trans, transition_time, transition_time)
|
||||
|
||||
if trans_pause:
|
||||
@@ -1646,7 +1846,9 @@ class Interface(object):
|
||||
self.force_redraw = False
|
||||
|
||||
# Redraw the screen.
|
||||
if needs_redraw and self.display.can_redraw(first_pass):
|
||||
if (needs_redraw and
|
||||
(first_pass or not pygame.event.peek(ALL_EVENTS)) and
|
||||
self.display.can_redraw(first_pass)):
|
||||
|
||||
# If we have a movie, start showing it.
|
||||
suppress_blit = renpy.display.video.interact()
|
||||
@@ -1761,7 +1963,6 @@ class Interface(object):
|
||||
if self.timeout_time != old_timeout_time:
|
||||
# Always set to at least 1ms.
|
||||
pygame.time.set_timer(TIMEEVENT, int(time_left * 1000 + 1))
|
||||
|
||||
old_timeout_time = self.timeout_time
|
||||
|
||||
# Handle autosaving, as necessary.
|
||||
@@ -1776,7 +1977,7 @@ class Interface(object):
|
||||
else:
|
||||
ev = self.event_wait()
|
||||
|
||||
if ev.type == NOEVENT:
|
||||
if ev.type == pygame.NOEVENT:
|
||||
continue
|
||||
|
||||
if renpy.config.profile:
|
||||
@@ -1790,7 +1991,7 @@ class Interface(object):
|
||||
|
||||
ev2 = self.event_peek()
|
||||
|
||||
if ev2 and ev2.type not in (NOEVENT, PERIODIC, REDRAW, QUIT):
|
||||
if ev2 and ev2.type not in (pygame.NOEVENT, PERIODIC, REDRAW, pygame.QUIT):
|
||||
ev = self.event_poll()
|
||||
|
||||
# Handle redraw timeouts.
|
||||
@@ -1827,12 +2028,12 @@ class Interface(object):
|
||||
renpy.display.behavior.skipping(ev)
|
||||
|
||||
# Handle quit specially for now.
|
||||
if ev.type == QUIT:
|
||||
if ev.type == pygame.QUIT:
|
||||
self.quit_event()
|
||||
|
||||
# Merge mousemotion events.
|
||||
if ev.type == MOUSEMOTION:
|
||||
evs = pygame.event.get([MOUSEMOTION])
|
||||
if ev.type == pygame.MOUSEMOTION:
|
||||
evs = pygame.event.get([pygame.MOUSEMOTION])
|
||||
if len(evs):
|
||||
ev = evs[-1]
|
||||
|
||||
@@ -1840,12 +2041,11 @@ class Interface(object):
|
||||
self.focused = True
|
||||
|
||||
# Handle focus notifications.
|
||||
if ev.type == ACTIVEEVENT:
|
||||
if ev.type == pygame.ACTIVEEVENT:
|
||||
if ev.state & 1:
|
||||
self.focused = ev.gain
|
||||
|
||||
# x, y = getattr(ev, 'pos', (0, 0))
|
||||
x, y = pygame.mouse.get_pos()
|
||||
x, y = getattr(ev, 'pos', pygame.mouse.get_pos())
|
||||
x -= self.display.screen_xoffset
|
||||
y -= self.display.screen_yoffset
|
||||
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
|
||||
import pygame
|
||||
import renpy
|
||||
import textwrap
|
||||
import select
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
|
||||
@@ -42,6 +39,10 @@ class ReportError(object):
|
||||
|
||||
# In the report method, Ren'Py may be in an ill-defined state.
|
||||
def report(self, error_type):
|
||||
import os.path
|
||||
import pygame
|
||||
pygame.display.init()
|
||||
|
||||
msg = "Ren'Py has experienced " + error_type + ".\n"
|
||||
msg += "Left-click or space reloads, right-click or escape exits."
|
||||
|
||||
@@ -61,11 +62,11 @@ class ReportError(object):
|
||||
|
||||
while True:
|
||||
|
||||
if os.path.exists(commandfile):
|
||||
if commandfile and os.path.exists(commandfile):
|
||||
return True
|
||||
|
||||
ev = pygame.event.wait()
|
||||
|
||||
|
||||
if ev.type == pygame.MOUSEBUTTONUP:
|
||||
|
||||
if ev.button == 1:
|
||||
|
||||
@@ -21,9 +21,8 @@
|
||||
|
||||
# This file contains code to manage focus on the display.
|
||||
|
||||
import renpy
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
import renpy
|
||||
|
||||
class Focus(object):
|
||||
|
||||
@@ -169,10 +168,9 @@ def before_interact(roots):
|
||||
for f, n in fwn:
|
||||
if f is not current:
|
||||
f.unfocus()
|
||||
|
||||
|
||||
if current:
|
||||
current.focus(default=True)
|
||||
|
||||
|
||||
|
||||
# This changes the focus to be the widget contained inside the new
|
||||
@@ -217,7 +215,7 @@ def change_focus(newfocus, default=False):
|
||||
# This handles mouse events, to see if they change the focus.
|
||||
def mouse_handler(ev, x, y, default=False):
|
||||
|
||||
if ev.type not in (MOUSEMOTION, MOUSEBUTTONUP, MOUSEBUTTONDOWN):
|
||||
if ev.type not in (pygame.MOUSEMOTION, pygame.MOUSEBUTTONUP, pygame.MOUSEBUTTONDOWN):
|
||||
return
|
||||
|
||||
new_focus = renpy.display.render.focus_at_point(x, y)
|
||||
|
||||
+28
-24
@@ -20,16 +20,12 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
|
||||
import xml.etree.ElementTree as etree
|
||||
|
||||
try:
|
||||
import _renpy_font
|
||||
pygame.font = _renpy_font
|
||||
except:
|
||||
pass
|
||||
|
||||
import _renpy_font
|
||||
pygame.font = _renpy_font
|
||||
|
||||
import renpy
|
||||
|
||||
# This contains a map from (fn, size, bold, italics, underline) to the
|
||||
@@ -78,15 +74,14 @@ class ImageFont(object):
|
||||
def render(self, text, antialias, color, black_color=(0, 0, 0, 255), background=None):
|
||||
|
||||
if not text:
|
||||
return pygame.Surface((0, self.height), 0,
|
||||
renpy.game.interface.display.sample_surface)
|
||||
return renpy.display.pgrender.surface((0, self.height), True)
|
||||
|
||||
xoff, _ = self.offsets[text[0]]
|
||||
x = -xoff
|
||||
y = 0
|
||||
|
||||
surf = pygame.Surface(self.size(text), 0,
|
||||
renpy.game.interface.display.sample_surface)
|
||||
surf = renpy.display.pgrender.surface(self.size(text), True)
|
||||
|
||||
for a, b in zip(text, text[1:]):
|
||||
xoff, yoff = self.offsets[a]
|
||||
surf.blit(self.chars[a], (x + xoff, y + yoff))
|
||||
@@ -96,15 +91,14 @@ class ImageFont(object):
|
||||
surf.blit(self.chars[text[-1]], (x + xoff, y + yoff))
|
||||
|
||||
if renpy.config.recolor_sfonts and \
|
||||
(color != (255, 255, 255, 255) or black_color != (0, 0, 0, 255) ) and \
|
||||
renpy.display.module.can_twomap:
|
||||
(color != (255, 255, 255, 255) or black_color != (0, 0, 0, 255)):
|
||||
|
||||
newsurf = pygame.Surface(surf.get_size(), surf.get_flags(), surf)
|
||||
newsurf = renpy.display.pgrender.surface(surf.get_size(), True)
|
||||
renpy.display.module.twomap(surf, newsurf, color, black_color)
|
||||
renpy.display.render.mutated_surface(newsurf)
|
||||
|
||||
surf = newsurf
|
||||
|
||||
renpy.display.render.mutated_surface(surf)
|
||||
return surf
|
||||
|
||||
def get_linesize(self):
|
||||
@@ -151,7 +145,7 @@ class SFont(ImageFont):
|
||||
self.baseline = height
|
||||
|
||||
# Create space characters.
|
||||
self.chars[u' '] = pygame.Surface((self.spacewidth, height), 0, surf)
|
||||
self.chars[u' '] = renpy.display.pgrender.surface((self.spacewidth, height), True)
|
||||
self.width[u' '] = self.spacewidth
|
||||
self.advance[u' '] = self.spacewidth
|
||||
self.offsets[u' '] = (0, 0)
|
||||
@@ -256,7 +250,7 @@ class MudgeFont(ImageFont):
|
||||
|
||||
# Create space characters.
|
||||
if u' ' not in self.chars:
|
||||
self.chars[u' '] = pygame.Surface((self.spacewidth, height), 0, surf)
|
||||
self.chars[u' '] = renpy.display.pgrender.surface((self.spacewidth, height), True)
|
||||
self.width[u' '] = self.spacewidth
|
||||
self.advance[u' '] = self.spacewidth
|
||||
self.offsets[u' '] = (0, 0)
|
||||
@@ -378,11 +372,22 @@ def register_bmfont(name=None, size=None, bold=False, italics=False, underline=F
|
||||
|
||||
def load_ttf(fn, size, bold, italics, underline, expand):
|
||||
|
||||
# Figure out the font index.
|
||||
index = 0
|
||||
|
||||
if "@" in fn:
|
||||
index, fn = fn.split("@", 1)
|
||||
index = int(index)
|
||||
|
||||
try:
|
||||
rv = pygame.font.Font(renpy.loader.load(fn), size)
|
||||
f = renpy.loader.load(fn)
|
||||
rv = _renpy_font.Font(f, size, index)
|
||||
|
||||
rv.set_bold(bold)
|
||||
rv.set_italic(italics)
|
||||
except:
|
||||
|
||||
except IOError:
|
||||
|
||||
# Let's try to find the font on our own.
|
||||
fonts = [ i.strip().lower() for i in fn.split(",") ]
|
||||
|
||||
@@ -394,7 +399,7 @@ def load_ttf(fn, size, bold, italics, underline, expand):
|
||||
for flags, ffn in v.iteritems():
|
||||
for i in fonts:
|
||||
if ffn.lower().endswith(i):
|
||||
rv = pygame.font.Font(ffn, size)
|
||||
rv = _renpy_font.Font(ffn, size, index)
|
||||
rv.set_bold(bold)
|
||||
rv.set_italic(italics)
|
||||
break
|
||||
@@ -404,7 +409,7 @@ def load_ttf(fn, size, bold, italics, underline, expand):
|
||||
break
|
||||
else:
|
||||
# Let pygame try to find the font for us.
|
||||
rv = pygame.font.SysFont(fn, size, bold, italics)
|
||||
rv = pygame.sysfont.SysFont(fn, size, bold, italics)
|
||||
|
||||
rv.set_underline(underline)
|
||||
|
||||
@@ -432,9 +437,8 @@ def get_font(origfn, size, origbold=False, origitalics=False, underline=False, e
|
||||
try:
|
||||
rv = load_ttf(fn, size, bold, italics, underline, expand)
|
||||
except:
|
||||
if renpy.config.debug:
|
||||
raise
|
||||
raise Exception("Could not find font: %r" % ((fn, size, bold, italics, underline), ))
|
||||
renpy.game.exception_info = "Finding font: %r" % ((fn, size, bold, italics, underline),)
|
||||
raise
|
||||
|
||||
font_cache[(origfn, size, origbold, origitalics, underline, expand)] = rv
|
||||
|
||||
|
||||
+42
-90
@@ -24,14 +24,12 @@
|
||||
# cropping and scaling).
|
||||
|
||||
import renpy
|
||||
import random
|
||||
import math
|
||||
import zipfile
|
||||
import cStringIO
|
||||
import threading
|
||||
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
|
||||
# This is an entry in the image cache.
|
||||
class CacheEntry(object):
|
||||
@@ -83,11 +81,14 @@ class Cache(object):
|
||||
self.keep_preloading = True
|
||||
|
||||
# The preload thread.
|
||||
self.preload_thread = threading.Thread(target=self.preload_thread_main)
|
||||
self.preload_thread = threading.Thread(target=self.preload_thread_main, name="preloader")
|
||||
self.preload_thread.setDaemon(True)
|
||||
self.preload_thread.start()
|
||||
|
||||
def quit(self):
|
||||
if not self.preload_thread.isAlive():
|
||||
return
|
||||
|
||||
self.lock.acquire()
|
||||
self.keep_preloading = False
|
||||
self.lock.notify()
|
||||
@@ -160,9 +161,7 @@ class Cache(object):
|
||||
raise Exception("Expected an image of some sort, but got" + str(image) + ".")
|
||||
|
||||
if not image.cache:
|
||||
surf = image.load()
|
||||
surf = surf.convert_alpha(renpy.game.interface.display.window)
|
||||
|
||||
surf = image.load()
|
||||
renpy.display.render.mutated_surface(surf)
|
||||
return surf
|
||||
|
||||
@@ -180,15 +179,17 @@ class Cache(object):
|
||||
ce = self.cache.get(image, None)
|
||||
|
||||
if ce is not None:
|
||||
self.cache.release()
|
||||
self.cache.release()
|
||||
|
||||
# Otherwise, we keep the lock, and load the image ourselves.
|
||||
if ce is None:
|
||||
|
||||
surf = image.load()
|
||||
has_alpha = surf.get_masks()[3]
|
||||
surf = surf.convert_alpha(renpy.game.interface.display.window)
|
||||
|
||||
try:
|
||||
surf = image.load()
|
||||
except:
|
||||
self.lock.release()
|
||||
raise
|
||||
|
||||
ce = CacheEntry(image, surf)
|
||||
self.total_cache_size += ce.size
|
||||
self.cache[image] = ce
|
||||
@@ -205,26 +206,16 @@ class Cache(object):
|
||||
rle = not renpy.game.less_memory
|
||||
# rle = image.rle
|
||||
surf = ce.surf
|
||||
|
||||
# # If we don't know if the image is RLE or not, guess.
|
||||
# # Only do so if the image has an alpha channel.
|
||||
# if rle is None and has_alpha and not renpy.game.less_memory:
|
||||
# sw, sh = surf.get_size()
|
||||
|
||||
# for i in range(0, 10):
|
||||
# if surf.get_at((random.randint(0, sw-1),
|
||||
# random.randint(0, sh-1)))[3] == 0:
|
||||
# rle = True
|
||||
# break
|
||||
|
||||
if rle:
|
||||
|
||||
# We must copy the surface, so we have a RLE-specific version.
|
||||
rle_surf = ce.surf.convert_alpha(renpy.game.interface.display.window)
|
||||
rle_surf.set_alpha(255, RLEACCEL)
|
||||
rle_surf = renpy.display.pgrender.copy_surface(ce.surf)
|
||||
rle_surf.set_alpha(255, pygame.RLEACCEL)
|
||||
renpy.display.render.mutated_surface(rle_surf)
|
||||
|
||||
rle_cache[id(ce.surf)] = rle_surf
|
||||
renpy.display.render.mutated_surface(ce.surf)
|
||||
|
||||
if renpy.config.debug_image_cache:
|
||||
print "Added to rle cache:", image
|
||||
|
||||
@@ -453,9 +444,9 @@ class Image(ImageBase):
|
||||
try:
|
||||
|
||||
if unscaled:
|
||||
surf = renpy.display.scale.image_load_unscaled(renpy.loader.load(self.filename), self.filename)
|
||||
surf = renpy.display.pgrender.load_image_unscaled(renpy.loader.load(self.filename), self.filename)
|
||||
else:
|
||||
surf = pygame.image.load(renpy.loader.load(self.filename), self.filename)
|
||||
surf = renpy.display.pgrender.load_image(renpy.loader.load(self.filename), self.filename)
|
||||
|
||||
return surf
|
||||
|
||||
@@ -493,7 +484,7 @@ class ZipFileImage(ImageBase):
|
||||
def load(self):
|
||||
zf = zipfile.ZipFile(self.zipfilename, 'r')
|
||||
sio = cStringIO.StringIO(zf.read(self.filename))
|
||||
rv = pygame.image.load(sio, self.filename)
|
||||
rv = renpy.display.pgrender.load_image(sio, self.filename)
|
||||
zf.close()
|
||||
|
||||
return rv
|
||||
@@ -542,8 +533,7 @@ class Composite(ImageBase):
|
||||
else:
|
||||
size = cache.get(self.images[0]).get_size()
|
||||
|
||||
rv = pygame.Surface(size, 0,
|
||||
renpy.game.interface.display.sample_surface)
|
||||
rv = renpy.display.pgrender.surface(size, True)
|
||||
|
||||
for pos, im in zip(self.positions, self.images):
|
||||
rv.blit(cache.get(im), pos)
|
||||
@@ -610,9 +600,7 @@ class FrameImage(ImageBase):
|
||||
dw = self.width
|
||||
dh = self.height
|
||||
|
||||
dest = pygame.Surface((dw, dh), 0,
|
||||
renpy.game.interface.display.sample_surface)
|
||||
|
||||
dest = renpy.display.pgrender.surface((dw, dh), True)
|
||||
rv = dest
|
||||
|
||||
source = cache.get(self.image)
|
||||
@@ -687,18 +675,17 @@ class FrameImage(ImageBase):
|
||||
tilew, tileh = srcsize
|
||||
dstw, dsth = dstsize
|
||||
|
||||
surf2 = renpy.display.scale.PygameSurface(dstsize, 0, surf)
|
||||
surf2 = renpy.display.pgrender.surface_unscaled(dstsize)
|
||||
|
||||
for y in range(0, dsth, tileh):
|
||||
for x in range(0, dstw, tilew):
|
||||
surf2.blit(surf, (x, y))
|
||||
|
||||
|
||||
surf = surf2
|
||||
|
||||
else:
|
||||
if self.bilinear and renpy.display.module.can_bilinear_scale:
|
||||
surf2 = renpy.display.scale.real_bilinear(surf, dstsize)
|
||||
if self.bilinear:
|
||||
surf2 = renpy.display.scale.real_smoothscale(surf, dstsize)
|
||||
else:
|
||||
surf2 = renpy.display.scale.real_transform_scale(surf, dstsize)
|
||||
|
||||
@@ -740,13 +727,7 @@ class SolidImage(ImageBase):
|
||||
|
||||
def load(self):
|
||||
|
||||
if self.color[3] != 255:
|
||||
sample = renpy.game.interface.display.sample_surface
|
||||
else:
|
||||
sample = renpy.game.interface.display.window
|
||||
|
||||
rv = pygame.Surface((self.width, self.height), 0,
|
||||
sample)
|
||||
rv = renpy.display.pgrender.surface((self.width, self.height), True)
|
||||
rv.fill(self.color)
|
||||
|
||||
return rv
|
||||
@@ -759,8 +740,6 @@ class Scale(ImageBase):
|
||||
|
||||
def __init__(self, im, width, height, bilinear=True, **properties):
|
||||
|
||||
bilinear = bilinear and renpy.display.module.can_bilinear_scale
|
||||
|
||||
im = image(im)
|
||||
super(Scale, self).__init__(im, width, height, bilinear, **properties)
|
||||
|
||||
@@ -782,7 +761,7 @@ class Scale(ImageBase):
|
||||
else:
|
||||
try:
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
rv = pygame.transform.scale(child, (self.width, self.height))
|
||||
rv = renpy.display.pgrender.transform_scale(child, (self.width, self.height))
|
||||
finally:
|
||||
renpy.display.render.blit_lock.release()
|
||||
|
||||
@@ -828,7 +807,7 @@ class FactorScale(ImageBase):
|
||||
else:
|
||||
try:
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
rv = pygame.transform.scale(surf, (width, height))
|
||||
rv = renpy.display.pgrender.transform_scale(surf, (width, height))
|
||||
finally:
|
||||
renpy.display.render.blit_lock.release()
|
||||
|
||||
@@ -858,29 +837,28 @@ class Flip(ImageBase):
|
||||
im = image(im)
|
||||
super(Flip, self).__init__(im, horizontal, vertical, **properties)
|
||||
|
||||
|
||||
|
||||
self.image = im
|
||||
self.horizontal = horizontal
|
||||
self.vertical = vertical
|
||||
|
||||
|
||||
def load(self):
|
||||
|
||||
child = cache.get(self.image)
|
||||
|
||||
try:
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
rv = pygame.transform.flip(child, self.horizontal, self.vertical)
|
||||
rv = renpy.display.pgrender.flip(child, self.horizontal, self.vertical)
|
||||
finally:
|
||||
renpy.display.render.blit_lock.release()
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
def predict_files(self):
|
||||
return self.image.predict_files()
|
||||
|
||||
|
||||
|
||||
|
||||
class Rotozoom(ImageBase):
|
||||
"""
|
||||
@@ -911,7 +889,7 @@ class Rotozoom(ImageBase):
|
||||
|
||||
try:
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
rv = pygame.transform.rotozoom(child, self.angle, self.zoom)
|
||||
rv = renpy.display.pgrender.rotozoom(child, self.angle, self.zoom)
|
||||
finally:
|
||||
renpy.display.render.blit_lock.release()
|
||||
|
||||
@@ -1000,13 +978,7 @@ class Map(ImageBase):
|
||||
|
||||
surf = cache.get(self.image)
|
||||
|
||||
if not renpy.display.module.can_map:
|
||||
return surf
|
||||
|
||||
if self.force_alpha and not (surf.get_masks()[3]):
|
||||
surf = surf.convert_alpha(renpy.game.interface.display.window)
|
||||
|
||||
rv = pygame.Surface(surf.get_size(), surf.get_flags(), surf)
|
||||
rv = renpy.display.pgrender.surface(surf.get_size(), True)
|
||||
|
||||
renpy.display.module.map(surf, rv,
|
||||
self.rmap, self.gmap, self.bmap, self.amap)
|
||||
@@ -1045,13 +1017,7 @@ class Twocolor(ImageBase):
|
||||
|
||||
surf = cache.get(self.image)
|
||||
|
||||
if not renpy.display.module.can_twomap:
|
||||
return surf
|
||||
|
||||
if self.force_alpha and not (surf.get_masks()[3]):
|
||||
surf = surf.convert_alpha(renpy.game.interface.display.window)
|
||||
|
||||
rv = pygame.Surface(surf.get_size(), surf.get_flags(), surf)
|
||||
rv = renpy.display.pgrender.surface(surf.get_size(), True)
|
||||
|
||||
renpy.display.module.twomap(surf, rv,
|
||||
self.white, self.black)
|
||||
@@ -1088,13 +1054,7 @@ class Recolor(ImageBase):
|
||||
|
||||
surf = cache.get(self.image)
|
||||
|
||||
if not renpy.display.module.can_linmap:
|
||||
return surf
|
||||
|
||||
if self.force_alpha and not (surf.get_masks()[3]):
|
||||
surf = surf.convert_alpha(renpy.game.interface.display.window)
|
||||
|
||||
rv = pygame.Surface(surf.get_size(), surf.get_flags(), surf)
|
||||
rv = renpy.display.pgrender.surface(surf.get_size(), True)
|
||||
|
||||
renpy.display.module.linmap(surf, rv,
|
||||
self.rmul, self.gmul, self.bmul, self.amul)
|
||||
@@ -1127,13 +1087,7 @@ class MatrixColor(ImageBase):
|
||||
|
||||
surf = cache.get(self.image)
|
||||
|
||||
if not renpy.display.module.can_colormatrix:
|
||||
return surf
|
||||
|
||||
if not (surf.get_masks()[3]):
|
||||
surf = surf.convert_alpha(renpy.game.interface.display.window)
|
||||
|
||||
rv = pygame.Surface(surf.get_size(), surf.get_flags(), surf)
|
||||
rv = renpy.display.pgrender.surface(surf.get_size(), True)
|
||||
|
||||
renpy.display.module.colormatrix(surf, rv, self.matrix)
|
||||
|
||||
@@ -1366,11 +1320,11 @@ class Tile(ImageBase):
|
||||
|
||||
surf = cache.get(self.image)
|
||||
|
||||
rv = renpy.display.pgrender.surface(size, True)
|
||||
|
||||
width, height = size
|
||||
sw, sh = surf.get_size()
|
||||
|
||||
rv = pygame.Surface(size, 0, surf)
|
||||
|
||||
for y in range(0, height, sh):
|
||||
for x in range(0, width, sw):
|
||||
rv.blit(surf, (x, y))
|
||||
@@ -1397,10 +1351,8 @@ class AlphaMask(ImageBase):
|
||||
raise Exception("AlphaMask surfaces must be the same size.")
|
||||
|
||||
# Used to copy the surface.
|
||||
rv = basesurf.convert_alpha(renpy.game.interface.display.window)
|
||||
|
||||
if renpy.display.module.can_munge:
|
||||
renpy.display.module.alpha_munge(masksurf, rv, identity)
|
||||
rv = renpy.display.pgrender.copy_surface(basesurf)
|
||||
renpy.display.module.alpha_munge(masksurf, rv, identity)
|
||||
|
||||
return rv
|
||||
|
||||
@@ -1434,8 +1386,7 @@ def image(arg, loose=False, **properties):
|
||||
if isinstance(arg, renpy.display.image.ImageReference):
|
||||
arg.find_target()
|
||||
return image(arg.target, loose=loose, **properties)
|
||||
|
||||
|
||||
|
||||
elif isinstance(arg, basestring):
|
||||
return Image(arg, **properties)
|
||||
|
||||
@@ -1455,7 +1406,8 @@ def image(arg, loose=False, **properties):
|
||||
raise Exception("Expected an image, but got a general displayable.")
|
||||
else:
|
||||
raise Exception("Could not construct image from argument.")
|
||||
|
||||
|
||||
|
||||
def load_image(fn):
|
||||
"""
|
||||
This loads an image from the given filename, using the cache.
|
||||
|
||||
+42
-13
@@ -26,8 +26,6 @@
|
||||
import renpy
|
||||
from renpy.display.render import render, Render
|
||||
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
|
||||
Image = renpy.display.im.image
|
||||
|
||||
@@ -48,12 +46,11 @@ class UncachedImage(renpy.display.core.Displayable):
|
||||
|
||||
super(UncachedImage, self).__init__(style=style, **properties)
|
||||
|
||||
self.surf = pygame.image.load(file, hint)
|
||||
self.surf = self.surf.convert_alpha(renpy.game.interface.display.window)
|
||||
self.surf = renpy.display.pgrender.image_load(file, hint)
|
||||
|
||||
if scale:
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
self.surf = pygame.transform.scale(self.surf, scale)
|
||||
self.surf = renpy.display.pgrender.transform_scale(self.surf, scale)
|
||||
renpy.display.render.blit_lock.release()
|
||||
|
||||
renpy.display.render.mutated_surface(self.surf)
|
||||
@@ -74,7 +71,8 @@ class ImageReference(renpy.display.core.Displayable):
|
||||
|
||||
nosave = [ 'target' ]
|
||||
target = None
|
||||
|
||||
param_target = None
|
||||
|
||||
def __init__(self, name, **properties):
|
||||
"""
|
||||
@param name: A tuple of strings, the name of the image. Or else
|
||||
@@ -85,8 +83,17 @@ class ImageReference(renpy.display.core.Displayable):
|
||||
|
||||
self.name = name
|
||||
|
||||
def get_parameterized(self):
|
||||
if self.param_target:
|
||||
return self.param_target.get_parameterized()
|
||||
|
||||
return self
|
||||
|
||||
def find_target(self):
|
||||
import renpy.exports as exports
|
||||
|
||||
if self.param_target:
|
||||
self.target = self.param_target
|
||||
return None
|
||||
|
||||
name = self.name
|
||||
|
||||
@@ -109,11 +116,14 @@ class ImageReference(renpy.display.core.Displayable):
|
||||
# Scan through, searching for an image (defined with an
|
||||
# input statement) that is a prefix of the given name.
|
||||
while name:
|
||||
if name in exports.images:
|
||||
target = exports.images[name]
|
||||
if name in renpy.exports.images:
|
||||
target = renpy.exports.images[name]
|
||||
|
||||
try:
|
||||
self.target = target.parameterize(name, parameters)
|
||||
if self.target is not target:
|
||||
self.param_target = self.target
|
||||
|
||||
except Exception, e:
|
||||
if renpy.config.debug:
|
||||
raise
|
||||
@@ -128,8 +138,22 @@ class ImageReference(renpy.display.core.Displayable):
|
||||
|
||||
error("Image '%s' not found." % ' '.join(self.name))
|
||||
return False
|
||||
|
||||
|
||||
def hide(self, st, at):
|
||||
if not self.target:
|
||||
self.find_target()
|
||||
|
||||
return self.target.hide(st, at)
|
||||
|
||||
def set_transform_event(self, event):
|
||||
if not self.target:
|
||||
self.find_target()
|
||||
|
||||
return self.target.set_transform_event(event)
|
||||
|
||||
|
||||
|
||||
|
||||
def event(self, ev, x, y, st):
|
||||
if not self.target:
|
||||
self.find_target()
|
||||
@@ -175,7 +199,6 @@ class Solid(renpy.display.core.Displayable):
|
||||
color. A Solid expands to fill all the space allocated to it,
|
||||
making it suitable for use as a background.
|
||||
"""
|
||||
|
||||
def __init__(self, color, **properties):
|
||||
"""
|
||||
@param color: An RGBA tuple, giving the color that the display
|
||||
@@ -183,11 +206,17 @@ class Solid(renpy.display.core.Displayable):
|
||||
"""
|
||||
|
||||
super(Solid, self).__init__(**properties)
|
||||
self.color = renpy.easy.color(color)
|
||||
|
||||
if color is not None:
|
||||
self.color = renpy.easy.color(color)
|
||||
else:
|
||||
self.color = None
|
||||
|
||||
def render(self, width, height, st, at):
|
||||
|
||||
si = renpy.display.im.SolidImage(self.color,
|
||||
color = self.color or self.style.color
|
||||
|
||||
si = renpy.display.im.SolidImage(color,
|
||||
width,
|
||||
height)
|
||||
|
||||
|
||||
@@ -22,12 +22,9 @@
|
||||
# This file is responsible for joystick support in Ren'Py.
|
||||
|
||||
import os
|
||||
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
|
||||
import renpy
|
||||
import sets
|
||||
|
||||
# Do we have a joystick enabled?
|
||||
enabled = False
|
||||
@@ -63,7 +60,7 @@ def event(ev):
|
||||
if not enabled:
|
||||
return ev
|
||||
|
||||
if ev.type == JOYAXISMOTION:
|
||||
if ev.type == pygame.JOYAXISMOTION:
|
||||
|
||||
if ev.value >= 0.5:
|
||||
state = "Positive"
|
||||
@@ -95,12 +92,12 @@ def event(ev):
|
||||
return pygame.event.Event(renpy.display.core.JOYEVENT,
|
||||
press=press, release=release)
|
||||
|
||||
if ev.type == JOYBUTTONDOWN:
|
||||
if ev.type == pygame.JOYBUTTONDOWN:
|
||||
|
||||
return pygame.event.Event(renpy.display.core.JOYEVENT,
|
||||
press="Button %d.%d" % (ev.joy, ev.button),
|
||||
release=None)
|
||||
if ev.type == JOYBUTTONUP:
|
||||
if ev.type == pygame.JOYBUTTONUP:
|
||||
|
||||
return pygame.event.Event(renpy.display.core.JOYEVENT,
|
||||
press=None,
|
||||
|
||||
+67
-34
@@ -22,13 +22,9 @@
|
||||
# This file contains classes that handle layout of displayables on
|
||||
# the screen.
|
||||
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
|
||||
import renpy
|
||||
from renpy.display.render import render, Render, IDENTITY, Matrix2D
|
||||
import time
|
||||
import math
|
||||
from renpy.display.render import render, Render
|
||||
|
||||
|
||||
def scale(num, base):
|
||||
"""
|
||||
@@ -97,11 +93,11 @@ class Container(renpy.display.core.Displayable):
|
||||
|
||||
super(Container, self).__init__(**properties)
|
||||
|
||||
def set_style_prefix(self, prefix):
|
||||
super(Container, self).set_style_prefix(prefix)
|
||||
def set_style_prefix(self, prefix, root):
|
||||
super(Container, self).set_style_prefix(prefix, root)
|
||||
|
||||
for i in self.children:
|
||||
i.set_style_prefix(prefix)
|
||||
i.set_style_prefix(prefix, False)
|
||||
|
||||
def add(self, d):
|
||||
"""
|
||||
@@ -177,6 +173,29 @@ class Container(renpy.display.core.Displayable):
|
||||
def visit(self):
|
||||
return self.children
|
||||
|
||||
# These interact with the ui functions to allow use as a context
|
||||
# manager.
|
||||
|
||||
def __enter__(self):
|
||||
|
||||
if renpy.ui.current is self and not renpy.ui.current_once:
|
||||
return self
|
||||
|
||||
raise Exception("%r cannot be used as a context manager.", type(self).__name__)
|
||||
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
|
||||
if exc_type:
|
||||
return False
|
||||
|
||||
if renpy.ui.current is not self:
|
||||
raise Exception("Widget %r left open at end of block.")
|
||||
|
||||
renpy.ui.close()
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
def LiveComposite(size, *args, **properties):
|
||||
@@ -209,7 +228,7 @@ def LiveComposite(size, *args, **properties):
|
||||
|
||||
width, height = size
|
||||
|
||||
rv = Fixed(xmaximum=width, ymaximum=height, **properties)
|
||||
rv = Fixed(xmaximum=width, ymaximum=height, xminimum=width, yminimum=height, **properties)
|
||||
|
||||
if len(args) % 2 != 0:
|
||||
raise Exception("LiveComposite requires an odd number of arguments.")
|
||||
@@ -621,7 +640,7 @@ class MultiBox(Container):
|
||||
for i, (xo, yo), t in children_offsets:
|
||||
|
||||
if t is None:
|
||||
cst = 0
|
||||
cst = st
|
||||
else:
|
||||
cst = renpy.game.interface.event_time - t
|
||||
|
||||
@@ -736,7 +755,7 @@ class Window(Container):
|
||||
cypadding = top_padding + bottom_padding
|
||||
|
||||
child = self.get_child()
|
||||
|
||||
|
||||
# Render the child.
|
||||
surf = render(child,
|
||||
width - cxmargin - cxpadding,
|
||||
@@ -1289,31 +1308,45 @@ class Alpha(renpy.display.core.Displayable):
|
||||
|
||||
rend = renpy.display.render.render(self.child, height, width, st, at)
|
||||
|
||||
if not renpy.display.module.can_linmap:
|
||||
return rend
|
||||
|
||||
w, h = rend.get_size()
|
||||
rv = renpy.display.render.Render(w, h)
|
||||
|
||||
oldsurf = rend.pygame_surface()
|
||||
|
||||
if not (oldsurf.get_masks()[3]):
|
||||
oldsurf = oldsurf.convert_alpha(renpy.game.interface.display.window)
|
||||
|
||||
newsurf = pygame.Surface(oldsurf.get_size(), oldsurf.get_flags(), oldsurf)
|
||||
|
||||
|
||||
renpy.display.module.linmap(oldsurf, newsurf,
|
||||
256, 256, 256, int(alpha * 256.0))
|
||||
|
||||
renpy.display.render.mutated_surface(newsurf)
|
||||
|
||||
rv.blit(newsurf, (0, 0))
|
||||
|
||||
rv.depends_on(rend)
|
||||
rv.blit(rend, (0, 0))
|
||||
rv.alpha = alpha
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
|
||||
|
||||
class AdjustTimes(Container):
|
||||
|
||||
def __init__(self, child, start_time, anim_time):
|
||||
super(AdjustTimes, self).__init__(style='default')
|
||||
|
||||
self.start_time = start_time
|
||||
self.anim_time = anim_time
|
||||
|
||||
self.add(child)
|
||||
|
||||
def render(self, w, h, st, at):
|
||||
|
||||
if self.start_time is None:
|
||||
self.start_time = renpy.game.interface.frame_time
|
||||
|
||||
if self.anim_time is None:
|
||||
self.anim_time = renpy.game.interface.frame_time
|
||||
|
||||
st = renpy.game.interface.frame_time - self.start_time
|
||||
at = renpy.game.interface.frame_time - self.anim_time
|
||||
|
||||
cr = renpy.display.render.render(self.child, w, h, st, at)
|
||||
cw, ch = cr.get_size()
|
||||
rv = renpy.display.render.Render(cw, ch)
|
||||
rv.blit(cr, (0, 0))
|
||||
|
||||
self.offsets = [ (0, 0) ]
|
||||
|
||||
return rv
|
||||
|
||||
def get_placement(self):
|
||||
return self.child.get_placement()
|
||||
|
||||
|
||||
|
||||
+152
-282
@@ -23,8 +23,7 @@
|
||||
# allows us to enhance the feature set of pygame in a renpy specific way.
|
||||
|
||||
import renpy
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
import pygame; pygame # prevents pyflakes warning.
|
||||
|
||||
import sys
|
||||
|
||||
@@ -32,18 +31,15 @@ try:
|
||||
import _renpy
|
||||
version = _renpy.version()
|
||||
|
||||
if version < 6009000:
|
||||
print >>sys.stderr, "The _renpy module was found, but is out of date.\nPlease read module/README.txt for more information."
|
||||
if version < (6, 10, 1):
|
||||
print >>sys.stderr, "The _renpy module was found, but is out of date."
|
||||
print >>sys.stderr, "Trying to run anyway, but you should expect errors."
|
||||
|
||||
except:
|
||||
# If for any reason we can't import the module, we have a version
|
||||
# number of 0.
|
||||
|
||||
print >>sys.stderr, "The _renpy module was not found. Please read module/README.txt for"
|
||||
print >>sys.stderr, "more information."
|
||||
|
||||
version = 0
|
||||
|
||||
sys.exit(-1)
|
||||
|
||||
def convert_and_call(function, src, dst, *args):
|
||||
"""
|
||||
@@ -54,87 +50,54 @@ def convert_and_call(function, src, dst, *args):
|
||||
same format, they are converted and then converted back.
|
||||
"""
|
||||
|
||||
# Now that all surfaces are 32bpp, this function doesn't do much
|
||||
# of anything anymore.
|
||||
|
||||
if (dst.get_masks()[3] != 0) != (src.get_masks()[3] != 0):
|
||||
raise Exception("Surface alphas do not match.")
|
||||
|
||||
dstsize = dst.get_bitsize()
|
||||
function(src, dst, *args)
|
||||
|
||||
if dst.get_bitsize() in (24, 32):
|
||||
target = dst
|
||||
else:
|
||||
if dst.get_masks()[3]:
|
||||
target = pygame.Surface(dst.get_size(), SRCALPHA, 32)
|
||||
else:
|
||||
target = pygame.Surface(dst.get_size(), 0, 24)
|
||||
|
||||
if src.get_bitsize() == target.get_bitsize():
|
||||
source = src
|
||||
else:
|
||||
source = src.convert(target)
|
||||
def pixellate(src, dst, avgwidth, avgheight, outwidth, outheight):
|
||||
"""
|
||||
This pixellates the source surface. First, every pixel in the
|
||||
source surface is projected onto a virtual surface, such that
|
||||
the average value of every avgwidth x avgheight pixels becomes
|
||||
one virtual pixel. It then gets projected back onto the
|
||||
destination surface at a ratio of one virtual pixel to every
|
||||
outwidth x outheight destination pixels.
|
||||
|
||||
function(source, target, *args)
|
||||
If either src or dst is not a 24 or 32 bit surface, they are
|
||||
converted... but that may be a significant performance hit.
|
||||
|
||||
The two surfaces must either have the same alpha or no alpha.
|
||||
"""
|
||||
|
||||
convert_and_call(_renpy.pixellate,
|
||||
src, dst,
|
||||
avgwidth, avgheight,
|
||||
outwidth, outheight)
|
||||
|
||||
|
||||
def scale(s, size):
|
||||
"""
|
||||
Scales down the supplied pygame surface by the given X and Y
|
||||
factors.
|
||||
|
||||
Always works, but may not be high quality.
|
||||
"""
|
||||
|
||||
width, height = s.get_size()
|
||||
dx, dy = size
|
||||
|
||||
d = renpy.display.pgrender.surface(size, True)
|
||||
|
||||
bilinear_scale(s, d)
|
||||
|
||||
if target is not dst:
|
||||
dst.blit(target, (0, 0))
|
||||
return d
|
||||
|
||||
|
||||
if version >= 4008002:
|
||||
|
||||
can_pixellate = True
|
||||
|
||||
def pixellate(src, dst, avgwidth, avgheight, outwidth, outheight):
|
||||
"""
|
||||
This pixellates the source surface. First, every pixel in the
|
||||
source surface is projected onto a virtual surface, such that
|
||||
the average value of every avgwidth x avgheight pixels becomes
|
||||
one virtual pixel. It then gets projected back onto the
|
||||
destination surface at a ratio of one virtual pixel to every
|
||||
outwidth x outheight destination pixels.
|
||||
|
||||
If either src or dst is not a 24 or 32 bit surface, they are
|
||||
converted... but that may be a significant performance hit.
|
||||
|
||||
The two surfaces must either have the same alpha or no alpha.
|
||||
"""
|
||||
|
||||
convert_and_call(_renpy.pixellate,
|
||||
src, dst,
|
||||
avgwidth, avgheight,
|
||||
outwidth, outheight)
|
||||
|
||||
|
||||
def scale(s, size):
|
||||
"""
|
||||
Scales down the supplied pygame surface by the given X and Y
|
||||
factors.
|
||||
|
||||
Always works, but may not be high quality.
|
||||
"""
|
||||
|
||||
width, height = s.get_size()
|
||||
|
||||
dx, dy = size
|
||||
|
||||
d = pygame.Surface(size, s.get_flags(), s)
|
||||
|
||||
if can_bilinear_scale:
|
||||
bilinear_scale(s, d)
|
||||
else:
|
||||
pixellate(s, d, width / dx, height / dy, 1, 1)
|
||||
|
||||
return d
|
||||
|
||||
else:
|
||||
|
||||
can_pixellate = False
|
||||
|
||||
def scale(s, size):
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
rv = pygame.transform.scale(s, size)
|
||||
renpy.display.render.blit_lock.release()
|
||||
return rv
|
||||
|
||||
|
||||
# What we have here are a pair of tables mapping masks to byte offsets
|
||||
# for 24 and 32 bpp modes. We represent 0xff000000 as positive and negative
|
||||
# numbers so that it doesn't yield a warning, and so that it works on
|
||||
@@ -173,230 +136,137 @@ def endian_order(src, r, g, b, a):
|
||||
return rv
|
||||
|
||||
|
||||
if version >= 5005000:
|
||||
|
||||
can_linmap = True
|
||||
def linmap(src, dst, rmap, gmap, bmap, amap):
|
||||
"""
|
||||
This maps the colors between two surfaces. The various map
|
||||
parameters should be fixed-point integers, with 1.0 == 256.
|
||||
"""
|
||||
|
||||
def linmap(src, dst, rmap, gmap, bmap, amap):
|
||||
"""
|
||||
This maps the colors between two surfaces. The various map
|
||||
parameters should be fixed-point integers, with 1.0 == 256.
|
||||
"""
|
||||
|
||||
convert_and_call(_renpy.linmap,
|
||||
src, dst,
|
||||
*endian_order(dst, rmap, gmap, bmap, amap))
|
||||
convert_and_call(_renpy.linmap,
|
||||
src, dst,
|
||||
*endian_order(dst, rmap, gmap, bmap, amap))
|
||||
|
||||
|
||||
save_png = _renpy.save_png
|
||||
save_png = _renpy.save_png
|
||||
|
||||
|
||||
else:
|
||||
def map(src, dst, rmap, gmap, bmap, amap):
|
||||
"""
|
||||
This maps the colors between two surfaces. The various map
|
||||
parameters must be 256 character long strings, with the value
|
||||
of a character at a given offset being what a particular pixel
|
||||
component value is mapped to.
|
||||
"""
|
||||
|
||||
can_linmap = False
|
||||
|
||||
def save_png(surf, file, compress=-1):
|
||||
convert_and_call(_renpy.map,
|
||||
src, dst,
|
||||
*endian_order(dst, rmap, gmap, bmap, amap))
|
||||
|
||||
|
||||
|
||||
def twomap(src, dst, white, black):
|
||||
"""
|
||||
Given colors for white and black, linearly maps things
|
||||
appropriately, taking the alpha channel from white.
|
||||
"""
|
||||
|
||||
wr = white[0]
|
||||
wg = white[1]
|
||||
wb = white[2]
|
||||
wa = white[3]
|
||||
|
||||
br = black[0]
|
||||
bg = black[1]
|
||||
bb = black[2]
|
||||
|
||||
ramp = renpy.display.im.ramp
|
||||
|
||||
if br == 0 and bg == 0 and bb == 0:
|
||||
linmap(src, dst,
|
||||
wr + 1,
|
||||
wg + 1,
|
||||
wb + 1,
|
||||
wa + 1)
|
||||
else:
|
||||
map(src, dst,
|
||||
ramp(br, wr),
|
||||
ramp(bg, wg),
|
||||
ramp(bb, wb),
|
||||
ramp(0, wa))
|
||||
|
||||
|
||||
def alpha_munge(src, dst, amap):
|
||||
"""
|
||||
This samples the red channel from src, maps it through amap, and
|
||||
place it into the alpha channel of amap.
|
||||
"""
|
||||
|
||||
if src.get_size() != dst.get_size():
|
||||
return
|
||||
|
||||
red = byte_offset(src)[0]
|
||||
alpha = byte_offset(dst)[3]
|
||||
|
||||
if version >= 4008005:
|
||||
|
||||
can_map = True
|
||||
|
||||
def map(src, dst, rmap, gmap, bmap, amap):
|
||||
"""
|
||||
This maps the colors between two surfaces. The various map
|
||||
parameters must be 256 character long strings, with the value
|
||||
of a character at a given offset being what a particular pixel
|
||||
component value is mapped to.
|
||||
"""
|
||||
|
||||
convert_and_call(_renpy.map,
|
||||
src, dst,
|
||||
*endian_order(dst, rmap, gmap, bmap, amap))
|
||||
if red is not None and alpha is not None:
|
||||
_renpy.alpha_munge(src, dst, red, alpha, amap)
|
||||
|
||||
|
||||
else:
|
||||
def bilinear_scale(src, dst, sx=0, sy=0, sw=None, sh=None, dx=0, dy=0, dw=None, dh=None, precise=0):
|
||||
|
||||
can_map = False
|
||||
if sw is None:
|
||||
sw, sh = src.get_size()
|
||||
if dw is None:
|
||||
dw, dh = dst.get_size()
|
||||
|
||||
while True:
|
||||
|
||||
if can_map or can_linmap:
|
||||
if sw <= dw * 2 and sh <= dh * 2:
|
||||
break
|
||||
|
||||
can_twomap = True
|
||||
nsw = max(sw / 2, dw)
|
||||
nsh = max(sh / 2, dh)
|
||||
|
||||
def twomap(src, dst, white, black):
|
||||
"""
|
||||
Given colors for white and black, linearly maps things
|
||||
appropriately, taking the alpha channel from white.
|
||||
"""
|
||||
nsrc = renpy.display.pgrender.surface((nsw, nsh), src.get_masks()[3])
|
||||
|
||||
wr = white[0]
|
||||
wg = white[1]
|
||||
wb = white[2]
|
||||
wa = white[3]
|
||||
|
||||
br = black[0]
|
||||
bg = black[1]
|
||||
bb = black[2]
|
||||
_renpy.bilinear(src, nsrc, sx, sy, sw, sh, precise=precise)
|
||||
|
||||
ramp = renpy.display.im.ramp
|
||||
sx = 0
|
||||
sy = 0
|
||||
sw = nsw
|
||||
sh = nsh
|
||||
src = nsrc
|
||||
|
||||
if can_linmap and br == 0 and bg == 0 and bb == 0:
|
||||
linmap(src, dst,
|
||||
wr + 1,
|
||||
wg + 1,
|
||||
wb + 1,
|
||||
wa + 1)
|
||||
else:
|
||||
map(src, dst,
|
||||
ramp(br, wr),
|
||||
ramp(bg, wg),
|
||||
ramp(bb, wb),
|
||||
ramp(0, wa))
|
||||
|
||||
else:
|
||||
|
||||
can_twomap = False
|
||||
|
||||
|
||||
if version >= 4008007:
|
||||
|
||||
can_munge = True
|
||||
|
||||
def alpha_munge(src, dst, amap):
|
||||
"""
|
||||
This samples the red channel from src, maps it through amap, and
|
||||
place it into the alpha channel of amap.
|
||||
"""
|
||||
|
||||
if src.get_size() != dst.get_size():
|
||||
return
|
||||
|
||||
red = byte_offset(src)[0]
|
||||
alpha = byte_offset(dst)[3]
|
||||
|
||||
if red is not None and alpha is not None:
|
||||
_renpy.alpha_munge(src, dst, red, alpha, amap)
|
||||
|
||||
else:
|
||||
|
||||
can_munge = False
|
||||
|
||||
def alpha_munge(src, dst, amap):
|
||||
return
|
||||
|
||||
|
||||
|
||||
if version >= 5006000:
|
||||
|
||||
can_bilinear_scale = True
|
||||
|
||||
def bilinear_scale(src, dst, sx=0, sy=0, sw=None, sh=None, dx=0, dy=0, dw=None, dh=None):
|
||||
|
||||
if sw is None:
|
||||
sw, sh = src.get_size()
|
||||
if dw is None:
|
||||
dw, dh = dst.get_size()
|
||||
|
||||
while True:
|
||||
|
||||
if sw <= dw * 2 and sh <= dh * 2:
|
||||
break
|
||||
|
||||
nsw = max(sw / 2, dw)
|
||||
nsh = max(sh / 2, dh)
|
||||
|
||||
nsrc = pygame.Surface((nsw, nsh), src.get_flags(), src)
|
||||
_renpy.bilinear(src, nsrc, sx, sy, sw, sh)
|
||||
sx = 0
|
||||
sy = 0
|
||||
sw = nsw
|
||||
sh = nsh
|
||||
src = nsrc
|
||||
|
||||
_renpy.bilinear(src, dst, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||
_renpy.bilinear(src, dst, sx, sy, sw, sh, dx, dy, dw, dh, precise=precise)
|
||||
|
||||
|
||||
transform = _renpy.transform
|
||||
|
||||
else:
|
||||
# Note: Blend requires all surfaces to be the same size.
|
||||
blend = _renpy.blend
|
||||
|
||||
def imageblend(a, b, dst, img, amap):
|
||||
red = byte_offset(img)[0]
|
||||
_renpy.imageblend(a, b, dst, img, red, amap)
|
||||
|
||||
can_bilinear_scale = False
|
||||
|
||||
def bilinear_scale(src, dst, sx=0, sy=0, sw=None, sh=None, dx=0, dy=0, dw=None, dh=None):
|
||||
return
|
||||
def colormatrix(src, dst, matrix):
|
||||
c = [ matrix[0:5], matrix[5:10], matrix[10:15], matrix[15:20] ]
|
||||
offs = byte_offset(src)
|
||||
|
||||
o = [ None ] * 4
|
||||
for i in range(0, 4):
|
||||
o[offs[i]] = i
|
||||
|
||||
_renpy.colormatrix(src, dst,
|
||||
c[o[0]][o[0]], c[o[0]][o[1]], c[o[0]][o[2]], c[o[0]][o[3]], c[o[0]][4],
|
||||
c[o[1]][o[0]], c[o[1]][o[1]], c[o[1]][o[2]], c[o[1]][o[3]], c[o[1]][4],
|
||||
c[o[2]][o[0]], c[o[2]][o[1]], c[o[2]][o[2]], c[o[2]][o[3]], c[o[2]][4],
|
||||
c[o[3]][o[0]], c[o[3]][o[1]], c[o[3]][o[2]], c[o[3]][o[3]], c[o[3]][4])
|
||||
|
||||
|
||||
def subpixel(src, dst, x, y):
|
||||
|
||||
shift = src.get_shifts()[3]
|
||||
_renpy.subpixel(src, dst, x, y, shift)
|
||||
|
||||
|
||||
|
||||
if version >= 5006006:
|
||||
can_transform = True
|
||||
transform = _renpy.transform
|
||||
else:
|
||||
can_transform = False
|
||||
|
||||
|
||||
|
||||
if version >= 6001000:
|
||||
# Note: Blend requires all surfaces to be the same size.
|
||||
can_blend = True
|
||||
blend = _renpy.blend
|
||||
|
||||
else:
|
||||
can_blend = False
|
||||
|
||||
|
||||
if version >= 6001000:
|
||||
|
||||
# Note: Blend requires all surfaces to be the same size.
|
||||
|
||||
can_imageblend = True
|
||||
|
||||
def imageblend(a, b, dst, img, amap):
|
||||
red = byte_offset(img)[0]
|
||||
_renpy.imageblend(a, b, dst, img, red, amap)
|
||||
|
||||
else:
|
||||
|
||||
can_imageblend = False
|
||||
|
||||
if version >= 6002001:
|
||||
|
||||
can_colormatrix = True
|
||||
|
||||
def colormatrix(src, dst, matrix):
|
||||
c = [ matrix[0:5], matrix[5:10], matrix[10:15], matrix[15:20] ]
|
||||
offs = byte_offset(src)
|
||||
|
||||
o = [ None ] * 4
|
||||
for i in range(0, 4):
|
||||
o[offs[i]] = i
|
||||
|
||||
_renpy.colormatrix(src, dst,
|
||||
c[o[0]][o[0]], c[o[0]][o[1]], c[o[0]][o[2]], c[o[0]][o[3]], c[o[0]][4],
|
||||
c[o[1]][o[0]], c[o[1]][o[1]], c[o[1]][o[2]], c[o[1]][o[3]], c[o[1]][4],
|
||||
c[o[2]][o[0]], c[o[2]][o[1]], c[o[2]][o[2]], c[o[2]][o[3]], c[o[2]][4],
|
||||
c[o[3]][o[0]], c[o[3]][o[1]], c[o[3]][o[2]], c[o[3]][o[3]], c[o[3]][4])
|
||||
|
||||
else:
|
||||
can_colormatrix = False
|
||||
|
||||
|
||||
if version >= 6009000:
|
||||
def subpixel(src, dst, x, y):
|
||||
|
||||
shift = renpy.game.interface.display.sample_surface.get_shifts()[3]
|
||||
_renpy.subpixel(src, dst, x, y, shift)
|
||||
|
||||
else:
|
||||
def subpixel(src, dst, x, y):
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
dst.blit(src, (int(x), int(y)))
|
||||
renpy.display.render.blit_lock.release()
|
||||
|
||||
if version >= 6009000:
|
||||
can_alpha_transform = True
|
||||
alpha_transform = _renpy.transform
|
||||
else:
|
||||
can_alpha_transform = False
|
||||
|
||||
|
||||
|
||||
+463
-62
@@ -22,95 +22,458 @@
|
||||
# This file contains displayables that move, zoom, rotate, or otherwise
|
||||
# transform displayables. (As well as displayables that support them.)
|
||||
|
||||
import time
|
||||
import math
|
||||
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
|
||||
import renpy
|
||||
from renpy.display.render import render, IDENTITY, Matrix2D
|
||||
from renpy.display.layout import Container
|
||||
|
||||
# Convert a position from cartesian to polar coordinates.
|
||||
def cartesian_to_polar(x, y, xaround, yaround):
|
||||
dx = x - xaround
|
||||
dy = y - yaround
|
||||
|
||||
radius = math.hypot(dx, dy)
|
||||
angle = math.atan2(dx, -dy) / math.pi * 180
|
||||
|
||||
if angle < 0:
|
||||
angle += 360
|
||||
|
||||
return angle, radius
|
||||
|
||||
def polar_to_cartesian(angle, radius, xaround, yaround):
|
||||
|
||||
angle = angle * math.pi / 180
|
||||
|
||||
dx = radius * math.sin(angle)
|
||||
dy = -radius * math.cos(angle)
|
||||
|
||||
x = type(xaround)(xaround + dx)
|
||||
y = type(yaround)(yaround + dy)
|
||||
|
||||
return x, y
|
||||
|
||||
|
||||
class TransformState(renpy.object.Object):
|
||||
|
||||
def __init__(self):
|
||||
self.alpha = 1
|
||||
self.rotate = None
|
||||
self.zoom = 1
|
||||
self.xzoom = 1
|
||||
self.yzoom = 1
|
||||
|
||||
self.xpos = 0
|
||||
self.ypos = 0
|
||||
self.xanchor = 0
|
||||
self.yanchor = 0
|
||||
|
||||
self.xaround = 0.0
|
||||
self.yaround = 0.0
|
||||
self.xanchoraround = 0.0
|
||||
self.yanchoraround = 0.0
|
||||
|
||||
self.subpixel = False
|
||||
|
||||
self.crop = None
|
||||
self.corner1 = None
|
||||
self.corner2 = None
|
||||
self.size = None
|
||||
|
||||
self.delay = 0
|
||||
|
||||
def take_state(self, ts):
|
||||
self.__dict__.update(ts.__dict__)
|
||||
|
||||
# Returns a dict, with p -> (old, new) where p is a property that
|
||||
# has changed between this object and the new object.
|
||||
def diff(self, ts):
|
||||
|
||||
rv = { }
|
||||
|
||||
for k, old in self.__dict__.iteritems():
|
||||
new = ts.__dict__[k]
|
||||
|
||||
if old != new:
|
||||
rv[k] = (old, new)
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
# These update various properties.
|
||||
def get_xalign(self):
|
||||
return self.xpos
|
||||
|
||||
def set_xalign(self, v):
|
||||
self.xpos = v
|
||||
self.xanchor = v
|
||||
|
||||
xalign = property(get_xalign, set_xalign)
|
||||
|
||||
def get_yalign(self):
|
||||
return self.ypos
|
||||
|
||||
def set_yalign(self, v):
|
||||
self.ypos = v
|
||||
self.yanchor = v
|
||||
|
||||
yalign = property(get_yalign, set_yalign)
|
||||
|
||||
def get_around(self):
|
||||
return (self.xaround, self.yaround)
|
||||
|
||||
def set_around(self, value):
|
||||
self.xaround, self.yaround = value
|
||||
self.xanchoraround, self.yanchoraround = None, None
|
||||
|
||||
def set_alignaround(self, value):
|
||||
self.xaround, self.yaround = value
|
||||
self.xanchoraround, self.yanchoraround = value
|
||||
|
||||
around = property(get_around, set_around)
|
||||
alignaround = property(get_around, set_alignaround)
|
||||
|
||||
def get_angle(self):
|
||||
angle, radius = cartesian_to_polar(self.xpos, self.ypos, self.xaround, self.yaround)
|
||||
return angle
|
||||
|
||||
def get_radius(self):
|
||||
angle, radius = cartesian_to_polar(self.xpos, self.ypos, self.xaround, self.yaround)
|
||||
return radius
|
||||
|
||||
def set_angle(self, value):
|
||||
angle, radius = cartesian_to_polar(self.xpos, self.ypos, self.xaround, self.yaround)
|
||||
angle = value
|
||||
self.xpos, self.ypos = polar_to_cartesian(angle, radius, self.xaround, self.yaround)
|
||||
|
||||
if self.xanchoraround:
|
||||
self.xanchor, self.yanchor = polar_to_cartesian(angle, radius, self.xaround, self.yaround)
|
||||
|
||||
def set_radius(self, value):
|
||||
angle, radius = cartesian_to_polar(self.xpos, self.ypos, self.xaround, self.yaround)
|
||||
radius = value
|
||||
self.xpos, self.ypos = polar_to_cartesian(angle, radius, self.xaround, self.yaround)
|
||||
|
||||
if self.xanchoraround:
|
||||
self.xanchor, self.yanchor = polar_to_cartesian(angle, radius, self.xaround, self.yaround)
|
||||
|
||||
angle = property(get_angle, set_angle)
|
||||
radius = property(get_radius, set_radius)
|
||||
|
||||
def get_pos(self):
|
||||
return self.xpos, self.ypos
|
||||
|
||||
def set_pos(self, value):
|
||||
self.xpos, self.ypos = value
|
||||
|
||||
pos = property(get_pos, set_pos)
|
||||
|
||||
def get_anchor(self):
|
||||
return self.xanchor, self.yanchor
|
||||
|
||||
def set_anchor(self, value):
|
||||
self.xanchor, self.yanchor = value
|
||||
|
||||
anchor = property(get_anchor, set_anchor)
|
||||
|
||||
def get_align(self):
|
||||
return self.xpos, self.ypos
|
||||
|
||||
def set_align(self, value):
|
||||
self.xanchor, self.yanchor = value
|
||||
self.xpos, self.ypos = value
|
||||
|
||||
align = property(get_align, set_align)
|
||||
|
||||
|
||||
|
||||
|
||||
class Proxy(object):
|
||||
"""
|
||||
This class proxies a field from the transform to its state.
|
||||
"""
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
def __get__(self, instance, owner):
|
||||
return getattr(instance.state, self.name)
|
||||
|
||||
def __set__(self, instance, value):
|
||||
return setattr(instance.state, self.name, value)
|
||||
|
||||
|
||||
class Transform(Container):
|
||||
|
||||
def __init__(self, child=None, function=None, alpha=1, rotate=None, zoom=1, xzoom=1, yzoom=1, **kwargs):
|
||||
__version__ = 3
|
||||
transform_event_responder = True
|
||||
|
||||
# Proxying things over to our state.
|
||||
alpha = Proxy("alpha")
|
||||
rotate = Proxy("rotate")
|
||||
zoom = Proxy("zoom")
|
||||
xzoom = Proxy("xzoom")
|
||||
yzoom = Proxy("yzoom")
|
||||
|
||||
xpos = Proxy("xpos")
|
||||
ypos = Proxy("ypos")
|
||||
xanchor = Proxy("xanchor")
|
||||
yanchor = Proxy("yanchor")
|
||||
|
||||
xalign = Proxy("xalign")
|
||||
yalign = Proxy("yalign")
|
||||
|
||||
around = Proxy("around")
|
||||
alignaround = Proxy("alignaround")
|
||||
angle = Proxy("angle")
|
||||
radius = Proxy("radius")
|
||||
|
||||
xaround = Proxy("xaround")
|
||||
yaround = Proxy("yaround")
|
||||
xanchoraround = Proxy("xanchoraround")
|
||||
yanchoraround = Proxy("yanchoraround")
|
||||
|
||||
pos = Proxy("pos")
|
||||
anchor = Proxy("anchor")
|
||||
align = Proxy("align")
|
||||
|
||||
crop = Proxy("crop")
|
||||
corner1 = Proxy("corner1")
|
||||
corner2 = Proxy("corner2")
|
||||
size = Proxy("size")
|
||||
|
||||
delay = Proxy("delay")
|
||||
|
||||
def after_upgrade(self, version):
|
||||
|
||||
if version < 1:
|
||||
self.active = False
|
||||
self.state = TransformState()
|
||||
|
||||
self.state.xpos = self.xpos or 0
|
||||
self.state.ypos = self.ypos or 0
|
||||
self.state.xanchor = self.xanchor or 0
|
||||
self.state.yanchor = self.yanchor or 0
|
||||
self.state.alpha = self.alpha
|
||||
self.state.rotate = self.rotate
|
||||
self.state.zoom = self.zoom
|
||||
self.state.xzoom = self.xzoom
|
||||
self.state.yzoom = self.yzoom
|
||||
|
||||
self.hide_request = False
|
||||
self.hide_response = True
|
||||
|
||||
if version < 2:
|
||||
self.st = 0
|
||||
self.at = 0
|
||||
|
||||
if version < 3:
|
||||
self.st_offset = 0
|
||||
self.at_offset = 0
|
||||
self.child_st_base = 0
|
||||
|
||||
if version < 4:
|
||||
self.style_arg = 'transform'
|
||||
|
||||
# Compatibility with old versions of the class.
|
||||
active = False
|
||||
|
||||
def __init__(self, child=None, function=None, style='transform', **kwargs):
|
||||
|
||||
# NOTE: When adding new parameters here, be sure they're
|
||||
# also used in called.
|
||||
|
||||
self.kwargs = kwargs
|
||||
self.kwargs.setdefault('style', 'transform')
|
||||
self.style_arg = style
|
||||
|
||||
super(Transform, self).__init__(**self.kwargs)
|
||||
super(Transform, self).__init__(style=style)
|
||||
|
||||
self.function = function
|
||||
|
||||
# Taken from the style by default.
|
||||
if child is not None:
|
||||
self.add(child)
|
||||
|
||||
self.xpos = None
|
||||
self.ypos = None
|
||||
self.xanchor = None
|
||||
self.yanchor = None
|
||||
self.state = TransformState()
|
||||
|
||||
# Taken from parameters.
|
||||
self.alpha = alpha
|
||||
self.rotate = rotate
|
||||
self.zoom = zoom
|
||||
self.xzoom = xzoom
|
||||
self.yzoom = yzoom
|
||||
# Apply the keyword arguments.
|
||||
for k, v in kwargs.iteritems():
|
||||
setattr(self.state, k, v)
|
||||
|
||||
# This is the matrix transforming our coordinates into child coordinates.
|
||||
self.forward = None
|
||||
|
||||
# Have we called the function at least once?
|
||||
self.active = False
|
||||
|
||||
# Have we been requested to hide?
|
||||
self.hide_request = False
|
||||
|
||||
# True if it's okay for us to hide.
|
||||
self.hide_response = True
|
||||
|
||||
self.st = 0
|
||||
self.at = 0
|
||||
self.st_offset = 0
|
||||
self.at_offset = 0
|
||||
|
||||
self.child_st_base = 0
|
||||
|
||||
|
||||
def take_state(self, t):
|
||||
"""
|
||||
Takes the transformation state from object t into this object.
|
||||
"""
|
||||
|
||||
self.state.take_state(t.state)
|
||||
|
||||
# Apply the keyword arguments.
|
||||
for k, v in self.kwargs.iteritems():
|
||||
setattr(self.state, k, v)
|
||||
|
||||
def take_execution_state(self, t):
|
||||
"""
|
||||
Takes the execution state from object t into this object. This is
|
||||
overridden by renpy.atl.TransformBase.
|
||||
"""
|
||||
|
||||
return
|
||||
|
||||
def hide(self, st, at):
|
||||
|
||||
if not self.hide_request:
|
||||
d = self()
|
||||
d.kwargs = { }
|
||||
d.take_state(self)
|
||||
d.take_execution_state(self)
|
||||
else:
|
||||
d = self
|
||||
|
||||
d.st_offset = self.st_offset
|
||||
d.at_offset = self.at_offset
|
||||
d.hide_request = True
|
||||
d.hide_response = True
|
||||
|
||||
if d.function is not None:
|
||||
d.function(d, st, at)
|
||||
|
||||
if not d.hide_response:
|
||||
renpy.display.render.redraw(d, 0)
|
||||
return d
|
||||
|
||||
def set_child(self, child):
|
||||
self.child = child
|
||||
self.child_st_base = self.st
|
||||
|
||||
def render(self, width, height, st, at):
|
||||
|
||||
# Should we perform clipping?
|
||||
clipping = False
|
||||
|
||||
# Preserve the illusion of linear time.
|
||||
if st == 0:
|
||||
self.st_offset = self.st
|
||||
if at == 0:
|
||||
self.at_offset = self.at
|
||||
|
||||
self.st = st = st + self.st_offset
|
||||
self.at = at = at + self.at_offset
|
||||
|
||||
# If we have to, call the function that updates this transform.
|
||||
if self.function is not None:
|
||||
|
||||
fr = self.function(self, st, at)
|
||||
|
||||
if fr is not None:
|
||||
renpy.display.render.redraw(self, fr)
|
||||
|
||||
cr = render(self.child, width, height, st, at)
|
||||
width, height = cr.get_size()
|
||||
|
||||
self.active = True
|
||||
|
||||
if self.state.size:
|
||||
width, height = self.state.size
|
||||
|
||||
if self.child is None:
|
||||
raise Exception("Transform does not have a child.")
|
||||
|
||||
cr = render(self.child, width, height, st - self.child_st_base, at)
|
||||
width, height = cr.get_size()
|
||||
|
||||
forward = IDENTITY
|
||||
reverse = IDENTITY
|
||||
xo = yo = 0
|
||||
|
||||
# Rotation first.
|
||||
if self.rotate is not None:
|
||||
|
||||
# Cropping.
|
||||
crop = self.state.crop
|
||||
if crop is None and self.state.corner1 and self.state.corner2:
|
||||
x1, y1 = self.state.corner1
|
||||
x2, y2 = self.state.corner2
|
||||
|
||||
minx = min(x1, x2)
|
||||
maxx = max(x1, x2)
|
||||
miny = min(y1, y2)
|
||||
maxy = max(y1, y2)
|
||||
|
||||
crop = (minx, miny, maxx - minx, maxy - miny)
|
||||
|
||||
if crop:
|
||||
|
||||
negative_xo, negative_yo, width, height = crop
|
||||
xo = -negative_xo
|
||||
yo = -negative_yo
|
||||
|
||||
clipping = True
|
||||
|
||||
if self.state.rotate:
|
||||
clipcr = renpy.display.render.Render(width, height)
|
||||
clipcr.subpixel_blit(cr, (xo, yo))
|
||||
clipcr.clipping = clipping
|
||||
xo = yo = 0
|
||||
cr = clipcr
|
||||
clipping = False
|
||||
|
||||
# Size.
|
||||
if self.state.size and self.state.size != (width, height):
|
||||
nw, nh = self.state.size
|
||||
xzoom = 1.0 * nw / width
|
||||
yzoom = 1.0 * nh / height
|
||||
forward = forward * Matrix2D(1.0 / xzoom, 0, 0, 1.0 / yzoom)
|
||||
reverse = Matrix2D(xzoom, 0, 0, yzoom) * reverse
|
||||
|
||||
xo = xo * xzoom
|
||||
yo = yo * yzoom
|
||||
|
||||
width, height = self.state.size
|
||||
|
||||
|
||||
# Rotation.
|
||||
if self.state.rotate is not None:
|
||||
|
||||
cw = width
|
||||
ch = height
|
||||
|
||||
width = height = math.hypot(cw, ch)
|
||||
angle = -self.rotate * math.pi / 180
|
||||
angle = -self.state.rotate * math.pi / 180
|
||||
|
||||
xdx = math.cos(angle)
|
||||
xdy = -math.sin(angle)
|
||||
ydx = -xdy
|
||||
ydy = xdx
|
||||
|
||||
forward = Matrix2D(xdx, xdy, ydx, ydy)
|
||||
forward = forward * Matrix2D(xdx, xdy, ydx, ydy)
|
||||
|
||||
xdx = math.cos(-angle)
|
||||
xdy = -math.sin(-angle)
|
||||
ydx = -xdy
|
||||
ydy = xdx
|
||||
|
||||
reverse = Matrix2D(xdx, xdy, ydx, ydy)
|
||||
reverse = Matrix2D(xdx, xdy, ydx, ydy) * reverse
|
||||
|
||||
xo, yo = reverse.transform(-cw / 2.0, -ch / 2.0)
|
||||
xo += width / 2.0
|
||||
yo += height / 2.0
|
||||
|
||||
if self.zoom != 1 or self.xzoom != 1 or self.yzoom != None:
|
||||
xzoom = self.zoom * self.xzoom
|
||||
yzoom = self.zoom * self.yzoom
|
||||
|
||||
xzoom = self.state.zoom * self.state.xzoom
|
||||
yzoom = self.state.zoom * self.state.yzoom
|
||||
|
||||
|
||||
if xzoom != 1 or yzoom != 1:
|
||||
|
||||
forward = forward * Matrix2D(1.0 / xzoom, 0, 0, 1.0 / yzoom)
|
||||
reverse = Matrix2D(xzoom, 0, 0, yzoom) * reverse
|
||||
@@ -128,16 +491,24 @@ class Transform(Container):
|
||||
|
||||
self.forward = forward
|
||||
|
||||
rv.alpha = self.alpha
|
||||
|
||||
rv.subpixel_blit(cr, (xo, yo), main=True)
|
||||
rv.alpha = self.state.alpha
|
||||
|
||||
rv.clipping = clipping
|
||||
|
||||
if self.state.subpixel:
|
||||
rv.subpixel_blit(cr, (xo, yo), main=True)
|
||||
else:
|
||||
rv.blit(cr, (xo, yo), main=True)
|
||||
|
||||
self.offsets = [ (xo, yo) ]
|
||||
|
||||
return rv
|
||||
|
||||
def event(self, ev, x, y, st):
|
||||
|
||||
if self.hide_request:
|
||||
return None
|
||||
|
||||
children = self.children
|
||||
offsets = self.offsets
|
||||
|
||||
@@ -158,42 +529,73 @@ class Transform(Container):
|
||||
|
||||
return None
|
||||
|
||||
def __call__(self, child):
|
||||
return Transform(
|
||||
def __call__(self, child=None, take_state=True):
|
||||
|
||||
if child is None:
|
||||
child = self.child
|
||||
|
||||
rv = Transform(
|
||||
child=child,
|
||||
function=self.function,
|
||||
alpha=self.alpha,
|
||||
rotate=self.rotate,
|
||||
zoom=self.zoom,
|
||||
xzoom=self.xzoom,
|
||||
yzoom=self.yzoom,
|
||||
style=self.style_arg,
|
||||
**self.kwargs)
|
||||
|
||||
rv.take_state(self)
|
||||
|
||||
return rv
|
||||
|
||||
def get_placement(self):
|
||||
xpos = self.xpos
|
||||
|
||||
if not self.active:
|
||||
if self.function is not None:
|
||||
fr = self.function(self, 0, 0)
|
||||
|
||||
if fr is not None:
|
||||
renpy.display.render.redraw(self, fr)
|
||||
|
||||
self.active = True
|
||||
|
||||
xpos = self.state.xpos
|
||||
if xpos is None:
|
||||
xpos = self.style.xpos
|
||||
|
||||
ypos = self.ypos
|
||||
ypos = self.state.ypos
|
||||
if ypos is None:
|
||||
ypos = self.style.ypos
|
||||
|
||||
xanchor = self.xanchor
|
||||
xanchor = self.state.xanchor
|
||||
if xanchor is None:
|
||||
xanchor = self.style.xanchor
|
||||
|
||||
yanchor = self.yanchor
|
||||
yanchor = self.state.yanchor
|
||||
if yanchor is None:
|
||||
yanchor = self.style.yanchor
|
||||
|
||||
return xpos, ypos, xanchor, yanchor, self.style.xoffset, self.style.yoffset, self.style.subpixel
|
||||
return xpos, ypos, xanchor, yanchor, self.style.xoffset, self.style.yoffset, self.state.subpixel
|
||||
|
||||
def update(self):
|
||||
renpy.display.render.invalidate(self)
|
||||
|
||||
def parameterize(self, name, parameters):
|
||||
if parameters:
|
||||
raise Exception("Image '%s' can't take parameters '%s'. (Perhaps you got the name wrong?)" %
|
||||
(' '.join(name), ' '.join(parameters)))
|
||||
|
||||
|
||||
# Note the call here.
|
||||
return self()
|
||||
|
||||
class ATLTransform(renpy.atl.ATLTransformBase, Transform):
|
||||
|
||||
def __init__(self, atl, child=None, context={}, parameters=None, style='transform'):
|
||||
renpy.atl.ATLTransformBase.__init__(self, atl, context, parameters)
|
||||
Transform.__init__(self, child=child, function=self.execute, style=style)
|
||||
|
||||
self.raw_child = self.child
|
||||
|
||||
def show(self):
|
||||
self.execute(self, 0, 0)
|
||||
|
||||
|
||||
class Motion(Container):
|
||||
"""
|
||||
This is used to move a child displayable around the screen. It
|
||||
@@ -612,7 +1014,7 @@ class Zoom(renpy.display.core.Displayable):
|
||||
self.after_child = None
|
||||
|
||||
self.time_warp = time_warp
|
||||
self.bilinear = bilinear and renpy.display.module.can_bilinear_scale
|
||||
self.bilinear = bilinear
|
||||
self.opaque = opaque
|
||||
self.anim_timebase = anim_timebase
|
||||
|
||||
@@ -694,7 +1096,8 @@ def zoom_core(rend, surf, rect, neww, newh, bilinear, opaque):
|
||||
|
||||
renpy.display.module.bilinear_scale(surf, dest,
|
||||
sx, sy, sw, sh,
|
||||
-x, -y, neww, newh)
|
||||
-x, -y, neww, newh,
|
||||
precise=1)
|
||||
|
||||
rv = renpy.display.render.Render(neww, newh, draw_func=draw, opaque=True)
|
||||
|
||||
@@ -704,15 +1107,16 @@ def zoom_core(rend, surf, rect, neww, newh, bilinear, opaque):
|
||||
if bilinear:
|
||||
sx, sy, sw, sh = rect
|
||||
|
||||
scalesurf = pygame.Surface((neww, newh), surf.get_flags(), surf)
|
||||
scalesurf = renpy.display.pgrender.surface((neww, newh), True)
|
||||
|
||||
renpy.display.module.bilinear_scale(surf, scalesurf,
|
||||
sx, sy, sw, sh,
|
||||
0, 0, neww, newh)
|
||||
0, 0, neww, newh,
|
||||
precise=1)
|
||||
else:
|
||||
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
scalesurf = pygame.transform.scale(surf.subsurface(rect), (neww, newh))
|
||||
scalesurf = renpy.display.pgrender.transform_scale(surf.subsurface(rect), (neww, newh))
|
||||
renpy.display.render.blit_lock.release()
|
||||
|
||||
renpy.display.render.mutated_surface(scalesurf)
|
||||
@@ -753,7 +1157,7 @@ class FactorZoom(renpy.display.core.Displayable):
|
||||
self.after_child = None
|
||||
|
||||
self.time_warp = time_warp
|
||||
self.bilinear = bilinear and renpy.display.module.can_bilinear_scale
|
||||
self.bilinear = bilinear
|
||||
self.opaque = opaque
|
||||
self.done = 0.0
|
||||
self.anim_timebase = anim_timebase
|
||||
@@ -838,7 +1242,7 @@ class SizeZoom(renpy.display.core.Displayable):
|
||||
self.after_child = None
|
||||
|
||||
self.time_warp = time_warp
|
||||
self.bilinear = bilinear and renpy.display.module.can_bilinear_scale
|
||||
self.bilinear = bilinear
|
||||
self.opaque = opaque
|
||||
self.done = 0.0
|
||||
self.anim_timebase = anim_timebase
|
||||
@@ -940,10 +1344,6 @@ class RotoZoom(renpy.display.core.Displayable):
|
||||
|
||||
def render(self, w, h, st, at):
|
||||
|
||||
if not renpy.display.module.can_transform:
|
||||
rv = renpy.display.render.Render(1, 1)
|
||||
return rv
|
||||
|
||||
if self.rot_anim_timebase:
|
||||
rot_time = at
|
||||
else:
|
||||
@@ -1032,8 +1432,9 @@ class RotoZoom(renpy.display.core.Displayable):
|
||||
culcy = ch / 2.0 + ydx * dulcx + ydy * dulcy
|
||||
|
||||
renpy.display.module.transform(surf, target,
|
||||
culcx, culcy,
|
||||
xdx, ydx, xdy, ydy)
|
||||
culcx, culcy,
|
||||
xdx, ydx, xdy, ydy,
|
||||
1.0, True)
|
||||
|
||||
rv = renpy.display.render.Render(dw, dh, draw_func=draw, opaque=self.opaque)
|
||||
rv.depends_on(child_rend)
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
# Copyright 2004-2009 PyTom <pytom@bishoujo.us>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation files
|
||||
# (the "Software"), to deal in the Software without restriction,
|
||||
# including without limitation the rights to use, copy, modify, merge,
|
||||
# publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
# and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# This module deals with pygame-specific rendering tasks.
|
||||
|
||||
import pygame
|
||||
import renpy
|
||||
|
||||
# This class is used to make a copy of a pygame module's functions. We
|
||||
# can then access those functions, and be relatively sure that those
|
||||
# have not changed.
|
||||
class ModuleProxy(object):
|
||||
def __init__(self, module):
|
||||
self.__dict__.update(module.__dict__)
|
||||
|
||||
opygame = ModuleProxy(pygame)
|
||||
opygame.display = ModuleProxy(pygame.display)
|
||||
opygame.transform = ModuleProxy(pygame.transform)
|
||||
opygame.image = ModuleProxy(pygame.image)
|
||||
|
||||
|
||||
# Sample surfaces, with and without alpha.
|
||||
sample_alpha = None
|
||||
sample_noalpha = None
|
||||
|
||||
def set_mode(resolution, flags=0, depth=0):
|
||||
"""
|
||||
Sets the mode of the pygame screen, and creates the sample
|
||||
surfaces.
|
||||
"""
|
||||
|
||||
global sample_alpha
|
||||
global sample_noalpha
|
||||
|
||||
rv = opygame.display.set_mode(resolution, flags, depth)
|
||||
|
||||
s = opygame.Surface((10, 10))
|
||||
sample_alpha = s.convert_alpha(rv)
|
||||
sample_noalpha = s.convert(rv)
|
||||
|
||||
return rv
|
||||
|
||||
set_mode_unscaled = set_mode
|
||||
|
||||
class Surface(opygame.Surface):
|
||||
"""
|
||||
This allows us to wrap around pygame's surface, to change
|
||||
its mode, as necessary.
|
||||
"""
|
||||
|
||||
def convert_alpha(self, surface=None):
|
||||
return copy_surface_unscaled(self, True)
|
||||
|
||||
def convert(self, surface=None):
|
||||
return copy_surface(self, False)
|
||||
|
||||
def copy(self):
|
||||
return copy_surface(self, self)
|
||||
|
||||
|
||||
def surface((width, height), alpha):
|
||||
"""
|
||||
Constructs a new surface. The allocated surface is actually a subsurface
|
||||
of a surface that has a 1 pixel border in all directions.
|
||||
|
||||
`alpha` - True if the new surface should have an alpha channel.
|
||||
"""
|
||||
|
||||
if isinstance(alpha, opygame.Surface):
|
||||
alpha = alpha.get_masks()[3]
|
||||
|
||||
if alpha:
|
||||
sample = sample_alpha
|
||||
else:
|
||||
sample = sample_noalpha
|
||||
|
||||
# We might not have initialized properly yet. This is enough
|
||||
# to get us underway.
|
||||
if sample is None:
|
||||
sample = opygame.Surface((2, 2), opygame.SRCALPHA, 32)
|
||||
|
||||
surf = Surface((width + 2, height + 2), 0, sample)
|
||||
return surf.subsurface((1, 1, width, height))
|
||||
|
||||
surface_unscaled = surface
|
||||
|
||||
|
||||
def copy_surface(surf, alpha=True):
|
||||
"""
|
||||
Creates a copy of the surface.
|
||||
"""
|
||||
|
||||
rv = surface_unscaled(surf.get_size(), alpha)
|
||||
|
||||
renpy.display.render.blit_lock.acquire()
|
||||
rv.blit(surf, (0, 0))
|
||||
renpy.display.render.blit_lock.release()
|
||||
|
||||
return rv
|
||||
|
||||
copy_surface_unscaled = copy_surface
|
||||
|
||||
|
||||
# Wrapper around image loading.
|
||||
|
||||
def load_image(f, filename):
|
||||
surf = opygame.image.load(f, filename)
|
||||
return copy_surface_unscaled(surf)
|
||||
|
||||
load_image_unscaled = load_image
|
||||
|
||||
|
||||
# Wrapper around functions we use from pygame.surface.
|
||||
|
||||
def flip(surf, horizontal, vertical):
|
||||
surf = opygame.transform.flip(surf, horizontal, vertical)
|
||||
return copy_surface_unscaled(surf)
|
||||
|
||||
flip_unscaled = flip
|
||||
|
||||
|
||||
def rotozoom(surf, angle, zoom):
|
||||
|
||||
surf = opygame.transform.rotozoom(surf, angle, zoom)
|
||||
return copy_surface_unscaled(surf)
|
||||
|
||||
rotozoom_unscaled = rotozoom
|
||||
|
||||
|
||||
def transform_scale(surf, size):
|
||||
surf = opygame.transform.scale(surf, size)
|
||||
return copy_surface_unscaled(surf, surf)
|
||||
|
||||
transform_scale_unscaled = transform_scale
|
||||
|
||||
|
||||
def transform_rotate(surf, angle):
|
||||
surf = opygame.transform.rotate(surf, angle)
|
||||
return copy_surface(surf)
|
||||
|
||||
transform_rotate_unscaled = transform_rotate
|
||||
|
||||
|
||||
|
||||
+128
-32
@@ -20,11 +20,9 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import collections
|
||||
import time
|
||||
import pygame
|
||||
import threading
|
||||
import math
|
||||
|
||||
import renpy
|
||||
|
||||
|
||||
@@ -94,6 +92,7 @@ def check_at_shutdown():
|
||||
return
|
||||
|
||||
free_memory()
|
||||
|
||||
if render_count != 0:
|
||||
raise Exception("Render count is %d at shutdown. This probably indicates a memory leak bug in Ren'Py." % render_count)
|
||||
|
||||
@@ -111,7 +110,7 @@ def render(d, width, height, st, at):
|
||||
rv = render_cache[d].get(orig_wh, None)
|
||||
if rv is not None:
|
||||
return rv
|
||||
|
||||
|
||||
style = d.style
|
||||
xmaximum = style.xmaximum
|
||||
ymaximum = style.ymaximum
|
||||
@@ -189,7 +188,7 @@ def process_redraws():
|
||||
|
||||
new_redraw_queue = [ ]
|
||||
seen = set()
|
||||
|
||||
|
||||
for t in redraw_queue:
|
||||
when, d = t
|
||||
|
||||
@@ -205,7 +204,7 @@ def process_redraws():
|
||||
# Remove this displayable and all its parents from the
|
||||
# render cache. But don't kill them yet, as that will kill the
|
||||
# children that we want to reuse.
|
||||
|
||||
|
||||
for v in render_cache[d].values():
|
||||
v.kill_cache()
|
||||
|
||||
@@ -215,8 +214,8 @@ def process_redraws():
|
||||
new_redraw_queue.append(t)
|
||||
|
||||
redraw_queue = new_redraw_queue
|
||||
|
||||
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
@@ -461,7 +460,7 @@ class Clipper(object):
|
||||
|
||||
updates.append((ix0, iy0, ix1 - ix0, iy1 - iy0))
|
||||
|
||||
|
||||
|
||||
return (x0, y0, x1 - x0, y1 - y0), updates
|
||||
|
||||
clippers = [ Clipper() ]
|
||||
@@ -614,18 +613,25 @@ def draw(dest, clip, what, xo, yo, screen):
|
||||
|
||||
def draw_transformed(dest, clip, what, xo, yo, alpha, forward, reverse):
|
||||
|
||||
# If our alpha has hit 0, don't do anything.
|
||||
if alpha <= 0.003: # (1 / 256)
|
||||
return
|
||||
|
||||
if forward is None:
|
||||
forward = IDENTITY
|
||||
reverse = IDENTITY
|
||||
|
||||
if not isinstance(what, Render):
|
||||
|
||||
if not renpy.display.module.can_alpha_transform:
|
||||
return
|
||||
|
||||
# Figure out where the other corner of the transformed surface
|
||||
# is on the screen.
|
||||
sw, sh = what.get_size()
|
||||
if clip:
|
||||
|
||||
dx0, dy0, dx1, dy1 = clip
|
||||
dw = dx1 - dx0
|
||||
dh = dy1 - dy0
|
||||
|
||||
else:
|
||||
dw, dh = dest.get_size()
|
||||
|
||||
@@ -639,6 +645,7 @@ def draw_transformed(dest, clip, what, xo, yo, alpha, forward, reverse):
|
||||
miny = math.floor(min(y0, y1, y2, y3) + yo)
|
||||
maxy = math.ceil(max(y0, y1, y2, y3) + yo)
|
||||
|
||||
|
||||
if minx < 0:
|
||||
minx = 0
|
||||
if miny < 0:
|
||||
@@ -655,31 +662,89 @@ def draw_transformed(dest, clip, what, xo, yo, alpha, forward, reverse):
|
||||
cx, cy = forward.transform(minx - xo, miny - yo)
|
||||
|
||||
if clip:
|
||||
|
||||
dest.blits.append(
|
||||
(minx, miny, maxx, maxy, clip, what,
|
||||
(minx, miny, maxx + dx0, maxy + dy0, clip, what,
|
||||
(cx, cy,
|
||||
forward.xdx, forward.ydx,
|
||||
forward.xdy, forward.ydy,
|
||||
alpha)))
|
||||
|
||||
else:
|
||||
|
||||
dest = dest.subsurface((minx, miny, maxx - minx, maxy - miny))
|
||||
|
||||
renpy.display.module.alpha_transform(
|
||||
|
||||
renpy.display.module.transform(
|
||||
what, dest,
|
||||
cx, cy,
|
||||
forward.xdx, forward.ydx,
|
||||
forward.xdy, forward.ydy,
|
||||
alpha)
|
||||
alpha, True)
|
||||
|
||||
return
|
||||
|
||||
if what.clipping:
|
||||
raise Exception("Clipping a transformed surface is not supported.")
|
||||
|
||||
if reverse.xdy or reverse.ydx:
|
||||
draw_transformed(dest, clip, what.pygame_surface(True), xo, yo, alpha, forward, reverse)
|
||||
return
|
||||
|
||||
|
||||
# raise Exception("Non-axis-aligned clipping is not supported.")
|
||||
|
||||
|
||||
|
||||
width = what.width * reverse.xdx
|
||||
height = what.height * reverse.ydy
|
||||
|
||||
if clip:
|
||||
cx0, cy0, cx1, cy1 = clip
|
||||
|
||||
cx0 = max(cx0, xo)
|
||||
cy0 = max(cy0, yo)
|
||||
cx1 = min(cx1, xo + width)
|
||||
cy1 = min(cy1, yo + height)
|
||||
|
||||
if cx0 > cx1 or cy0 > cy1:
|
||||
return
|
||||
|
||||
clip = (cx0, cy0, cx1, cy1)
|
||||
|
||||
else:
|
||||
|
||||
# After this code, x and y are the coordinates of the subsurface
|
||||
# relative to the destination. xo and yo are the offset of the
|
||||
# upper-left corner relative to the subsurface.
|
||||
|
||||
if xo >= 0:
|
||||
x = xo
|
||||
xo = 0
|
||||
else:
|
||||
x = 0
|
||||
# xo = xo
|
||||
|
||||
if yo >= 0:
|
||||
y = yo
|
||||
yo = 0
|
||||
else:
|
||||
y = 0
|
||||
# yo = yo
|
||||
|
||||
dw, dh = dest.get_size()
|
||||
|
||||
width = min(dw - x, width + xo)
|
||||
height = min(dh - y, height + yo)
|
||||
|
||||
if width < 0 or height < 0:
|
||||
return
|
||||
|
||||
dest = dest.subsurface((x, y, width, height))
|
||||
|
||||
|
||||
if what.draw_func:
|
||||
raise Exception("Using a draw_func on a transformed surface is not supported.")
|
||||
child = what.pygame_surface(True)
|
||||
draw_transformed(dest, clip, child, xo, yo, alpha, forward, reverse)
|
||||
|
||||
# raise Exception("Using a draw_func on a transformed surface is not supported.")
|
||||
|
||||
for child, cxo, cyo, focus, main in what.visible_children:
|
||||
|
||||
@@ -695,13 +760,12 @@ def draw_transformed(dest, clip, what, xo, yo, alpha, forward, reverse):
|
||||
draw_transformed(dest, clip, child, xo + cxo, yo + cyo, alpha * what.alpha, child_forward, child_reverse)
|
||||
|
||||
|
||||
|
||||
def render_screen(root, width, height):
|
||||
"""
|
||||
Renders `root` (a displayable) as the root of a screen with the given
|
||||
`width` and `height`.
|
||||
"""
|
||||
|
||||
|
||||
global old_screen_render
|
||||
global screen_render
|
||||
global invalidated
|
||||
@@ -713,14 +777,14 @@ def render_screen(root, width, height):
|
||||
screen_render.refcount += 1
|
||||
|
||||
invalidated = False
|
||||
|
||||
|
||||
return rv
|
||||
|
||||
def draw_screen(xoffset, yoffset, full_redraw):
|
||||
"""
|
||||
Draws the render produced by render_screen to the screen.
|
||||
"""
|
||||
|
||||
|
||||
screen_render.is_opaque()
|
||||
|
||||
clip = (xoffset, yoffset, xoffset + screen_render.width, yoffset + screen_render.height)
|
||||
@@ -775,7 +839,7 @@ def take_focuses(focuses):
|
||||
screen_render.take_focuses(
|
||||
0, 0, screen_render.width, screen_render.height,
|
||||
IDENTITY, 0, 0, focuses)
|
||||
|
||||
|
||||
def focus_at_point(x, y):
|
||||
"""
|
||||
Returns a focus object corresponding to the uppermost displayable
|
||||
@@ -797,6 +861,28 @@ def mutated_surface(surf):
|
||||
|
||||
for i in clippers:
|
||||
i.mutated.add(id(surf))
|
||||
|
||||
# Possible operations that can be done as part of a render.
|
||||
|
||||
# Blit the children one on top of another.
|
||||
BLIT = 0
|
||||
|
||||
# Dissolve between the first and second children, using the dissolve
|
||||
# parameter. The children need to be opaque.
|
||||
OPAQUE_DISSOLVE = 1
|
||||
|
||||
# Dissolve between the first and second children, using the dissolve
|
||||
# parameter.
|
||||
ALPHA_DISSOLVE = 2
|
||||
|
||||
# Dissolve between the first and second children, using the third child
|
||||
# as a mask image. The children need to be opaque.
|
||||
OPAQUE_IMAGE_DISSOLVE = 3
|
||||
|
||||
# Dissolve between the first and second children, using the third child
|
||||
# as a mask image.
|
||||
ALPHA_IMAGE_DISSOLVE = 4
|
||||
|
||||
|
||||
class Render(object):
|
||||
|
||||
@@ -833,6 +919,13 @@ class Render(object):
|
||||
|
||||
# len(self.parents) + len(self.depends_on_us)
|
||||
self.refcount = 0
|
||||
|
||||
# The operation we're performing.
|
||||
self.operation = BLIT
|
||||
|
||||
# If the operation is one of the DISSOLVES, this controls the
|
||||
# amount of the new image we'll be using.
|
||||
self.dissolve = 0.0
|
||||
|
||||
# These are Matrix2D objects used to transform the children of
|
||||
# this render. If None, then no transformation is done. Otherwise,
|
||||
@@ -886,6 +979,16 @@ class Render(object):
|
||||
self.surface = None
|
||||
self.alpha_surface = None
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
if self.dead:
|
||||
dead = "dead"
|
||||
else:
|
||||
dead = "live"
|
||||
|
||||
return "<Render %x %s of %r>" % (id(self), dead, self.render_of)
|
||||
|
||||
|
||||
def blit(self, source, (xo, yo), focus=True, main=True):
|
||||
"""
|
||||
Blits `source` (a Render or Surface) to this Render, offset by
|
||||
@@ -975,15 +1078,11 @@ class Render(object):
|
||||
# Otherwise, draw the current surface.
|
||||
if rv is None:
|
||||
|
||||
if alpha:
|
||||
sample = renpy.game.interface.display.sample_surface
|
||||
else:
|
||||
sample = renpy.game.interface.display.window
|
||||
|
||||
# Compute opacity information, as necessary.
|
||||
self.is_opaque()
|
||||
|
||||
rv = pygame.Surface((self.width, self.height), 0, sample)
|
||||
rv = renpy.display.pgrender.surface((self.width, self.height), alpha)
|
||||
|
||||
draw(rv, None, self, 0, 0, False)
|
||||
|
||||
# Stash and return the surface.
|
||||
@@ -1333,11 +1432,8 @@ class Render(object):
|
||||
"""
|
||||
Returns a canvas object that draws to this Render.
|
||||
"""
|
||||
surf = pygame.Surface(
|
||||
(self.width, self.height),
|
||||
renpy.game.interface.display.sample_surface.get_flags(),
|
||||
renpy.game.interface.display.sample_surface)
|
||||
|
||||
surf = renpy.display.pgrender.surface((self.width, self.height), True)
|
||||
mutated_surface(surf)
|
||||
|
||||
self.blit(surf, (0, 0))
|
||||
|
||||
+298
-282
@@ -25,20 +25,15 @@ import os
|
||||
import math
|
||||
import pygame
|
||||
import renpy
|
||||
import renpy.display.pgrender as pgrender
|
||||
|
||||
|
||||
# These need to be here before we mess with Pygame.
|
||||
import _renpy_font
|
||||
import _renpy
|
||||
|
||||
# Store this before we change it.
|
||||
PygameSurface = pygame.Surface
|
||||
|
||||
try:
|
||||
import _renpy_font as font_module
|
||||
except ImportError:
|
||||
import pygame.font as font_module
|
||||
|
||||
# This needs to be done before we mess too hard with pygame.
|
||||
try:
|
||||
import _renpy
|
||||
except ImportError:
|
||||
_renpy = None
|
||||
|
||||
# The factor we're scaling by.
|
||||
factor = 1.0
|
||||
@@ -59,80 +54,70 @@ def scale(n):
|
||||
return n
|
||||
|
||||
def real_bilinear(src, size):
|
||||
rv = pygame.Surface(size, 0, src)
|
||||
rv = pgrender.surface_unscaled(size, src)
|
||||
renpy.display.module.bilinear_scale(src, rv)
|
||||
return rv
|
||||
|
||||
# Does pygame.transform.scale.
|
||||
def real_transform_scale(surf, size):
|
||||
global real_transform_scale
|
||||
real_transform_scale = pygame.transform.scale
|
||||
return real_transform_scale(surf, size)
|
||||
return pgrender.transform_scale_unscaled(surf, size)
|
||||
|
||||
# Loads an image, without scaling it.
|
||||
def image_load_unscaled(f, hint, convert=True):
|
||||
rv = pygame.image.load(f, hint)
|
||||
|
||||
if convert:
|
||||
rv = rv.convert_alpha()
|
||||
|
||||
rv = pgrender.load_image_unscaled(f, hint)
|
||||
return rv
|
||||
|
||||
# Scales down a surface.
|
||||
def surface_scale(full):
|
||||
return full
|
||||
|
||||
# Saves an image without rescaling.
|
||||
def image_save_unscaled(surf, dest):
|
||||
pygame.image.save(surf, dest)
|
||||
|
||||
# Scales down a surface.
|
||||
def surface_scale(full):
|
||||
return full
|
||||
|
||||
if _renpy:
|
||||
real_renpy_pixellate = _renpy.pixellate
|
||||
real_renpy_transform = _renpy.transform
|
||||
real_renpy_pixellate = _renpy.pixellate
|
||||
real_renpy_transform = _renpy.transform
|
||||
|
||||
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.
|
||||
"""
|
||||
def real_smoothscale(src, size, dest=None):
|
||||
"""
|
||||
This scales src up or down to size. This uses both the pixellate
|
||||
and the transform operations to handle the scaling.
|
||||
"""
|
||||
|
||||
width, height = size
|
||||
srcwidth, srcheight = src.get_size()
|
||||
iwidth, iheight = srcwidth, srcheight
|
||||
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_transform(src, dest,
|
||||
0, 0,
|
||||
1.0 * iwidth / width , 0,
|
||||
0, 1.0 * iheight / height,
|
||||
)
|
||||
if dest is None:
|
||||
dest = pgrender.surface_unscaled(size, src)
|
||||
|
||||
if width == 0 or height == 0:
|
||||
return dest
|
||||
|
||||
else:
|
||||
real_smoothscale = pygame.transform.smoothscale
|
||||
|
||||
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 = pgrender.surface_unscaled((iwidth, iheight), src)
|
||||
real_renpy_pixellate(src, inter, xshrink, yshrink, 1, 1)
|
||||
src = inter
|
||||
|
||||
real_renpy_transform(src, dest,
|
||||
0, 0,
|
||||
1.0 * iwidth / width , 0,
|
||||
0, 1.0 * iheight / height,
|
||||
precise=1,
|
||||
)
|
||||
|
||||
return dest
|
||||
|
||||
smoothscale = real_smoothscale
|
||||
|
||||
@@ -190,12 +175,12 @@ def load_scaling():
|
||||
def real(s):
|
||||
return s.surface
|
||||
|
||||
|
||||
|
||||
def same_size(*args):
|
||||
"""
|
||||
If all the surfaces in args are the same size, return them all
|
||||
unchanged. Otherwise, compute smallest width and height, and
|
||||
take subsurfaces of anythign bigger.
|
||||
take subsurfaces of anything bigger.
|
||||
"""
|
||||
|
||||
w = min(i.get_width() for i in args)
|
||||
@@ -212,6 +197,7 @@ def load_scaling():
|
||||
rv.append(i)
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
def scale(n):
|
||||
if n is None:
|
||||
@@ -219,29 +205,17 @@ def load_scaling():
|
||||
|
||||
return int(n * factor)
|
||||
|
||||
def real_bilinear(src, size):
|
||||
rv = PygameSurface(size, 0, src)
|
||||
old_bilinear(src, rv)
|
||||
return rv
|
||||
|
||||
def real_transform_scale(surf, size):
|
||||
return old_transform_scale(surf, size)
|
||||
|
||||
def image_load_unscaled(f, hint, convert=True):
|
||||
rv = old_image_load(f, hint)
|
||||
if convert:
|
||||
rv = rv.convert_alpha()
|
||||
return rv
|
||||
|
||||
|
||||
def surface_scale(full):
|
||||
|
||||
if scale_fast:
|
||||
scaled = old_transform_scale(full, v2p(full.get_size()))
|
||||
scaled = real_transform_scale(full, v2p(full.get_size()))
|
||||
else:
|
||||
scaled = real_smoothscale(full, v2p(full.get_size()))
|
||||
|
||||
return Surface(scaled, wh=full.get_size())
|
||||
return ScaledSurface(scaled, wh=full.get_size())
|
||||
|
||||
|
||||
# Project a tuple from virtual to physical coordinates.
|
||||
def v2p(n):
|
||||
if n is None:
|
||||
@@ -249,6 +223,7 @@ def load_scaling():
|
||||
|
||||
return tuple([ int(i * factor) for i in n ])
|
||||
|
||||
|
||||
# Similar, but include an extra pixel to deal with rounding.
|
||||
def v2pplus(n):
|
||||
|
||||
@@ -257,6 +232,7 @@ def load_scaling():
|
||||
|
||||
return tuple([ int(i * factor) + k for i, k in zip(n, (0, 0, 1, 1)) ])
|
||||
|
||||
|
||||
# Project a tuple from physical to virtual coordinates.
|
||||
def p2v(n):
|
||||
if n is None:
|
||||
@@ -264,17 +240,37 @@ def load_scaling():
|
||||
|
||||
return tuple([ int(i / factor) for i in n ])
|
||||
|
||||
# Proxies a function call from a PygameSurface to a surface.
|
||||
|
||||
def set_mode((w, h), flags, bpp):
|
||||
|
||||
global screen
|
||||
|
||||
width = int(w * factor)
|
||||
height = int(h * factor)
|
||||
|
||||
real_screen = pgrender.set_mode_unscaled((width, height), flags, bpp)
|
||||
screen = ScaledSurface(real_screen, wh=(w, h))
|
||||
|
||||
return screen
|
||||
|
||||
pgrender.set_mode = set_mode
|
||||
pygame.display.set_mode = set_mode
|
||||
|
||||
|
||||
# Proxies a function call from a Surface to a pygame surface.
|
||||
def proxy(name):
|
||||
func = getattr(PygameSurface, name)
|
||||
def rv(self, *args, **kwargs):
|
||||
return func(self.surface, *args, **kwargs)
|
||||
|
||||
return rv
|
||||
|
||||
class Surface(object):
|
||||
|
||||
def __init__(self, what, flags=0, sample=None, wh=None):
|
||||
|
||||
# When scaling is enabled, objects of this class are returned from
|
||||
# pgrender.surface instead of pygame surfaces.
|
||||
class ScaledSurface(object):
|
||||
|
||||
def __init__(self, what, alpha=True, wh=None):
|
||||
|
||||
if isinstance(what, PygameSurface):
|
||||
self.surface = what
|
||||
@@ -297,20 +293,14 @@ def load_scaling():
|
||||
w = int(w * factor)
|
||||
h = int(h * factor)
|
||||
|
||||
if sample is None:
|
||||
sample = screen
|
||||
|
||||
if not isinstance(sample, PygameSurface):
|
||||
sample = sample.surface
|
||||
|
||||
self.surface = PygameSurface((w, h), flags, sample)
|
||||
self.surface = pgrender.surface_unscaled((w, h), alpha)
|
||||
|
||||
self.virtx = 0
|
||||
self.virty = 0
|
||||
self.physx = 0
|
||||
self.physy = 0
|
||||
|
||||
|
||||
|
||||
def transform_pos(self, (x, y)):
|
||||
"""
|
||||
Converts a virtual position into a physical one.
|
||||
@@ -327,6 +317,7 @@ def load_scaling():
|
||||
|
||||
return (x0 - self.physx, y0 - self.physy)
|
||||
|
||||
|
||||
def transform_rect(self, (x, y, w, h)):
|
||||
"""
|
||||
Converts a virtual rectangle into a physical one.
|
||||
@@ -353,8 +344,9 @@ def load_scaling():
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return "<scale.Surface %r %r>" % (self.get_size(), self.surface)
|
||||
return "<ScaledSurface %r %r>" % (self.get_size(), self.surface)
|
||||
|
||||
|
||||
def blit(self, s, destpos, sourcerect=None):
|
||||
|
||||
if sourcerect is None:
|
||||
@@ -367,25 +359,19 @@ def load_scaling():
|
||||
self.transform_pos(destpos),
|
||||
self.transform_rect(sourcerect))
|
||||
|
||||
def convert(self, *args):
|
||||
if args:
|
||||
args = (args[0].surface,)
|
||||
return Surface(self.surface.convert(*args), wh=self.get_size())
|
||||
|
||||
def convert_alpha(self, *args):
|
||||
if args:
|
||||
args = (args[0].surface,)
|
||||
return Surface(self.surface.convert_alpha(*args), wh=self.get_size())
|
||||
|
||||
def copy(self):
|
||||
return Surface(self.surface.copy(), wh=self.get_size())
|
||||
return ScaledSurface(self.surface.copy(), wh=self.get_size())
|
||||
|
||||
|
||||
def fill(self, color):
|
||||
self.surface.fill(color)
|
||||
|
||||
|
||||
def get_alpha(self):
|
||||
return self.surface.get_alpha()
|
||||
|
||||
|
||||
def get_at(self, pos):
|
||||
x, y = self.transform_pos(pos)
|
||||
w, h = self.surface.get_size()
|
||||
@@ -393,19 +379,13 @@ def load_scaling():
|
||||
return self.surface.get_at((min(x, w - 1), min(y, h - 1)))
|
||||
|
||||
|
||||
get_colorkey = proxy("get_colorkey")
|
||||
set_colorkey = proxy("set_colorkey")
|
||||
get_alpha = proxy("get_alpha")
|
||||
set_alpha = proxy("set_alpha")
|
||||
get_locked = proxy("get_locked")
|
||||
get_locks = proxy("get_locks")
|
||||
map_rgb = proxy("map_rgb")
|
||||
unmap_rgb = proxy("unmap_rgb")
|
||||
get_bytesize = proxy("get_bytesize")
|
||||
get_bitsize = proxy("get_bitsize")
|
||||
get_flags = proxy("get_flags")
|
||||
get_pitch = proxy("get_pitch")
|
||||
get_masks = proxy("get_masks")
|
||||
set_masks = proxy("set_masks")
|
||||
get_shifts = proxy("get_shifts")
|
||||
set_shifts = proxy("set_shifts")
|
||||
@@ -429,7 +409,7 @@ def load_scaling():
|
||||
|
||||
def get_size(self):
|
||||
return (self.width, self.height)
|
||||
|
||||
|
||||
def set_alpha(self, alpha, flags):
|
||||
self.surface.set_alpha(alpha, flags)
|
||||
|
||||
@@ -438,7 +418,7 @@ def load_scaling():
|
||||
prect = self.transform_rect(rect)
|
||||
surf = self.surface.subsurface(prect)
|
||||
|
||||
rv = Surface(surf, wh=rect[2:])
|
||||
rv = ScaledSurface(surf, wh=rect[2:])
|
||||
|
||||
vx, vy, vw, vh = rect
|
||||
px, py, pw, ph = prect
|
||||
@@ -459,9 +439,6 @@ def load_scaling():
|
||||
def unlock(self):
|
||||
pass
|
||||
|
||||
def mustlock(self):
|
||||
return False
|
||||
|
||||
def get_locked(self):
|
||||
return False
|
||||
|
||||
@@ -474,23 +451,27 @@ def load_scaling():
|
||||
|
||||
return rv
|
||||
|
||||
pygame.Surface = Surface
|
||||
pgrender.surface = ScaledSurface
|
||||
|
||||
old_set_mode = pygame.display.set_mode
|
||||
|
||||
def set_mode((w, h), flags, bpp):
|
||||
def copy_surface(surf, alpha=True):
|
||||
# We don't need to unbox alpha, since all relevant methods
|
||||
# are proxied.
|
||||
|
||||
global screen
|
||||
new_surf = pgrender.copy_surface_unscaled(surf.surface, alpha)
|
||||
return ScaledSurface(new_surf, wh=(surf.width, surf.height))
|
||||
|
||||
width = int(w * factor)
|
||||
height = int(h * factor)
|
||||
pgrender.copy_surface = copy_surface
|
||||
|
||||
|
||||
|
||||
screen = Surface(old_set_mode((width, height), flags, bpp), wh=(w, h))
|
||||
|
||||
return screen
|
||||
|
||||
pygame.display.set_mode = set_mode
|
||||
def pygame_surface(size, flags, sample):
|
||||
return ScaledSurface(size, sample)
|
||||
|
||||
pygame.Surface = pygame_surface
|
||||
|
||||
|
||||
|
||||
old_update = pygame.display.update
|
||||
|
||||
def update(rects=None):
|
||||
@@ -505,83 +486,70 @@ def load_scaling():
|
||||
|
||||
pygame.display.update = update
|
||||
|
||||
|
||||
def get_surface():
|
||||
return screen
|
||||
|
||||
pygame.display.get_surface = get_surface
|
||||
|
||||
old_image_load = pygame.image.load
|
||||
|
||||
def image_load(*args, **kwargs):
|
||||
|
||||
full = old_image_load(*args, **kwargs)
|
||||
full = full.convert_alpha()
|
||||
|
||||
|
||||
def load_image(f, filename):
|
||||
full = pgrender.load_image_unscaled(f, filename)
|
||||
return surface_scale(full)
|
||||
|
||||
|
||||
pygame.image.load = image_load
|
||||
|
||||
old_transform_scale = pygame.transform.scale
|
||||
pgrender.load_image = load_image
|
||||
pygame.image.load = load_image
|
||||
|
||||
|
||||
def transform_scale(surf, size):
|
||||
|
||||
rv = old_transform_scale(surf.surface, v2p(size))
|
||||
rv = Surface(rv, wh=size)
|
||||
rv = pgrender.transform_scale_unscaled(surf.surface, v2p(size))
|
||||
rv = ScaledSurface(rv, wh=size)
|
||||
|
||||
return rv
|
||||
|
||||
pgrender.transform_scale = transform_scale
|
||||
pygame.transform.scale = transform_scale
|
||||
|
||||
old_transform_smoothscale = pygame.transform.smoothscale
|
||||
|
||||
def transform_smoothscale(surf, size, dest=None):
|
||||
|
||||
if dest is not None:
|
||||
rv = old_transform_smoothscale(surf.surface, v2p(size), dest.surface)
|
||||
else:
|
||||
rv = old_transform_smoothscale(surf.surface, v2p(size))
|
||||
|
||||
rv = Surface(rv, wh=size)
|
||||
|
||||
return rv
|
||||
|
||||
pygame.transform.smoothscale = transform_smoothscale
|
||||
|
||||
old_transform_flip = pygame.transform.flip
|
||||
|
||||
|
||||
|
||||
def transform_flip(surf, xbool, ybool):
|
||||
return Surface(old_transform_flip(surf.surface, xbool, ybool),
|
||||
wh=surf.get_size())
|
||||
new_surf = pgrender.flip_unscaled(surf.surface, xbool, ybool)
|
||||
return ScaledSurface(new_surf, wh=surf.get_size())
|
||||
|
||||
pgrender.flip = transform_flip
|
||||
pygame.transform.flip = transform_flip
|
||||
|
||||
|
||||
old_transform_rotate = pygame.transform.rotate
|
||||
|
||||
|
||||
def transform_rotate(surf, angle):
|
||||
return Surface(old_transform_flip(surf.surface, angle))
|
||||
new_surf = pgrender.transform_rotate_unscaled(surf.surface, angle)
|
||||
return ScaledSurface(new_surf)
|
||||
|
||||
pgrender.transform_rotate = transform_rotate
|
||||
pygame.transform.rotate = transform_rotate
|
||||
|
||||
old_transform_rotozoom = pygame.transform.rotozoom
|
||||
|
||||
def transform_rotozoom(surf, angle, scale):
|
||||
return Surface(old_transform_flip(surf.surface, angle, scale))
|
||||
|
||||
def rotozoom(surf, angle, scale):
|
||||
new_surf = pgrender.rotozoom(surf.surface, angle, scale)
|
||||
return ScaledSurface(new_surf)
|
||||
|
||||
pygame.transform.rotozoom = transform_rotozoom
|
||||
pgrender.rotozoom = rotozoom
|
||||
pygame.transform.rotozoom = rotozoom
|
||||
|
||||
|
||||
# Ignoring scale2x and chop. The former due to a pending api change,
|
||||
# the latter due to general uselessness.
|
||||
|
||||
PygameFont = font_module.Font
|
||||
PygameFont = _renpy_font.Font
|
||||
|
||||
class Font(object):
|
||||
|
||||
def __init__(self, o, size):
|
||||
self.font = PygameFont(o, int(size * factor))
|
||||
def __init__(self, o, size, index):
|
||||
self.font = PygameFont(o, int(size * factor), index)
|
||||
|
||||
def render(self, *args):
|
||||
return Surface(self.font.render(*args))
|
||||
return ScaledSurface(self.font.render(*args))
|
||||
|
||||
def size(self, text):
|
||||
return p2v(self.font.size(text))
|
||||
@@ -619,18 +587,21 @@ def load_scaling():
|
||||
def set_expand(self, value):
|
||||
self.font.set_expand(value * factor)
|
||||
|
||||
font_module.Font = Font
|
||||
_renpy_font.Font = Font
|
||||
|
||||
|
||||
old_image_save = pygame.image.save
|
||||
|
||||
def image_save(surf, dest):
|
||||
surf = old_transform_scale(surf.surface, surf.get_size())
|
||||
surf = pgrender.transform_scale_unscaled(surf.surface, surf.get_size())
|
||||
old_image_save(surf, dest)
|
||||
|
||||
pygame.image.save = image_save
|
||||
|
||||
|
||||
def image_save_unscaled(surf, dest):
|
||||
old_image_save(surf.surface, dest)
|
||||
|
||||
|
||||
old_mouse_get_pos = pygame.mouse.get_pos
|
||||
|
||||
@@ -639,140 +610,182 @@ def load_scaling():
|
||||
|
||||
pygame.mouse.get_pos = mouse_get_pos
|
||||
|
||||
|
||||
def scale_event(ev):
|
||||
if ev.type == pygame.MOUSEMOTION:
|
||||
return pygame.event.Event(ev.type, pos=p2v(ev.pos), rel=p2v(ev.rel), buttons=ev.buttons)
|
||||
elif ev.type == pygame.MOUSEBUTTONUP or ev.type == pygame.MOUSEBUTTONDOWN:
|
||||
return pygame.event.Event(ev.type, pos=p2v(ev.pos), button=ev.button)
|
||||
else:
|
||||
return ev
|
||||
|
||||
if _renpy is not None:
|
||||
|
||||
old_save_png = _renpy.save_png
|
||||
|
||||
def save_png(surf, dest, compress=-1):
|
||||
surf = old_transform_scale(surf.surface, surf.get_size())
|
||||
old_save_png(surf, dest, compress=compress)
|
||||
|
||||
_renpy.save_png = save_png
|
||||
old_event_poll = pygame.event.poll
|
||||
|
||||
def event_poll():
|
||||
ev = old_event_poll()
|
||||
return scale_event(ev)
|
||||
|
||||
pygame.event.poll = event_poll
|
||||
|
||||
|
||||
old_event_wait = pygame.event.wait
|
||||
|
||||
def event_wait():
|
||||
ev = old_event_wait()
|
||||
return scale_event(ev)
|
||||
|
||||
pygame.event.wait = event_wait
|
||||
|
||||
|
||||
old_event_get = pygame.event.get
|
||||
|
||||
def event_get(*args):
|
||||
rv = old_event_get(*args)
|
||||
|
||||
if rv:
|
||||
rv[-1] = scale_event(rv[-1])
|
||||
|
||||
return rv
|
||||
|
||||
pygame.event.get = event_get
|
||||
|
||||
|
||||
|
||||
old_pixellate = _renpy.pixellate
|
||||
old_save_png = _renpy.save_png
|
||||
|
||||
def pixellate(pysrc, pydst, avgwidth, avgheight, outwidth, outheight):
|
||||
ow = max(int(outwidth * factor), 1)
|
||||
oh = max(int(outheight * factor), 1)
|
||||
def save_png(surf, dest, compress=-1):
|
||||
surf = pgrender.transform_scale_unscaled(surf.surface, surf.get_size())
|
||||
old_save_png(surf, dest, compress=compress)
|
||||
|
||||
owf = 1.0 * ow / outwidth
|
||||
ohf = 1.0 * oh / outheight
|
||||
|
||||
|
||||
old_pixellate(pysrc.surface, pydst.surface,
|
||||
max(avgwidth * owf, 1),
|
||||
max(avgheight * ohf, 1),
|
||||
ow, oh)
|
||||
|
||||
_renpy.pixellate = pixellate
|
||||
|
||||
|
||||
old_map = _renpy.map
|
||||
|
||||
def map(pysrc, pydst, r, g, b, a):
|
||||
pysrc, pydst = same_size(pysrc.surface, pydst.surface)
|
||||
old_map(pysrc, pydst, r, g, b, a)
|
||||
|
||||
_renpy.map = map
|
||||
_renpy.save_png = save_png
|
||||
|
||||
|
||||
old_linmap = _renpy.linmap
|
||||
old_pixellate = _renpy.pixellate
|
||||
|
||||
def linmap(pysrc, pydst, r, g, b, a):
|
||||
pysrc, pydst = same_size(pysrc.surface, pydst.surface)
|
||||
old_linmap(pysrc, pydst, r, g, b, a)
|
||||
def pixellate(pysrc, pydst, avgwidth, avgheight, outwidth, outheight):
|
||||
ow = max(int(outwidth * factor), 1)
|
||||
oh = max(int(outheight * factor), 1)
|
||||
|
||||
_renpy.linmap = linmap
|
||||
owf = 1.0 * ow / outwidth
|
||||
ohf = 1.0 * oh / outheight
|
||||
|
||||
old_pixellate(pysrc.surface, pydst.surface,
|
||||
max(avgwidth * owf, 1),
|
||||
max(avgheight * ohf, 1),
|
||||
ow, oh)
|
||||
|
||||
_renpy.pixellate = pixellate
|
||||
|
||||
|
||||
old_bilinear = _renpy.bilinear
|
||||
def bilinear(pysrc, pydst, source_xoff=0.0, source_yoff=0.0,
|
||||
source_width=None, source_height=None,
|
||||
dest_xoff=0.0, dest_yoff=0.0, dest_width=None, dest_height=None):
|
||||
old_map = _renpy.map
|
||||
|
||||
def f(n):
|
||||
if n is None:
|
||||
return n
|
||||
return n * factor
|
||||
|
||||
source_xoff = f(source_xoff)
|
||||
source_yoff = f(source_yoff)
|
||||
source_width = f(source_width)
|
||||
source_height = f(source_height)
|
||||
def map(pysrc, pydst, r, g, b, a):
|
||||
pysrc, pydst = same_size(pysrc.surface, pydst.surface)
|
||||
old_map(pysrc, pydst, r, g, b, a)
|
||||
|
||||
dest_xoff = f(dest_xoff)
|
||||
dest_yoff = f(dest_yoff)
|
||||
dest_width = f(dest_width)
|
||||
dest_height = f(dest_height)
|
||||
|
||||
old_bilinear(pysrc.surface, pydst.surface,
|
||||
source_xoff=source_xoff,
|
||||
source_yoff=source_yoff,
|
||||
source_width=source_width,
|
||||
source_height=source_height,
|
||||
dest_xoff=dest_xoff,
|
||||
dest_yoff=dest_yoff,
|
||||
dest_width=dest_width,
|
||||
dest_height=dest_height)
|
||||
|
||||
_renpy.bilinear = bilinear
|
||||
|
||||
|
||||
old_alpha_munge = _renpy.alpha_munge
|
||||
|
||||
|
||||
def alpha_munge(pysrc, pydst, srcchan, dstchan, amap):
|
||||
pysrc, pydst = same_size(pysrc.surface, pydst.surface)
|
||||
old_alpha_munge(pysrc, pydst, srcchan, dstchan, amap)
|
||||
|
||||
_renpy.alpha_munge = alpha_munge
|
||||
_renpy.map = map
|
||||
|
||||
|
||||
old_transform = _renpy.transform
|
||||
old_linmap = _renpy.linmap
|
||||
|
||||
def transform(pysrc, pydst, corner_x, corner_y,
|
||||
xdx, ydx, xdy, ydy, a=1.0):
|
||||
|
||||
old_transform(pysrc.surface, pydst.surface,
|
||||
corner_x * factor, corner_y * factor,
|
||||
xdx, ydx, xdy, ydy, a)
|
||||
|
||||
_renpy.transform = transform
|
||||
|
||||
def linmap(pysrc, pydst, r, g, b, a):
|
||||
pysrc, pydst = same_size(pysrc.surface, pydst.surface)
|
||||
old_linmap(pysrc, pydst, r, g, b, a)
|
||||
|
||||
old_subpixel = _renpy.subpixel
|
||||
|
||||
def subpixel(pysrc, pydst, x, y, shift):
|
||||
return old_subpixel(pysrc.surface, pydst.surface, x * factor, y * factor, shift)
|
||||
_renpy.linmap = linmap
|
||||
|
||||
_renpy.subpixel = subpixel
|
||||
|
||||
|
||||
old_blend = _renpy.blend
|
||||
old_bilinear = _renpy.bilinear
|
||||
|
||||
def bilinear(pysrc, pydst, source_xoff=0.0, source_yoff=0.0,
|
||||
source_width=None, source_height=None,
|
||||
dest_xoff=0.0, dest_yoff=0.0, dest_width=None,
|
||||
dest_height=None, precise=0):
|
||||
|
||||
def blend(pysrca, pysrcb, pydst, alpha):
|
||||
pysrca, pysrcb, pydst = same_size(pysrca.surface, pysrcb.surface, pydst.surface)
|
||||
old_blend(pysrca, pysrcb, pydst, alpha)
|
||||
def f(n):
|
||||
if n is None:
|
||||
return n
|
||||
return n * factor
|
||||
|
||||
_renpy.blend = blend
|
||||
|
||||
old_imageblend = _renpy.imageblend
|
||||
source_xoff = f(source_xoff)
|
||||
source_yoff = f(source_yoff)
|
||||
source_width = f(source_width)
|
||||
source_height = f(source_height)
|
||||
|
||||
def imageblend(pysrca, pysrcb, pydst, pyimg, aoff, amap):
|
||||
pysrca, pysrcb, pydst, pyimg = same_size(pysrca.surface, pysrcb.surface, pydst.surface, pyimg.surface)
|
||||
old_imageblend(pysrca, pysrcb, pydst, pyimg, aoff, amap)
|
||||
dest_xoff = f(dest_xoff)
|
||||
dest_yoff = f(dest_yoff)
|
||||
dest_width = f(dest_width)
|
||||
dest_height = f(dest_height)
|
||||
|
||||
_renpy.imageblend = imageblend
|
||||
old_bilinear(pysrc.surface, pydst.surface,
|
||||
source_xoff=source_xoff,
|
||||
source_yoff=source_yoff,
|
||||
source_width=source_width,
|
||||
source_height=source_height,
|
||||
dest_xoff=dest_xoff,
|
||||
dest_yoff=dest_yoff,
|
||||
dest_width=dest_width,
|
||||
dest_height=dest_height,
|
||||
precise=precise)
|
||||
|
||||
old_colormatrix = _renpy.colormatrix
|
||||
_renpy.bilinear = bilinear
|
||||
|
||||
def colormatrix(src, dst, *args):
|
||||
src, dst = same_size(src.surface, dst.surface)
|
||||
old_colormatrix(src, dst, *args)
|
||||
|
||||
_renpy.colormatrix = colormatrix
|
||||
old_alpha_munge = _renpy.alpha_munge
|
||||
|
||||
def alpha_munge(pysrc, pydst, srcchan, dstchan, amap):
|
||||
pysrc, pydst = same_size(pysrc.surface, pydst.surface)
|
||||
old_alpha_munge(pysrc, pydst, srcchan, dstchan, amap)
|
||||
|
||||
_renpy.alpha_munge = alpha_munge
|
||||
|
||||
|
||||
old_transform = _renpy.transform
|
||||
|
||||
def transform(pysrc, pydst, corner_x, corner_y,
|
||||
xdx, ydx, xdy, ydy, a=1.0, precise=0):
|
||||
|
||||
old_transform(pysrc.surface, pydst.surface,
|
||||
corner_x * factor, corner_y * factor,
|
||||
xdx, ydx, xdy, ydy, a, precise)
|
||||
|
||||
_renpy.transform = transform
|
||||
|
||||
|
||||
old_subpixel = _renpy.subpixel
|
||||
|
||||
def subpixel(pysrc, pydst, x, y, shift):
|
||||
return old_subpixel(pysrc.surface, pydst.surface, x * factor, y * factor, shift)
|
||||
|
||||
_renpy.subpixel = subpixel
|
||||
|
||||
|
||||
old_blend = _renpy.blend
|
||||
|
||||
def blend(pysrca, pysrcb, pydst, alpha):
|
||||
pysrca, pysrcb, pydst = same_size(pysrca.surface, pysrcb.surface, pydst.surface)
|
||||
old_blend(pysrca, pysrcb, pydst, alpha)
|
||||
|
||||
_renpy.blend = blend
|
||||
|
||||
|
||||
old_imageblend = _renpy.imageblend
|
||||
|
||||
def imageblend(pysrca, pysrcb, pydst, pyimg, aoff, amap):
|
||||
pysrca, pysrcb, pydst, pyimg = same_size(pysrca.surface, pysrcb.surface, pydst.surface, pyimg.surface)
|
||||
old_imageblend(pysrca, pysrcb, pydst, pyimg, aoff, amap)
|
||||
|
||||
_renpy.imageblend = imageblend
|
||||
|
||||
|
||||
old_colormatrix = _renpy.colormatrix
|
||||
|
||||
def colormatrix(src, dst, *args):
|
||||
src, dst = same_size(src.surface, dst.surface)
|
||||
old_colormatrix(src, dst, *args)
|
||||
|
||||
_renpy.colormatrix = colormatrix
|
||||
|
||||
|
||||
def draw_scale(o):
|
||||
@@ -789,15 +802,18 @@ def load_scaling():
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def draw_wrap(f):
|
||||
def newf(surf, color, *args, **kwargs):
|
||||
f(surf.surface, color, *draw_scale(args), **draw_scale(kwargs))
|
||||
return newf
|
||||
|
||||
|
||||
def arc_wrap(f):
|
||||
def newf(surf, color, Rect, start_angle, stop_angle, width=1):
|
||||
f(surf.surface, color, draw_scale(Rect), start_angle, stop_angle, draw_scale(width))
|
||||
return newf
|
||||
|
||||
|
||||
pygame.draw.rect = draw_wrap(pygame.draw.rect)
|
||||
pygame.draw.polygon = draw_wrap(pygame.draw.polygon)
|
||||
@@ -820,7 +836,7 @@ def load_scaling():
|
||||
if rv is None:
|
||||
return rv
|
||||
else:
|
||||
return Surface(rv, wh=size)
|
||||
return ScaledSurface(rv, wh=size)
|
||||
|
||||
# Now, put everything from this function's namespace into the
|
||||
# module namespace.
|
||||
|
||||
+56
-28
@@ -19,13 +19,12 @@
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
|
||||
import re
|
||||
import renpy
|
||||
import sys
|
||||
|
||||
from _renpybidi import log2vis, WRTL, RTL, ON
|
||||
|
||||
get_font = renpy.display.font.get_font
|
||||
ImageFont = renpy.display.font.ImageFont
|
||||
|
||||
@@ -149,23 +148,15 @@ class TextStyle(object):
|
||||
color = (r, g, b, 255)
|
||||
|
||||
surf = font.render(text, antialias, color)
|
||||
|
||||
rv = renpy.display.pgrender.copy_surface(surf)
|
||||
|
||||
if self.strikethrough:
|
||||
sw, sh = surf.get_size()
|
||||
soh = max(sh / 10, 1)
|
||||
surf.subsurface((0, sh / 2, sw, soh)).fill(color)
|
||||
rv.subsurface((0, sh / 2, sw, soh)).fill(color)
|
||||
|
||||
if a != 255 and renpy.display.module.can_linmap:
|
||||
|
||||
if not surf.get_masks()[3]:
|
||||
surf = surf.convert_alpha(renpy.game.interface.display.window)
|
||||
|
||||
rv = pygame.Surface(surf.get_size(), surf.get_flags(), surf)
|
||||
|
||||
renpy.display.module.linmap(surf, rv, 256, 256, 256, a + 1)
|
||||
|
||||
else:
|
||||
rv = surf
|
||||
if a != 255:
|
||||
renpy.display.module.linmap(rv, rv, 256, 256, 256, a + 1)
|
||||
|
||||
renpy.display.render.mutated_surface(rv)
|
||||
|
||||
@@ -354,10 +345,16 @@ def layout_width(triples, justify=False):
|
||||
|
||||
curts = None
|
||||
cur = ""
|
||||
|
||||
rtl = renpy.config.rtl
|
||||
|
||||
for type, ts, i in triples:
|
||||
if ts is not curts:
|
||||
if cur:
|
||||
|
||||
if rtl:
|
||||
cur, dir = log2vis(cur, ON)
|
||||
|
||||
rv += curts.get_width(cur)
|
||||
|
||||
curts = ts
|
||||
@@ -365,6 +362,10 @@ def layout_width(triples, justify=False):
|
||||
|
||||
elif justify and type == "space":
|
||||
cur += i
|
||||
|
||||
if rtl:
|
||||
cur, dir = log2vis(cur, ON)
|
||||
|
||||
rv += curts.get_width(cur)
|
||||
cur = ""
|
||||
|
||||
@@ -372,6 +373,9 @@ def layout_width(triples, justify=False):
|
||||
cur += i
|
||||
|
||||
if curts:
|
||||
if rtl:
|
||||
cur, dir = log2vis(cur, ON)
|
||||
|
||||
rv += curts.get_width(cur)
|
||||
|
||||
return rv
|
||||
@@ -449,8 +453,6 @@ def greedy_text_layout(triples, width, style):
|
||||
|
||||
def subtitle_text_layout_core(triples, width, style, soft, n, justify):
|
||||
|
||||
sizecache = { }
|
||||
|
||||
lines = [ ]
|
||||
line = [ ]
|
||||
|
||||
@@ -548,6 +550,17 @@ def subtitle_text_layout(triples, width, style):
|
||||
lines_last = [ ]
|
||||
|
||||
for triples in pars:
|
||||
x = 0
|
||||
newtriples = []
|
||||
while x<len(triples):
|
||||
triplewidth = layout_width([triples[x],],justify)
|
||||
if triplewidth<=width or triples[x][0]!='word':
|
||||
newtriples.append(triples[x])
|
||||
else:
|
||||
for char in triples[x][2]:
|
||||
newtriples.append(('word',triples[x][1],char))
|
||||
x+=1
|
||||
triples = newtriples
|
||||
|
||||
sumwidths = layout_width(triples, justify)
|
||||
|
||||
@@ -588,7 +601,7 @@ class Text(renpy.display.core.Displayable):
|
||||
|
||||
__version__ = 2
|
||||
|
||||
def after_upgrade(version):
|
||||
def after_upgrade(self, version):
|
||||
if version <= 0:
|
||||
self.activated = None
|
||||
if version <= 1:
|
||||
@@ -777,7 +790,6 @@ class Text(renpy.display.core.Displayable):
|
||||
|
||||
for kind, i in tliter:
|
||||
|
||||
|
||||
if kind == "tag" and i.startswith("image="):
|
||||
|
||||
m = re.match(r'image=(.*)', i)
|
||||
@@ -785,7 +797,7 @@ class Text(renpy.display.core.Displayable):
|
||||
if not m:
|
||||
raise Exception('Image tag %s could not be parsed.' % i)
|
||||
|
||||
i = renpy.display.im.image(m.group(1))
|
||||
i = renpy.easy.displayable(m.group(1))
|
||||
ntl.append(("widget", i))
|
||||
self.children.append(i)
|
||||
|
||||
@@ -887,10 +899,10 @@ class Text(renpy.display.core.Displayable):
|
||||
|
||||
self.laidout_hyperlinks = [ ]
|
||||
|
||||
if not self.text:
|
||||
text = " "
|
||||
else:
|
||||
text = self.text
|
||||
# if not self.text:
|
||||
# text = " "
|
||||
# else:
|
||||
# text = self.text
|
||||
|
||||
# for i in re.split(r'( |\{[^{}]+\}|\{\{|\n)', text):
|
||||
|
||||
@@ -1149,6 +1161,25 @@ class Text(renpy.display.core.Displayable):
|
||||
if oldts:
|
||||
line.append((oldts, cur))
|
||||
|
||||
|
||||
if renpy.config.rtl:
|
||||
|
||||
rtl_line = [ ]
|
||||
|
||||
# RTL direction.
|
||||
line_direction = ON
|
||||
|
||||
for ts, i in line:
|
||||
if isinstance(ts, TextStyle):
|
||||
i, line_direction = log2vis(i, line_direction)
|
||||
|
||||
rtl_line.append((ts, i))
|
||||
|
||||
if line_direction == RTL or line_direction == WRTL:
|
||||
rtl_line.reverse()
|
||||
|
||||
line = rtl_line
|
||||
|
||||
width = 0
|
||||
height = 0
|
||||
|
||||
@@ -1208,7 +1239,6 @@ class Text(renpy.display.core.Displayable):
|
||||
"""
|
||||
|
||||
if not self.laidout:
|
||||
import sys
|
||||
return sys.maxint
|
||||
|
||||
return self.laidout_length
|
||||
@@ -1232,8 +1262,6 @@ class Text(renpy.display.core.Displayable):
|
||||
text_align = self.style.text_align
|
||||
justify = self.style.justify
|
||||
|
||||
lines = len(self.laidout)
|
||||
|
||||
for line, line_height, line_width, last in zip(self.laidout, self.laidout_lineheights, self.laidout_linewidths, self.laidout_lines_last):
|
||||
if justify and not last:
|
||||
empty_space = (self.laidout_width - line_width - indent)
|
||||
|
||||
+254
-259
@@ -37,8 +37,6 @@
|
||||
|
||||
import renpy
|
||||
from renpy.display.render import render
|
||||
import pygame
|
||||
from pygame.constants import *
|
||||
|
||||
|
||||
class Transition(renpy.display.core.Displayable):
|
||||
@@ -243,18 +241,10 @@ class Pixellate(Transition):
|
||||
steps in each direction.
|
||||
"""
|
||||
|
||||
nosave = [ 'surface', 'surface_size' ]
|
||||
|
||||
surface = None
|
||||
surface_size = None
|
||||
|
||||
def __init__(self, time, steps, old_widget=None, new_widget=None, **properties):
|
||||
|
||||
time = float(time)
|
||||
|
||||
if not renpy.display.module.can_pixellate:
|
||||
time = 0
|
||||
|
||||
super(Pixellate, self).__init__(time, **properties)
|
||||
|
||||
self.time = time
|
||||
@@ -287,18 +277,17 @@ class Pixellate(Transition):
|
||||
rdr = render(visible, width, height, st, at)
|
||||
|
||||
surf = rdr.pygame_surface(False)
|
||||
|
||||
if surf.get_size() != self.surface_size:
|
||||
self.surface_size = surf.get_size()
|
||||
self.surface = pygame.Surface(self.surface_size, surf.get_flags(), surf)
|
||||
size = surf.get_size()
|
||||
|
||||
newsurf = renpy.display.pgrender.surface(size, False)
|
||||
|
||||
px = 2 ** step
|
||||
|
||||
renpy.display.module.pixellate(surf, self.surface, px, px, px, px)
|
||||
renpy.display.render.mutated_surface(self.surface)
|
||||
renpy.display.module.pixellate(surf, newsurf, px, px, px, px)
|
||||
renpy.display.render.mutated_surface(newsurf)
|
||||
|
||||
rv = renpy.display.render.Render(rdr.width, rdr.height)
|
||||
rv.blit(self.surface, (0, 0))
|
||||
rv.blit(newsurf, (0, 0))
|
||||
rv.depends_on(rdr)
|
||||
|
||||
renpy.display.render.redraw(self, 0)
|
||||
@@ -336,7 +325,7 @@ class Dissolve(Transition):
|
||||
if renpy.game.less_updates:
|
||||
return null_render(self, width, height, st, at)
|
||||
|
||||
if st >= self.time or not renpy.display.module.can_blend:
|
||||
if st >= self.time:
|
||||
self.events = True
|
||||
return render(self.new_widget, width, height, st, at)
|
||||
|
||||
@@ -363,20 +352,243 @@ class Dissolve(Transition):
|
||||
|
||||
if w <= 0 or h <= 0:
|
||||
return
|
||||
|
||||
|
||||
renpy.display.module.blend(
|
||||
bottom_surface.subsurface((-x, -y, w, h)),
|
||||
top_surface.subsurface((-x, -y, w, h)),
|
||||
dest.subsurface((0, 0, w, h)),
|
||||
alpha)
|
||||
|
||||
if self.alpha:
|
||||
|
||||
surf = renpy.display.pgrender.surface((width, height), True)
|
||||
draw(surf, 0, 0)
|
||||
renpy.display.render.mutated_surface(surf)
|
||||
|
||||
rv = renpy.display.render.Render(width, height)
|
||||
rv.blit(surf, (0, 0))
|
||||
|
||||
else:
|
||||
rv = renpy.display.render.Render(width, height, draw_func=draw, opaque=True)
|
||||
|
||||
rv.depends_on(top, True)
|
||||
rv.depends_on(bottom)
|
||||
return rv
|
||||
|
||||
|
||||
class ImageDissolve(Transition):
|
||||
"""
|
||||
This dissolves the old scene into the new scene, using an image
|
||||
to control the dissolve process.
|
||||
|
||||
A list of values is used to control this mapping. This list of
|
||||
values consists 256 fully transparent values, a ramp (of a
|
||||
specified number of steps) from full transparency to full opacity,
|
||||
and 256 fully opaque values. A 256 entry window is slid over this
|
||||
list, and the values found within are used to map the red channel
|
||||
of the image onto the opacity of the new scene.
|
||||
|
||||
Basically, this means that while pixels come in first, black last,
|
||||
and the ramp controls the sharpness of the transition.
|
||||
|
||||
@param image: The image that will be used to control this
|
||||
transition. The image should be the same size as the scene being
|
||||
dissolved.
|
||||
|
||||
@param time: The amount of time the dissolve will take.
|
||||
|
||||
@param ramplen: The number of pixels of ramp to use. This defaults
|
||||
to 8.
|
||||
|
||||
@param ramptype: Type of alpha ramp. Possible types are: linear, cube,
|
||||
dcube, mcube. Default is linear. Non-linear types must have
|
||||
ramplen >= 8. "cube": Ease in, sharp out. "dcube": Sharp in, sharp out.
|
||||
"mcube": Ease in, ease out.
|
||||
|
||||
@param ramp: If given, this is expected to be a sequence of
|
||||
integers in the range 0 to 255. This sequence explicitly gives the
|
||||
ramp to be used. If given, this overrides ramplen and ramptype.
|
||||
|
||||
@param reverse: This reverses the ramp and the direction of the window
|
||||
slide. When True, black pixels dissolve in first, and while pixels come
|
||||
in last.
|
||||
"""
|
||||
|
||||
__version__ = 1
|
||||
|
||||
def after_upgrade(self, version):
|
||||
if version < 1:
|
||||
self.alpha = False
|
||||
|
||||
def generate_ramp(self, ramplen, ramptype, explicit_ramp, reverse):
|
||||
"""
|
||||
Precomputes the ramp.
|
||||
"""
|
||||
|
||||
ramp = '\x00' * 256
|
||||
|
||||
if explicit_ramp is not None:
|
||||
|
||||
for i in explicit_ramp:
|
||||
ramp += chr(i)
|
||||
|
||||
else:
|
||||
|
||||
if ramptype == 'cube':
|
||||
# make sure ramplen is big enough, to avoid div-by-0 errors
|
||||
# Not much point in nonlinear if the size is that small, anyway
|
||||
if ramplen >= 8:
|
||||
table = []
|
||||
for i in range(ramplen):
|
||||
table.append(i * i * i)
|
||||
scale = max(table) / 255.0
|
||||
for i in range(ramplen):
|
||||
#print i, table[i], table[i] / scale
|
||||
ramp += chr(int(table[i] / scale))
|
||||
else:
|
||||
ramptype = 'linear'
|
||||
|
||||
elif ramptype == 'dcube':
|
||||
if ramplen >= 8:
|
||||
table = []
|
||||
for i in range(ramplen / 2 - ramplen, ramplen / 2):
|
||||
table.append(i * i * i)
|
||||
adj = abs(min(table))
|
||||
for i in range(len(table)):
|
||||
table[i] += adj
|
||||
scale = max(table) / 255.0
|
||||
#print "scale:", scale
|
||||
for i in range(ramplen):
|
||||
#print i, table[i], table[i] / scale
|
||||
ramp += chr(int(table[i] / scale))
|
||||
else:
|
||||
ramptype = 'linear'
|
||||
|
||||
elif ramptype == 'mcube':
|
||||
if ramplen >= 8:
|
||||
ramplen = (ramplen / 2) * 2 # make sure it's even
|
||||
table = []
|
||||
for i in range(ramplen / 2):
|
||||
table.append(i * i * i)
|
||||
adj = table[-1]
|
||||
tmptable = []
|
||||
for i in table:
|
||||
tmptable.append(i)
|
||||
for i in range(1, len(table) + 1):
|
||||
tmptable.append(abs(table[len(table) - i] - adj) + adj)
|
||||
table = tmptable
|
||||
scale = max(table) / 255.0
|
||||
#print "scale:", scale
|
||||
for i in range(ramplen):
|
||||
#print i, table[i], table[i] / scale
|
||||
ramp += chr(int(table[i] / scale))
|
||||
else:
|
||||
ramptype = 'linear'
|
||||
|
||||
if ramptype == 'linear':
|
||||
for i in range(ramplen):
|
||||
ramp += chr(255 * i / ramplen)
|
||||
|
||||
ramp += '\xff' * 256
|
||||
|
||||
old = 0
|
||||
for i in ramp:
|
||||
i = ord(i)
|
||||
if i < old:
|
||||
self.can_fast = False
|
||||
break
|
||||
|
||||
old = i
|
||||
else:
|
||||
self.can_fast = True
|
||||
|
||||
if reverse:
|
||||
ramp = list(ramp)
|
||||
ramp.reverse()
|
||||
ramp = ''.join(ramp)
|
||||
|
||||
return ramp
|
||||
|
||||
|
||||
def __init__(self, image, time, ramplen=8, ramptype='linear', ramp=None, reverse=False, alpha=False,
|
||||
old_widget=None, new_widget=None, **properties):
|
||||
|
||||
super(ImageDissolve, self).__init__(time, **properties)
|
||||
|
||||
self.time = time
|
||||
self.old_widget = old_widget
|
||||
self.new_widget = new_widget
|
||||
self.events = False
|
||||
self.alpha = alpha
|
||||
|
||||
self.image = renpy.display.im.image(image)
|
||||
|
||||
if ramp is not None:
|
||||
ramplen = len(ramp)
|
||||
|
||||
self.ramp = self.generate_ramp(ramplen, ramptype, ramp, reverse)
|
||||
|
||||
self.steps = ramplen + 256
|
||||
self.reverse = reverse
|
||||
|
||||
|
||||
def visit(self):
|
||||
return super(ImageDissolve, self).visit() + [ self.image ]
|
||||
|
||||
def render(self, width, height, st, at):
|
||||
|
||||
if renpy.game.less_updates:
|
||||
return null_render(self, width, height, st, at)
|
||||
|
||||
if st >= self.time:
|
||||
self.events = True
|
||||
return render(self.new_widget, width, height, st, at)
|
||||
|
||||
image = renpy.display.im.cache.get(self.image)
|
||||
|
||||
if st < self.time:
|
||||
renpy.display.render.redraw(self, 0)
|
||||
|
||||
step = int(self.steps * st / self.time)
|
||||
|
||||
if self.reverse:
|
||||
step = self.steps - step
|
||||
|
||||
ramp = self.ramp[step:step+256]
|
||||
|
||||
|
||||
bottom = render(self.old_widget, width, height, st, at)
|
||||
top = render(self.new_widget, width, height, st, at)
|
||||
|
||||
bottom_surface = bottom.pygame_surface(self.alpha)
|
||||
top_surface = top.pygame_surface(self.alpha)
|
||||
|
||||
iw, ih = image.get_size()
|
||||
|
||||
width = min(bottom.width, top.width, iw)
|
||||
height = min(bottom.height, top.height, ih)
|
||||
|
||||
def draw(dest, x, y):
|
||||
|
||||
dw, dh = dest.get_size()
|
||||
|
||||
w = min(dw, width + x)
|
||||
h = min(dh, height + y)
|
||||
|
||||
renpy.display.module.imageblend(
|
||||
bottom_surface.subsurface((-x, -y, w, h)),
|
||||
top_surface.subsurface((-x, -y, w, h)),
|
||||
dest.subsurface((0, 0, w, h)),
|
||||
image.subsurface((-x, -y, w, h)),
|
||||
ramp)
|
||||
|
||||
if self.alpha:
|
||||
|
||||
rv = renpy.display.render.Render(width, height)
|
||||
surf = pygame.Surface((width, height), bottom_surface.get_flags(), bottom_surface)
|
||||
surf = renpy.display.pgrender.surface((width, height), True)
|
||||
draw(surf, 0, 0)
|
||||
renpy.display.render.mutated_surface(surf)
|
||||
|
||||
rv = renpy.display.render.Render(width, height)
|
||||
rv.blit(surf, (0, 0))
|
||||
|
||||
else:
|
||||
@@ -773,35 +985,42 @@ def MoveTransition(delay, old_widget=None, new_widget=None, factory=None, enter
|
||||
# Otherwise, we recompute the scene list for the two widgets, merging
|
||||
# as appropriate.
|
||||
|
||||
def tag_d(sle):
|
||||
# Wraps the displayable found in SLE so that the various timebases
|
||||
# are maintained.
|
||||
def wrap(sle):
|
||||
key, zorder, st, at, d = sle
|
||||
return renpy.display.layout.AdjustTimes(d, st, at)
|
||||
|
||||
def tag(sle):
|
||||
if sle[0] is None:
|
||||
tag = sle[4]
|
||||
else:
|
||||
tag = sle[0]
|
||||
|
||||
return tag, sle[4]
|
||||
return tag
|
||||
|
||||
def merge(sle, d):
|
||||
return (sle[0], sle[1], 0, sle[3], d)
|
||||
|
||||
# A list of tags on the new layer.
|
||||
new_tags = { }
|
||||
new_tags = set()
|
||||
|
||||
# The scene list we're creating.
|
||||
rv_sl = [ ]
|
||||
|
||||
# The new scene list we're copying from.
|
||||
new_scene_list = new.scene_list[:]
|
||||
|
||||
|
||||
for new_sle in new.scene_list:
|
||||
new_tag, new_d = tag_d(new_sle)
|
||||
new_tag = tag(new_sle)
|
||||
|
||||
if new_tag is not None:
|
||||
new_tags[new_tag] = new_d
|
||||
new_tags.add(new_tag)
|
||||
|
||||
for old_sle in old.scene_list:
|
||||
old_tag, old_d = tag_d(old_sle)
|
||||
|
||||
old_tag = tag(old_sle)
|
||||
old_d = wrap(old_sle)
|
||||
|
||||
# In old, not in new.
|
||||
if old_tag not in new_tags:
|
||||
|
||||
@@ -817,10 +1036,10 @@ def MoveTransition(delay, old_widget=None, new_widget=None, factory=None, enter
|
||||
# In new, not in old.
|
||||
while new_scene_list:
|
||||
new_sle = (new_scene_list.pop(0))
|
||||
new_tag, new_d = tag_d(new_sle)
|
||||
|
||||
if new_tag in new_tags:
|
||||
del new_tags[new_tag]
|
||||
new_tag = tag(new_sle)
|
||||
new_d = wrap(new_sle)
|
||||
|
||||
new_tags.discard(new_tag)
|
||||
|
||||
if new_tag == old_tag:
|
||||
break
|
||||
@@ -850,10 +1069,8 @@ def MoveTransition(delay, old_widget=None, new_widget=None, factory=None, enter
|
||||
# scene list.
|
||||
while new_scene_list:
|
||||
new_sle = (new_scene_list.pop(0))
|
||||
new_tag, new_d = tag_d(new_sle)
|
||||
|
||||
if new_tag in new_tags:
|
||||
del new_tags[new_tag]
|
||||
new_tag = tag(new_sle)
|
||||
new_d = wrap(new_sle)
|
||||
|
||||
move = enter_factory(position(new_d), delay, new_d)
|
||||
if move is None:
|
||||
@@ -862,8 +1079,6 @@ def MoveTransition(delay, old_widget=None, new_widget=None, factory=None, enter
|
||||
rv_sl.append(merge(new_sle, move))
|
||||
continue
|
||||
|
||||
|
||||
|
||||
layer = new.layer_name
|
||||
rv = renpy.display.layout.MultiBox(layout='fixed', focus=layer, **renpy.game.interface.layer_properties[layer])
|
||||
rv.append_scene_list(rv_sl)
|
||||
@@ -880,226 +1095,6 @@ def MoveTransition(delay, old_widget=None, new_widget=None, factory=None, enter
|
||||
return rv
|
||||
|
||||
|
||||
class ImageDissolve(Transition):
|
||||
"""
|
||||
This dissolves the old scene into the new scene, using an image
|
||||
to control the dissolve process.
|
||||
|
||||
A list of values is used to control this mapping. This list of
|
||||
values consists 256 fully transparent values, a ramp (of a
|
||||
specified number of steps) from full transparency to full opacity,
|
||||
and 256 fully opaque values. A 256 entry window is slid over this
|
||||
list, and the values found within are used to map the red channel
|
||||
of the image onto the opacity of the new scene.
|
||||
|
||||
Basically, this means that while pixels come in first, black last,
|
||||
and the ramp controls the sharpness of the transition.
|
||||
|
||||
@param image: The image that will be used to control this
|
||||
transition. The image should be the same size as the scene being
|
||||
dissolved.
|
||||
|
||||
@param time: The amount of time the dissolve will take.
|
||||
|
||||
@param ramplen: The number of pixels of ramp to use. This defaults
|
||||
to 8.
|
||||
|
||||
@param ramptype: Type of alpha ramp. Possible types are: linear, cube,
|
||||
dcube, mcube. Default is linear. Non-linear types must have
|
||||
ramplen >= 8. "cube": Ease in, sharp out. "dcube": Sharp in, sharp out.
|
||||
"mcube": Ease in, ease out.
|
||||
|
||||
@param ramp: If given, this is expected to be a sequence of
|
||||
integers in the range 0 to 255. This sequence explicitly gives the
|
||||
ramp to be used. If given, this overrides ramplen and ramptype.
|
||||
|
||||
@param reverse: This reverses the ramp and the direction of the window
|
||||
slide. When True, black pixels dissolve in first, and while pixels come
|
||||
in last.
|
||||
"""
|
||||
|
||||
__version__ = 1
|
||||
|
||||
def after_upgrade(self, version):
|
||||
if version < 1:
|
||||
self.alpha = False
|
||||
|
||||
def generate_ramp(self, ramplen, ramptype, explicit_ramp, reverse):
|
||||
"""
|
||||
Precomputes the ramp.
|
||||
"""
|
||||
|
||||
ramp = '\x00' * 256
|
||||
|
||||
if explicit_ramp is not None:
|
||||
|
||||
for i in explicit_ramp:
|
||||
ramp += chr(i)
|
||||
|
||||
else:
|
||||
|
||||
if ramptype == 'cube':
|
||||
# make sure ramplen is big enough, to avoid div-by-0 errors
|
||||
# Not much point in nonlinear if the size is that small, anyway
|
||||
if ramplen >= 8:
|
||||
table = []
|
||||
for i in range(ramplen):
|
||||
table.append(i * i * i)
|
||||
scale = max(table) / 255.0
|
||||
for i in range(ramplen):
|
||||
#print i, table[i], table[i] / scale
|
||||
ramp += chr(int(table[i] / scale))
|
||||
else:
|
||||
ramptype = 'linear'
|
||||
|
||||
elif ramptype == 'dcube':
|
||||
if ramplen >= 8:
|
||||
table = []
|
||||
for i in range(ramplen / 2 - ramplen, ramplen / 2):
|
||||
table.append(i * i * i)
|
||||
adj = abs(min(table))
|
||||
for i in range(len(table)):
|
||||
table[i] += adj
|
||||
scale = max(table) / 255.0
|
||||
#print "scale:", scale
|
||||
for i in range(ramplen):
|
||||
#print i, table[i], table[i] / scale
|
||||
ramp += chr(int(table[i] / scale))
|
||||
else:
|
||||
ramptype = 'linear'
|
||||
|
||||
elif ramptype == 'mcube':
|
||||
if ramplen >= 8:
|
||||
ramplen = (ramplen / 2) * 2 # make sure it's even
|
||||
table = []
|
||||
for i in range(ramplen / 2):
|
||||
table.append(i * i * i)
|
||||
adj = table[-1]
|
||||
tmptable = []
|
||||
for i in table:
|
||||
tmptable.append(i)
|
||||
for i in range(1, len(table) + 1):
|
||||
tmptable.append(abs(table[len(table) - i] - adj) + adj)
|
||||
table = tmptable
|
||||
scale = max(table) / 255.0
|
||||
#print "scale:", scale
|
||||
for i in range(ramplen):
|
||||
#print i, table[i], table[i] / scale
|
||||
ramp += chr(int(table[i] / scale))
|
||||
else:
|
||||
ramptype = 'linear'
|
||||
|
||||
if ramptype == 'linear':
|
||||
for i in range(ramplen):
|
||||
ramp += chr(255 * i / ramplen)
|
||||
|
||||
ramp += '\xff' * 256
|
||||
|
||||
old = 0
|
||||
for i in ramp:
|
||||
i = ord(i)
|
||||
if i < old:
|
||||
self.can_fast = False
|
||||
break
|
||||
|
||||
old = i
|
||||
else:
|
||||
self.can_fast = True
|
||||
|
||||
if reverse:
|
||||
ramp = list(ramp)
|
||||
ramp.reverse()
|
||||
ramp = ''.join(ramp)
|
||||
|
||||
return ramp
|
||||
|
||||
|
||||
def __init__(self, image, time, ramplen=8, ramptype='linear', ramp=None, reverse=False, alpha=False,
|
||||
old_widget=None, new_widget=None, **properties):
|
||||
|
||||
super(ImageDissolve, self).__init__(time, **properties)
|
||||
|
||||
self.time = time
|
||||
self.old_widget = old_widget
|
||||
self.new_widget = new_widget
|
||||
self.events = False
|
||||
self.alpha = alpha
|
||||
|
||||
self.image = renpy.display.im.image(image)
|
||||
|
||||
if ramp is not None:
|
||||
ramplen = len(ramp)
|
||||
|
||||
self.ramp = self.generate_ramp(ramplen, ramptype, ramp, reverse)
|
||||
|
||||
self.steps = ramplen + 256
|
||||
self.reverse = reverse
|
||||
|
||||
|
||||
def visit(self):
|
||||
return super(ImageDissolve, self).visit() + [ self.image ]
|
||||
|
||||
def render(self, width, height, st, at):
|
||||
|
||||
if renpy.game.less_updates:
|
||||
return null_render(self, width, height, st, at)
|
||||
|
||||
if st >= self.time or not renpy.display.module.can_imageblend:
|
||||
self.events = True
|
||||
return render(self.new_widget, width, height, st, at)
|
||||
|
||||
image = renpy.display.im.cache.get(self.image)
|
||||
|
||||
if st < self.time:
|
||||
renpy.display.render.redraw(self, 0)
|
||||
|
||||
step = int(self.steps * st / self.time)
|
||||
|
||||
if self.reverse:
|
||||
step = self.steps - step
|
||||
|
||||
ramp = self.ramp[step:step+256]
|
||||
|
||||
|
||||
bottom = render(self.old_widget, width, height, st, at)
|
||||
top = render(self.new_widget, width, height, st, at)
|
||||
|
||||
bottom_surface = bottom.pygame_surface(self.alpha)
|
||||
top_surface = top.pygame_surface(self.alpha)
|
||||
|
||||
iw, ih = image.get_size()
|
||||
|
||||
width = min(bottom.width, top.width, iw)
|
||||
height = min(bottom.height, top.height, ih)
|
||||
|
||||
def draw(dest, x, y):
|
||||
|
||||
dw, dh = dest.get_size()
|
||||
|
||||
w = min(dw, width + x)
|
||||
h = min(dh, height + y)
|
||||
|
||||
renpy.display.module.imageblend(
|
||||
bottom_surface.subsurface((-x, -y, w, h)),
|
||||
top_surface.subsurface((-x, -y, w, h)),
|
||||
dest.subsurface((0, 0, w, h)),
|
||||
image.subsurface((-x, -y, w, h)),
|
||||
ramp)
|
||||
|
||||
if self.alpha:
|
||||
|
||||
rv = renpy.display.render.Render(width, height)
|
||||
surf = pygame.Surface((width, height), bottom_surface.get_flags(), bottom_surface)
|
||||
draw(surf, 0, 0)
|
||||
renpy.display.render.mutated_surface(surf)
|
||||
rv.blit(surf, (0, 0))
|
||||
|
||||
else:
|
||||
rv = renpy.display.render.Render(width, height, draw_func=draw, opaque=True)
|
||||
|
||||
rv.depends_on(top, True)
|
||||
rv.depends_on(bottom)
|
||||
return rv
|
||||
|
||||
def ComposeTransition(trans, before=None, after=None, new_widget=None, old_widget=None):
|
||||
if before is not None:
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import renpy
|
||||
from renpy.display.render import render
|
||||
import pygame
|
||||
import sys # for maxint
|
||||
|
||||
# True if the movie that is currently displaying is in fullscreen mode,
|
||||
# False if it's a smaller size.
|
||||
@@ -91,8 +88,6 @@ def interact():
|
||||
the movie should be displayed fullscreen or not.
|
||||
"""
|
||||
|
||||
playing = renpy.audio.music.get_playing("movie")
|
||||
|
||||
if fullscreen and renpy.audio.music.get_playing("movie"):
|
||||
return True
|
||||
else:
|
||||
@@ -125,7 +120,7 @@ class Movie(renpy.display.core.Displayable):
|
||||
playing = renpy.audio.music.get_playing("movie")
|
||||
|
||||
if (surface is None) or (surface.get_size() != size) or (surface_file != playing):
|
||||
surface = pygame.Surface(size, 0, renpy.game.interface.display.window)
|
||||
surface = renpy.display.pgrender.surface(size, False)
|
||||
surface_file = playing
|
||||
surface.fill((0, 0, 0, 255))
|
||||
|
||||
|
||||
+7
-3
@@ -46,9 +46,11 @@ def displayable_or_none(d):
|
||||
if isinstance(d, basestring):
|
||||
if d[0] == '#':
|
||||
return renpy.store.Solid(d)
|
||||
else:
|
||||
elif "." in d:
|
||||
return renpy.store.Image(d)
|
||||
|
||||
else:
|
||||
return renpy.store.ImageReference(tuple(d.split()))
|
||||
|
||||
# We assume the user knows what he's doing in this case.
|
||||
if hasattr(d, 'parameterize'):
|
||||
return d
|
||||
@@ -66,8 +68,10 @@ def displayable(d):
|
||||
if isinstance(d, basestring):
|
||||
if d[0] == '#':
|
||||
return renpy.store.Solid(d)
|
||||
else:
|
||||
elif "." in d:
|
||||
return renpy.store.Image(d)
|
||||
else:
|
||||
return renpy.store.ImageReference(tuple(d.split()))
|
||||
|
||||
# We assume the user knows what he's doing in this case.
|
||||
if hasattr(d, 'parameterize'):
|
||||
|
||||
+6
-2
@@ -23,7 +23,7 @@
|
||||
# renpy object, as well as the context object.
|
||||
|
||||
import renpy
|
||||
import copy
|
||||
|
||||
|
||||
class Delete(object):
|
||||
pass
|
||||
@@ -176,7 +176,7 @@ class Context(renpy.object.Object):
|
||||
Pops all levels of the dynamic stack. Called when we jump
|
||||
out of a context.
|
||||
"""
|
||||
|
||||
|
||||
while self.dynamic_stack:
|
||||
self.pop_dynamic()
|
||||
|
||||
@@ -264,6 +264,10 @@ class Context(renpy.object.Object):
|
||||
self.dynamic_stack.append({ })
|
||||
self.current = label
|
||||
|
||||
self.make_dynamic([ "_args", "_kwargs" ])
|
||||
renpy.store._args = None
|
||||
renpy.store._kwargs = None
|
||||
|
||||
return renpy.game.script.lookup(label)
|
||||
|
||||
def lookup_return(self, pop=True):
|
||||
|
||||
+57
-23
@@ -39,14 +39,38 @@ from renpy.display.video import movie_start_fullscreen, movie_start_displayable,
|
||||
from renpy.loadsave import load, save, list_saved_games, can_load, rename_save, unlink_save, scan_saved_game
|
||||
from renpy.python import py_eval as eval
|
||||
from renpy.python import rng as random
|
||||
from renpy.atl import atl_warper
|
||||
|
||||
from renpy.character import show_display_say, predict_show_display_say, display_say
|
||||
|
||||
import renpy.audio.sound as sound
|
||||
import renpy.audio.music as music
|
||||
|
||||
import time
|
||||
import sets
|
||||
|
||||
def public_api():
|
||||
"""
|
||||
This does nothing, except to make the pyflakes warnings about
|
||||
unused imports go away.
|
||||
"""
|
||||
ParameterizedText
|
||||
register_sfont, register_mudgefont, register_bmfont
|
||||
Keymap
|
||||
Minigame
|
||||
curry, partial
|
||||
play
|
||||
movie_start_fullscreen, movie_start_displayable, movie_stop
|
||||
load, save, list_saved_games, can_load, rename_save, unlink_save, scan_saved_game
|
||||
eval
|
||||
random
|
||||
atl_warper
|
||||
show_display_say, predict_show_display_say, display_say
|
||||
sound
|
||||
music
|
||||
|
||||
del public_api
|
||||
|
||||
|
||||
import collections
|
||||
|
||||
# This is a map from image name to a Displayable object corresponding
|
||||
# to that image name.
|
||||
@@ -166,7 +190,7 @@ def showing(name, layer='master'):
|
||||
|
||||
return renpy.game.context().predict_info.images.showing(layer, name)
|
||||
|
||||
def show(name, at_list=[ ], layer='master', what=None, zorder=0, tag=None, behind=[ ]):
|
||||
def show(name, at_list=[ ], layer='master', what=None, zorder=0, tag=None, behind=[ ], atl=None):
|
||||
"Documented in wiki as renpy.show."
|
||||
|
||||
if renpy.game.init_phase:
|
||||
@@ -190,7 +214,10 @@ def show(name, at_list=[ ], layer='master', what=None, zorder=0, tag=None, behin
|
||||
base = img = renpy.display.image.ImageReference(what, style='image_placement')
|
||||
|
||||
for i in at_list:
|
||||
img = i(img)
|
||||
if isinstance(i, renpy.display.motion.Transform):
|
||||
img = i(child=img)
|
||||
else:
|
||||
img = i(img)
|
||||
|
||||
# Update the list of images we have ever seen.
|
||||
renpy.game.persistent._seen_images[name] = True
|
||||
@@ -205,7 +232,7 @@ def show(name, at_list=[ ], layer='master', what=None, zorder=0, tag=None, behin
|
||||
if renpy.config.missing_hide:
|
||||
renpy.config.missing_hide(name, layer)
|
||||
|
||||
sls.add(layer, img, key, zorder, behind, at_list=at_list, name=name)
|
||||
sls.add(layer, img, key, zorder, behind, at_list=at_list, name=name, atl=atl)
|
||||
|
||||
|
||||
def hide(name, layer='master'):
|
||||
@@ -417,6 +444,8 @@ def display_menu(items, window_style='menu_window', interact=True, with_none=Non
|
||||
renpy.ui.window(style=window_style)
|
||||
renpy.ui.menu(items, location=renpy.game.context().current, focus="choices", default=True, **kwargs)
|
||||
|
||||
renpy.exports.shown_window()
|
||||
|
||||
# Log the chosen choice.
|
||||
for label, val in items:
|
||||
if val:
|
||||
@@ -509,7 +538,7 @@ def say(who, what, interact=True):
|
||||
|
||||
|
||||
def imagemap(ground, selected, hotspots, unselected=None, overlays=False,
|
||||
style='imagemap', with_none=None, **properties):
|
||||
style='imagemap', mouse='imagemap', with_none=None, **properties):
|
||||
"""
|
||||
Displays an imagemap. An image map consists of two images and a
|
||||
list of hotspots that are defined on that image. When the user
|
||||
@@ -552,7 +581,7 @@ def imagemap(ground, selected, hotspots, unselected=None, overlays=False,
|
||||
|
||||
rv = renpy.ui.interact(suppress_overlay=(not overlays),
|
||||
type='imagemap',
|
||||
mouse='imagemap',
|
||||
mouse=mouse,
|
||||
roll_forward=roll_forward)
|
||||
|
||||
renpy.exports.checkpoint(rv)
|
||||
@@ -977,7 +1006,6 @@ def launch_editor(filenames, line=1, transient=0):
|
||||
statement.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import renpy.subprocess as subprocess
|
||||
import os.path
|
||||
|
||||
@@ -987,13 +1015,11 @@ def launch_editor(filenames, line=1, transient=0):
|
||||
if not len(filenames):
|
||||
return
|
||||
|
||||
shell = True
|
||||
|
||||
filenames = [ shell_escape(os.path.normpath(i)) for i in filenames ]
|
||||
filename = filenames[0]
|
||||
|
||||
allfiles = config.editor_file_separator.join(filenames)
|
||||
otherfiles = config.editor_file_separator.join(filenames[1:])
|
||||
allfiles = renpy.config.editor_file_separator.join(filenames)
|
||||
otherfiles = renpy.config.editor_file_separator.join(filenames[1:])
|
||||
|
||||
subs = dict(filename=filename, line=line, allfiles=allfiles, otherfiles=otherfiles)
|
||||
if transient and (renpy.config.editor_transient is not None):
|
||||
@@ -1059,7 +1085,10 @@ def do_reshow_say(who, what, interact=False):
|
||||
curried_do_reshow_say = curry(do_reshow_say)
|
||||
|
||||
def get_reshow_say(**kwargs):
|
||||
return curried_do_reshow_say(store._last_say_who, store._last_say_what, **kwargs)
|
||||
return curried_do_reshow_say(
|
||||
renpy.store._last_say_who,
|
||||
renpy.store._last_say_what,
|
||||
**kwargs)
|
||||
|
||||
def reshow_say(**kwargs):
|
||||
get_reshow_say()(**kwargs)
|
||||
@@ -1101,7 +1130,7 @@ def image_size(im):
|
||||
raise Exception("renpy.image_size expects it's argument to be an image.")
|
||||
|
||||
surf = im.load()
|
||||
return im.get_size()
|
||||
return surf.get_size()
|
||||
|
||||
def get_at_list(name, layer='master'):
|
||||
if isinstance(name, basestring):
|
||||
@@ -1210,19 +1239,19 @@ def game_menu(screen=None):
|
||||
call_in_new_context("_game_menu", screen)
|
||||
|
||||
def shown_window():
|
||||
renpy.game.interface.shown_window = True
|
||||
renpy.game.context().scene_lists.shown_window = True
|
||||
|
||||
def get_placement(d):
|
||||
o = renpy.store.object()
|
||||
p = d.get_placement()
|
||||
|
||||
o.xpos = d[0]
|
||||
o.ypos = d[1]
|
||||
o.xanchor = d[2]
|
||||
o.yanchor = d[3]
|
||||
o.xoffset = d[4]
|
||||
o.yoffset = d[5]
|
||||
o.subpixel = d[6]
|
||||
o.xpos = p[0]
|
||||
o.ypos = p[1]
|
||||
o.xanchor = p[2]
|
||||
o.yanchor = p[3]
|
||||
o.xoffset = p[4]
|
||||
o.yoffset = p[5]
|
||||
o.subpixel = p[6]
|
||||
|
||||
return o
|
||||
|
||||
@@ -1238,5 +1267,10 @@ class Displayable(renpy.display.core.Displayable, renpy.python.RevertableObject)
|
||||
|
||||
class Container(renpy.display.core.Displayable, renpy.python.RevertableObject):
|
||||
_list_type = renpy.python.RevertableList
|
||||
|
||||
|
||||
def get_roll_forward():
|
||||
return renpy.game.interface.shown_window
|
||||
|
||||
# This is a map from a definition to the place where it was
|
||||
# defined.
|
||||
definitions = collections.defaultdict(list)
|
||||
|
||||
@@ -253,6 +253,10 @@ def invoke_in_new_context(callable, *args, **kwargs):
|
||||
return callable(*args, **kwargs)
|
||||
finally:
|
||||
contexts.pop()
|
||||
|
||||
if interface.restart_interaction:
|
||||
contexts[-1].scene_lists.focused = None
|
||||
|
||||
|
||||
def call_in_new_context(label, *args, **kwargs):
|
||||
"""
|
||||
@@ -296,3 +300,8 @@ def call_in_new_context(label, *args, **kwargs):
|
||||
contexts.pop()
|
||||
raise renpy.game.JumpException(e.args[0])
|
||||
|
||||
finally:
|
||||
if interface.restart_interaction:
|
||||
contexts[-1].scene_lists.focused = None
|
||||
|
||||
|
||||
|
||||
+3
-1
@@ -20,12 +20,14 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import renpy
|
||||
import sys
|
||||
import codecs
|
||||
import os
|
||||
import os.path
|
||||
import time
|
||||
|
||||
image_prefixes = None
|
||||
filenames = None
|
||||
|
||||
# Things to check in lint.
|
||||
#
|
||||
# Image files exist, and are of the right case.
|
||||
|
||||
+25
-11
@@ -26,11 +26,9 @@ from pickle import loads
|
||||
from cStringIO import StringIO
|
||||
import sys
|
||||
import types
|
||||
import codecs
|
||||
|
||||
# Files on disk should be checked before archives. Otherwise, among
|
||||
# other things, using a new version of bytecode.rpb will break.
|
||||
|
||||
archives = [ ]
|
||||
|
||||
# The value of renpy.config.archives the last time index_archives was
|
||||
@@ -161,11 +159,14 @@ class SubFile(object):
|
||||
rv1 = self.start[self.offset:self.offset + length]
|
||||
length -= len(rv1)
|
||||
self.offset += len(rv1)
|
||||
|
||||
rv2 = self.f.read(length)
|
||||
self.offset += len(rv2)
|
||||
|
||||
return rv1 + rv2
|
||||
if length:
|
||||
rv2 = self.f.read(length)
|
||||
self.offset += len(rv2)
|
||||
else:
|
||||
rv2 = ""
|
||||
|
||||
return (rv1 + rv2)
|
||||
|
||||
def readline(self, length=None):
|
||||
|
||||
@@ -234,13 +235,18 @@ class SubFile(object):
|
||||
def seek(self, offset, whence=0):
|
||||
|
||||
if whence == 0:
|
||||
self.offset = offset
|
||||
offset = offset
|
||||
elif whence == 1:
|
||||
self.offset = self.offset + offset
|
||||
offset = self.offset + offset
|
||||
elif whence == 2:
|
||||
self.offset = self.length + offset
|
||||
offset = self.length + offset
|
||||
|
||||
offset = self.offset - len(self.start)
|
||||
if offset > self.length:
|
||||
offset = self.length
|
||||
|
||||
self.offset = offset
|
||||
|
||||
offset = offset - len(self.start)
|
||||
if offset < 0:
|
||||
offset = 0
|
||||
|
||||
@@ -264,6 +270,11 @@ def load(name):
|
||||
if renpy.config.reject_backslash and "\\" in name:
|
||||
raise Exception("Backslash in filename, use '/' instead: %r" % name)
|
||||
|
||||
if renpy.config.file_open_callback:
|
||||
rv = renpy.config.file_open_callback(name)
|
||||
if rv is not None:
|
||||
return rv
|
||||
|
||||
# Look for the file directly.
|
||||
if not renpy.config.force_archives:
|
||||
|
||||
@@ -305,7 +316,7 @@ def load(name):
|
||||
|
||||
return rv
|
||||
|
||||
raise Exception("Couldn't find file '%s'." % name)
|
||||
raise IOError("Couldn't find file '%s'." % name)
|
||||
|
||||
def loadable(name):
|
||||
"""
|
||||
@@ -334,6 +345,9 @@ def transfn(name):
|
||||
if renpy.config.reject_backslash and "\\" in name:
|
||||
raise Exception("Backslash in filename, use '/' instead: %r" % name)
|
||||
|
||||
if isinstance(name, unicode):
|
||||
name = name.encode("utf-8")
|
||||
|
||||
for d in renpy.config.searchpath:
|
||||
fn = os.path.join(renpy.config.basedir, d, name)
|
||||
|
||||
|
||||
+2
-1
@@ -28,7 +28,6 @@ import StringIO
|
||||
import cStringIO
|
||||
|
||||
import zipfile
|
||||
import time
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
@@ -422,3 +421,5 @@ def MultiPersistent(name):
|
||||
|
||||
rv._filename = fn
|
||||
return rv
|
||||
|
||||
|
||||
|
||||
+10
-7
@@ -25,7 +25,7 @@ import os
|
||||
import sys
|
||||
import time
|
||||
import zipfile
|
||||
from cPickle import loads, dumps, HIGHEST_PROTOCOL
|
||||
from cPickle import loads, dumps
|
||||
import __main__
|
||||
|
||||
def save_persistent():
|
||||
@@ -50,9 +50,6 @@ def run(restart):
|
||||
store.clear()
|
||||
store.update(renpy.game.clean_store)
|
||||
|
||||
# Note that this is a restart.
|
||||
renpy.store._restart = restart
|
||||
|
||||
# Re-Initialize the log.
|
||||
game.log = renpy.python.RollbackLog()
|
||||
|
||||
@@ -87,6 +84,10 @@ def run(restart):
|
||||
renpy.exports.log("--- " + time.ctime())
|
||||
renpy.exports.log("")
|
||||
|
||||
# Note if this is a restart.
|
||||
renpy.store._restart = restart
|
||||
restart = None
|
||||
|
||||
# We run until we get an exception.
|
||||
try:
|
||||
game.context().run()
|
||||
@@ -96,6 +97,7 @@ def run(restart):
|
||||
# We get this when the context has changed, and so we go and
|
||||
# start running from the new context.
|
||||
except game.RestartException, e:
|
||||
|
||||
renpy.game.contexts = e.contexts
|
||||
|
||||
label = e.label
|
||||
@@ -314,8 +316,9 @@ def main():
|
||||
break
|
||||
except game.FullRestartException, e:
|
||||
restart = e.reason
|
||||
|
||||
finally:
|
||||
renpy.display.core.cpu_idle.set()
|
||||
renpy.loadsave.autosave_not_running.wait()
|
||||
|
||||
# This is stuff we do on a normal, non-error return.
|
||||
renpy.display.core.cpu_idle.set()
|
||||
renpy.display.render.check_at_shutdown()
|
||||
renpy.loadsave.autosave_not_running.wait()
|
||||
|
||||
+87
-25
@@ -25,8 +25,6 @@
|
||||
import codecs
|
||||
import re
|
||||
import os
|
||||
import os.path
|
||||
import sets
|
||||
|
||||
import renpy
|
||||
import renpy.ast as ast
|
||||
@@ -345,7 +343,7 @@ class Lexer(object):
|
||||
|
||||
# A list of keywords which should not be parsed as names, because
|
||||
# there is a huge chance of confusion.
|
||||
keywords = sets.Set([
|
||||
keywords = set([
|
||||
'as',
|
||||
'at',
|
||||
'behind',
|
||||
@@ -366,6 +364,7 @@ class Lexer(object):
|
||||
'with',
|
||||
'while',
|
||||
'zorder',
|
||||
'transform',
|
||||
])
|
||||
|
||||
|
||||
@@ -577,14 +576,6 @@ class Lexer(object):
|
||||
|
||||
return self.match(r'(\+|\-)?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?')
|
||||
|
||||
def integer(self):
|
||||
"""
|
||||
Tries to parse an integer. Returns a string containing the
|
||||
integer, or None.
|
||||
"""
|
||||
|
||||
return self.match(r'(\+|\-)?\d+')
|
||||
|
||||
def word(self):
|
||||
"""
|
||||
Parses a name, which may be a keyword or not.
|
||||
@@ -833,7 +824,7 @@ class Lexer(object):
|
||||
|
||||
return self.filename, self.number
|
||||
|
||||
def require(self, thing):
|
||||
def require(self, thing, name=None):
|
||||
"""
|
||||
Tries to parse thing, and reports an error if it cannot be done.
|
||||
|
||||
@@ -843,10 +834,10 @@ class Lexer(object):
|
||||
"""
|
||||
|
||||
if isinstance(thing, str):
|
||||
name = thing
|
||||
name = name or thing
|
||||
rv = self.match(thing)
|
||||
else:
|
||||
name = thing.im_func.func_name
|
||||
name = name or thing.im_func.func_name
|
||||
rv = thing()
|
||||
|
||||
if rv is None:
|
||||
@@ -1015,6 +1006,8 @@ def parse_image_specifier(l):
|
||||
if layer is None:
|
||||
layer = 'master'
|
||||
|
||||
|
||||
|
||||
return image_name, expression, tag, at_list, layer, zorder, behind
|
||||
|
||||
def parse_with(l, node):
|
||||
@@ -1036,7 +1029,7 @@ def parse_with(l, node):
|
||||
node,
|
||||
ast.With(loc, expr) ]
|
||||
|
||||
|
||||
|
||||
|
||||
def parse_menu(stmtl, loc):
|
||||
|
||||
@@ -1162,7 +1155,7 @@ def parse_parameters(l):
|
||||
|
||||
add_positional = True
|
||||
|
||||
names = sets.Set()
|
||||
names = set()
|
||||
|
||||
if not l.match(r'\('):
|
||||
return None
|
||||
@@ -1438,7 +1431,6 @@ def parse_statement(l):
|
||||
|
||||
### Scene statement.
|
||||
if l.keyword('scene'):
|
||||
l.expect_noblock('scene statement')
|
||||
|
||||
if l.keyword('onlayer'):
|
||||
layer = l.require(l.name)
|
||||
@@ -1451,7 +1443,13 @@ def parse_statement(l):
|
||||
return ast.Scene(loc, None, layer)
|
||||
|
||||
imspec = parse_image_specifier(l)
|
||||
rv = parse_with(l, ast.Scene(loc, imspec, imspec[4]))
|
||||
stmt = ast.Scene(loc, imspec, imspec[4])
|
||||
rv = parse_with(l, stmt)
|
||||
|
||||
if l.match(':'):
|
||||
stmt.atl = renpy.atl.parse_atl(l.subblock_lexer())
|
||||
else:
|
||||
l.expect_noblock('scene statement')
|
||||
|
||||
l.expect_eol()
|
||||
l.advance()
|
||||
@@ -1461,10 +1459,15 @@ def parse_statement(l):
|
||||
### Show statement.
|
||||
if l.keyword('show'):
|
||||
imspec = parse_image_specifier(l)
|
||||
rv = parse_with(l, ast.Show(loc, imspec))
|
||||
stmt = ast.Show(loc, imspec)
|
||||
rv = parse_with(l, stmt)
|
||||
|
||||
if l.match(':'):
|
||||
stmt.atl = renpy.atl.parse_atl(l.subblock_lexer())
|
||||
else:
|
||||
l.expect_noblock('show statement')
|
||||
|
||||
l.expect_eol()
|
||||
l.expect_noblock('show statement')
|
||||
l.advance()
|
||||
|
||||
return rv
|
||||
@@ -1492,21 +1495,80 @@ def parse_statement(l):
|
||||
### Image statement.
|
||||
if l.keyword('image'):
|
||||
|
||||
|
||||
name = parse_image_name(l)
|
||||
l.require('=')
|
||||
expr = l.rest()
|
||||
|
||||
rv = ast.Image(loc, name, expr)
|
||||
if l.match(':'):
|
||||
l.expect_eol()
|
||||
expr = None
|
||||
atl = renpy.atl.parse_atl(l.subblock_lexer())
|
||||
else:
|
||||
l.require('=')
|
||||
expr = l.rest()
|
||||
atl = None
|
||||
l.expect_noblock('image statement')
|
||||
|
||||
rv = ast.Image(loc, name, expr, atl)
|
||||
|
||||
if not l.init:
|
||||
rv = ast.Init(loc, [ rv ], 990)
|
||||
|
||||
l.expect_noblock('image statement')
|
||||
l.advance()
|
||||
|
||||
return rv
|
||||
|
||||
### Define statement.
|
||||
if l.keyword('define'):
|
||||
|
||||
priority = l.integer()
|
||||
if priority:
|
||||
priority = int(priority)
|
||||
else:
|
||||
priority = 0
|
||||
|
||||
name = l.require(l.name)
|
||||
l.require('=')
|
||||
expr = l.rest()
|
||||
|
||||
l.expect_noblock('define statement')
|
||||
|
||||
rv = ast.Define(loc, name, expr)
|
||||
|
||||
if not l.init:
|
||||
rv = ast.Init(loc, [ rv ], priority)
|
||||
|
||||
l.advance()
|
||||
|
||||
return rv
|
||||
|
||||
### Transform statement.
|
||||
if l.keyword('transform'):
|
||||
|
||||
priority = l.integer()
|
||||
if priority:
|
||||
priority = int(priority)
|
||||
else:
|
||||
priority = 0
|
||||
|
||||
name = l.require(l.name)
|
||||
parameters = parse_parameters(l)
|
||||
|
||||
if parameters and (parameters.extrakw or parameters.extrapos):
|
||||
l.error('transform statement does not take a variable number of parameters')
|
||||
|
||||
l.require(':')
|
||||
l.expect_eol()
|
||||
|
||||
atl = renpy.atl.parse_atl(l.subblock_lexer())
|
||||
|
||||
rv = ast.Transform(loc, name, atl, parameters)
|
||||
|
||||
if not l.init:
|
||||
rv = ast.Init(loc, [ rv ], priority)
|
||||
|
||||
l.advance()
|
||||
|
||||
return rv
|
||||
|
||||
### One-line python statement.
|
||||
if l.match(r'\$'):
|
||||
python_code = l.rest()
|
||||
|
||||
+22
-10
@@ -31,11 +31,9 @@ import compiler.ast as ast
|
||||
|
||||
import marshal
|
||||
import random
|
||||
import types
|
||||
import weakref
|
||||
import re
|
||||
import sets
|
||||
import sys
|
||||
|
||||
import renpy
|
||||
|
||||
@@ -220,13 +218,19 @@ def py_compile(source, mode, filename='<none>', lineno=1):
|
||||
|
||||
if "\\u" in source:
|
||||
source = string_re.sub(make_unicode, source)
|
||||
|
||||
|
||||
if mode == "exec":
|
||||
source = "from __future__ import with_statement\n" + source
|
||||
line_offset = 2
|
||||
else:
|
||||
line_offset = 1
|
||||
|
||||
try:
|
||||
tree = parse(source, mode)
|
||||
except SyntaxError, e:
|
||||
|
||||
if e.lineno is not None:
|
||||
msg = "Syntax error on line %d of %s" % (e.lineno + lineno - 1, filename)
|
||||
msg = "Syntax error on line %d of %s" % (e.lineno + lineno - line_offset, filename)
|
||||
|
||||
if len(source) < 128:
|
||||
msg += ":\n " + orig_source
|
||||
@@ -238,10 +242,10 @@ def py_compile(source, mode, filename='<none>', lineno=1):
|
||||
recursively_replace(tree, wrap_node)
|
||||
|
||||
if mode == 'exec':
|
||||
set_filename(filename, lineno - 1, tree)
|
||||
set_filename(filename, lineno - line_offset, tree)
|
||||
cg = ModuleCodeGenerator(tree)
|
||||
else:
|
||||
set_filename(filename, lineno - 1, tree)
|
||||
set_filename(filename, lineno - line_offset, tree)
|
||||
cg = ExpressionCodeGenerator(tree)
|
||||
|
||||
return cg.getCode()
|
||||
@@ -404,7 +408,6 @@ class RevertableSet(sets.Set):
|
||||
class RevertableObject(object):
|
||||
|
||||
def __setattr__(self, attr, value):
|
||||
import sys
|
||||
object.__setattr__(self, attr, value)
|
||||
|
||||
def __delattr__(self, attr):
|
||||
@@ -752,10 +755,14 @@ class RollbackLog(renpy.object.Object):
|
||||
that the user may want to rollback to just before this
|
||||
node.
|
||||
"""
|
||||
|
||||
|
||||
if self.current.checkpoint:
|
||||
return
|
||||
|
||||
|
||||
# Only allow checkpoints in the top-level context.
|
||||
if len(renpy.game.contexts) > 1:
|
||||
return
|
||||
|
||||
if self.rollback_limit < renpy.config.hard_rollback_limit:
|
||||
self.rollback_limit += 1
|
||||
|
||||
@@ -950,11 +957,16 @@ def py_eval(source, globals=None, locals=None):
|
||||
return eval(py_compile(source, 'eval'), globals, locals)
|
||||
|
||||
|
||||
|
||||
# Code for pickling bound methods.
|
||||
|
||||
def method_pickle(method):
|
||||
name = method.im_func.__name__
|
||||
obj = method.im_class
|
||||
|
||||
obj = method.im_self
|
||||
|
||||
if obj is None:
|
||||
obj = method.im_class
|
||||
|
||||
return method_unpickle, (obj, name)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user