mirror of
https://github.com/evennia/evennia.git
synced 2026-03-21 15:26:30 +01:00
552 lines
No EOL
40 KiB
HTML
552 lines
No EOL
40 KiB
HTML
<!DOCTYPE html>
|
||
|
||
<html lang="en" data-content_root="../">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
|
||
<title>evennia.contrib.utils.tree_select.tree_select — Evennia latest documentation</title>
|
||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=d75fae25" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/nature.css?v=279e0f84" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/custom.css?v=e4a91a55" />
|
||
<script src="../_static/documentation_options.js?v=c6e86fd7"></script>
|
||
<script src="../_static/doctools.js?v=9bcbadda"></script>
|
||
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
|
||
<link rel="icon" href="../_static/favicon.ico"/>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="evennia.help" href="evennia.help.html" />
|
||
<link rel="prev" title="evennia.contrib.utils.tree_select.tests" href="evennia.contrib.utils.tree_select.tests.html" />
|
||
</head><body>
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.help.html" title="evennia.help"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.contrib.utils.tree_select.tests.html" title="evennia.contrib.utils.tree_select.tests"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.contrib.html" >evennia.contrib</a> »</li>
|
||
<li class="nav-item nav-item-5"><a href="evennia.contrib.utils.html" >evennia.contrib.utils</a> »</li>
|
||
<li class="nav-item nav-item-6"><a href="evennia.contrib.utils.tree_select.html" accesskey="U">evennia.contrib.utils.tree_select</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.contrib.utils.tree_select.tree_select</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-evennia.contrib.utils.tree_select.tree_select">
|
||
<span id="evennia-contrib-utils-tree-select-tree-select"></span><h1>evennia.contrib.utils.tree_select.tree_select<a class="headerlink" href="#module-evennia.contrib.utils.tree_select.tree_select" title="Link to this heading">¶</a></h1>
|
||
<p>Easy menu selection tree</p>
|
||
<p>Contrib - Tim Ashley Jenkins 2017</p>
|
||
<p>This module allows you to create and initialize an entire branching EvMenu
|
||
instance with nothing but a multi-line string passed to one function.</p>
|
||
<p>EvMenu is incredibly powerful and flexible, but using it for simple menus
|
||
can often be fairly cumbersome - a simple menu that can branch into five
|
||
categories would require six nodes, each with options represented as a list
|
||
of dictionaries.</p>
|
||
<p>This module provides a function, init_tree_selection, which acts as a frontend
|
||
for EvMenu, dynamically sourcing the options from a multi-line string you provide.
|
||
For example, if you define a string as such:</p>
|
||
<blockquote>
|
||
<div><p>TEST_MENU = ‘’’Foo
|
||
Bar
|
||
Baz
|
||
Qux’’’</p>
|
||
</div></blockquote>
|
||
<p>And then use TEST_MENU as the ‘treestr’ source when you call init_tree_selection
|
||
on a player:</p>
|
||
<blockquote>
|
||
<div><p>init_tree_selection(TEST_MENU, caller, callback)</p>
|
||
</div></blockquote>
|
||
<p>The player will be presented with an EvMenu, like so:</p>
|
||
<blockquote>
|
||
<div><p>Foo
|
||
Bar
|
||
Baz
|
||
Qux</p>
|
||
</div></blockquote>
|
||
<p>Making a selection will pass the selection’s key to the specified callback as a
|
||
string along with the caller, as well as the index of the selection (the line number
|
||
on the source string) along with the source string for the tree itself.</p>
|
||
<p>In addition to specifying selections on the menu, you can also specify categories.
|
||
Categories are indicated by putting options below it preceded with a ‘-’ character.
|
||
If a selection is a category, then choosing it will bring up a new menu node, prompting
|
||
the player to select between those options, or to go back to the previous menu. In
|
||
addition, categories are marked by default with a ‘[+]’ at the end of their key. Both
|
||
this marker and the option to go back can be disabled.</p>
|
||
<p>Categories can be nested in other categories as well - just go another ‘-’ deeper. You
|
||
can do this as many times as you like. There’s no hard limit to the number of
|
||
categories you can go down.</p>
|
||
<p>For example, let’s add some more options to our menu, turning ‘Bar’ into a category.</p>
|
||
<blockquote>
|
||
<div><p>TEST_MENU = ‘’’Foo
|
||
Bar
|
||
-You’ve got to know
|
||
–When to hold em
|
||
–When to fold em
|
||
–When to walk away
|
||
Baz
|
||
Qux’’’</p>
|
||
</div></blockquote>
|
||
<p>Now when we call the menu, we can see that ‘Bar’ has become a category instead of a
|
||
selectable option.</p>
|
||
<blockquote>
|
||
<div><p>Foo
|
||
Bar [+]
|
||
Baz
|
||
Qux</p>
|
||
</div></blockquote>
|
||
<p>Note the [+] next to ‘Bar’. If we select ‘Bar’, it’ll show us the option listed under it.</p>
|
||
<blockquote>
|
||
<div><p>You’ve got to know [+]
|
||
<< Go Back: Return to the previous menu.</p>
|
||
</div></blockquote>
|
||
<p>Just the one option, which is a category itself, and the option to go back, which will
|
||
take us back to the previous menu. Let’s select ‘You’ve got to know’.</p>
|
||
<blockquote>
|
||
<div><p>When to hold em
|
||
When to fold em
|
||
When to walk away
|
||
<< Go Back: Return to the previous menu.</p>
|
||
</div></blockquote>
|
||
<p>Now we see the three options listed under it, too. We can select one of them or use ‘Go
|
||
Back’ to return to the ‘Bar’ menu we were just at before. It’s very simple to make a
|
||
branching tree of selections!</p>
|
||
<p>One last thing - you can set the descriptions for the various options simply by adding a
|
||
‘:’ character followed by the description to the option’s line. For example, let’s add a
|
||
description to ‘Baz’ in our menu:</p>
|
||
<blockquote>
|
||
<div><p>TEST_MENU = ‘’’Foo
|
||
Bar
|
||
-You’ve got to know
|
||
–When to hold em
|
||
–When to fold em
|
||
–When to walk away
|
||
Baz: Look at this one: the best option.
|
||
Qux’’’</p>
|
||
</div></blockquote>
|
||
<p>Now we see that the Baz option has a description attached that’s separate from its key:</p>
|
||
<blockquote>
|
||
<div><p>Foo
|
||
Bar [+]
|
||
Baz: Look at this one: the best option.
|
||
Qux</p>
|
||
</div></blockquote>
|
||
<p>Once the player makes a selection - let’s say, ‘Foo’ - the menu will terminate and call
|
||
your specified callback with the selection, like so:</p>
|
||
<blockquote>
|
||
<div><p>callback(caller, TEST_MENU, 0, “Foo”)</p>
|
||
</div></blockquote>
|
||
<p>The index of the selection is given along with a string containing the selection’s key.
|
||
That way, if you have two selections in the menu with the same key, you can still
|
||
differentiate between them.</p>
|
||
<p>And that’s all there is to it! For simple branching-tree selections, using this system is
|
||
much easier than manually creating EvMenu nodes. It also makes generating menus with dynamic
|
||
options much easier - since the source of the menu tree is just a string, you could easily
|
||
generate that string procedurally before passing it to the init_tree_selection function.
|
||
For example, if a player casts a spell or does an attack without specifying a target, instead
|
||
of giving them an error, you could present them with a list of valid targets to select by
|
||
generating a multi-line string of targets and passing it to init_tree_selection, with the
|
||
callable performing the maneuver once a selection is made.</p>
|
||
<p>This selection system only works for simple branching trees - doing anything really complicated
|
||
like jumping between categories or prompting for arbitrary input would still require a full
|
||
EvMenu implementation. For simple selections, however, I’m sure you will find using this function
|
||
to be much easier!</p>
|
||
<p>Included in this module is a sample menu and function which will let a player change the color
|
||
of their name - feel free to mess with it to get a feel for how this system works by importing
|
||
this module in your game’s default_cmdsets.py module and adding CmdNameColor to your default
|
||
character’s command set.</p>
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.init_tree_selection">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.contrib.utils.tree_select.tree_select.</span></span><span class="sig-name descname"><span class="pre">init_tree_selection</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">treestr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">caller</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callback</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mark_category</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">go_back</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmd_on_exit</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'look'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">start_text</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'Make</span> <span class="pre">your</span> <span class="pre">selection:'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#init_tree_selection"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.init_tree_selection" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Prompts a player to select an option from a menu tree given as a multi-line string.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>treestr</strong> (<em>str</em>) – Multi-lne string representing menu options</p></li>
|
||
<li><p><strong>caller</strong> (<em>obj</em>) – Player to initialize the menu for</p></li>
|
||
<li><p><strong>callback</strong> (<em>callable</em>) – Function to run when a selection is made. Must take 4 args:
|
||
caller (obj): Caller given above
|
||
treestr (str): Menu tree string given above
|
||
index (int): Index of final selection
|
||
selection (str): Key of final selection</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
<dl class="simple">
|
||
<dt>Options:</dt><dd><p>index (int or None): Index to start the menu at, or None for top level
|
||
mark_category (bool): If True, marks categories with a [+] symbol in the menu
|
||
go_back (bool): If True, present an option to go back to previous categories
|
||
start_text (str): Text to display at the top level of the menu
|
||
cmd_on_exit(str): Command to enter when the menu exits - ‘look’ by default</p>
|
||
</dd>
|
||
</dl>
|
||
<p class="rubric">Notes</p>
|
||
<p>This function will initialize an instance of EvMenu with options generated
|
||
dynamically from the source string, and passes the menu user’s selection to
|
||
a function of your choosing. The EvMenu is made of a single, repeating node,
|
||
which will call itself over and over at different levels of the menu tree as
|
||
categories are selected.</p>
|
||
<p>Once a non-category selection is made, the user’s selection will be passed to
|
||
the given callable, both as a string and as an index number. The index is given
|
||
to ensure every selection has a unique identifier, so that selections with the
|
||
same key in different categories can be distinguished between.</p>
|
||
<p>The menus called by this function are not persistent and cannot perform
|
||
complicated tasks like prompt for arbitrary input or jump multiple category
|
||
levels at once - you’ll have to use EvMenu itself if you want to take full
|
||
advantage of its features.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.dashcount">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.contrib.utils.tree_select.tree_select.</span></span><span class="sig-name descname"><span class="pre">dashcount</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">entry</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#dashcount"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.dashcount" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Counts the number of dashes at the beginning of a string. This
|
||
is needed to determine the depth of options in categories.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><strong>entry</strong> (<em>str</em>) – String to count the dashes at the start of</p>
|
||
</dd>
|
||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><em>dashes (int)</em> – Number of dashes at the start</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.is_category">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.contrib.utils.tree_select.tree_select.</span></span><span class="sig-name descname"><span class="pre">is_category</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">treestr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#is_category"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.is_category" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Determines whether an option in a tree string is a category by
|
||
whether or not there are additional options below it.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>treestr</strong> (<em>str</em>) – Multi-line string representing menu options</p></li>
|
||
<li><p><strong>index</strong> (<em>int</em>) – Which line of the string to test</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><em>is_category (bool)</em> – Whether the option is a category</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.parse_opts">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.contrib.utils.tree_select.tree_select.</span></span><span class="sig-name descname"><span class="pre">parse_opts</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">treestr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">category_index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#parse_opts"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.parse_opts" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Parses a tree string and given index into a list of options. If
|
||
category_index is none, returns all the options at the top level of
|
||
the menu. If category_index corresponds to a category, returns a list
|
||
of options under that category. If category_index corresponds to
|
||
an option that is not a category, it’s a selection and returns True.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>treestr</strong> (<em>str</em>) – Multi-line string representing menu options</p></li>
|
||
<li><p><strong>category_index</strong> (<em>int</em>) – Index of category or None for top level</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><p><em>kept_opts (list or True)</em> –</p>
|
||
<dl class="simple">
|
||
<dt>Either a list of options in the selected</dt><dd><p>category or True if a selection was made</p>
|
||
</dd>
|
||
</dl>
|
||
</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.index_to_selection">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.contrib.utils.tree_select.tree_select.</span></span><span class="sig-name descname"><span class="pre">index_to_selection</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">treestr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">desc</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#index_to_selection"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.index_to_selection" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Given a menu tree string and an index, returns the corresponding selection’s
|
||
name as a string. If ‘desc’ is set to True, will return the selection’s
|
||
description as a string instead.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>treestr</strong> (<em>str</em>) – Multi-line string representing menu options</p></li>
|
||
<li><p><strong>index</strong> (<em>int</em>) – Index to convert to selection key or description</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
<dl class="simple">
|
||
<dt>Options:</dt><dd><p>desc (bool): If true, returns description instead of key</p>
|
||
</dd>
|
||
</dl>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p><em>selection (str)</em> – Selection key or description if ‘desc’ is set</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.go_up_one_category">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.contrib.utils.tree_select.tree_select.</span></span><span class="sig-name descname"><span class="pre">go_up_one_category</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">treestr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#go_up_one_category"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.go_up_one_category" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Given a menu tree string and an index, returns the category that the given option
|
||
belongs to. Used for the ‘go back’ option.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>treestr</strong> (<em>str</em>) – Multi-line string representing menu options</p></li>
|
||
<li><p><strong>index</strong> (<em>int</em>) – Index to determine the parent category of</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><em>parent_category (int)</em> – Index of parent category</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.optlist_to_menuoptions">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.contrib.utils.tree_select.tree_select.</span></span><span class="sig-name descname"><span class="pre">optlist_to_menuoptions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">treestr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">optlist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mark_category</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">go_back</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#optlist_to_menuoptions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.optlist_to_menuoptions" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Takes a list of options processed by parse_opts and turns it into
|
||
a list/dictionary of menu options for use in menunode_treeselect.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>treestr</strong> (<em>str</em>) – Multi-line string representing menu options</p></li>
|
||
<li><p><strong>optlist</strong> (<em>list</em>) – List of options to convert to EvMenu’s option format</p></li>
|
||
<li><p><strong>index</strong> (<em>int</em>) – Index of current category</p></li>
|
||
<li><p><strong>mark_category</strong> (<em>bool</em>) – Whether or not to mark categories with [+]</p></li>
|
||
<li><p><strong>go_back</strong> (<em>bool</em>) – Whether or not to add an option to go back in the menu</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||
<dd class="field-even"><p><p><em>menuoptions (list of dicts)</em> –</p>
|
||
<dl class="simple">
|
||
<dt>List of menu options formatted for use</dt><dd><p>in EvMenu, each passing a different “newindex” kwarg that changes
|
||
the menu level or makes a selection</p>
|
||
</dd>
|
||
</dl>
|
||
</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.menunode_treeselect">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.contrib.utils.tree_select.tree_select.</span></span><span class="sig-name descname"><span class="pre">menunode_treeselect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">caller</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">raw_string</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#menunode_treeselect"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.menunode_treeselect" title="Link to this definition">¶</a></dt>
|
||
<dd><p>This is the repeating menu node that handles the tree selection.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.CmdNameColor">
|
||
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">evennia.contrib.utils.tree_select.tree_select.</span></span><span class="sig-name descname"><span class="pre">CmdNameColor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#CmdNameColor"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Bases: <a class="reference internal" href="evennia.commands.command.html#evennia.commands.command.Command" title="evennia.commands.command.Command"><code class="xref py py-class docutils literal notranslate"><span class="pre">Command</span></code></a></p>
|
||
<p>Set or remove a special color on your name. Just an example for the
|
||
easy menu selection tree contrib.</p>
|
||
<dl class="py attribute">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.CmdNameColor.key">
|
||
<span class="sig-name descname"><span class="pre">key</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'namecolor'</span></em><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.key" title="Link to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.CmdNameColor.func">
|
||
<span class="sig-name descname"><span class="pre">func</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#CmdNameColor.func"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.func" title="Link to this definition">¶</a></dt>
|
||
<dd><p>This is the actual executing part of the command. It is
|
||
called directly after self.parse(). See the docstring of this
|
||
module for which object properties are available (beyond those
|
||
set in self.parse())</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.CmdNameColor.aliases">
|
||
<span class="sig-name descname"><span class="pre">aliases</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">[]</span></em><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.aliases" title="Link to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.CmdNameColor.help_category">
|
||
<span class="sig-name descname"><span class="pre">help_category</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'general'</span></em><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.help_category" title="Link to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.CmdNameColor.lock_storage">
|
||
<span class="sig-name descname"><span class="pre">lock_storage</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'cmd:all();'</span></em><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.lock_storage" title="Link to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.CmdNameColor.search_index_entry">
|
||
<span class="sig-name descname"><span class="pre">search_index_entry</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{'aliases':</span> <span class="pre">'',</span> <span class="pre">'category':</span> <span class="pre">'general',</span> <span class="pre">'key':</span> <span class="pre">'namecolor',</span> <span class="pre">'no_prefix':</span> <span class="pre">'</span> <span class="pre">',</span> <span class="pre">'tags':</span> <span class="pre">'',</span> <span class="pre">'text':</span> <span class="pre">'\nSet</span> <span class="pre">or</span> <span class="pre">remove</span> <span class="pre">a</span> <span class="pre">special</span> <span class="pre">color</span> <span class="pre">on</span> <span class="pre">your</span> <span class="pre">name.</span> <span class="pre">Just</span> <span class="pre">an</span> <span class="pre">example</span> <span class="pre">for</span> <span class="pre">the\neasy</span> <span class="pre">menu</span> <span class="pre">selection</span> <span class="pre">tree</span> <span class="pre">contrib.\n'}</span></em><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.search_index_entry" title="Link to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py function">
|
||
<dt class="sig sig-object py" id="evennia.contrib.utils.tree_select.tree_select.change_name_color">
|
||
<span class="sig-prename descclassname"><span class="pre">evennia.contrib.utils.tree_select.tree_select.</span></span><span class="sig-name descname"><span class="pre">change_name_color</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">caller</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">treestr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">selection</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/utils/tree_select/tree_select.html#change_name_color"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#evennia.contrib.utils.tree_select.tree_select.change_name_color" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Changes a player’s name color.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>caller</strong> (<em>obj</em>) – Character whose name to color.</p></li>
|
||
<li><p><strong>treestr</strong> (<em>str</em>) – String for the color change menu - unused</p></li>
|
||
<li><p><strong>index</strong> (<em>int</em>) – Index of menu selection - unused</p></li>
|
||
<li><p><strong>selection</strong> (<em>str</em>) – Selection made from the name color menu - used
|
||
to determine the color the player chose.</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
|
||
|
||
<div class="clearer"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="Main">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="../index.html">
|
||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo of Evennia"/>
|
||
</a></p>
|
||
<search id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="../search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</search>
|
||
<script>document.getElementById('searchbox').style.display = "block"</script>
|
||
<h3><a href="../index.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">evennia.contrib.utils.tree_select.tree_select</a><ul>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.init_tree_selection"><code class="docutils literal notranslate"><span class="pre">init_tree_selection()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.dashcount"><code class="docutils literal notranslate"><span class="pre">dashcount()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.is_category"><code class="docutils literal notranslate"><span class="pre">is_category()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.parse_opts"><code class="docutils literal notranslate"><span class="pre">parse_opts()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.index_to_selection"><code class="docutils literal notranslate"><span class="pre">index_to_selection()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.go_up_one_category"><code class="docutils literal notranslate"><span class="pre">go_up_one_category()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.optlist_to_menuoptions"><code class="docutils literal notranslate"><span class="pre">optlist_to_menuoptions()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.menunode_treeselect"><code class="docutils literal notranslate"><span class="pre">menunode_treeselect()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor"><code class="docutils literal notranslate"><span class="pre">CmdNameColor</span></code></a><ul>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.key"><code class="docutils literal notranslate"><span class="pre">CmdNameColor.key</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.func"><code class="docutils literal notranslate"><span class="pre">CmdNameColor.func()</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.aliases"><code class="docutils literal notranslate"><span class="pre">CmdNameColor.aliases</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.help_category"><code class="docutils literal notranslate"><span class="pre">CmdNameColor.help_category</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.lock_storage"><code class="docutils literal notranslate"><span class="pre">CmdNameColor.lock_storage</span></code></a></li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.CmdNameColor.search_index_entry"><code class="docutils literal notranslate"><span class="pre">CmdNameColor.search_index_entry</span></code></a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#evennia.contrib.utils.tree_select.tree_select.change_name_color"><code class="docutils literal notranslate"><span class="pre">change_name_color()</span></code></a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<div>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="evennia.contrib.utils.tree_select.tests.html"
|
||
title="previous chapter">evennia.contrib.utils.tree_select.tests</a></p>
|
||
</div>
|
||
<div>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="evennia.help.html"
|
||
title="next chapter">evennia.help</a></p>
|
||
</div>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/api/evennia.contrib.utils.tree_select.tree_select.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
||
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
||
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
|
||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||
<li>
|
||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||
</li>
|
||
</ul>
|
||
<h3>Doc Versions</h3>
|
||
<ul>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/latest/index.html">latest (main branch)</a>
|
||
</li>
|
||
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/5.x/index.html">v5.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/4.x/index.html">v4.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/3.x/index.html">v3.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/2.x/index.html">v2.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/1.x/index.html">v1.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/0.x/index.html">v0.9.5 branch (outdated)</a>
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.help.html" title="evennia.help"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.contrib.utils.tree_select.tests.html" title="evennia.contrib.utils.tree_select.tests"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.contrib.html" >evennia.contrib</a> »</li>
|
||
<li class="nav-item nav-item-5"><a href="evennia.contrib.utils.html" >evennia.contrib.utils</a> »</li>
|
||
<li class="nav-item nav-item-6"><a href="evennia.contrib.utils.tree_select.html" >evennia.contrib.utils.tree_select</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.contrib.utils.tree_select.tree_select</a></li>
|
||
</ul>
|
||
</div>
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2024, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
|
||
</div>
|
||
</body>
|
||
</html> |