|
TheCOSCGameProject
1.0
|
Utility functions for the Valeris game. More...
#include <iostream>#include <fstream>#include <sstream>#include <string>#include <vector>#include <chrono>#include <sys/ioctl.h>#include <unistd.h>#include <termios.h>

Go to the source code of this file.
Functions | |
| void | SetTerminalSize (int height, int width) |
| Set the terminal size on non-Windows systems. More... | |
| void | delay (int milliseconds) |
| Mimic a delay in milliseconds. More... | |
| void | typePrint (const std::string &content, int delayTime=15, const std::string &color="\3[36m") |
| Print text with a typing effect. More... | |
| std::string | getFileContent (std::string fileName) |
| Read the content of a file and return it as a string. More... | |
| std::vector< std::string > | split (const std::string &str, char delimiter) |
| Split a string by a delimiter. More... | |
| void | clear (int limit) |
| Clear the console up to a certain limit. More... | |
| std::string | getUserInputLine () |
| Get a full line of user input. More... | |
| std::string | getUserInputToken () |
| Get a single word or token of user input. More... | |
| int | generateRandomNumber (int low, int high) |
| Generate a random number between two values. More... | |
| int | stringToInt (const std::string &str) |
| Convert a string to an integer. More... | |
| std::string | repeatString (const std::string &str, int count) |
| Repeat a string a specified number of times. More... | |
| std::string | toLowerCase (const std::string &str) |
| Convert a string to lowercase. More... | |
| int | readInt () |
| Read an integer from user input. More... | |
| void | disableInput () |
| Disable user input. More... | |
| void | enableInput () |
| Enable user input. More... | |
| void | waitForEnter () |
| Wait for the user to press Enter. More... | |
| std::string | toUpperCase (const std::string &input) |
| Convert a string to uppercase. More... | |
| std::vector< int > | getDist (std::vector< std::string > vector) |
Utility functions for the Valeris game.
This file contains various utility functions that are used throughout the Valeris game. These include functions for console manipulation, input handling, string processing, and more.
| void clear | ( | int | limit | ) |
Clear the console up to a certain limit.
| limit | The number of lines to clear. |
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 | ) |
Mimic a delay in milliseconds.
| milliseconds | The number of milliseconds to delay. |
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 | ( | ) |
Disable user input.
Disable user input.
Disables input features such as echo and canonical mode on both Windows and non-Windows systems.
| void enableInput | ( | ) |
Enable user input.
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 | ||
| ) |
Generate a random number between two values.
| low | The lower bound of the random number. |
| high | The upper bound of the random number. |
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 | ) |
Read the content of a file and return it as a string.
| fileName | The name of the file to read. |
Read the content of a file and return it as a string.
| fileName | The name of the file to read. |
| std::string getUserInputLine | ( | ) |
Get a full line of user input.
Get a full line of user input.
| std::string getUserInputToken | ( | ) |
Get a single word or token of user input.
Get a single word or token of user input.
| int readInt | ( | ) |
Read 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 | ||
| ) |
Repeat a string a specified number of times.
| str | The string to repeat. |
| count | The number of times to repeat the string. |
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 | ||
| ) |
Set the terminal size on non-Windows systems.
| height | The desired height of the terminal. |
| width | The desired width of the terminal. |
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 | ||
| ) |
Split a string by a delimiter.
| str | The string to split. |
| delimiter | The character used as the 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 | ) |
Convert a string to an integer.
| str | The string to convert. |
Convert a string to an integer.
| str | The string to convert. |
| std::string toLowerCase | ( | const std::string & | str | ) |
Convert a string to lowercase.
| str | The string to convert. |
Convert a string to lowercase.
| str | The string to convert. |
| std::string toUpperCase | ( | const std::string & | input | ) |
Convert a string to uppercase.
| input | The string to convert. |
Convert a string to uppercase.
| input | The string to convert. |
| void typePrint | ( | const std::string & | content, |
| int | delayTime, | ||
| const std::string & | color | ||
| ) |
Print text with a typing effect.
| content | The text content to print. |
| delayTime | The delay time between characters in milliseconds. |
| color | The color code for the text. |
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 | ( | ) |
Wait 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