1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
#include "pch.h"
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <windows.h>
using namespace std;
vector<string> colourOptions = { "0 : Black" ,
"1 : Blue" ,
"2 : Green" ,
"3 : Aqua" ,
"4 : Red" ,
"5 : Purple" ,
"6 : Yellow" ,
"7 : White" ,
"8 : Gray" ,
"9 : Light_Blue" ,
"10: Light_Green" ,
"11: Light_Aqua" ,
"12: Light_Red" ,
"13: Light_Purple",
"14: Light_Yellow",
"15: Bright_White" };
vector<string> mainOptions = { "1. Change text colour",
"2. Change frame colour",
"3. Change frame type",
"4. Change console color",
"5. Exit" };
vector<string> frameOptions = { "1. No frame",
"2. Single frame",
"3. Double frame" };
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
struct Frame
{
char TL, TR, BL, BR, H, V;
int colour = 7;
};
void colour(int n) { SetConsoleTextAttribute(h, n); }
void drawChar(char c, int col = 7) { colour(col); cout << c; }
void drawString(string s, int col = 7) { colour(col); cout << s; }
void setFrameBlank(Frame &F) { F = { ' ', ' ', ' ', ' ', ' ', ' ', F.colour }; }
void setFrameSingle(Frame &F) { F = { '\xDA', '\xBF', '\xC0', '\xD9', '\xC4', '\xB3', F.colour }; }
void setFrameDouble(Frame &F) { F = { '\xC9', '\xBB', '\xC8', '\xBC', '\xCD', '\xBA', F.colour }; }
int drawMenu(const vector<string> &options, const Frame &F, int textColour, int width)
{
drawString(F.TL + string(width, F.H) + F.TR, F.colour);
cout << '\n';
for (string s : options)
{
drawChar(F.V, F.colour);
drawString(' ' + s + string(width - s.size() - 1, ' '), textColour);
drawChar(F.V, F.colour);
cout << '\n';
}
drawString(F.BL + string(width, F.H) + F.BR, F.colour);
cout << '\n';
colour(textColour);
int ans;
cin >> ans;
cout << '\n';
return ans;
}
int main()
{
Frame F; setFrameDouble(F);
int textColour = 7;
int consoleColour = 0;
int menuWidth = 30;
cout << "Press any key to draw textbox..." << endl;
system("pause>nul");
system("cls");
while (true)
{
int ans = drawMenu(mainOptions, F, textColour, menuWidth);
switch (ans)
{
case 1:
textColour = drawMenu(colourOptions, F, textColour, menuWidth);
break;
case 2:
F.colour = drawMenu(colourOptions, F, textColour, menuWidth);
break;
case 3:
{
int typeFrame = drawMenu(frameOptions, F, textColour, menuWidth);
switch (typeFrame)
{
case 1: setFrameBlank(F); break;
case 2: setFrameSingle(F); break;
case 3: setFrameDouble(F); break;
}
break;
}
case 4:
{
consoleColour = drawMenu(colourOptions, F, textColour, menuWidth);
switch (consoleColour)
{
case 1: system("color 12"); break;
case 2: system("color 23"); break;
case 3: system("color 34"); break;
case 4: system("color 45"); break;
case 5: system("color 56"); break;
case 6: system("color 67"); break;
case 7: system("color 78"); break;
case 8: system("color 89"); break;
case 9: system("color 9A"); break;
case 10: system("color AB"); break;
case 11: system("color BC"); break;
case 12: system("color CD"); break;
case 13: system("color DE"); break;
case 14: system("color EF"); break;
case 15: system("color F0"); break;
}
break;
}
case 5:
{
exit(0);
break;
}
default:
colour(7);
return 0;
}
system("cls");
}
}
|