Skip to content

Commit

Permalink
documented set_application_name, focus_window, is_window_hidden, and …
Browse files Browse the repository at this point in the history
…get_window_text. Also fixed parameter name being inconsistent in pack::read_file's documentation, and removed joystick_count from the documentation as it was an old SDL2 function.
  • Loading branch information
TheQuinbox committed Sep 13, 2024
1 parent bab0c9a commit eb19d7d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Get the contents of a file contained in a pack.

## Arguments:
* string pack_filename: the name of the file to be read.
* uint offset: the offset within the file to begin reading data from (do not confuse this with pack::get_file_offset)
* uint offset_in_file: the offset within the file to begin reading data from (do not confuse this with pack::get_file_offset)
* uint size: the number of bytes to read (see `pack::get_file_size` to read the entire file).

## Returns:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
Attempt to bring your NVGT window to the foreground.
bool focus_window();
## Returns:
bool: true if the window was successfully focused, false otherwise.
*/

// Example:
void main() {
timer focuser;
show_window("Focus every 5 seconds example");
while (true) {
wait(5);
if (key_pressed(KEY_ESCAPE)) exit();
if (focuser.has_elapsed(5000)) {
focuser.restart();
focus_window();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
Returns the title of your window.
string get_window_text();
## Returns:
string: the title of your window.
*/

// Example:
void main() {
string[] possible_titles = {"Hello world", "NVGT test", "My game", "Example", "Window title example"};
show_window(possible_titles[random(0, possible_titles.length() - 1)]);
while (true) {
wait(5);
if (key_pressed(KEY_ESCAPE)) exit();
if (key_pressed(KEY_SPACE)) {
screen_reader_output("The window title currently is: " + get_window_text(), true);
show_window(possible_titles[random(0, possible_titles.length() - 1)]); // Randomize the title again.
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
Determines if your game's window is hidden or not.
bool is_window_hidden();
## Returns:
bool: true if your game window is hidden, false if it's shown.
*/

// Example:
void main() {
show_window("Test");
bool hide = random_bool();
if (hide) hide_window();
alert("The window is", is_window_hidden() ? "hidden" : "shown");
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# set_application_name
This function lets you set the name of your application. This is a name that's sent to your operating system in certain instances, for example in volume mixer dialogs or when an app goes not responding. It does not effect the window title or anything similar.

`bool set_application_name(string application_name);`

## Arguments:
* string application_name: the name to set for your application.

## Returns:
bool: true if the name was successfully set, false otherwise.

0 comments on commit eb19d7d

Please sign in to comment.