|
TheCOSCGameProject
1.0
|
Implements utility functions for the Valeris game. More...

Macros | |
| #define | NOMINMAX |
Functions | |
| void | SetTerminalSize (int height, int width) |
| Sets the terminal window size on non-Windows systems. More... | |
| void | delay (int milliseconds) |
| Creates a delay for a specified amount of time. More... | |
| void | disableInput () |
| Disables user input on the console/terminal. More... | |
| void | enableInput () |
| Enables user input on the console/terminal. More... | |
| void | typePrint (const std::string &content, int delayTime, const std::string &color) |
| Prints text with a typing effect. More... | |
| std::string | getFileContent (std::string fileName) |
| Reads the content of a file into a string. More... | |
| std::vector< std::string > | split (const std::string &str, char delimiter) |
| Splits a string into tokens based on a delimiter. More... | |
| void | clear (int limit) |
| Clears a specified number of lines from the console/terminal. More... | |
| std::string | getUserInputLine () |
| Gets a full line of user input from the console. More... | |
| std::string | getUserInputToken () |
| Gets a single word or token of user input from the console. More... | |
| int | generateRandomNumber (int low, int high) |
| Generates a random number within a specified range. More... | |
| int | stringToInt (const std::string &str) |
| Converts a string to an integer. More... | |
| std::string | repeatString (const std::string &str, int count) |
| Repeats a string a specified number of times. More... | |
| std::string | toLowerCase (const std::string &str) |
| Converts a string to lowercase. More... | |
| int | readInt () |
| Reads an integer from user input. More... | |
| void | waitForEnter () |
| Waits for the user to press Enter. More... | |
| std::string | toUpperCase (const std::string &input) |
| Converts a string to uppercase. More... | |
| std::vector< int > | getDist (std::vector< std::string > vector) |
Implements utility functions for the Valeris game.
This file contains various utility functions used throughout the Valeris game, including console/terminal manipulation, input handling, string processing, and delays.
| #define NOMINMAX |
| void clear | ( | int | limit | ) |
Clears a specified number of lines from the console/terminal.
Clear the console up to a certain limit.
| limit | The number of lines to clear. |
This function moves the cursor up and clears the specified number of lines from the console or terminal output.
| void delay | ( | int | milliseconds | ) |
Creates a delay for a specified amount of time.
Mimic a delay in milliseconds.
| milliseconds | The number of milliseconds to delay. |
This function uses a busy-wait loop to create a delay, which can be used to control the timing of text display or other actions.
| void disableInput | ( | ) |
Disables user input on the console/terminal.
Disable user input.
Disables input features such as echo and canonical mode on both Windows and non-Windows systems.
| void enableInput | ( | ) |
Enables user input on the console/terminal.
Enable user input.
Restores input features such as echo and canonical mode on both Windows and non-Windows systems.
| int generateRandomNumber | ( | int | low, |
| int | high | ||
| ) |
Generates a random number within a specified range.
Generate a random number between two values.
| low | The lower bound of the range. |
| high | The upper bound of the range. |
| std::vector<int> getDist | ( | std::vector< std::string > | vector | ) |
| std::string getFileContent | ( | std::string | fileName | ) |
Reads the content of a file into a string.
Read the content of a file and return it as a string.
| fileName | The name of the file to read. |
| std::string getUserInputLine | ( | ) |
Gets a full line of user input from the console.
Get a full line of user input.
| std::string getUserInputToken | ( | ) |
Gets a single word or token of user input from the console.
Get a single word or token of user input.
| int readInt | ( | ) |
Reads an integer from user input.
Read an integer from user input.
This function ensures that the input is a valid integer, handling errors and prompting the user until a valid input is received.
| std::string repeatString | ( | const std::string & | str, |
| int | count | ||
| ) |
Repeats a string a specified number of times.
Repeat a string a specified number of times.
| str | The string to repeat. |
| count | The number of times to repeat the string. |
| void SetTerminalSize | ( | int | height, |
| int | width | ||
| ) |
Sets the terminal window size on non-Windows systems.
Set the terminal size on non-Windows systems.
| height | The desired height of the terminal window. |
| width | The desired width of the terminal window. |
| std::vector<std::string> split | ( | const std::string & | str, |
| char | delimiter | ||
| ) |
Splits a string into tokens based on a delimiter.
Split a string by a delimiter.
| str | The string to split. |
| delimiter | The character used as the delimiter. |
| int stringToInt | ( | const std::string & | str | ) |
Converts a string to an integer.
Convert a string to an integer.
| str | The string to convert. |
| std::string toLowerCase | ( | const std::string & | str | ) |
Converts a string to lowercase.
Convert a string to lowercase.
| str | The string to convert. |
| std::string toUpperCase | ( | const std::string & | input | ) |
Converts a string to uppercase.
Convert a string to uppercase.
| input | The string to convert. |
| void typePrint | ( | const std::string & | content, |
| int | delayTime, | ||
| const std::string & | color | ||
| ) |
Prints text with a typing effect.
Print text with a typing effect.
| content | The text content to print. |
| delayTime | The delay between each character in milliseconds. Default is 15 milliseconds. |
| color | The color code for the text. Default is cyan ("\033[36m"). |
This function prints text one character at a time, simulating a typing effect, with customizable delay and color.
| void waitForEnter | ( | ) |
Waits for the user to press Enter.
Wait for the user to press Enter.
This function pauses the program and waits for the user to press the Enter key before continuing.
1.8.13