int TextInput( int x, int y, const char *prompt, int maxlen, int fieldlen, char *strres, void (*handlekey)( int key, VString &s, int &pos ) ) { VString str = strres; int res = TextInput( x, y, prompt, maxlen, fieldlen, &str, handlekey ); strcpy( strres, str.data() ); return res; }
/** * * @return false to exit or change level, true otherwise. */ bool PlayerUI::Input(bool* levelEnded, bool* downLevel) { int x; int y; player->GetPos(&x, &y); /*Get current position for movement*/ int thisX = x; //set movement positions to default int thisY = y; ShowControls(); int choice = mainUI->ConsoleGetInput(); if (choice == KEY_UP || choice == 'w') thisY--; else if (choice == KEY_RIGHT || choice == 'd') thisX++; else if (choice == KEY_DOWN || choice == 's') thisY++; else if (choice == KEY_LEFT || choice == 'a') thisX--; else if (choice == 'q' || choice == KEY_EXIT ) return false; else if (choice == 'c') return TextInput(); else if (choice == 'i') AccessPlayerInv(); //handle any movement input if ((x != thisX) || (y != thisY)) { PlayerMoveTurn(thisX, thisY,levelEnded,downLevel); if (*levelEnded) return false; } return true; }
void Prompt(string cmd) { int &width = game.world->hud->width; int &height = game.world->hud->height; game.input->text = cmd; game.input->onText = getInput; // Move this to init game.world->hud->children.insert(TextInput(game.input, 0, 0, width, height)); }
CHARMMParameters::CHARMMParameters(TextInput top_file, TextInput par_file, bool translate_names_to_pdb) { // Parameter objects are not designed to be added into other containers set_was_used(true); read_topology_file(top_file, translate_names_to_pdb); if (par_file != TextInput()) { read_parameter_file(par_file); } }
/* Procedure de gestion des evenements du menu * @param SDL_Event* event * Evenements de la fenetre * @param S_GameConfig gameConfig * Structure de configuration du jeu * @param E_MenuSelected selected * Selection du menu * @return E_MenuSelected * Eventuel bouton clique */ E_MenuSelected EventsMenu(SDL_Event* event, S_GameConfig* gameConfig, E_MenuSelected* selected) { E_MenuSelected clicked = NONE; SDL_WaitEvent(event); switch(event->type) { case SDL_QUIT: clicked = QUIT; break; case SDL_MOUSEBUTTONDOWN: if (ClickRect(event, 450, 446, 150, 45)) *selected = QUIT; if (ClickRect(event, 158, 446, 150, 45)) *selected = START; break; case SDL_MOUSEBUTTONUP: if (event->button.button == SDL_BUTTON_LEFT) { // Boutons if (ClickRect(event, 450, 446, 150, 45)) clicked = QUIT; if (ClickRect(event, 158, 446, 150, 45)) { if (strlen(gameConfig->namePlayer1) > 0 && strlen(gameConfig->namePlayer2) > 0) clicked = START; } // Selection des zones de texte if (ClickRect(event, 379, 126, 300, 40)) *selected = PLAYER1; else if (ClickRect(event, 379, 186, 300, 40)) *selected = PLAYER2; else *selected = NONE; // Clic sur les boutons if (ClickRect(event, 379, 246, 40, 40)) gameConfig->player1Color = BLACK; if (ClickRect(event, 568, 246, 40, 40)) gameConfig->player1Color = WHITE; if (ClickRect(event, 41, 306, 40, 40)) gameConfig->option = 1; if (ClickRect(event, 420, 306, 40, 40)) gameConfig->option = 0; // Clic sur les fleches if (ClickRect(event, 444, 366, 30, 40)) { if (gameConfig->points > MIN_POINTS) gameConfig->points -= 2; } if (ClickRect(event, 584, 366, 30, 40)) { if (gameConfig->points < MAX_POINTS) gameConfig->points += 2; } } break; case SDL_KEYUP: if (*selected == PLAYER1) TextInput(gameConfig->namePlayer1, event->key.keysym); else if (*selected == PLAYER2) TextInput(gameConfig->namePlayer2, event->key.keysym); break; } return clicked; }