Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Console Tools
- #include <stdio.h>
- #include <3ds.h>
- #include <string.h>
- char[1000] foregroundColorString;
- char[1000] backgroundColorString;
- char[1000] fullColorString;
- char[1000] fullCursorPositionString;
- //printArt(lineOne, lineTwo, lineThree, lineFour, lineFive, lineSix, lineSeven) - Prints ascii art to the console. Supports up to seven lines.
- //clearScreen() - clears the screen of all text.
- //setConsoleScreen(direction) - sets the console to be on the top or bottom screen. direction can be "top" or "bottom".
- //setConsoleColors(foregroundColor, backgroundColor) - set the colors of the foreground and background of the colsole. Both parameters are strings and can be: "black", "red", "green", "yellow", "blue", "magenta", "cyan",or "white".
- //setConsoleColorsToDefault() - sets the console foreground and background colors to default: white text, black background.
- //setCursorPosition(x, y) - set the cursor's position to x, y.
- void printArt(char[1000] lineOne, char[1000] lineTwo, char[1000] lineThree, char[1000] lineFour, char[1000] lineFive, char[1000] lineSix, char[1000] lineSeven){
- printf("%s\n", lineOne);
- printf("%s\n", lineTwo);
- printf("%s\n", lineThree);
- printf("%s\n", lineFour);
- printf("%s\n", lineFive);
- printf("%s\n", lineSix);
- printf("%s\n", lineSeven);
- }
- void clearScreen(){
- printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
- }
- void setConsoleScreen(char[6] direction){
- if(direction == "top"){
- consoleInit(GFX_TOP, NULL);
- } else if(direction == "bottom"){
- consoleInit(GFX_BOTTOM, NULL);
- }
- }
- void setConsoleColors(String foreGroundColor, String backgroundColor){
- if(foreGroundColor == "black"){
- memcpy(foregroundColorString, "\x1b[30");
- } else if(foregroundColor == "red"){
- memcpy(foregroundColorString, "\x1b[31");
- } else if(foregroundColor == "green"){
- memcpy(foregroundColorString, "\x1b[32");
- } else if(foregroundColor == "yellow"){
- memcpy(foregroundColorString, "\x1b[33");
- } else if(foregroundColor == "blue"){
- memcpy(foregroundColorString, "\x1b[34");
- } else if(foregroundColor == "magenta"){
- memcpy(foregroundColorString, "\x1b[35");
- } else if(foregroundColor == "cyan"){
- memcpy(foregroundColorString, "\x1b[36");
- } else if(foregroundColor == "white"){
- memcpy(foregroundColorString, "\x1b[37");
- }
- if(backGroundColor == "black"){
- strcpy(backgroundColorString, ";40m");
- } else if(backgroundColor == "red"){
- strcpy(backgroundColorString, ";41m");
- } else if(backgroundColor == "green"){
- strcpy(backgroundColorString, ";42m");
- } else if(backgroundColor == "yellow"){
- strcpy(backgroundColorString, ";43m");
- } else if(backgroundColor == "blue"){
- strcpy(backgroundColorString, ";44m");
- } else if(backgroundColor == "magenta"){
- strcpy(backgroundColorString, ";45m");
- } else if(backgroundColor == "cyan"){
- strcpy(backgroundColorString, ";46m");
- } else if(backgroundColor == "white"){
- strcpy(backgroundColorString, ";47m");
- }
- strcpy(fullColorString, "%s", foregroundColorString);
- strcat(fullColorString, "%s", backgroundColorString);
- printf("%s", fullColorString);
- }
- void setConsoleColorsToDefault(){
- strcpy(fullColorString, "\x1b[39;49m");
- printf("%s", fullColorString);
- }
- void setCursorPosition(int x, int y){
- sprintf(fullCursorPositionString, "\x1b[%d;%dH", x, y);
- printf("%s", fullCorsorPositionString);
- }
Advertisement
Add Comment
Please, Sign In to add comment