|
@@ -376,7 +376,7 @@ void change_commands(int* commands){
|
|
|
|
|
|
for(int i=0;i<CMD_NUM;i++){
|
|
|
if(commands[i]==' ') chcommands[i]="Barra sp.";
|
|
|
- else chcommands[i]=commands[i];
|
|
|
+ else chcommands[i]=(char)commands[i];
|
|
|
if(i==line) wattron(change,COLOR_PAIR(9));
|
|
|
mvwprintw(change,i+5,1,"%s: %s",name[i].c_str(),chcommands[i].c_str());
|
|
|
wattron(change,COLOR_PAIR(1));
|
|
@@ -405,6 +405,7 @@ void change_commands(int* commands){
|
|
|
timeout(-1);
|
|
|
cmd=wgetch(change);
|
|
|
commands[line]=tolower(cmd);
|
|
|
+ dump_commands(commands);
|
|
|
wmove(change,line+5,0);
|
|
|
wclrtoeol(change);
|
|
|
box(change,ACS_VLINE,ACS_HLINE);
|
|
@@ -422,7 +423,47 @@ void change_commands(int* commands){
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+void dump_commands(int* commands)
|
|
|
+{
|
|
|
+ std::ofstream cmd;
|
|
|
+ std::string local_dir = getenv("HOME");
|
|
|
+ std::string cmd_file = local_dir + RECORD_DIR + "commands";
|
|
|
+ create_folder(0);
|
|
|
+ cmd.open(cmd_file);
|
|
|
+ if(cmd.is_open()) {
|
|
|
+ for(int i = 0; i < CMD_NUM; i++) {
|
|
|
+ cmd << (char)commands[i];
|
|
|
+ }
|
|
|
+ cmd << std::endl;
|
|
|
+ cmd.close();
|
|
|
+ } else {
|
|
|
+ printw("error: cannot open %s", cmd_file);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void read_commands(int* commands)
|
|
|
+{
|
|
|
+ std::ifstream cmd;
|
|
|
+ int def[CMD_NUM] = {'a', 'd', 'w', 's', 'p', ' ', 'l', 'm', 'q'}; // default
|
|
|
+ std::string local_dir = getenv("HOME");
|
|
|
+ std::string cmd_file = local_dir + RECORD_DIR + "commands";
|
|
|
+ cmd.open(cmd_file);
|
|
|
+ if(cmd.is_open()) {
|
|
|
+ std::string line;
|
|
|
+ getline(cmd, line);
|
|
|
+ for(int i = 0; i < CMD_NUM; i++) {
|
|
|
+ commands[i] = (int)line[i];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for(int i = 0; i <CMD_NUM; i++) {
|
|
|
+ commands[i] = def[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void load_enemies(e_list& enemies,int enemy_num)
|
|
|
{
|
|
|
enemies.clear();
|