[Super-tux-devel] Patch for displaying controls in the menu
Brought to you by:
wkendrick
From: Chris B. <chr...@we...> - 2005-08-28 19:55:37
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi there! I made a little patch for SuperTux 0.1.3. It changes the shown ascii-code into the character in the control-setting-menu. I'm just pasting the changed code below (and the whole file as an attachment), so you can decide whether to update your code or not. I think this patch is a little help for people, who are not familiar with acsii-codes, so they won't stuck when they see the character they pressed instead of die ascii-code. Please answer me directly, because I didn't subscribe the mailing list (one reason is the spam-thing). Thanks! Great game, keep on coding, Chris Blaettermann - --- BEGIN OF THE PATCH --- menu.cpp - beginning at line 204 void MenuItem::change_input(const char *text_) { if(text) { free(input); input = (char*) malloc(sizeof(char )*(strlen(text_)+1)); /* implements displaying the characters a to z instead of the ascii-code */ if((char)text_[1]=='9' || (char)text_[1]=='1') { char *tmp; tmp = (char*) malloc(sizeof(char)*2); tmp[0] = text_[0]; tmp[1] = '\0'; strcpy(input, tmp); } else { strcpy(input, text_); } } } ############## menu.cpp - beginning at line 243 void Menu::get_controlfield_key_into_input(MenuItem *item) { switch(*item->int_p) { case SDLK_UP: item->change_input("Up cursor"); break; case SDLK_DOWN: item->change_input("Down cursor"); break; case SDLK_LEFT: item->change_input("Left cursor"); break; case SDLK_RIGHT: item->change_input("Right cursor"); break; case SDLK_RETURN: item->change_input("Return"); break; case SDLK_SPACE: item->change_input("Space"); break; case SDLK_RSHIFT: item->change_input("Right Shift"); break; case SDLK_LSHIFT: item->change_input("Left Shift"); break; case SDLK_RCTRL: item->change_input("Right Control"); break; case SDLK_LCTRL: item->change_input("Left Control"); break; case SDLK_RALT: item->change_input("Right Alt"); break; case SDLK_LALT: item->change_input("Left Alt"); break; default: { char tmp[64]; snprintf(tmp, 64, "%d", *item->int_p); int i_char = (int)*item->int_p; /* limits displaying all characters from a to z */ if(i_char >= 97 && i_char <= 122) { char c = (char)*item->int_p; item->change_input(&c); } else { item->change_input(tmp); } } break; } } - --- END OF THE PATCH --- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDEhal8pxaZkht6wcRAkOlAKDGq8YCBc0my9Tu34PPgMYM+WSMggCgmnxL s617XSyRclxKC8JfatxfV5w= =VKU5 -----END PGP SIGNATURE----- |