documentation indexreference manualfunction index

Contents

Themes

Themes provide a simple way of changing the look of the main and game menus. A single function call applies styles to many of the elements of the main and game menus, giving a consistent look to the interface.

Theme functions should be called after the config.screen_width, config.screen_height, and library.script_version variables have been set, and after any layout functions have been called. They should be called before any style is changed by hand.

Theme Functions

These theme functions are


Function: theme.roundrect (widget="#003c78", widget_hover="#0050a0", widget_text="#c8e1ff", widget_selected="#ffffc8", disabled="#404040", disabled_text="#c8c8c8", label=,"#ffffff" frame="#6496c8", window="#000000c0", text_size=None, small_text_size=None, mm_root=..., gm_root=..., less_rounded=False):

This enables the use of the roundrect theme. By default, this theme styles the game in a blue color scheme. However, by supplying one or more of the parameters given below, the color scheme can be changed.

widget - The background color of non-focued buttons and sliders.

widget_hover - The background color of focused buttons and sliders.

widget_text - The text color of non-selected buttons.

widget_selected - The text color of selected buttons.

disabled - The background color of disabled buttons.

disabled_text - The text color of disabled buttons.

label - The text color of non-selected labels.

frame - The background color of frames.

mm_root - A displayable (such as an Image or Solid) that will be used as the background for the main menu.

gm_root - A displayable (such as an Image or Solid) that will be used as the background for the game menu.

less_rounded - If True, causes the buttons to appear less rounded in 800x600 mode (has no effect in 640x480 mode).

text_size - The size of text, such as button captions, labels, and prompts. Defaults to 18 if the screen is 640 pixels wide or less, and 22 otherwise.

small_text_size - The size of the text on large buttons. Defaults to 12 if the screen is 640 pixels wide or less, and 16 otherwise.

widget, widget_hover, disabled, and frame may either be single colors, or tuples containing two colors. In the latter case, a vertical gradient is used.

Component functions

The following functions exist to allow you to add elements of the roundrect theme to another theme. The other theme must have been set up before these functions can be used. Arguments are as for roundrect, except that all must be specified (no defaulting occurs).



Function: theme.outline (inside="#fff", idle="#e66", hover="#48f", selected="#84f", insensitive="#ccc", label="#484", prompt="#484", background="#fee", large_button="#fff8f8", text_size=22, small_text_size=16):

This function selects a theme that is based on outlining text in different colors.

inside - The color of text inside the various outlines.

idle - The outline color of the text of an idle button or bar.

hover - The outline color of a hovered button or bar.

selected - The outline color of a selected button.

insensitive - The outline color of an insensitive button.

label - The outline color of a label.

prompt - The outline color of a prompt.

background - A displayable used for the game and main menu backgrounds.

large_button - The background color of large backgrounds.

text_size - The size of large text. (Used for buttons, labels, and prompts.)

small_text_size - The size of small text. (Used in large buttons.)

Component functions

The following functions exist to allow you to add elements of the outline theme to another theme. The other theme must have been set up before these functions can be used. Arguments are as for theme.outline, except that all must be specified (no defaulting occurs).




Function: theme.ancient ():

This is a theme that attempts to emulate the theme used by Ren'Py 6.5.0 when no theme was explicitly specified.



Theme Modifiers

These are functions that can be called after a theme function, allowing you to change a portion of a theme.


Function: theme.image_buttons (d):

Used to define buttons in terms of 5-tuples of image filenames. This expects its single parameter, d, to be a dictionary mapping untranslated button names to 5-tuples. Each 5-tuple should contain 5 filenames, giving the image used for the button when:

in that order.


Function: theme.image_labels (d):

Replaces labels with images. This takes a single parameter, d, which is expected to be a map from the text of a label to an image file.


Custom Theme

It's also possible to define your own Ren'Py theme. A custom theme consists of Ren'Py code that does the following.

Often, the base styles come in name/name_text pairs. In these cases, name represents a Button or Window with style name, in which a Text with style name_text lives.

The base styles are:

style.frame (inherits from style.default)
Used for frames on top of which the rest of the interface can comfortably sit.
style.button (inherits from style.default)
style.button_text (inherits from style.default)
Used for buttons, especially buttons whose primary purpose is navigating through the interface. (Like the main menu and the game menu navigation buttons.)
style.small_button (inherits from style.button)
style.small_button_text (inherits from style.button_text)
Used for smaller navigation buttons. It might make sense to set a minimum width on buttons, but small_buttons should be allowed to shrink as small as possible.
style.radio_button (inherits from style.button)
style.radio_button_text (inherits from style.button_text)
Used for buttons that are arranged in a group, such that only one of the buttons in the group can be selected at a time.
style.check_button (inherits from style.button)
style.check_button_text (inherits from style.button_text)
Used for buttons that toggle their selected state to indicate if an option is set or not. (These aren't used in any of the pre-defined layouts.)
style.large_button (inherits from style.default)
style.large_button_text (inherits from style.default)
Used for large buttons, such as file picker entries, that can contain a large amount of text and other information.
style.label (inherits from style.default)
style.label_text (inherits from style.default)
Used for labels, which are small text messages that never change.
style.prompt (inherits from style.default)
style.prompt_text (inherits from style.default)
Used for prompts, longer text messages which may change at runtime.
style.bar (inherits from style.default)
style.vbar (inherits from style.default)
Used for horizontal and vertical bars, respectively. Bars are generally intended to indicate a quantity or an amount of progress, but aren't expected to be adjusted by the user.
style.slider (inherits from style.default)
style.vslider (inherits from style.default)
Used for horizontal and vertical sliders, respectively. Sliders are bars that are used to adjust a value.
style.scrollbar (inherits from style.default)
style.vscrollbar (inherits from style.default)
Used for horizontal and vertical scrollbars, respectively.
style.mm_root (inherits from style.default)
style.gm_root (inherits from style.default)
Used for the backgrounds of the main and game menus, respectively.

Generally, themes should not adjust the margins, positioning properties, or maximum sizes of these styles. An exception is that the bars are expected to set a maximum size in a direction perpendicular to the orientation of the bar (ymaximum for bar and scrollbar; xmaximum for vbar and vscrollbar). No limitations apply to the _text styles.


documentation indexreference manualfunction index