char* startscreen(){ int row, col, my, mx, inx, iny; char *user=(char*)malloc(13*sizeof(char)); char msg[]="rivertalk."; initscr(); echo(); getmaxyx(stdscr,row,col); my=(int)row*0.5; mx=(int)(col - 10)*0.5; iny= my+2; inx=mx-7; attron(A_BOLD); mvprintw(my, mx, msg); attroff(A_BOLD); refresh(); getch(); mvprintw(iny, inx, "Username: "); refresh(); mvgetstr(iny, inx+ 10, user); clear(); refresh(); endwin(); return user; }
bool MENU_ChargerGrilleSimple(Grille grille) { char mesg[]="Entrez la destination de la grille à charger(chemin relatif) :\n "; char str[512]; int row,col; bool continuer = true; //Permet de voir ce qui est écris echo(); GRILLE_Initialiser (grille) ; while(continuer) { /* raffaraîchissement */ clear () ; refresh () ; getmaxyx(stdscr,row,col); mvprintw(row/2,(col-strlen(mesg))/2,"%s",mesg); mvgetstr(row/2 + 1,(col-strlen(mesg))/2, str); /* initialisation et lecture de la grille */ if(ES_FICHIERS_ImportPlateau (str, grille) == false) { mvprintw(LINES - 2, 0, "Le fichier %s n'existe pas ou n'est pas un fichier valide !", str); mvprintw(LINES - 1, 0, "Appuyer sur n'importe quelle touche (ou 'q' pour revenir au menu)..."); if(getch() == 'q') return false; } else { mvprintw(LINES - 2, 0, "Le fichier %s a été chargé avec succés !", str); mvprintw(LINES - 1, 0, "Appuyer sur 'q' pour revenir au menu à tout moment."); getch(); continuer = false; } } noecho(); return true; }
void drawCfg(bool isConf){ if(isConf){drawMain();} nocbreak(); echo(); timeout(30000); sleep(1); wattron(win,COLOR_PAIR(1)); mvwprintw(win,5,1, isConf ? "IP Configuration\n" : "**Interface Not Configured:**\n"); wattroff(win,COLOR_PAIR(1)); mvwprintw(win,6,1,"Enter IP Address: \n"); refresh(); char ip[20],mask[20]; mvgetstr(6,19,ip); mvwprintw(win,7,1,"Enter Subnet Mask: \n"); refresh(); mvgetstr(7,20,mask); if(strlen(ip) >= 6 && strlen(mask) >= 7){ gw.setIP(ip,mask); }else{ mvwprintw(win,8,1,"Unable to set IP/Subnet \n"); refresh(); sleep(3); } timeout(0); cbreak(); noecho(); drawMain(); }
char* CursWin::GetStr(char buf[]) { mvgetstr(curRowPos+upperLeftRow+1,curColPos+upperLeftCol+1,buf); curRowPos++; curColPos = 0; return &(buf[0]); }
int Shop::fenceselect(squadst& customers) const { int ret=0; consolidateloot(location[customers.squad[0]->base]->loot); int page=0; vector<int> selected(location[customers.squad[0]->base]->loot.size(),0); do { erase(); set_color(COLOR_WHITE,COLOR_BLACK,0); move(0,0); addstr("What will you sell?"); if (ret > 0) { move(0,30); addstr("Estimated Liberal Amount: $"); addstr(tostring(ret).c_str()); } printparty(); int x = 1, y = 10; std::string outstr; std::string itemstr; for (int l = page * 18; l < (int)location[customers.squad[0]->base]->loot.size() && l < page * 18 + 18; l++) { if (selected[l]) set_color(COLOR_GREEN,COLOR_BLACK,1); else set_color(COLOR_WHITE,COLOR_BLACK,0); itemstr = location[customers.squad[0]->base]->loot[l]->equip_title(); if (location[customers.squad[0]->base]->loot[l]->get_number() > 1) { if(selected[l] > 0) { itemstr += " " + tostring(selected[l]) + "/"; } else itemstr += " x"; itemstr += tostring(location[customers.squad[0]->base]->loot[l]->get_number()); } outstr = static_cast<char>(l - page * 18 + 'A'); outstr += " - " + itemstr; move(y,x); addstr(outstr.c_str()); x += 26; if (x > 53) { x = 1; y++; } } //PAGE UP set_color(COLOR_WHITE,COLOR_BLACK,0); if (page > 0) { move(17,1); addprevpagestr(); } //PAGE DOWN if((page + 1) * 18 < (int)location[customers.squad[0]->base]->loot.size()) { move(17,53); addnextpagestr(); } set_color(COLOR_WHITE,COLOR_BLACK,0); move(23,1); addstr("Press a letter to select an item to sell."); move(24,1); addstr("Enter - Done"); refresh(); int c = getch(); translategetch(c); if (c >= 'a' && c <= 'r') { int slot = c - 'a' + page * 18; if(slot >= 0 && slot < (int)location[customers.squad[0]->base]->loot.size()) { if (selected[slot]) { ret -= location[customers.squad[0]->base]->loot[slot]->get_fencevalue() * selected[slot]; selected[slot] = 0; } else { if (!location[customers.squad[0]->base]->loot[slot]->is_good_for_sale()) { printparty(); move(8,15); set_color(COLOR_WHITE,COLOR_BLACK,1); addstr(" You can't sell damaged goods."); refresh(); getch(); } else { if (location[customers.squad[0]->base]->loot[slot]->get_number() > 1) { selected[slot] = 1; printparty(); move(8,15); set_color(COLOR_WHITE,COLOR_BLACK,1); addstr(" How many? "); refresh(); char str[100]; keypad(stdscr,FALSE); raw_output(FALSE); echo(); curs_set(1); mvgetstr(8,32,str); curs_set(0); noecho(); raw_output(TRUE); keypad(stdscr,TRUE); selected[slot] = atoi(str); if (selected[slot] < 0) selected[slot] = 0; else if (selected[slot] > location[customers.squad[0]->base]->loot[slot]->get_number()) selected[slot]=location[customers.squad[0]->base]->loot[slot]->get_number(); } else selected[slot]=1; ret += location[customers.squad[0]->base]->loot[slot]->get_fencevalue() * selected[slot]; } } } } if(c == 'x'||c==10||c==ESC) break; //PAGE UP if((c == interface_pgup || c == KEY_UP || c == KEY_LEFT) && page > 0) page--; //PAGE DOWN if((c == interface_pgdn || c == KEY_DOWN || c == KEY_RIGHT) && (page + 1) * 18 < (int)location[customers.squad[0]->base]->loot.size()) page++; } while (true); for(int l = location[customers.squad[0]->base]->loot.size() - 1; l >= 0; l--) { if(selected[l] > 0) { location[customers.squad[0]->base]->loot[l]->decrease_number(selected[l]); if(location[customers.squad[0]->base]->loot[l]->get_number() <= 0) delete_and_remove(location[customers.squad[0]->base]->loot,l); } } return ret; }