| 642 | } |
| 643 | |
| 644 | void Window_Settings::RefreshButtonList() { |
| 645 | auto& mappings = Input::GetInputSource()->GetButtonMappings(); |
| 646 | auto custom_names = Input::GetInputKeyNames(); |
| 647 | |
| 648 | std::vector<Input::InputButton> buttons; |
| 649 | switch (GetFrame().arg) { |
| 650 | case 0: |
| 651 | buttons = { Input::UP, Input::DOWN, Input::LEFT, Input::RIGHT, Input::DECISION, Input::CANCEL, Input::SHIFT, |
| 652 | Input::N0, Input::N1, Input::N2, Input::N3, Input::N4, Input::N5, Input::N6, Input::N7, Input::N8, Input::N9, |
| 653 | Input::PLUS, Input::MINUS, Input::MULTIPLY, Input::DIVIDE, Input::PERIOD, Input::MOUSE_LEFT, |
| 654 | Input::MOUSE_MIDDLE, Input::MOUSE_RIGHT, Input::SCROLL_UP, Input::SCROLL_DOWN }; |
| 655 | break; |
| 656 | case 1: |
| 657 | buttons = {Input::SETTINGS_MENU, Input::TOGGLE_FPS, Input::TOGGLE_FULLSCREEN, Input::TOGGLE_ZOOM, |
| 658 | Input::TAKE_SCREENSHOT, Input::RESET, Input::FAST_FORWARD_A, Input::FAST_FORWARD_B, |
| 659 | Input::PAGE_UP, Input::PAGE_DOWN }; |
| 660 | break; |
| 661 | case 2: |
| 662 | buttons = { Input::DEBUG_MENU, Input::DEBUG_THROUGH, Input::DEBUG_SAVE, Input::DEBUG_ABORT_EVENT, |
| 663 | Input::SHOW_LOG }; |
| 664 | break; |
| 665 | } |
| 666 | |
| 667 | for (auto b: buttons) { |
| 668 | auto button = static_cast<Input::InputButton>(b); |
| 669 | |
| 670 | std::string name = Input::kInputButtonNames.tag(button); |
| 671 | |
| 672 | // Improve readability of the names |
| 673 | bool first_letter = true; |
| 674 | for (size_t i = 0; i < name.size(); ++i) { |
| 675 | auto& ch = name[i]; |
| 676 | if (ch >= 'A' && ch <= 'Z') { |
| 677 | if (!first_letter) { |
| 678 | ch += 32; |
| 679 | } |
| 680 | first_letter = false; |
| 681 | } else if (ch == '_') { |
| 682 | ch = ' '; |
| 683 | first_letter = true; |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | std::string help = Input::kInputButtonHelp.tag(button); |
| 688 | std::string value; |
| 689 | |
| 690 | // Append as many buttons as fit on the screen, then add ... |
| 691 | int contents_w = GetContents()->width(); |
| 692 | int name_size = Text::GetSize(*Font::Default(), name).width; |
| 693 | int value_size = 0; |
| 694 | |
| 695 | for (auto ki = mappings.LowerBound(button); ki != mappings.end() && ki->first == button; ++ki) { |
| 696 | auto custom_name = std::find_if(custom_names.begin(), custom_names.end(), [&](auto& key_pair) { |
| 697 | return key_pair.first == ki->second; |
| 698 | }); |
| 699 | |
| 700 | std::string cur_value; |
| 701 | if (custom_name != custom_names.end()) { |