| 914 | } |
| 915 | |
| 916 | void UIStartupMenu::menu_item_activated(int id) |
| 917 | { |
| 918 | switch (id) |
| 919 | { |
| 920 | case GAME_TYPE_NORMAL: |
| 921 | case GAME_TYPE_DESCENT: |
| 922 | case GAME_TYPE_CUSTOM_SEED: |
| 923 | case GAME_TYPE_TUTORIAL: |
| 924 | case GAME_TYPE_SPRINT: |
| 925 | case GAME_TYPE_HINTS: |
| 926 | trim_string(input_string); |
| 927 | // XXX: is it ever not a good name? |
| 928 | if (is_good_name(input_string, true)) |
| 929 | { |
| 930 | ng_choice.type = static_cast<game_type>(id); |
| 931 | ng_choice.name = input_string; |
| 932 | done = true; |
| 933 | } |
| 934 | return; |
| 935 | |
| 936 | case GAME_TYPE_ARENA: |
| 937 | ng_choice.type = GAME_TYPE_ARENA; |
| 938 | done = true; |
| 939 | return; |
| 940 | |
| 941 | case GAME_TYPE_INSTRUCTIONS: |
| 942 | show_help(); |
| 943 | return; |
| 944 | |
| 945 | case GAME_TYPE_HIGH_SCORES: |
| 946 | show_hiscore_table(); |
| 947 | return; |
| 948 | |
| 949 | default: |
| 950 | // It was a savegame instead |
| 951 | const int save_number = id - NUM_GAME_TYPE; |
| 952 | if (save_number < num_saves) // actual save |
| 953 | { |
| 954 | // Save the savegame character name |
| 955 | ng_choice.name = chars.at(save_number).name; |
| 956 | ng_choice.type = chars.at(save_number).saved_game_type; |
| 957 | ng_choice.filename = chars.at(save_number).filename; |
| 958 | } |
| 959 | else // "new game" |
| 960 | { |
| 961 | ng_choice.name = ""; |
| 962 | ng_choice.type = GAME_TYPE_NORMAL; |
| 963 | ng_choice.filename = ""; // ? |
| 964 | } |
| 965 | done = true; |
| 966 | return; |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | /** |
| 971 | * Saves game mode and player name to ng_choice. |
no test coverage detected