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
|
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <fstream>
using namespace std;
char TextMap[80][45];
int ColorMap[80][45];
int GridX = 0;
int GridY = 0;
int TextHotKey[10] = {0, 46, 35, 43, 62, 60, 61, 126, 5, 6};
int ColorHotKey[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int curTextHotKey = 1;
int curColorHotKey = 1;
char CMD;
ofstream Write;
ifstream Read;
int main()
{
system("MODE CON: COLS=80");
system("MODE CON: LINES=60");
HANDLE hOut;
COORD cursPos;
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
bool runLoop = true;
for(int X = 0; X < 80; X++)
{
for(int Y = 0; Y < 45; Y++)
{
TextMap[X][Y] = '.';
ColorMap[X][Y] = 7;
}
}
for(int X = 0; X < 80; X++)
{
for(int Y = 0; Y < 45; Y++)
{
cout << TextMap[X][Y];
}
}
for(int X = 0; X < 79; X++)
{
cout << (char)205;
if(X == 37)
{
cout << (char)203;
}
}
cout <<
"ASCII Map Editor (80 x 45 characters) " << (char)186 << "Current Tile: ' ' " << endl <<
"Keys: " << (char)186 << "Tile Hotkeys: Color Hotkeys: " << endl <<
"'Q' = Quit to menu " << (char)186 << "1: 1: " << endl <<
"'S' = Save map " << (char)186 << "2: 2: " << endl <<
"'L' = Load map " << (char)186 << "3: 3: " << endl <<
"'c' = Change color " << (char)186 << "4: 4: " << endl <<
"'t' = Change tile " << (char)186 << "5: 5: " << endl <<
"'a' = Apply tile " << (char)186 << "6: 6: " << endl <<
"'H' = Change tile hotkeys " << (char)186 << "7: 7: " << endl <<
"'L' = Load map " << (char)186 << "8: 8: " << endl <<
"'C' = Change color " << (char)186 << "9: 9: " << endl <<
"'L' = Load map " << (char)186 << "Cursor Position: " << endl;
for(int X = 0; X < 79; X++)
{
cout << (char)205;
if(X == 37)
{
cout << (char)202;
}
}
cursPos.X = GridX;
cursPos.Y = GridY;
SetConsoleCursorPosition(hOut, cursPos);
while(runLoop == true)
{
CMD = getch();
switch(CMD)
{
case '8':
if(GridY > 0)
{
GridY--;
}
break;
case '2':
if(GridY < 44)
{
GridY++;
}
break;
case '4':
if(GridX > 0)
{
GridX--;
}
break;
case '6':
if(GridX < 79)
{
GridX++;
}
break;
case 't':
CMD = getch();
if(CMD >= '1' && CMD <= '9')
{
curTextHotKey = CMD-'0';
}
break;
case 'c':
CMD = getch();
if(CMD >= '1' && CMD <= '9')
{
curColorHotKey = CMD-'0';
}
break;
case 'a':
TextMap[GridX][GridY] = TextHotKey[curTextHotKey];
ColorMap[GridX][GridY] = ColorHotKey[curColorHotKey];
SetConsoleTextAttribute(hOut,ColorHotKey[curColorHotKey]);
cout << (char)TextHotKey[curTextHotKey];
break;
case 'S':
|
{
Write.open("Save.bin", ios::out | ios::binary);
for(int X = 0; X < 80; X++)
{
for(int Y = 0; Y < 45; Y++)
{
Write << (char)TextMap[Y][X];
}
}
Write.close();
break;
}
case 'L': <----------------LOADING HERE HERE
{
Read.open("Save.bin", ios::in | ios::binary);
for(int X = 0; X < 80; X++)
{
for(int Y = 0; Y < 45; Y++)
{
Read >> TextMap[Y][X];
}
}
Read.close();
cursPos.X = 0;
cursPos.Y = 0;
SetConsoleCursorPosition(hOut, cursPos);
for(int X = 0; X < 80; X++)
{
for(int Y = 0; Y < 45; Y++)
{
cout << (char)TextMap[Y][X];
}
}
break;
}
}
SetConsoleTextAttribute(hOut,7);
cursPos.X = 56;
cursPos.Y = 57;
SetConsoleCursorPosition(hOut, cursPos);
cout << GridX << "/" << GridY;
cursPos.X = 54;
cursPos.Y = 46;
SetConsoleCursorPosition(hOut, cursPos);
SetConsoleTextAttribute(hOut,ColorHotKey[curColorHotKey]);
cout << (char)TextHotKey[curTextHotKey];
for(int Hc = 0; Hc < 9; Hc++)
{
cursPos.X = 59;
cursPos.Y = 48 + Hc;
SetConsoleCursorPosition(hOut, cursPos);
SetConsoleTextAttribute(hOut,ColorHotKey[1 + Hc]);
cout << (char)TextHotKey[curTextHotKey];
}
for(int Ht = 0; Ht < 9; Ht++)
{
cursPos.X = 41;
cursPos.Y = 48 + Ht;
SetConsoleCursorPosition(hOut, cursPos);
SetConsoleTextAttribute(hOut,ColorHotKey[curColorHotKey]);
cout << (char)TextHotKey[1 + Ht];
}
SetConsoleTextAttribute(hOut,7);
cursPos.X = GridX;
cursPos.Y = GridY;
SetConsoleCursorPosition(hOut, cursPos);
}
} |