Compare commits
154 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c7bdede29 | |||
| 4208836d77 | |||
| 592341f5b1 | |||
| bc41ebadce | |||
| 0deadb41ee | |||
| 076624c4c2 | |||
| 943b421779 | |||
| c21acfb108 | |||
| 8ae58964d8 | |||
| 0cf0135a00 | |||
| 11d8a8a249 | |||
| 8edacbf9f1 | |||
| e6f49527b6 | |||
| 9b897f7ffc | |||
| bc06c75cf2 | |||
| ef324e2f9f | |||
| 002ed104de | |||
| 211fd59d66 | |||
| 3827198240 | |||
| 760d975d5b | |||
| ad25bd6597 | |||
| 9edc9aa741 | |||
| 061f481d10 | |||
| f33839212d | |||
| ac46d25470 | |||
| efdf7d4e30 | |||
| 76d942ebb3 | |||
| 24881174ce | |||
| 88a44ea1a9 | |||
| d0aed4a284 | |||
| 47f5cce2c3 | |||
| 534f669e1d | |||
| 2f422080e9 | |||
| 6efbd90a7c | |||
| 446b5fd32f | |||
| 705dc5f53b | |||
| c5dba9f4a1 | |||
| 904c2ebe73 | |||
| 275f52814f | |||
| 693cf9f8c9 | |||
| 35c2ec5a83 | |||
| 3b60efd744 | |||
| daac5d8ebf | |||
| 1fab6d8707 | |||
| aaff11668a | |||
| 536341a819 | |||
| b9c468e446 | |||
| 03edec9785 | |||
| da70a85d75 | |||
| 4ba170b8d8 | |||
| 72ae15c635 | |||
| 1179066dda | |||
| 62d0093bee | |||
| 55c0d3b4a7 | |||
| 92014eafdd | |||
| b1be4c8ed4 | |||
| 06f36dd8d1 | |||
| 3a15f5c717 | |||
| 031f3338b1 | |||
| 66125b2e10 | |||
| e6becffc4c | |||
| d281e57879 | |||
| 5196a970a0 | |||
| efcbc92e7a | |||
| 142fa33548 | |||
| 4b6e871ac6 | |||
| 1fbbad053a | |||
| 61aa933d97 | |||
| 70c3ea773e | |||
| a16de04682 | |||
| 0280a12589 | |||
| 4dc8fef9c1 | |||
| 2c02645ec7 | |||
| 40bad327fe | |||
| f5653d3c4d | |||
| 4026d7818b | |||
| a0fda2f058 | |||
| 93546e2d5c | |||
| 85a562713a | |||
| 4e9beb1a5d | |||
| 522333e0f5 | |||
| b4c4d0264c | |||
| 21c3187fa3 | |||
| b377cfcdef | |||
| 5d384e531d | |||
| 2b00c64973 | |||
| 7c777dea22 | |||
| 9d0c77917d | |||
| 6d40ced435 | |||
| 0675ee7f79 | |||
| 0aec15a848 | |||
| 2ff01a99ac | |||
| 0596ed7739 | |||
| d8beb99964 | |||
| 648dfd8d75 | |||
| 279a7a3fc8 | |||
| a62aede62f | |||
| b07bbbc1c9 | |||
| 547ce87eaa | |||
| c206456d00 | |||
| 590dd13f8f | |||
| afd0e70479 | |||
| b9166b35b3 | |||
| 333fa51862 | |||
| ec6d256707 | |||
| 86764d92a6 | |||
| cf1c9b3e5e | |||
| b15d7179b6 | |||
| 72312f1249 | |||
| 373198f628 | |||
| e96d8c774b | |||
| 8e221e183d | |||
| 2249c49303 | |||
| 388362d318 | |||
| a554ea8e8b | |||
| 090719deee | |||
| e29a162a85 | |||
| e17fa9edc2 | |||
| e57529257e | |||
| 866f9228ef | |||
| 3a38a8b89b | |||
| 0509a23881 | |||
| cbb0741ab9 | |||
| 716bb0fac1 | |||
| acb193bd7b | |||
| 0a09beb731 | |||
| 93dca3df73 | |||
| 008143a3da | |||
| 30a4db432e | |||
| 65546baf01 | |||
| 8be5069490 | |||
| 802410644b | |||
| e74b172372 | |||
| 23ac59588e | |||
| 7f6e9de5e5 | |||
| 143906ae9d | |||
| b003371456 | |||
| 1e6fa37a10 | |||
| 935786a161 | |||
| 23c4d07432 | |||
| 77107ef1eb | |||
| cac4238b12 | |||
| 8c402c2dc3 | |||
| 9bff95826a | |||
| fc0f7cecc4 | |||
| 0b5c5ce17e | |||
| 9aa61532ff | |||
| 3271557f8a | |||
| 9587342129 | |||
| 9b4821308d | |||
| 663978906a | |||
| 60f3308b8b | |||
| a305d6e725 | |||
| 1feff344b8 |
@@ -29,3 +29,28 @@ jcc
|
||||
scite/scite.zip
|
||||
screenshot*
|
||||
.ropeproject
|
||||
release_cardgame.sh
|
||||
cardgame
|
||||
dse.split
|
||||
empty
|
||||
empty-linux-x86.tar.bz2
|
||||
empty-mac.zip
|
||||
empty.zip
|
||||
errors.txt
|
||||
icons
|
||||
iliad-icon.png
|
||||
iliad-work
|
||||
kuroi
|
||||
lsprofcalltree.py
|
||||
manifest.xml
|
||||
mediatest
|
||||
musicroom
|
||||
nobmtest
|
||||
renpy-iliad.sh
|
||||
renpy.kcg
|
||||
renpy.stats
|
||||
renpygame-1.2.zip
|
||||
speedtest
|
||||
styles.txt
|
||||
renpygame-demo/game/saves
|
||||
./lib
|
||||
|
||||
@@ -1,3 +1,231 @@
|
||||
New in Ren'Py 6.9.3
|
||||
-------------------
|
||||
|
||||
This release includes Launcher2, a near-total rewrite of the Ren'Py
|
||||
launcher. Among the more important changes are:
|
||||
|
||||
* The launcher now supports a project directory. It is no longer
|
||||
necessary to move projects around when upgrading Ren'Py.
|
||||
|
||||
* The launcher has support for selecting the editor to use. While we
|
||||
ship with jEdit support, other editors can be downloaded from the
|
||||
Ren'Py web site.
|
||||
|
||||
* When building distributions, the launcher now allows the user to
|
||||
choose which distributions are built.
|
||||
|
||||
* The Macintosh distribution now places all non-documentation files
|
||||
inside a single application.
|
||||
|
||||
* There is a new combined distribution, which includes support for
|
||||
Windows, Linux, and Macintosh in a single zip file.
|
||||
|
||||
|
||||
The new ui.detached function allows one to use the ui functions to
|
||||
define displayables without adding them to a layer.
|
||||
|
||||
|
||||
Ren'Py will now search for a directory named "Ren'Py Data" in the
|
||||
directories above your Ren'Py installation. If found, save data will
|
||||
be placed in that directory, rather than the system-specific default
|
||||
location. This should help make it easier to develop Ren'Py games when
|
||||
using a USB drive.
|
||||
|
||||
|
||||
The save location for screenshots has now been standardized. It is now
|
||||
the directory containing the executable used to start Ren'Py, be it a
|
||||
.exe, .py, .sh, or .app. (The latter is handled specially.)
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Fixed a long-standing problem that could cause Rollback to operate
|
||||
incorrectly with object that were unreachable at the time of the
|
||||
Rollback.
|
||||
|
||||
Fixed a problem that prevented animations from displaying correctly
|
||||
when the animation was displayed more than once.
|
||||
|
||||
Fixed a problem that could cause children of the various
|
||||
MultiBox-based displayables (Fixed, HBox, VBox, and LiveComposite) to
|
||||
display animations incorrectly.
|
||||
|
||||
|
||||
New in Ren'Py 6.9.2
|
||||
-------------------
|
||||
|
||||
The semantics for play and queue have changed slightly. Now, when a
|
||||
play statement is followed by one or more queue statements, the first
|
||||
file in each play or queue statement will be played. For example:
|
||||
|
||||
play music "a.ogg"
|
||||
queue music "b.ogg"
|
||||
queue music "c.ogg"
|
||||
|
||||
will play "a.ogg", "b.ogg", and then loop "c.ogg". This change also
|
||||
applies to renpy.music.play and renpy.music.queue.
|
||||
|
||||
|
||||
Rollback was changed so that doing anything other than a roll-forward
|
||||
while in rollback mode exits rollback immediately.
|
||||
|
||||
|
||||
The library alias for config has been removed.
|
||||
|
||||
|
||||
Fixed a regression that caused dissolves to be terribly slow.
|
||||
|
||||
Fixed a bug that caused Ren'Py to crash when playing music on Windows
|
||||
when Data Execution Prevention was enabled. DEP is enabled by default
|
||||
on 64-bit Windows Vista.
|
||||
|
||||
Fixed a bug that caused Ren'Py to crash when a window icon was used on
|
||||
a computer with a 16-bit or 8-bit screen depth.
|
||||
|
||||
Fixed a bug that caused ui.sizer to malfunction.
|
||||
|
||||
Fixed a repeated word in "The Question".
|
||||
|
||||
Fixed a bug that could cause it to take two tries to define a joystick
|
||||
button.
|
||||
|
||||
|
||||
|
||||
New in Ren'Py 6.9.1
|
||||
-------------------
|
||||
|
||||
The music and video playback code has been completely rewritten. The
|
||||
new implementation uses the ffmpeg library. It includes the following
|
||||
features:
|
||||
|
||||
* Support for ogg, mp3, mp2, wav, and flac audio.
|
||||
|
||||
* Support for theora, mpeg4 part 2 (including DivX and Xvid), mpeg2,
|
||||
and mpeg1 video.
|
||||
|
||||
* Support for an arbitrary number of named channels, replacing the
|
||||
previous eight numbered channels.
|
||||
|
||||
* Audio files are now automatically converted to the output sampling
|
||||
rate (by default, 44100hz). This prevents the problems that would
|
||||
previously crop up when playing audio sampled at other rates.
|
||||
|
||||
* The play, queue, and stop statements now take a channel name as the
|
||||
second argument, which makes using user-defined channels easier.
|
||||
|
||||
As part of this rewrite, we have eliminated support for mod formats,
|
||||
as they are not supported by ffmpeg.
|
||||
|
||||
Please read the reference manual documentation for Audio and Movies to
|
||||
learn the new interface.
|
||||
|
||||
The new code requires some changes in the saved data. As a result,
|
||||
loading a file saved with a prior version of Ren'Py may lead to a lack
|
||||
of music until the next track is played.
|
||||
|
||||
|
||||
|
||||
The new window statement allows one to control if an empty window is
|
||||
shown when no character is speaking. Specifically, the
|
||||
|
||||
window show [transition]
|
||||
|
||||
statement shows the window, and the
|
||||
|
||||
window hide [transition]
|
||||
|
||||
statement hides it. Both can take an optional
|
||||
transition. config.empty_window is responsible for displaying the
|
||||
window, while config.window_show_transition and
|
||||
config.window_hide_transition are default transitions. The state of
|
||||
the window can be determined by testing _window. The
|
||||
renpy.shown_window function can be called to suppress displaying the
|
||||
empty window, and is called automatically when characters speak.
|
||||
|
||||
|
||||
Hotspots for the game menu buttons can be defined as part of
|
||||
layout.imagemap_load_save, layout.imagemap_preferences, and
|
||||
layout.imagemap_yesno_prompt. Doing so prevents layout.navigation from
|
||||
being called for that screen. It also allows opaque imagemaps to be
|
||||
used, rather than forcing them to be transparent to allow the
|
||||
navigation to show through.
|
||||
|
||||
|
||||
There is a new config.windows_icon variable, that lets one set the
|
||||
window icon for Windows separately from Mac OS X and Linux.
|
||||
|
||||
|
||||
Ren'Py now automatically scales itself down when it detects that the
|
||||
game window is too large for the screen.
|
||||
|
||||
|
||||
The define.move_transitions function can now pass keyword arguments to
|
||||
the moves it creates. The most useful thing with this is to pass
|
||||
subpixel=True, in order to create subpixel move transitions.
|
||||
|
||||
|
||||
The Motion (including Move and Pan), Zoom, RotoZoom, and FactorZoom
|
||||
displayables now use the style.motion style, which now has xanchor and
|
||||
yanchor both set to 0. This gives these movements the same semantics
|
||||
when used inside an image clause as they have outside one.
|
||||
|
||||
|
||||
im.Grayscale and im.Sepia now take properties, so they can be
|
||||
positioned.
|
||||
|
||||
|
||||
The new renpy.get_placement function returns information about the
|
||||
placement of displayables.
|
||||
|
||||
|
||||
Improved the render management code, so there should no longer be any
|
||||
leaks reported during shutdown.
|
||||
|
||||
|
||||
Deal with the case where a bmfont has a negative offset for the first
|
||||
character in a string.
|
||||
|
||||
|
||||
Added more verbose diagnostics when illegal statements are run in the
|
||||
init phase.
|
||||
|
||||
|
||||
Added _rollback, which controls if rollback is enabled.
|
||||
|
||||
|
||||
Added a target parameter to renpy.full_restart, which allows the main
|
||||
menu screen to be selected after a restart.
|
||||
|
||||
|
||||
|
||||
Fixed a bug that caused layout.imagemap_main_menu to call a label even
|
||||
though there was a button with the same name.
|
||||
|
||||
Fixed a bug that prevented Zoom from working in non-bilinear mode.
|
||||
|
||||
Fixed a bug that could cause buttons not not consume events when using
|
||||
an imagemap main menu.
|
||||
|
||||
Fixed a bug that caused Transform to produce an incorrectly-sized
|
||||
render.
|
||||
|
||||
Fixed a bug that could cause crashing when rolling back to a Zoom with
|
||||
an after_child.
|
||||
|
||||
Fixed a bug that could cause segfaults when saving overly-complicated
|
||||
images.
|
||||
|
||||
|
||||
New in Ren'Py 6.9.0
|
||||
-------------------
|
||||
|
||||
@@ -117,6 +345,14 @@ Ren'Py now autosaves when entering the quit prompt, and will not actually
|
||||
quit until this autosave is complete.
|
||||
|
||||
|
||||
The default framerate limit (config.framerate) has been raised to
|
||||
100fps. This make tearing less noticable than on a 60hz screen.
|
||||
|
||||
|
||||
Added renpy.partial as a version of renpy.curry that requires two
|
||||
function calls, rather than three.
|
||||
|
||||
|
||||
Fixed a divide by zero error that occured when Alpha was used for 0
|
||||
seconds.
|
||||
|
||||
@@ -4266,4 +4502,3 @@ controls which transitions are performed.
|
||||
|
||||
Added a Pan function which can be used in an at clause. This allows us
|
||||
to pan over a background image.
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Copyright 2004-2009 PyTom <pytom@bishoujo.us>
|
||||
Ren'Py itself is covered by the terms of the following (MIT) license:
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
@@ -19,9 +20,6 @@ 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.
|
||||
|
||||
---
|
||||
|
||||
(The above is the MIT License)
|
||||
|
||||
Please see each individual source file for a list of copyright
|
||||
holders. The pictures of Eileen in the demo are Copyright 2006
|
||||
@@ -34,25 +32,20 @@ launchers may contain code taken from the following projects:
|
||||
* Pygame (LGPL)
|
||||
* SDL (LGPL)
|
||||
* SDL_image (LGPL)
|
||||
* SDL_sound (LGPL)
|
||||
* SDL_ttf (LGPL)
|
||||
* SDL_mixer (LGPL)
|
||||
* Freetype (LGPL)
|
||||
* FFmpeg (LGPL)
|
||||
* jpeg (JPEG License)
|
||||
* libmodplug (Public Domain)
|
||||
* libogg (Xiph.org License)
|
||||
* libpng (PNG license)
|
||||
* libvorbis (Xiph.org License)
|
||||
* smpeg (LGPL)
|
||||
* speex (Xiph.org License)
|
||||
* zlib (Zlib License)
|
||||
* zlib (Zlib License)
|
||||
* bzip2 (Bzip2 License)
|
||||
* pyobjc (MIT License)
|
||||
|
||||
The Linux launcher may also include code from:
|
||||
The Linux build may also include code from:
|
||||
|
||||
* directfb (LGPL)
|
||||
* svgalib (LGPL)
|
||||
* svgalib (LGPL)
|
||||
|
||||
For the purpose of LGPL compliance, the source code to all LGPL
|
||||
software we depend on is either in the Ren'Py package (available from
|
||||
@@ -61,9 +54,13 @@ http://www.renpy.org/), or in the renpy-deps package
|
||||
by including a copy of this license with every copy of Ren'Py you
|
||||
distribute, and referring to it in your project's README file.
|
||||
|
||||
The default Ren'Py build distributes Ren'Py alongside jEdit, which is
|
||||
licensed under the GNU GPL. The source code to jEdit is distributed as
|
||||
part of the renpy-deps package (http://www.renpy.org/dl/lgpl/).
|
||||
|
||||
|
||||
GNU Lesser General Public License
|
||||
---------------------------------
|
||||
=================================
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
@@ -575,7 +572,7 @@ That's all there is to it!
|
||||
|
||||
|
||||
Python License
|
||||
--------------
|
||||
==============
|
||||
|
||||
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
||||
@@ -625,7 +622,7 @@ Agreement.
|
||||
|
||||
|
||||
Jpeg License
|
||||
------------
|
||||
============
|
||||
|
||||
In plain English:
|
||||
|
||||
@@ -674,39 +671,8 @@ commercial products, provided that all warranty or liability claims are
|
||||
assumed by the product vendor.
|
||||
|
||||
|
||||
Xiph.org License
|
||||
----------------
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
PNG License
|
||||
-----------
|
||||
===========
|
||||
|
||||
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||
@@ -734,9 +700,8 @@ supporting the PNG file format in commercial products. If you use this
|
||||
source code in a product, acknowledgment is not required but would be
|
||||
appreciated.
|
||||
|
||||
|
||||
Zlib License
|
||||
------------
|
||||
============
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -754,8 +719,9 @@ Zlib License
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
Bzip2 License
|
||||
-------------
|
||||
=============
|
||||
|
||||
This program, "bzip2", the associated library "libbzip2", and all
|
||||
documentation, are copyright (C) 1996-2005 Julian R Seward. All
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
build_exe.py run_game
|
||||
@@ -31,6 +31,7 @@ def main():
|
||||
'pygame.surfarray',
|
||||
'pygame.mixer',
|
||||
'pygame.mixer_music',
|
||||
'pygame.font',
|
||||
'_ssl',
|
||||
'_hashlib',
|
||||
'win32con',
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
1#!/usr/bin/env python
|
||||
|
||||
import glob
|
||||
import re
|
||||
from sets import Set as set
|
||||
import sys
|
||||
|
||||
seen_files = set()
|
||||
seen_strings = set()
|
||||
|
||||
def tl(fn, s):
|
||||
|
||||
s = eval(s)
|
||||
|
||||
if len(s) < 3:
|
||||
return
|
||||
|
||||
if s in seen_strings:
|
||||
return
|
||||
|
||||
if fn not in seen_files:
|
||||
print >>out
|
||||
print >>out, " # Translatable strings found in", fn
|
||||
print >>out
|
||||
seen_files.add(fn)
|
||||
|
||||
print >>out, " config.translations[%r] = %r" % (s, s)
|
||||
seen_strings.add(s)
|
||||
|
||||
def process(fn):
|
||||
|
||||
data = file(fn).read()
|
||||
|
||||
for m in re.finditer(r'\bu\"(\\"|[^"])+\"', data):
|
||||
tl(fn, m.group(0))
|
||||
|
||||
for m in re.finditer(r"\bu\'(\\'|[^'])+\'", data):
|
||||
tl(fn, m.group(0))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# out = file("extras/translations.rpy", "w")
|
||||
out = sys.stdout
|
||||
|
||||
print >>out, "# This file contains a list of all of the phrases you can translate"
|
||||
print >>out, "# from the Ren'Py launcher."
|
||||
print >>out, ""
|
||||
print >>out, "init python:"
|
||||
|
||||
for fn in glob.glob("launcher/*.rpy"):
|
||||
process(fn)
|
||||
@@ -0,0 +1,84 @@
|
||||
1#!/usr/bin/env python
|
||||
|
||||
import collections
|
||||
import glob
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
# A map from string to filename, line number where the string is found.
|
||||
strings = collections.defaultdict(list)
|
||||
|
||||
def process(fn):
|
||||
|
||||
lineno = 0
|
||||
|
||||
for data in file(fn, "r"):
|
||||
|
||||
lineno += 1
|
||||
|
||||
matches = [ ]
|
||||
|
||||
matches += re.finditer(r'\bu\"(\\"|[^"])+\"', data)
|
||||
matches += re.finditer(r"\bu\'(\\'|[^'])+\'", data)
|
||||
|
||||
for m in matches:
|
||||
s = m.group(0)[2:-1]
|
||||
|
||||
if "\\u" in s:
|
||||
continue
|
||||
|
||||
if len(s) == 1:
|
||||
continue
|
||||
|
||||
strings[s].append("%s:%d" % (fn, lineno))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
files = [ ]
|
||||
|
||||
files += glob.glob("launcher2/*.rpy")
|
||||
files += glob.glob("common/*.rpy")
|
||||
files += glob.glob("common/_layout/*.rpym")
|
||||
files += glob.glob("common/_compat/*.rpym")
|
||||
|
||||
for fn in files:
|
||||
process(fn)
|
||||
|
||||
|
||||
converse = [ ]
|
||||
|
||||
for k, v in strings.iteritems():
|
||||
v = " ".join(sorted(v))
|
||||
converse.append((v, k))
|
||||
|
||||
converse.sort()
|
||||
|
||||
print """\
|
||||
# Ren'Py Visual Novel Engine
|
||||
# Copyright (C) 2009 PyTom <pytom@bishoujo.us>
|
||||
# This file is distributed under the same license as the Ren'Py package.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: mainline\\n"
|
||||
"Report-Msgid-Bugs-To: PyTom <pytom@bishoujo.us>\\n"
|
||||
"POT-Creation-Date: %s\\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\\n"
|
||||
"MIME-Version: 1.0\\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\\n"
|
||||
"Content-Transfer-Encoding: 8bit\\n"
|
||||
""" % time.strftime("%Y-%m-%d %H:%M%z")
|
||||
|
||||
for v, k in converse:
|
||||
print
|
||||
print "#:", v
|
||||
print "#, python-format"
|
||||
print "msgid \"%s\"" % k
|
||||
print "msgstr \"\""
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
1#!/usr/bin/env python
|
||||
|
||||
import collections
|
||||
import glob
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import os
|
||||
|
||||
# A map from string to filename, line number where the string is found.
|
||||
strings = collections.defaultdict(list)
|
||||
|
||||
def process(fn):
|
||||
|
||||
lineno = 0
|
||||
|
||||
for data in file(fn, "r"):
|
||||
|
||||
lineno += 1
|
||||
|
||||
matches = [ ]
|
||||
|
||||
matches += re.finditer(r'\bu\"(\\"|[^"])+\"', data)
|
||||
matches += re.finditer(r"\bu\'(\\'|[^'])+\'", data)
|
||||
|
||||
for m in matches:
|
||||
s = m.group(0)[2:-1]
|
||||
|
||||
if "\\u" in s:
|
||||
continue
|
||||
|
||||
if len(s) == 1:
|
||||
continue
|
||||
|
||||
strings[s].append("%s:%d" % (fn, lineno))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
files = [ ]
|
||||
|
||||
files += glob.glob("launcher/*.rpy")
|
||||
files += glob.glob("common/*.rpy")
|
||||
files += glob.glob("common/_layout/*.rpym")
|
||||
files += glob.glob("common/_compat/*.rpym")
|
||||
|
||||
if "launcher/strings.rpy" in files:
|
||||
files.remove("launcher/strings.rpy")
|
||||
|
||||
for fn in files:
|
||||
process(fn)
|
||||
|
||||
converse = [ ]
|
||||
|
||||
for k, v in strings.iteritems():
|
||||
v = " ".join(sorted(v))
|
||||
converse.append((v, k))
|
||||
|
||||
converse.sort()
|
||||
|
||||
f = file("launcher/strings.rpy", "w")
|
||||
|
||||
files = set(i for i in os.listdir("launcher") if i.endswith(".rpy"))
|
||||
|
||||
print >>f, """\
|
||||
init python:
|
||||
LAUNCHER_RPYS = %r
|
||||
|
||||
TRANSLATION_STRINGS = [
|
||||
""" % files
|
||||
|
||||
for v, k in converse:
|
||||
# print
|
||||
# print "#:", v
|
||||
# print "#, python-format"
|
||||
|
||||
print >>f, " %r," % unicode(k)
|
||||
|
||||
print >>f, """\
|
||||
]
|
||||
"""
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import glob
|
||||
import os
|
||||
|
||||
files = glob.glob("common/*.rpy")
|
||||
files.sort()
|
||||
|
||||
styles = [ ]
|
||||
|
||||
for fn in files:
|
||||
f = file(fn)
|
||||
|
||||
fi = iter(f)
|
||||
|
||||
for l in iter(fi):
|
||||
|
||||
l = l.strip()
|
||||
|
||||
if l.startswith("### "):
|
||||
|
||||
prefix, style, parent = l.split()
|
||||
|
||||
desc = ""
|
||||
|
||||
for l in fi:
|
||||
|
||||
l = l.strip()
|
||||
if not l.startswith("# "):
|
||||
break
|
||||
|
||||
desc = desc + " " + l[2:]
|
||||
|
||||
styles.append(' style.create("%s", "%s", "%s")' % (style, parent, desc[1:]))
|
||||
|
||||
f.close()
|
||||
|
||||
f = file("common/style.rpy")
|
||||
of = file("common/style.rpy.new", "w")
|
||||
|
||||
fi = iter(f)
|
||||
|
||||
for l in fi:
|
||||
|
||||
of.write(l)
|
||||
|
||||
if l.startswith("# AUTOMATICALLY GENERATED"):
|
||||
|
||||
for l in styles:
|
||||
of.write(l + "\n")
|
||||
|
||||
for l in fi:
|
||||
if l.startswith("# END AUTOMATICALLY GENERATED"):
|
||||
break
|
||||
|
||||
of.write(l)
|
||||
|
||||
f.close()
|
||||
of.close()
|
||||
|
||||
os.rename("common/style.rpy", "common/style.rpy.bak")
|
||||
os.rename("common/style.rpy.new", "common/style.rpy")
|
||||
@@ -1,48 +0,0 @@
|
||||
1#!/usr/bin/env python
|
||||
|
||||
import glob
|
||||
import re
|
||||
from sets import Set as set
|
||||
import sys
|
||||
|
||||
seen_files = set()
|
||||
seen_strings = set()
|
||||
|
||||
def tl(fn, s):
|
||||
|
||||
s = eval(s)
|
||||
|
||||
if s in seen_strings:
|
||||
return
|
||||
|
||||
if fn not in seen_files:
|
||||
print >>out
|
||||
print >>out, " # Translatable strings found in", fn
|
||||
print >>out
|
||||
seen_files.add(fn)
|
||||
|
||||
print >>out, " config.translations[%r] = %r" % (s, s)
|
||||
seen_strings.add(s)
|
||||
|
||||
def process(fn):
|
||||
|
||||
data = file(fn).read()
|
||||
|
||||
for m in re.finditer(r'\bu\"(\\"|[^"])+\"', data):
|
||||
tl(fn, m.group(0))
|
||||
|
||||
for m in re.finditer(r"\bu\'(\\'|[^'])+\'", data):
|
||||
tl(fn, m.group(0))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# out = file("extras/translations.rpy", "w")
|
||||
out = sys.stdout
|
||||
|
||||
print >>out, "# This file contains a list of all of the phrases you can translate"
|
||||
print >>out, "# from the Ren'Py common code."
|
||||
print >>out, ""
|
||||
print >>out, "init python:"
|
||||
|
||||
for fn in glob.glob("common/*.rpy") + glob.glob("common/_layout/*.rpym") + glob.glob("common/_compat/*.rpym"):
|
||||
process(fn)
|
||||
@@ -13,6 +13,9 @@ init -1210 python:
|
||||
if version <= (6, 5, 0):
|
||||
layout.compat()
|
||||
|
||||
if version <= (6, 9, 1):
|
||||
store.library = store.config
|
||||
|
||||
init 1210 python hide::
|
||||
|
||||
# This returns true if the script_version is <= the
|
||||
@@ -54,6 +57,9 @@ init 1210 python hide::
|
||||
if compat(6, 2, 0):
|
||||
config.reject_backslash = False
|
||||
|
||||
if compat(6, 9, 0):
|
||||
style.motion.clear()
|
||||
|
||||
if "Fullscreen" in config.translations:
|
||||
fs = _("Fullscreen")
|
||||
config.translations.setdefault("Fullscreen 4:3", fs + " 4:3")
|
||||
|
||||
@@ -62,69 +62,69 @@ init -1110 python:
|
||||
return .5 - math.cos(math.pi * x) / 2.0
|
||||
|
||||
# This defines a family of move transitions.
|
||||
def move_transitions(prefix, delay, time_warp=None, in_time_warp=None, out_time_warp=None, old=False, layers=[ 'master' ]):
|
||||
def move_transitions(prefix, delay, time_warp=None, in_time_warp=None, out_time_warp=None, old=False, layers=[ 'master' ], **kwargs):
|
||||
moves = {
|
||||
"" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
factory=MoveFactory(time_warp=time_warp)),
|
||||
factory=MoveFactory(time_warp=time_warp, **kwargs)),
|
||||
|
||||
"inright" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
factory=MoveFactory(time_warp=time_warp),
|
||||
enter_factory=MoveIn((1.0, None, 0.0, None), time_warp=in_time_warp)),
|
||||
factory=MoveFactory(time_warp=time_warp, **kwargs),
|
||||
enter_factory=MoveIn((1.0, None, 0.0, None), time_warp=in_time_warp, **kwargs)),
|
||||
|
||||
"inleft" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
factory=MoveFactory(time_warp=time_warp),
|
||||
enter_factory=MoveIn((0.0, None, 1.0, None), time_warp=in_time_warp)),
|
||||
factory=MoveFactory(time_warp=time_warp, **kwargs),
|
||||
enter_factory=MoveIn((0.0, None, 1.0, None), time_warp=in_time_warp, **kwargs)),
|
||||
|
||||
"intop" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
factory=MoveFactory(time_warp=time_warp),
|
||||
enter_factory=MoveIn((None, 0.0, None, 1.0), time_warp=in_time_warp)),
|
||||
factory=MoveFactory(time_warp=time_warp, **kwargs),
|
||||
enter_factory=MoveIn((None, 0.0, None, 1.0), time_warp=in_time_warp, **kwargs)),
|
||||
|
||||
"inbottom" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
factory=MoveFactory(time_warp=time_warp),
|
||||
enter_factory=MoveIn((None, 1.0, None, 0.0), time_warp=in_time_warp)),
|
||||
factory=MoveFactory(time_warp=time_warp, **kwargs),
|
||||
enter_factory=MoveIn((None, 1.0, None, 0.0), time_warp=in_time_warp, **kwargs)),
|
||||
|
||||
"outright" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
factory=MoveFactory(time_warp=time_warp),
|
||||
leave_factory=MoveOut((1.0, None, 0.0, None), time_warp=out_time_warp)),
|
||||
factory=MoveFactory(time_warp=time_warp, **kwargs),
|
||||
leave_factory=MoveOut((1.0, None, 0.0, None), time_warp=out_time_warp, **kwargs)),
|
||||
|
||||
"outleft" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
factory=MoveFactory(time_warp=time_warp),
|
||||
leave_factory=MoveOut((0.0, None, 1.0, None), time_warp=out_time_warp)),
|
||||
factory=MoveFactory(time_warp=time_warp, **kwargs),
|
||||
leave_factory=MoveOut((0.0, None, 1.0, None), time_warp=out_time_warp, **kwargs)),
|
||||
|
||||
"outtop" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
factory=MoveFactory(time_warp=time_warp),
|
||||
leave_factory=MoveOut((None, 0.0, None, 1.0), time_warp=out_time_warp)),
|
||||
factory=MoveFactory(time_warp=time_warp, **kwargs),
|
||||
leave_factory=MoveOut((None, 0.0, None, 1.0), time_warp=out_time_warp, **kwargs)),
|
||||
|
||||
"outbottom" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
factory=MoveFactory(time_warp=time_warp),
|
||||
leave_factory=MoveOut((None, 1.0, None, 0.0), time_warp=time_warp)),
|
||||
factory=MoveFactory(time_warp=time_warp, **kwargs),
|
||||
leave_factory=MoveOut((None, 1.0, None, 0.0), time_warp=time_warp, **kwargs)),
|
||||
}
|
||||
|
||||
for k, v in moves.iteritems():
|
||||
|
||||
@@ -18,7 +18,7 @@ init -1105 python:
|
||||
|
||||
# This takes care of actually displaying button menus.
|
||||
def _display_button_menu(menuitems):
|
||||
|
||||
|
||||
narration = [ s for s, i in menuitems if i is None and s ]
|
||||
menuitems = [ (s, i) for s, i in menuitems if i is not None or not s ]
|
||||
|
||||
|
||||
@@ -69,6 +69,12 @@ init -1180 python:
|
||||
|
||||
config.with_callback = _default_with_callback
|
||||
|
||||
|
||||
def _default_empty_window():
|
||||
store.narrator("", interact=False)
|
||||
|
||||
config.empty_window = _default_empty_window
|
||||
|
||||
style.skip_indicator = Style(style.default, heavy=True, help='The skip indicator.')
|
||||
style.skip_indicator.xpos = 10
|
||||
style.skip_indicator.ypos = 10
|
||||
@@ -123,10 +129,13 @@ init -1180 python:
|
||||
return
|
||||
|
||||
_preferences.fullscreen = False
|
||||
|
||||
import webbrowser
|
||||
webbrowser.open_new("file:///" + config.basedir + "/" + config.help)
|
||||
|
||||
|
||||
try:
|
||||
import webbrowser
|
||||
webbrowser.open_new("file:///" + config.basedir + "/" + config.help)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
init -1180 python hide:
|
||||
|
||||
@@ -134,18 +143,36 @@ init -1180 python hide:
|
||||
def screenshot():
|
||||
import os.path
|
||||
import os
|
||||
|
||||
pattern = os.environ.get("RENPY_SCREENSHOT_PATTERN", "screenshot%04d.png")
|
||||
import __main__
|
||||
|
||||
pattern = os.environ.get("RENPY_SCREENSHOT_PATTERN", "screenshot%04d.png")
|
||||
|
||||
# Pick the directory to save into.
|
||||
dest = config.renpy_base.rstrip("/")
|
||||
|
||||
# Guess if we're an OSX App.
|
||||
if dest.endswith("/Contents/Resources/autorun"):
|
||||
# Go up 4 directories.
|
||||
dest = os.path.dirname(dest)
|
||||
dest = os.path.dirname(dest)
|
||||
dest = os.path.dirname(dest)
|
||||
dest = os.path.dirname(dest)
|
||||
|
||||
# Try to pick a filename.
|
||||
i = 1
|
||||
while True:
|
||||
fn = pattern % i
|
||||
fn = dest + "/" + pattern % i
|
||||
if not os.path.exists(fn):
|
||||
break
|
||||
i += 1
|
||||
|
||||
renpy.screenshot(fn)
|
||||
|
||||
try:
|
||||
renpy.screenshot(fn)
|
||||
except:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
def dump_styles():
|
||||
if config.developer:
|
||||
renpy.style.write_text("styles.txt")
|
||||
@@ -284,32 +311,13 @@ label _hide_windows:
|
||||
python:
|
||||
_windows_hidden = True
|
||||
ui.saybehavior(dismiss=['dismiss', 'hide_windows'])
|
||||
ui.interact(suppress_overlay=True)
|
||||
ui.interact(suppress_overlay=True, suppress_window=True)
|
||||
_windows_hidden = False
|
||||
|
||||
return
|
||||
|
||||
|
||||
# This code here handles check for the correct version of the Ren'Py module.
|
||||
|
||||
label _check_module:
|
||||
|
||||
if not config.module_warning:
|
||||
return
|
||||
|
||||
python hide:
|
||||
module_info = _(u"While Ren'Py games may be playable without the renpy module, some features may be disabled. For more information, read the module/README.txt file or go to http://www.bishoujo.us/renpy/.")
|
||||
|
||||
if renpy.module_version() == 0:
|
||||
_show_exception(_(u"renpy module not found."),
|
||||
_(u"The renpy module could not be loaded on your system.") + "\n\n" + module_info)
|
||||
elif renpy.module_version() < config.module_version:
|
||||
_show_exception(_(u"Old renpy module found."),
|
||||
_(u"An old version (%d) of the Ren'Py module was found on your system, while this game requires version %d.") % (renpy.module_version(), config.module_version) + "\n\n" + module_info)
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
label _save_reload_game:
|
||||
python hide:
|
||||
@@ -509,7 +517,7 @@ init 1180 python:
|
||||
|
||||
label _enter_menu:
|
||||
python hide:
|
||||
renpy.movie_stop()
|
||||
renpy.movie_stop(only_fullscreen=True)
|
||||
renpy.take_screenshot((config.thumbnail_width, config.thumbnail_height))
|
||||
|
||||
renpy.context()._menu = True
|
||||
@@ -518,9 +526,11 @@ label _enter_menu:
|
||||
renpy.context().main_menu = False
|
||||
renpy.context_dynamic("main_menu")
|
||||
renpy.context_dynamic("_window_subtitle")
|
||||
|
||||
renpy.context_dynamic("_window")
|
||||
|
||||
store.main_menu = False
|
||||
store._window_subtitle = config.menu_window_subtitle
|
||||
store._window = False
|
||||
|
||||
store.mouse_visible = True
|
||||
store.suppress_overlay = True
|
||||
@@ -599,7 +609,7 @@ label _return:
|
||||
|
||||
if renpy.context().main_menu:
|
||||
$ renpy.transition(config.game_main_transition)
|
||||
jump _main_menu
|
||||
jump _main_menu_screen
|
||||
|
||||
$ renpy.transition(config.exit_transition)
|
||||
|
||||
@@ -652,7 +662,7 @@ label _start:
|
||||
for i in config.start_callbacks:
|
||||
i()
|
||||
|
||||
call _check_module from _call__check_module_1
|
||||
# call _check_module from _call__check_module_1
|
||||
call _load_reload_game from _call__load_reload_game_1
|
||||
|
||||
scene black
|
||||
@@ -674,12 +684,6 @@ label _start:
|
||||
|
||||
$ renpy.block_rollback()
|
||||
|
||||
python hide:
|
||||
for i in range(0, 7):
|
||||
# renpy.music.stop(channel=i)
|
||||
# renpy.sound.stop(channel=i)
|
||||
pass
|
||||
|
||||
if config.main_menu_music:
|
||||
$ renpy.music.play(config.main_menu_music, if_changed=True)
|
||||
else:
|
||||
@@ -695,15 +699,19 @@ label _start:
|
||||
jump expression _restart[1]
|
||||
|
||||
label _invoke_main_menu:
|
||||
|
||||
$ renpy.call_in_new_context("_enter_main_menu")
|
||||
|
||||
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.
|
||||
jump start
|
||||
|
||||
# At this point, we've been switched into a new context. So we
|
||||
# initialize it.
|
||||
label _enter_main_menu:
|
||||
label _main_menu(_main_menu_screen="_main_menu_screen"):
|
||||
|
||||
call _enter_menu from _call__enter_menu_1
|
||||
|
||||
@@ -713,9 +721,11 @@ label _enter_main_menu:
|
||||
|
||||
renpy.context().main_menu = True
|
||||
store.main_menu = True
|
||||
|
||||
jump expression _main_menu_screen
|
||||
|
||||
# This is called to show the main menu to the user.
|
||||
label _main_menu:
|
||||
label _main_menu_screen:
|
||||
|
||||
# Let the user completely override the main menu. (But please note
|
||||
# it still lives in the menu context, rather than the game context.)
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
# This file contains code that sets up the various mixers, based on how
|
||||
# the user sets config.has_music, .has_sound, and .has_voice.
|
||||
|
||||
init -1130:
|
||||
|
||||
init -1130 python hide:
|
||||
|
||||
# Set to true in the very unlikely event you want to manually init
|
||||
# the sound system.
|
||||
$ config.force_sound = False
|
||||
config.force_sound = False
|
||||
|
||||
# basics: True if the game will have music.
|
||||
$ config.has_music = True
|
||||
config.has_music = True
|
||||
|
||||
# basics: True if the game will have sound effects.
|
||||
$ config.has_sound = True
|
||||
config.has_sound = True
|
||||
|
||||
# Register 8 channels by default, for compatiblity with older version
|
||||
# of Ren'Py.
|
||||
for i in xrange(0, 8):
|
||||
renpy.music.register_channel(i)
|
||||
|
||||
renpy.music.register_channel("movie", "music", False, stop_on_mute=False)
|
||||
|
||||
# Set up default names for some of the channels.
|
||||
renpy.music.alias_channel(0, "sound")
|
||||
renpy.music.alias_channel(7, "music")
|
||||
renpy.music.alias_channel(2, "voice")
|
||||
|
||||
init 1130:
|
||||
|
||||
@@ -41,7 +53,6 @@ init 1130:
|
||||
else:
|
||||
for i, m in enumerate(mixers):
|
||||
renpy.sound.set_mixer(i, m, default=True)
|
||||
renpy.sound.set_pan(0, 0, channel=i)
|
||||
if m == 'music':
|
||||
renpy.music.set_music(i, True, default=True)
|
||||
else:
|
||||
|
||||
@@ -78,7 +78,7 @@ init -1100 python:
|
||||
return s
|
||||
|
||||
def nvl_show_core():
|
||||
|
||||
|
||||
if renpy.in_rollback():
|
||||
nvl_window = __s(style.nvl_window)['rollback']
|
||||
nvl_vbox = __s(style.nvl_vbox)['rollback']
|
||||
@@ -99,8 +99,14 @@ init -1100 python:
|
||||
rv = config.nvl_show_display_say(who, what, variant=nvl_variant, **kw)
|
||||
|
||||
ui.close()
|
||||
|
||||
renpy.shown_window()
|
||||
|
||||
return rv
|
||||
|
||||
def nvl_window():
|
||||
nvl_show_core()
|
||||
|
||||
def nvl_show(with_):
|
||||
nvl_show_core()
|
||||
renpy.with_statement(with_)
|
||||
@@ -208,7 +214,6 @@ init -1100 python:
|
||||
kind=adv)
|
||||
|
||||
def nvl_clear():
|
||||
|
||||
store.nvl_list = [ ]
|
||||
|
||||
# Run clear at the start of the game.
|
||||
@@ -219,6 +224,10 @@ init -1100 python:
|
||||
if nvl_list is None:
|
||||
store.nvl_list = [ ]
|
||||
|
||||
ui.layer("transient")
|
||||
ui.clear()
|
||||
ui.close()
|
||||
|
||||
ui.window(style=__s(style.nvl_window))
|
||||
ui.vbox(style=__s(style.nvl_vbox))
|
||||
|
||||
|
||||
@@ -164,7 +164,6 @@ python early hide:
|
||||
|
||||
renpy.music.queue(eval(p["file"]), channel=channel)
|
||||
|
||||
|
||||
renpy.statements.register('queue music',
|
||||
parse=parse_queue_music,
|
||||
execute=execute_queue_music,
|
||||
@@ -254,10 +253,131 @@ python early hide:
|
||||
parse=parse_stop_music,
|
||||
execute=execute_stop_sound)
|
||||
|
||||
|
||||
# Generic play/queue/stop statements. These take a channel name as
|
||||
# the second thing.
|
||||
|
||||
def parse_play_generic(l, parse_play_music=parse_play_music):
|
||||
channel = l.name()
|
||||
|
||||
if channel is None:
|
||||
renpy.error('play requires a channel')
|
||||
|
||||
rv = parse_play_music(l)
|
||||
if rv["channel"] is None:
|
||||
rv["channel"] = repr(channel)
|
||||
|
||||
return rv
|
||||
|
||||
def parse_queue_generic(l, parse_queue_music=parse_queue_music):
|
||||
channel = l.name()
|
||||
|
||||
if channel is None:
|
||||
renpy.error('queue requires a channel')
|
||||
|
||||
rv = parse_queue_music(l)
|
||||
if rv["channel"] is None:
|
||||
rv["channel"] = repr(channel)
|
||||
|
||||
return rv
|
||||
|
||||
def parse_stop_generic(l, parse_stop_music=parse_stop_music):
|
||||
channel = l.name()
|
||||
|
||||
if channel is None:
|
||||
renpy.error('stop requires a channel')
|
||||
|
||||
rv = parse_stop_music(l)
|
||||
if rv["channel"] is None:
|
||||
rv["channel"] = repr(channel)
|
||||
|
||||
return rv
|
||||
|
||||
def lint_play_generic(p, lint_play_music=lint_play_music):
|
||||
channel = eval(p["channel"])
|
||||
|
||||
if not renpy.music.channel_defined(channel):
|
||||
renpy.error("channel %r is not defined" % channel)
|
||||
|
||||
lint_play_music(p)
|
||||
|
||||
def lint_stop_generic(p):
|
||||
channel = eval(p["channel"])
|
||||
|
||||
if not renpy.music.channel_defined(channel):
|
||||
renpy.error("channel %r is not defined" % channel)
|
||||
|
||||
renpy.statements.register('play',
|
||||
parse=parse_play_generic,
|
||||
execute=execute_play_music,
|
||||
predict=predict_play_music,
|
||||
lint=lint_play_generic)
|
||||
|
||||
renpy.statements.register('queue',
|
||||
parse=parse_queue_generic,
|
||||
execute=execute_queue_music,
|
||||
lint=lint_play_generic)
|
||||
|
||||
renpy.statements.register('stop',
|
||||
parse=parse_stop_generic,
|
||||
execute=execute_stop_music,
|
||||
lint=lint_stop_generic)
|
||||
|
||||
|
||||
# The "window show" and "window hide" statements.
|
||||
def parse_window(l):
|
||||
p = l.simple_expression()
|
||||
if not l.eol():
|
||||
renpy.error('expected end of line')
|
||||
|
||||
return p
|
||||
|
||||
def lint_window(p):
|
||||
if p is not None:
|
||||
_try_eval(p, 'window transition')
|
||||
|
||||
def execute_window_show(p):
|
||||
if store._window:
|
||||
return
|
||||
|
||||
if p is not None:
|
||||
trans = eval(p)
|
||||
else:
|
||||
trans = config.window_show_transition
|
||||
|
||||
renpy.with_statement(None)
|
||||
store._window = True
|
||||
renpy.with_statement(trans)
|
||||
|
||||
def execute_window_hide(p):
|
||||
if not _window:
|
||||
return
|
||||
|
||||
if p is not None:
|
||||
trans = eval(p)
|
||||
else:
|
||||
trans = config.window_hide_transition
|
||||
|
||||
renpy.with_statement(None)
|
||||
store._window = False
|
||||
renpy.with_statement(trans)
|
||||
|
||||
renpy.statements.register('window show',
|
||||
parse=parse_window,
|
||||
execute=execute_window_show,
|
||||
lint=lint_window)
|
||||
|
||||
renpy.statements.register('window hide',
|
||||
parse=parse_window,
|
||||
execute=execute_window_hide,
|
||||
lint=lint_window)
|
||||
|
||||
|
||||
init -1200 python:
|
||||
|
||||
config.window_show_transition = None
|
||||
config.window_hide_transition = None
|
||||
|
||||
def _try_eval(e, what):
|
||||
try:
|
||||
return eval(e)
|
||||
|
||||
@@ -33,6 +33,7 @@ init -1200 python hide:
|
||||
style.image_placement = Style(style.default, help='default placement of images on the screen')
|
||||
style.image = Style(style.default, help="default style of images")
|
||||
|
||||
style.motion = Style(style.default, help="default style of motions and zooms.")
|
||||
style.animation = Style(style.default, help="default style of animations.")
|
||||
|
||||
style.say_label = Style(style.default, help='the name of the character speaking dialogue.')
|
||||
@@ -68,7 +69,7 @@ init -1200 python hide:
|
||||
style.hyperlink_text = Style(style.default, help='hyperlinked text')
|
||||
|
||||
style.viewport = Style(style.default, help='default style of viewports')
|
||||
style.transform = Style(style.default, help='default style of transforms')
|
||||
style.transform = Style(style.motion, help='default style of transforms')
|
||||
|
||||
style.list = Style(style.default)
|
||||
style.list_box = Style(style.vbox)
|
||||
@@ -199,6 +200,10 @@ init -1090 python:
|
||||
style.hbox.box_layout = 'horizontal'
|
||||
style.vbox.box_layout = 'vertical'
|
||||
|
||||
# Motions, zooms, rotozooms, and transforms.
|
||||
style.motion.xanchor = 0
|
||||
style.motion.yanchor = 0
|
||||
|
||||
# Windows.
|
||||
style.window.background = Solid((0, 0, 0, 192))
|
||||
style.window.xpadding = 6
|
||||
|
||||
@@ -306,7 +306,7 @@ init -1110 python hide:
|
||||
gm_root = None):
|
||||
|
||||
if button_menu is None:
|
||||
if config.script_version < (6, 9, 0):
|
||||
if (config.script_version is not None) and (config.script_version < (6, 9, 0)):
|
||||
button_menu = True
|
||||
else:
|
||||
button_menu = False
|
||||
|
||||
@@ -52,7 +52,7 @@ init -1120:
|
||||
# This is called on each interaction, to ensure that the
|
||||
# appropriate voice file is played for the user.
|
||||
def voice_interact():
|
||||
|
||||
|
||||
if not config.has_voice:
|
||||
return
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ init python:
|
||||
style.js_prefs_button.xminimum = 0.5
|
||||
style.js_prefs_box.box_first_spacing = 10
|
||||
|
||||
|
||||
|
||||
config.joystick_keys = [
|
||||
(u'Left', 'joy_left'),
|
||||
(u'Right', 'joy_right'),
|
||||
@@ -42,8 +40,6 @@ init python:
|
||||
(u'Hide Text', 'joy_hide'),
|
||||
(u'Menu', 'joy_menu'),
|
||||
]
|
||||
|
||||
|
||||
|
||||
def _joystick_select_binding():
|
||||
|
||||
@@ -55,8 +51,8 @@ init python:
|
||||
layout.button(_(label) + " - " + _(_preferences.joymap.get(key, u"Not Assigned")), "prefs_js", clicked=my_clicked, index=label)
|
||||
|
||||
def _joystick_get_binding():
|
||||
ui.add(renpy.display.joystick.JoyBehavior())
|
||||
ui.saybehavior()
|
||||
ui.add(renpy.display.joystick.JoyBehavior())
|
||||
|
||||
def _joystick_take_binding(binding, key):
|
||||
|
||||
@@ -79,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
|
||||
@@ -104,7 +100,7 @@ label joystick_preferences_screen:
|
||||
python:
|
||||
layout.navigation("joystick_preferences")
|
||||
_joystick_preferences()
|
||||
ui.interact()
|
||||
ui.interact(mouse="gamemenu")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ init python:
|
||||
ui.close() # slots
|
||||
ui.close() # whole thing
|
||||
|
||||
result = ui.interact()
|
||||
result = ui.interact(mouse="gamemenu")
|
||||
type, value = result
|
||||
|
||||
if type == "return":
|
||||
|
||||
@@ -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,7 +2,7 @@ init python:
|
||||
|
||||
class _ImageMapper(object):
|
||||
|
||||
def __init__(self, ground, idle, hover, selected_idle, selected_hover, hotspots):
|
||||
def __init__(self, screen, ground, idle, hover, selected_idle, selected_hover, hotspots):
|
||||
|
||||
self.idle = idle
|
||||
self.hover = hover
|
||||
@@ -13,10 +13,29 @@ init python:
|
||||
for (x1, y1, x2, y2, name) in 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)
|
||||
|
||||
ui.fixed(style='imagemap')
|
||||
ui.image(ground)
|
||||
|
||||
# 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
|
||||
|
||||
self.button(name, act, screen == screen_)
|
||||
|
||||
def button(self, name, clicked, selected):
|
||||
|
||||
if name not in self.hotspots:
|
||||
@@ -32,8 +51,8 @@ init python:
|
||||
hover = self.selected_hover
|
||||
else:
|
||||
idle = self.idle
|
||||
hover = self.selected_hover
|
||||
|
||||
hover = self.hover
|
||||
|
||||
ui.imagebutton(
|
||||
LiveCrop((x1, y1, (x2 - x1), (y2 - y1)), idle),
|
||||
LiveCrop((x1, y1, (x2 - x1), (y2 - y1)), hover),
|
||||
|
||||
@@ -233,10 +233,8 @@ init python:
|
||||
|
||||
__scratch.file_picker_page = fpp
|
||||
|
||||
# Show navigation
|
||||
layout.navigation(screen)
|
||||
|
||||
ime = _ImageMapper(
|
||||
screen,
|
||||
config.load_save_ground,
|
||||
config.load_save_idle,
|
||||
config.load_save_hover,
|
||||
@@ -291,7 +289,7 @@ init python:
|
||||
|
||||
ime.close()
|
||||
|
||||
result = ui.interact()
|
||||
result = ui.interact(mouse="gamemenu")
|
||||
type, value = result
|
||||
|
||||
if type == "return":
|
||||
|
||||
@@ -32,7 +32,8 @@ label main_menu_screen:
|
||||
rv = renpy.imagemap(
|
||||
config.main_menu_ground,
|
||||
config.main_menu_selected,
|
||||
config.main_menu_hotspots)
|
||||
config.main_menu_hotspots,
|
||||
mouse="mainmenu")
|
||||
|
||||
for e in config.main_menu:
|
||||
name = e[0]
|
||||
@@ -44,9 +45,12 @@ label main_menu_screen:
|
||||
if isinstance(act, basestring):
|
||||
act = ui.jumpsoutofcontext(act)
|
||||
act()
|
||||
|
||||
break
|
||||
else:
|
||||
ui.jumpsoutofcontext(rv)()
|
||||
|
||||
|
||||
jump main_menu_screen
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -39,9 +39,8 @@ init python:
|
||||
|
||||
def __show_preferences():
|
||||
|
||||
layout.navigation("prefs")
|
||||
|
||||
ime = _ImageMapper(
|
||||
"preferences",
|
||||
config.preferences_ground,
|
||||
config.preferences_idle,
|
||||
config.preferences_hover,
|
||||
@@ -128,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:
|
||||
|
||||
|
||||
@@ -17,9 +17,8 @@ init python hide:
|
||||
def yesno_prompt(screen, message):
|
||||
renpy.transition(config.intra_transition)
|
||||
|
||||
layout.navigation(screen)
|
||||
|
||||
ime = _ImageMapper(
|
||||
screen,
|
||||
config.yesno_prompt_ground,
|
||||
config.yesno_prompt_idle,
|
||||
config.yesno_prompt_hover,
|
||||
@@ -34,7 +33,7 @@ init python hide:
|
||||
|
||||
layout.prompt(message, "yesno")
|
||||
|
||||
rv = ui.interact()
|
||||
rv = ui.interact(mouse="gamemenu")
|
||||
renpy.transition(config.intra_transition)
|
||||
return rv
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ init python:
|
||||
ui.add(DynamicDisplayable(_file_picker_thumbnail))
|
||||
|
||||
try:
|
||||
rv = ui.interact()
|
||||
rv = ui.interact(mouse="gamemenu")
|
||||
finally:
|
||||
__session.scrollbar_position = adj.value
|
||||
__session.thumbnail = None
|
||||
|
||||
@@ -6,6 +6,8 @@ init:
|
||||
image logo crop = im.Crop("logo.png", 0, 0, 100, 307)
|
||||
|
||||
image logo scale = im.Scale("logo.png", 100, 150)
|
||||
|
||||
image logo factorscale = im.FactorScale("logo.png", 1.5, 1.5)
|
||||
|
||||
image logo composite = im.Composite((200, 407),
|
||||
(0, 0), "logo.png",
|
||||
@@ -101,8 +103,13 @@ label demo_imageops:
|
||||
show logo scale at logopos
|
||||
with dissolve
|
||||
|
||||
e "The im.Scale operation lets us change the size of images."
|
||||
e "The im.Scale operation lets us scale an image to a particular size."
|
||||
|
||||
show logo factorscale at logopos
|
||||
with dissolve
|
||||
|
||||
e "im.FactorScale lets us do the same thing, except to a factor of the original size."
|
||||
|
||||
show logo green at logopos
|
||||
with dissolve
|
||||
|
||||
|
||||
@@ -223,6 +223,8 @@ label demo_minigame:
|
||||
|
||||
e "Now, why don't we play some pong?"
|
||||
|
||||
window hide None
|
||||
|
||||
label demo_minigame_pong:
|
||||
|
||||
# Put up the pong background, in the usual fashion.
|
||||
@@ -232,11 +234,13 @@ label demo_minigame_pong:
|
||||
python:
|
||||
ui.add(PongDisplayable())
|
||||
winner = ui.interact(suppress_overlay=True, suppress_underlay=True)
|
||||
|
||||
|
||||
scene bg washington
|
||||
show eileen vhappy
|
||||
|
||||
|
||||
window show None
|
||||
|
||||
|
||||
if winner == "eileen":
|
||||
|
||||
e "I win!"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# 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:
|
||||
|
||||
@@ -22,18 +23,35 @@ label demo_multimedia:
|
||||
# This plays a sound effect.
|
||||
play sound "18005551212.ogg"
|
||||
|
||||
e "We can also play up to eight channels of sound effects on top of the music."
|
||||
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."
|
||||
|
||||
e "We also support playing mpeg movies, but we don't have one to show you right now."
|
||||
|
||||
show eileen concerned
|
||||
|
||||
e "Sorry."
|
||||
|
||||
show eileen happy
|
||||
$ 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
|
||||
|
||||
@@ -10,6 +10,8 @@ init:
|
||||
|
||||
label demo_nvlmode:
|
||||
|
||||
window hide
|
||||
|
||||
nvl clear
|
||||
nvl show dissolve
|
||||
|
||||
@@ -72,6 +74,7 @@ label demo_nvlmode:
|
||||
$ menu = renpy.display_menu
|
||||
|
||||
nvl hide dissolve
|
||||
window show
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -92,6 +92,8 @@ label demo_text:
|
||||
|
||||
eoutline "You can have more than one outline, and each has its own color and offset."
|
||||
|
||||
window hide
|
||||
|
||||
esubtitle "Here, we have two outlines around the white text."
|
||||
|
||||
esubtitle "The bottom one is a translucent black that's offset a little, while the top one is green."
|
||||
@@ -99,7 +101,9 @@ label demo_text:
|
||||
esubtitle "By hiding the window and adjusting the layout method, we are able to create reasonable subtitles."
|
||||
|
||||
esubtitle "This might be an interesting look for a game."
|
||||
|
||||
|
||||
window show
|
||||
|
||||
esfont "For even more control, Ren'Py supports SFonts, image files containing font information."
|
||||
|
||||
esfont "SFonts let you use fonts you otherwise couldn't, and apply special effects to fonts using your favorite image editor."
|
||||
|
||||
@@ -90,7 +90,9 @@ init:
|
||||
button(face, editing == i, ("edit", i), xminimum=250)
|
||||
|
||||
ui.null(height=20)
|
||||
ui.textbutton("Continue", clicked=ui.returns(("done", True)), xminimum=250)
|
||||
ui.textbutton("Continue",
|
||||
clicked=ui.returns(("done", True)),
|
||||
xminimum=250)
|
||||
ui.null(height=20)
|
||||
ui.close()
|
||||
|
||||
@@ -98,28 +100,30 @@ init:
|
||||
# Choice window.
|
||||
if editing:
|
||||
ui.frame(xpos=300,
|
||||
ypos=200,
|
||||
xanchor='left',
|
||||
yanchor='top',
|
||||
xfill=False,
|
||||
xminimum=500
|
||||
)
|
||||
ypos=200,
|
||||
xanchor='left',
|
||||
yanchor='top',
|
||||
xfill=False,
|
||||
xminimum=500,
|
||||
xmargin = 10
|
||||
)
|
||||
|
||||
ui.vbox()
|
||||
ui.text("What will you do in the %s?" % editing.lower())
|
||||
ui.null(height=20)
|
||||
|
||||
for i in choices:
|
||||
button(i, plan[editing] == i, ("set", i),
|
||||
xpos=0, xanchor='left')
|
||||
button(i,
|
||||
plan[editing] == i,
|
||||
("set", i),
|
||||
xpos=0,
|
||||
xanchor='left',
|
||||
xminimum=250)
|
||||
|
||||
ui.close()
|
||||
|
||||
# Window at the bottom.
|
||||
ui.window()
|
||||
ui.vbox()
|
||||
ui.text("To get to the next screen, click the 'Continue' button.")
|
||||
ui.close()
|
||||
e("To get to the next screen, click the 'Continue' button.", interact=False)
|
||||
|
||||
type, value = ui.interact()
|
||||
|
||||
@@ -199,6 +203,8 @@ label demo_ui:
|
||||
|
||||
e "Imagemaps let the user click on an image to make a choice. For example, the following screen lets you pick what to do after school:"
|
||||
|
||||
window hide None
|
||||
|
||||
# This is an imagemap. It consists of two images, and a list of
|
||||
# hotspots. For each hotspot we give the coordinates of the left,
|
||||
# top, right, and bottom sides, and the value to return if it is
|
||||
@@ -215,6 +221,8 @@ label demo_ui:
|
||||
# result variable. We can use an if statement to vary what
|
||||
# happens based on the user's choice.
|
||||
|
||||
window show None
|
||||
|
||||
if result == "swimming":
|
||||
|
||||
e "You chose swimming."
|
||||
@@ -242,6 +250,8 @@ label demo_ui:
|
||||
e "We also support viewports, that allow us to display things that are bigger then the screen."
|
||||
|
||||
e "This viewport can be adjusted by dragging, by the mouse wheel, and by the scrollbars."
|
||||
|
||||
window hide
|
||||
|
||||
show eileen happy at right
|
||||
with move
|
||||
@@ -262,15 +272,23 @@ label demo_ui:
|
||||
|
||||
show eileen happy at center
|
||||
with move
|
||||
|
||||
|
||||
window show
|
||||
|
||||
e "While these constructs are probably enough for most visual novels, dating simulations may be more complicated."
|
||||
|
||||
e "The ui functions allow you to create quite complicated interfaces."
|
||||
|
||||
e "For example, try the following scheduling and stats screen, which could be used by a stat-based dating simulation."
|
||||
|
||||
hide eileen
|
||||
with dissolve
|
||||
|
||||
$ day_planner()
|
||||
|
||||
show eileen happy
|
||||
with dissolve
|
||||
|
||||
e "For a better implementation of this, take a look at the dating sim engine (DSE) that ships with Ren'Py."
|
||||
|
||||
call fight("Eileen", 10, 99, pname=povname) from _call_fight_1
|
||||
|
||||
@@ -10,7 +10,7 @@ init:
|
||||
("demo_transitions", "Transitions", "5.6.6"),
|
||||
("demo_movement", "Positions and Movement", "6.9.0"),
|
||||
("demo_animation", "Animation", "6.2.0"),
|
||||
("demo_multimedia", "Music and Sound", "5.6.3"),
|
||||
("demo_multimedia", "Music, Sound, and Video", "6.9.1"),
|
||||
("demo_imageops", "Image Operations", "6.5.0"),
|
||||
("demo_ui", "User Interaction", "6.5.0"),
|
||||
("demo_text", "Fonts and Text Tags", "6.8.0"),
|
||||
@@ -64,7 +64,7 @@ label demos:
|
||||
|
||||
# Is this the first time through the demo?
|
||||
$ demo_first_time = True
|
||||
|
||||
|
||||
show eileen happy at left
|
||||
with move
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -235,6 +235,12 @@ init -1 python hide:
|
||||
## Used when a game is loaded.
|
||||
config.after_load_transition = dissolve
|
||||
|
||||
## Used when the window is shown.
|
||||
config.window_show_transition = Dissolve(.25)
|
||||
|
||||
## Used when the window is hidden.
|
||||
config.window_hide_transition = Dissolve(.25)
|
||||
|
||||
#########################################
|
||||
## This is the name of the directory where the game's data is
|
||||
## stored. (It needs to be set early, before any other init code
|
||||
@@ -256,7 +262,9 @@ init -1 python hide:
|
||||
## The default text speed in characters per second. 0 is infinite.
|
||||
config.default_text_cps = 0
|
||||
|
||||
|
||||
config.window_icon = "logo.png"
|
||||
config.windows_icon = "logo32.png"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ label start:
|
||||
|
||||
# Start the background music playing.
|
||||
play music "mozart.ogg"
|
||||
|
||||
window show
|
||||
|
||||
e "Hi, and welcome to the Ren'Py demo game."
|
||||
|
||||
@@ -47,6 +49,8 @@ label start:
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -87,11 +87,7 @@ def tree(root):
|
||||
|
||||
if ".svn" in dirs:
|
||||
dirs.remove(".svn")
|
||||
else:
|
||||
if not root == "lib":
|
||||
print "Note:", dirname, "not in subversion."
|
||||
|
||||
|
||||
|
||||
for f in filenames:
|
||||
if f[-1] == '~' or f[0] == '.':
|
||||
continue
|
||||
@@ -155,32 +151,27 @@ def main():
|
||||
module_files = [
|
||||
"lib/pysdlsound/linmixer.py",
|
||||
"lib/pysdlsound/__init__.py",
|
||||
"README.txt",
|
||||
"_renpy.pyx",
|
||||
"_renpy.c",
|
||||
"core.c",
|
||||
"mmx.h",
|
||||
"native_midi.h",
|
||||
"native_midi_common.c",
|
||||
"native_midi_common.h",
|
||||
"native_midi_mac.c",
|
||||
"native_midi_win32.c",
|
||||
"nativemidi.c",
|
||||
"nativemidi.pyx",
|
||||
"pss.c",
|
||||
"pss.h",
|
||||
"sound.c",
|
||||
"sound.pyx",
|
||||
"rwobject.c",
|
||||
"renpy.h",
|
||||
"setup.py",
|
||||
"winmixer.c",
|
||||
"winmixer.pyx",
|
||||
"ffdecode.c",
|
||||
"IMG_savepng.c",
|
||||
"IMG_savepng.h",
|
||||
"mmx.h",
|
||||
"pss.c",
|
||||
"pss.h",
|
||||
"README.txt",
|
||||
"_renpy.c",
|
||||
"renpy_font.c",
|
||||
"renpy.h",
|
||||
"_renpy.pyx",
|
||||
"renpy_ttf.c",
|
||||
"renpy_ttf.h",
|
||||
"rwobject.c",
|
||||
"setup.py",
|
||||
"sound.c",
|
||||
"sound.pyx",
|
||||
"subpixel.c",
|
||||
"winmixer.c",
|
||||
"winmixer.pyx",
|
||||
]
|
||||
|
||||
for i in module_files:
|
||||
@@ -237,6 +228,7 @@ def main():
|
||||
print "Did you remember to rebuild the exe after the last change?"
|
||||
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?"
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#bodyContent {
|
||||
font-size: 136%;
|
||||
font-size: medium;
|
||||
background: #fff;
|
||||
margin-left: 3em;
|
||||
margin-right: 3em;
|
||||
margin-left: 20%;
|
||||
margin-right: 20%;
|
||||
padding: 1.5em;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ rm -Rf images
|
||||
mkdir -p images
|
||||
cp `find www.renpy.org -name \*.png -type f` images
|
||||
|
||||
# No jpgs yet.
|
||||
# cp `find www.renpy.org -name \*.jpg -type f` images
|
||||
No jpgs yet.
|
||||
cp `find www.renpy.org -name \*.jpg -type f` images
|
||||
|
||||
rm -Rf reference tutorials
|
||||
python2.5 process.py
|
||||
|
||||
|
Before Width: | Height: | Size: 4.3 KiB |
@@ -1,9 +0,0 @@
|
||||
init:
|
||||
image black = Solid((0, 0, 0, 255))
|
||||
|
||||
label main_menu:
|
||||
|
||||
$ renpy.renpy.style.write_docs("doc/styles.xml")
|
||||
$ renpy.renpy.style.write_hierarchy("doc/style_heirarchy.xml")
|
||||
$ raise "foo"
|
||||
|
||||
@@ -29,9 +29,10 @@ margin-left: -2.5em;
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="renpy_help"></div>
|
||||
<p><a name="Basic_Help" id="Basic_Help"></a></p>
|
||||
<h3><span class="mw-headline">Basic Help</span></h3>
|
||||
<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>
|
||||
@@ -105,5 +106,8 @@ margin-left: -2.5em;
|
||||
<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>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
import binascii
|
||||
|
||||
|
||||
def a2b(a):
|
||||
return binascii.a2b_hex(''.join(a.split()))
|
||||
|
||||
|
||||
resources = {
|
||||
260 : a2b('''
|
||||
01 00 ff ff 00 00 00 00 00 00 00 00 c8 00 c0 80
|
||||
02 00 00 00 00 00 b8 00 29 00 00 00 00 00 00 00
|
||||
08 00 90 01 00 01 4d 00 53 00 20 00 53 00 68 00
|
||||
65 00 6c 00 6c 00 20 00 44 00 6c 00 67 00 00 00
|
||||
00 00 00 00 00 00 00 00 01 00 01 50 7f 00 14 00
|
||||
32 00 0e 00 01 00 00 00 ff ff 80 00 4f 00 4b 00
|
||||
00 00 00 00 00 00 00 00 00 00 00 00 04 08 00 50
|
||||
07 00 07 00 aa 00 0c 00 ea 03 00 00 ff ff 81 00
|
||||
00 00 00 00
|
||||
'''),
|
||||
261 : a2b('''
|
||||
01 00 ff ff 00 00 00 00 00 00 00 00 c8 00 c0 80
|
||||
04 00 00 00 00 00 b8 00 3a 00 00 00 00 00 00 00
|
||||
08 00 90 01 00 01 4d 00 53 00 20 00 53 00 68 00
|
||||
65 00 6c 00 6c 00 20 00 44 00 6c 00 67 00 00 00
|
||||
00 00 00 00 00 00 00 00 80 00 81 50 07 00 14 00
|
||||
aa 00 0c 00 ec 03 00 00 ff ff 81 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 01 00 01 50 7f 00 25 00
|
||||
32 00 0e 00 01 00 00 00 ff ff 80 00 4f 00 4b 00
|
||||
00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 50
|
||||
4a 00 25 00 32 00 0e 00 02 00 00 00 ff ff 80 00
|
||||
43 00 61 00 6e 00 63 00 65 00 6c 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 04 08 00 50 07 00 07 00
|
||||
aa 00 0c 00 eb 03 00 00 ff ff 81 00 00 00 00 00
|
||||
'''),
|
||||
262 : a2b('''
|
||||
01 00 ff ff 00 00 00 00 00 00 00 00 c8 00 c0 80
|
||||
04 00 00 00 00 00 b8 00 29 00 00 00 00 00 00 00
|
||||
08 00 90 01 00 01 4d 00 53 00 20 00 53 00 68 00
|
||||
65 00 6c 00 6c 00 20 00 44 00 6c 00 67 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 01 50 7f 00 14 00
|
||||
32 00 0e 00 06 00 00 00 ff ff 80 00 59 00 65 00
|
||||
73 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
04 08 00 50 07 00 07 00 aa 00 0c 00 ed 03 00 00
|
||||
ff ff 81 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
00 00 01 50 07 00 14 00 32 00 0e 00 07 00 00 00
|
||||
ff ff 80 00 4e 00 6f 00 00 00 00 00 00 00 00 00
|
||||
00 00 00 00 00 00 01 50 4b 00 14 00 32 00 0e 00
|
||||
02 00 00 00 ff ff 80 00 43 00 61 00 6e 00 63 00
|
||||
65 00 6c 00 00 00 00 00
|
||||
'''),
|
||||
263 : a2b('''
|
||||
01 00 ff ff 00 00 00 00 00 00 00 00 80 00 ca 80
|
||||
03 00 00 00 00 00 e2 00 29 00 00 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 81 50 07 00 14 00
|
||||
97 00 0e 00 eb 03 00 00 6d 00 73 00 63 00 74 00
|
||||
6c 00 73 00 5f 00 70 00 72 00 6f 00 67 00 72 00
|
||||
65 00 73 00 73 00 33 00 32 00 00 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 04 08 00 50 07 00 07 00
|
||||
d4 00 0c 00 ea 03 00 00 ff ff 81 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 00 50 a9 00 14 00
|
||||
32 00 0e 00 02 00 00 00 ff ff 80 00 43 00 61 00
|
||||
6e 00 63 00 65 00 6c 00 00 00 00 00
|
||||
'''),
|
||||
264 : a2b('''
|
||||
01 00 ff ff 00 00 00 00 00 00 00 00 c8 00 c0 80
|
||||
04 00 00 00 00 00 b8 00 3a 00 00 00 00 00 00 00
|
||||
08 00 90 01 00 01 4d 00 53 00 20 00 53 00 68 00
|
||||
65 00 6c 00 6c 00 20 00 44 00 6c 00 67 00 00 00
|
||||
00 00 00 00 00 00 00 00 a0 00 81 50 07 00 14 00
|
||||
aa 00 0c 00 ec 03 00 00 ff ff 81 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 01 00 01 50 7f 00 25 00
|
||||
32 00 0e 00 01 00 00 00 ff ff 80 00 4f 00 4b 00
|
||||
00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 50
|
||||
4a 00 25 00 32 00 0e 00 02 00 00 00 ff ff 80 00
|
||||
43 00 61 00 6e 00 63 00 65 00 6c 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 04 08 00 50 07 00 07 00
|
||||
aa 00 0c 00 eb 03 00 00 ff ff 81 00 00 00 00 00
|
||||
'''),
|
||||
265 : a2b('''
|
||||
01 00 ff ff 00 00 00 00 00 00 00 00 c8 00 c8 80
|
||||
12 00 00 00 00 00 d9 00 fc 00 00 00 00 00 00 00
|
||||
08 00 90 01 00 01 4d 00 53 00 20 00 53 00 68 00
|
||||
65 00 6c 00 6c 00 20 00 44 00 6c 00 67 00 00 00
|
||||
00 00 00 00 00 00 00 00 01 00 01 50 6c 00 ea 00
|
||||
30 00 0e 00 01 00 00 00 ff ff 80 00 4f 00 4b 00
|
||||
00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 50
|
||||
a2 00 ea 00 30 00 0e 00 02 00 00 00 ff ff 80 00
|
||||
43 00 61 00 6e 00 63 00 65 00 6c 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 07 00 00 50 06 00 06 00
|
||||
cc 00 4e 00 ff ff ff ff ff ff 80 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 03 00 21 50 48 00 12 00
|
||||
84 00 64 00 03 00 00 00 ff ff 85 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 02 50 0c 00 24 00
|
||||
c0 00 08 00 04 00 00 00 ff ff 82 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 80 00 81 50 0c 00 30 00
|
||||
c0 00 0e 00 05 00 00 00 ff ff 81 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 01 50 9c 00 42 00
|
||||
30 00 0e 00 06 00 00 00 ff ff 80 00 41 00 64 00
|
||||
64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
07 00 00 50 06 00 54 00 cb 00 3c 00 ff ff ff ff
|
||||
ff ff 80 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
03 00 21 50 48 00 61 00 84 00 64 00 07 00 00 00
|
||||
ff ff 85 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
00 00 02 50 0c 00 72 00 c0 00 08 00 08 00 00 00
|
||||
ff ff 82 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
00 00 01 50 9c 00 7e 00 30 00 0e 00 09 00 00 00
|
||||
ff ff 80 00 41 00 64 00 64 00 00 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 01 50 06 00 96 00
|
||||
42 00 0e 00 0a 00 00 00 ff ff 80 00 41 00 64 00
|
||||
64 00 20 00 66 00 69 00 6c 00 65 00 2e 00 2e 00
|
||||
2e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
00 00 01 50 4e 00 96 00 42 00 0e 00 0b 00 00 00
|
||||
ff ff 80 00 41 00 64 00 64 00 20 00 6e 00 65 00
|
||||
77 00 20 00 66 00 69 00 6c 00 65 00 2e 00 2e 00
|
||||
2e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
00 00 01 50 06 00 a8 00 42 00 0e 00 0c 00 00 00
|
||||
ff ff 80 00 41 00 64 00 64 00 20 00 66 00 6f 00
|
||||
6c 00 64 00 65 00 72 00 2e 00 2e 00 2e 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 00 00 07 00 00 50
|
||||
06 00 c6 00 cc 00 1e 00 ff ff ff ff ff ff 80 00
|
||||
43 00 6f 00 6d 00 6d 00 61 00 6e 00 64 00 20 00
|
||||
6c 00 69 00 6e 00 65 00 3a 00 00 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 80 00 81 50 0c 00 d2 00
|
||||
c0 00 0e 00 0e 00 00 00 ff ff 81 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 02 50 0c 00 14 00
|
||||
3c 00 08 00 1e 00 00 00 ff ff 82 00 4f 00 70 00
|
||||
74 00 69 00 6f 00 6e 00 3a 00 00 00 00 00 00 00
|
||||
00 00 00 00 00 00 00 00 00 00 02 50 0c 00 63 00
|
||||
3c 00 08 00 46 00 00 00 ff ff 82 00 43 00 6f 00
|
||||
6d 00 6d 00 61 00 6e 00 64 00 3a 00 00 00 00 00
|
||||
'''),
|
||||
270 : a2b('''
|
||||
01 00 ff ff 00 00 00 00 00 00 00 00 48 04 00 44
|
||||
02 00 00 00 00 00 23 01 1a 00 00 00 00 00 00 00
|
||||
08 00 00 00 00 00 4d 00 53 00 20 00 53 00 68 00
|
||||
65 00 6c 00 6c 00 20 00 44 00 6c 00 67 00 00 00
|
||||
00 00 00 00 00 00 00 00 01 00 02 50 00 00 07 00
|
||||
23 01 08 00 ff ff ff ff ff ff 82 00 53 00 74 00
|
||||
61 00 74 00 69 00 63 00 00 00 00 00 00 00 00 00
|
||||
00 00 00 00 00 00 02 40 00 00 12 00 23 01 08 00
|
||||
5f 04 00 00 ff ff 82 00 73 00 74 00 63 00 33 00
|
||||
32 00 00 00 00 00
|
||||
'''),
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
# Name: None
|
||||
# Version: 1
|
||||
# Description: Disables the automatic launching of an editor.
|
||||
|
||||
config.editor = None
|
||||
config.editor_transient = None
|
||||
@@ -0,0 +1,177 @@
|
||||
init python:
|
||||
import renpy.tools.archiver as archiver
|
||||
import os
|
||||
import os.path
|
||||
import fnmatch
|
||||
|
||||
label archiver:
|
||||
|
||||
python hide:
|
||||
|
||||
# Get the options
|
||||
name = project.info.get('archive_name', "data")
|
||||
include = project.info.get('archive_include', "*.png *.gif *.jpg")
|
||||
exclude = project.info.get('archive_exclude', "presplash.png")
|
||||
|
||||
# Allow the user to set the options.
|
||||
while True:
|
||||
|
||||
set_tooltip("")
|
||||
|
||||
screen()
|
||||
ui.vbox()
|
||||
|
||||
title(_(u"Archiver"))
|
||||
|
||||
text(_(u"The archiver allows you to obfuscate your game by including files in an archive file."))
|
||||
|
||||
ui.null(height=15)
|
||||
|
||||
text_variable(_(u"Archive Name:"), name, "name",
|
||||
_(u"The name of the archive to create."))
|
||||
|
||||
text_variable(_(u"Include Patterns:"), include, "include",
|
||||
_(u"Files matching these patterns are included in the archive."))
|
||||
|
||||
text_variable(_(u"Exclude Patterns:"), exclude, "exclude",
|
||||
_(u"Files matching these patterns are excluded from the archive."))
|
||||
|
||||
ui.null(height=15)
|
||||
|
||||
button(_(u"Archive"), ui.returns("archive"), _(u"Build the archive."))
|
||||
button(_(u"Cancel"), ui.jumps("top"), "")
|
||||
|
||||
ui.close()
|
||||
|
||||
act = interact()
|
||||
|
||||
if act == "name":
|
||||
name = input(
|
||||
_(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."),
|
||||
name)
|
||||
|
||||
elif act == "include":
|
||||
include = input(
|
||||
_(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."),
|
||||
include)
|
||||
|
||||
elif act == "exclude":
|
||||
exclude = input(
|
||||
_(u"Include Patterns"),
|
||||
_(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."),
|
||||
exclude)
|
||||
|
||||
elif act == "archive":
|
||||
break
|
||||
|
||||
# Store the options.
|
||||
|
||||
project.info["archive_name"] = name
|
||||
project.info["archive_include"] = include
|
||||
project.info["archive_exclude"] = exclude
|
||||
|
||||
project.save()
|
||||
|
||||
|
||||
# Break up the extension lists.
|
||||
|
||||
include = [ i.strip() for i in include.split() ]
|
||||
exclude = [ i.strip() for i in exclude.split() ]
|
||||
|
||||
# Get the gamedir and the archived dir.
|
||||
gamedir = os.path.join(project.path, "game")
|
||||
archived = os.path.join(project.path, "archived")
|
||||
|
||||
# The prefix of the archive file.
|
||||
prefix = os.path.join(gamedir, name)
|
||||
|
||||
archived_files = set()
|
||||
files = [ ]
|
||||
|
||||
# Choose files to archive.
|
||||
|
||||
set_tooltip("")
|
||||
|
||||
info(
|
||||
_(u"Scanning Files..."),
|
||||
"")
|
||||
|
||||
for bdir in (gamedir, archived):
|
||||
|
||||
for dirname, dirs, filenames in os.walk(bdir):
|
||||
|
||||
dirs[:] = [ i for i in dirs if not i[0] == '.' ]
|
||||
|
||||
for fn in filenames:
|
||||
|
||||
fullfn = dirname + "/" + fn
|
||||
shortfn = fullfn[len(bdir)+1:]
|
||||
|
||||
if fn[0] == ".":
|
||||
continue
|
||||
|
||||
if shortfn in archived_files:
|
||||
continue
|
||||
|
||||
should_archive = False
|
||||
|
||||
for i in include:
|
||||
if fnmatch.fnmatch(fn, i):
|
||||
should_archive = True
|
||||
|
||||
for i in exclude:
|
||||
if fnmatch.fnmatch(fn, i):
|
||||
should_archive = False
|
||||
|
||||
if not should_archive:
|
||||
continue
|
||||
|
||||
files.append((fullfn, shortfn))
|
||||
archived_files.add(shortfn)
|
||||
|
||||
if not files:
|
||||
error(_(u"The patterns did not match any files, so no archive was created."))
|
||||
|
||||
# Actually archiving files.
|
||||
info(_(u"Archiving Files..."), "")
|
||||
|
||||
archiver.archive(prefix, files)
|
||||
|
||||
# Move files out of the way.
|
||||
for fullfn, shortfn in files:
|
||||
afn = archived + "/" + shortfn
|
||||
|
||||
if fullfn == afn:
|
||||
continue
|
||||
|
||||
try:
|
||||
os.makedirs(os.path.dirname(afn))
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
os.rename(fullfn, afn)
|
||||
except:
|
||||
os.rename(afn, afn + ".old")
|
||||
os.rename(fullfn, afn)
|
||||
os.unlink(afn + ".old")
|
||||
|
||||
# Report success.
|
||||
screen()
|
||||
ui.vbox()
|
||||
|
||||
title(_(u"Success"))
|
||||
text(_(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."))
|
||||
|
||||
ui.null(height=20)
|
||||
|
||||
button(_(u"Return"), ui.jumps("top"), None)
|
||||
|
||||
ui.close()
|
||||
interact()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,329 @@
|
||||
init -1 python:
|
||||
style_backup = renpy.style.backup()
|
||||
|
||||
init python:
|
||||
|
||||
import codecs
|
||||
import re
|
||||
import sys
|
||||
|
||||
##########################################################################
|
||||
# Code to update options.rpy
|
||||
|
||||
def list_logical_lines(filename):
|
||||
"""
|
||||
This reads in filename, and turns it into a list of logical
|
||||
lines.
|
||||
"""
|
||||
|
||||
f = codecs.open(filename, "rb", "utf-8")
|
||||
data = f.read()
|
||||
f.close()
|
||||
|
||||
# The result.
|
||||
rv = []
|
||||
|
||||
# The current position we're looking at in the buffer.
|
||||
pos = 0
|
||||
|
||||
# Looping over the lines in the file.
|
||||
while pos < len(data):
|
||||
|
||||
# The line that we're building up.
|
||||
line = ""
|
||||
|
||||
# The number of open parenthesis there are right now.
|
||||
parendepth = 0
|
||||
|
||||
# Looping over the characters in a single logical line.
|
||||
while pos < len(data):
|
||||
|
||||
c = data[pos]
|
||||
|
||||
if c == '\n' and not parendepth:
|
||||
rv.append(line)
|
||||
|
||||
pos += 1
|
||||
# This helps out error checking.
|
||||
line = ""
|
||||
break
|
||||
|
||||
# Backslash/newline.
|
||||
if c == "\\" and data[pos+1] == "\n":
|
||||
pos += 2
|
||||
line += "\\\n"
|
||||
continue
|
||||
|
||||
# Parenthesis.
|
||||
if c in ('(', '[', '{'):
|
||||
parendepth += 1
|
||||
|
||||
if c in ('}', ']', ')') and parendepth:
|
||||
parendepth -= 1
|
||||
|
||||
# Comments.
|
||||
if c == '#':
|
||||
while data[pos] != '\n':
|
||||
line += data[pos]
|
||||
pos += 1
|
||||
|
||||
continue
|
||||
|
||||
# Strings.
|
||||
if c in ('"', "'", "`"):
|
||||
delim = c
|
||||
line += c
|
||||
pos += 1
|
||||
|
||||
escape = False
|
||||
|
||||
while pos < len(data):
|
||||
|
||||
c = data[pos]
|
||||
|
||||
if escape:
|
||||
escape = False
|
||||
pos += 1
|
||||
line += c
|
||||
continue
|
||||
|
||||
if c == delim:
|
||||
pos += 1
|
||||
line += c
|
||||
break
|
||||
|
||||
if c == '\\':
|
||||
escape = True
|
||||
|
||||
line += c
|
||||
pos += 1
|
||||
|
||||
continue
|
||||
|
||||
continue
|
||||
|
||||
line += c
|
||||
pos += 1
|
||||
|
||||
if line:
|
||||
rv.append(line)
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
def switch_theme(name):
|
||||
"""
|
||||
Switches the theme of the current project to the named theme.
|
||||
"""
|
||||
|
||||
theme_functions = set(i[1] for i in themes)
|
||||
|
||||
td = theme_data[name].copy()
|
||||
td["name"] = name
|
||||
|
||||
# Did we change the file at all?
|
||||
changed = False
|
||||
|
||||
filename = os.path.join(project.gamedir, "options.rpy")
|
||||
|
||||
out = codecs.open(filename + ".new", "wb", "utf-8")
|
||||
|
||||
for l in list_logical_lines(filename):
|
||||
|
||||
m = re.match(r' theme.(\w+)\(', l)
|
||||
if m:
|
||||
if m.group(1) in theme_functions:
|
||||
l = theme_templates[td["theme"]] % td
|
||||
changed = True
|
||||
|
||||
out.write(l + "\n")
|
||||
|
||||
out.close()
|
||||
|
||||
if changed:
|
||||
try:
|
||||
os.unlink(filename + ".bak")
|
||||
except:
|
||||
pass
|
||||
|
||||
os.rename(filename, filename + ".bak")
|
||||
os.rename(filename + ".new", filename)
|
||||
|
||||
else:
|
||||
os.unlink(filename + ".new")
|
||||
|
||||
error(_(u"Could not modify options.rpy. Perhaps it was changed too much."))
|
||||
|
||||
set_tooltip(_(u"Theme changed to %s.") % name)
|
||||
renpy.jump("top")
|
||||
|
||||
curried_switch_theme = renpy.curry(switch_theme)
|
||||
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Code that handles display.
|
||||
|
||||
current_theme = None
|
||||
|
||||
def show_theme(name, target):
|
||||
"""
|
||||
Changes from the current theme to the roundrect theme named
|
||||
`name`.
|
||||
"""
|
||||
|
||||
if current_theme == name:
|
||||
return
|
||||
|
||||
store.current_theme = name
|
||||
|
||||
td = theme_data[name].copy()
|
||||
kind = td["theme"]
|
||||
del td["theme"]
|
||||
|
||||
if kind == "roundrect":
|
||||
td["rounded_window"] = False
|
||||
|
||||
renpy.style.restore(style_backup)
|
||||
getattr(theme, kind)(**td)
|
||||
customize_styles()
|
||||
renpy.style.rebuild()
|
||||
|
||||
renpy.jump(target)
|
||||
|
||||
curried_show_theme = renpy.curry(show_theme)
|
||||
|
||||
def theme_demo():
|
||||
# The sample area, that shows what the theme looks like.
|
||||
ui.window(style='default', background="#444", xpadding=1, ypadding=1)
|
||||
ui.window(style='gm_root', xpadding=5, ypadding=5)
|
||||
ui.vbox(5)
|
||||
|
||||
# Display Preference.
|
||||
ui.window(style=style.prefs_pref_frame)
|
||||
ui.vbox(style=style.prefs_pref_box)
|
||||
|
||||
ui.hbox(style=style.prefs_pref_choicebox)
|
||||
|
||||
layout.label(_(u"Display"), "prefs")
|
||||
layout.button(_(u"Window"), "prefs", clicked=does_nothing, selected=True)
|
||||
layout.button(_(u"Fullscreen"), "prefs", clicked=does_nothing, selected=False)
|
||||
layout.button(_(u"Planetarium"), "prefs", clicked=None, selected=False)
|
||||
|
||||
ui.close()
|
||||
ui.close()
|
||||
|
||||
# Volume Preference
|
||||
ui.window(style=style.prefs_pref_frame)
|
||||
ui.vbox(style=style.prefs_pref_box)
|
||||
|
||||
layout.label(_(u"Music Volume"), "prefs")
|
||||
ui.vbox(style=style.prefs_volume_box)
|
||||
|
||||
ui.bar(128,
|
||||
92,
|
||||
changed=does_nothing,
|
||||
style=style.prefs_volume_slider)
|
||||
|
||||
layout.button(_(u"Test"), "soundtest", clicked=does_nothing)
|
||||
|
||||
ui.close()
|
||||
ui.close()
|
||||
|
||||
ui.close() # vbox
|
||||
|
||||
|
||||
# Used to have buttons not do anything.
|
||||
def does_nothing(*args):
|
||||
return
|
||||
|
||||
|
||||
label choose_theme:
|
||||
|
||||
python:
|
||||
if not os.path.exists(os.path.join(project.gamedir, "options.rpy")):
|
||||
error(_(u"The options.rpy file does not exist in the game directory, so this launcher cannot change the theme."))
|
||||
|
||||
current_theme = None
|
||||
theme_adjustment = ui.adjustment()
|
||||
|
||||
label repeat_choose_theme:
|
||||
|
||||
python hide:
|
||||
|
||||
tip = _(u"Themes control the basic look of interface elements. You'll be able to pick a color scheme next.")
|
||||
|
||||
screen()
|
||||
ui.vbox()
|
||||
title(_(u"Choose Theme"))
|
||||
|
||||
ui.grid(2, 1, padding=10, xfill=True)
|
||||
|
||||
# The scroll area, that lets the user pick a theme.
|
||||
scrolled('top', theme_adjustment)
|
||||
ui.vbox()
|
||||
|
||||
for name, function, exemplar in themes:
|
||||
button(name,
|
||||
ui.returns(function),
|
||||
"",
|
||||
hovered=curried_show_theme(exemplar, "repeat_choose_theme"),
|
||||
unhovered=does_nothing)
|
||||
|
||||
ui.close() # vbox
|
||||
ui.close() # scrolled
|
||||
|
||||
theme_demo()
|
||||
|
||||
ui.close() # grid
|
||||
ui.close() # vbox
|
||||
|
||||
set_tooltip(tip)
|
||||
store.theme_function = interact()
|
||||
|
||||
|
||||
label choose_color_scheme:
|
||||
|
||||
python:
|
||||
|
||||
current_theme = None
|
||||
theme_adjustment = ui.adjustment()
|
||||
|
||||
label repeat_choose_color_scheme:
|
||||
|
||||
python hide:
|
||||
|
||||
tip = _(u"Please choose a color scheme for your project.")
|
||||
|
||||
themes = [ k for k,v in theme_data.iteritems() if v["theme"] == theme_function ]
|
||||
themes.sort()
|
||||
|
||||
screen()
|
||||
ui.vbox()
|
||||
title(_(u"Choose Color Scheme"))
|
||||
|
||||
ui.grid(2, 1, padding=10, xfill=True)
|
||||
|
||||
# The scroll area, that lets the user pick a theme.
|
||||
scrolled('choose_theme', theme_adjustment)
|
||||
ui.vbox()
|
||||
|
||||
for i in themes:
|
||||
button(i,
|
||||
curried_switch_theme(i),
|
||||
"",
|
||||
hovered=curried_show_theme(i, "repeat_choose_color_scheme"),
|
||||
unhovered=does_nothing)
|
||||
|
||||
ui.close() # vbox
|
||||
ui.close() # scrolled
|
||||
|
||||
theme_demo()
|
||||
|
||||
ui.close() # grid
|
||||
ui.close() # vbox
|
||||
|
||||
set_tooltip(tip)
|
||||
interact()
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
# This file contains the code needed to build a Ren'Py distribution.
|
||||
|
||||
init python:
|
||||
import zipfile
|
||||
import tarfile
|
||||
import os
|
||||
import os.path
|
||||
import zipfile
|
||||
import tarfile
|
||||
import time
|
||||
import sys
|
||||
import zlib
|
||||
zlib.Z_DEFAULT_COMPRESSION = 9
|
||||
|
||||
import pefile
|
||||
|
||||
# Returns true if a file or directory should not be included in
|
||||
# the distribution
|
||||
|
||||
ignored_files = ("thumbs.db",
|
||||
"launcherinfo.py",
|
||||
"traceback.txt",
|
||||
"errors.txt",
|
||||
"icon.ico",
|
||||
"icon.icns"
|
||||
)
|
||||
|
||||
# These are files that are ignored wherever they are found in a
|
||||
# distribution.
|
||||
ignored_files = (
|
||||
"thumbs.db",
|
||||
"traceback.txt",
|
||||
"errors.txt",
|
||||
"saves"
|
||||
)
|
||||
|
||||
# These are files (and directories) that are ignored when found in
|
||||
# the root directory of the distribution.
|
||||
root_ignored_files = (
|
||||
"common",
|
||||
"renpy",
|
||||
@@ -33,52 +33,51 @@ init python:
|
||||
"msvcr71.dll",
|
||||
"lib",
|
||||
"iliad-icon.png",
|
||||
"manifest.xml"
|
||||
"manifest.xml",
|
||||
"icon.ico",
|
||||
"icon.icns",
|
||||
"launcherinfo.py",
|
||||
"archived",
|
||||
)
|
||||
|
||||
# Extensions that should be made executable.
|
||||
executable_extensions = (
|
||||
"MacOS",
|
||||
"so",
|
||||
"dylib",
|
||||
".sh",
|
||||
"python",
|
||||
"python.real",
|
||||
)
|
||||
|
||||
def ignored(fn, dir, dest, root):
|
||||
if fn[0] == ".":
|
||||
return True
|
||||
|
||||
for i in store.ignore_extensions:
|
||||
if fn.endswith(i):
|
||||
return True
|
||||
def tree(
|
||||
src,
|
||||
dest,
|
||||
exclude_suffix=[ ".pyc", "~", ".bak" ],
|
||||
exclude_prefix=[ "#", "." ],
|
||||
exclude_files = set(ignored_files),
|
||||
root_exclude_prefix = [ ],
|
||||
root_exclude_suffix = [ ".py", ".sh", ".app" ],
|
||||
root_exclude_files = set(root_ignored_files),
|
||||
root=False):
|
||||
|
||||
if fn.lower() in ignored_files:
|
||||
return True
|
||||
"""
|
||||
Returns a list of source-filename, destination-filename pairs.
|
||||
"""
|
||||
|
||||
if fn == "saves":
|
||||
return True
|
||||
if dest[0] != "/":
|
||||
raise Exception("Destination must begin with /: %r" % dest)
|
||||
|
||||
if fn == "archived":
|
||||
return True
|
||||
src = src.rstrip('/')
|
||||
dest = dest.rstrip('/')
|
||||
|
||||
if root and dir == dest:
|
||||
if fn.endswith(".py") or fn.endswith(".sh") or fn.endswith(".app"):
|
||||
return True
|
||||
def include(fn, is_root):
|
||||
"""
|
||||
Returns True if the file should be included in the list of
|
||||
files we are copying.
|
||||
"""
|
||||
|
||||
if fn in root_ignored_files:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def tree(src, dest,
|
||||
exclude_suffix=[ ".pyc", "~", ".bak" ],
|
||||
exclude_prefix=[ ".", '#' ],
|
||||
exclude=ignored_files,
|
||||
exclude_func=ignored,
|
||||
root=False,
|
||||
):
|
||||
|
||||
# Get rid of trailing slashes.
|
||||
if src[-1] == "/":
|
||||
src = src[:-1]
|
||||
|
||||
if dest and dest[-1] == "/":
|
||||
dest = dest[:-1]
|
||||
|
||||
# What should we include?
|
||||
def include(fn, destdir, dest):
|
||||
for i in exclude_suffix:
|
||||
if fn.endswith(i):
|
||||
return False
|
||||
@@ -87,448 +86,464 @@ init python:
|
||||
if fn.startswith(i):
|
||||
return False
|
||||
|
||||
for i in exclude:
|
||||
if i == fn.lower():
|
||||
if fn in exclude_files:
|
||||
return False
|
||||
|
||||
if not root or not is_root:
|
||||
return True
|
||||
|
||||
for i in root_exclude_suffix:
|
||||
if fn.endswith(i):
|
||||
return False
|
||||
|
||||
if exclude_func and exclude_func(fn, destdir, dest, root):
|
||||
for i in root_exclude_prefix:
|
||||
if fn.startswith(i):
|
||||
return False
|
||||
|
||||
if fn in root_exclude_files:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
rv = [ ]
|
||||
|
||||
|
||||
# Walk the tree, including what is necessary.
|
||||
for srcdir, dirs, files in os.walk(src):
|
||||
|
||||
if dest:
|
||||
destdir = dest + srcdir[len(src):]
|
||||
else:
|
||||
destdir = srcdir[len(src) + 1:]
|
||||
|
||||
if destdir:
|
||||
rv.append((srcdir, destdir))
|
||||
is_root = (srcdir == src)
|
||||
|
||||
srcdir += "/"
|
||||
destdir = dest + srcdir[len(src):]
|
||||
destdir.replace("\\", "/")
|
||||
|
||||
rv.append((srcdir, destdir))
|
||||
|
||||
for fn in files:
|
||||
|
||||
if not include(fn, destdir, dest):
|
||||
|
||||
if not include(fn, is_root):
|
||||
continue
|
||||
|
||||
sfn = srcdir + "/" + fn
|
||||
|
||||
if destdir:
|
||||
dfn = destdir + "/" + fn
|
||||
else:
|
||||
dfn = fn
|
||||
|
||||
dfn = dfn.replace("\\", "/")
|
||||
sfn = srcdir + fn
|
||||
dfn = destdir + fn
|
||||
|
||||
rv.append((sfn, dfn))
|
||||
|
||||
dirs[:] = [ i for i in dirs if include(i, destdir, dest) ]
|
||||
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
|
||||
`filename` directory. `file_data` is a map from source file to
|
||||
replacement data.
|
||||
"""
|
||||
|
||||
files.sort(key=lambda a : a[1])
|
||||
progress_len = len(files)
|
||||
|
||||
fn = os.path.join(os.path.dirname(project.path), filename)
|
||||
|
||||
zf = zipfile.ZipFile(fn + ".zip", "w", zipfile.ZIP_DEFLATED)
|
||||
|
||||
for i, (fn, an) in enumerate(files):
|
||||
|
||||
progress(t, progress_len, i)
|
||||
|
||||
if os.path.isdir(fn):
|
||||
continue
|
||||
|
||||
zi = zipfile.ZipInfo(filename + an)
|
||||
|
||||
s = os.stat(fn)
|
||||
zi.date_time = time.gmtime(s.st_mtime)[:6]
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.create_system = 3
|
||||
|
||||
for i in executable_extensions:
|
||||
if os.path.dirname(fn).endswith(i) or fn.endswith(i):
|
||||
zi.external_attr = long(0100777) << 16
|
||||
break
|
||||
else:
|
||||
zi.external_attr = long(0100666) << 16
|
||||
|
||||
if fn in file_data:
|
||||
data = file_data[fn]
|
||||
else:
|
||||
data = file(fn, "rb").read()
|
||||
|
||||
zf.writestr(zi, data)
|
||||
|
||||
zf.close()
|
||||
|
||||
def make_tar(t, filename, files):
|
||||
"""
|
||||
Makes a tarfile, as above.
|
||||
"""
|
||||
|
||||
files.sort(key=lambda a : a[1])
|
||||
progress_len = len(files)
|
||||
|
||||
fn = os.path.join(os.path.dirname(project.path), filename)
|
||||
|
||||
tf = tarfile.open(fn + ".tar.bz2", "w:bz2")
|
||||
tf.dereference = True
|
||||
|
||||
for j, (fn, an) in enumerate(files):
|
||||
|
||||
progress(t, progress_len, j)
|
||||
|
||||
info = tf.gettarinfo(fn, filename + an)
|
||||
|
||||
perms = 0666
|
||||
|
||||
if info.isdir():
|
||||
perms = 0777
|
||||
|
||||
for i in executable_extensions:
|
||||
if fn.endswith(i):
|
||||
perms = 0777
|
||||
|
||||
info.mode = perms
|
||||
info.uid = 1000
|
||||
info.gid = 1000
|
||||
info.uname = "renpy"
|
||||
info.gname = "renpy"
|
||||
|
||||
if info.isreg():
|
||||
tf.addfile(info, file(fn, "rb"))
|
||||
else:
|
||||
tf.addfile(info)
|
||||
|
||||
tf.close()
|
||||
|
||||
|
||||
def dist_exists(fn):
|
||||
"""
|
||||
Returns true if the given file exists in the renpy directory.
|
||||
"""
|
||||
|
||||
return os.path.exists(os.path.join(config.renpy_base, fn))
|
||||
|
||||
|
||||
label distribute:
|
||||
|
||||
call lint
|
||||
|
||||
if not yesno(_(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?")):
|
||||
|
||||
jump top
|
||||
|
||||
python hide:
|
||||
zlib.Z_DEFAULT_COMPRESSION = 9
|
||||
|
||||
store.progress_time = 0
|
||||
# Do we have the files?
|
||||
has_windows = dist_exists("renpy.exe")
|
||||
has_linux = dist_exists("lib/linux-x86")
|
||||
has_mac = dist_exists("renpy.app")
|
||||
has_all = has_windows and has_mac and has_linux
|
||||
|
||||
def progress(tit, n, m, time=time):
|
||||
# Should we build these distributions?
|
||||
build_windows = has_windows and project.info.get("build_windows", has_windows)
|
||||
build_linux = has_linux and project.info.get("build_linux", has_linux)
|
||||
build_mac = has_mac and project.info.get("build_mac", has_mac)
|
||||
build_all = has_all and project.info.get("build_all", False)
|
||||
|
||||
# The base name of the distribution.
|
||||
base_name = project.info.get("distribution_base", project.name)
|
||||
|
||||
# The executable name.
|
||||
executable_name = project.info.get("executable_name", project.name)
|
||||
|
||||
# Extensions to exclude.
|
||||
ignore_extensions = project.info.get("ignore_extensions", "~ .bak")
|
||||
|
||||
# Documentation extensions.
|
||||
documentation_extensions = project.info.get("documentation_extensions", "txt html")
|
||||
|
||||
# Prompt the user for all of the above.
|
||||
|
||||
while True:
|
||||
|
||||
set_tooltip("")
|
||||
screen()
|
||||
|
||||
if time.time() < store.progress_time + .1:
|
||||
return
|
||||
ui.vbox()
|
||||
|
||||
title(tit)
|
||||
title(_(u"Building Distributions"))
|
||||
|
||||
text_variable(_(u"Base Name:"), base_name, "base_name",
|
||||
_(u"Used to generate the names of directories and archive files."))
|
||||
|
||||
text_variable(_(u"Executable Name:"), executable_name, "executable_name",
|
||||
_(u"Used to generate the names of executables and runnable programs."))
|
||||
|
||||
text_variable(_(u"Ignore Extensions:"), ignore_extensions, "ignore_extensions",
|
||||
_(u"Files with these extensions will not be included in the distributions."))
|
||||
|
||||
text_variable(_(u"Documentation Extensions:"), documentation_extensions, "documentation_extensions",
|
||||
_(u"Files with these extensions will be treated as documentation, when building the Macintosh application."))
|
||||
|
||||
text(_(u"Distributions to Build:"))
|
||||
|
||||
if has_windows:
|
||||
toggle_button(_(u"Windows x86"), build_windows, ui.returns("build_windows"),
|
||||
_(u"Zip distribution for the 32-bit Windows platform."))
|
||||
|
||||
if has_linux:
|
||||
toggle_button(_(u"Linux x86"), build_linux, ui.returns("build_linux"),
|
||||
_(u"Tar.Bz2 distribution for the Linux x86 platform."))
|
||||
|
||||
if has_mac:
|
||||
toggle_button(_(u"Macintosh Universal"), build_mac, ui.returns("build_mac"),
|
||||
_(u"Single application distribution for the Macintosh x86 and ppc platforms."))
|
||||
|
||||
if has_all:
|
||||
toggle_button(_(u"Windows/Linux/Mac Combined"), build_all, ui.returns("build_all"),
|
||||
_(u"Zip distribution for the Windows x86, Linux x86, Macintosh x86 and Macintosh ppc platforms."))
|
||||
|
||||
|
||||
ui.null(height=15)
|
||||
|
||||
button(_(u"Build"), ui.returns("build"), _(u"Start building the distributions."))
|
||||
button(_(u"Cancel"), ui.jumps("top"), "")
|
||||
|
||||
mid(message)
|
||||
ui.bar(m, n, xmaximum=200, xalign=0.5)
|
||||
ui.close()
|
||||
|
||||
ui.pausebehavior(0)
|
||||
interact()
|
||||
act = interact()
|
||||
|
||||
if act == "build_windows":
|
||||
build_windows = not build_windows
|
||||
elif act == "build_linux":
|
||||
build_linux = not build_linux
|
||||
elif act == "build_mac":
|
||||
build_mac = not build_mac
|
||||
elif act == "build_all":
|
||||
build_all = not build_all
|
||||
elif act == "base_name":
|
||||
|
||||
base_name = input(
|
||||
_(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\"."),
|
||||
base_name)
|
||||
|
||||
elif act == "executable_name":
|
||||
|
||||
executable_name = input(
|
||||
_(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."),
|
||||
executable_name)
|
||||
|
||||
# Check to see which platforms we can build on.
|
||||
if os.path.exists(config.renpy_base + "/renpy.exe"):
|
||||
windows = True
|
||||
else:
|
||||
windows = False
|
||||
elif act == "ignore_extensions":
|
||||
|
||||
if os.path.exists(config.renpy_base + "/lib/linux-x86"):
|
||||
linux = True
|
||||
else:
|
||||
linux = False
|
||||
ignore_extensions = input(
|
||||
_(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."),
|
||||
ignore_extensions)
|
||||
|
||||
if os.path.exists(config.renpy_base + "/lib/linux-iliad"):
|
||||
iliad = True
|
||||
else:
|
||||
iliad = False
|
||||
elif act == "documentation_extensions":
|
||||
|
||||
if os.path.exists(config.renpy_base + "/renpy.app"):
|
||||
mac = True
|
||||
else:
|
||||
mac = False
|
||||
|
||||
if not (windows or mac or linux or iliad):
|
||||
store.error(u"Can't Distribute", u"Ren'Py is missing files required for distribution. Please download the full package from {a=http://www.renpy.org/}www.renpy.org{/a}.", "tools_menu")
|
||||
|
||||
lint()
|
||||
documentation_extensions = input(
|
||||
_(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."),
|
||||
documentation_extensions)
|
||||
|
||||
elif act == "build":
|
||||
break
|
||||
|
||||
store.message = ""
|
||||
# Store the user-selected options in info, and save info.
|
||||
|
||||
title(_(u"Building Distributions"))
|
||||
project.info["distribution_base"] = base_name
|
||||
project.info["executable_name"] = executable_name
|
||||
project.info["ignore_extensions"] = ignore_extensions
|
||||
project.info["documentation_extensions"] = documentation_extensions
|
||||
|
||||
mid()
|
||||
text(u"I've just performed a lint on your project. If it contains errors, you should say no and fix them.\nCheck {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?")
|
||||
ui.close()
|
||||
|
||||
bottom()
|
||||
button(u"Yes", clicked=ui.returns(True))
|
||||
button(u"No", clicked=ui.returns(False))
|
||||
ui.close()
|
||||
|
||||
if not interact():
|
||||
renpy.jump("tools")
|
||||
|
||||
|
||||
# if not windows or not mac or not linux:
|
||||
# store.message = "The full version of Ren'Py can build for Windows, Mac, and Linux. Download it from www.renpy.org."
|
||||
|
||||
title(u"Building Distributions")
|
||||
|
||||
mid()
|
||||
text(u"Distributions will be built for the following platforms:")
|
||||
|
||||
spacer()
|
||||
|
||||
if windows:
|
||||
text(u"Windows 2000+", style='launcher_input')
|
||||
|
||||
if linux:
|
||||
text(u"Linux x86", style='launcher_input')
|
||||
|
||||
if iliad:
|
||||
text(u"iLiad", style='launcher_input')
|
||||
|
||||
if mac:
|
||||
text(u"Mac OS X 10.4+", style='launcher_input')
|
||||
|
||||
spacer()
|
||||
|
||||
|
||||
# TODO: If missing platforms, prompt for a DL.
|
||||
|
||||
text(u"Is this okay?")
|
||||
ui.close()
|
||||
|
||||
bottom()
|
||||
button(u"Yes", clicked=ui.returns(True))
|
||||
button(u"No", clicked=ui.returns(False))
|
||||
ui.close()
|
||||
|
||||
if not interact():
|
||||
renpy.jump("tools")
|
||||
|
||||
default_name = project.info.get('distribution_base', project.name)
|
||||
|
||||
name = prompt(u"Building Distributions",
|
||||
u"Please enter a base name for the directories making up this distribution.",
|
||||
"tools",
|
||||
default_name,
|
||||
u"This usually should include a name and version number, like 'moonlight_walks-1.0'.")
|
||||
|
||||
name = name.strip()
|
||||
|
||||
if not name:
|
||||
store.error(u"Error", u"The distribution name should not be empty.", "tools_menu")
|
||||
|
||||
try:
|
||||
name = name.encode("ascii")
|
||||
except:
|
||||
store.error(u"Error", u"Distribution names must be ASCII. This is because archive file formats do not support non-ASCII characters in a uniform way.", "tools_menu")
|
||||
|
||||
project.info['distribution_base'] = name
|
||||
|
||||
ignore_extensions = project.info.get('ignore_extensions', "~ .bak")
|
||||
ignore_extensions = prompt(u"Building Distributions", u"Please enter a space separated list of the file extensions you do not want included in the distribution.", "tools", ignore_extensions)
|
||||
store.ignore_extensions = [ i.strip() for i in ignore_extensions.strip().split() ]
|
||||
project.info['ignore_extensions'] = ignore_extensions
|
||||
project.info["build_windows"] = build_windows
|
||||
project.info["build_linux"] = build_linux
|
||||
project.info["build_mac"] = build_mac
|
||||
project.info["build_all"] = build_all
|
||||
|
||||
project.save()
|
||||
|
||||
# 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() ]
|
||||
|
||||
# Figure out the files that will make up the distribution.
|
||||
# Scan for the files we want to include in the various distributions.
|
||||
info(_(u"Scanning..."), "")
|
||||
|
||||
multi = [ ]
|
||||
# Files included in the various distributions.
|
||||
multi_files = [ ]
|
||||
win_files = [ ]
|
||||
linux_files = [ ]
|
||||
mac_files = [ ]
|
||||
|
||||
# This finds the files and directories in the tree, and includes
|
||||
# them in the result.
|
||||
|
||||
|
||||
# renpy and common directories.
|
||||
multi.extend(tree(config.renpy_base + "/renpy", "renpy"))
|
||||
multi.append((config.renpy_base + "/LICENSE.txt", "renpy/LICENSE.txt"))
|
||||
multi.extend(tree(config.commondir, "common"))
|
||||
# A map from source file name to replacement data to be placed in
|
||||
# that file.
|
||||
file_data = { }
|
||||
|
||||
# Include the project.
|
||||
multi.extend(tree(project.path, '',
|
||||
exclude_suffix = [ ],
|
||||
exclude_prefix = [ ],
|
||||
exclude=[ ],
|
||||
root=True))
|
||||
|
||||
shortgamedir = project.gamedir[len(project.path)+1:]
|
||||
######################################################################
|
||||
# Multi files.
|
||||
|
||||
rb = config.renpy_base.replace("\\", "/") + "/"
|
||||
|
||||
def add_script_version(fn, multi=multi, shortgamedir=shortgamedir):
|
||||
|
||||
|
||||
for a, b in multi:
|
||||
if b == shortgamedir + "/" + fn:
|
||||
|
||||
# Project files.
|
||||
multi_files.extend(tree(project.path, "/", root=True, exclude_suffix=ignore_extensions))
|
||||
multi_files.append((rb + "renpy.py", "/" + executable_name + ".py"))
|
||||
|
||||
# Renpy files.
|
||||
multi_files.extend(tree(rb + "common", "/common"))
|
||||
multi_files.extend(tree(rb + "renpy", "/renpy"))
|
||||
multi_files.append((rb + "LICENSE.txt", "/renpy/LICENSE.txt"))
|
||||
|
||||
def add_script_version(fn, ignore_extensions=ignore_extensions, multi_files=multi_files, rb=rb):
|
||||
"""
|
||||
Add a script_version file if it does not already exist, and if the
|
||||
extension is allowed by the game.
|
||||
"""
|
||||
|
||||
for a, b in multi_files:
|
||||
if b == "/game/" + fn:
|
||||
return
|
||||
|
||||
for i in store.ignore_extensions:
|
||||
for i in ignore_extensions:
|
||||
if fn.endswith(i):
|
||||
return
|
||||
return
|
||||
|
||||
multi.append((config.gamedir + "/" + fn, shortgamedir + "/" + fn))
|
||||
multi_files.append((rb + "launcher/" + fn, "/game/" + fn))
|
||||
|
||||
add_script_version("script_version.rpy")
|
||||
add_script_version("script_version.rpyc")
|
||||
|
||||
# renpy.py
|
||||
multi.append((config.renpy_base + "/renpy.py",
|
||||
project.name + ".py"))
|
||||
|
||||
# Windows Zip
|
||||
if windows:
|
||||
win_files = [
|
||||
( config.renpy_base + "/renpy.exe", project.name + ".exe"),
|
||||
( config.renpy_base + "/renpy.code", "renpy.code" ),
|
||||
( config.renpy_base + "/python25.dll", "python25.dll" ),
|
||||
( config.renpy_base + "/msvcr71.dll", "msvcr71.dll" ),
|
||||
]
|
||||
|
||||
######################################################################
|
||||
# Windows files.
|
||||
|
||||
if build_windows or build_all:
|
||||
|
||||
win_files.append((rb + "renpy.exe", "/" + executable_name + ".exe"))
|
||||
win_files.append((rb + "renpy.code", "/renpy.code"))
|
||||
win_files.append((rb + "python25.dll", "/python25.dll"))
|
||||
win_files.append((rb + "msvcr71.dll", "/msvcr71.dll"))
|
||||
|
||||
win_data = { }
|
||||
if os.path.exists(project.path + "/icon.ico"):
|
||||
win_data[project.name + ".exe"] = pefile.change_icons(
|
||||
config.renpy_base + "/renpy.exe",
|
||||
file_data[rb + "renpy.exe"] = pefile.change_icons(
|
||||
rb + "renpy.exe",
|
||||
project.path + "/icon.ico",
|
||||
)
|
||||
|
||||
|
||||
######################################################################
|
||||
# Linux files.
|
||||
|
||||
if build_linux or build_all:
|
||||
|
||||
linux_files.append((rb + "renpy.sh", "/" + executable_name + ".sh"))
|
||||
linux_files.append((rb + "lib", "/lib"))
|
||||
linux_files.append((rb + "lib/python", "/lib/python"))
|
||||
linux_files.extend(tree(rb + "lib/linux-x86", "/lib/linux-x86"))
|
||||
|
||||
# Warning: The tar.bz2 builder doesn't support file_data.
|
||||
|
||||
|
||||
zf = zipfile.ZipFile(name + ".zip", "w", zipfile.ZIP_DEFLATED)
|
||||
######################################################################
|
||||
# Mac (non-app) files.
|
||||
|
||||
if build_mac or build_all:
|
||||
mac_files = tree(rb + "renpy.app",
|
||||
"/" + executable_name + ".app")
|
||||
|
||||
progress_len = len(multi) + len(win_files)
|
||||
store.message = u"Be sure to announce your project at the Lemma Soft Forums."
|
||||
|
||||
for i, (fn, an) in enumerate(multi + win_files):
|
||||
progress(u"Building Windows", i, progress_len)
|
||||
# Rename executable.
|
||||
mac_files = [ (fn, an.replace("Ren'Py Launcher", executable_name)) for (fn, an) in mac_files ]
|
||||
|
||||
if os.path.isdir(fn):
|
||||
continue
|
||||
|
||||
zi = zipfile.ZipInfo(name + "/" + an)
|
||||
# Plist file.
|
||||
quoted_name = executable_name.replace("&", "&").replace("<", "<")
|
||||
info_plist = file(rb + "renpy.app/Contents/Info.plist", "rb").read().replace("Ren'Py Launcher", quoted_name)
|
||||
file_data[rb + "renpy.app/Contents/Info.plist"] = info_plist
|
||||
|
||||
s = os.stat(fn)
|
||||
zi.date_time = time.gmtime(s.st_mtime)[:6]
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.create_system = 3
|
||||
|
||||
zi.external_attr = long(0100666) << 16
|
||||
data = file(fn, "rb").read()
|
||||
|
||||
data = win_data.get(an, data)
|
||||
|
||||
zf.writestr(zi, data)
|
||||
|
||||
|
||||
zf.close()
|
||||
|
||||
|
||||
# Linux Tar Bz2
|
||||
if linux:
|
||||
|
||||
linux_files = [
|
||||
(config.renpy_base + "/lib/linux-x86", "lib/linux-x86"),
|
||||
(config.renpy_base + "/renpy.sh", project.name + ".sh"),
|
||||
(config.renpy_base + "/lib/python", "lib/python"),
|
||||
]
|
||||
|
||||
|
||||
linux_files.extend(tree(config.renpy_base + "/lib/linux-x86", "lib/linux-x86"))
|
||||
|
||||
tf = tarfile.open(name + "-linux-x86.tar.bz2", "w:bz2")
|
||||
tf.dereference = True
|
||||
|
||||
progress_len = len(multi) + len(linux_files)
|
||||
store.message = u"If appropriate, please submit your game to www.renai.us."
|
||||
|
||||
for j, i in enumerate(multi + linux_files):
|
||||
|
||||
progress(u"Building Linux", j, progress_len)
|
||||
|
||||
fn, an = i
|
||||
|
||||
info = tf.gettarinfo(fn, name + "-linux-x86/" + an)
|
||||
|
||||
if info.isdir():
|
||||
perms = 0777
|
||||
elif info.name.endswith(".sh"):
|
||||
perms = 0777
|
||||
elif info.name.endswith(".so"):
|
||||
perms = 0777
|
||||
elif info.name.endswith("python"):
|
||||
perms = 0777
|
||||
elif info.name.endswith("python.real"):
|
||||
perms = 0777
|
||||
else:
|
||||
perms = 0666
|
||||
|
||||
info.mode = perms
|
||||
info.uid = 1000
|
||||
info.gid = 1000
|
||||
info.uname = "renpy"
|
||||
info.gname = "renpy"
|
||||
|
||||
if info.isreg():
|
||||
tf.addfile(info, file(fn, "rb"))
|
||||
else:
|
||||
tf.addfile(info)
|
||||
|
||||
tf.close()
|
||||
|
||||
|
||||
# iLiad Tar Bz2
|
||||
if iliad:
|
||||
|
||||
iliad_files = [
|
||||
(config.renpy_base + "/lib", "lib"),
|
||||
(config.renpy_base + "/renpy-iliad.sh", project.name + ".sh"),
|
||||
(config.renpy_base + "/lib/python", "lib/python"),
|
||||
(config.renpy_base + "/manifest.xml", "manifest.xml"),
|
||||
(config.renpy_base + "/iliad-icon.png", "iliad-icon.png"),
|
||||
]
|
||||
|
||||
iliad_files.extend(tree(config.renpy_base + "/lib/linux-iliad", "lib/linux-iliad"))
|
||||
|
||||
iliad_data = { }
|
||||
|
||||
manifest = file(config.renpy_base + "/manifest.xml", "r").read()
|
||||
manifest = manifest.replace("GAMENAME", project.name)
|
||||
iliad_data["manifest.xml"] = manifest
|
||||
|
||||
zf = zipfile.ZipFile(name + "-iLiad.zip", "w", zipfile.ZIP_DEFLATED)
|
||||
|
||||
progress_len = len(multi) + len(iliad_files)
|
||||
store.message = u"We thank Hixbooks for sponsoring iLiad support."
|
||||
|
||||
for i, (fn, an) in enumerate(multi + iliad_files):
|
||||
|
||||
progress(u"Building iLiad", i, progress_len)
|
||||
|
||||
if os.path.isdir(fn):
|
||||
continue
|
||||
|
||||
zi = zipfile.ZipInfo(project.name + "/" + an)
|
||||
|
||||
s = os.stat(fn)
|
||||
zi.date_time = time.gmtime(s.st_mtime)[:6]
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.create_system = 3
|
||||
|
||||
for ext in [ ".sh", ".so", "python", "python.real" ]:
|
||||
if fn.endswith(ext):
|
||||
zi.external_attr = long(0100777) << 16
|
||||
data = file(fn, "rb").read()
|
||||
break
|
||||
else:
|
||||
zi.external_attr = long(0100666) << 16
|
||||
data = file(fn, "rb").read()
|
||||
|
||||
data = iliad_data.get(an, data)
|
||||
zf.writestr(zi, data)
|
||||
|
||||
zf.close()
|
||||
|
||||
if mac:
|
||||
|
||||
mac_files = tree(config.renpy_base + "/renpy.app",
|
||||
project.name + ".app")
|
||||
|
||||
mac_files = [ (fn, an.replace("Ren'Py Launcher", project.name)) for (fn, an) in mac_files ]
|
||||
|
||||
# Data replacement for macintosh.
|
||||
mac_data = { }
|
||||
|
||||
quoted_name = project.name.replace("&", "&").replace("<", "<")
|
||||
info_plist = file(config.renpy_base + "/renpy.app/Contents/Info.plist", "rb").read().replace("Ren'Py Launcher", quoted_name)
|
||||
mac_data[project.name + ".app/Contents/Info.plist"] = info_plist
|
||||
|
||||
quoted_name = project.name.replace("\"", "\\\"")
|
||||
launcher_py = file(config.renpy_base + "/renpy.app/Contents/Resources/launcher.py", "rb").read().replace("Ren'Py Launcher", quoted_name)
|
||||
mac_data[project.name + ".app/Contents/Resources/launcher.py"] = launcher_py
|
||||
# Launcher script.
|
||||
quoted_name = executable_name.replace("\"", "\\\"")
|
||||
launcher_py = file(rb + "renpy.app/Contents/Resources/launcher.py", "rb").read().replace("Ren'Py Launcher", quoted_name)
|
||||
file_data[rb + "renpy.app/Contents/Resources/launcher.py"] = launcher_py
|
||||
|
||||
# Icon file.
|
||||
if os.path.exists(project.path + "/icon.icns"):
|
||||
icon_data = file(project.path + "/icon.icns", "rb").read()
|
||||
mac_data[project.name + ".app/Contents/Resources/launcher.icns"] = icon_data
|
||||
|
||||
zf = zipfile.ZipFile(name + "-mac.zip", "w", zipfile.ZIP_DEFLATED)
|
||||
file_data[rb + "renpy.app/Contents/Resources/launcher.icns"] = icon_data
|
||||
|
||||
progress_len = len(multi) + len(mac_files)
|
||||
store.message = u"Thank you for choosing Ren'Py."
|
||||
|
||||
for i, (fn, an) in enumerate(multi + mac_files):
|
||||
######################################################################
|
||||
# Now, build the various distributions.
|
||||
|
||||
progress(u"Building Mac OS X", i, progress_len)
|
||||
if build_windows:
|
||||
make_zip(
|
||||
_(u"Building Windows..."),
|
||||
base_name + "-win32",
|
||||
multi_files + win_files,
|
||||
file_data)
|
||||
|
||||
if os.path.isdir(fn):
|
||||
continue
|
||||
if build_linux:
|
||||
make_tar(
|
||||
_(u"Building Linux..."),
|
||||
base_name + "-linux-x86",
|
||||
multi_files + linux_files)
|
||||
|
||||
zi = zipfile.ZipInfo(name + "-mac/" + an)
|
||||
|
||||
s = os.stat(fn)
|
||||
zi.date_time = time.gmtime(s.st_mtime)[:6]
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.create_system = 3
|
||||
|
||||
if os.path.dirname(fn).endswith("MacOS") or fn.endswith(".so") or fn.endswith(".dylib"):
|
||||
zi.external_attr = long(0100777) << 16
|
||||
data = file(fn, "rb").read()
|
||||
if build_mac:
|
||||
|
||||
# Reorganize the files so all the non application files live inside
|
||||
# the application. If there's documentation involved, then it
|
||||
# lives in both places.
|
||||
macapp_files = [ ]
|
||||
|
||||
for fn, an in multi_files + mac_files:
|
||||
if not an.startswith("/" + executable_name + ".app"):
|
||||
new_an = "/" + executable_name + ".app/Contents/Resources/autorun" + an
|
||||
macapp_files.append((fn, new_an))
|
||||
|
||||
if an.rindex('/') == 0:
|
||||
for i in documentation_extensions:
|
||||
if fn.endswith(i):
|
||||
macapp_files.append((fn, an))
|
||||
break
|
||||
else:
|
||||
zi.external_attr = long(0100666) << 16
|
||||
data = file(fn, "rb").read()
|
||||
macapp_files.append((fn, an))
|
||||
|
||||
make_zip(
|
||||
_(u"Building Macintosh..."),
|
||||
base_name + "-mac",
|
||||
macapp_files,
|
||||
file_data)
|
||||
|
||||
data = mac_data.get(an, data)
|
||||
zf.writestr(zi, data)
|
||||
|
||||
if build_all:
|
||||
make_zip(
|
||||
_(u"Building Combined..."),
|
||||
base_name + "-all",
|
||||
multi_files + win_files + linux_files + mac_files,
|
||||
file_data)
|
||||
|
||||
zf.close()
|
||||
# Report success to the user.
|
||||
set_tooltip(_(u"Thank you for choosing Ren'Py."))
|
||||
|
||||
|
||||
# Announce Success
|
||||
|
||||
store.message = ""
|
||||
|
||||
title(u"Success")
|
||||
|
||||
mid()
|
||||
text(u"The distribution(s) have been built. Be sure to test them before release.")
|
||||
|
||||
spacer()
|
||||
|
||||
if mac:
|
||||
text(u"Note that unpacking and repacking Mac zips and Linux tarballs on Windows isn't supported.")
|
||||
|
||||
ui.close()
|
||||
|
||||
bottom()
|
||||
button(u"Return", clicked=ui.returns(True))
|
||||
ui.close()
|
||||
screen()
|
||||
ui.vbox()
|
||||
|
||||
title(_(u"Success"))
|
||||
text(_(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."))
|
||||
|
||||
ui.null(height=20)
|
||||
|
||||
button(_(u"Return"), ui.jumps("top"), None)
|
||||
|
||||
ui.close()
|
||||
interact()
|
||||
|
||||
|
||||
jump tools
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +1,162 @@
|
||||
# This file contains logic for detecting an editor, and for selecting
|
||||
# the default editor.
|
||||
# This file contains logic for selecting an editor.
|
||||
|
||||
init:
|
||||
python hide:
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
init python:
|
||||
|
||||
if not config.editor:
|
||||
import glob
|
||||
import re
|
||||
import traceback
|
||||
import os
|
||||
import os.path
|
||||
|
||||
|
||||
# The default name for the editor.
|
||||
if persistent.editor is None:
|
||||
persistent.editor = "jEdit"
|
||||
|
||||
# A map from editor name to the file containing information about
|
||||
# that editor.
|
||||
editors = { }
|
||||
|
||||
editor = os.path.normpath(config.renpy_base + "/jedit/jedit.jar")
|
||||
editor = renpy.shell_escape(editor)
|
||||
# A map from editor to the version of that editor.
|
||||
editor_versions = { }
|
||||
|
||||
if sys.platform == 'win32':
|
||||
config.editor = 'javaw.exe -jar "' + editor + '" -reuseview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
config.editor_transient = 'javaw.exe -jar "' + editor + '" -newplainview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
else:
|
||||
config.editor = 'java -jar "' + editor + '" -reuseview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
config.editor_transient = 'java -jar "' + editor + '" -newplainview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
# A map from editor to a description of that editor.
|
||||
editor_descriptions = { }
|
||||
|
||||
# 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
|
||||
checks out, adds it to editors. Uses editor_versions as a cache
|
||||
so we only add the newest version of each editor.
|
||||
"""
|
||||
|
||||
info = { }
|
||||
|
||||
f = file(ef, "r")
|
||||
for l in f:
|
||||
m = re.match("#\s*(\w+):\s*(.*?)\s*$", l)
|
||||
if not m:
|
||||
break
|
||||
|
||||
info[m.group(1)] = m.group(2)
|
||||
|
||||
f.close()
|
||||
|
||||
if config.editor:
|
||||
os.environ['RENPY_EDITOR'] = config.editor
|
||||
if config.editor_transient:
|
||||
os.environ['RENPY_EDITOR_TRANSIENT'] = config.editor_transient
|
||||
|
||||
try:
|
||||
name = info["Name"]
|
||||
version = int(info["Version"])
|
||||
description = info.get("Description", "")
|
||||
except:
|
||||
traceback.print_exc()
|
||||
print >>sys.stderr, ef
|
||||
|
||||
|
||||
if version > editor_versions.get(name, -1):
|
||||
editors[name] = ef
|
||||
editor_versions[name] = version
|
||||
editor_descriptions[name] = description
|
||||
|
||||
|
||||
def scan_editors():
|
||||
"""
|
||||
Finds all *.editor.py files, and uses them to populate the list
|
||||
of editors.
|
||||
"""
|
||||
|
||||
editors.clear()
|
||||
editor_versions.clear()
|
||||
editor_descriptions.clear()
|
||||
|
||||
for d in [ config.renpy_base, persistent.projects_directory ]:
|
||||
if d is None:
|
||||
continue
|
||||
|
||||
for ef in glob.glob(d + "/*/*.editor.py"):
|
||||
scan_editor(ef)
|
||||
|
||||
|
||||
def setup_editor():
|
||||
"""
|
||||
Sets the system up to respect the value containined in
|
||||
persistent.editor.
|
||||
"""
|
||||
|
||||
if not set_editor:
|
||||
return
|
||||
|
||||
ef = None
|
||||
|
||||
for i in [ persistent.editor, "jEdit", "None" ]:
|
||||
if i in editors:
|
||||
ef = editors[i]
|
||||
break
|
||||
else:
|
||||
return
|
||||
|
||||
ctx = {
|
||||
"renpy" : renpy,
|
||||
"config" : config,
|
||||
"persistent" : persistent,
|
||||
"base" : os.path.dirname(ef),
|
||||
}
|
||||
|
||||
execfile(ef, ctx, ctx)
|
||||
|
||||
if set_editor:
|
||||
if config.editor:
|
||||
os.environ['RENPY_EDITOR'] = config.editor
|
||||
else:
|
||||
if 'RENPY_EDITOR' in os.environ:
|
||||
del os.environ['RENPY_EDITOR']
|
||||
|
||||
if set_editor_transient:
|
||||
if config.editor_transient:
|
||||
os.environ['RENPY_EDITOR_TRANSIENT'] = config.editor_transient
|
||||
else:
|
||||
if 'RENPY_EDITOR_TRANSIENT' in os.environ:
|
||||
del os.environ['RENPY_EDITOR_TRANSIENT']
|
||||
|
||||
label editor:
|
||||
|
||||
python hide:
|
||||
|
||||
if not set_editor:
|
||||
error(_(u"The editor has been set from the RENPY_EDITOR environment variable, and cannot be changed."), "options")
|
||||
|
||||
set_tooltip("")
|
||||
|
||||
screen()
|
||||
ui.vbox()
|
||||
title(_(u"Choose Editor"))
|
||||
|
||||
text(_(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}."))
|
||||
|
||||
ui.null(height=15)
|
||||
|
||||
scrolled("options")
|
||||
|
||||
ui.vbox()
|
||||
|
||||
for i in sorted(editors, key=lambda a : a.lower()):
|
||||
button(i,
|
||||
ui.returns(i),
|
||||
editor_descriptions[i])
|
||||
|
||||
ui.close() # Vbox
|
||||
ui.close() # Scrolled
|
||||
|
||||
ui.close() # Vbox
|
||||
|
||||
persistent.editor = interact()
|
||||
setup_editor()
|
||||
|
||||
jump options
|
||||
|
||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 7.7 KiB |
@@ -0,0 +1,315 @@
|
||||
# This file contains the various components of the launcher interface.
|
||||
|
||||
init python:
|
||||
|
||||
import time
|
||||
|
||||
|
||||
# Settings.
|
||||
config.developer = True
|
||||
|
||||
# Style customizations. These need to be in a function so that we can
|
||||
# change them when we're choosing a theme.
|
||||
def customize_styles():
|
||||
style.window.yminimum = 60
|
||||
style.window.left_padding = 60
|
||||
|
||||
style.hyperlink_text.color = "#03c"
|
||||
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!")
|
||||
|
||||
def show_tooltip(st, at):
|
||||
return Text(tooltip, color="#fff", size=14), None
|
||||
|
||||
def set_tooltip(s):
|
||||
global tooltip
|
||||
|
||||
if tooltip != s:
|
||||
tooltip = s
|
||||
renpy.restart_interaction()
|
||||
|
||||
tooltips = renpy.curry(set_tooltip)
|
||||
|
||||
def unset_tooltip(s):
|
||||
global tooltip
|
||||
|
||||
if s and tooltip == s:
|
||||
tooltip = ""
|
||||
renpy.restart_interaction()
|
||||
|
||||
untooltips = renpy.curry(unset_tooltip)
|
||||
|
||||
|
||||
def screen():
|
||||
"""
|
||||
Display a screen. This should be called before any code that
|
||||
draws to the screen.
|
||||
"""
|
||||
|
||||
ui.add(Solid("#fff"))
|
||||
|
||||
ui.window(yalign=1.0)
|
||||
ui.add(DynamicDisplayable(show_tooltip))
|
||||
|
||||
ui.image("eileen_small.png", xalign=0.0, yalign=1.0)
|
||||
|
||||
ui.window(xmargin=20, top_margin=4, bottom_margin=85, style='default')
|
||||
|
||||
def interact():
|
||||
"""
|
||||
Closes the screen, and causes an interaction to occur.
|
||||
"""
|
||||
|
||||
return ui.interact(suppress_overlay=True, suppress_underlay=True)
|
||||
|
||||
def title(s):
|
||||
"""
|
||||
Display a title on the screen.
|
||||
"""
|
||||
|
||||
ui.window(style="default", bottom_margin=4, top_margin=12)
|
||||
ui.text(s, size=26, color="#333", font="DejaVuSerif.ttf")
|
||||
|
||||
def text(s):
|
||||
"""
|
||||
Display text on the screen.
|
||||
"""
|
||||
|
||||
ui.text(s, size=15, color="#333", font="DejaVuSerif.ttf", justify=True)
|
||||
|
||||
def button(s, clicked=None, subtitle="", hovered=None, unhovered=None, size=20):
|
||||
"""
|
||||
Displays a button with caption `s`.
|
||||
"""
|
||||
|
||||
if subtitle is not None:
|
||||
if hovered is None:
|
||||
hovered = tooltips(subtitle)
|
||||
|
||||
if unhovered is None:
|
||||
unhovered = untooltips(subtitle)
|
||||
|
||||
ui.button(style="default", clicked=clicked,
|
||||
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)
|
||||
|
||||
def small_button(s, clicked=None, subtitle="", hovered=None, unhovered=None):
|
||||
"""
|
||||
Displays a button with caption `s`.
|
||||
"""
|
||||
|
||||
if hovered is None:
|
||||
hovered = tooltips(subtitle)
|
||||
|
||||
if unhovered is None:
|
||||
unhovered = untooltips(subtitle)
|
||||
|
||||
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)
|
||||
|
||||
def toggle_button(s, checked, clicked=None, subtitle=""):
|
||||
"""
|
||||
Displays a button with caption `s`.
|
||||
"""
|
||||
|
||||
hovered = tooltips(subtitle)
|
||||
unhovered = untooltips(subtitle)
|
||||
|
||||
if checked:
|
||||
s = u"\u25a3 " + s
|
||||
else:
|
||||
s = u"\u25a1 " + 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)
|
||||
|
||||
def scrolled(cancel, yadj=None):
|
||||
|
||||
if yadj is None:
|
||||
yadj = ui.adjustment()
|
||||
|
||||
ui.side(['r', 'b', 'c'])
|
||||
|
||||
ui.bar(adjustment=yadj, style='lscrollbar')
|
||||
|
||||
if cancel:
|
||||
ui.vbox()
|
||||
ui.null(height=12)
|
||||
button(_(u"Cancel"), clicked=ui.jumps(cancel))
|
||||
ui.close()
|
||||
else:
|
||||
ui.null()
|
||||
|
||||
ui.viewport(yadjustment=yadj, mousewheel=True)
|
||||
|
||||
# Left up to the user to close.
|
||||
|
||||
def error(message, target="top"):
|
||||
"""
|
||||
Displays an error to the user, and lets him click to return to
|
||||
`target`.
|
||||
"""
|
||||
|
||||
set_tooltip("")
|
||||
|
||||
screen()
|
||||
|
||||
ui.vbox()
|
||||
title(_(u"Error"))
|
||||
text(message)
|
||||
|
||||
ui.null(height=20)
|
||||
|
||||
if target is None:
|
||||
clicked = ui.returns(True)
|
||||
else:
|
||||
clicked = ui.jumps(target)
|
||||
|
||||
button(_(u"Return"), clicked, None)
|
||||
ui.close()
|
||||
|
||||
interact()
|
||||
|
||||
def info(t, message):
|
||||
"""
|
||||
Displays an informational message to the user, and immediately
|
||||
returns.
|
||||
"""
|
||||
|
||||
ui.pausebehavior(0)
|
||||
|
||||
screen()
|
||||
|
||||
ui.vbox()
|
||||
title(t)
|
||||
text(message)
|
||||
ui.close()
|
||||
|
||||
interact()
|
||||
|
||||
def yesno(t, message):
|
||||
"""
|
||||
Asks a yes/no question of the user.
|
||||
"""
|
||||
|
||||
set_tooltip("")
|
||||
|
||||
screen()
|
||||
|
||||
ui.vbox()
|
||||
title(t)
|
||||
text(message)
|
||||
button(_(u"Yes"), ui.returns(True), "")
|
||||
button(_(u"No"), ui.returns(False), "")
|
||||
ui.close()
|
||||
|
||||
return interact()
|
||||
|
||||
def text_variable(t, value, returns, tooltip=""):
|
||||
|
||||
text(t)
|
||||
small_button(value, ui.returns(returns), tooltip)
|
||||
ui.null(height=5)
|
||||
|
||||
def input(t, prompt, value, cancel=None):
|
||||
|
||||
set_tooltip(_(u"Press enter when done."))
|
||||
|
||||
while True:
|
||||
|
||||
screen()
|
||||
ui.vbox()
|
||||
|
||||
title(t)
|
||||
text(prompt)
|
||||
ui.null(height=10)
|
||||
ui.input(value, size=20, color="#00c")
|
||||
|
||||
if cancel is not None:
|
||||
ui.null(height=20)
|
||||
button(_(u"Cancel"), ui.jumps(cancel), "")
|
||||
|
||||
ui.close()
|
||||
|
||||
value = interact()
|
||||
value = value.strip()
|
||||
|
||||
if not value:
|
||||
error(
|
||||
_(u"The string cannot be empty. Please enter some text."),
|
||||
None)
|
||||
|
||||
continue
|
||||
|
||||
try:
|
||||
value = value.encode("ascii")
|
||||
except:
|
||||
error(
|
||||
_(u"Non-ASCII filenames are not allowed. This is because Zip files cannot reliably represent non-ASCII filenames."),
|
||||
None)
|
||||
|
||||
continue
|
||||
|
||||
break
|
||||
|
||||
return value
|
||||
|
||||
# The time progress was last updated. We only update the progress
|
||||
# every 10th of a second, so that we don't waste time doing
|
||||
# such updates.
|
||||
progress_time = 0
|
||||
|
||||
|
||||
def progress(what, limit, amount):
|
||||
"""
|
||||
Show progress to the user.
|
||||
"""
|
||||
|
||||
global progress_time
|
||||
|
||||
t = time.time()
|
||||
if t < progress_time + .1:
|
||||
return
|
||||
|
||||
progress_time = t
|
||||
|
||||
set_tooltip(_(u"Processed %d of %d files.") % (amount + 1, limit))
|
||||
|
||||
ui.pausebehavior(0)
|
||||
|
||||
screen()
|
||||
|
||||
ui.vbox(xfill=True)
|
||||
|
||||
title(what)
|
||||
ui.null(height=20)
|
||||
ui.bar(limit, amount, xmaximum=300, xalign=0.5, style='lbar')
|
||||
|
||||
ui.close()
|
||||
interact()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Name: jEdit
|
||||
# Version: 1
|
||||
# Description: jEdit requires Java be installed on your computer.
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
editor = os.path.normpath(base + "/../jedit/jedit.jar")
|
||||
editor = renpy.shell_escape(editor)
|
||||
|
||||
if sys.platform == 'win32':
|
||||
config.editor = 'javaw.exe -jar "' + editor + '" -reuseview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
config.editor_transient = 'javaw.exe -jar "' + editor + '" -newplainview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
else:
|
||||
config.editor = 'java -jar "' + editor + '" -reuseview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
config.editor_transient = 'java -jar "' + editor + '" -newplainview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 50 KiB |
@@ -1,167 +1,49 @@
|
||||
label new:
|
||||
init python:
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import shutil
|
||||
|
||||
label new_project:
|
||||
|
||||
if persistent.projects_directory is None:
|
||||
call choose_projects_directory
|
||||
|
||||
python hide:
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import time
|
||||
|
||||
name = input(
|
||||
_(u"New Project"),
|
||||
_(u"Please type the name of your new project."),
|
||||
"", cancel='top')
|
||||
|
||||
# Select a template.
|
||||
|
||||
choices = [ (p.name, p.info["description"], p, None, False) for p in projects if p.info.get("template", None)]
|
||||
|
||||
template = paged_menu(u"Select a Template", choices, u"Please select a project to use as a template for your project.")
|
||||
|
||||
# Choose project name.
|
||||
|
||||
name = prompt(u"Project Name", u"Type the name of your new project, and press enter.\n", "main")
|
||||
name = name.strip()
|
||||
|
||||
error = None
|
||||
path = os.path.join(persistent.projects_directory, name)
|
||||
|
||||
if not name:
|
||||
error = u"Please enter a non-empty project name."
|
||||
elif os.path.exists(name):
|
||||
error = u"A file or directory named '%s' already exists." % name
|
||||
else:
|
||||
try:
|
||||
name = name.encode("ascii")
|
||||
except:
|
||||
error = u"Project names must be ASCII. This is because the ZIP file format does not support non-ASCII characters in a uniform way."
|
||||
|
||||
if error:
|
||||
store.error(u"Error", error, "main")
|
||||
|
||||
# Tell the user we're creating the project.
|
||||
title(u"Creating Project")
|
||||
store.message = u"Please wait while we create the project."
|
||||
ui.pausebehavior(0)
|
||||
interact()
|
||||
|
||||
# Here is where we actually create the project.
|
||||
|
||||
import shutil
|
||||
|
||||
shutil.copytree(template.path, name)
|
||||
|
||||
unlink = template.info.get("unlink", [ ])
|
||||
unlink += [ 'launcherinfo.py' ]
|
||||
set_tooltip("")
|
||||
|
||||
for i in unlink:
|
||||
if os.path.exists(name + "/" + i):
|
||||
os.unlink(name + "/" + i)
|
||||
if os.path.exists(path):
|
||||
error(_(u"Something with that name already exists in the projects directory."))
|
||||
|
||||
info(_(u"Creating Project"),
|
||||
_(u"Please wait while we create the project."))
|
||||
|
||||
template = os.path.join(config.renpy_base, "template")
|
||||
|
||||
shutil.copytree(template, path)
|
||||
|
||||
launcherinfo = os.path.join(path, "launcherinfo.py")
|
||||
if os.path.exists(launcherinfo):
|
||||
os.unlink(launcherinfo)
|
||||
|
||||
for dir, dirs, files in os.walk(name):
|
||||
for d in list(dirs):
|
||||
if d.startswith("."):
|
||||
dirs.remove(d)
|
||||
dn = dir + "/" + d
|
||||
shutil.rmtree(dn, True)
|
||||
|
||||
# Change the save directory.
|
||||
options = file(name + "/game/options.rpy").read()
|
||||
options = file(path + "/game/options.rpy").read()
|
||||
save_dir = "%s-%d" % (name, time.time())
|
||||
options = options.replace("template-1220804310", save_dir)
|
||||
file(name + "/game/options.rpy", "w").write(options)
|
||||
|
||||
persistent.project = name
|
||||
file(path + "/game/options.rpy", "w").write(options)
|
||||
|
||||
call find_project from _call_find_project_2
|
||||
p = Project(path)
|
||||
p.select()
|
||||
|
||||
label choose_theme:
|
||||
jump choose_theme
|
||||
|
||||
python hide:
|
||||
|
||||
# Select a color scheme.
|
||||
|
||||
themes = theme_data.keys()
|
||||
themes.sort()
|
||||
|
||||
choices = [ ]
|
||||
for i in themes:
|
||||
|
||||
def hovered(i=i):
|
||||
td = theme_data[i].copy()
|
||||
engine = td["theme"]
|
||||
del td["theme"]
|
||||
|
||||
if engine == "roundrect":
|
||||
renpy.style.restore(style_backup)
|
||||
theme.roundrect(launcher=True, **td)
|
||||
renpy.style.rebuild()
|
||||
return ("repeat", 0)
|
||||
|
||||
choices.append((i, None, i, hovered, False))
|
||||
|
||||
color_theme = paged_menu(u"Select a Theme", choices, u"Please select a color theme for your project. You can always change the colors later.", cancel='color_theme_cancel')
|
||||
|
||||
# Restore default theme.
|
||||
renpy.style.restore(style_backup)
|
||||
theme.roundrect(launcher=True)
|
||||
renpy.style.rebuild()
|
||||
|
||||
ofn = project.path + "/game/options.rpy"
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
if not os.path.exists(ofn):
|
||||
error(u"Changing Theme", u"The options file does not seem to exist.", "main")
|
||||
|
||||
inf = file(ofn, "rU")
|
||||
outf = file(ofn + ".new", "w")
|
||||
|
||||
td = theme_data[color_theme]
|
||||
|
||||
# TODO: Make this less specific to roundrect. Need to figure out
|
||||
# how to switch themes, rather than just recolor them.
|
||||
|
||||
changing = False
|
||||
changed = False
|
||||
|
||||
for l in inf:
|
||||
|
||||
if re.match(r'\s*theme.roundrect\(', l):
|
||||
changing = True
|
||||
changed = True
|
||||
elif re.match(r'\s*\)', l):
|
||||
changing = False
|
||||
elif changing:
|
||||
|
||||
def repl(m, td=td):
|
||||
return m.group(1) + m.group(2) + " = \"" + td.get(m.group(2), m.group(3)) + "\","
|
||||
|
||||
l = re.sub(r'^(\s*)(\w+) = "([\da-fA-F#]+)",', repl, l)
|
||||
|
||||
outf.write(l)
|
||||
|
||||
outf.close()
|
||||
inf.close()
|
||||
|
||||
try:
|
||||
os.rename(ofn + ".new", ofn)
|
||||
except:
|
||||
|
||||
# I hate windows.
|
||||
os.rename(ofn, ofn + ".old")
|
||||
os.rename(ofn + ".new", ofn)
|
||||
os.unlink(ofn + ".old")
|
||||
|
||||
if not changed:
|
||||
error(u"Changing Theme", u"Could not modify options.rpy, perhaps it was edited too much.", "main")
|
||||
|
||||
jump main
|
||||
|
||||
|
||||
|
||||
label color_theme_cancel:
|
||||
|
||||
python hide:
|
||||
|
||||
# Restore default theme.
|
||||
renpy.style.restore(style_backup)
|
||||
theme.roundrect(launcher=True)
|
||||
renpy.style.rebuild()
|
||||
|
||||
jump main
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
## This file contains some of the options that can be changed to customize
|
||||
## your Ren'Py game. It only contains the most common options... there
|
||||
## is quite a bit more customization you can do.
|
||||
##
|
||||
## Lines beginning with two '#' marks are comments, and you shouldn't
|
||||
## uncomment them. Lines beginning with a single '#' mark are
|
||||
## commented-out code, and you may want to uncomment them when
|
||||
## appropriate.
|
||||
|
||||
init -1 python hide:
|
||||
|
||||
## Should we enable the use of developer tools? This should be
|
||||
## set to False before the game is released, so the user can't
|
||||
## cheat using developer tools.
|
||||
|
||||
config.developer = True
|
||||
|
||||
## These control the width and height of the screen.
|
||||
|
||||
config.screen_width = 540
|
||||
config.screen_height = 440
|
||||
|
||||
## This controls the title of the window, when Ren'Py is
|
||||
## running in a window.
|
||||
|
||||
config.window_title = _(u"%s Launcher") % renpy.version()
|
||||
|
||||
#########################################
|
||||
# Themes
|
||||
|
||||
## We then want to call a theme function. themes.roundrect is
|
||||
## a theme that features the use of rounded rectangles. It's
|
||||
## the only theme we currently support.
|
||||
##
|
||||
## The theme function takes a number of parameters that can
|
||||
## customize the color scheme.
|
||||
|
||||
theme.roundrect(
|
||||
|
||||
## The color of an idle widget face.
|
||||
widget = "#003c78",
|
||||
|
||||
## The color of a focused widget face.
|
||||
widget_hover = "#0050a0",
|
||||
|
||||
## The color of the text in a widget.
|
||||
widget_text = "#c8ffff",
|
||||
|
||||
## The color of the text in a selected widget. (For
|
||||
## example, the current value of a preference.)
|
||||
widget_selected = "#ffffc8",
|
||||
|
||||
## The color of a disabled widget face.
|
||||
disabled = "#404040",
|
||||
|
||||
## The color of disabled widget text.
|
||||
disabled_text = "#c8c8c8",
|
||||
|
||||
## The color of informational labels.
|
||||
label = "#ffffff",
|
||||
|
||||
## The color of a frame containing widgets.
|
||||
frame = "#6496c8",
|
||||
|
||||
## If this is True, the in-game window is rounded. If False,
|
||||
## the in-game window is square.
|
||||
rounded_window = False,
|
||||
|
||||
## The background of the main menu. This can be a color
|
||||
## beginning with '#', or an image filename. The latter
|
||||
## should take up the full height and width of the screen.
|
||||
mm_root = "#dcebff",
|
||||
|
||||
## The background of the game menu. This can be a color
|
||||
## beginning with '#', or an image filename. The latter
|
||||
## should take up the full height and width of the screen.
|
||||
gm_root = "#dcebff",
|
||||
|
||||
## And we're done with the theme. The theme will customize
|
||||
## various styles, so if we want to change them, we should
|
||||
## do so below.
|
||||
)
|
||||
|
||||
theme.outline_bars(
|
||||
inside="#6496c8",
|
||||
idle="#06c",
|
||||
hover="#00c")
|
||||
|
||||
# Copy the bar styles used by the launcher, so the theme
|
||||
# selector can't change them.
|
||||
style.lbar = Style(style.default)
|
||||
style.lbar.take(style.bar)
|
||||
style.lscrollbar = Style(style.default)
|
||||
style.lscrollbar.take(style.vscrollbar)
|
||||
|
||||
#########################################
|
||||
## These settings let you change some of the sounds that are used by
|
||||
## Ren'Py.
|
||||
|
||||
## Set this to False if the game does not have any sound effects.
|
||||
config.sound = False
|
||||
|
||||
python early:
|
||||
config.save_directory = "launcher-2"
|
||||
|
||||
init -1 python hide:
|
||||
#########################################
|
||||
## Default values of Preferences.
|
||||
|
||||
## Note: These options are only evaluated the first time a
|
||||
## game is run. To have them run a second time, delete
|
||||
## game/saves/persistent
|
||||
|
||||
## Should we start in fullscreen mode?
|
||||
|
||||
config.default_fullscreen = False
|
||||
|
||||
## The default text speed in characters per second. 0 is infinite.
|
||||
|
||||
config.default_text_cps = 0
|
||||
|
||||
#########################################
|
||||
## More customizations can go here.
|
||||
|
||||
config.has_autosave = False
|
||||
|
||||
config.window_icon = "logo.png"
|
||||
config.windows_icon = "logo32.png"
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# This file handles the launcher options screen.
|
||||
|
||||
label options:
|
||||
|
||||
python hide:
|
||||
|
||||
screen()
|
||||
ui.vbox()
|
||||
|
||||
title(_(u"Launcher Options"))
|
||||
|
||||
editor = persistent.editor
|
||||
if not set_editor:
|
||||
editor = _(u"Using RENPY_EDITOR")
|
||||
|
||||
text_variable(_("Text Editor"), editor, "editor",
|
||||
_(u"Change the default text editor."))
|
||||
|
||||
ui.null(height=15)
|
||||
|
||||
button(_(u"Projects Directory"),
|
||||
ui.jumps("options_cpd"),
|
||||
_(u"Select the directory Ren'Py searches for projects."))
|
||||
|
||||
ui.null(height=15)
|
||||
|
||||
button(_(u"Return"), ui.jumps("top"), "")
|
||||
|
||||
ui.close()
|
||||
|
||||
act = interact()
|
||||
|
||||
if act == "editor":
|
||||
renpy.jump("editor")
|
||||
|
||||
|
||||
jump options
|
||||
|
||||
label options_cpd:
|
||||
call choose_projects_directory
|
||||
jump options
|
||||
|
||||
@@ -7,31 +7,38 @@ import sys
|
||||
import array
|
||||
|
||||
# The starting point of the resource segment in the file.
|
||||
RESOURCE_BASE=0x3400
|
||||
RESOURCE_BASE=0x3600
|
||||
|
||||
# The virtual memory location the resource segment is loaded
|
||||
# to.
|
||||
RESOURCE_VIRTUAL=0x6000
|
||||
|
||||
# The offset of the field that tells us with the alignment need be.
|
||||
ALIGNMENT_FIELD = 0x138
|
||||
ALIGNMENT_FIELD = 0x130
|
||||
|
||||
# The start of the .rsrc segment header.
|
||||
RSRC_HEADER = 0x268
|
||||
|
||||
# Locations in the file where we need to patch in the resource
|
||||
# segment length.
|
||||
RESOURCE_LENGTH_PATCHES = [ 0x018c, 0x278 ]
|
||||
RESOURCE_LENGTH_PATCHES = [ 0x0184, RSRC_HEADER + 0x8 ]
|
||||
|
||||
# Locations in the file where we need to patch in the padded
|
||||
# resource segment length.
|
||||
RESOURCE_PADDED_PATCHES = [ 0x280 ]
|
||||
RESOURCE_PADDED_PATCHES = [ RSRC_HEADER + 0x10 ]
|
||||
|
||||
# Locations in the file where we need to patch in the change in the
|
||||
# size of the resource segement (and hence the change in the file's
|
||||
# total size.)
|
||||
SIZE_DELTA_PATCHES = [ 0x150 ]
|
||||
SIZE_DELTA_PATCHES = [ 0x148 ]
|
||||
|
||||
# A location in the file that will be checked to be sure it matches
|
||||
# RESOURCE_BASE.
|
||||
CHECK_ADDRESS = 0x284
|
||||
CHECK_ADDRESS = RSRC_HEADER + 0x14
|
||||
|
||||
# A location in the file that will be checked to make sure it matches
|
||||
# RESOURCE_VIRTUAL
|
||||
CHECK_ADDRESS2 = RSRC_HEADER + 0xc
|
||||
|
||||
# This class performs various operations on memory-loaded binary files,
|
||||
# including modifications.
|
||||
@@ -285,10 +292,14 @@ def change_icons(oldexe, icofn):
|
||||
global pe
|
||||
pe = BinFile(oldexe)
|
||||
|
||||
# Check that RESOURCE_BASE is still valid.
|
||||
# Check that RESOURCE_BASE and RESOURCE_VIRTUAL are still valid.
|
||||
pe.seek(CHECK_ADDRESS)
|
||||
if pe.u32() != RESOURCE_BASE:
|
||||
raise Exception("RESOURCE_BASE is no longer correct. Please check all relocations.")
|
||||
raise Exception("RESOURCE_BASE is no longer correct. Please check all relocations.")
|
||||
|
||||
pe.seek(CHECK_ADDRESS2)
|
||||
if pe.u32() != RESOURCE_VIRTUAL:
|
||||
raise Exception("RESOURCE_VIRTUAL is no longer correct. Please check all relocations.")
|
||||
|
||||
resources = parse_directory(0)
|
||||
# show_resources(resources, "")
|
||||
|
||||
@@ -0,0 +1,453 @@
|
||||
"""Common operations on Posix pathnames.
|
||||
|
||||
Instead of importing this module directly, import os and refer to
|
||||
this module as os.path. The "os.path" name is an alias for this
|
||||
module on Posix systems; on other systems (e.g. Mac, Windows),
|
||||
os.path provides the same operations in a manner specific to that
|
||||
platform, and is an alias to another module (e.g. macpath, ntpath).
|
||||
|
||||
Some of this can actually be useful on non-Posix systems too, e.g.
|
||||
for manipulation of the pathname component of URLs.
|
||||
"""
|
||||
|
||||
import os
|
||||
import stat
|
||||
|
||||
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
|
||||
"basename","dirname","commonprefix","getsize","getmtime",
|
||||
"getatime","getctime","islink","exists","lexists","isdir","isfile",
|
||||
"ismount","walk","expanduser","expandvars","normpath","abspath",
|
||||
"samefile","sameopenfile","samestat",
|
||||
"curdir","pardir","sep","pathsep","defpath","altsep","extsep",
|
||||
"devnull","realpath","supports_unicode_filenames"]
|
||||
|
||||
# strings representing various path-related bits and pieces
|
||||
curdir = '.'
|
||||
pardir = '..'
|
||||
extsep = '.'
|
||||
sep = '/'
|
||||
pathsep = ':'
|
||||
defpath = ':/bin:/usr/bin'
|
||||
altsep = None
|
||||
devnull = '/dev/null'
|
||||
|
||||
# Normalize the case of a pathname. Trivial in Posix, string.lower on Mac.
|
||||
# On MS-DOS this may also turn slashes into backslashes; however, other
|
||||
# normalizations (such as optimizing '../' away) are not allowed
|
||||
# (another function should be defined to do that).
|
||||
|
||||
def normcase(s):
|
||||
"""Normalize case of pathname. Has no effect under Posix"""
|
||||
return s
|
||||
|
||||
|
||||
# Return whether a path is absolute.
|
||||
# Trivial in Posix, harder on the Mac or MS-DOS.
|
||||
|
||||
def isabs(s):
|
||||
"""Test whether a path is absolute"""
|
||||
return s.startswith('/')
|
||||
|
||||
|
||||
# Join pathnames.
|
||||
# Ignore the previous parts if a part is absolute.
|
||||
# Insert a '/' unless the first part is empty or already ends in '/'.
|
||||
|
||||
def join(a, *p):
|
||||
"""Join two or more pathname components, inserting '/' as needed"""
|
||||
path = a
|
||||
for b in p:
|
||||
if b.startswith('/'):
|
||||
path = b
|
||||
elif path == '' or path.endswith('/'):
|
||||
path += b
|
||||
else:
|
||||
path += '/' + b
|
||||
return path
|
||||
|
||||
|
||||
# Split a path in head (everything up to the last '/') and tail (the
|
||||
# rest). If the path ends in '/', tail will be empty. If there is no
|
||||
# '/' in the path, head will be empty.
|
||||
# Trailing '/'es are stripped from head unless it is the root.
|
||||
|
||||
def split(p):
|
||||
"""Split a pathname. Returns tuple "(head, tail)" where "tail" is
|
||||
everything after the final slash. Either part may be empty."""
|
||||
i = p.rfind('/') + 1
|
||||
head, tail = p[:i], p[i:]
|
||||
if head and head != '/'*len(head):
|
||||
head = head.rstrip('/')
|
||||
return head, tail
|
||||
|
||||
|
||||
# Split a path in root and extension.
|
||||
# The extension is everything starting at the last dot in the last
|
||||
# pathname component; the root is everything before that.
|
||||
# It is always true that root + ext == p.
|
||||
|
||||
def splitext(p):
|
||||
"""Split the extension from a pathname. Extension is everything from the
|
||||
last dot to the end. Returns "(root, ext)", either part may be empty."""
|
||||
i = p.rfind('.')
|
||||
if i<=p.rfind('/'):
|
||||
return p, ''
|
||||
else:
|
||||
return p[:i], p[i:]
|
||||
|
||||
|
||||
# Split a pathname into a drive specification and the rest of the
|
||||
# path. Useful on DOS/Windows/NT; on Unix, the drive is always empty.
|
||||
|
||||
def splitdrive(p):
|
||||
"""Split a pathname into drive and path. On Posix, drive is always
|
||||
empty."""
|
||||
return '', p
|
||||
|
||||
|
||||
# Return the tail (basename) part of a path.
|
||||
|
||||
def basename(p):
|
||||
"""Returns the final component of a pathname"""
|
||||
return split(p)[1]
|
||||
|
||||
|
||||
# Return the head (dirname) part of a path.
|
||||
|
||||
def dirname(p):
|
||||
"""Returns the directory component of a pathname"""
|
||||
return split(p)[0]
|
||||
|
||||
|
||||
# Return the longest prefix of all list elements.
|
||||
|
||||
def commonprefix(m):
|
||||
"Given a list of pathnames, returns the longest common leading component"
|
||||
if not m: return ''
|
||||
s1 = min(m)
|
||||
s2 = max(m)
|
||||
n = min(len(s1), len(s2))
|
||||
for i in xrange(n):
|
||||
if s1[i] != s2[i]:
|
||||
return s1[:i]
|
||||
return s1[:n]
|
||||
|
||||
# Get size, mtime, atime of files.
|
||||
|
||||
def getsize(filename):
|
||||
"""Return the size of a file, reported by os.stat()."""
|
||||
return os.stat(filename).st_size
|
||||
|
||||
def getmtime(filename):
|
||||
"""Return the last modification time of a file, reported by os.stat()."""
|
||||
return os.stat(filename).st_mtime
|
||||
|
||||
def getatime(filename):
|
||||
"""Return the last access time of a file, reported by os.stat()."""
|
||||
return os.stat(filename).st_atime
|
||||
|
||||
def getctime(filename):
|
||||
"""Return the metadata change time of a file, reported by os.stat()."""
|
||||
return os.stat(filename).st_ctime
|
||||
|
||||
# Is a path a symbolic link?
|
||||
# This will always return false on systems where os.lstat doesn't exist.
|
||||
|
||||
def islink(path):
|
||||
"""Test whether a path is a symbolic link"""
|
||||
try:
|
||||
st = os.lstat(path)
|
||||
except (os.error, AttributeError):
|
||||
return False
|
||||
return stat.S_ISLNK(st.st_mode)
|
||||
|
||||
|
||||
# Does a path exist?
|
||||
# This is false for dangling symbolic links.
|
||||
|
||||
def exists(path):
|
||||
"""Test whether a path exists. Returns False for broken symbolic links"""
|
||||
try:
|
||||
st = os.stat(path)
|
||||
except os.error:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
# Being true for dangling symbolic links is also useful.
|
||||
|
||||
def lexists(path):
|
||||
"""Test whether a path exists. Returns True for broken symbolic links"""
|
||||
try:
|
||||
st = os.lstat(path)
|
||||
except os.error:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
# Is a path a directory?
|
||||
# This follows symbolic links, so both islink() and isdir() can be true
|
||||
# for the same path.
|
||||
|
||||
def isdir(path):
|
||||
"""Test whether a path is a directory"""
|
||||
try:
|
||||
st = os.stat(path)
|
||||
except os.error:
|
||||
return False
|
||||
return stat.S_ISDIR(st.st_mode)
|
||||
|
||||
|
||||
# Is a path a regular file?
|
||||
# This follows symbolic links, so both islink() and isfile() can be true
|
||||
# for the same path.
|
||||
|
||||
def isfile(path):
|
||||
"""Test whether a path is a regular file"""
|
||||
try:
|
||||
st = os.stat(path)
|
||||
except os.error:
|
||||
return False
|
||||
return stat.S_ISREG(st.st_mode)
|
||||
|
||||
|
||||
# Are two filenames really pointing to the same file?
|
||||
|
||||
def samefile(f1, f2):
|
||||
"""Test whether two pathnames reference the same actual file"""
|
||||
s1 = os.stat(f1)
|
||||
s2 = os.stat(f2)
|
||||
return samestat(s1, s2)
|
||||
|
||||
|
||||
# Are two open files really referencing the same file?
|
||||
# (Not necessarily the same file descriptor!)
|
||||
|
||||
def sameopenfile(fp1, fp2):
|
||||
"""Test whether two open file objects reference the same file"""
|
||||
s1 = os.fstat(fp1)
|
||||
s2 = os.fstat(fp2)
|
||||
return samestat(s1, s2)
|
||||
|
||||
|
||||
# Are two stat buffers (obtained from stat, fstat or lstat)
|
||||
# describing the same file?
|
||||
|
||||
def samestat(s1, s2):
|
||||
"""Test whether two stat buffers reference the same file"""
|
||||
return s1.st_ino == s2.st_ino and \
|
||||
s1.st_dev == s2.st_dev
|
||||
|
||||
|
||||
# Is a path a mount point?
|
||||
# (Does this work for all UNIXes? Is it even guaranteed to work by Posix?)
|
||||
|
||||
def ismount(path):
|
||||
"""Test whether a path is a mount point"""
|
||||
try:
|
||||
s1 = os.lstat(path)
|
||||
s2 = os.lstat(join(path, '..'))
|
||||
except os.error:
|
||||
return False # It doesn't exist -- so not a mount point :-)
|
||||
dev1 = s1.st_dev
|
||||
dev2 = s2.st_dev
|
||||
if dev1 != dev2:
|
||||
return True # path/.. on a different device as path
|
||||
ino1 = s1.st_ino
|
||||
ino2 = s2.st_ino
|
||||
if ino1 == ino2:
|
||||
return True # path/.. is the same i-node as path
|
||||
return False
|
||||
|
||||
|
||||
# Directory tree walk.
|
||||
# For each directory under top (including top itself, but excluding
|
||||
# '.' and '..'), func(arg, dirname, filenames) is called, where
|
||||
# dirname is the name of the directory and filenames is the list
|
||||
# of files (and subdirectories etc.) in the directory.
|
||||
# The func may modify the filenames list, to implement a filter,
|
||||
# or to impose a different order of visiting.
|
||||
|
||||
def walk(top, func, arg):
|
||||
"""Directory tree walk with callback function.
|
||||
|
||||
For each directory in the directory tree rooted at top (including top
|
||||
itself, but excluding '.' and '..'), call func(arg, dirname, fnames).
|
||||
dirname is the name of the directory, and fnames a list of the names of
|
||||
the files and subdirectories in dirname (excluding '.' and '..'). func
|
||||
may modify the fnames list in-place (e.g. via del or slice assignment),
|
||||
and walk will only recurse into the subdirectories whose names remain in
|
||||
fnames; this can be used to implement a filter, or to impose a specific
|
||||
order of visiting. No semantics are defined for, or required of, arg,
|
||||
beyond that arg is always passed to func. It can be used, e.g., to pass
|
||||
a filename pattern, or a mutable object designed to accumulate
|
||||
statistics. Passing None for arg is common."""
|
||||
|
||||
try:
|
||||
names = os.listdir(top)
|
||||
except os.error:
|
||||
return
|
||||
func(arg, top, names)
|
||||
for name in names:
|
||||
name = join(top, name)
|
||||
try:
|
||||
st = os.lstat(name)
|
||||
except os.error:
|
||||
continue
|
||||
if stat.S_ISDIR(st.st_mode):
|
||||
walk(name, func, arg)
|
||||
|
||||
|
||||
# Expand paths beginning with '~' or '~user'.
|
||||
# '~' means $HOME; '~user' means that user's home directory.
|
||||
# If the path doesn't begin with '~', or if the user or $HOME is unknown,
|
||||
# the path is returned unchanged (leaving error reporting to whatever
|
||||
# function is called with the expanded path as argument).
|
||||
# See also module 'glob' for expansion of *, ? and [...] in pathnames.
|
||||
# (A function should also be defined to do full *sh-style environment
|
||||
# variable expansion.)
|
||||
|
||||
def expanduser(path):
|
||||
"""Expand ~ and ~user constructions. If user or $HOME is unknown,
|
||||
do nothing."""
|
||||
if not path.startswith('~'):
|
||||
return path
|
||||
i = path.find('/', 1)
|
||||
if i < 0:
|
||||
i = len(path)
|
||||
if i == 1:
|
||||
if 'HOME' not in os.environ:
|
||||
import pwd
|
||||
userhome = pwd.getpwuid(os.getuid()).pw_dir
|
||||
else:
|
||||
userhome = os.environ['HOME']
|
||||
else:
|
||||
import pwd
|
||||
try:
|
||||
pwent = pwd.getpwnam(path[1:i])
|
||||
except KeyError:
|
||||
return path
|
||||
userhome = pwent.pw_dir
|
||||
userhome = userhome.rstrip('/')
|
||||
return userhome + path[i:]
|
||||
|
||||
|
||||
# Expand paths containing shell variable substitutions.
|
||||
# This expands the forms $variable and ${variable} only.
|
||||
# Non-existent variables are left unchanged.
|
||||
|
||||
_varprog = None
|
||||
|
||||
def expandvars(path):
|
||||
"""Expand shell variables of form $var and ${var}. Unknown variables
|
||||
are left unchanged."""
|
||||
global _varprog
|
||||
if '$' not in path:
|
||||
return path
|
||||
if not _varprog:
|
||||
import re
|
||||
_varprog = re.compile(r'\$(\w+|\{[^}]*\})')
|
||||
i = 0
|
||||
while True:
|
||||
m = _varprog.search(path, i)
|
||||
if not m:
|
||||
break
|
||||
i, j = m.span(0)
|
||||
name = m.group(1)
|
||||
if name.startswith('{') and name.endswith('}'):
|
||||
name = name[1:-1]
|
||||
if name in os.environ:
|
||||
tail = path[j:]
|
||||
path = path[:i] + os.environ[name]
|
||||
i = len(path)
|
||||
path += tail
|
||||
else:
|
||||
i = j
|
||||
return path
|
||||
|
||||
|
||||
# Normalize a path, e.g. A//B, A/./B and A/foo/../B all become A/B.
|
||||
# It should be understood that this may change the meaning of the path
|
||||
# if it contains symbolic links!
|
||||
|
||||
def normpath(path):
|
||||
"""Normalize path, eliminating double slashes, etc."""
|
||||
if path == '':
|
||||
return '.'
|
||||
initial_slashes = path.startswith('/')
|
||||
# POSIX allows one or two initial slashes, but treats three or more
|
||||
# as single slash.
|
||||
if (initial_slashes and
|
||||
path.startswith('//') and not path.startswith('///')):
|
||||
initial_slashes = 2
|
||||
comps = path.split('/')
|
||||
new_comps = []
|
||||
for comp in comps:
|
||||
if comp in ('', '.'):
|
||||
continue
|
||||
if (comp != '..' or (not initial_slashes and not new_comps) or
|
||||
(new_comps and new_comps[-1] == '..')):
|
||||
new_comps.append(comp)
|
||||
elif new_comps:
|
||||
new_comps.pop()
|
||||
comps = new_comps
|
||||
path = '/'.join(comps)
|
||||
if initial_slashes:
|
||||
path = '/'*initial_slashes + path
|
||||
return path or '.'
|
||||
|
||||
|
||||
def abspath(path):
|
||||
"""Return an absolute path."""
|
||||
if not isabs(path):
|
||||
path = join(os.getcwd(), path)
|
||||
return normpath(path)
|
||||
|
||||
|
||||
# Return a canonical path (i.e. the absolute location of a file on the
|
||||
# filesystem).
|
||||
|
||||
def realpath(filename):
|
||||
"""Return the canonical path of the specified filename, eliminating any
|
||||
symbolic links encountered in the path."""
|
||||
if isabs(filename):
|
||||
bits = ['/'] + filename.split('/')[1:]
|
||||
else:
|
||||
bits = [''] + filename.split('/')
|
||||
|
||||
for i in range(2, len(bits)+1):
|
||||
component = join(*bits[0:i])
|
||||
# Resolve symbolic links.
|
||||
if islink(component):
|
||||
resolved = _resolve_link(component)
|
||||
if resolved is None:
|
||||
# Infinite loop -- return original component + rest of the path
|
||||
return abspath(join(*([component] + bits[i:])))
|
||||
else:
|
||||
newpath = join(*([resolved] + bits[i:]))
|
||||
return realpath(newpath)
|
||||
|
||||
return abspath(filename)
|
||||
|
||||
|
||||
def _resolve_link(path):
|
||||
"""Internal helper function. Takes a path and follows symlinks
|
||||
until we either arrive at something that isn't a symlink, or
|
||||
encounter a path we've seen before (meaning that there's a loop).
|
||||
"""
|
||||
paths_seen = []
|
||||
while islink(path):
|
||||
if path in paths_seen:
|
||||
# Already seen this path, so we must have a symlink loop
|
||||
return None
|
||||
paths_seen.append(path)
|
||||
# Resolve where the link points to
|
||||
resolved = os.readlink(path)
|
||||
if not isabs(resolved):
|
||||
dir = dirname(path)
|
||||
path = normpath(join(dir, resolved))
|
||||
else:
|
||||
path = normpath(resolved)
|
||||
return path
|
||||
|
||||
supports_unicode_filenames = False
|
||||
@@ -0,0 +1,312 @@
|
||||
init python:
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
ZWSP = u"\u200B"
|
||||
|
||||
# The process of the running game.
|
||||
game_proc = None
|
||||
|
||||
class ProcessBehavior(renpy.display.layout.Null):
|
||||
|
||||
def __init__(self, proc):
|
||||
super(ProcessBehavior, self).__init__()
|
||||
|
||||
self.proc = proc
|
||||
|
||||
def event(self, ev, x, y, st):
|
||||
|
||||
if self.proc.poll() is not None:
|
||||
return True
|
||||
|
||||
renpy.game.interface.timeout(.25)
|
||||
|
||||
def quote_char(c):
|
||||
n = ord(c)
|
||||
if 0x20 <= n <= 0x7f:
|
||||
return c
|
||||
else:
|
||||
return "\\x%02x" % n
|
||||
|
||||
# Quotes an arbitrary string (without knowing the encoding) for display.
|
||||
def quote(s):
|
||||
s ="".join(quote_char(i) for i in s)
|
||||
s = s.replace("/", "/" + ZWSP)
|
||||
s = s.replace("\\", "\\" + ZWSP)
|
||||
return s
|
||||
|
||||
class Project(object):
|
||||
|
||||
def __init__(self, path):
|
||||
# The name of the project.
|
||||
self.name = os.path.basename(path)
|
||||
|
||||
# The full path to the project.
|
||||
self.path = path
|
||||
|
||||
# The path to the game directory, for convenience.
|
||||
self.gamedir = os.path.join(path, "game")
|
||||
|
||||
def __repr__(self):
|
||||
return "<Project %r>" % (self.path)
|
||||
|
||||
def select(self):
|
||||
"""
|
||||
Select this project as the one that we're working on.
|
||||
"""
|
||||
|
||||
global project
|
||||
global game_proc
|
||||
|
||||
persistent.project_path = self.path
|
||||
project = self
|
||||
game_proc = None
|
||||
|
||||
# Load the informatrion dictionary.
|
||||
info = dict()
|
||||
launcherinfo = os.path.join(self.path, "launcherinfo.py")
|
||||
|
||||
if os.path.exists(launcherinfo):
|
||||
source = file(launcherinfo, "rU").read().decode("utf8")
|
||||
if source[0] == u'\ufeff':
|
||||
source = source[1:]
|
||||
source = source.encode("raw_unicode_escape")
|
||||
|
||||
exec source in info
|
||||
|
||||
del info["__builtins__"]
|
||||
|
||||
self.info = info
|
||||
|
||||
def save(self):
|
||||
"""
|
||||
Saves the info dictionary into the launcherinfo file.
|
||||
"""
|
||||
|
||||
launcherinfo = os.path.join(self.path, "launcherinfo.py")
|
||||
|
||||
f = file(launcherinfo + ".new", "w")
|
||||
for k, v in self.info.iteritems():
|
||||
f.write("%s = %r\n" % (k, v))
|
||||
f.close()
|
||||
|
||||
try:
|
||||
os.rename(launcherinfo + ".new", launcherinfo)
|
||||
except:
|
||||
os.unlink(launcherinfo)
|
||||
os.rename(launcherinfo + ".new", launcherinfo)
|
||||
|
||||
|
||||
|
||||
def scan_projects():
|
||||
"""
|
||||
Scans for projects. Returns a list of Project objects.
|
||||
"""
|
||||
|
||||
rv = [ ]
|
||||
|
||||
project_dirs = [ config.renpy_base ]
|
||||
|
||||
if persistent.projects_directory:
|
||||
project_dirs.append(persistent.projects_directory)
|
||||
|
||||
for d in project_dirs:
|
||||
|
||||
if not os.path.isdir(d):
|
||||
continue
|
||||
|
||||
for pd in sorted(os.listdir(d), key=lambda a : a.lower()):
|
||||
path = os.path.join(d, pd)
|
||||
|
||||
if not os.path.isdir(path):
|
||||
continue
|
||||
|
||||
gamedir = os.path.join(path, "game")
|
||||
|
||||
if not os.path.isdir(gamedir):
|
||||
continue
|
||||
|
||||
rv.append(Project(path))
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
def choose_default_project():
|
||||
"""
|
||||
Chooses the default project, based on the persistent information.
|
||||
"""
|
||||
|
||||
project = None
|
||||
projects = scan_projects()
|
||||
|
||||
for i in projects:
|
||||
if i.path == persistent.project_path:
|
||||
i.select()
|
||||
return
|
||||
|
||||
for i in projects:
|
||||
if i.name == "demo":
|
||||
i.select()
|
||||
return
|
||||
|
||||
if projects:
|
||||
projects[0].select()
|
||||
return
|
||||
|
||||
|
||||
def select_project(p):
|
||||
p.select()
|
||||
renpy.jump("top")
|
||||
|
||||
curried_select_project = renpy.curry(select_project)
|
||||
|
||||
label select_project:
|
||||
|
||||
if persistent.projects_directory is None:
|
||||
call choose_projects_directory
|
||||
|
||||
python:
|
||||
|
||||
screen()
|
||||
|
||||
ui.vbox()
|
||||
|
||||
title(_(u"Select Project"))
|
||||
scrolled("top")
|
||||
|
||||
ui.vbox()
|
||||
|
||||
projects = scan_projects()
|
||||
|
||||
for i in projects:
|
||||
|
||||
button(i.name,
|
||||
curried_select_project(i),
|
||||
quote(i.path))
|
||||
|
||||
ui.close() # vbox
|
||||
ui.close() # scrolled
|
||||
ui.close() # vbox
|
||||
|
||||
interact()
|
||||
|
||||
label launch:
|
||||
|
||||
python hide:
|
||||
|
||||
if sys.platform == "win32" and sys.argv[0].lower().endswith(".exe"):
|
||||
proc = subprocess.Popen([sys.argv[0], project.path])
|
||||
else:
|
||||
proc = subprocess.Popen([sys.executable, sys.argv[0], project.path])
|
||||
|
||||
set_tooltip(_(u"%s has been launched.") % project.name.capitalize())
|
||||
|
||||
store.game_proc = proc
|
||||
|
||||
jump top
|
||||
|
||||
|
||||
label game_directory:
|
||||
|
||||
python hide:
|
||||
gamedir = os.path.normpath(project.gamedir)
|
||||
|
||||
if sys.platform == "win32":
|
||||
os.startfile(gamedir)
|
||||
elif platform.mac_ver()[0]:
|
||||
subprocess.Popen([ "open", gamedir ])
|
||||
else:
|
||||
subprocess.Popen([ "xdg-open", gamedir ])
|
||||
|
||||
gamedir = quote(gamedir)
|
||||
set_tooltip(_(u"Opening game directory:\n%s") % gamedir)
|
||||
|
||||
jump top
|
||||
|
||||
|
||||
label edit_script:
|
||||
|
||||
python hide:
|
||||
|
||||
if not config.editor:
|
||||
error(_(u"No editor has been selected."))
|
||||
|
||||
files = [ project.gamedir + "/" + i for i in os.listdir(project.gamedir) if i.endswith(".rpy") if not i[0] == "."]
|
||||
files.sort()
|
||||
|
||||
for i in files[:]:
|
||||
if i.endswith("options.rpy"):
|
||||
files.remove(i)
|
||||
files.insert(0, i)
|
||||
|
||||
for i in files[:]:
|
||||
if i.endswith("script.rpy"):
|
||||
files.remove(i)
|
||||
files.insert(0, i)
|
||||
|
||||
if not files:
|
||||
error(_(u"No files to edit."))
|
||||
|
||||
if not renpy.launch_editor(files):
|
||||
error(_(u"Launching the editor failed."))
|
||||
|
||||
set_tooltip(_(u"Launched editor with %d script files.") % len(files))
|
||||
|
||||
jump top
|
||||
|
||||
|
||||
label lint:
|
||||
|
||||
python hide:
|
||||
|
||||
set_tooltip("")
|
||||
|
||||
info(_(u"Lint"), _(u"Lint in progress."))
|
||||
|
||||
lf = file("lint.txt", "w+")
|
||||
|
||||
if hasattr(sys, "winver") and sys.argv[0].lower().endswith(".exe"):
|
||||
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)
|
||||
|
||||
proc.wait()
|
||||
|
||||
lf.close()
|
||||
|
||||
renpy.launch_editor([ "lint.txt" ], transient=1)
|
||||
|
||||
return
|
||||
|
||||
|
||||
label call_lint:
|
||||
call lint
|
||||
|
||||
python:
|
||||
set_tooltip(_(u"Lint complete."))
|
||||
|
||||
jump top
|
||||
|
||||
|
||||
label delete_persistent:
|
||||
|
||||
python hide:
|
||||
set_tooltip("")
|
||||
|
||||
info(_(u"Delete Persistent"), _(u"Deleting persistent data."))
|
||||
|
||||
if hasattr(sys, "winver") and sys.argv[0].lower().endswith(".exe"):
|
||||
proc = subprocess.Popen([config.renpy_base + "/console.exe", "--rmpersistent", project.path])
|
||||
else:
|
||||
proc = subprocess.Popen([sys.executable, sys.argv[0], "--rmpersistent", project.path])
|
||||
|
||||
proc.wait()
|
||||
|
||||
set_tooltip(_(u"Persistent data has been deleted."))
|
||||
|
||||
jump top
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
init python:
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
try:
|
||||
import EasyDialogs
|
||||
except ImportError:
|
||||
try:
|
||||
import EasyDialogsWin as EasyDialogs
|
||||
except:
|
||||
EasyDialogs = None
|
||||
|
||||
|
||||
label choose_projects_directory:
|
||||
|
||||
python hide:
|
||||
|
||||
set_tooltip("")
|
||||
|
||||
info(_(u"Choose Projects Directory"),
|
||||
_(u"Please choose the directory containing your projects."))
|
||||
|
||||
|
||||
path = persistent.projects_directory
|
||||
|
||||
if path is None:
|
||||
path = os.path.dirname(config.renpy_base)
|
||||
|
||||
|
||||
if EasyDialogs:
|
||||
|
||||
choice = EasyDialogs.AskFolder(defaultLocation=path, wanted=str)
|
||||
if choice is not None:
|
||||
path = choice
|
||||
|
||||
else:
|
||||
|
||||
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 ],
|
||||
env=env, stdout=subprocess.PIPE)
|
||||
|
||||
choice = zen.stdout.read()
|
||||
zen.wait()
|
||||
|
||||
if choice:
|
||||
path = choice[:-1]
|
||||
|
||||
except:
|
||||
error(_(u"Could not run zenity. The projects directory has been set to the directory immediately above the directory containing Ren'Py."), None)
|
||||
|
||||
persistent.projects_directory = path
|
||||
choose_default_project()
|
||||
|
||||
return
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
label main_menu:
|
||||
return
|
||||
|
||||
label start:
|
||||
python:
|
||||
choose_default_project()
|
||||
scan_editors()
|
||||
setup_editor()
|
||||
|
||||
jump top
|
||||
|
||||
label top:
|
||||
python:
|
||||
|
||||
if game_proc and game_proc.poll() is None:
|
||||
launch = None
|
||||
ui.add(ProcessBehavior(game_proc))
|
||||
else:
|
||||
launch = ui.jumps("launch")
|
||||
game_proc = None
|
||||
|
||||
screen()
|
||||
|
||||
ui.vbox()
|
||||
ui.viewport(draggable=True, ymaximum=47)
|
||||
title(project.name.capitalize())
|
||||
|
||||
ui.grid(2, 4, transpose=True)
|
||||
|
||||
button(_(u"Launch"),
|
||||
launch,
|
||||
_(u"Launches the project."))
|
||||
|
||||
button(_(u"Edit Script"),
|
||||
ui.jumps("edit_script"),
|
||||
_(u"Edits the script of the project."))
|
||||
|
||||
button(_(u"Game Directory"),
|
||||
ui.jumps("game_directory"),
|
||||
_(u"Opens the project's game directory."))
|
||||
|
||||
button(_(u"Check Script (Lint)"),
|
||||
ui.jumps("call_lint"),
|
||||
_(u"Checks the script of the project for likely errors."))
|
||||
|
||||
|
||||
button(_(u"Choose Theme"),
|
||||
ui.jumps("choose_theme"),
|
||||
_(u"Changes the theme used by the project."))
|
||||
|
||||
button(_(u"Delete Persistent"),
|
||||
ui.jumps("delete_persistent"),
|
||||
_(u"Deletes the persistent data associated with the project."))
|
||||
|
||||
button(_(u"Archive Files"),
|
||||
ui.jumps("archiver"),
|
||||
_(u"Archives files found in the game and archived directories."))
|
||||
|
||||
button(_(u"Build Distributions"),
|
||||
ui.jumps("distribute"),
|
||||
_(u"Builds distributions of the project."))
|
||||
|
||||
ui.close()
|
||||
|
||||
title(_(u"Ren'Py"))
|
||||
|
||||
ui.grid(2, 3, transpose=True)
|
||||
|
||||
button(_(u"Select Project"),
|
||||
ui.jumps("select_project"),
|
||||
_(u"Select a project to work with."))
|
||||
|
||||
button(_(u"New Project"),
|
||||
ui.jumps("new_project"),
|
||||
_(u"Create a new project."))
|
||||
|
||||
button(_(u"Quit"),
|
||||
renpy.quit,
|
||||
_(u"Causes the launcher to exit."))
|
||||
|
||||
button(_(u"Options"),
|
||||
ui.jumps("options"),
|
||||
_(u"Change Ren'Py launcher options."))
|
||||
|
||||
button(_(u"Ren'Py Help"),
|
||||
ui.jumps("documentation"),
|
||||
_(u"Open the Ren'Py documentation in a web browser."))
|
||||
|
||||
ui.null()
|
||||
|
||||
ui.close()
|
||||
ui.close()
|
||||
|
||||
interact()
|
||||
|
||||
# ProcessBehavior can return True, which sends us here.
|
||||
jump top
|
||||
|
||||
|
||||
label documentation:
|
||||
|
||||
python hide:
|
||||
import webbrowser
|
||||
webbrowser.open_new("file:///" + config.renpy_base + "/doc/index.html")
|
||||
set_tooltip(_(u"Now showing the Ren'Py documentation in your web browser."))
|
||||
|
||||
jump top
|
||||
|
||||
|
||||
label confirm_quit:
|
||||
$ renpy.quit()
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
init -999:
|
||||
$ config.script_version = (6, 8, 0)
|
||||
$ config.script_version = (6, 9, 3)
|
||||
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
init python:
|
||||
LAUNCHER_RPYS = set(['options.rpy', 'strings.rpy', 'transupdate.rpy', 'choose_theme.rpy', 'archiver.rpy', 'project.rpy', 'script_version.rpy', 'new.rpy', 'themes_data.rpy', 'opts.rpy', 'interface.rpy', 'projectsdir.rpy', 'distribute.rpy', 'script.rpy', 'editor.rpy'])
|
||||
|
||||
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"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"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"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"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"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"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"Ren'Py",
|
||||
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.",
|
||||
]
|
||||
|
||||
@@ -1,244 +1,305 @@
|
||||
init 1 python:
|
||||
theme_data = {'Basic Blue': {'disabled': '#404040',
|
||||
'disabled_text': '#c8c8c8',
|
||||
'frame': '#6496c8',
|
||||
'gm_root': '#dcebff',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#dcebff',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#003c78',
|
||||
'widget_hover': '#0050a0',
|
||||
'widget_selected': '#ffffc8',
|
||||
'widget_text': '#c8ffff'},
|
||||
'Bloody Mary': {'disabled': '#400000',
|
||||
'disabled_text': '#260000',
|
||||
'frame': '#400808',
|
||||
'gm_root': '#000000',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#000000',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#000000',
|
||||
'widget_hover': '#830000',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#C2C2C2'},
|
||||
'Colorblind': {'disabled': '#898989',
|
||||
'disabled_text': '#666666',
|
||||
'frame': '#252525',
|
||||
'gm_root': '#393939',
|
||||
'label': '#c2c2c2',
|
||||
'mm_root': '#393939',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#898989',
|
||||
'widget_hover': '#464646',
|
||||
'widget_selected': '#F2F2F2',
|
||||
'widget_text': '#CCCCCC'},
|
||||
'Cotton Candy': {'disabled': '#C8AFA1',
|
||||
'disabled_text': '#E1D4C9',
|
||||
'frame': '#FCF5F2',
|
||||
'gm_root': '#D0B4BA',
|
||||
'label': '#805C40',
|
||||
'mm_root': '#D0B4BA',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#ECC7D0',
|
||||
'widget_hover': '#E1D4C9',
|
||||
'widget_selected': '#805C40',
|
||||
'widget_text': '#805C40'},
|
||||
'Creamsicle': {'disabled': '#FFECBF',
|
||||
'disabled_text': '#ffffff',
|
||||
'frame': '#FFECBF',
|
||||
'gm_root': '#FDF5E3',
|
||||
'label': '#502F13',
|
||||
'mm_root': '#FDF5E3',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#D96B00',
|
||||
'widget_hover': '#FD9B1C',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#FCE6B1'},
|
||||
'Dramatic Flesh': {'disabled': '#ab6038',
|
||||
'disabled_text': '#BF7C51',
|
||||
'frame': '#49271b',
|
||||
'gm_root': '#2a201f',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#2a201f',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#BF7C51',
|
||||
'widget_hover': '#dda570',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#E5DFDF'},
|
||||
'Easter Baby': {'disabled': '#DDE9FF',
|
||||
'disabled_text': '#A6AFBF',
|
||||
'frame': '#CCF8DC',
|
||||
'gm_root': '#FBF9DF',
|
||||
'label': '#698071',
|
||||
'mm_root': '#FBF9DF',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#F5D4EE',
|
||||
'widget_hover': '#F0DDFF',
|
||||
'widget_selected': '#000000',
|
||||
'widget_text': '#698071'},
|
||||
'Favorite Jeans': {'disabled': '#919994',
|
||||
'disabled_text': '#B6BFB9',
|
||||
'frame': '#6f7571',
|
||||
'gm_root': '#b0b8ba',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#b0b8ba',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#8699a7',
|
||||
'widget_hover': '#9eb1ad',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#dcdfd6'},
|
||||
'Fine China': {'disabled': '#ADB9CC',
|
||||
'disabled_text': '#DFBA14',
|
||||
'frame': '#ADB9CC',
|
||||
'gm_root': '#F7F7FA',
|
||||
'label': '#39435E',
|
||||
'mm_root': '#F7F7FA',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#6A7183',
|
||||
'widget_hover': '#1A2B47',
|
||||
'widget_selected': '#E3E3E4',
|
||||
'widget_text': '#C9C9CB'},
|
||||
'First Valentines': {'disabled': '#F8F2D0',
|
||||
'disabled_text': '#BFA1A1',
|
||||
'frame': '#F8F2D0',
|
||||
'gm_root': '#D98989',
|
||||
'label': '#5D1010',
|
||||
'mm_root': '#D98989',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#F09898',
|
||||
'widget_hover': '#D6C5BB',
|
||||
'widget_selected': '#B31E1E',
|
||||
'widget_text': '#593131'},
|
||||
'Ice Queen': {'disabled': '#F0F2F2',
|
||||
'disabled_text': '#FBFBFB',
|
||||
'frame': '#ffffff',
|
||||
'gm_root': '#E6E6E6',
|
||||
'label': '#D9D9D9',
|
||||
'mm_root': '#E6E6E6',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#D9D9D9',
|
||||
'widget_hover': '#F0F2F2',
|
||||
'widget_selected': '#737373',
|
||||
'widget_text': '#ffffff'},
|
||||
'Mocha Latte': {'disabled': '#614D3A',
|
||||
'disabled_text': '#80654D',
|
||||
'frame': '#926841',
|
||||
'gm_root': '#1A140E',
|
||||
'label': '#F1EBE5',
|
||||
'mm_root': '#1A140E',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#4D3B29',
|
||||
'widget_hover': '#996E45',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#B99D83'},
|
||||
'Muted Horror': {'disabled': '#73735C',
|
||||
'disabled_text': '#8C8C70',
|
||||
'frame': '#555544',
|
||||
'gm_root': '#1A0001',
|
||||
'label': '#1A0001',
|
||||
'mm_root': '#1A0001',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#777777',
|
||||
'widget_hover': '#73735C',
|
||||
'widget_selected': '#000000',
|
||||
'widget_text': '#404033'},
|
||||
'Old Polaroid': {'disabled': '#A89E7D',
|
||||
'disabled_text': '#CCC097',
|
||||
'frame': '#49403E',
|
||||
'gm_root': '#A84A3E',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#A84A3E',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#A89E7D',
|
||||
'widget_hover': '#8DB6B9',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#49403E'},
|
||||
'Really Red': {'disabled': '#404040',
|
||||
'disabled_text': '#c8c8c8',
|
||||
'frame': '#e17373',
|
||||
'gm_root': '#ffd0d0',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#ffd0d0',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#963232',
|
||||
'widget_hover': '#c83232',
|
||||
'widget_selected': '#ffffc8',
|
||||
'widget_text': '#ffffff'},
|
||||
'Summer Sky': {'disabled': '#6074BF',
|
||||
'disabled_text': '#7383BF',
|
||||
'frame': '#6074BF',
|
||||
'gm_root': '#B4CDD4',
|
||||
'label': '#94C7D4',
|
||||
'mm_root': '#B4CDD4',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#F2E6AA',
|
||||
'widget_hover': '#FCFCA4',
|
||||
'widget_selected': '#1A5766',
|
||||
'widget_text': '#7DA8B3'},
|
||||
'Swamp Critter': {'disabled': '#A2521D',
|
||||
'disabled_text': '#753D00',
|
||||
'frame': '#797C1C',
|
||||
'gm_root': '#B09D5A',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#B09B4F',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#753D00',
|
||||
'widget_hover': '#B19A48',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#CCCAC2'},
|
||||
'Urban Sprawl': {'disabled': '#8F0000',
|
||||
'disabled_text': '#333333',
|
||||
'frame': '#8F0000',
|
||||
'gm_root': '#000000',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#000000',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#333333',
|
||||
'widget_hover': '#000000',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#6C8A2F'},
|
||||
'Victorian Gingerbread': {'disabled': '#7A674F',
|
||||
'disabled_text': '#664F33',
|
||||
'frame': '#BF8A73',
|
||||
'gm_root': '#695640',
|
||||
'label': '#F2EDC4',
|
||||
'mm_root': '#695640',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#7A674F',
|
||||
'widget_hover': '#BDA77D',
|
||||
'widget_selected': '#FDFBEE',
|
||||
'widget_text': '#F2EDC4'},
|
||||
'Watermelon Pie': {'disabled': '#FABF46',
|
||||
'disabled_text': '#FFE06D',
|
||||
'frame': '#C3CD91',
|
||||
'gm_root': '#F7F7C5',
|
||||
'label': '#FCFCD7',
|
||||
'mm_root': '#F7F7C5',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#FFE06D',
|
||||
'widget_hover': '#E38A4F',
|
||||
'widget_selected': '#996600',
|
||||
'widget_text': '#FAA700'},
|
||||
'White Chocolate': {'disabled': '#614D3A',
|
||||
'disabled_text': '#80654D',
|
||||
'frame': '#926841',
|
||||
'gm_root': '#FBF9EA',
|
||||
'label': '#F1EBE5',
|
||||
'mm_root': '#FBF9EA',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#33271C',
|
||||
'widget_hover': '#ECE7C4',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#B99D83'},
|
||||
'Winter Mint': {'disabled': '#426143',
|
||||
'disabled_text': '#819981',
|
||||
'frame': '#245536',
|
||||
'gm_root': '#e5f1e5',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#e5f1e5',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#7AA27B',
|
||||
'widget_hover': '#A3C7A3',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#CDE0CE'}}
|
||||
|
||||
# This is a list of (theme name, theme function, theme exemplar) tuples.
|
||||
themes = [
|
||||
("Roundrect", "roundrect", "Basic Blue"),
|
||||
]
|
||||
|
||||
# This is a map from theme function to template text that sensibly calls
|
||||
# that function.
|
||||
theme_templates = { }
|
||||
|
||||
theme_templates["roundrect"] = """\
|
||||
theme.roundrect(
|
||||
# Color scheme: %(name)s
|
||||
|
||||
## The color of an idle widget face.
|
||||
widget = "%(widget)s",
|
||||
|
||||
## The color of a focused widget face.
|
||||
widget_hover = "%(widget_hover)s",
|
||||
|
||||
## The color of the text in a widget.
|
||||
widget_text = "%(widget_text)s",
|
||||
|
||||
## The color of the text in a selected widget. (For
|
||||
## example, the current value of a preference.)
|
||||
widget_selected = "%(widget_selected)s",
|
||||
|
||||
## The color of a disabled widget face.
|
||||
disabled = "%(disabled)s",
|
||||
|
||||
## The color of disabled widget text.
|
||||
disabled_text = "%(disabled_text)s",
|
||||
|
||||
## The color of informational labels.
|
||||
label = "%(label)s",
|
||||
|
||||
## The color of a frame containing widgets.
|
||||
frame = "%(frame)s",
|
||||
|
||||
## The background of the main menu. This can be a color
|
||||
## beginning with '#', or an image filename. The latter
|
||||
## should take up the full height and width of the screen.
|
||||
mm_root = "%(mm_root)s",
|
||||
|
||||
## The background of the game menu. This can be a color
|
||||
## beginning with '#', or an image filename. The latter
|
||||
## should take up the full height and width of the screen.
|
||||
gm_root = "%(gm_root)s",
|
||||
|
||||
## If this is True, the in-game window is rounded. If False,
|
||||
## the in-game window is square.
|
||||
rounded_window = False,
|
||||
|
||||
## And we're done with the theme. The theme will customize
|
||||
## various styles, so if we want to change them, we should
|
||||
## do so below.
|
||||
)"""
|
||||
|
||||
# This is a map from theme name to the code needed to implement that
|
||||
# theme.
|
||||
theme_data = {
|
||||
'Basic Blue': {'disabled': '#404040',
|
||||
'disabled_text': '#c8c8c8',
|
||||
'frame': '#6496c8',
|
||||
'gm_root': '#dcebff',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#dcebff',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#003c78',
|
||||
'widget_hover': '#0050a0',
|
||||
'widget_selected': '#ffffc8',
|
||||
'widget_text': '#c8ffff'},
|
||||
'Bloody Mary': {'disabled': '#400000',
|
||||
'disabled_text': '#260000',
|
||||
'frame': '#400808',
|
||||
'gm_root': '#000000',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#000000',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#000000',
|
||||
'widget_hover': '#830000',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#C2C2C2'},
|
||||
'Colorblind': {'disabled': '#898989',
|
||||
'disabled_text': '#666666',
|
||||
'frame': '#252525',
|
||||
'gm_root': '#393939',
|
||||
'label': '#c2c2c2',
|
||||
'mm_root': '#393939',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#898989',
|
||||
'widget_hover': '#464646',
|
||||
'widget_selected': '#F2F2F2',
|
||||
'widget_text': '#CCCCCC'},
|
||||
'Cotton Candy': {'disabled': '#C8AFA1',
|
||||
'disabled_text': '#E1D4C9',
|
||||
'frame': '#FCF5F2',
|
||||
'gm_root': '#D0B4BA',
|
||||
'label': '#805C40',
|
||||
'mm_root': '#D0B4BA',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#ECC7D0',
|
||||
'widget_hover': '#E1D4C9',
|
||||
'widget_selected': '#805C40',
|
||||
'widget_text': '#805C40'},
|
||||
'Creamsicle': {'disabled': '#FFECBF',
|
||||
'disabled_text': '#ffffff',
|
||||
'frame': '#FFECBF',
|
||||
'gm_root': '#FDF5E3',
|
||||
'label': '#502F13',
|
||||
'mm_root': '#FDF5E3',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#D96B00',
|
||||
'widget_hover': '#FD9B1C',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#FCE6B1'},
|
||||
'Dramatic Flesh': {'disabled': '#ab6038',
|
||||
'disabled_text': '#BF7C51',
|
||||
'frame': '#49271b',
|
||||
'gm_root': '#2a201f',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#2a201f',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#BF7C51',
|
||||
'widget_hover': '#dda570',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#E5DFDF'},
|
||||
'Easter Baby': {'disabled': '#DDE9FF',
|
||||
'disabled_text': '#A6AFBF',
|
||||
'frame': '#CCF8DC',
|
||||
'gm_root': '#FBF9DF',
|
||||
'label': '#698071',
|
||||
'mm_root': '#FBF9DF',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#F5D4EE',
|
||||
'widget_hover': '#F0DDFF',
|
||||
'widget_selected': '#000000',
|
||||
'widget_text': '#698071'},
|
||||
'Favorite Jeans': {'disabled': '#919994',
|
||||
'disabled_text': '#B6BFB9',
|
||||
'frame': '#6f7571',
|
||||
'gm_root': '#b0b8ba',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#b0b8ba',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#8699a7',
|
||||
'widget_hover': '#9eb1ad',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#dcdfd6'},
|
||||
'Fine China': {'disabled': '#ADB9CC',
|
||||
'disabled_text': '#DFBA14',
|
||||
'frame': '#ADB9CC',
|
||||
'gm_root': '#F7F7FA',
|
||||
'label': '#39435E',
|
||||
'mm_root': '#F7F7FA',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#6A7183',
|
||||
'widget_hover': '#1A2B47',
|
||||
'widget_selected': '#E3E3E4',
|
||||
'widget_text': '#C9C9CB'},
|
||||
'First Valentines': {'disabled': '#F8F2D0',
|
||||
'disabled_text': '#BFA1A1',
|
||||
'frame': '#F8F2D0',
|
||||
'gm_root': '#D98989',
|
||||
'label': '#5D1010',
|
||||
'mm_root': '#D98989',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#F09898',
|
||||
'widget_hover': '#D6C5BB',
|
||||
'widget_selected': '#B31E1E',
|
||||
'widget_text': '#593131'},
|
||||
'Ice Queen': {'disabled': '#F0F2F2',
|
||||
'disabled_text': '#FBFBFB',
|
||||
'frame': '#ffffff',
|
||||
'gm_root': '#E6E6E6',
|
||||
'label': '#D9D9D9',
|
||||
'mm_root': '#E6E6E6',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#D9D9D9',
|
||||
'widget_hover': '#F0F2F2',
|
||||
'widget_selected': '#737373',
|
||||
'widget_text': '#ffffff'},
|
||||
'Mocha Latte': {'disabled': '#614D3A',
|
||||
'disabled_text': '#80654D',
|
||||
'frame': '#926841',
|
||||
'gm_root': '#1A140E',
|
||||
'label': '#F1EBE5',
|
||||
'mm_root': '#1A140E',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#4D3B29',
|
||||
'widget_hover': '#996E45',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#B99D83'},
|
||||
'Muted Horror': {'disabled': '#73735C',
|
||||
'disabled_text': '#8C8C70',
|
||||
'frame': '#555544',
|
||||
'gm_root': '#1A0001',
|
||||
'label': '#1A0001',
|
||||
'mm_root': '#1A0001',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#777777',
|
||||
'widget_hover': '#73735C',
|
||||
'widget_selected': '#000000',
|
||||
'widget_text': '#404033'},
|
||||
'Old Polaroid': {'disabled': '#A89E7D',
|
||||
'disabled_text': '#CCC097',
|
||||
'frame': '#49403E',
|
||||
'gm_root': '#A84A3E',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#A84A3E',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#A89E7D',
|
||||
'widget_hover': '#8DB6B9',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#49403E'},
|
||||
'Really Red': {'disabled': '#404040',
|
||||
'disabled_text': '#c8c8c8',
|
||||
'frame': '#e17373',
|
||||
'gm_root': '#ffd0d0',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#ffd0d0',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#963232',
|
||||
'widget_hover': '#c83232',
|
||||
'widget_selected': '#ffffc8',
|
||||
'widget_text': '#ffffff'},
|
||||
'Summer Sky': {'disabled': '#6074BF',
|
||||
'disabled_text': '#7383BF',
|
||||
'frame': '#6074BF',
|
||||
'gm_root': '#B4CDD4',
|
||||
'label': '#94C7D4',
|
||||
'mm_root': '#B4CDD4',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#F2E6AA',
|
||||
'widget_hover': '#FCFCA4',
|
||||
'widget_selected': '#1A5766',
|
||||
'widget_text': '#7DA8B3'},
|
||||
'Swamp Critter': {'disabled': '#A2521D',
|
||||
'disabled_text': '#753D00',
|
||||
'frame': '#797C1C',
|
||||
'gm_root': '#B09D5A',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#B09B4F',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#753D00',
|
||||
'widget_hover': '#B19A48',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#CCCAC2'},
|
||||
'Urban Sprawl': {'disabled': '#8F0000',
|
||||
'disabled_text': '#333333',
|
||||
'frame': '#8F0000',
|
||||
'gm_root': '#000000',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#000000',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#333333',
|
||||
'widget_hover': '#000000',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#6C8A2F'},
|
||||
'Victorian Gingerbread': {'disabled': '#7A674F',
|
||||
'disabled_text': '#664F33',
|
||||
'frame': '#BF8A73',
|
||||
'gm_root': '#695640',
|
||||
'label': '#F2EDC4',
|
||||
'mm_root': '#695640',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#7A674F',
|
||||
'widget_hover': '#BDA77D',
|
||||
'widget_selected': '#FDFBEE',
|
||||
'widget_text': '#F2EDC4'},
|
||||
'Watermelon Pie': {'disabled': '#FABF46',
|
||||
'disabled_text': '#FFE06D',
|
||||
'frame': '#C3CD91',
|
||||
'gm_root': '#F7F7C5',
|
||||
'label': '#FCFCD7',
|
||||
'mm_root': '#F7F7C5',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#FFE06D',
|
||||
'widget_hover': '#E38A4F',
|
||||
'widget_selected': '#996600',
|
||||
'widget_text': '#FAA700'},
|
||||
'White Chocolate': {'disabled': '#614D3A',
|
||||
'disabled_text': '#80654D',
|
||||
'frame': '#926841',
|
||||
'gm_root': '#FBF9EA',
|
||||
'label': '#F1EBE5',
|
||||
'mm_root': '#FBF9EA',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#33271C',
|
||||
'widget_hover': '#ECE7C4',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#B99D83'},
|
||||
'Winter Mint': {'disabled': '#426143',
|
||||
'disabled_text': '#819981',
|
||||
'frame': '#245536',
|
||||
'gm_root': '#e5f1e5',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#e5f1e5',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#7AA27B',
|
||||
'widget_hover': '#A3C7A3',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#CDE0CE'}}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
# This file contains code for updating translations. Basically, it will
|
||||
# search for a non-default file in launcher, and if that file exists, it
|
||||
# will append missing translations to it.
|
||||
|
||||
init python:
|
||||
import os
|
||||
import os.path
|
||||
import traceback
|
||||
import codecs
|
||||
|
||||
def update_translations():
|
||||
|
||||
# Find the first file in the launcher directory that was
|
||||
# not distributed with Ren'Py.
|
||||
for fn in sorted(os.listdir(config.gamedir)):
|
||||
if not fn.endswith(".rpy"):
|
||||
continue
|
||||
|
||||
if fn in LAUNCHER_RPYS:
|
||||
continue
|
||||
|
||||
break
|
||||
|
||||
else:
|
||||
return
|
||||
|
||||
# Find untranslated strings.
|
||||
new_translations = [ ]
|
||||
|
||||
for t in TRANSLATION_STRINGS:
|
||||
if t not in config.translations:
|
||||
new_translations.append(t)
|
||||
|
||||
if not new_translations:
|
||||
return
|
||||
|
||||
|
||||
# Add a block to the file with the untranslated strings.
|
||||
f = codecs.open(os.path.join(config.gamedir, fn), "a", "utf-8")
|
||||
|
||||
print >>f
|
||||
print >>f, "# New translations for", renpy.version()
|
||||
print >>f, "init -1 python hide:"
|
||||
print >>f, " config.translations.update({"
|
||||
|
||||
for t in new_translations:
|
||||
|
||||
print >>f
|
||||
print >>f, " %r" % t
|
||||
print >>f, " : %r," % t
|
||||
|
||||
print >>f
|
||||
print >>f, " })"
|
||||
|
||||
f.close()
|
||||
|
||||
init 100 python hide:
|
||||
|
||||
try:
|
||||
update_translations()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
@@ -0,0 +1,534 @@
|
||||
# This file contains the code needed to build a Ren'Py distribution.
|
||||
|
||||
init python:
|
||||
import zipfile
|
||||
import tarfile
|
||||
import os
|
||||
import os.path
|
||||
import time
|
||||
import sys
|
||||
import zlib
|
||||
|
||||
import pefile
|
||||
|
||||
# Returns true if a file or directory should not be included in
|
||||
# the distribution
|
||||
|
||||
ignored_files = ("thumbs.db",
|
||||
"launcherinfo.py",
|
||||
"traceback.txt",
|
||||
"errors.txt",
|
||||
"icon.ico",
|
||||
"icon.icns"
|
||||
)
|
||||
|
||||
|
||||
root_ignored_files = (
|
||||
"common",
|
||||
"renpy",
|
||||
"renpy.code",
|
||||
"python23.dll",
|
||||
"python24.dll",
|
||||
"python25.dll",
|
||||
"msvcr71.dll",
|
||||
"lib",
|
||||
"iliad-icon.png",
|
||||
"manifest.xml"
|
||||
)
|
||||
|
||||
def ignored(fn, dir, dest, root):
|
||||
if fn[0] == ".":
|
||||
return True
|
||||
|
||||
for i in store.ignore_extensions:
|
||||
if fn.endswith(i):
|
||||
return True
|
||||
|
||||
if fn.lower() in ignored_files:
|
||||
return True
|
||||
|
||||
if fn == "saves":
|
||||
return True
|
||||
|
||||
if fn == "archived":
|
||||
return True
|
||||
|
||||
if root and dir == dest:
|
||||
if fn.endswith(".py") or fn.endswith(".sh") or fn.endswith(".app"):
|
||||
return True
|
||||
|
||||
if fn in root_ignored_files:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def tree(src, dest,
|
||||
exclude_suffix=[ ".pyc", "~", ".bak" ],
|
||||
exclude_prefix=[ ".", '#' ],
|
||||
exclude=ignored_files,
|
||||
exclude_func=ignored,
|
||||
root=False,
|
||||
):
|
||||
|
||||
# Get rid of trailing slashes.
|
||||
if src[-1] == "/":
|
||||
src = src[:-1]
|
||||
|
||||
if dest and dest[-1] == "/":
|
||||
dest = dest[:-1]
|
||||
|
||||
# What should we include?
|
||||
def include(fn, destdir, dest):
|
||||
for i in exclude_suffix:
|
||||
if fn.endswith(i):
|
||||
return False
|
||||
|
||||
for i in exclude_prefix:
|
||||
if fn.startswith(i):
|
||||
return False
|
||||
|
||||
for i in exclude:
|
||||
if i == fn.lower():
|
||||
return False
|
||||
|
||||
if exclude_func and exclude_func(fn, destdir, dest, root):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
rv = [ ]
|
||||
|
||||
# Walk the tree, including what is necessary.
|
||||
for srcdir, dirs, files in os.walk(src):
|
||||
|
||||
if dest:
|
||||
destdir = dest + srcdir[len(src):]
|
||||
else:
|
||||
destdir = srcdir[len(src) + 1:]
|
||||
|
||||
if destdir:
|
||||
rv.append((srcdir, destdir))
|
||||
|
||||
for fn in files:
|
||||
|
||||
if not include(fn, destdir, dest):
|
||||
continue
|
||||
|
||||
sfn = srcdir + "/" + fn
|
||||
|
||||
if destdir:
|
||||
dfn = destdir + "/" + fn
|
||||
else:
|
||||
dfn = fn
|
||||
|
||||
dfn = dfn.replace("\\", "/")
|
||||
|
||||
rv.append((sfn, dfn))
|
||||
|
||||
dirs[:] = [ i for i in dirs if include(i, destdir, dest) ]
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
label distribute:
|
||||
|
||||
python hide:
|
||||
zlib.Z_DEFAULT_COMPRESSION = 9
|
||||
|
||||
store.progress_time = 0
|
||||
|
||||
def progress(tit, n, m, time=time):
|
||||
|
||||
if time.time() < store.progress_time + .1:
|
||||
return
|
||||
|
||||
title(tit)
|
||||
|
||||
mid(message)
|
||||
ui.bar(m, n, xmaximum=200, xalign=0.5)
|
||||
ui.close()
|
||||
|
||||
ui.pausebehavior(0)
|
||||
interact()
|
||||
|
||||
# Check to see which platforms we can build on.
|
||||
if os.path.exists(config.renpy_base + "/renpy.exe"):
|
||||
windows = True
|
||||
else:
|
||||
windows = False
|
||||
|
||||
if os.path.exists(config.renpy_base + "/lib/linux-x86"):
|
||||
linux = True
|
||||
else:
|
||||
linux = False
|
||||
|
||||
if os.path.exists(config.renpy_base + "/lib/linux-iliad"):
|
||||
iliad = True
|
||||
else:
|
||||
iliad = False
|
||||
|
||||
if os.path.exists(config.renpy_base + "/renpy.app"):
|
||||
mac = True
|
||||
else:
|
||||
mac = False
|
||||
|
||||
if not (windows or mac or linux or iliad):
|
||||
store.error(u"Can't Distribute", u"Ren'Py is missing files required for distribution. Please download the full package from {a=http://www.renpy.org/}www.renpy.org{/a}.", "tools_menu")
|
||||
|
||||
lint()
|
||||
|
||||
store.message = ""
|
||||
|
||||
title(_(u"Building Distributions"))
|
||||
|
||||
mid()
|
||||
text(u"I've just performed a lint on your project. If it contains errors, you should say no and fix them.\nCheck {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?")
|
||||
ui.close()
|
||||
|
||||
bottom()
|
||||
button(u"Yes", clicked=ui.returns(True))
|
||||
button(u"No", clicked=ui.returns(False))
|
||||
ui.close()
|
||||
|
||||
if not interact():
|
||||
renpy.jump("tools")
|
||||
|
||||
|
||||
# if not windows or not mac or not linux:
|
||||
# store.message = "The full version of Ren'Py can build for Windows, Mac, and Linux. Download it from www.renpy.org."
|
||||
|
||||
title(u"Building Distributions")
|
||||
|
||||
mid()
|
||||
text(u"Distributions will be built for the following platforms:")
|
||||
|
||||
spacer()
|
||||
|
||||
if windows:
|
||||
text(u"Windows 2000+", style='launcher_input')
|
||||
|
||||
if linux:
|
||||
text(u"Linux x86", style='launcher_input')
|
||||
|
||||
if iliad:
|
||||
text(u"iLiad", style='launcher_input')
|
||||
|
||||
if mac:
|
||||
text(u"Mac OS X 10.4+", style='launcher_input')
|
||||
|
||||
spacer()
|
||||
|
||||
|
||||
# TODO: If missing platforms, prompt for a DL.
|
||||
|
||||
text(u"Is this okay?")
|
||||
ui.close()
|
||||
|
||||
bottom()
|
||||
button(u"Yes", clicked=ui.returns(True))
|
||||
button(u"No", clicked=ui.returns(False))
|
||||
ui.close()
|
||||
|
||||
if not interact():
|
||||
renpy.jump("tools")
|
||||
|
||||
default_name = project.info.get('distribution_base', project.name)
|
||||
|
||||
name = prompt(u"Building Distributions",
|
||||
u"Please enter a base name for the directories making up this distribution.",
|
||||
"tools",
|
||||
default_name,
|
||||
u"This usually should include a name and version number, like 'moonlight_walks-1.0'.")
|
||||
|
||||
name = name.strip()
|
||||
|
||||
if not name:
|
||||
store.error(u"Error", u"The distribution name should not be empty.", "tools_menu")
|
||||
|
||||
try:
|
||||
name = name.encode("ascii")
|
||||
except:
|
||||
store.error(u"Error", u"Distribution names must be ASCII. This is because archive file formats do not support non-ASCII characters in a uniform way.", "tools_menu")
|
||||
|
||||
project.info['distribution_base'] = name
|
||||
|
||||
ignore_extensions = project.info.get('ignore_extensions', "~ .bak")
|
||||
ignore_extensions = prompt(u"Building Distributions", u"Please enter a space separated list of the file extensions you do not want included in the distribution.", "tools", ignore_extensions)
|
||||
store.ignore_extensions = [ i.strip() for i in ignore_extensions.strip().split() ]
|
||||
project.info['ignore_extensions'] = ignore_extensions
|
||||
|
||||
project.save()
|
||||
|
||||
# Figure out the files that will make up the distribution.
|
||||
|
||||
multi = [ ]
|
||||
|
||||
# This finds the files and directories in the tree, and includes
|
||||
# them in the result.
|
||||
|
||||
|
||||
# renpy and common directories.
|
||||
multi.extend(tree(config.renpy_base + "/renpy", "renpy"))
|
||||
multi.append((config.renpy_base + "/LICENSE.txt", "renpy/LICENSE.txt"))
|
||||
multi.extend(tree(config.commondir, "common"))
|
||||
|
||||
# Include the project.
|
||||
multi.extend(tree(project.path, '',
|
||||
exclude_suffix = [ ],
|
||||
exclude_prefix = [ ],
|
||||
exclude=[ ],
|
||||
root=True))
|
||||
|
||||
shortgamedir = project.gamedir[len(project.path)+1:]
|
||||
|
||||
|
||||
def add_script_version(fn, multi=multi, shortgamedir=shortgamedir):
|
||||
|
||||
for a, b in multi:
|
||||
if b == shortgamedir + "/" + fn:
|
||||
return
|
||||
|
||||
for i in store.ignore_extensions:
|
||||
if fn.endswith(i):
|
||||
return
|
||||
|
||||
multi.append((config.gamedir + "/" + fn, shortgamedir + "/" + fn))
|
||||
|
||||
add_script_version("script_version.rpy")
|
||||
add_script_version("script_version.rpyc")
|
||||
|
||||
# renpy.py
|
||||
multi.append((config.renpy_base + "/renpy.py",
|
||||
project.name + ".py"))
|
||||
|
||||
# Windows Zip
|
||||
if windows:
|
||||
win_files = [
|
||||
( config.renpy_base + "/renpy.exe", project.name + ".exe"),
|
||||
( config.renpy_base + "/renpy.code", "renpy.code" ),
|
||||
( config.renpy_base + "/python25.dll", "python25.dll" ),
|
||||
( config.renpy_base + "/msvcr71.dll", "msvcr71.dll" ),
|
||||
]
|
||||
|
||||
win_data = { }
|
||||
if os.path.exists(project.path + "/icon.ico"):
|
||||
win_data[project.name + ".exe"] = pefile.change_icons(
|
||||
config.renpy_base + "/renpy.exe",
|
||||
project.path + "/icon.ico",
|
||||
)
|
||||
|
||||
zf = zipfile.ZipFile(name + ".zip", "w", zipfile.ZIP_DEFLATED)
|
||||
|
||||
progress_len = len(multi) + len(win_files)
|
||||
store.message = u"Be sure to announce your project at the Lemma Soft Forums."
|
||||
|
||||
for i, (fn, an) in enumerate(multi + win_files):
|
||||
progress(u"Building Windows", i, progress_len)
|
||||
|
||||
if os.path.isdir(fn):
|
||||
continue
|
||||
|
||||
zi = zipfile.ZipInfo(name + "/" + an)
|
||||
|
||||
s = os.stat(fn)
|
||||
zi.date_time = time.gmtime(s.st_mtime)[:6]
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.create_system = 3
|
||||
|
||||
zi.external_attr = long(0100666) << 16
|
||||
data = file(fn, "rb").read()
|
||||
|
||||
data = win_data.get(an, data)
|
||||
|
||||
zf.writestr(zi, data)
|
||||
|
||||
|
||||
zf.close()
|
||||
|
||||
|
||||
# Linux Tar Bz2
|
||||
if linux:
|
||||
|
||||
linux_files = [
|
||||
(config.renpy_base + "/lib/linux-x86", "lib/linux-x86"),
|
||||
(config.renpy_base + "/renpy.sh", project.name + ".sh"),
|
||||
(config.renpy_base + "/lib/python", "lib/python"),
|
||||
]
|
||||
|
||||
|
||||
linux_files.extend(tree(config.renpy_base + "/lib/linux-x86", "lib/linux-x86"))
|
||||
|
||||
tf = tarfile.open(name + "-linux-x86.tar.bz2", "w:bz2")
|
||||
tf.dereference = True
|
||||
|
||||
progress_len = len(multi) + len(linux_files)
|
||||
store.message = u"If appropriate, please submit your game to www.renai.us."
|
||||
|
||||
for j, i in enumerate(multi + linux_files):
|
||||
|
||||
progress(u"Building Linux", j, progress_len)
|
||||
|
||||
fn, an = i
|
||||
|
||||
info = tf.gettarinfo(fn, name + "-linux-x86/" + an)
|
||||
|
||||
if info.isdir():
|
||||
perms = 0777
|
||||
elif info.name.endswith(".sh"):
|
||||
perms = 0777
|
||||
elif info.name.endswith(".so"):
|
||||
perms = 0777
|
||||
elif info.name.endswith("python"):
|
||||
perms = 0777
|
||||
elif info.name.endswith("python.real"):
|
||||
perms = 0777
|
||||
else:
|
||||
perms = 0666
|
||||
|
||||
info.mode = perms
|
||||
info.uid = 1000
|
||||
info.gid = 1000
|
||||
info.uname = "renpy"
|
||||
info.gname = "renpy"
|
||||
|
||||
if info.isreg():
|
||||
tf.addfile(info, file(fn, "rb"))
|
||||
else:
|
||||
tf.addfile(info)
|
||||
|
||||
tf.close()
|
||||
|
||||
|
||||
# iLiad Tar Bz2
|
||||
if iliad:
|
||||
|
||||
iliad_files = [
|
||||
(config.renpy_base + "/lib", "lib"),
|
||||
(config.renpy_base + "/renpy-iliad.sh", project.name + ".sh"),
|
||||
(config.renpy_base + "/lib/python", "lib/python"),
|
||||
(config.renpy_base + "/manifest.xml", "manifest.xml"),
|
||||
(config.renpy_base + "/iliad-icon.png", "iliad-icon.png"),
|
||||
]
|
||||
|
||||
iliad_files.extend(tree(config.renpy_base + "/lib/linux-iliad", "lib/linux-iliad"))
|
||||
|
||||
iliad_data = { }
|
||||
|
||||
manifest = file(config.renpy_base + "/manifest.xml", "r").read()
|
||||
manifest = manifest.replace("GAMENAME", project.name)
|
||||
iliad_data["manifest.xml"] = manifest
|
||||
|
||||
zf = zipfile.ZipFile(name + "-iLiad.zip", "w", zipfile.ZIP_DEFLATED)
|
||||
|
||||
progress_len = len(multi) + len(iliad_files)
|
||||
store.message = u"We thank Hixbooks for sponsoring iLiad support."
|
||||
|
||||
for i, (fn, an) in enumerate(multi + iliad_files):
|
||||
|
||||
progress(u"Building iLiad", i, progress_len)
|
||||
|
||||
if os.path.isdir(fn):
|
||||
continue
|
||||
|
||||
zi = zipfile.ZipInfo(project.name + "/" + an)
|
||||
|
||||
s = os.stat(fn)
|
||||
zi.date_time = time.gmtime(s.st_mtime)[:6]
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.create_system = 3
|
||||
|
||||
for ext in [ ".sh", ".so", "python", "python.real" ]:
|
||||
if fn.endswith(ext):
|
||||
zi.external_attr = long(0100777) << 16
|
||||
data = file(fn, "rb").read()
|
||||
break
|
||||
else:
|
||||
zi.external_attr = long(0100666) << 16
|
||||
data = file(fn, "rb").read()
|
||||
|
||||
data = iliad_data.get(an, data)
|
||||
zf.writestr(zi, data)
|
||||
|
||||
zf.close()
|
||||
|
||||
if mac:
|
||||
|
||||
mac_files = tree(config.renpy_base + "/renpy.app",
|
||||
project.name + ".app")
|
||||
|
||||
mac_files = [ (fn, an.replace("Ren'Py Launcher", project.name)) for (fn, an) in mac_files ]
|
||||
|
||||
# Data replacement for macintosh.
|
||||
mac_data = { }
|
||||
|
||||
quoted_name = project.name.replace("&", "&").replace("<", "<")
|
||||
info_plist = file(config.renpy_base + "/renpy.app/Contents/Info.plist", "rb").read().replace("Ren'Py Launcher", quoted_name)
|
||||
mac_data[project.name + ".app/Contents/Info.plist"] = info_plist
|
||||
|
||||
quoted_name = project.name.replace("\"", "\\\"")
|
||||
launcher_py = file(config.renpy_base + "/renpy.app/Contents/Resources/launcher.py", "rb").read().replace("Ren'Py Launcher", quoted_name)
|
||||
mac_data[project.name + ".app/Contents/Resources/launcher.py"] = launcher_py
|
||||
|
||||
if os.path.exists(project.path + "/icon.icns"):
|
||||
icon_data = file(project.path + "/icon.icns", "rb").read()
|
||||
mac_data[project.name + ".app/Contents/Resources/launcher.icns"] = icon_data
|
||||
|
||||
zf = zipfile.ZipFile(name + "-mac.zip", "w", zipfile.ZIP_DEFLATED)
|
||||
|
||||
progress_len = len(multi) + len(mac_files)
|
||||
store.message = u"Thank you for choosing Ren'Py."
|
||||
|
||||
for i, (fn, an) in enumerate(multi + mac_files):
|
||||
|
||||
progress(u"Building Mac OS X", i, progress_len)
|
||||
|
||||
if os.path.isdir(fn):
|
||||
continue
|
||||
|
||||
zi = zipfile.ZipInfo(name + "-mac/" + an)
|
||||
|
||||
s = os.stat(fn)
|
||||
zi.date_time = time.gmtime(s.st_mtime)[:6]
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.create_system = 3
|
||||
|
||||
if os.path.dirname(fn).endswith("MacOS") or fn.endswith(".so") or fn.endswith(".dylib"):
|
||||
zi.external_attr = long(0100777) << 16
|
||||
data = file(fn, "rb").read()
|
||||
else:
|
||||
zi.external_attr = long(0100666) << 16
|
||||
data = file(fn, "rb").read()
|
||||
|
||||
data = mac_data.get(an, data)
|
||||
zf.writestr(zi, data)
|
||||
|
||||
zf.close()
|
||||
|
||||
|
||||
# Announce Success
|
||||
|
||||
store.message = ""
|
||||
|
||||
title(u"Success")
|
||||
|
||||
mid()
|
||||
text(u"The distribution(s) have been built. Be sure to test them before release.")
|
||||
|
||||
spacer()
|
||||
|
||||
if mac:
|
||||
text(u"Note that unpacking and repacking Mac zips and Linux tarballs on Windows isn't supported.")
|
||||
|
||||
ui.close()
|
||||
|
||||
bottom()
|
||||
button(u"Return", clicked=ui.returns(True))
|
||||
ui.close()
|
||||
|
||||
interact()
|
||||
|
||||
|
||||
jump tools
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# This file contains logic for detecting an editor, and for selecting
|
||||
# the default editor.
|
||||
|
||||
init:
|
||||
python hide:
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
if not config.editor:
|
||||
|
||||
editor = os.path.normpath(config.renpy_base + "/jedit/jedit.jar")
|
||||
|
||||
if os.path.exists(editor):
|
||||
|
||||
editor = renpy.shell_escape(editor)
|
||||
|
||||
if sys.platform == 'win32':
|
||||
config.editor = 'javaw.exe -jar "' + editor + '" -reuseview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
config.editor_transient = 'javaw.exe -jar "' + editor + '" -newplainview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
else:
|
||||
config.editor = 'java -jar "' + editor + '" -reuseview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
config.editor_transient = 'java -jar "' + editor + '" -newplainview "%(filename)s" +line:%(line)d "%(otherfiles)s"'
|
||||
|
||||
if config.editor:
|
||||
os.environ['RENPY_EDITOR'] = config.editor
|
||||
if config.editor_transient:
|
||||
os.environ['RENPY_EDITOR_TRANSIENT'] = config.editor_transient
|
||||
|
||||
|
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1,167 @@
|
||||
label new:
|
||||
|
||||
python hide:
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import time
|
||||
|
||||
|
||||
# Select a template.
|
||||
|
||||
choices = [ (p.name, p.info["description"], p, None, False) for p in projects if p.info.get("template", None)]
|
||||
|
||||
template = paged_menu(u"Select a Template", choices, u"Please select a project to use as a template for your project.")
|
||||
|
||||
# Choose project name.
|
||||
|
||||
name = prompt(u"Project Name", u"Type the name of your new project, and press enter.\n", "main")
|
||||
name = name.strip()
|
||||
|
||||
error = None
|
||||
|
||||
if not name:
|
||||
error = u"Please enter a non-empty project name."
|
||||
elif os.path.exists(name):
|
||||
error = u"A file or directory named '%s' already exists." % name
|
||||
else:
|
||||
try:
|
||||
name = name.encode("ascii")
|
||||
except:
|
||||
error = u"Project names must be ASCII. This is because the ZIP file format does not support non-ASCII characters in a uniform way."
|
||||
|
||||
if error:
|
||||
store.error(u"Error", error, "main")
|
||||
|
||||
# Tell the user we're creating the project.
|
||||
title(u"Creating Project")
|
||||
store.message = u"Please wait while we create the project."
|
||||
ui.pausebehavior(0)
|
||||
interact()
|
||||
|
||||
# Here is where we actually create the project.
|
||||
|
||||
import shutil
|
||||
|
||||
shutil.copytree(template.path, name)
|
||||
|
||||
unlink = template.info.get("unlink", [ ])
|
||||
unlink += [ 'launcherinfo.py' ]
|
||||
|
||||
for i in unlink:
|
||||
if os.path.exists(name + "/" + i):
|
||||
os.unlink(name + "/" + i)
|
||||
|
||||
for dir, dirs, files in os.walk(name):
|
||||
for d in list(dirs):
|
||||
if d.startswith("."):
|
||||
dirs.remove(d)
|
||||
dn = dir + "/" + d
|
||||
shutil.rmtree(dn, True)
|
||||
|
||||
# Change the save directory.
|
||||
options = file(name + "/game/options.rpy").read()
|
||||
save_dir = "%s-%d" % (name, time.time())
|
||||
options = options.replace("template-1220804310", save_dir)
|
||||
file(name + "/game/options.rpy", "w").write(options)
|
||||
|
||||
persistent.project = name
|
||||
|
||||
call find_project from _call_find_project_2
|
||||
|
||||
label choose_theme:
|
||||
|
||||
python hide:
|
||||
|
||||
# Select a color scheme.
|
||||
|
||||
themes = theme_data.keys()
|
||||
themes.sort()
|
||||
|
||||
choices = [ ]
|
||||
for i in themes:
|
||||
|
||||
def hovered(i=i):
|
||||
td = theme_data[i].copy()
|
||||
engine = td["theme"]
|
||||
del td["theme"]
|
||||
|
||||
if engine == "roundrect":
|
||||
renpy.style.restore(style_backup)
|
||||
theme.roundrect(launcher=True, **td)
|
||||
renpy.style.rebuild()
|
||||
return ("repeat", 0)
|
||||
|
||||
choices.append((i, None, i, hovered, False))
|
||||
|
||||
color_theme = paged_menu(u"Select a Theme", choices, u"Please select a color theme for your project. You can always change the colors later.", cancel='color_theme_cancel')
|
||||
|
||||
# Restore default theme.
|
||||
renpy.style.restore(style_backup)
|
||||
theme.roundrect(launcher=True)
|
||||
renpy.style.rebuild()
|
||||
|
||||
ofn = project.path + "/game/options.rpy"
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
if not os.path.exists(ofn):
|
||||
error(u"Changing Theme", u"The options file does not seem to exist.", "main")
|
||||
|
||||
inf = file(ofn, "rU")
|
||||
outf = file(ofn + ".new", "w")
|
||||
|
||||
td = theme_data[color_theme]
|
||||
|
||||
# TODO: Make this less specific to roundrect. Need to figure out
|
||||
# how to switch themes, rather than just recolor them.
|
||||
|
||||
changing = False
|
||||
changed = False
|
||||
|
||||
for l in inf:
|
||||
|
||||
if re.match(r'\s*theme.roundrect\(', l):
|
||||
changing = True
|
||||
changed = True
|
||||
elif re.match(r'\s*\)', l):
|
||||
changing = False
|
||||
elif changing:
|
||||
|
||||
def repl(m, td=td):
|
||||
return m.group(1) + m.group(2) + " = \"" + td.get(m.group(2), m.group(3)) + "\","
|
||||
|
||||
l = re.sub(r'^(\s*)(\w+) = "([\da-fA-F#]+)",', repl, l)
|
||||
|
||||
outf.write(l)
|
||||
|
||||
outf.close()
|
||||
inf.close()
|
||||
|
||||
try:
|
||||
os.rename(ofn + ".new", ofn)
|
||||
except:
|
||||
|
||||
# I hate windows.
|
||||
os.rename(ofn, ofn + ".old")
|
||||
os.rename(ofn + ".new", ofn)
|
||||
os.unlink(ofn + ".old")
|
||||
|
||||
if not changed:
|
||||
error(u"Changing Theme", u"Could not modify options.rpy, perhaps it was edited too much.", "main")
|
||||
|
||||
jump main
|
||||
|
||||
|
||||
|
||||
label color_theme_cancel:
|
||||
|
||||
python hide:
|
||||
|
||||
# Restore default theme.
|
||||
renpy.style.restore(style_backup)
|
||||
theme.roundrect(launcher=True)
|
||||
renpy.style.rebuild()
|
||||
|
||||
jump main
|
||||
@@ -0,0 +1,343 @@
|
||||
|
||||
# http://www.csn.ul.ie/~caolan/publink/winresdump/winresdump/doc/pefile.html
|
||||
# Contains a reasonable description of the format.
|
||||
|
||||
import struct
|
||||
import sys
|
||||
import array
|
||||
|
||||
# The starting point of the resource segment in the file.
|
||||
RESOURCE_BASE=0x3600
|
||||
|
||||
# The virtual memory location the resource segment is loaded
|
||||
# to.
|
||||
RESOURCE_VIRTUAL=0x6000
|
||||
|
||||
# The offset of the field that tells us with the alignment need be.
|
||||
ALIGNMENT_FIELD = 0x130
|
||||
|
||||
# The start of the .rsrc segment header.
|
||||
RSRC_HEADER = 0x268
|
||||
|
||||
# Locations in the file where we need to patch in the resource
|
||||
# segment length.
|
||||
RESOURCE_LENGTH_PATCHES = [ 0x0184, RSRC_HEADER + 0x8 ]
|
||||
|
||||
# Locations in the file where we need to patch in the padded
|
||||
# resource segment length.
|
||||
RESOURCE_PADDED_PATCHES = [ RSRC_HEADER + 0x10 ]
|
||||
|
||||
# Locations in the file where we need to patch in the change in the
|
||||
# size of the resource segement (and hence the change in the file's
|
||||
# total size.)
|
||||
SIZE_DELTA_PATCHES = [ 0x148 ]
|
||||
|
||||
# A location in the file that will be checked to be sure it matches
|
||||
# RESOURCE_BASE.
|
||||
CHECK_ADDRESS = RSRC_HEADER + 0x14
|
||||
|
||||
# A location in the file that will be checked to make sure it matches
|
||||
# RESOURCE_VIRTUAL
|
||||
CHECK_ADDRESS2 = RSRC_HEADER + 0xc
|
||||
|
||||
# This class performs various operations on memory-loaded binary files,
|
||||
# including modifications.
|
||||
class BinFile(object):
|
||||
|
||||
def set_u32(self, addr, value):
|
||||
self.a[addr+0] = (value >> 0) & 0xff
|
||||
self.a[addr+1] = (value >> 8) & 0xff
|
||||
self.a[addr+2] = (value >> 16) & 0xff
|
||||
self.a[addr+3] = (value >> 24) & 0xff
|
||||
|
||||
def u32(self):
|
||||
addr = self.addr
|
||||
rv = self.a[addr]
|
||||
rv |= self.a[addr+1] << 8
|
||||
rv |= self.a[addr+2] << 16
|
||||
rv |= self.a[addr+3] << 24
|
||||
self.addr += 4
|
||||
return rv
|
||||
|
||||
def u16(self):
|
||||
addr = self.addr
|
||||
rv = self.a[addr]
|
||||
rv |= self.a[addr+1] << 8
|
||||
self.addr += 2
|
||||
return rv
|
||||
|
||||
def u8(self):
|
||||
rv = self.a[self.addr]
|
||||
self.addr += 1
|
||||
return rv
|
||||
|
||||
def name(self):
|
||||
c = self.u16()
|
||||
|
||||
rv = u""
|
||||
for i in range(c):
|
||||
rv += unichr(self.u16())
|
||||
|
||||
return rv
|
||||
|
||||
def seek(self, addr):
|
||||
self.addr = addr
|
||||
|
||||
def tostring(self):
|
||||
return self.a.tostring()
|
||||
|
||||
def substring(self, start, len):
|
||||
return self.a[start:start+len].tostring()
|
||||
|
||||
def __init__(self, fn):
|
||||
data = open(fn, "rb").read()
|
||||
self.a = array.array('B')
|
||||
self.a.fromstring(data)
|
||||
|
||||
##############################################################################
|
||||
# These functions parse data out of the file. In these functions, offset is
|
||||
# relative to the start of the file.
|
||||
|
||||
# This parses a data block out of the resources.
|
||||
def parse_data(offset):
|
||||
pe.seek(RESOURCE_BASE + offset)
|
||||
data_offset = pe.u32()
|
||||
data_len = pe.u32()
|
||||
code_page = pe.u32()
|
||||
pe.u32()
|
||||
|
||||
l = [ ]
|
||||
|
||||
pe.seek(data_offset + RESOURCE_BASE - RESOURCE_VIRTUAL)
|
||||
for i in range(data_len):
|
||||
l.append(chr(pe.u8()))
|
||||
|
||||
return (code_page, "".join(l))
|
||||
|
||||
# This parses a resource directory.
|
||||
def parse_directory(offset):
|
||||
|
||||
pe.seek(RESOURCE_BASE + offset)
|
||||
char = pe.u32()
|
||||
timedate = pe.u32()
|
||||
major = pe.u16()
|
||||
minor = pe.u16()
|
||||
n_named = pe.u16()
|
||||
n_id = pe.u16()
|
||||
|
||||
entries = [ ]
|
||||
|
||||
for i in range(n_named + n_id):
|
||||
entries.append((pe.u32(), pe.u32()))
|
||||
|
||||
rv = { }
|
||||
|
||||
for name, value in entries:
|
||||
|
||||
if name & 0x80000000:
|
||||
pe.seek((name & 0x7fffffff) + RESOURCE_BASE)
|
||||
name = pe.name()
|
||||
|
||||
if value & 0x80000000:
|
||||
value = parse_directory(value & 0x7fffffff)
|
||||
else:
|
||||
value = parse_data(value)
|
||||
|
||||
rv[name] = value
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
##############################################################################
|
||||
# This utility function displays the tree of resources that have been loaded.
|
||||
def show_resources(d, prefix):
|
||||
|
||||
if not isinstance(d, dict):
|
||||
print prefix, "Codepage", d[0], "length", len(d[1])
|
||||
return
|
||||
|
||||
for k in d:
|
||||
print prefix, k
|
||||
show_resources(d[k], prefix + " ")
|
||||
|
||||
##############################################################################
|
||||
# These functions repack the resources into a new resource segment. Here,
|
||||
# the offset is relative to the start of the resource segment.
|
||||
|
||||
class Packer(object):
|
||||
|
||||
def pack(self, d):
|
||||
self.data = ""
|
||||
self.data_offset = 0
|
||||
|
||||
self.entries = ""
|
||||
self.entries_offset = 0
|
||||
|
||||
head = self.pack_dict(d, 0)
|
||||
|
||||
self.data = ""
|
||||
self.data_offset = len(head) + len(self.entries)
|
||||
|
||||
self.entries = ""
|
||||
self.entries_offset = len(head)
|
||||
|
||||
return self.pack_dict(d, 0) + self.entries + self.data
|
||||
|
||||
|
||||
|
||||
def pack_name(self, s):
|
||||
rv = self.data_offset + len(self.data)
|
||||
|
||||
l = len(s)
|
||||
s = s.encode("utf-16le")
|
||||
self.data += struct.pack("<H", l) + s + "\0\0"
|
||||
|
||||
return rv
|
||||
|
||||
def pack_tuple(self, t):
|
||||
codepage, data = t
|
||||
|
||||
rv = len(self.entries) + self.entries_offset
|
||||
|
||||
if len(self.data) % 2:
|
||||
self.data += "P"
|
||||
|
||||
daddr = len(self.data) + self.data_offset
|
||||
|
||||
self.entries += struct.pack("<IIII", daddr + RESOURCE_VIRTUAL, len(data), codepage, 0)
|
||||
self.data += data
|
||||
|
||||
# if len(self.data) % 1 == 1:
|
||||
# self.data += 'P'
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
|
||||
|
||||
def pack_dict(self, d, offset):
|
||||
name_entries = sorted((a, b) for a, b in d.iteritems() if isinstance(a, unicode))
|
||||
id_entries = sorted((a, b) for a, b in d.iteritems() if isinstance(a, int))
|
||||
|
||||
rv = struct.pack("<IIHHHH", 0, 0, 4, 0, len(name_entries), len(id_entries))
|
||||
|
||||
offset += len(rv) + (len(name_entries) + len(id_entries)) * 8
|
||||
|
||||
rest = ""
|
||||
|
||||
for (name, value) in name_entries + id_entries:
|
||||
if isinstance(name, unicode):
|
||||
name = 0x80000000 | self.pack_name(name)
|
||||
|
||||
if isinstance(value, dict):
|
||||
addr = offset | 0x80000000
|
||||
packed = self.pack_dict(value, offset)
|
||||
offset += len(packed)
|
||||
rest += packed
|
||||
else:
|
||||
addr = self.pack_tuple(value)
|
||||
|
||||
rv += struct.pack("<II", name, addr)
|
||||
|
||||
return rv + rest
|
||||
|
||||
##############################################################################
|
||||
# This loads in an icon file, and returns a dictionary that is suitable for
|
||||
# use in the resources of an exe file.
|
||||
def load_icon(fn):
|
||||
f = BinFile(fn)
|
||||
|
||||
f.seek(0)
|
||||
f.u16()
|
||||
f.u16()
|
||||
count = f.u16()
|
||||
|
||||
rv = { }
|
||||
rv[3] = { }
|
||||
|
||||
group = struct.pack("HHH", 0, 1, count)
|
||||
|
||||
for i in range(count):
|
||||
width = f.u8()
|
||||
height = f.u8()
|
||||
colors = f.u8()
|
||||
reserved = f.u8()
|
||||
planes = f.u16()
|
||||
bpp = f.u16()
|
||||
size = f.u32()
|
||||
offset = f.u32()
|
||||
|
||||
addr = f.addr
|
||||
f.seek(offset + 16)
|
||||
if not f.u32():
|
||||
f.set_u32(offset + 20, 0)
|
||||
|
||||
rv[3][i + 1] = { 0 : (1252, f.substring(offset, size)) }
|
||||
|
||||
|
||||
group += struct.pack("BBBBHHIH", width, height, colors, reserved,
|
||||
planes, bpp, size, i + 1)
|
||||
|
||||
f.seek(addr)
|
||||
|
||||
rv[14] = { 1 : { 0 : (1252, group) } }
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
##############################################################################
|
||||
# This is the main function that should be called externally, that copies over
|
||||
# the icons.
|
||||
def change_icons(oldexe, icofn):
|
||||
global pe
|
||||
pe = BinFile(oldexe)
|
||||
|
||||
# Check that RESOURCE_BASE and RESOURCE_VIRTUAL are still valid.
|
||||
pe.seek(CHECK_ADDRESS)
|
||||
if pe.u32() != RESOURCE_BASE:
|
||||
raise Exception("RESOURCE_BASE is no longer correct. Please check all relocations.")
|
||||
|
||||
pe.seek(CHECK_ADDRESS2)
|
||||
if pe.u32() != RESOURCE_VIRTUAL:
|
||||
raise Exception("RESOURCE_VIRTUAL is no longer correct. Please check all relocations.")
|
||||
|
||||
resources = parse_directory(0)
|
||||
# show_resources(resources, "")
|
||||
resources.update(load_icon(icofn))
|
||||
# show_resources(resources, "")
|
||||
|
||||
rsrc = Packer().pack(resources)
|
||||
rsrc_len = len(rsrc)
|
||||
|
||||
pe.seek(ALIGNMENT_FIELD)
|
||||
alignment = pe.u32()
|
||||
|
||||
if len(rsrc) % alignment:
|
||||
pad = alignment - (len(rsrc) % alignment)
|
||||
padding = "RENPYVNE" * (pad / 8 + 1)
|
||||
padding = padding[:pad]
|
||||
rsrc += padding
|
||||
|
||||
padded_len = len(rsrc)
|
||||
|
||||
for addr in RESOURCE_LENGTH_PATCHES:
|
||||
pe.set_u32(addr, rsrc_len)
|
||||
|
||||
for addr in RESOURCE_PADDED_PATCHES:
|
||||
pe.seek(addr)
|
||||
size_delta = padded_len - pe.u32()
|
||||
pe.set_u32(addr, padded_len)
|
||||
|
||||
for addr in SIZE_DELTA_PATCHES:
|
||||
pe.seek(addr)
|
||||
pe.set_u32(addr, pe.u32() + size_delta)
|
||||
|
||||
|
||||
return pe.tostring()[:RESOURCE_BASE] + rsrc
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
f = file(sys.argv[3], "wb")
|
||||
f.write(change_icons(sys.argv[1], sys.argv[2]))
|
||||
f.close()
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
init 1 python:
|
||||
theme_data = {'Basic Blue': {'disabled': '#404040',
|
||||
'disabled_text': '#c8c8c8',
|
||||
'frame': '#6496c8',
|
||||
'gm_root': '#dcebff',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#dcebff',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#003c78',
|
||||
'widget_hover': '#0050a0',
|
||||
'widget_selected': '#ffffc8',
|
||||
'widget_text': '#c8ffff'},
|
||||
'Bloody Mary': {'disabled': '#400000',
|
||||
'disabled_text': '#260000',
|
||||
'frame': '#400808',
|
||||
'gm_root': '#000000',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#000000',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#000000',
|
||||
'widget_hover': '#830000',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#C2C2C2'},
|
||||
'Colorblind': {'disabled': '#898989',
|
||||
'disabled_text': '#666666',
|
||||
'frame': '#252525',
|
||||
'gm_root': '#393939',
|
||||
'label': '#c2c2c2',
|
||||
'mm_root': '#393939',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#898989',
|
||||
'widget_hover': '#464646',
|
||||
'widget_selected': '#F2F2F2',
|
||||
'widget_text': '#CCCCCC'},
|
||||
'Cotton Candy': {'disabled': '#C8AFA1',
|
||||
'disabled_text': '#E1D4C9',
|
||||
'frame': '#FCF5F2',
|
||||
'gm_root': '#D0B4BA',
|
||||
'label': '#805C40',
|
||||
'mm_root': '#D0B4BA',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#ECC7D0',
|
||||
'widget_hover': '#E1D4C9',
|
||||
'widget_selected': '#805C40',
|
||||
'widget_text': '#805C40'},
|
||||
'Creamsicle': {'disabled': '#FFECBF',
|
||||
'disabled_text': '#ffffff',
|
||||
'frame': '#FFECBF',
|
||||
'gm_root': '#FDF5E3',
|
||||
'label': '#502F13',
|
||||
'mm_root': '#FDF5E3',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#D96B00',
|
||||
'widget_hover': '#FD9B1C',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#FCE6B1'},
|
||||
'Dramatic Flesh': {'disabled': '#ab6038',
|
||||
'disabled_text': '#BF7C51',
|
||||
'frame': '#49271b',
|
||||
'gm_root': '#2a201f',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#2a201f',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#BF7C51',
|
||||
'widget_hover': '#dda570',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#E5DFDF'},
|
||||
'Easter Baby': {'disabled': '#DDE9FF',
|
||||
'disabled_text': '#A6AFBF',
|
||||
'frame': '#CCF8DC',
|
||||
'gm_root': '#FBF9DF',
|
||||
'label': '#698071',
|
||||
'mm_root': '#FBF9DF',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#F5D4EE',
|
||||
'widget_hover': '#F0DDFF',
|
||||
'widget_selected': '#000000',
|
||||
'widget_text': '#698071'},
|
||||
'Favorite Jeans': {'disabled': '#919994',
|
||||
'disabled_text': '#B6BFB9',
|
||||
'frame': '#6f7571',
|
||||
'gm_root': '#b0b8ba',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#b0b8ba',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#8699a7',
|
||||
'widget_hover': '#9eb1ad',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#dcdfd6'},
|
||||
'Fine China': {'disabled': '#ADB9CC',
|
||||
'disabled_text': '#DFBA14',
|
||||
'frame': '#ADB9CC',
|
||||
'gm_root': '#F7F7FA',
|
||||
'label': '#39435E',
|
||||
'mm_root': '#F7F7FA',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#6A7183',
|
||||
'widget_hover': '#1A2B47',
|
||||
'widget_selected': '#E3E3E4',
|
||||
'widget_text': '#C9C9CB'},
|
||||
'First Valentines': {'disabled': '#F8F2D0',
|
||||
'disabled_text': '#BFA1A1',
|
||||
'frame': '#F8F2D0',
|
||||
'gm_root': '#D98989',
|
||||
'label': '#5D1010',
|
||||
'mm_root': '#D98989',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#F09898',
|
||||
'widget_hover': '#D6C5BB',
|
||||
'widget_selected': '#B31E1E',
|
||||
'widget_text': '#593131'},
|
||||
'Ice Queen': {'disabled': '#F0F2F2',
|
||||
'disabled_text': '#FBFBFB',
|
||||
'frame': '#ffffff',
|
||||
'gm_root': '#E6E6E6',
|
||||
'label': '#D9D9D9',
|
||||
'mm_root': '#E6E6E6',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#D9D9D9',
|
||||
'widget_hover': '#F0F2F2',
|
||||
'widget_selected': '#737373',
|
||||
'widget_text': '#ffffff'},
|
||||
'Mocha Latte': {'disabled': '#614D3A',
|
||||
'disabled_text': '#80654D',
|
||||
'frame': '#926841',
|
||||
'gm_root': '#1A140E',
|
||||
'label': '#F1EBE5',
|
||||
'mm_root': '#1A140E',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#4D3B29',
|
||||
'widget_hover': '#996E45',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#B99D83'},
|
||||
'Muted Horror': {'disabled': '#73735C',
|
||||
'disabled_text': '#8C8C70',
|
||||
'frame': '#555544',
|
||||
'gm_root': '#1A0001',
|
||||
'label': '#1A0001',
|
||||
'mm_root': '#1A0001',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#777777',
|
||||
'widget_hover': '#73735C',
|
||||
'widget_selected': '#000000',
|
||||
'widget_text': '#404033'},
|
||||
'Old Polaroid': {'disabled': '#A89E7D',
|
||||
'disabled_text': '#CCC097',
|
||||
'frame': '#49403E',
|
||||
'gm_root': '#A84A3E',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#A84A3E',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#A89E7D',
|
||||
'widget_hover': '#8DB6B9',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#49403E'},
|
||||
'Really Red': {'disabled': '#404040',
|
||||
'disabled_text': '#c8c8c8',
|
||||
'frame': '#e17373',
|
||||
'gm_root': '#ffd0d0',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#ffd0d0',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#963232',
|
||||
'widget_hover': '#c83232',
|
||||
'widget_selected': '#ffffc8',
|
||||
'widget_text': '#ffffff'},
|
||||
'Summer Sky': {'disabled': '#6074BF',
|
||||
'disabled_text': '#7383BF',
|
||||
'frame': '#6074BF',
|
||||
'gm_root': '#B4CDD4',
|
||||
'label': '#94C7D4',
|
||||
'mm_root': '#B4CDD4',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#F2E6AA',
|
||||
'widget_hover': '#FCFCA4',
|
||||
'widget_selected': '#1A5766',
|
||||
'widget_text': '#7DA8B3'},
|
||||
'Swamp Critter': {'disabled': '#A2521D',
|
||||
'disabled_text': '#753D00',
|
||||
'frame': '#797C1C',
|
||||
'gm_root': '#B09D5A',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#B09B4F',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#753D00',
|
||||
'widget_hover': '#B19A48',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#CCCAC2'},
|
||||
'Urban Sprawl': {'disabled': '#8F0000',
|
||||
'disabled_text': '#333333',
|
||||
'frame': '#8F0000',
|
||||
'gm_root': '#000000',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#000000',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#333333',
|
||||
'widget_hover': '#000000',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#6C8A2F'},
|
||||
'Victorian Gingerbread': {'disabled': '#7A674F',
|
||||
'disabled_text': '#664F33',
|
||||
'frame': '#BF8A73',
|
||||
'gm_root': '#695640',
|
||||
'label': '#F2EDC4',
|
||||
'mm_root': '#695640',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#7A674F',
|
||||
'widget_hover': '#BDA77D',
|
||||
'widget_selected': '#FDFBEE',
|
||||
'widget_text': '#F2EDC4'},
|
||||
'Watermelon Pie': {'disabled': '#FABF46',
|
||||
'disabled_text': '#FFE06D',
|
||||
'frame': '#C3CD91',
|
||||
'gm_root': '#F7F7C5',
|
||||
'label': '#FCFCD7',
|
||||
'mm_root': '#F7F7C5',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#FFE06D',
|
||||
'widget_hover': '#E38A4F',
|
||||
'widget_selected': '#996600',
|
||||
'widget_text': '#FAA700'},
|
||||
'White Chocolate': {'disabled': '#614D3A',
|
||||
'disabled_text': '#80654D',
|
||||
'frame': '#926841',
|
||||
'gm_root': '#FBF9EA',
|
||||
'label': '#F1EBE5',
|
||||
'mm_root': '#FBF9EA',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#33271C',
|
||||
'widget_hover': '#ECE7C4',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#B99D83'},
|
||||
'Winter Mint': {'disabled': '#426143',
|
||||
'disabled_text': '#819981',
|
||||
'frame': '#245536',
|
||||
'gm_root': '#e5f1e5',
|
||||
'label': '#ffffff',
|
||||
'mm_root': '#e5f1e5',
|
||||
'theme': 'roundrect',
|
||||
'widget': '#7AA27B',
|
||||
'widget_hover': '#A3C7A3',
|
||||
'widget_selected': '#ffffff',
|
||||
'widget_text': '#CDE0CE'}}
|
||||
|
||||
@@ -105,7 +105,7 @@ def save_png(surf, file, compress=-1):
|
||||
|
||||
save_png_core(surf, RWopsFromPython(file), compress)
|
||||
|
||||
|
||||
|
||||
def pixellate(pysrc, pydst, avgwidth, avgheight, outwidth, outheight):
|
||||
|
||||
if not isinstance(pysrc, PygameSurface):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "renpy.h"
|
||||
#include <pygame/pygame.h>
|
||||
#include "IMG_savepng.h"
|
||||
#include <pygame/pygame.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -30,7 +30,6 @@ void save_png_core(PyObject *pysurf, SDL_RWops *rw, int compress) {
|
||||
IMG_SavePNG_RW(rw, surf, compress);
|
||||
}
|
||||
|
||||
|
||||
/* This pixellates a 32-bit RGBA pygame surface to a destination
|
||||
* surface of a given size.
|
||||
*
|
||||
@@ -1001,18 +1000,18 @@ void transform32_std(PyObject *pysrc, PyObject *pydst,
|
||||
|
||||
unsigned int amul = (int) (a * 256);
|
||||
|
||||
lsx = corner_x * 256;
|
||||
lsy = corner_y * 256;
|
||||
lsx = corner_x * 65536;
|
||||
lsy = corner_y * 65536;
|
||||
|
||||
xdx *= 256;
|
||||
ydx *= 256;
|
||||
xdy *= 256;
|
||||
ydy *= 256;
|
||||
xdx *= 65536;
|
||||
ydx *= 65536;
|
||||
xdy *= 65536;
|
||||
ydy *= 65536;
|
||||
|
||||
|
||||
// Scaled subtracted srcw and srch.
|
||||
float fsw = (srcw - 2) * 256;
|
||||
float fsh = (srch - 2) * 256;
|
||||
float fsw = (srcw - 1) * 65536 - 1;
|
||||
float fsh = (srch - 1) * 65536 - 1;
|
||||
|
||||
for (y = 0; y < dsth; y++, lsx += xdy, lsy += ydy) {
|
||||
|
||||
@@ -1059,7 +1058,7 @@ void transform32_std(PyObject *pysrc, PyObject *pydst,
|
||||
|
||||
sx = lsx + minx * xdx;
|
||||
sy = lsy + minx * ydx;
|
||||
|
||||
|
||||
int sxi = (int) sx;
|
||||
int syi = (int) sy;
|
||||
int xdxi = (int) xdx;
|
||||
@@ -1067,13 +1066,13 @@ void transform32_std(PyObject *pysrc, PyObject *pydst,
|
||||
|
||||
while (d <= dend) {
|
||||
int px, py;
|
||||
px = sxi >> 8;
|
||||
py = syi >> 8;
|
||||
px = sxi >> 16;
|
||||
py = syi >> 16;
|
||||
|
||||
unsigned char *sp = srcpixels + py * srcpitch + px * 4;
|
||||
|
||||
int yfrac = syi & 0xff; // ((short) sy) & 0xff;
|
||||
int xfrac = sxi & 0xff; // ((short) sx) & 0xff;
|
||||
int yfrac = (syi >> 8) & 0xff; // ((short) sy) & 0xff;
|
||||
int xfrac = (sxi >> 8) & 0xff; // ((short) sx) & 0xff;
|
||||
|
||||
unsigned int pal = *(unsigned int *) sp;
|
||||
unsigned int pbl = *(unsigned int *) (sp + 4);
|
||||
@@ -1165,17 +1164,17 @@ int transform32_mmx(PyObject *pysrc, PyObject *pydst,
|
||||
// Compute the coloring multiplier.
|
||||
unsigned int amul = (unsigned int) (a * 256);
|
||||
|
||||
lsx = corner_x * 256;
|
||||
lsy = corner_y * 256;
|
||||
lsx = corner_x * 65536;
|
||||
lsy = corner_y * 65536;
|
||||
|
||||
xdx *= 256;
|
||||
ydx *= 256;
|
||||
xdy *= 256;
|
||||
ydy *= 256;
|
||||
xdx *= 65536;
|
||||
ydx *= 65536;
|
||||
xdy *= 65536;
|
||||
ydy *= 65536;
|
||||
|
||||
// Scaled subtracted srcw and srch.
|
||||
float fsw = (srcw - 2) * 256;
|
||||
float fsh = (srch - 2) * 256;
|
||||
float fsw = (srcw - 1) * 65536 - 1;
|
||||
float fsh = (srch - 1) * 65536 - 1;
|
||||
|
||||
for (y = 0; y < dsth; y++, lsx += xdy, lsy += ydy) {
|
||||
|
||||
@@ -1236,13 +1235,13 @@ int transform32_mmx(PyObject *pysrc, PyObject *pydst,
|
||||
|
||||
while (d <= dend) {
|
||||
|
||||
px = sxi >> 8;
|
||||
py = syi >> 8;
|
||||
px = sxi >> 16;
|
||||
py = syi >> 16;
|
||||
|
||||
unsigned char *sp = srcpixels + py * srcpitch + px * 4;
|
||||
|
||||
unsigned int yfrac = syi & 0xff; // ((short) sy) & 0xff;
|
||||
unsigned int xfrac = sxi & 0xff; // ((short) sx) & 0xff;
|
||||
unsigned int yfrac = (syi >> 8) & 0xff; // ((short) sy) & 0xff;
|
||||
unsigned int xfrac = (sxi >> 8) & 0xff; // ((short) sx) & 0xff;
|
||||
|
||||
// Put xfrac in mm5, yfrac in m6
|
||||
pxor_r2r(mm5, mm5);
|
||||
|
||||
@@ -2,12 +2,6 @@ import sys
|
||||
|
||||
from sound import *
|
||||
|
||||
try:
|
||||
import nativemidi
|
||||
sys.modules['nativemidi'] = sys.modules['pysdlsound.nativemidi']
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
import winmixer
|
||||
sys.modules['winmixer'] = sys.modules['pysdlsound.winmixer']
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
native_midi: Hardware Midi support for the SDL_mixer library
|
||||
Copyright (C) 2000 Florian 'Proff' Schulze
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Florian 'Proff' Schulze
|
||||
florian.proff.schulze@gmx.net
|
||||
*/
|
||||
|
||||
#ifndef _NATIVE_MIDI_H_
|
||||
#define _NATIVE_MIDI_H_
|
||||
|
||||
#include <SDL/SDL_rwops.h>
|
||||
|
||||
typedef struct _NativeMidiSong NativeMidiSong;
|
||||
|
||||
int native_midi_detect();
|
||||
NativeMidiSong *native_midi_loadsong(char *midifile);
|
||||
NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *rw);
|
||||
void native_midi_freesong(NativeMidiSong *song);
|
||||
void native_midi_start(NativeMidiSong *song);
|
||||
void native_midi_stop();
|
||||
int native_midi_active();
|
||||
void native_midi_setvolume(int volume);
|
||||
char *native_midi_error();
|
||||
|
||||
#endif /* _NATIVE_MIDI_H_ */
|
||||
@@ -1,404 +0,0 @@
|
||||
/*
|
||||
native_midi: Hardware Midi support for the SDL_mixer library
|
||||
Copyright (C) 2000,2001 Florian 'Proff' Schulze
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Florian 'Proff' Schulze
|
||||
florian.proff.schulze@gmx.net
|
||||
*/
|
||||
|
||||
|
||||
#include "native_midi_common.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
/* The maximum number of midi tracks that we can handle
|
||||
#define MIDI_TRACKS 32 */
|
||||
|
||||
|
||||
/* A single midi track as read from the midi file */
|
||||
typedef struct
|
||||
{
|
||||
Uint8 *data; /* MIDI message stream */
|
||||
int len; /* length of the track data */
|
||||
} MIDITrack;
|
||||
|
||||
/* A midi file, stripped down to the absolute minimum - divison & track data */
|
||||
typedef struct
|
||||
{
|
||||
int division; /* number of pulses per quarter note (ppqn) */
|
||||
int nTracks; /* number of tracks */
|
||||
MIDITrack *track; /* tracks */
|
||||
} MIDIFile;
|
||||
|
||||
|
||||
/* Some macros that help us stay endianess-independant */
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
#define BE_SHORT(x) (x)
|
||||
#define BE_LONG(x) (x)
|
||||
#else
|
||||
#define BE_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
|
||||
#define BE_LONG(x) ((((x)&0x0000FF)<<24) | \
|
||||
(((x)&0x00FF00)<<8) | \
|
||||
(((x)&0xFF0000)>>8) | \
|
||||
(((x)>>24)&0xFF))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Get Variable Length Quantity */
|
||||
static int GetVLQ(MIDITrack *track, int *currentPos)
|
||||
{
|
||||
int l = 0;
|
||||
Uint8 c;
|
||||
while(1)
|
||||
{
|
||||
c = track->data[*currentPos];
|
||||
(*currentPos)++;
|
||||
l += (c & 0x7f);
|
||||
if (!(c & 0x80))
|
||||
return l;
|
||||
l <<= 7;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a single MIDIEvent */
|
||||
static MIDIEvent *CreateEvent(Uint32 time, Uint8 event, Uint8 a, Uint8 b)
|
||||
{
|
||||
MIDIEvent *newEvent;
|
||||
|
||||
newEvent = calloc(1, sizeof(MIDIEvent));
|
||||
|
||||
if (newEvent)
|
||||
{
|
||||
newEvent->time = time;
|
||||
newEvent->status = event;
|
||||
newEvent->data[0] = a;
|
||||
newEvent->data[1] = b;
|
||||
}
|
||||
|
||||
return newEvent;
|
||||
}
|
||||
|
||||
/* Convert a single midi track to a list of MIDIEvents */
|
||||
static MIDIEvent *MIDITracktoStream(MIDITrack *track)
|
||||
{
|
||||
Uint32 atime = 0;
|
||||
Uint32 len = 0;
|
||||
Uint8 event,type,a,b;
|
||||
Uint8 laststatus = 0;
|
||||
Uint8 lastchan = 0;
|
||||
int currentPos = 0;
|
||||
int end = 0;
|
||||
MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */
|
||||
MIDIEvent *currentEvent = head;
|
||||
|
||||
while (!end)
|
||||
{
|
||||
if (currentPos >= track->len)
|
||||
break; /* End of data stream reached */
|
||||
|
||||
atime += GetVLQ(track, ¤tPos);
|
||||
event = track->data[currentPos++];
|
||||
|
||||
/* Handle SysEx seperatly */
|
||||
if (((event>>4) & 0x0F) == MIDI_STATUS_SYSEX)
|
||||
{
|
||||
if (event == 0xFF)
|
||||
{
|
||||
type = track->data[currentPos];
|
||||
currentPos++;
|
||||
switch(type)
|
||||
{
|
||||
case 0x2f: /* End of data marker */
|
||||
end = 1;
|
||||
case 0x51: /* Tempo change */
|
||||
/*
|
||||
a=track->data[currentPos];
|
||||
b=track->data[currentPos+1];
|
||||
c=track->data[currentPos+2];
|
||||
AddEvent(song, atime, MEVT_TEMPO, c, b, a);
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
type = 0;
|
||||
|
||||
len = GetVLQ(track, ¤tPos);
|
||||
|
||||
/* Create an event and attach the extra data, if any */
|
||||
currentEvent->next = CreateEvent(atime, event, type, 0);
|
||||
currentEvent = currentEvent->next;
|
||||
if (NULL == currentEvent)
|
||||
{
|
||||
FreeMIDIEventList(head);
|
||||
return NULL;
|
||||
}
|
||||
if (len)
|
||||
{
|
||||
currentEvent->extraLen = len;
|
||||
currentEvent->extraData = malloc(len);
|
||||
memcpy(currentEvent->extraData, &(track->data[currentPos]), len);
|
||||
currentPos += len;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
a = event;
|
||||
if (a & 0x80) /* It's a status byte */
|
||||
{
|
||||
/* Extract channel and status information */
|
||||
lastchan = a & 0x0F;
|
||||
laststatus = (a>>4) & 0x0F;
|
||||
|
||||
/* Read the next byte which should always be a data byte */
|
||||
a = track->data[currentPos++] & 0x7F;
|
||||
}
|
||||
switch(laststatus)
|
||||
{
|
||||
case MIDI_STATUS_NOTE_OFF:
|
||||
case MIDI_STATUS_NOTE_ON: /* Note on */
|
||||
case MIDI_STATUS_AFTERTOUCH: /* Key Pressure */
|
||||
case MIDI_STATUS_CONTROLLER: /* Control change */
|
||||
case MIDI_STATUS_PITCH_WHEEL: /* Pitch wheel */
|
||||
b = track->data[currentPos++] & 0x7F;
|
||||
currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, b);
|
||||
currentEvent = currentEvent->next;
|
||||
if (NULL == currentEvent)
|
||||
{
|
||||
FreeMIDIEventList(head);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case MIDI_STATUS_PROG_CHANGE: /* Program change */
|
||||
case MIDI_STATUS_PRESSURE: /* Channel pressure */
|
||||
a &= 0x7f;
|
||||
currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, 0);
|
||||
currentEvent = currentEvent->next;
|
||||
if (NULL == currentEvent)
|
||||
{
|
||||
FreeMIDIEventList(head);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* Sysex already handled above */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentEvent = head->next;
|
||||
free(head); /* release the dummy head event */
|
||||
return currentEvent;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a midi song, consisting of up to 32 tracks, to a list of MIDIEvents.
|
||||
* To do so, first convert the tracks seperatly, then interweave the resulting
|
||||
* MIDIEvent-Lists to one big list.
|
||||
*/
|
||||
static MIDIEvent *MIDItoStream(MIDIFile *mididata)
|
||||
{
|
||||
MIDIEvent **track;
|
||||
MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */
|
||||
MIDIEvent *currentEvent = head;
|
||||
int trackID;
|
||||
|
||||
if (NULL == head)
|
||||
return NULL;
|
||||
|
||||
track = (MIDIEvent**) calloc(1, sizeof(MIDIEvent*) * mididata->nTracks);
|
||||
if (NULL == head)
|
||||
return NULL;
|
||||
|
||||
/* First, convert all tracks to MIDIEvent lists */
|
||||
for (trackID = 0; trackID < mididata->nTracks; trackID++)
|
||||
track[trackID] = MIDITracktoStream(&mididata->track[trackID]);
|
||||
|
||||
/* Now, merge the lists. */
|
||||
/* TODO */
|
||||
while(1)
|
||||
{
|
||||
Uint32 lowestTime = INT_MAX;
|
||||
int currentTrackID = -1;
|
||||
|
||||
/* Find the next event */
|
||||
for (trackID = 0; trackID < mididata->nTracks; trackID++)
|
||||
{
|
||||
if (track[trackID] && (track[trackID]->time < lowestTime))
|
||||
{
|
||||
currentTrackID = trackID;
|
||||
lowestTime = track[currentTrackID]->time;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we processes all events */
|
||||
if (currentTrackID == -1)
|
||||
break;
|
||||
|
||||
currentEvent->next = track[currentTrackID];
|
||||
track[currentTrackID] = track[currentTrackID]->next;
|
||||
|
||||
currentEvent = currentEvent->next;
|
||||
|
||||
|
||||
lowestTime = 0;
|
||||
}
|
||||
|
||||
/* Make sure the list is properly terminated */
|
||||
currentEvent->next = 0;
|
||||
|
||||
currentEvent = head->next;
|
||||
free(track);
|
||||
free(head); /* release the dummy head event */
|
||||
return currentEvent;
|
||||
}
|
||||
|
||||
static int ReadMIDIFile(MIDIFile *mididata, SDL_RWops *rw)
|
||||
{
|
||||
int i = 0;
|
||||
Uint32 ID;
|
||||
Uint32 size;
|
||||
Uint16 format;
|
||||
Uint16 tracks;
|
||||
Uint16 division;
|
||||
|
||||
if (!mididata)
|
||||
return 0;
|
||||
if (!rw)
|
||||
return 0;
|
||||
|
||||
/* Make sure this is really a MIDI file */
|
||||
SDL_RWread(rw, &ID, 1, 4);
|
||||
if (BE_LONG(ID) != 'MThd')
|
||||
return 0;
|
||||
|
||||
/* Header size must be 6 */
|
||||
SDL_RWread(rw, &size, 1, 4);
|
||||
size = BE_LONG(size);
|
||||
if (size != 6)
|
||||
return 0;
|
||||
|
||||
/* We only support format 0 and 1, but not 2 */
|
||||
SDL_RWread(rw, &format, 1, 2);
|
||||
format = BE_SHORT(format);
|
||||
if (format != 0 && format != 1)
|
||||
return 0;
|
||||
|
||||
SDL_RWread(rw, &tracks, 1, 2);
|
||||
tracks = BE_SHORT(tracks);
|
||||
mididata->nTracks = tracks;
|
||||
|
||||
/* Allocate tracks */
|
||||
mididata->track = (MIDITrack*) calloc(1, sizeof(MIDITrack) * mididata->nTracks);
|
||||
if (NULL == mididata->track)
|
||||
{
|
||||
goto bail;
|
||||
}
|
||||
|
||||
/* Retrieve the PPQN value, needed for playback */
|
||||
SDL_RWread(rw, &division, 1, 2);
|
||||
mididata->division = BE_SHORT(division);
|
||||
|
||||
|
||||
for (i=0; i<tracks; i++)
|
||||
{
|
||||
SDL_RWread(rw, &ID, 1, 4); /* We might want to verify this is MTrk... */
|
||||
SDL_RWread(rw, &size, 1, 4);
|
||||
size = BE_LONG(size);
|
||||
mididata->track[i].len = size;
|
||||
mididata->track[i].data = malloc(size);
|
||||
if (NULL == mididata->track[i].data)
|
||||
{
|
||||
goto bail;
|
||||
}
|
||||
SDL_RWread(rw, mididata->track[i].data, 1, size);
|
||||
}
|
||||
return 1;
|
||||
|
||||
bail:
|
||||
for(;i >= 0; i--)
|
||||
{
|
||||
if (mididata->track[i].data)
|
||||
free(mididata->track[i].data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
MIDIEvent *CreateMIDIEventList(SDL_RWops *rw, Uint16 *division)
|
||||
{
|
||||
MIDIFile *mididata = NULL;
|
||||
MIDIEvent *eventList;
|
||||
int trackID;
|
||||
|
||||
mididata = calloc(1, sizeof(MIDIFile));
|
||||
if (!mididata)
|
||||
return NULL;
|
||||
|
||||
/* Open the file */
|
||||
if ( rw != NULL )
|
||||
{
|
||||
/* Read in the data */
|
||||
if ( ! ReadMIDIFile(mididata, rw))
|
||||
{
|
||||
free(mididata);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free(mididata);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (division)
|
||||
*division = mididata->division;
|
||||
|
||||
eventList = MIDItoStream(mididata);
|
||||
|
||||
for(trackID = 0; trackID < mididata->nTracks; trackID++)
|
||||
{
|
||||
if (mididata->track[trackID].data)
|
||||
free(mididata->track[trackID].data);
|
||||
}
|
||||
free(mididata->track);
|
||||
free(mididata);
|
||||
|
||||
return eventList;
|
||||
}
|
||||
|
||||
void FreeMIDIEventList(MIDIEvent *head)
|
||||
{
|
||||
MIDIEvent *cur, *next;
|
||||
|
||||
cur = head;
|
||||
|
||||
while (cur)
|
||||
{
|
||||
next = cur->next;
|
||||
if (cur->extraData)
|
||||
free (cur->extraData);
|
||||
free (cur);
|
||||
cur = next;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
native_midi: Hardware Midi support for the SDL_mixer library
|
||||
Copyright (C) 2000,2001 Florian 'Proff' Schulze & Max Horn
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Florian 'Proff' Schulze
|
||||
florian.proff.schulze@gmx.net
|
||||
|
||||
Max Horn
|
||||
max@quendi.de
|
||||
*/
|
||||
|
||||
#ifndef _NATIVE_MIDI_COMMON_H_
|
||||
#define _NATIVE_MIDI_COMMON_H_
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
/* Midi Status Bytes */
|
||||
#define MIDI_STATUS_NOTE_OFF 0x8
|
||||
#define MIDI_STATUS_NOTE_ON 0x9
|
||||
#define MIDI_STATUS_AFTERTOUCH 0xA
|
||||
#define MIDI_STATUS_CONTROLLER 0xB
|
||||
#define MIDI_STATUS_PROG_CHANGE 0xC
|
||||
#define MIDI_STATUS_PRESSURE 0xD
|
||||
#define MIDI_STATUS_PITCH_WHEEL 0xE
|
||||
#define MIDI_STATUS_SYSEX 0xF
|
||||
|
||||
/* We store the midi events in a linked list; this way it is
|
||||
easy to shuffle the tracks together later on; and we are
|
||||
flexible in the size of each elemnt.
|
||||
*/
|
||||
typedef struct MIDIEvent
|
||||
{
|
||||
Uint32 time; /* Time at which this midi events occurs */
|
||||
Uint8 status; /* Status byte */
|
||||
Uint8 data[2]; /* 1 or 2 bytes additional data for most events */
|
||||
|
||||
Uint32 extraLen; /* For some SysEx events, we need additional storage */
|
||||
Uint8 *extraData;
|
||||
|
||||
struct MIDIEvent *next;
|
||||
} MIDIEvent;
|
||||
|
||||
|
||||
/* Load a midifile to memory, converting it to a list of MIDIEvents.
|
||||
This function returns a linked lists of MIDIEvents, 0 if an error occured.
|
||||
*/
|
||||
MIDIEvent *CreateMIDIEventList(SDL_RWops *rw, Uint16 *division);
|
||||
|
||||
/* Release a MIDIEvent list after usage. */
|
||||
void FreeMIDIEventList(MIDIEvent *head);
|
||||
|
||||
|
||||
#endif /* _NATIVE_MIDI_COMMON_H_ */
|
||||
@@ -1,707 +0,0 @@
|
||||
/*
|
||||
native_midi_mac: Native Midi support on MacOS for the SDL_mixer library
|
||||
Copyright (C) 2001 Max Horn
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Max Horn
|
||||
max@quendi.de
|
||||
*/
|
||||
|
||||
#ifndef MACOSX
|
||||
#define MACOSX
|
||||
#endif
|
||||
|
||||
#if defined(macintosh) || defined(MACOSX)
|
||||
|
||||
#include "native_midi.h"
|
||||
#include "native_midi_common.h"
|
||||
|
||||
#ifdef MACOSX
|
||||
#include <QuickTime/QuickTimeMusic.h>
|
||||
#else
|
||||
#include <QuickTimeMusic.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Native Midi song */
|
||||
struct _NativeMidiSong
|
||||
{
|
||||
Uint32 *tuneSequence;
|
||||
Uint32 *tuneHeader;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
/* number of (32-bit) long words in a note request event */
|
||||
kNoteRequestEventLength = ((sizeof(NoteRequest)/sizeof(long)) + 2),
|
||||
|
||||
/* number of (32-bit) long words in a marker event */
|
||||
kMarkerEventLength = 1,
|
||||
|
||||
/* number of (32-bit) long words in a general event, minus its data */
|
||||
kGeneralEventLength = 2
|
||||
};
|
||||
|
||||
#define ERROR_BUF_SIZE 256
|
||||
#define BUFFER_INCREMENT 5000
|
||||
|
||||
#define REST_IF_NECESSARY() do {\
|
||||
int timeDiff = eventPos->time - lastEventTime; \
|
||||
if(timeDiff) \
|
||||
{ \
|
||||
timeDiff = (int)(timeDiff*tick); \
|
||||
qtma_StuffRestEvent(*tunePos, timeDiff); \
|
||||
tunePos++; \
|
||||
lastEventTime = eventPos->time; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
static Uint32 *BuildTuneSequence(MIDIEvent *evntlist, int ppqn, int part_poly_max[32], int part_to_inst[32], int *numParts);
|
||||
static Uint32 *BuildTuneHeader(int part_poly_max[32], int part_to_inst[32], int numParts);
|
||||
|
||||
/* The global TunePlayer instance */
|
||||
static TunePlayer gTunePlayer = NULL;
|
||||
static int gInstaceCount = 0;
|
||||
static Uint32 *gCurrentTuneSequence = NULL;
|
||||
static char gErrorBuffer[ERROR_BUF_SIZE] = "";
|
||||
|
||||
|
||||
/* Check whether QuickTime is available */
|
||||
int native_midi_detect()
|
||||
{
|
||||
/* TODO */
|
||||
return 1;
|
||||
}
|
||||
|
||||
NativeMidiSong *native_midi_loadsong(char *midifile)
|
||||
{
|
||||
NativeMidiSong *song = NULL;
|
||||
MIDIEvent *evntlist = NULL;
|
||||
int part_to_inst[32];
|
||||
int part_poly_max[32];
|
||||
int numParts = 0;
|
||||
Uint16 ppqn;
|
||||
SDL_RWops *rw;
|
||||
|
||||
/* Init the arrays */
|
||||
memset(part_poly_max,0,sizeof(part_poly_max));
|
||||
memset(part_to_inst,-1,sizeof(part_to_inst));
|
||||
|
||||
/* Attempt to load the midi file */
|
||||
rw = SDL_RWFromFile(midifile, "rb");
|
||||
if (rw) {
|
||||
evntlist = CreateMIDIEventList(rw, &ppqn);
|
||||
SDL_RWclose(rw);
|
||||
if (!evntlist)
|
||||
goto bail;
|
||||
}
|
||||
|
||||
/* Allocate memory for the song struct */
|
||||
song = malloc(sizeof(NativeMidiSong));
|
||||
if (!song)
|
||||
goto bail;
|
||||
|
||||
/* Build a tune sequence from the event list */
|
||||
song->tuneSequence = BuildTuneSequence(evntlist, ppqn, part_poly_max, part_to_inst, &numParts);
|
||||
if(!song->tuneSequence)
|
||||
goto bail;
|
||||
|
||||
/* Now build a tune header from the data we collect above, create
|
||||
all parts as needed and assign them the correct instrument.
|
||||
*/
|
||||
song->tuneHeader = BuildTuneHeader(part_poly_max, part_to_inst, numParts);
|
||||
if(!song->tuneHeader)
|
||||
goto bail;
|
||||
|
||||
/* Increment the instance count */
|
||||
gInstaceCount++;
|
||||
if (gTunePlayer == NULL)
|
||||
gTunePlayer = OpenDefaultComponent(kTunePlayerComponentType, 0);
|
||||
|
||||
/* Finally, free the event list */
|
||||
FreeMIDIEventList(evntlist);
|
||||
|
||||
return song;
|
||||
|
||||
bail:
|
||||
if (evntlist)
|
||||
FreeMIDIEventList(evntlist);
|
||||
|
||||
if (song)
|
||||
{
|
||||
if(song->tuneSequence)
|
||||
free(song->tuneSequence);
|
||||
|
||||
if(song->tuneHeader)
|
||||
DisposePtr((Ptr)song->tuneHeader);
|
||||
|
||||
free(song);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *rw)
|
||||
{
|
||||
NativeMidiSong *song = NULL;
|
||||
MIDIEvent *evntlist = NULL;
|
||||
int part_to_inst[32];
|
||||
int part_poly_max[32];
|
||||
int numParts = 0;
|
||||
Uint16 ppqn;
|
||||
|
||||
/* Init the arrays */
|
||||
memset(part_poly_max,0,sizeof(part_poly_max));
|
||||
memset(part_to_inst,-1,sizeof(part_to_inst));
|
||||
|
||||
/* Attempt to load the midi file */
|
||||
evntlist = CreateMIDIEventList(rw, &ppqn);
|
||||
if (!evntlist)
|
||||
goto bail;
|
||||
|
||||
/* Allocate memory for the song struct */
|
||||
song = malloc(sizeof(NativeMidiSong));
|
||||
if (!song)
|
||||
goto bail;
|
||||
|
||||
/* Build a tune sequence from the event list */
|
||||
song->tuneSequence = BuildTuneSequence(evntlist, ppqn, part_poly_max, part_to_inst, &numParts);
|
||||
if(!song->tuneSequence)
|
||||
goto bail;
|
||||
|
||||
/* Now build a tune header from the data we collect above, create
|
||||
all parts as needed and assign them the correct instrument.
|
||||
*/
|
||||
song->tuneHeader = BuildTuneHeader(part_poly_max, part_to_inst, numParts);
|
||||
if(!song->tuneHeader)
|
||||
goto bail;
|
||||
|
||||
/* Increment the instance count */
|
||||
gInstaceCount++;
|
||||
if (gTunePlayer == NULL)
|
||||
gTunePlayer = OpenDefaultComponent(kTunePlayerComponentType, 0);
|
||||
|
||||
/* Finally, free the event list */
|
||||
FreeMIDIEventList(evntlist);
|
||||
|
||||
return song;
|
||||
|
||||
bail:
|
||||
if (evntlist)
|
||||
FreeMIDIEventList(evntlist);
|
||||
|
||||
if (song)
|
||||
{
|
||||
if(song->tuneSequence)
|
||||
free(song->tuneSequence);
|
||||
|
||||
if(song->tuneHeader)
|
||||
DisposePtr((Ptr)song->tuneHeader);
|
||||
|
||||
free(song);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void native_midi_freesong(NativeMidiSong *song)
|
||||
{
|
||||
if(!song || !song->tuneSequence)
|
||||
return;
|
||||
|
||||
/* If this is the currently playing song, stop it now */
|
||||
if (song->tuneSequence == gCurrentTuneSequence)
|
||||
native_midi_stop();
|
||||
|
||||
/* Finally, free the data storage */
|
||||
free(song->tuneSequence);
|
||||
DisposePtr((Ptr)song->tuneHeader);
|
||||
free(song);
|
||||
|
||||
/* Increment the instance count */
|
||||
gInstaceCount--;
|
||||
if ((gTunePlayer != NULL) && (gInstaceCount == 0))
|
||||
{
|
||||
CloseComponent(gTunePlayer);
|
||||
gTunePlayer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void native_midi_start(NativeMidiSong *song)
|
||||
{
|
||||
UInt32 queueFlags = 0;
|
||||
ComponentResult tpError;
|
||||
|
||||
assert (gTunePlayer != NULL);
|
||||
|
||||
SDL_PauseAudio(1);
|
||||
// SDL_UnlockAudio();
|
||||
|
||||
/* First, stop the currently playing music */
|
||||
native_midi_stop();
|
||||
|
||||
/* Set up the queue flags */
|
||||
queueFlags = kTuneStartNow;
|
||||
|
||||
/* Set the time scale (units per second), we want milliseconds */
|
||||
tpError = TuneSetTimeScale(gTunePlayer, 1000);
|
||||
if (tpError != noErr)
|
||||
{
|
||||
strncpy (gErrorBuffer, "MIDI error during TuneSetTimeScale", ERROR_BUF_SIZE);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Set the header, to tell what instruments are used */
|
||||
tpError = TuneSetHeader(gTunePlayer, (UInt32 *)song->tuneHeader);
|
||||
if (tpError != noErr)
|
||||
{
|
||||
strncpy (gErrorBuffer, "MIDI error during TuneSetHeader", ERROR_BUF_SIZE);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Have it allocate whatever resources are needed */
|
||||
tpError = TunePreroll(gTunePlayer);
|
||||
if (tpError != noErr)
|
||||
{
|
||||
strncpy (gErrorBuffer, "MIDI error during TunePreroll", ERROR_BUF_SIZE);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* We want to play at normal volume */
|
||||
tpError = TuneSetVolume(gTunePlayer, 0x00010000);
|
||||
if (tpError != noErr)
|
||||
{
|
||||
strncpy (gErrorBuffer, "MIDI error during TuneSetVolume", ERROR_BUF_SIZE);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Finally, start playing the full song */
|
||||
gCurrentTuneSequence = song->tuneSequence;
|
||||
tpError = TuneQueue(gTunePlayer, (UInt32 *)song->tuneSequence, 0x00010000, 0, 0xFFFFFFFF, queueFlags, NULL, 0);
|
||||
if (tpError != noErr)
|
||||
{
|
||||
strncpy (gErrorBuffer, "MIDI error during TuneQueue", ERROR_BUF_SIZE);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
1;
|
||||
// SDL_LockAudio();
|
||||
SDL_PauseAudio(0);
|
||||
}
|
||||
|
||||
void native_midi_stop()
|
||||
{
|
||||
if (gTunePlayer == NULL)
|
||||
return;
|
||||
|
||||
/* Stop music */
|
||||
TuneStop(gTunePlayer, 0);
|
||||
|
||||
/* Deallocate all instruments */
|
||||
TuneUnroll(gTunePlayer);
|
||||
}
|
||||
|
||||
int native_midi_active()
|
||||
{
|
||||
if (gTunePlayer != NULL)
|
||||
{
|
||||
TuneStatus ts;
|
||||
|
||||
TuneGetStatus(gTunePlayer,&ts);
|
||||
return ts.queueTime != 0;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void native_midi_setvolume(int volume)
|
||||
{
|
||||
if (gTunePlayer == NULL)
|
||||
return;
|
||||
|
||||
/* QTMA olume may range from 0.0 to 1.0 (in 16.16 fixed point encoding) */
|
||||
TuneSetVolume(gTunePlayer, (0x00010000 * volume)/SDL_MIX_MAXVOLUME);
|
||||
}
|
||||
|
||||
char *native_midi_error()
|
||||
{
|
||||
return gErrorBuffer;
|
||||
}
|
||||
|
||||
Uint32 *BuildTuneSequence(MIDIEvent *evntlist, int ppqn, int part_poly_max[32], int part_to_inst[32], int *numParts)
|
||||
{
|
||||
int part_poly[32];
|
||||
int channel_to_part[16];
|
||||
|
||||
int channel_pan[16];
|
||||
int channel_vol[16];
|
||||
int channel_pitch_bend[16];
|
||||
|
||||
int lastEventTime = 0;
|
||||
int tempo = 500000;
|
||||
double Ippqn = 1.0 / (1000*ppqn);
|
||||
double tick = tempo * Ippqn;
|
||||
MIDIEvent *eventPos = evntlist;
|
||||
MIDIEvent *noteOffPos;
|
||||
Uint32 *tunePos, *endPos;
|
||||
Uint32 *tuneSequence;
|
||||
size_t tuneSize;
|
||||
|
||||
/* allocate space for the tune header */
|
||||
tuneSize = 5000;
|
||||
tuneSequence = (Uint32 *)malloc(tuneSize * sizeof(Uint32));
|
||||
if (tuneSequence == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Set starting position in our tune memory */
|
||||
tunePos = tuneSequence;
|
||||
endPos = tuneSequence + tuneSize;
|
||||
|
||||
/* Initialise the arrays */
|
||||
memset(part_poly,0,sizeof(part_poly));
|
||||
|
||||
memset(channel_to_part,-1,sizeof(channel_to_part));
|
||||
memset(channel_pan,-1,sizeof(channel_pan));
|
||||
memset(channel_vol,-1,sizeof(channel_vol));
|
||||
memset(channel_pitch_bend,-1,sizeof(channel_pitch_bend));
|
||||
|
||||
*numParts = 0;
|
||||
|
||||
/*
|
||||
* Now the major work - iterate over all GM events,
|
||||
* and turn them into QuickTime Music format.
|
||||
* At the same time, calculate the max. polyphony for each part,
|
||||
* and also the part->instrument mapping.
|
||||
*/
|
||||
while(eventPos)
|
||||
{
|
||||
int status = (eventPos->status&0xF0)>>4;
|
||||
int channel = eventPos->status&0x0F;
|
||||
int part = channel_to_part[channel];
|
||||
int velocity, pitch;
|
||||
int value, controller;
|
||||
int bend;
|
||||
int newInst;
|
||||
|
||||
/* Check if we are running low on space... */
|
||||
if((tunePos+16) > endPos)
|
||||
{
|
||||
/* Resize our data storage. */
|
||||
Uint32 *oldTuneSequence = tuneSequence;
|
||||
|
||||
tuneSize += BUFFER_INCREMENT;
|
||||
tuneSequence = (Uint32 *)realloc(tuneSequence, tuneSize * sizeof(Uint32));
|
||||
if(oldTuneSequence != tuneSequence)
|
||||
tunePos += tuneSequence - oldTuneSequence;
|
||||
endPos = tuneSequence + tuneSize;
|
||||
}
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case MIDI_STATUS_NOTE_OFF:
|
||||
assert(part>=0 && part<=31);
|
||||
|
||||
/* Keep track of the polyphony of the current part */
|
||||
part_poly[part]--;
|
||||
break;
|
||||
case MIDI_STATUS_NOTE_ON:
|
||||
if (part < 0)
|
||||
{
|
||||
/* If no part is specified yet, we default to the first instrument, which
|
||||
is piano (or the first drum kit if we are on the drum channel)
|
||||
*/
|
||||
int newInst;
|
||||
|
||||
if (channel == 9)
|
||||
newInst = kFirstDrumkit + 1; /* the first drum kit is the "no drum" kit! */
|
||||
else
|
||||
newInst = kFirstGMInstrument;
|
||||
part = channel_to_part[channel] = *numParts;
|
||||
part_to_inst[(*numParts)++] = newInst;
|
||||
}
|
||||
/* TODO - add support for more than 32 parts using eXtended QTMA events */
|
||||
assert(part<=31);
|
||||
|
||||
/* Decode pitch & velocity */
|
||||
pitch = eventPos->data[0];
|
||||
velocity = eventPos->data[1];
|
||||
|
||||
if (velocity == 0)
|
||||
{
|
||||
/* was a NOTE OFF in disguise, so we decrement the polyphony */
|
||||
part_poly[part]--;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Keep track of the polyphony of the current part */
|
||||
int foo = ++part_poly[part];
|
||||
if (part_poly_max[part] < foo)
|
||||
part_poly_max[part] = foo;
|
||||
|
||||
/* Now scan forward to find the matching NOTE OFF event */
|
||||
for(noteOffPos = eventPos; noteOffPos; noteOffPos = noteOffPos->next)
|
||||
{
|
||||
if ((noteOffPos->status&0xF0)>>4 == MIDI_STATUS_NOTE_OFF
|
||||
&& channel == (eventPos->status&0x0F)
|
||||
&& pitch == noteOffPos->data[0])
|
||||
break;
|
||||
/* NOTE ON with velocity == 0 is the same as a NOTE OFF */
|
||||
if ((noteOffPos->status&0xF0)>>4 == MIDI_STATUS_NOTE_ON
|
||||
&& channel == (eventPos->status&0x0F)
|
||||
&& pitch == noteOffPos->data[0]
|
||||
&& 0 == noteOffPos->data[1])
|
||||
break;
|
||||
}
|
||||
|
||||
/* Did we find a note off? Should always be the case, but who knows... */
|
||||
if (noteOffPos)
|
||||
{
|
||||
/* We found a NOTE OFF, now calculate the note duration */
|
||||
int duration = (int)((noteOffPos->time - eventPos->time)*tick);
|
||||
|
||||
REST_IF_NECESSARY();
|
||||
/* Now we need to check if we get along with a normal Note Event, or if we need an extended one... */
|
||||
if (duration < 2048 && pitch>=32 && pitch<=95 && velocity>=0 && velocity<=127)
|
||||
{
|
||||
qtma_StuffNoteEvent(*tunePos, part, pitch, velocity, duration);
|
||||
tunePos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
qtma_StuffXNoteEvent(*tunePos, *(tunePos+1), part, pitch, velocity, duration);
|
||||
tunePos+=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MIDI_STATUS_AFTERTOUCH:
|
||||
/* NYI - use kControllerAfterTouch. But how are the parameters to be mapped? */
|
||||
break;
|
||||
case MIDI_STATUS_CONTROLLER:
|
||||
controller = eventPos->data[0];
|
||||
value = eventPos->data[1];
|
||||
|
||||
switch(controller)
|
||||
{
|
||||
case 0: /* bank change - igore for now */
|
||||
break;
|
||||
case kControllerVolume:
|
||||
if(channel_vol[channel] != value<<8)
|
||||
{
|
||||
channel_vol[channel] = value<<8;
|
||||
if(part>=0 && part<=31)
|
||||
{
|
||||
REST_IF_NECESSARY();
|
||||
qtma_StuffControlEvent(*tunePos, part, kControllerVolume, channel_vol[channel]);
|
||||
tunePos++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kControllerPan:
|
||||
if(channel_pan[channel] != (value << 1) + 256)
|
||||
{
|
||||
channel_pan[channel] = (value << 1) + 256;
|
||||
if(part>=0 && part<=31)
|
||||
{
|
||||
REST_IF_NECESSARY();
|
||||
qtma_StuffControlEvent(*tunePos, part, kControllerPan, channel_pan[channel]);
|
||||
tunePos++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* No other controllers implemented yet */;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case MIDI_STATUS_PROG_CHANGE:
|
||||
/* Instrument changed */
|
||||
newInst = eventPos->data[0];
|
||||
|
||||
/* Channel 9 (the 10th channel) is different, it indicates a drum kit */
|
||||
if (channel == 9)
|
||||
newInst += kFirstDrumkit;
|
||||
else
|
||||
newInst += kFirstGMInstrument;
|
||||
/* Only if the instrument for this channel *really* changed, add a new part. */
|
||||
if(newInst != part_to_inst[part])
|
||||
{
|
||||
/* TODO maybe make use of kGeneralEventPartChange here,
|
||||
to help QT reuse note channels?
|
||||
*/
|
||||
part = channel_to_part[channel] = *numParts;
|
||||
part_to_inst[(*numParts)++] = newInst;
|
||||
|
||||
if(channel_vol[channel] >= 0)
|
||||
{
|
||||
REST_IF_NECESSARY();
|
||||
qtma_StuffControlEvent(*tunePos, part, kControllerVolume, channel_vol[channel]);
|
||||
tunePos++;
|
||||
}
|
||||
if(channel_pan[channel] >= 0)
|
||||
{
|
||||
REST_IF_NECESSARY();
|
||||
qtma_StuffControlEvent(*tunePos, part, kControllerPan, channel_pan[channel]);
|
||||
tunePos++;
|
||||
}
|
||||
if(channel_pitch_bend[channel] >= 0)
|
||||
{
|
||||
REST_IF_NECESSARY();
|
||||
qtma_StuffControlEvent(*tunePos, part, kControllerPitchBend, channel_pitch_bend[channel]);
|
||||
tunePos++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MIDI_STATUS_PRESSURE:
|
||||
/* NYI */
|
||||
break;
|
||||
case MIDI_STATUS_PITCH_WHEEL:
|
||||
/* In the midi spec, 0x2000 = center, 0x0000 = - 2 semitones, 0x3FFF = +2 semitones
|
||||
but for QTMA, we specify it as a 8.8 fixed point of semitones
|
||||
TODO: detect "pitch bend range changes" & honor them!
|
||||
*/
|
||||
bend = (eventPos->data[0] & 0x7f) | ((eventPos->data[1] & 0x7f) << 7);
|
||||
|
||||
/* "Center" the bend */
|
||||
bend -= 0x2000;
|
||||
|
||||
/* Move it to our format: */
|
||||
bend <<= 4;
|
||||
|
||||
/* If it turns out the pitch bend didn't change, stop here */
|
||||
if(channel_pitch_bend[channel] == bend)
|
||||
break;
|
||||
|
||||
channel_pitch_bend[channel] = bend;
|
||||
if(part>=0 && part<=31)
|
||||
{
|
||||
/* Stuff a control event */
|
||||
REST_IF_NECESSARY();
|
||||
qtma_StuffControlEvent(*tunePos, part, kControllerPitchBend, bend);
|
||||
tunePos++;
|
||||
}
|
||||
break;
|
||||
case MIDI_STATUS_SYSEX:
|
||||
if (eventPos->status == 0xFF && eventPos->data[0] == 0x51) /* Tempo change */
|
||||
{
|
||||
tempo = (eventPos->extraData[0] << 16) +
|
||||
(eventPos->extraData[1] << 8) +
|
||||
eventPos->extraData[2];
|
||||
|
||||
tick = tempo * Ippqn;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* on to the next event */
|
||||
eventPos = eventPos->next;
|
||||
}
|
||||
|
||||
/* Finally, place an end marker */
|
||||
*tunePos = kEndMarkerValue;
|
||||
|
||||
return tuneSequence;
|
||||
}
|
||||
|
||||
Uint32 *BuildTuneHeader(int part_poly_max[32], int part_to_inst[32], int numParts)
|
||||
{
|
||||
Uint32 *myHeader;
|
||||
Uint32 *myPos1, *myPos2; /* pointers to the head and tail long words of a music event */
|
||||
NoteRequest *myNoteRequest;
|
||||
NoteAllocator myNoteAllocator; /* for the NAStuffToneDescription call */
|
||||
ComponentResult myErr = noErr;
|
||||
int part;
|
||||
|
||||
myHeader = NULL;
|
||||
myNoteAllocator = NULL;
|
||||
|
||||
/*
|
||||
* Open up the Note Allocator
|
||||
*/
|
||||
myNoteAllocator = OpenDefaultComponent(kNoteAllocatorComponentType,0);
|
||||
if (myNoteAllocator == NULL)
|
||||
goto bail;
|
||||
|
||||
/*
|
||||
* Allocate space for the tune header
|
||||
*/
|
||||
myHeader = (Uint32 *)
|
||||
NewPtrClear((numParts * kNoteRequestEventLength + kMarkerEventLength) * sizeof(Uint32));
|
||||
if (myHeader == NULL)
|
||||
goto bail;
|
||||
|
||||
myPos1 = myHeader;
|
||||
|
||||
/*
|
||||
* Loop over all parts
|
||||
*/
|
||||
for(part = 0; part < numParts; ++part)
|
||||
{
|
||||
/*
|
||||
* Stuff request for the instrument with the given polyphony
|
||||
*/
|
||||
myPos2 = myPos1 + (kNoteRequestEventLength - 1); /* last longword of general event */
|
||||
qtma_StuffGeneralEvent(*myPos1, *myPos2, part, kGeneralEventNoteRequest, kNoteRequestEventLength);
|
||||
myNoteRequest = (NoteRequest *)(myPos1 + 1);
|
||||
myNoteRequest->info.flags = 0;
|
||||
/* I'm told by the Apple people that the Quicktime types were poorly designed and it was
|
||||
* too late to change them. On little endian, the BigEndian(Short|Fixed) types are structs
|
||||
* while on big endian they are primitive types. Furthermore, Quicktime failed to
|
||||
* provide setter and getter functions. To get this to work, we need to case the
|
||||
* code for the two possible situations.
|
||||
* My assumption is that the right-side value was always expected to be BigEndian
|
||||
* as it was written way before the Universal Binary transition. So in the little endian
|
||||
* case, OSSwap is used.
|
||||
*/
|
||||
#if __LITTLE_ENDIAN__
|
||||
myNoteRequest->info.polyphony.bigEndianValue = OSSwapHostToBigInt16(part_poly_max[part]);
|
||||
myNoteRequest->info.typicalPolyphony.bigEndianValue = OSSwapHostToBigInt32(0x00010000);
|
||||
#else
|
||||
myNoteRequest->info.polyphony = part_poly_max[part];
|
||||
myNoteRequest->info.typicalPolyphony = 0x00010000;
|
||||
#endif
|
||||
myErr = NAStuffToneDescription(myNoteAllocator,part_to_inst[part],&myNoteRequest->tone);
|
||||
if (myErr != noErr)
|
||||
goto bail;
|
||||
|
||||
/* move pointer to beginning of next event */
|
||||
myPos1 += kNoteRequestEventLength;
|
||||
}
|
||||
|
||||
*myPos1 = kEndMarkerValue; /* end of sequence marker */
|
||||
|
||||
|
||||
bail:
|
||||
if(myNoteAllocator)
|
||||
CloseComponent(myNoteAllocator);
|
||||
|
||||
/* if we encountered an error, dispose of the storage we allocated and return NULL */
|
||||
if (myErr != noErr) {
|
||||
DisposePtr((Ptr)myHeader);
|
||||
myHeader = NULL;
|
||||
}
|
||||
|
||||
return myHeader;
|
||||
}
|
||||
|
||||
#endif /* MacOS native MIDI support */
|
||||
@@ -1,321 +0,0 @@
|
||||
/*
|
||||
native_midi: Hardware Midi support for the SDL_mixer library
|
||||
Copyright (C) 2000,2001 Florian 'Proff' Schulze
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Florian 'Proff' Schulze
|
||||
florian.proff.schulze@gmx.net
|
||||
*/
|
||||
|
||||
/* everything below is currently one very big bad hack ;) Proff */
|
||||
|
||||
#ifdef WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <mmsystem.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include "native_midi.h"
|
||||
#include "native_midi_common.h"
|
||||
|
||||
struct _NativeMidiSong {
|
||||
int MusicLoaded;
|
||||
int MusicPlaying;
|
||||
MIDIHDR MidiStreamHdr;
|
||||
MIDIEVENT *NewEvents;
|
||||
Uint16 ppqn;
|
||||
int Size;
|
||||
int NewPos;
|
||||
};
|
||||
|
||||
static UINT MidiDevice=MIDI_MAPPER;
|
||||
static HMIDISTRM hMidiStream;
|
||||
static NativeMidiSong *currentsong;
|
||||
|
||||
static int BlockOut(NativeMidiSong *song)
|
||||
{
|
||||
MMRESULT err;
|
||||
int BlockSize;
|
||||
|
||||
if ((song->MusicLoaded) && (song->NewEvents))
|
||||
{
|
||||
// proff 12/8/98: Added for savety
|
||||
midiOutUnprepareHeader((HMIDIOUT)hMidiStream,&song->MidiStreamHdr,sizeof(MIDIHDR));
|
||||
if (song->NewPos>=song->Size)
|
||||
return 0;
|
||||
BlockSize=(song->Size-song->NewPos);
|
||||
if (BlockSize<=0)
|
||||
return 0;
|
||||
if (BlockSize>36000)
|
||||
BlockSize=36000;
|
||||
song->MidiStreamHdr.lpData=(void *)((unsigned char *)song->NewEvents+song->NewPos);
|
||||
song->NewPos+=BlockSize;
|
||||
song->MidiStreamHdr.dwBufferLength=BlockSize;
|
||||
song->MidiStreamHdr.dwBytesRecorded=BlockSize;
|
||||
song->MidiStreamHdr.dwFlags=0;
|
||||
err=midiOutPrepareHeader((HMIDIOUT)hMidiStream,&song->MidiStreamHdr,sizeof(MIDIHDR));
|
||||
if (err!=MMSYSERR_NOERROR)
|
||||
return 0;
|
||||
err=midiStreamOut(hMidiStream,&song->MidiStreamHdr,sizeof(MIDIHDR));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void MIDItoStream(NativeMidiSong *song, MIDIEvent *evntlist)
|
||||
{
|
||||
int eventcount;
|
||||
MIDIEvent *event;
|
||||
MIDIEVENT *newevent;
|
||||
|
||||
eventcount=0;
|
||||
event=evntlist;
|
||||
while (event)
|
||||
{
|
||||
eventcount++;
|
||||
event=event->next;
|
||||
}
|
||||
song->NewEvents=malloc(eventcount*3*sizeof(DWORD));
|
||||
if (!song->NewEvents)
|
||||
return;
|
||||
memset(song->NewEvents,0,(eventcount*3*sizeof(DWORD)));
|
||||
|
||||
eventcount=0;
|
||||
event=evntlist;
|
||||
newevent=song->NewEvents;
|
||||
while (event)
|
||||
{
|
||||
int status = (event->status&0xF0)>>4;
|
||||
switch (status)
|
||||
{
|
||||
case MIDI_STATUS_NOTE_OFF:
|
||||
case MIDI_STATUS_NOTE_ON:
|
||||
case MIDI_STATUS_AFTERTOUCH:
|
||||
case MIDI_STATUS_CONTROLLER:
|
||||
case MIDI_STATUS_PROG_CHANGE:
|
||||
case MIDI_STATUS_PRESSURE:
|
||||
case MIDI_STATUS_PITCH_WHEEL:
|
||||
newevent->dwDeltaTime=event->time;
|
||||
newevent->dwEvent=(event->status|0x80)|(event->data[0]<<8)|(event->data[1]<<16)|(MEVT_SHORTMSG<<24);
|
||||
newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD)));
|
||||
eventcount++;
|
||||
break;
|
||||
|
||||
case MIDI_STATUS_SYSEX:
|
||||
if (event->status == 0xFF && event->data[0] == 0x51) /* Tempo change */
|
||||
{
|
||||
int tempo = (event->extraData[0] << 16) |
|
||||
(event->extraData[1] << 8) |
|
||||
event->extraData[2];
|
||||
newevent->dwDeltaTime=event->time;
|
||||
newevent->dwEvent=(MEVT_TEMPO<<24) | tempo;
|
||||
newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD)));
|
||||
eventcount++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
event=event->next;
|
||||
}
|
||||
|
||||
song->Size=eventcount*3*sizeof(DWORD);
|
||||
|
||||
{
|
||||
int time;
|
||||
int temptime;
|
||||
|
||||
song->NewPos=0;
|
||||
time=0;
|
||||
newevent=song->NewEvents;
|
||||
while (song->NewPos<song->Size)
|
||||
{
|
||||
temptime=newevent->dwDeltaTime;
|
||||
newevent->dwDeltaTime-=time;
|
||||
time=temptime;
|
||||
if ((song->NewPos+12)>=song->Size)
|
||||
newevent->dwEvent |= MEVT_F_CALLBACK;
|
||||
newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD)));
|
||||
song->NewPos+=12;
|
||||
}
|
||||
}
|
||||
song->NewPos=0;
|
||||
song->MusicLoaded=1;
|
||||
}
|
||||
|
||||
void CALLBACK MidiProc( HMIDIIN hMidi, UINT uMsg, DWORD dwInstance,
|
||||
DWORD dwParam1, DWORD dwParam2 )
|
||||
{
|
||||
switch( uMsg )
|
||||
{
|
||||
case MOM_DONE:
|
||||
if ((currentsong->MusicLoaded) && ((DWORD)dwParam1 == (DWORD)¤tsong->MidiStreamHdr))
|
||||
BlockOut(currentsong);
|
||||
break;
|
||||
case MOM_POSITIONCB:
|
||||
if ((currentsong->MusicLoaded) && ((DWORD)dwParam1 == (DWORD)¤tsong->MidiStreamHdr))
|
||||
currentsong->MusicPlaying=0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int native_midi_detect()
|
||||
{
|
||||
MMRESULT merr;
|
||||
HMIDISTRM MidiStream;
|
||||
|
||||
merr=midiStreamOpen(&MidiStream,&MidiDevice,1,(DWORD)&MidiProc,0,CALLBACK_FUNCTION);
|
||||
if (merr!=MMSYSERR_NOERROR)
|
||||
MidiStream=0;
|
||||
midiStreamClose(MidiStream);
|
||||
if (!MidiStream)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
NativeMidiSong *native_midi_loadsong(char *midifile)
|
||||
{
|
||||
NativeMidiSong *newsong;
|
||||
MIDIEvent *evntlist = NULL;
|
||||
SDL_RWops *rw;
|
||||
|
||||
newsong=malloc(sizeof(NativeMidiSong));
|
||||
if (!newsong)
|
||||
return NULL;
|
||||
memset(newsong,0,sizeof(NativeMidiSong));
|
||||
|
||||
/* Attempt to load the midi file */
|
||||
rw = SDL_RWFromFile(midifile, "rb");
|
||||
if (rw) {
|
||||
evntlist = CreateMIDIEventList(rw, &newsong->ppqn);
|
||||
SDL_RWclose(rw);
|
||||
if (!evntlist)
|
||||
{
|
||||
free(newsong);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
MIDItoStream(newsong, evntlist);
|
||||
|
||||
FreeMIDIEventList(evntlist);
|
||||
|
||||
return newsong;
|
||||
}
|
||||
|
||||
NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *rw)
|
||||
{
|
||||
NativeMidiSong *newsong;
|
||||
MIDIEvent *evntlist = NULL;
|
||||
|
||||
newsong=malloc(sizeof(NativeMidiSong));
|
||||
if (!newsong)
|
||||
return NULL;
|
||||
memset(newsong,0,sizeof(NativeMidiSong));
|
||||
|
||||
/* Attempt to load the midi file */
|
||||
evntlist = CreateMIDIEventList(rw, &newsong->ppqn);
|
||||
if (!evntlist)
|
||||
{
|
||||
free(newsong);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MIDItoStream(newsong, evntlist);
|
||||
|
||||
FreeMIDIEventList(evntlist);
|
||||
|
||||
return newsong;
|
||||
}
|
||||
|
||||
void native_midi_freesong(NativeMidiSong *song)
|
||||
{
|
||||
if (hMidiStream)
|
||||
{
|
||||
midiStreamStop(hMidiStream);
|
||||
midiStreamClose(hMidiStream);
|
||||
}
|
||||
if (song)
|
||||
{
|
||||
if (song->NewEvents)
|
||||
free(song->NewEvents);
|
||||
free(song);
|
||||
}
|
||||
}
|
||||
|
||||
void native_midi_start(NativeMidiSong *song)
|
||||
{
|
||||
MMRESULT merr;
|
||||
MIDIPROPTIMEDIV mptd;
|
||||
|
||||
native_midi_stop();
|
||||
if (!hMidiStream)
|
||||
{
|
||||
merr=midiStreamOpen(&hMidiStream,&MidiDevice,1,(DWORD)&MidiProc,0,CALLBACK_FUNCTION);
|
||||
if (merr!=MMSYSERR_NOERROR)
|
||||
{
|
||||
hMidiStream=0;
|
||||
return;
|
||||
}
|
||||
//midiStreamStop(hMidiStream);
|
||||
currentsong=song;
|
||||
currentsong->NewPos=0;
|
||||
currentsong->MusicPlaying=1;
|
||||
mptd.cbStruct=sizeof(MIDIPROPTIMEDIV);
|
||||
mptd.dwTimeDiv=currentsong->ppqn;
|
||||
merr=midiStreamProperty(hMidiStream,(LPBYTE)&mptd,MIDIPROP_SET | MIDIPROP_TIMEDIV);
|
||||
BlockOut(song);
|
||||
merr=midiStreamRestart(hMidiStream);
|
||||
}
|
||||
}
|
||||
|
||||
void native_midi_stop()
|
||||
{
|
||||
if (!hMidiStream)
|
||||
return;
|
||||
midiStreamStop(hMidiStream);
|
||||
midiStreamClose(hMidiStream);
|
||||
currentsong=NULL;
|
||||
hMidiStream = 0;
|
||||
}
|
||||
|
||||
int native_midi_active()
|
||||
{
|
||||
return currentsong->MusicPlaying;
|
||||
}
|
||||
|
||||
void native_midi_setvolume(int volume)
|
||||
{
|
||||
int calcVolume;
|
||||
if (volume > 128)
|
||||
volume = 128;
|
||||
if (volume < 0)
|
||||
volume = 0;
|
||||
calcVolume = (65535 * volume / 128);
|
||||
|
||||
midiOutSetVolume((HMIDIOUT)hMidiStream, MAKELONG(calcVolume , calcVolume));
|
||||
}
|
||||
|
||||
char *native_midi_error()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
#endif /* Windows native MIDI support */
|
||||
@@ -1,104 +0,0 @@
|
||||
# Copyright 2005 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.
|
||||
|
||||
cdef extern from "pss.h":
|
||||
|
||||
cdef struct SDL_RWops:
|
||||
int (* close)(SDL_RWops *)
|
||||
|
||||
SDL_RWops* RWopsFromPython(object obj)
|
||||
|
||||
cdef int SDL_GetTicks()
|
||||
|
||||
cdef extern from "native_midi.h":
|
||||
|
||||
cdef struct _NativeMidiSong:
|
||||
pass
|
||||
|
||||
ctypedef _NativeMidiSong NativeMidiSong
|
||||
|
||||
int native_midi_detect()
|
||||
NativeMidiSong *native_midi_loadsong(char *midifile)
|
||||
NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *rw)
|
||||
void native_midi_freesong(NativeMidiSong *song)
|
||||
void native_midi_start(NativeMidiSong *song)
|
||||
void native_midi_stop()
|
||||
int native_midi_active()
|
||||
void native_midi_setvolume(int volume)
|
||||
char *native_midi_error()
|
||||
|
||||
cdef NativeMidiSong *current
|
||||
cdef int start
|
||||
|
||||
current = NULL
|
||||
|
||||
def init():
|
||||
if not native_midi_detect():
|
||||
raise Exception("Could not initialize native midi support.")
|
||||
|
||||
def play(file):
|
||||
cdef SDL_RWops *rw
|
||||
|
||||
if current:
|
||||
stop()
|
||||
|
||||
rw = RWopsFromPython(file)
|
||||
|
||||
if rw == NULL:
|
||||
raise Exception, "Could not create RWops."
|
||||
|
||||
global current
|
||||
current = native_midi_loadsong_RW(rw)
|
||||
|
||||
rw.close(rw)
|
||||
|
||||
if current == NULL:
|
||||
raise Exception, "Could not load midi file."
|
||||
|
||||
global start
|
||||
start = SDL_GetTicks()
|
||||
native_midi_start(current)
|
||||
|
||||
|
||||
def stop():
|
||||
|
||||
global current
|
||||
|
||||
if not current:
|
||||
return
|
||||
|
||||
native_midi_stop()
|
||||
native_midi_freesong(current)
|
||||
current = NULL
|
||||
|
||||
def busy():
|
||||
return native_midi_active()
|
||||
|
||||
def get_pos():
|
||||
|
||||
if not busy():
|
||||
return -1
|
||||
|
||||
return SDL_GetTicks() - start
|
||||
|
||||
def set_volume(volume):
|
||||
native_midi_setvolume(int(volume * 128))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2005 PyTom <pytom@bishoujo.us>
|
||||
Copyright 2005-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
|
||||
@@ -24,9 +24,19 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#include "pss.h"
|
||||
#include <Python.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_sound.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Declarations of ffdecode functions. */
|
||||
struct VideoState;
|
||||
|
||||
struct VideoState *ffpy_stream_open(SDL_RWops *, const char *);
|
||||
void ffpy_stream_close(struct VideoState *is);
|
||||
void ffpy_alloc_event(struct VideoState *vs, PyObject *surface);
|
||||
void ffpy_refresh_event(struct VideoState *vs);
|
||||
void ffpy_init(int rate, int status);
|
||||
int ffpy_audio_decode(struct VideoState *is, Uint8 *stream, int len);
|
||||
|
||||
|
||||
/* The current Python. */
|
||||
PyInterpreterState* interp;
|
||||
PyThreadState* thread = NULL;
|
||||
@@ -52,6 +62,10 @@ static void decref(PyObject *ref) {
|
||||
}
|
||||
|
||||
/* Locking on entry from python... */
|
||||
// #define BEGIN() PyThreadState *_save;
|
||||
// #define ENTER() { printf("Locking by %s.\n", __FUNCTION__); _save = PyEval_SaveThread(); SDL_LockAudio(); printf("Lock by %s\n", __FUNCTION__); }
|
||||
// #define EXIT() { SDL_UnlockAudio(); PyEval_RestoreThread(_save); printf("Release by %s\n", __FUNCTION__); }
|
||||
|
||||
#define BEGIN() PyThreadState *_save;
|
||||
#define ENTER() { _save = PyEval_SaveThread(); SDL_LockAudio(); }
|
||||
#define EXIT() { SDL_UnlockAudio(); PyEval_RestoreThread(_save); }
|
||||
@@ -60,9 +74,6 @@ static void decref(PyObject *ref) {
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
/* The number of channels we support. */
|
||||
#define NUM_CHANNELS 8
|
||||
|
||||
/* Various error codes. */
|
||||
#define SUCCESS 0
|
||||
#define SDL_ERROR -1
|
||||
@@ -86,7 +97,7 @@ struct Channel {
|
||||
|
||||
/* The currently playing sample, NULL if this sample isn't playing
|
||||
anything. */
|
||||
Sound_Sample *playing;
|
||||
struct VideoState *playing;
|
||||
|
||||
/* The name of the playing music. */
|
||||
PyObject *playing_name;
|
||||
@@ -98,7 +109,7 @@ struct Channel {
|
||||
int playing_tight;
|
||||
|
||||
/* The queued up sample. */
|
||||
Sound_Sample *queued;
|
||||
struct VideoState *queued;
|
||||
|
||||
/* The name of the queued up sample. */
|
||||
PyObject *queued_name;
|
||||
@@ -115,12 +126,6 @@ struct Channel {
|
||||
/* The volume of the channel. */
|
||||
int volume;
|
||||
|
||||
/* The number of decoded bytes in the buffer. */
|
||||
int decoded;
|
||||
|
||||
/* The offset into the buffer that we last stopped at. */
|
||||
int last;
|
||||
|
||||
/* The position (in bytes) that this channel has queued to. */
|
||||
int pos;
|
||||
|
||||
@@ -154,12 +159,32 @@ struct Channel {
|
||||
|
||||
/* The number of samples we've finished in the current pan. */
|
||||
unsigned int pan_done;
|
||||
|
||||
|
||||
/* These are used like in pan, above. Unlike the volume parameter,
|
||||
the voulme set here is persisted between sessions. */
|
||||
float vol2_start;
|
||||
float vol2_end;
|
||||
unsigned int vol2_length;
|
||||
unsigned int vol2_done;
|
||||
};
|
||||
|
||||
struct Dying {
|
||||
struct VideoState *stream;
|
||||
struct Dying *next;
|
||||
};
|
||||
|
||||
static struct Dying *dying = NULL;
|
||||
|
||||
/*
|
||||
* The number of channels the system knows about.
|
||||
*/
|
||||
int num_channels = 0;
|
||||
|
||||
/*
|
||||
* All of the channels that the system knows about.
|
||||
*/
|
||||
struct Channel channels[NUM_CHANNELS];
|
||||
struct Channel *channels = NULL;
|
||||
|
||||
/*
|
||||
* The spec of the audio that is playing.
|
||||
@@ -169,7 +194,7 @@ SDL_AudioSpec audio_spec;
|
||||
|
||||
static float interpolate_pan(struct Channel *c) {
|
||||
float done;
|
||||
|
||||
|
||||
if (c->pan_done > c->pan_length) {
|
||||
c->pan_length = 0;
|
||||
}
|
||||
@@ -184,6 +209,22 @@ static float interpolate_pan(struct Channel *c) {
|
||||
|
||||
}
|
||||
|
||||
static float interpolate_vol2(struct Channel *c) {
|
||||
float done;
|
||||
|
||||
if (c->vol2_done > c->vol2_length) {
|
||||
c->vol2_length = 0;
|
||||
}
|
||||
|
||||
if (c->vol2_length == 0) {
|
||||
return c->vol2_end;
|
||||
}
|
||||
|
||||
done = 1.0 * c->vol2_done / c->vol2_length;
|
||||
|
||||
return c->vol2_start + done * (c->vol2_end - c->vol2_start);
|
||||
}
|
||||
|
||||
static int ms_to_bytes(int ms) {
|
||||
return ((long long) ms) * audio_spec.freq * audio_spec.channels * 2 / 1000;
|
||||
}
|
||||
@@ -197,8 +238,6 @@ static void start_sample(struct Channel* c, int reset_fade) {
|
||||
|
||||
if (!c) return;
|
||||
|
||||
c->decoded = 0;
|
||||
c->last = 0;
|
||||
c->pos = 0;
|
||||
|
||||
if (reset_fade) {
|
||||
@@ -211,54 +250,43 @@ static void start_sample(struct Channel* c, int reset_fade) {
|
||||
c->fade_off = 0;
|
||||
c->fade_vol = 0;
|
||||
|
||||
c->fade_step_len = ms_to_bytes(c->playing_fadein) / fade_steps;
|
||||
c->fade_step_len &= ~0x7; // Even sample.
|
||||
|
||||
if (fade_steps) {
|
||||
c->fade_step_len = ms_to_bytes(c->playing_fadein) / fade_steps;
|
||||
c->fade_step_len &= ~0x7; // Even sample.
|
||||
} else {
|
||||
c->fade_step_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
c->stop_bytes = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* static void update_pause(void) { */
|
||||
/* int i; */
|
||||
/* int pause = 1; */
|
||||
|
||||
/* for (i = 0; i < NUM_CHANNELS; i++) { */
|
||||
/* if (channels[i].playing) { */
|
||||
/* pause = 0; */
|
||||
/* break; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* SDL_PauseAudio(pause); */
|
||||
/* } */
|
||||
|
||||
static void free_sample(Sound_Sample *ss) {
|
||||
Sound_FreeSample(ss);
|
||||
static void free_sample(struct VideoState *ss) {
|
||||
ffpy_stream_close(ss);
|
||||
}
|
||||
|
||||
#define MAX_SHORT (32767)
|
||||
#define MIN_SHORT (-32768)
|
||||
|
||||
// Actually mixes the audio.
|
||||
static void mixaudio(Uint8 *dst, Uint8 *src, int length, int volume) {
|
||||
|
||||
// SDL_MixAudio may not work when length % 16 != 0.
|
||||
if ((length & 0x0f) == 0) {
|
||||
SDL_MixAudio(dst, src, length, volume);
|
||||
} else {
|
||||
int i;
|
||||
short *sdst = (short *) dst;
|
||||
short *ssrc = (short *) src;
|
||||
|
||||
int newlength = length + 16 - (length & 0xf);
|
||||
Uint8 newsrc[newlength];
|
||||
Uint8 newdst[newlength];
|
||||
|
||||
memcpy(newsrc, src, length);
|
||||
memcpy(newdst, dst, length);
|
||||
for (i = 0; i < length / 2; i++) {
|
||||
int sound = *sdst + (volume * *ssrc) / SDL_MIX_MAXVOLUME;
|
||||
if (sound > MAX_SHORT) {
|
||||
sound = MAX_SHORT;
|
||||
}
|
||||
if (sound < MIN_SHORT) {
|
||||
sound = MIN_SHORT;
|
||||
}
|
||||
|
||||
// Mix the audio once.
|
||||
SDL_MixAudio(newdst, newsrc, newlength, volume);
|
||||
|
||||
memcpy(dst, newdst, length);
|
||||
}
|
||||
*sdst++ = (short) sound;
|
||||
ssrc++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -267,7 +295,7 @@ static void fade_mixaudio(struct Channel *c,
|
||||
Uint8 *dst, Uint8 *src, int length) {
|
||||
|
||||
while (length) {
|
||||
|
||||
|
||||
// No fade case.
|
||||
if (c->fade_step_len == 0) {
|
||||
mixaudio(dst, src, length, c->volume);
|
||||
@@ -277,8 +305,9 @@ static void fade_mixaudio(struct Channel *c,
|
||||
// Fading, but we have some space left in the current step.
|
||||
if (c->fade_off < c->fade_step_len) {
|
||||
int l = min(c->fade_step_len - c->fade_off, length);
|
||||
mixaudio(dst, src, l, c->fade_vol);
|
||||
|
||||
mixaudio(dst, src, l, c->fade_vol);
|
||||
|
||||
length -= l;
|
||||
dst += l;
|
||||
src += l;
|
||||
@@ -302,7 +331,7 @@ static void fade_mixaudio(struct Channel *c,
|
||||
c->fade_step_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -317,12 +346,14 @@ static void post_event(struct Channel *c) {
|
||||
SDL_PushEvent(&e);
|
||||
}
|
||||
|
||||
/* This handels panning and vol2 manipulations. */
|
||||
static void pan_audio(struct Channel *c, Uint8 *stream, int length) {
|
||||
int i;
|
||||
short *sample = (short *) stream;
|
||||
length /= 4;
|
||||
|
||||
float pan;
|
||||
float vol2;
|
||||
int left = 256;
|
||||
int right = 256;
|
||||
|
||||
@@ -331,20 +362,25 @@ static void pan_audio(struct Channel *c, Uint8 *stream, int length) {
|
||||
|
||||
if ((i & 0x1f) == 0) {
|
||||
pan = interpolate_pan(c);
|
||||
|
||||
// If the pan is even, skip 32 samples and call it a day.
|
||||
if (pan == 0.0) {
|
||||
vol2 = interpolate_vol2(c);
|
||||
|
||||
// If nothing to do, skip 32 samples.
|
||||
if (pan == 0.0 && vol2 == 1.0) {
|
||||
i += 31;
|
||||
c->pan_done += 32;
|
||||
c->vol2_done += 32;
|
||||
sample += 32 * 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
vol2 *= 256.0;
|
||||
|
||||
if (pan < 0) {
|
||||
left = 256;
|
||||
right = (int) (256 * (1.0 + pan));
|
||||
left = (int) vol2;
|
||||
right = (int) (vol2 * (1.0 + pan));
|
||||
} else {
|
||||
left = (int) (256 * (1.0 - pan));
|
||||
right = 256;
|
||||
left = (int) (vol2 * (1.0 - pan));
|
||||
right = (int) vol2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,15 +391,17 @@ static void pan_audio(struct Channel *c, Uint8 *stream, int length) {
|
||||
sample++;
|
||||
|
||||
c->pan_done += 1;
|
||||
c->vol2_done += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void callback(void *userdata, Uint8 *stream, int length) {
|
||||
int channel = 0;
|
||||
|
||||
for (channel = 0; channel < NUM_CHANNELS; channel++) {
|
||||
|
||||
for (channel = 0; channel < num_channels; channel++) {
|
||||
|
||||
|
||||
int mixed = 0;
|
||||
struct Channel *c = &channels[channel];
|
||||
|
||||
@@ -377,24 +415,22 @@ static void callback(void *userdata, Uint8 *stream, int length) {
|
||||
|
||||
while (mixed < length && c->playing) {
|
||||
int mixleft = length - mixed;
|
||||
int bufleft = c->decoded - c->last;
|
||||
Uint8 buffer[mixleft];
|
||||
|
||||
// Decode some amount of data.
|
||||
|
||||
int bytes = ffpy_audio_decode(c->playing, buffer, mixleft);
|
||||
|
||||
// We have some data in the buffer.
|
||||
if (c->stop_bytes && bufleft) {
|
||||
int bytes = min(bufleft, mixleft);
|
||||
|
||||
if (c->stop_bytes && bytes) {
|
||||
|
||||
if (c->stop_bytes != -1)
|
||||
bytes = min(c->stop_bytes, bytes);
|
||||
|
||||
pan_audio(c, &( ((Uint8*) c->playing->buffer) [c->last]),
|
||||
bytes);
|
||||
|
||||
fade_mixaudio(c, &stream[mixed],
|
||||
&( ((Uint8*) c->playing->buffer) [c->last]),
|
||||
bytes);
|
||||
|
||||
pan_audio(c, buffer, bytes);
|
||||
fade_mixaudio(c, &stream[mixed], buffer, bytes);
|
||||
|
||||
mixed += bytes;
|
||||
c->last += bytes;
|
||||
|
||||
if (c->stop_bytes != -1)
|
||||
c->stop_bytes -= bytes;
|
||||
@@ -407,13 +443,19 @@ static void callback(void *userdata, Uint8 *stream, int length) {
|
||||
// Otherwise, no data is left in the buffer. Check why,
|
||||
// and act accordingly.
|
||||
|
||||
// EOF or ERROR -- Skip to the next sample.
|
||||
if (c->stop_bytes == 0 || c->playing->flags & (SOUND_SAMPLEFLAG_ERROR | SOUND_SAMPLEFLAG_EOF)) {
|
||||
int old_tight = c->playing_tight;
|
||||
// Skip to the next sample.
|
||||
if (c->stop_bytes == 0 || bytes == 0) {
|
||||
|
||||
int old_tight = c->playing_tight;
|
||||
struct Dying *d;
|
||||
|
||||
post_event(c);
|
||||
|
||||
free_sample(c->playing);
|
||||
d = malloc(sizeof(struct Dying));
|
||||
d->next = dying;
|
||||
d->stream = c->playing;
|
||||
dying = d;
|
||||
|
||||
decref(c->playing_name);
|
||||
|
||||
c->playing = c->queued;
|
||||
@@ -427,31 +469,53 @@ static void callback(void *userdata, Uint8 *stream, int length) {
|
||||
c->queued_tight = 0;
|
||||
|
||||
start_sample(c, ! old_tight);
|
||||
/* update_pause(); */
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we're here, we're simply out of data in the
|
||||
// buffer. Decode some.
|
||||
|
||||
c->decoded = Sound_Decode(c->playing);
|
||||
c->last = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks that the given channel is in range. Returns 0 if it is,
|
||||
* sets an error and returns -1 if it is not.
|
||||
* sets an error and returns -1 if it is not. Allocates channels
|
||||
* that don't already exist.
|
||||
*/
|
||||
static int check_channel(int c) {
|
||||
if (c < 0 || c >= NUM_CHANNELS) {
|
||||
int i;
|
||||
|
||||
if (c < 0) {
|
||||
error(PSS_ERROR);
|
||||
error_msg = "Channel number out of range.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (c >= num_channels) {
|
||||
channels = realloc(channels, sizeof(struct Channel) * (c + 1));
|
||||
|
||||
for (i = num_channels; i <= c; i++) {
|
||||
|
||||
channels[i].playing = NULL;
|
||||
channels[i].queued = NULL;
|
||||
channels[i].playing_name = NULL;
|
||||
channels[i].queued_name = NULL;
|
||||
channels[i].volume = SDL_MIX_MAXVOLUME;
|
||||
channels[i].paused = 1;
|
||||
channels[i].event = 0;
|
||||
channels[i].pan_start = 0.0;
|
||||
channels[i].pan_end = 0.0;
|
||||
channels[i].pan_length = 0;
|
||||
channels[i].pan_done = 0;
|
||||
channels[i].vol2_start = 1.0;
|
||||
channels[i].vol2_end = 1.0;
|
||||
channels[i].vol2_length = 0;
|
||||
channels[i].vol2_done = 0;
|
||||
}
|
||||
|
||||
num_channels = c + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -460,15 +524,9 @@ static int check_channel(int c) {
|
||||
* Loads the provided sample. Returns the sample on success, NULL on
|
||||
* failure.
|
||||
*/
|
||||
static Sound_Sample *load_sample(SDL_RWops *rw, const char *ext) {
|
||||
Sound_AudioInfo ai;
|
||||
Sound_Sample *rv;
|
||||
|
||||
ai.format = audio_spec.format;
|
||||
ai.channels = audio_spec.channels;
|
||||
ai.rate = audio_spec.freq;
|
||||
|
||||
rv = Sound_NewSample(rw, ext, &ai, audio_spec.samples * audio_spec.channels * 2);
|
||||
struct VideoState *load_sample(SDL_RWops *rw, const char *ext) {
|
||||
struct VideoState *rv;
|
||||
rv = ffpy_stream_open(rw, ext);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -739,14 +797,20 @@ void PSS_fadeout(int channel, int ms) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
fade_steps = c->volume;
|
||||
c->fade_delta = -1;
|
||||
c->fade_off = 0;
|
||||
c->fade_vol = c->volume;
|
||||
|
||||
c->fade_step_len = ms_to_bytes(ms) / fade_steps;
|
||||
c->fade_step_len &= ~0x7; // Even sample.
|
||||
|
||||
if (fade_steps) {
|
||||
c->fade_step_len = ms_to_bytes(ms) / fade_steps;
|
||||
c->fade_step_len &= ~0x7; // Even sample.
|
||||
} else {
|
||||
c->fade_step_len = 0;
|
||||
}
|
||||
|
||||
c->stop_bytes = ms_to_bytes(ms);
|
||||
c->queued_tight = 0;
|
||||
|
||||
@@ -791,7 +855,7 @@ void PSS_unpause_all(void) {
|
||||
|
||||
ENTER();
|
||||
|
||||
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||
for (i = 0; i < num_channels; i++) {
|
||||
channels[i].paused = 0;
|
||||
}
|
||||
|
||||
@@ -927,13 +991,37 @@ void PSS_set_pan(int channel, float pan, float delay) {
|
||||
error(SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* This sets the secondary volume of the channel.
|
||||
*/
|
||||
void PSS_set_secondary_volume(int channel, float vol2, float delay) {
|
||||
struct Channel *c;
|
||||
BEGIN();
|
||||
|
||||
if (check_channel(channel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
c = &channels[channel];
|
||||
|
||||
ENTER();
|
||||
|
||||
c->vol2_start = interpolate_vol2(c);
|
||||
c->vol2_end = vol2;
|
||||
c->vol2_length = (int) (audio_spec.freq * delay);
|
||||
c->vol2_done = 0;
|
||||
|
||||
EXIT();
|
||||
|
||||
error(SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initializes the sound to the given frequencies, channels, and
|
||||
* sample buffer size.
|
||||
*/
|
||||
void PSS_init(int freq, int stereo, int samples) {
|
||||
int i;
|
||||
void PSS_init(int freq, int stereo, int samples, int status) {
|
||||
|
||||
if (initialized) {
|
||||
return;
|
||||
@@ -964,36 +1052,15 @@ void PSS_init(int freq, int stereo, int samples) {
|
||||
audio_spec.callback = callback;
|
||||
audio_spec.userdata = NULL;
|
||||
|
||||
if (SDL_OpenAudio(&audio_spec, NULL)) {
|
||||
if (SDL_OpenAudio(&audio_spec, &audio_spec)) {
|
||||
error(SDL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (! Sound_Init()) {
|
||||
SDL_CloseAudio();
|
||||
error(SOUND_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the channels.
|
||||
*/
|
||||
|
||||
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||
channels[i].playing = NULL;
|
||||
channels[i].queued = NULL;
|
||||
channels[i].volume = SDL_MIX_MAXVOLUME;
|
||||
channels[i].paused = 1;
|
||||
channels[i].event = 0;
|
||||
channels[i].pan_start = 0.0;
|
||||
channels[i].pan_end = 0.0;
|
||||
channels[i].pan_length = 0;
|
||||
channels[i].pan_done = 0;
|
||||
|
||||
}
|
||||
|
||||
SDL_PauseAudio(0);
|
||||
|
||||
ffpy_init(audio_spec.freq, status);
|
||||
|
||||
initialized = 1;
|
||||
|
||||
error(SUCCESS);
|
||||
@@ -1012,17 +1079,60 @@ void PSS_quit() {
|
||||
SDL_PauseAudio(1);
|
||||
EXIT();
|
||||
|
||||
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||
for (i = 0; i < num_channels; i++) {
|
||||
PSS_stop(i);
|
||||
}
|
||||
|
||||
Sound_Quit();
|
||||
SDL_CloseAudio();
|
||||
|
||||
num_channels = 0;
|
||||
initialized = 0;
|
||||
error(SUCCESS);
|
||||
}
|
||||
|
||||
/* This must be called frequently, to take care of deallocating dead
|
||||
* streams. */
|
||||
void PSS_periodic() {
|
||||
BEGIN();
|
||||
|
||||
int i;
|
||||
|
||||
if (!dying) {
|
||||
return;
|
||||
}
|
||||
|
||||
ENTER();
|
||||
|
||||
while (dying) {
|
||||
struct Dying *d = dying;
|
||||
ffpy_stream_close(d->stream);
|
||||
dying = d->next;
|
||||
free(d);
|
||||
}
|
||||
|
||||
EXIT();
|
||||
}
|
||||
|
||||
/* This should be called in response to an FF_ALLOC_EVENT, with a pygame
|
||||
* surface to display the movie on. */
|
||||
void PSS_alloc_event(PyObject *surface) {
|
||||
int i;
|
||||
for (i = 0; i < num_channels; i++) {
|
||||
if (channels[i].playing) {
|
||||
ffpy_alloc_event(channels[i].playing, surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This should be called in response to a FF_REFRESH_EVENT */
|
||||
void PSS_refresh_event(void) {
|
||||
int i;
|
||||
for (i = 0; i < num_channels; i++) {
|
||||
if (channels[i].playing) {
|
||||
ffpy_refresh_event(channels[i].playing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the error message string if an error has occured, or
|
||||
@@ -1035,7 +1145,7 @@ const char *PSS_get_error() {
|
||||
case SDL_ERROR:
|
||||
return SDL_GetError();
|
||||
case SOUND_ERROR:
|
||||
return Sound_GetError();
|
||||
return "Some sort of ffmpeg error.";
|
||||
case PSS_ERROR:
|
||||
return error_msg;
|
||||
default:
|
||||
|
||||
@@ -29,7 +29,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
SDL_RWops* RWopsFromPythonThreaded(PyObject* obj);
|
||||
|
||||
|
||||
void PSS_play(int channel, SDL_RWops *rw, const char *ext, PyObject *name, int fadeout, int tight, int paused);
|
||||
void PSS_queue(int channel, SDL_RWops *rw, const char *ext, PyObject *name, int fadeout, int tight);
|
||||
void PSS_stop(int channel);
|
||||
@@ -44,8 +43,14 @@ int PSS_get_pos(int channel);
|
||||
void PSS_set_volume(int channel, float volume);
|
||||
float PSS_get_volume(int channel);
|
||||
void PSS_set_pan(int channel, float pan, float delay);
|
||||
void PSS_init(int freq, int stereo, int samples);
|
||||
void PSS_set_secondary_volume(int channel, float vol2, float delay);
|
||||
void PSS_init(int freq, int stereo, int samples, int status);
|
||||
void PSS_quit(void);
|
||||
|
||||
void PSS_periodic(void);
|
||||
void PSS_alloc_event(PyObject *surface);
|
||||
void PSS_refresh_event(void);
|
||||
|
||||
const char *PSS_get_error(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
# -*- python -*-
|
||||
# Copyright 2005 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.
|
||||
|
||||
|
||||
cdef extern void ffplay_init()
|
||||
cdef extern int ffplay_open(char *filename)
|
||||
cdef extern void ffplay_close()
|
||||
cdef extern int ffplay_event_handler(int)
|
||||
|
||||
def version():
|
||||
return 1
|
||||
|
||||
def init():
|
||||
ffplay_init()
|
||||
|
||||
def play(fn):
|
||||
if ffplay_open(fn):
|
||||
raise Exception("ffplay could not open: " + fn)
|
||||
|
||||
def stop():
|
||||
ffplay_close()
|
||||
|
||||
def event_handler(type):
|
||||
return ffplay_event_handler(type)
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <Python.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "pygame.h"
|
||||
#include <pygame/pygame.h>
|
||||
#include "structmember.h"
|
||||
#include "renpy_ttf.h"
|
||||
|
||||
|
||||
@@ -310,9 +310,10 @@ static int rw_seek_th(SDL_RWops* context, int offset, int whence)
|
||||
{
|
||||
result = PyObject_CallFunction(helper->seek, "ii", offset, whence);
|
||||
if(!result) {
|
||||
PyThreadState_Swap(oldstate);
|
||||
PyEval_ReleaseLock();
|
||||
return -1;
|
||||
PyErr_Clear();
|
||||
PyThreadState_Swap(oldstate);
|
||||
PyEval_ReleaseLock();
|
||||
return -1;
|
||||
}
|
||||
|
||||
Py_DECREF(result);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
import distutils.core
|
||||
import os
|
||||
import os.path
|
||||
@@ -12,48 +10,135 @@ try:
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
# These control the level of optimization versus debugging.
|
||||
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", "/home/tom/ab/deps/install")
|
||||
install = os.environ.get("RENPY_DEPS_INSTALL", None)
|
||||
|
||||
# Check to see if that's the case.
|
||||
if not os.path.isdir(install):
|
||||
print "The Ren'Py dependencies install directory:"
|
||||
print
|
||||
print install
|
||||
print
|
||||
print "does not exist. Please set RENPY_DEPS_INSTALL to the correct"
|
||||
print "location of the Ren'Py dependencies install directory, and "
|
||||
print "re-run this script."
|
||||
if install is None:
|
||||
print """
|
||||
The RENPY_DEPS_INSTALL environment variable has not been set. This
|
||||
should be set to a double-colon-delimited list of places where the
|
||||
Ren'Py dependencies can be found. (To use system libraries, this can
|
||||
be set to a system directory, like /usr.)
|
||||
"""
|
||||
sys.exit(-1)
|
||||
|
||||
# Default compile arguements for everybody.
|
||||
include_dirs = [ install + "/include", install + "/include/SDL", install + "/include/freetype2", install + "/include/pygame"]
|
||||
library_dirs = [ install + "/lib" ]
|
||||
# Fast math breaks on windows. :-(
|
||||
extra_compile_args = [ "-O3", "-funroll-loops" ] # , "-ffast-math" ]
|
||||
install = install.split("::")
|
||||
|
||||
include_dirs = [ ]
|
||||
library_dirs = [ ]
|
||||
|
||||
def add_include(prefix, file):
|
||||
"""
|
||||
Search for prefix/file underneath <i> and <i>/include, for each of the
|
||||
directories <i> in install. When found, puts the directory it was found
|
||||
in into include_dirs.
|
||||
"""
|
||||
|
||||
checked = [ ]
|
||||
for i in install:
|
||||
|
||||
dir = os.path.join(i, prefix)
|
||||
fn = os.path.join(dir, file)
|
||||
fn = os.path.normpath(fn)
|
||||
checked.append(fn)
|
||||
if os.path.exists(fn):
|
||||
break
|
||||
|
||||
dir = os.path.join(i, "include", prefix)
|
||||
fn = os.path.join(dir, file)
|
||||
fn = os.path.normpath(fn)
|
||||
checked.append(fn)
|
||||
|
||||
if os.path.exists(fn):
|
||||
break
|
||||
|
||||
else:
|
||||
|
||||
print "Could not find include %s." % file
|
||||
print "The paths searched were:"
|
||||
for i in checked:
|
||||
print "-", i
|
||||
sys.exit(-1)
|
||||
|
||||
dir = os.path.normpath(dir)
|
||||
|
||||
print "Found %s in %s." % (file, dir)
|
||||
|
||||
if dir not in include_dirs:
|
||||
include_dirs.append(dir)
|
||||
|
||||
def add_library(name):
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
|
||||
checked = [ ]
|
||||
|
||||
for i in install:
|
||||
for d in ('', 'lib'):
|
||||
for suffix in (".so", ".dylib", ".a"):
|
||||
|
||||
dir = os.path.join(i, d)
|
||||
fn = os.path.join(dir, name + suffix)
|
||||
checked.append(fn)
|
||||
|
||||
if os.path.exists(fn):
|
||||
print "Found %s." % fn
|
||||
|
||||
if dir not in library_dirs:
|
||||
library_dirs.append(dir)
|
||||
return
|
||||
|
||||
print "Couldn't find library %s." % name
|
||||
print "The paths searched were:"
|
||||
for i in checked:
|
||||
print "-", i
|
||||
sys.exit(-1)
|
||||
|
||||
add_include("", "zlib.h")
|
||||
add_include("", "png.h")
|
||||
add_include("SDL", "SDL.h")
|
||||
add_include("", "ft2build.h")
|
||||
add_include("freetype2", "freetype/freetype.h")
|
||||
add_include("", "libavutil/avstring.h")
|
||||
add_include("", "libavformat/avformat.h")
|
||||
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")
|
||||
add_library("libfreetype")
|
||||
|
||||
|
||||
|
||||
extra_link_args = [ ]
|
||||
png_libraries = [ 'png', "z" ]
|
||||
|
||||
sdl_libraries = [ 'SDL' ]
|
||||
sound_libraries = [ 'SDL_sound', 'smpeg', 'vorbisfile', 'vorbis', 'ogg', 'modplug', 'stdc++', ]
|
||||
sound_libraries = [ "avformat", "avcodec", "avutil", "z" ]
|
||||
png_libraries = [ 'png', "z" ]
|
||||
|
||||
# The following turn on optional modules.
|
||||
nativemidi = None
|
||||
winmixer = None
|
||||
linmixer = None
|
||||
|
||||
# Detect win32.
|
||||
if platform.win32_ver()[0]:
|
||||
nativemidi = [ 'nativemidi.c', 'native_midi_win32.c', 'native_midi_common.c', 'rwobject.c' ]
|
||||
nativemidi_libs = [ 'winmm', 'SDL' ]
|
||||
extra_compile_args.append("-fno-strict-aliasing")
|
||||
winmixer = True
|
||||
|
||||
# Detect mac.
|
||||
if platform.mac_ver()[0]:
|
||||
nativemidi = [ 'nativemidi.c', 'native_midi_mac.c', 'native_midi_common.c', 'rwobject.c' ]
|
||||
nativemidi_libs = [ 'SDL' ]
|
||||
|
||||
# Detect OSS.
|
||||
try:
|
||||
import ossaudiodev
|
||||
@@ -83,14 +168,14 @@ 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' ],
|
||||
)
|
||||
|
||||
extensions.append(renpy_font)
|
||||
|
||||
psse = distutils.core.Extension(
|
||||
"pysdlsound.sound",
|
||||
[ "pss.c", "rwobject.c", "sound.c" ],
|
||||
[ "pss.c", "rwobject.c", "sound.c", "ffdecode.c" ],
|
||||
include_dirs=include_dirs,
|
||||
library_dirs=library_dirs,
|
||||
extra_compile_args=extra_compile_args,
|
||||
@@ -100,19 +185,6 @@ psse = distutils.core.Extension(
|
||||
|
||||
extensions.append(psse)
|
||||
|
||||
if nativemidi:
|
||||
nme = distutils.core.Extension(
|
||||
"pysdlsound.nativemidi",
|
||||
nativemidi,
|
||||
include_dirs=include_dirs,
|
||||
library_dirs=library_dirs,
|
||||
extra_compile_args=extra_compile_args,
|
||||
libraries=nativemidi_libs,
|
||||
extra_link_args=extra_link_args,
|
||||
)
|
||||
|
||||
extensions.append(nme)
|
||||
|
||||
if winmixer:
|
||||
wme = distutils.core.Extension(
|
||||
"pysdlsound.winmixer",
|
||||
@@ -125,20 +197,9 @@ if winmixer:
|
||||
if linmixer:
|
||||
py_modules.append('pysdlsound.linmixer')
|
||||
|
||||
|
||||
# ffplay = distutils.core.Extension(
|
||||
# "renpy_ffplay",
|
||||
# ["renpy_ffplay.c", "ffplay_module.c"],
|
||||
# include_dirs = [ install + '/include/SDL', install + '/include/ffmpeg', install + '/include' ],
|
||||
# library_dirs = [ install + '/lib' ],
|
||||
# libraries = [ 'avcodec', 'avformat', 'avcodec', 'avutil', 'vorbis', 'vorbisenc', 'ogg', 'SDL', 'z', 'm', ],
|
||||
# )
|
||||
|
||||
# extensions.append(ffplay)
|
||||
|
||||
distutils.core.setup(
|
||||
name = "renpy_module",
|
||||
version = "5.5.0",
|
||||
version = "6.9.1",
|
||||
ext_modules = extensions,
|
||||
py_modules = py_modules,
|
||||
package_dir = { '' : 'lib' },
|
||||
|
||||
@@ -39,17 +39,17 @@ cdef extern from "pss.h":
|
||||
void PSS_set_endevent(int channel, int event)
|
||||
void PSS_set_volume(int channel, float volume)
|
||||
float PSS_get_volume(int channel)
|
||||
void PSS_set_pan(int channel, float left, float right)
|
||||
void PSS_init(int freq, int stereo, int samples)
|
||||
void PSS_set_pan(int channel, float pan, float delay)
|
||||
void PSS_set_secondary_volume(int channel, float vol2, float delay)
|
||||
void PSS_init(int freq, int stereo, int samples, int status)
|
||||
void PSS_quit()
|
||||
|
||||
void PSS_periodic()
|
||||
void PSS_alloc_event(object)
|
||||
void PSS_refresh_event()
|
||||
|
||||
char *PSS_get_error()
|
||||
|
||||
def _extension(s):
|
||||
i = s.rfind('.')
|
||||
if i == -1:
|
||||
return s
|
||||
return s[i+1:]
|
||||
|
||||
def check_error():
|
||||
e = PSS_get_error();
|
||||
if e:
|
||||
@@ -73,9 +73,7 @@ def play(channel, file, name, paused=False, fadein=0, tight=False):
|
||||
else:
|
||||
tight = 0
|
||||
|
||||
ext = _extension(name)
|
||||
|
||||
PSS_play(channel, rw, ext, name, fadein, tight, pause)
|
||||
PSS_play(channel, rw, name, name, fadein, tight, pause)
|
||||
check_error()
|
||||
|
||||
def queue(channel, file, name, fadein=0, tight=False):
|
||||
@@ -88,9 +86,7 @@ def queue(channel, file, name, fadein=0, tight=False):
|
||||
else:
|
||||
tight = 0
|
||||
|
||||
ext = _extension(name)
|
||||
|
||||
PSS_queue(channel, rw, ext, name, fadein, tight)
|
||||
PSS_queue(channel, rw, name, name, fadein, tight)
|
||||
check_error()
|
||||
|
||||
def stop(channel):
|
||||
@@ -128,13 +124,21 @@ def get_pos(channel):
|
||||
return PSS_get_pos(channel)
|
||||
|
||||
def set_volume(channel, volume):
|
||||
PSS_set_volume(channel, 10 ** volume / 10 )
|
||||
if volume == 0:
|
||||
PSS_set_volume(channel, 0)
|
||||
else:
|
||||
PSS_set_volume(channel, 10 ** volume / 10 )
|
||||
|
||||
check_error()
|
||||
|
||||
def set_pan(channel, pan, delay):
|
||||
PSS_set_pan(channel, pan, delay)
|
||||
check_error()
|
||||
|
||||
def set_secondary_volume(channel, volume, delay):
|
||||
PSS_set_secondary_volume(channel, volume, delay)
|
||||
check_error()
|
||||
|
||||
def set_end_event(channel, event):
|
||||
PSS_set_endevent(channel, event)
|
||||
check_error()
|
||||
@@ -142,13 +146,27 @@ def set_end_event(channel, event):
|
||||
def get_volume(channel):
|
||||
return PSS_get_volume(channel)
|
||||
|
||||
def init(freq, stereo, samples):
|
||||
PSS_init(freq, stereo, samples)
|
||||
def init(freq, stereo, samples, status=False):
|
||||
if status:
|
||||
status = 1
|
||||
else:
|
||||
status = 0
|
||||
|
||||
PSS_init(freq, stereo, samples, status)
|
||||
check_error()
|
||||
|
||||
def quit():
|
||||
PSS_quit()
|
||||
|
||||
def periodic():
|
||||
PSS_periodic()
|
||||
|
||||
def alloc_event(surf):
|
||||
PSS_alloc_event(surf)
|
||||
|
||||
def refresh_event():
|
||||
PSS_refresh_event()
|
||||
|
||||
def check_version(version):
|
||||
if version < 2 or version > 3:
|
||||
if version < 2 or version > 4:
|
||||
raise Exception("pysdlsound version mismatch.")
|
||||
|
||||