renpy/doc/rooms.html

979 lines
67 KiB
HTML
Raw Normal View History

2023-01-18 22:13:55 +00:00
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Image Gallery, Music Room, and Replay Actions &#8212; Ren&#39;Py Documentation</title>
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
<script type="text/javascript" src="_static/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Drag and Drop" href="drag_drop.html" />
<link rel="prev" title="Side Images" href="side_image.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
</head><body>
<div id="navbar" class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">
Ren&#39;Py Documentation</a>
<span class="navbar-text navbar-version pull-left"><b>7.5.3</b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li><a href="https://www.renpy.org">Home Page</a></li>
<li><a href="https://www.renpy.org/doc/html/">Online Documentation</a></li>
<li class="dropdown globaltoc-container">
<a role="button"
id="dLabelGlobalToc"
data-toggle="dropdown"
data-target="#"
href="index.html">Site <b class="caret"></b></a>
<ul class="dropdown-menu globaltoc"
role="menu"
aria-labelledby="dLabelGlobalToc"><ul>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="gui.html">GUI Customization Guide</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="language_basics.html">Language Basics</a></li>
<li class="toctree-l1"><a class="reference internal" href="label.html">Labels &amp; Control Flow</a></li>
<li class="toctree-l1"><a class="reference internal" href="dialogue.html">Dialogue and Narration</a></li>
<li class="toctree-l1"><a class="reference internal" href="displaying_images.html">Displaying Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="menus.html">In-Game Menus</a></li>
<li class="toctree-l1"><a class="reference internal" href="python.html">Python Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="conditional.html">Conditional Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="audio.html">Audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="movie.html">Movie</a></li>
<li class="toctree-l1"><a class="reference internal" href="voice.html">Voice</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="text.html">Text</a></li>
<li class="toctree-l1"><a class="reference internal" href="translation.html">Translation</a></li>
<li class="toctree-l1"><a class="reference internal" href="displayables.html">Displayables</a></li>
<li class="toctree-l1"><a class="reference internal" href="transforms.html">Transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="transitions.html">Transitions</a></li>
<li class="toctree-l1"><a class="reference internal" href="atl.html">Animation and Transformation Language</a></li>
<li class="toctree-l1"><a class="reference internal" href="matrixcolor.html">Matrixcolor</a></li>
<li class="toctree-l1"><a class="reference internal" href="layeredimage.html">Layered Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="3dstage.html">3D Stage</a></li>
<li class="toctree-l1"><a class="reference internal" href="live2d.html">Live2D Cubism</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="style.html">Styles</a></li>
<li class="toctree-l1"><a class="reference internal" href="style_properties.html">Style Properties</a></li>
<li class="toctree-l1"><a class="reference internal" href="screens.html">Screens and Screen Language</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_actions.html">Screen Actions, Values, and Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_special.html">Special Screen Names</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_optimization.html">Screen Language Optimization</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="preferences.html">Preference Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="store_variables.html">Store Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="mouse.html">Custom Mouse Cursors</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="launcher.html">Launcher</a></li>
<li class="toctree-l1"><a class="reference internal" href="developer_tools.html">Developer Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="director.html">Interactive Director</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="nvl_mode.html">NVL-Mode Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="input.html">Text Input</a></li>
<li class="toctree-l1"><a class="reference internal" href="side_image.html">Side Images</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Image Gallery, Music Room, and Replay Actions</a></li>
<li class="toctree-l1"><a class="reference internal" href="drag_drop.html">Drag and Drop</a></li>
<li class="toctree-l1"><a class="reference internal" href="sprites.html">Sprites</a></li>
<li class="toctree-l1"><a class="reference internal" href="keymap.html">Customizing the Keymap</a></li>
<li class="toctree-l1"><a class="reference internal" href="achievement.html">Achievements</a></li>
<li class="toctree-l1"><a class="reference internal" href="history.html">Dialogue History</a></li>
<li class="toctree-l1"><a class="reference internal" href="multiple.html">Multiple Character Dialogue</a></li>
<li class="toctree-l1"><a class="reference internal" href="splashscreen_presplash.html">Splashscreen and Presplash</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="statement_equivalents.html">Statement Equivalents</a></li>
<li class="toctree-l1"><a class="reference internal" href="save_load_rollback.html">Saving, Loading, and Rollback</a></li>
<li class="toctree-l1"><a class="reference internal" href="persistent.html">Persistent Data</a></li>
<li class="toctree-l1"><a class="reference internal" href="trans_trans_python.html">Transforms and Transitions in Python</a></li>
<li class="toctree-l1"><a class="reference internal" href="gui_advanced.html">Advanced GUI</a></li>
<li class="toctree-l1"><a class="reference internal" href="screen_python.html">Screens and Python</a></li>
<li class="toctree-l1"><a class="reference internal" href="modes.html">Modes</a></li>
<li class="toctree-l1"><a class="reference internal" href="cdd.html">Creator-Defined Displayables</a></li>
<li class="toctree-l1"><a class="reference internal" href="cds.html">Creator-Defined Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="custom_text_tags.html">Custom Text Tags</a></li>
<li class="toctree-l1"><a class="reference internal" href="character_callbacks.html">Character Callbacks</a></li>
<li class="toctree-l1"><a class="reference internal" href="file_python.html">File Access</a></li>
<li class="toctree-l1"><a class="reference internal" href="color_class.html">Color Class</a></li>
<li class="toctree-l1"><a class="reference internal" href="matrix.html">Matrix</a></li>
<li class="toctree-l1"><a class="reference internal" href="model.html">Model-Based Rendering</a></li>
<li class="toctree-l1"><a class="reference internal" href="other.html">Other Functions and Variables</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="build.html">Building Distributions</a></li>
<li class="toctree-l1"><a class="reference internal" href="updater.html">Web Updater</a></li>
<li class="toctree-l1"><a class="reference internal" href="android.html">Android</a></li>
<li class="toctree-l1"><a class="reference internal" href="chromeos.html">Chrome OS/Chromebook</a></li>
<li class="toctree-l1"><a class="reference internal" href="ios.html">iOS</a></li>
<li class="toctree-l1"><a class="reference internal" href="iap.html">In-App Purchasing</a></li>
<li class="toctree-l1"><a class="reference internal" href="gesture.html">Gestures</a></li>
<li class="toctree-l1"><a class="reference internal" href="raspi.html">Raspberry Pi</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="security.html">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="problems.html">Dealing with Problems</a></li>
<li class="toctree-l1"><a class="reference internal" href="environment_variables.html">Environment Variables</a></li>
<li class="toctree-l1"><a class="reference internal" href="self_voicing.html">Self-Voicing</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="editor.html">Text Editor Integration</a></li>
<li class="toctree-l1"><a class="reference internal" href="skins.html">Skins</a></li>
<li class="toctree-l1"><a class="reference internal" href="translating_renpy.html">Translating Ren'Py</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog (Ren'Py 7.x-)</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog6.html">Changelog (Ren'Py 6.11 - 6.99)</a></li>
<li class="toctree-l1"><a class="reference internal" href="incompatible.html">Incompatible Changes</a></li>
<li class="toctree-l1"><a class="reference internal" href="distributor.html">Distributor Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
<li class="toctree-l1"><a class="reference internal" href="credits.html">Credits</a></li>
<li class="toctree-l1"><a class="reference internal" href="sponsors.html">Ren'Py Development Sponsors</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="thequestion.html">Script of The Question</a></li>
<li class="toctree-l1"><a class="reference internal" href="thequestion_nvl.html">NVL-mode script for The Question</a></li>
</ul>
</ul>
</li>
</ul>
<form class="navbar-form navbar-right" action="search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3">
<div id="sidebar" class="bs-sidenav" role="complementary"><ul>
<li><a class="reference internal" href="#">Image Gallery, Music Room, and Replay Actions</a><ul>
<li><a class="reference internal" href="#image-gallery">Image Gallery</a></li>
<li><a class="reference internal" href="#music-room">Music Room</a></li>
<li><a class="reference internal" href="#replay">Replay</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="col-md-9 content">
<div class="section" id="image-gallery-music-room-and-replay-actions">
<h1>Image Gallery, Music Room, and Replay Actions<a class="headerlink" href="#image-gallery-music-room-and-replay-actions" title="Permalink to this headline"> link</a></h1>
<div class="section" id="image-gallery">
<span id="id1"></span><h2>Image Gallery<a class="headerlink" href="#image-gallery" title="Permalink to this headline"> link</a></h2>
<p>A image gallery is a screen that allows the player to unlock images,
and then view those images. The screen has one or more buttons associated
with it, and each button has one or more associated images. Buttons and
images also have conditions that determine if they have unlocked.</p>
<p>Image galleries are managed by instances of the Gallery class. A
single instance of the gallery class may be shared between multiple
image gallery screens.</p>
<p>A gallery has one or more buttons associated with it, a button has one
or more images associated with it, and each image has one or more displayables
associated with it. Conditions can be assigned to buttons and images. A button
is unlocked when all of the conditions associated with it are satisfied and
at least one image associated with that button is unlocked. An image is unlocked
when all associated conditions are satisfied.</p>
<p>Creating an image gallery consists of the following four steps.</p>
<ol class="arabic">
<li><p class="first">Create an instance of Gallery.</p>
</li>
<li><p class="first">Add buttons and images to that gallery, along with conditions that
determine if the buttons and images they belong to are unlocked. This
is also a multi-step process.</p>
<ol class="arabic simple">
<li>Declare a new button by calling <a class="reference internal" href="#Gallery.button" title="Gallery.button"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Gallery.button()</span></code></a>.</li>
<li>Optionally, add one or more unlock conditions to the button by
calling <a class="reference internal" href="#Gallery.unlock" title="Gallery.unlock"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Gallery.unlock()</span></code></a> or <a class="reference internal" href="#Gallery.condition" title="Gallery.condition"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Gallery.condition()</span></code></a>.</li>
<li>Declare an image by calling <a class="reference internal" href="#Gallery.image" title="Gallery.image"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Gallery.image()</span></code></a> with one or more
displayables as arguments. Or call the convenience method
<a class="reference internal" href="#Gallery.unlock_image" title="Gallery.unlock_image"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Gallery.unlock_image()</span></code></a> instead.</li>
<li>Optionally, call <a class="reference internal" href="#Gallery.transform" title="Gallery.transform"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Gallery.transform()</span></code></a> to associate
transforms with the displayables.</li>
<li>Optionally, add one or more unlock conditions to the image by
calling <a class="reference internal" href="#Gallery.unlock" title="Gallery.unlock"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Gallery.unlock()</span></code></a>, <a class="reference internal" href="#Gallery.condition" title="Gallery.condition"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Gallery.condition()</span></code></a>,
or <a class="reference internal" href="#Gallery.allprior" title="Gallery.allprior"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Gallery.allprior()</span></code></a>.</li>
</ol>
<p>Additional images can be added to a button by repeating steps 3-5,
while additional buttons can be added to the gallery by repeating
all five steps.</p>
</li>
<li><p class="first">Create an image gallery screen. The screen should display a background,
and should contain navigation that allows the user to show other
image galleries, or to return to the main or extras menu.</p>
</li>
<li><p class="first">Add a way to display the image gallery screen to the main or extras menu.</p>
</li>
</ol>
<p>Here's an example:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">init</span> <span class="k">python</span><span class="p">:</span>
<span class="c1"># Step 1. Create the gallery object.</span>
<span class="n">g</span> <span class="o">=</span> <span class="n">Gallery</span><span class="p">()</span>
<span class="c1"># Step 2. Add buttons and images to the gallery.</span>
<span class="c1"># A button with an image that is always unlocked.</span>
<span class="n">g</span><span class="o">.</span><span class="k">button</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">)</span>
<span class="c1"># A button that contains an image that automatically unlocks.</span>
<span class="n">g</span><span class="o">.</span><span class="k">button</span><span class="p">(</span><span class="s2">&quot;dawn&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;dawn1&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock</span><span class="p">(</span><span class="s2">&quot;dawn1&quot;</span><span class="p">)</span>
<span class="c1"># This button has multiple images assocated with it. We use unlock_image</span>
<span class="c1"># so we don&#39;t have to call both .image and .unlock. We also apply a</span>
<span class="c1"># transform to the first image.</span>
<span class="n">g</span><span class="o">.</span><span class="k">button</span><span class="p">(</span><span class="s2">&quot;dark&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock_image</span><span class="p">(</span><span class="s2">&quot;bigbeach1&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">transform</span><span class="p">(</span><span class="n">slowpan</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock_image</span><span class="p">(</span><span class="s2">&quot;beach1 mary&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock_image</span><span class="p">(</span><span class="s2">&quot;beach2&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock_image</span><span class="p">(</span><span class="s2">&quot;beach3&quot;</span><span class="p">)</span>
<span class="c1"># This button has a condition associated with it, allowing the game</span>
<span class="c1"># to choose which images unlock.</span>
<span class="n">g</span><span class="o">.</span><span class="k">button</span><span class="p">(</span><span class="s2">&quot;end1&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">condition</span><span class="p">(</span><span class="s2">&quot;persistent.unlock_1&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;transfer&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;moonpic&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;girlpic&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;nogirlpic&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;bad_ending&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">button</span><span class="p">(</span><span class="s2">&quot;end2&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">condition</span><span class="p">(</span><span class="s2">&quot;persistent.unlock_2&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;library&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;beach1 nomoon&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;bad_ending&quot;</span><span class="p">)</span>
<span class="c1"># The last image in this button has an condition associated with it,</span>
<span class="c1"># so it will only unlock if the user gets both endings.</span>
<span class="n">g</span><span class="o">.</span><span class="k">button</span><span class="p">(</span><span class="s2">&quot;end3&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">condition</span><span class="p">(</span><span class="s2">&quot;persistent.unlock_3&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;littlemary2&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;littlemary&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;good_ending&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">condition</span><span class="p">(</span><span class="s2">&quot;persistent.unlock_3 and persistent.unlock_4&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">button</span><span class="p">(</span><span class="s2">&quot;end4&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">condition</span><span class="p">(</span><span class="s2">&quot;persistent.unlock_4&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;hospital1&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;hospital2&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;hospital3&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;heaven&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;white&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">image</span><span class="p">(</span><span class="s2">&quot;good_ending&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">condition</span><span class="p">(</span><span class="s2">&quot;persistent.unlock_3 and persistent.unlock_4&quot;</span><span class="p">)</span>
<span class="c1"># The final two buttons contain images that show multiple pictures</span>
<span class="c1"># at the same time. This can be used to compose character art onto</span>
<span class="c1"># a background.</span>
<span class="n">g</span><span class="o">.</span><span class="k">button</span><span class="p">(</span><span class="s2">&quot;dawn mary&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock_image</span><span class="p">(</span><span class="s2">&quot;dawn1&quot;</span><span class="p">,</span> <span class="s2">&quot;mary dawn wistful&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock_image</span><span class="p">(</span><span class="s2">&quot;dawn1&quot;</span><span class="p">,</span> <span class="s2">&quot;mary dawn smiling&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock_image</span><span class="p">(</span><span class="s2">&quot;dawn1&quot;</span><span class="p">,</span> <span class="s2">&quot;mary dawn vhappy&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="k">button</span><span class="p">(</span><span class="s2">&quot;dark mary&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock_image</span><span class="p">(</span><span class="s2">&quot;beach2&quot;</span><span class="p">,</span> <span class="s2">&quot;mary dark wistful&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock_image</span><span class="p">(</span><span class="s2">&quot;beach2&quot;</span><span class="p">,</span> <span class="s2">&quot;mary dark smiling&quot;</span><span class="p">)</span>
<span class="n">g</span><span class="o">.</span><span class="n">unlock_image</span><span class="p">(</span><span class="s2">&quot;beach2&quot;</span><span class="p">,</span> <span class="s2">&quot;mary dark vhappy&quot;</span><span class="p">)</span>
<span class="c1"># The transition used when switching images.</span>
<span class="n">g</span><span class="o">.</span><span class="n">transition</span> <span class="o">=</span> <span class="n">dissolve</span>
<span class="c1"># Step 3. The gallery screen we use.</span>
<span class="k">screen</span> <span class="n">gallery</span><span class="p">:</span>
<span class="c1"># Ensure this replaces the main menu.</span>
<span class="k">tag</span> <span class="k">menu</span>
<span class="c1"># The background.</span>
<span class="k">add</span> <span class="s2">&quot;beach2&quot;</span>
<span class="c1"># A grid of buttons.</span>
<span class="k">grid</span> <span class="mi">3</span> <span class="mi">3</span><span class="p">:</span>
<span class="na">xfill</span> <span class="kc">True</span>
<span class="na">yfill</span> <span class="kc">True</span>
<span class="c1"># Call make_button to show a particular button.</span>
<span class="k">add</span> <span class="n">g</span><span class="o">.</span><span class="n">make_button</span><span class="p">(</span><span class="s2">&quot;dark&quot;</span><span class="p">,</span> <span class="s2">&quot;gal-dark.png&quot;</span><span class="p">,</span> <span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="na">yalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="k">add</span> <span class="n">g</span><span class="o">.</span><span class="n">make_button</span><span class="p">(</span><span class="s2">&quot;dawn&quot;</span><span class="p">,</span> <span class="s2">&quot;gal-dawn.png&quot;</span><span class="p">,</span> <span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="na">yalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="k">add</span> <span class="n">g</span><span class="o">.</span><span class="n">make_button</span><span class="p">(</span><span class="s2">&quot;end1&quot;</span><span class="p">,</span> <span class="s2">&quot;gal-end1.png&quot;</span><span class="p">,</span> <span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="na">yalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="k">add</span> <span class="n">g</span><span class="o">.</span><span class="n">make_button</span><span class="p">(</span><span class="s2">&quot;end2&quot;</span><span class="p">,</span> <span class="s2">&quot;gal-end2.png&quot;</span><span class="p">,</span> <span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="na">yalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="k">add</span> <span class="n">g</span><span class="o">.</span><span class="n">make_button</span><span class="p">(</span><span class="s2">&quot;end3&quot;</span><span class="p">,</span> <span class="s2">&quot;gal-end3.png&quot;</span><span class="p">,</span> <span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="na">yalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="k">add</span> <span class="n">g</span><span class="o">.</span><span class="n">make_button</span><span class="p">(</span><span class="s2">&quot;end4&quot;</span><span class="p">,</span> <span class="s2">&quot;gal-end4.png&quot;</span><span class="p">,</span> <span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="na">yalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="k">add</span> <span class="n">g</span><span class="o">.</span><span class="n">make_button</span><span class="p">(</span><span class="s2">&quot;dark mary&quot;</span><span class="p">,</span> <span class="s2">&quot;gal-dark_mary.png&quot;</span><span class="p">,</span> <span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="na">yalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="k">add</span> <span class="n">g</span><span class="o">.</span><span class="n">make_button</span><span class="p">(</span><span class="s2">&quot;dawn mary&quot;</span><span class="p">,</span> <span class="s2">&quot;gal-dawn_mary.png&quot;</span><span class="p">,</span> <span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="na">yalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="k">add</span> <span class="n">g</span><span class="o">.</span><span class="n">make_button</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">,</span> <span class="s2">&quot;title.png&quot;</span><span class="p">,</span> <span class="na">xalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="na">yalign</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
<span class="c1"># The screen is responsible for returning to the main menu. It could also</span>
<span class="c1"># navigate to other gallery screens.</span>
<span class="k">textbutton</span> <span class="s2">&quot;Return&quot;</span> <span class="na">action</span> <span class="n">Return</span><span class="p">()</span> <span class="na">xalign</span> <span class="mf">0.5</span> <span class="na">yalign</span> <span class="mf">0.5</span>
</pre></div>
</div>
<p>Step 4 will vary based on how your game is structured, but one way of
accomplishing it is to add the following line:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">textbutton</span> <span class="s2">&quot;Gallery&quot;</span> <span class="na">action</span> <span class="n">ShowMenu</span><span class="p">(</span><span class="s2">&quot;gallery&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>to the main menu screen.</p>
<dl class="class">
<dt id="Gallery">
<em class="property">class </em><code class="descname">Gallery</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery" title="Permalink to this definition"> link</a></dt>
<dd><p>This class supports the creation of an image gallery by handling the
locking of images, providing an action that can show one or more images,
and a providing method that creates buttons that use that action.</p>
<dl class="attribute">
<dt id="Gallery.transition">
<code class="descname">transition</code><a class="headerlink" href="#Gallery.transition" title="Permalink to this definition"> link</a></dt>
<dd><p>The transition that is used when changing images.</p>
</dd></dl>
<dl class="attribute">
<dt id="Gallery.locked_button">
<code class="descname">locked_button</code><a class="headerlink" href="#Gallery.locked_button" title="Permalink to this definition"> link</a></dt>
<dd><p>The default displayable used by make_button for a locked button.</p>
</dd></dl>
<dl class="attribute">
<dt id="Gallery.hover_border">
<code class="descname">hover_border</code><a class="headerlink" href="#Gallery.hover_border" title="Permalink to this definition"> link</a></dt>
<dd><p>The default hover border used by make_button.</p>
</dd></dl>
<dl class="attribute">
<dt id="Gallery.idle_border">
<code class="descname">idle_border</code><a class="headerlink" href="#Gallery.idle_border" title="Permalink to this definition"> link</a></dt>
<dd><p>The default idle border used by make_button.</p>
</dd></dl>
<dl class="attribute">
<dt id="Gallery.unlocked_advance">
<code class="descname">unlocked_advance</code><a class="headerlink" href="#Gallery.unlocked_advance" title="Permalink to this definition"> link</a></dt>
<dd><p>If true, the gallery will only advance through unlocked images.</p>
</dd></dl>
<dl class="attribute">
<dt id="Gallery.navigation">
<code class="descname">navigation</code><a class="headerlink" href="#Gallery.navigation" title="Permalink to this definition"> link</a></dt>
<dd><p>If true, the gallery will display navigation and slideshow
buttons on top of the images.</p>
<p>To customize the look of the navigation, you may override the
gallery_navigation screen. The default screen is defined in
renpy/common/00gallery.rpy</p>
</dd></dl>
<dl class="attribute">
<dt id="Gallery.span_buttons">
<code class="descname">span_buttons</code><a class="headerlink" href="#Gallery.span_buttons" title="Permalink to this definition"> link</a></dt>
<dd><p>If true, the gallery will advance between buttons.</p>
</dd></dl>
<dl class="attribute">
<dt id="Gallery.slideshow_delay">
<code class="descname">slideshow_delay</code><a class="headerlink" href="#Gallery.slideshow_delay" title="Permalink to this definition"> link</a></dt>
<dd><p>The time it will take for the gallery to advance between images
in slideshow mode.</p>
</dd></dl>
<dl class="attribute">
<dt>
<code class="descname">image_screen = &quot;_gallery&quot;</code></dt>
<dd><p>The screen that is used to show individual images in this gallery.
This screen is supplied the following keyword arguments:</p>
<dl class="docutils">
<dt><cite>locked</cite></dt>
<dd>True if the image is locked.</dd>
<dt><cite>displayables</cite></dt>
<dd>A list of transformed displayables that should be shown to the user.</dd>
<dt><cite>index</cite></dt>
<dd>A 1-based index of the image being shown.</dd>
<dt><cite>count</cite></dt>
<dd>The number of images attached to the current button.</dd>
<dt><cite>gallery</cite></dt>
<dd>The image gallery object.</dd>
</dl>
<p>Additional arguments may be supplied by prefixing them with
<cite>show_</cite> in calls to Gallery.image and Gallery.unlock image.</p>
<p>The default screen is defined at the bottom of renpy/common/00gallery.rpy.</p>
</dd></dl>
<dl class="method">
<dt id="Gallery.Action">
<code class="descname">Action</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.Action" title="Permalink to this definition"> link</a></dt>
<dd><p>An action that displays the images associated with the given button
name.</p>
</dd></dl>
<dl class="method">
<dt id="Gallery.Next">
<code class="descname">Next</code><span class="sig-paren">(</span><em>unlocked=False</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.Next" title="Permalink to this definition"> link</a></dt>
<dd><p>Advances to the next image in the gallery.</p>
<dl class="docutils">
<dt><cite>unlocked</cite></dt>
<dd>If true, only considers unlocked images.</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="Gallery.Previous">
<code class="descname">Previous</code><span class="sig-paren">(</span><em>unlocked=False</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.Previous" title="Permalink to this definition"> link</a></dt>
<dd><p>Goes to the previous image in the gallery.</p>
<dl class="docutils">
<dt><cite>unlocked</cite></dt>
<dd>If true, only considers unlocked images.</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="Gallery.Return">
<code class="descname">Return</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.Return" title="Permalink to this definition"> link</a></dt>
<dd><p>Stops displaying gallery images.</p>
</dd></dl>
<dl class="method">
<dt id="Gallery.ToggleSlideshow">
<code class="descname">ToggleSlideshow</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.ToggleSlideshow" title="Permalink to this definition"> link</a></dt>
<dd><p>Toggles slideshow mode.</p>
</dd></dl>
<dl class="method">
<dt id="Gallery.allprior">
<code class="descname">allprior</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.allprior" title="Permalink to this definition"> link</a></dt>
<dd><p>A condition that is true if all prior images associated with the
current button have been unlocked.</p>
</dd></dl>
<dl class="method">
<dt id="Gallery.button">
<code class="descname">button</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.button" title="Permalink to this definition"> link</a></dt>
<dd><p>Creates a new button, named <cite>name</cite>.</p>
<dl class="docutils">
<dt><cite>name</cite></dt>
<dd>The name of the button being created.</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="Gallery.condition">
<code class="descname">condition</code><span class="sig-paren">(</span><em>expression</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.condition" title="Permalink to this definition"> link</a></dt>
<dd><p>A condition that is satisfied when an expression evaluates to true.</p>
<dl class="docutils">
<dt><cite>expression</cite></dt>
<dd>A string giving a Python expression.</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="Gallery.get_fraction">
<code class="descname">get_fraction</code><span class="sig-paren">(</span><em>name</em>, <em>format=u'{seen}/{total}'</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.get_fraction" title="Permalink to this definition"> link</a></dt>
<dd><p>Returns a text string giving the number of unlocked images and total number of images in the button
named <cite>name</cite>.</p>
<dl class="docutils">
<dt><cite>format</cite></dt>
<dd><p class="first">A Python format string that's used to format the numbers. This has three values that
can be substituted in:</p>
<dl class="last docutils">
<dt>{seen}</dt>
<dd>The number of images that have been seen.</dd>
<dt>{total}</dt>
<dd>The total number of images in the button.</dd>
<dt>{locked}</dt>
<dd>The number of images that are still locked.</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="Gallery.image">
<code class="descname">image</code><span class="sig-paren">(</span><em>*displayables</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.image" title="Permalink to this definition"> link</a></dt>
<dd><p>Adds a new image to the current button, where an image consists
of one or more displayables.</p>
<p>Properties beginning with <cite>show_</cite> have that prefix stripped off,
and are passed to the gallery.image_screen screen as additional
keyword arguments.</p>
</dd></dl>
<dl class="method">
<dt id="Gallery.make_button">
<code class="descname">make_button</code><span class="sig-paren">(</span><em>name</em>, <em>unlocked</em>, <em>locked=None</em>, <em>hover_border=None</em>, <em>idle_border=None</em>, <em>style=None</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.make_button" title="Permalink to this definition"> link</a></dt>
<dd><p>This creates a button that displays the images associated with the given
button name.</p>
<dl class="docutils">
<dt><cite>name</cite></dt>
<dd>The name of the button that will be created.</dd>
<dt><cite>unlocked</cite></dt>
<dd>A displayable that is displayed for this button when it is
unlocked.</dd>
<dt><cite>locked</cite></dt>
<dd>A displayable that is displayed for this button when it is
locked. If None, the locked_button field of the gallery
object is used instead.</dd>
<dt><cite>hover_border</cite></dt>
<dd>A displayable that is used to overlay this button when
it is unlocked and has focus. If None, the hover_border
field of the gallery object is used.</dd>
<dt><cite>idle_border</cite></dt>
<dd>A displayable that is used to overlay this button when
it is unlocked but unfocused. If None, the idle_border
field of the gallery object is used.</dd>
<dt><cite>style</cite></dt>
<dd>The style the button inherits from. When None, defaults
to the &quot;empty&quot; style, so as not to inherit borders and
so on.</dd>
</dl>
<p>Additional keyword arguments become style properties of the
created button object.</p>
</dd></dl>
<dl class="method">
<dt id="Gallery.transform">
<code class="descname">transform</code><span class="sig-paren">(</span><em>*transforms</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.transform" title="Permalink to this definition"> link</a></dt>
<dd><p>Applies transforms to the last image registered. This should be
called with the same number of transforms as the image has
displayables. The transforms are applied to the corresponding
displayables.</p>
<p>If a transform is None, the default transform is used.</p>
</dd></dl>
<dl class="method">
<dt id="Gallery.unlock">
<code class="descname">unlock</code><span class="sig-paren">(</span><em>*images</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.unlock" title="Permalink to this definition"> link</a></dt>
<dd><p>A condition that takes one or more image names as argument, and
is satisfied when all the named images have been seen by the
player. The image names should be given as strings.</p>
</dd></dl>
<dl class="method">
<dt id="Gallery.unlock_image">
<code class="descname">unlock_image</code><span class="sig-paren">(</span><em>*images</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#Gallery.unlock_image" title="Permalink to this definition"> link</a></dt>
<dd><p>A convenience method that is equivalent to calling image and unlock
with the same parameters. (Keyword arguments beginning with <code class="docutils literal notranslate"><span class="pre">show_</span></code> are
only passed to image.) This will cause an image to be displayed
if it has been seen before.</p>
<p>The images should be specified as strings giving image names.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="music-room">
<span id="id2"></span><h2>Music Room<a class="headerlink" href="#music-room" title="Permalink to this headline"> link</a></h2>
<p>A music room is a screen that allows the user to select and play music
tracks from the game. These tracks may start off locked when the user
first begins playing a particular game, and will be unlocked as the
user listens to the music while playing the game.</p>
<p>A music room is managed by an instance of the MusicRoom class. There
can be more than one MusicRoom instance in a game, allowing a game to
have multiple music rooms. Creating a music room consists of the
following four steps:</p>
<ol class="arabic">
<li><p class="first">Create an instance of MusicRoom. The MusicRoom constructor takes
parameters to control the channel on which music is played back,
and how long it takes to fade music out and back in.</p>
</li>
<li><p class="first">Add music files to the instance.</p>
</li>
<li><p class="first">Create a screen that uses the MusicRoom instance to create actions
for buttons, imagebuttons, or hotspots. These actions can pick a
track, the next or previous track, or stop and start the music.</p>
<p>Note that the actions used are members of a MusicRoom instance,
so if the MusicRoom instance is named <code class="docutils literal notranslate"><span class="pre">mr</span></code>, then
<code class="docutils literal notranslate"><span class="pre">mr.Play(&quot;track1.ogg&quot;)</span></code> is how you'd use the play action.</p>
</li>
<li><p class="first">Add the music room screen to the main menu, or an extras menu.</p>
</li>
</ol>
<p>Here's an example:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">init</span> <span class="k">python</span><span class="p">:</span>
<span class="c1"># Step 1. Create a MusicRoom instance.</span>
<span class="n">mr</span> <span class="o">=</span> <span class="n">MusicRoom</span><span class="p">(</span><span class="n">fadeout</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span>
<span class="c1"># Step 2. Add music files.</span>
<span class="n">mr</span><span class="o">.</span><span class="k">add</span><span class="p">(</span><span class="s2">&quot;track1.ogg&quot;</span><span class="p">,</span> <span class="n">always_unlocked</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">mr</span><span class="o">.</span><span class="k">add</span><span class="p">(</span><span class="s2">&quot;track2.ogg&quot;</span><span class="p">)</span>
<span class="n">mr</span><span class="o">.</span><span class="k">add</span><span class="p">(</span><span class="s2">&quot;track3.ogg&quot;</span><span class="p">)</span>
<span class="c1"># Step 3. Create the music room screen.</span>
<span class="k">screen</span> <span class="n">music_room</span><span class="p">:</span>
<span class="k">tag</span> <span class="k">menu</span>
<span class="k">frame</span><span class="p">:</span>
<span class="k">has</span> <span class="k">vbox</span>
<span class="c1"># The buttons that play each track.</span>
<span class="k">textbutton</span> <span class="s2">&quot;Track 1&quot;</span> <span class="na">action</span> <span class="n">mr</span><span class="o">.</span><span class="n">Play</span><span class="p">(</span><span class="s2">&quot;track1.ogg&quot;</span><span class="p">)</span>
<span class="k">textbutton</span> <span class="s2">&quot;Track 2&quot;</span> <span class="na">action</span> <span class="n">mr</span><span class="o">.</span><span class="n">Play</span><span class="p">(</span><span class="s2">&quot;track2.ogg&quot;</span><span class="p">)</span>
<span class="k">textbutton</span> <span class="s2">&quot;Track 3&quot;</span> <span class="na">action</span> <span class="n">mr</span><span class="o">.</span><span class="n">Play</span><span class="p">(</span><span class="s2">&quot;track3.ogg&quot;</span><span class="p">)</span>
<span class="k">null</span> <span class="na">height</span> <span class="mi">20</span>
<span class="c1"># Buttons that let us advance tracks.</span>
<span class="k">textbutton</span> <span class="s2">&quot;Next&quot;</span> <span class="na">action</span> <span class="n">mr</span><span class="o">.</span><span class="n">Next</span><span class="p">()</span>
<span class="k">textbutton</span> <span class="s2">&quot;Previous&quot;</span> <span class="na">action</span> <span class="n">mr</span><span class="o">.</span><span class="n">Previous</span><span class="p">()</span>
<span class="k">null</span> <span class="na">height</span> <span class="mi">20</span>
<span class="c1"># The button that lets the user exit the music room.</span>
<span class="k">textbutton</span> <span class="s2">&quot;Main Menu&quot;</span> <span class="na">action</span> <span class="n">ShowMenu</span><span class="p">(</span><span class="s2">&quot;main_menu&quot;</span><span class="p">)</span>
<span class="c1"># Start the music playing on entry to the music room.</span>
<span class="k">on</span> <span class="s2">&quot;replace&quot;</span> <span class="na">action</span> <span class="n">mr</span><span class="o">.</span><span class="n">Play</span><span class="p">()</span>
<span class="c1"># Restore the main menu music upon leaving.</span>
<span class="k">on</span> <span class="s2">&quot;replaced&quot;</span> <span class="na">action</span> <span class="n">Play</span><span class="p">(</span><span class="s2">&quot;music&quot;</span><span class="p">,</span> <span class="s2">&quot;track1.ogg&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Step 4 will vary based on how your game is structured, but one way of
accomplishing it is to add the following line:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">textbutton</span> <span class="s2">&quot;Music Room&quot;</span> <span class="na">action</span> <span class="n">ShowMenu</span><span class="p">(</span><span class="s2">&quot;music_room&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>to the main menu screen.</p>
<p>Using the <code class="xref py py-func docutils literal notranslate"><span class="pre">Preferences()</span></code> function, especially
<code class="docutils literal notranslate"><span class="pre">Preferences(&quot;music</span> <span class="pre">volume&quot;)</span></code>, it's possible to include a volume
slider on the music screen.</p>
<dl class="class">
<dt id="MusicRoom">
<em class="property">class </em><code class="descname">MusicRoom</code><span class="sig-paren">(</span><em>channel=u'music'</em>, <em>fadeout=0.0</em>, <em>fadein=0.0</em>, <em>loop=True</em>, <em>single_track=False</em>, <em>shuffle=False</em>, <em>stop_action=None</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom" title="Permalink to this definition"> link</a></dt>
<dd><p>A music room that contains a series of songs that can be unlocked
by the user, and actions that can play entries from the list in
order.</p>
<dl class="docutils">
<dt><cite>channel</cite></dt>
<dd>The channel that this music room will operate on.</dd>
<dt><cite>fadeout</cite></dt>
<dd>The number of seconds it takes to fade out the old
music when changing tracks.</dd>
<dt><cite>fadein</cite></dt>
<dd>The number of seconds it takes to fade in the new
music when changing tracks.</dd>
<dt><cite>loop</cite></dt>
<dd>Determines if playback will loop or stop when it reaches
the end of the playlist.</dd>
<dt><cite>single_track</cite></dt>
<dd>If true, only a single track will play. If loop is true,
that track will loop. Otherwise, playback will stop when the
track finishes.</dd>
<dt><cite>shuffle</cite></dt>
<dd>If true, the tracks are shuffled, and played in the shuffled
order. If false, the tracks are played in the order they're
added to the MusicRoom.</dd>
<dt><cite>stop_action</cite></dt>
<dd>An action to run when the music has stopped.</dd>
</dl>
<p>Single_track and shuffle conflict with each other. Only one should
be true at a time. (Actions that set single_track and shuffle
enforce this.)</p>
<dl class="method">
<dt id="MusicRoom.Next">
<code class="descname">Next</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.Next" title="Permalink to this definition"> link</a></dt>
<dd><p>An action that causes the music room to play the next unlocked file
in the playlist.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.Play">
<code class="descname">Play</code><span class="sig-paren">(</span><em>filename=None</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.Play" title="Permalink to this definition"> link</a></dt>
<dd><p>This action causes the music room to start playing. If <cite>filename</cite> is given, that
file begins playing. Otherwise, the currently playing file starts
over (if it's unlocked), or the first file starts playing.</p>
<p>If <cite>filename</cite> is given, buttons with this action will be insensitive
while <cite>filename</cite> is locked, and will be selected when <cite>filename</cite>
is playing.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.Previous">
<code class="descname">Previous</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.Previous" title="Permalink to this definition"> link</a></dt>
<dd><p>An action that causes the music room to play the previous unlocked
file in the playlist.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.RandomPlay">
<code class="descname">RandomPlay</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.RandomPlay" title="Permalink to this definition"> link</a></dt>
<dd><p>This action causes the music room to start playing a randomly selected unlocked
music track.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.SetLoop">
<code class="descname">SetLoop</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.SetLoop" title="Permalink to this definition"> link</a></dt>
<dd><p>This action sets the value of the loop property.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.SetShuffle">
<code class="descname">SetShuffle</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.SetShuffle" title="Permalink to this definition"> link</a></dt>
<dd><p>This action sets the value of the shuffle property.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.SetSingleTrack">
<code class="descname">SetSingleTrack</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.SetSingleTrack" title="Permalink to this definition"> link</a></dt>
<dd><p>This action sets the value of the single_track property.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.Stop">
<code class="descname">Stop</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.Stop" title="Permalink to this definition"> link</a></dt>
<dd><p>This action stops the music.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.ToggleLoop">
<code class="descname">ToggleLoop</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.ToggleLoop" title="Permalink to this definition"> link</a></dt>
<dd><p>This action toggles the value of the loop property.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.TogglePause">
<code class="descname">TogglePause</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.TogglePause" title="Permalink to this definition"> link</a></dt>
<dd><p>If music is playing, pauses or unpauses the music as appropriate.</p>
<p>This button is selected when the music is paused.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.TogglePlay">
<code class="descname">TogglePlay</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.TogglePlay" title="Permalink to this definition"> link</a></dt>
<dd><p>If no music is currently playing, this action starts playing the first
unlocked track. Otherwise, stops the currently playing music.</p>
<p>This button is selected when any music is playing.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.ToggleShuffle">
<code class="descname">ToggleShuffle</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.ToggleShuffle" title="Permalink to this definition"> link</a></dt>
<dd><p>This action toggles the value of the shuffle property.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.ToggleSingleTrack">
<code class="descname">ToggleSingleTrack</code><span class="sig-paren">(</span><em>self</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.ToggleSingleTrack" title="Permalink to this definition"> link</a></dt>
<dd><p>This action toggles the value of the single_track property.</p>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.add">
<code class="descname">add</code><span class="sig-paren">(</span><em>filename</em>, <em>always_unlocked=False</em>, <em>action=None</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.add" title="Permalink to this definition"> link</a></dt>
<dd><p>Adds the music file <cite>filename</cite> to this music room. The music room
will play unlocked files in the order that they are added to the
room.</p>
<dl class="docutils">
<dt><cite>always_unlocked</cite></dt>
<dd>If true, the music file will be always unlocked. This allows
the file to show up in the music room before it has been
played in the game.</dd>
<dt><cite>action</cite></dt>
<dd><p class="first">This is a action or the list of actions. these are called when this
file is played.</p>
<p class="last">For example, These actions is used to change a screen or background, description
by the playing file.</p>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="MusicRoom.is_unlocked">
<code class="descname">is_unlocked</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="headerlink" href="#MusicRoom.is_unlocked" title="Permalink to this definition"> link</a></dt>
<dd><p>Returns true if the filename has been unlocked (or is always
unlocked), and false if it is still locked.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="replay">
<span id="id3"></span><h2>Replay<a class="headerlink" href="#replay" title="Permalink to this headline"> link</a></h2>
<p>Ren'Py also includes the ability to replay a scene from inside a the
main or game menu. This can be used to create a &quot;scene gallery&quot;, or
memory gallery that allows the player to repeat important scenes.
After the scene finishes, Ren'Py returns to the menu screen that
launched the replay.</p>
<p>Scene replay is also possible using the <a class="reference internal" href="screen_actions.html#Start" title="Start"><code class="xref py py-func docutils literal notranslate"><span class="pre">Start()</span></code></a> action. The
difference between the two modes are:</p>
<ul class="simple">
<li>A replay can be launched from any screen while Start can only be
used in the main menu or screens shown by the main menu.</li>
<li>When a replay finishes, control returns to the point where the
replay was invoked. That point can be inside the main menu, game
menu. If a game is in progress when replay is called, game state is
preserved.</li>
<li>Saving is disabled while in replay mode.</li>
<li>While in replay mode, a call to <a class="reference internal" href="#renpy.end_replay" title="renpy.end_replay"><code class="xref py py-func docutils literal notranslate"><span class="pre">renpy.end_replay()</span></code></a> will end
the replay. In normal mode, end_replay does nothing.</li>
</ul>
<p>To take advantage of the replay mode, a scene should begin with a
label, and end with a call to <a class="reference internal" href="#renpy.end_replay" title="renpy.end_replay"><code class="xref py py-func docutils literal notranslate"><span class="pre">renpy.end_replay()</span></code></a>. The scene should make
no assumption as to the state of the layers or variables, which can be
very different in normal and replay mode. (When a replay begins, the label
is invoked with a black screen.)</p>
<p>For example:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span>
<span class="s2">&quot;And finally, I met the wizard himself.&quot;</span>
<span class="k">label</span> <span class="n">meaning_of_life</span><span class="p">:</span>
<span class="k">scene</span>
<span class="s2">&quot;Mage&quot;</span> <span class="s2">&quot;What is the meaning of life, you say?&quot;</span>
<span class="s2">&quot;Mage&quot;</span> <span class="s2">&quot;I&#39;ve thought about it long and hard. A long time, I&#39;ve</span>
<span class="n">spent</span> <span class="n">pondering</span> <span class="n">that</span> <span class="n">very</span> <span class="n">thing</span><span class="o">.</span><span class="s2">&quot;</span>
<span class="s2">&quot;Mage&quot;</span> <span class="s2">&quot;And I&#39;ll say - the answer - the meaning of life</span>
<span class="n">itself</span><span class="o">...</span><span class="s2">&quot;</span>
<span class="s2">&quot;Mage&quot;</span> <span class="s2">&quot;Is forty-three.&quot;</span>
<span class="k">$</span> <span class="n">renpy</span><span class="o">.</span><span class="n">end_replay</span><span class="p">()</span>
<span class="s2">&quot;Mage&quot;</span> <span class="s2">&quot;Something like that, anyway.&quot;</span>
</pre></div>
</div>
<p>With the scene define like that, the replay can be invoked with the
Replay action:</p>
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">textbutton</span> <span class="s2">&quot;The meaning of life&quot;</span> <span class="na">action</span> <span class="n">Replay</span><span class="p">(</span><span class="s2">&quot;meaning_of_life&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>There is one store variable used by replay mode:</p>
<dl class="var">
<dt id="var-_in_replay">
<code class="descname">_in_replay</code><a class="headerlink" href="#var-_in_replay" title="Permalink to this definition"> link</a></dt>
<dd><p>When in replay mode, this is sent to the label at which replay
mode was started. Outside of replay mode, this is None.</p>
</dd></dl>
<p>In addition, <a class="reference internal" href="config.html#var-config.enter_replay_transition"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.enter_replay_transition</span></code></a> and
<a class="reference internal" href="config.html#var-config.exit_replay_transition"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.exit_replay_transition</span></code></a> are used when entering and exiting
replay mode, respectively. <a class="reference internal" href="config.html#var-config.replay_scope"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.replay_scope</span></code></a> adds variables
to the cleaned store when entering a replay, and by default sets
<a class="reference internal" href="store_variables.html#var-_game_menu_screen"><code class="xref std std-var docutils literal notranslate"><span class="pre">_game_menu_screen</span></code></a> to cause right-clicking in a replay to
default to showing the preferences screen.</p>
<p>The following variables and actions are used in replay mode:</p>
<dl class="function">
<dt id="EndReplay">
<code class="descname">EndReplay</code><span class="sig-paren">(</span><em>confirm=True</em><span class="sig-paren">)</span><a class="headerlink" href="#EndReplay" title="Permalink to this definition"> link</a></dt>
<dd><p>Ends the current replay.</p>
<dl class="docutils">
<dt><cite>confirm</cite></dt>
<dd>If true, prompts the user for confirmation before ending the
replay.</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="Replay">
<code class="descname">Replay</code><span class="sig-paren">(</span><em>label</em>, <em>scope={}</em>, <em>locked=None</em><span class="sig-paren">)</span><a class="headerlink" href="#Replay" title="Permalink to this definition"> link</a></dt>
<dd><p>An action that starts <cite>label</cite> as a replay.</p>
<dl class="docutils">
<dt><cite>scope</cite></dt>
<dd>A dictionary mapping variable name to value. These variables are set
when entering the replay.</dd>
<dt><cite>locked</cite></dt>
<dd>If true, this replay is locked. If false, it is unlocked. If None, the
replay is locked if the label has not been seen in any playthrough.</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="renpy.call_replay">
<code class="descclassname">renpy.</code><code class="descname">call_replay</code><span class="sig-paren">(</span><em>label</em>, <em>scope={}</em><span class="sig-paren">)</span><a class="headerlink" href="#renpy.call_replay" title="Permalink to this definition"> link</a></dt>
<dd><p>Calls a label as a memory.</p>
<p>Keyword arguments are used to set the initial values of variables in the
memory context.</p>
</dd></dl>
<dl class="function">
<dt id="renpy.end_replay">
<code class="descclassname">renpy.</code><code class="descname">end_replay</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#renpy.end_replay" title="Permalink to this definition"> link</a></dt>
<dd><p>If we're in a replay, ends the replay immediately. Otherwise, does
nothing.</p>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-right">
<a href="#">Back to top</a>
</p>
<p>
&copy; Copyright 2012-2022, Tom Rothamel.<br/>
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.6.<br/>
</p>
</div>
</footer>
</body>
</html>