Deleted numerous files
[whatever.git] / whatever.cpp
blob180b5093768511dcc152ed2f51e1afd44527560b
1 #include<iostream>
2 #include<vector>
3 #include<ncurses/curses.h>
4 #include<filesystem>
5 #include<fstream>
6 #include<string>
7 #include"json.hpp"
9 #define rf() wrefresh(stdscr)
10 #define mv(x,y) wmove(stdscr,(y),(x))
12 #ifdef _WIN32
13 #include<windows.h>
14 #endif
15 using namespace std;
16 using nlohmann::json;
17 using namespace std::filesystem;
19 // !!! RUN `chcp 65001` on windows before running this program !!!
21 class Map
23 int number_of_lines;
24 /* 1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,19,s1,cp,sdjc,dxjc, yz, fs, yf, 23 in all
25 * 1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,19,26,27,1001,1002,1003,1004,1005. */
26 int number_of_stations;
27 string filename;
28 string faas; //File As A String
29 json faaj; //File As A Json
30 public:
31 Map(string filename)
33 ifstream fmapin(filename.append(".json"));
34 char thisch;
35 while(!fmapin.eof())
37 fmapin>>thisch;
38 faas.append(1,thisch);
40 faas.erase(faas.length()-1);
41 faas.append("\n");
42 try
44 faaj=json::parse(faas);
46 catch(...)
48 cerr<<"Error while trying to parse the map file "<<filename<<".json"<<endl;
51 string raw_contents()
53 return faas;
57 vector<Map> maps;
59 int main()
61 #ifdef _WIN32
62 system("chcp 65001");
63 #endif
64 path map_path="map";
65 Map bj("beijing");
67 //yee (start)
69 initscr();
70 cbreak();
71 noecho();
72 keypad(stdscr,TRUE);
73 nodelay(stdscr,TRUE);
74 mv(0,(LINES-7)/2-1);
75 for(int _=0;_<COLS;_++)
77 addch('=');
79 mv(0,(LINES-7)/2+1);
80 for(int _=0;_<COLS;_++)
82 addch('=');
84 for (;;)
86 int ch;
87 if((ch=getch())==ERR)
89 // didn't respond, this part of code is not yet ready
91 else
93 // pressed something
94 switch(ch)
96 case KEY_UP:case KEY_DOWN:case KEY_LEFT:case KEY_RIGHT:
97 mv(0,LINES-7);
98 addstr("Sorry, the game currently does not support "
99 "\narrow keys. Use hjkl and yubn instead:\n"
100 "y k u\n"
101 " \\|/ \n"
102 "h-@-l\n"
103 " /|\\\n"
104 "b j n\n");
105 rf();
106 break;
107 case 'Q':
108 mv(0,LINES-1);
109 addstr("Do you really want to quit? Press Q again to confirm: ");
110 for(;;)
112 if((ch=getch())=='Q')
114 endwin();
115 return 0;
117 else if(ch!=ERR)
119 mv(0,LINES-1);
120 addstr("Well, okay then. ");
121 break;
124 break;
125 default:
126 mv(0,LINES-1);
127 addstr("Unknown command. You typed: ");
128 addch(ch);
129 break;
133 endwin();
135 //yee (end)
137 return 0;