Skip to content

Commit

Permalink
Documentation - set_enable_search, menu.nvgt, minor name change in co…
Browse files Browse the repository at this point in the history
…ntributor section (#134)

* Also fixes menu::allow_escape, menu::allow_search and menu::allow_go_to_index which were resetting even if the reset_settings bool was set to false, since the form was recreating itself.
  • Loading branch information
Jonathans859 authored Nov 6, 2024
1 parent 2d9895b commit 6638726
Show file tree
Hide file tree
Showing 24 changed files with 140 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/src/appendix/Contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ This file contains the names of anyone who has helped contribute to the NVGT eng
* [Gruia Chiscop](https://github.com/GruiaChiscop): AVSpeech implementation.
* [Hamza Ahmad](https://github.com/literary-programmer): Contributed virtual_dialogs.nvgt include, Improvements to form.nvgt.
* [Abdullah Tepeli](https://github.com/colonel-official): Delete-by-word support for the audio_form include.
* Beta testers including but not limited to Patrick Wilson, Quin G, Steven D, Lucas Brown, Liam Erven, DJWolfy, Lukáš Hosnedl, Heaven Games, Pragma and Day Garwood, without the valuable feedback and suggestions provided by these people NVGT would have never gotten this far.
* Beta testers including but not limited to Patrick Wilson, Quin G, Steven D, Lucas Brown, Liam Erven, DJWolfy, Lukáš Hosnedl, Jonathan859, Remi, Pragma and Day Garwood, without the valuable feedback and suggestions provided by these people NVGT would have never gotten this far.
* Last but not least, nothing is worth maintaining or developing without users, and so thank you to everyone who uses this engine and gives it their feedback, time and attention!
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# get_line_column
Get the current line column of an input box.

`int audio_form::get_line_column(int control_index);`

## Arguments:
* int control_index: the index of the input box to retrieve the line column from.

## Returns:
int: The line column of the input box, or -1 if there was an error.

## Remarks:
This method only works on input boxes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# get_line_number
Get the current line number of an input box.

`int audio_form::get_line_number(int control_index);`

## Arguments:
* int control_index: the index of the input box to retrieve the line number from.

## Returns:
int: The line number of the input box, or -1 if there was an error.

## Remarks:
This method only works on input boxes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# get_text
Get the text from an input box or status bar.

`string audio_form::get_text(int control_index);`

## Arguments:
* int control_index: the index of the control to retrieve the text from.

## Returns:
string: The text from the control, or an empty string if there was an error.

## Remarks:
This method only works on input boxes and status bars.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# set_enable_search
Toggles whether the control can use search functionality.

`bool audio_form::set_enable_search(int control_index, bool enabled);`

## Arguments:
* int control_index: the index of the control.
* bool enabled: enables the search functionality.

## Returns:
bool: true if the state was successfully set, false otherwise.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file indicates that this subdirectory should be considered as a root page in the markdown version of the documentation, see the docgen notes for more details.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# add_item
Add an item to the menu.

`bool menu::add_item(string text, string id = "", int position = -1);`

## Arguments:
* string text: the text of the item to add to the menu.
* string id = "": the ID of the item.
* int position = -1: the position to insert the new item at (-1 = end of menu).

## Returns:
int: the position of the new item in the menu.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# intro
Produces the intro sequence for the menu. It is not required to call this function if you don't want to.

`void menu::intro();`
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# monitor
Monitors the menu; handles keyboard input, the callback, sounds and more. Should be called in a loop as long as the menu is active.

`bool menu::monitor();`

## Returns:
bool: true if the menu should keep running, or false if it has been exited or if an option has been selected.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# reset
Resets the menu to it's default state.

`void menu::reset(bool reset_settings = false);`

## Arguments:
* bool reset_settings = false: If this is enabled, the sounds and other such properties are cleared.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# automatic_intro
If this is true, the intro function will be automatically called the first time the monitor method is invoqued, then the variable will be set to false. It can be set to true again at any time to cause the intro sequence to repeat, or the intro function can be called manually.

bool menu::automatic_intro;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# click_sound
The sound played when the user changes positions in the menu.

`string menu::click_sound;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# close_sound
The sound played when the user escapes out of the menu.

`string menu::close_sound;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# edge_sound
The sound which plays when the user attempts moving beyond the border of a menu while wrapping is disabled.

`string menu::edge_sound;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# focus_first_item
If this is false, the user will be required to press an arrow key to focus either the first or last item of the menu after the intro function has been called. Otherwise they will be focused on the first item.
This is disabled by default.

`bool menu::focus_first_item;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# intro_text
The text spoken when the void intro() function is called.

`string menu::intro_text;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# open_sound
The sound played when the void intro() function is called.

`string menu::open_sound;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# pack_file
Optionally set this to a pack containing sounds.

`pack menu::pack_file;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# select_sound
The sound played when the user chooses an option in the menu.

`string menu::select_sound;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# wrap
If the user moves beyond an edge of the menu, set this to true to jump them to the other edge, or false to play an edge sound and repeat the last item.
By default this is set to false.

`bool menu::wrap;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# wrap_delay
How much time (in ms) should the menu block when wrapping. Defaults to 10ms.

`uint menu::wrap_delay;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# wrap_sound
The sound played when the menu wraps (only happens when bool wrap = true).

`string menu::wrap_sound;`
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# menu
This class gives you an easy way to create a typical menu based on the audio_form list control item, including some nice aditional options such as navigation sounds, wrapping, and more.
6 changes: 6 additions & 0 deletions release/include/menu.nvgt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ class menu {
f_cancel = form.create_button("Cancel", false, allow_escape);
form.set_state(f_cancel, true, false);
form.focus_silently(f_list);
//If the settings haven't been reset, restore the settings to the form, as it has been recreated.
if(!reset_settings) {
set_allow_escape(get_allow_escape());
set_allow_search(get_allow_search());
set_allow_go_to_index(get_allow_go_to_index());
}
}
// Item IDs are entirely optional.
int add_item(const string&in text, const string&in id = "", int position = -1) {
Expand Down

0 comments on commit 6638726

Please sign in to comment.