Arusekk

whoami_FTG.h

Jul 2nd, 2015
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. int vwsselect(int xpos, int ypos, int ile, va_list vv) { // ujemne ile powoduje nieczyszczenie
  2.   size_t szer;
  3.   char key, poz;
  4.   bool czysc=true;
  5.   if (ile<0) {
  6.     czysc=false;
  7.     ile*=-1;
  8.   }
  9.   std::vector<const char*> v;
  10.   for (poz=0; poz<ile; poz++) {
  11.     v.push_back(va_arg(vv, const char*));
  12.     szer=std::max(szer, strlen(v.back()));
  13.   }
  14.   for (poz=0; poz<ile; poz++) {
  15.     cpos(xpos+poz, ypos);
  16.     printf("%-*s", szer, v[poz]);
  17.   }
  18.   poz = 0;
  19.   for (;;) {
  20.     if (_kbhit()) {
  21.       key = _getch();
  22.  
  23.       if (key == 'e') {
  24.     break;
  25.       }
  26.  
  27.       if (key == 'w' && poz > 0) poz--;
  28.       if (key == 's' && poz < ile-1) poz++;
  29.  
  30.       if (poz > 0) {
  31.     cpos(poz+xpos-1, ypos-1);
  32.     printf(" ");
  33.       }
  34.       cpos(poz+xpos, ypos-1);
  35.       printf(">");
  36.       if (poz < ile-1) {
  37.     cpos(poz+xpos+1, ypos-1);
  38.     printf(" ");
  39.       }
  40.     }
  41.   }
  42.   if (czysc)
  43.     clearwindow(xpos, ypos-1, szer+1, ile);
  44.   return poz;
  45. }
  46.  
  47. int wsselect(int xpos, int ypos, int ile, ...) { // ujemne ile powoduje nieczyszczenie
  48.   va_list vv;
  49.   va_start(vv, ile);
  50.   int ret=vwsselect(xpos, ypos, ile, vv);
  51.   va_end(vv);
  52.   return ret;
  53. }
  54.  
  55. void whoami() {
  56.   cpos(5, 3);
  57.   printf("Kim byl twoj ojciec?");
  58.   ojciec=wsselect(5, 5, 9, "humanista", "geografem", "sportowcem", "informatykiem", "mikrobiologiem", "prawnikiem", "lekarzem", "zulem", "tirowcem");
  59.   cpos(5, 3);
  60.   printf("Kim byla twoja matka?");
  61.   matka=wsselect(5, 5, 8, "humanistka", "modelka", "sportowcem", "informatykiem", "mikrobiologiem", "prawnikiem", "lekarzem", "bibliotekarka");
  62. }
Advertisement
Add Comment
Please, Sign In to add comment