| 958 | } |
| 959 | |
| 960 | void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override |
| 961 | { |
| 962 | switch (widget) { |
| 963 | case WID_SA_PREVIOUS: |
| 964 | do { |
| 965 | this->current_sprite = (this->current_sprite == 0 ? GetMaxSpriteID() : this->current_sprite) - 1; |
| 966 | } while (GetSpriteType(this->current_sprite) != SpriteType::Normal); |
| 967 | this->SelectAction5Type(); |
| 968 | this->SetDirty(); |
| 969 | break; |
| 970 | |
| 971 | case WID_SA_GOTO: |
| 972 | ShowQueryString({}, STR_SPRITE_ALIGNER_GOTO_CAPTION, 7, this, CS_NUMERAL, {}); |
| 973 | break; |
| 974 | |
| 975 | case WID_SA_NEXT: |
| 976 | do { |
| 977 | this->current_sprite = (this->current_sprite + 1) % GetMaxSpriteID(); |
| 978 | } while (GetSpriteType(this->current_sprite) != SpriteType::Normal); |
| 979 | this->SelectAction5Type(); |
| 980 | this->SetDirty(); |
| 981 | break; |
| 982 | |
| 983 | case WID_SA_PICKER: |
| 984 | this->LowerWidget(WID_SA_PICKER); |
| 985 | _newgrf_debug_sprite_picker.mode = SPM_WAIT_CLICK; |
| 986 | this->SetDirty(); |
| 987 | break; |
| 988 | |
| 989 | case WID_SA_LIST: { |
| 990 | auto it = this->vscroll->GetScrolledItemFromWidget(_newgrf_debug_sprite_picker.sprites, pt.y, this, widget); |
| 991 | if (it != _newgrf_debug_sprite_picker.sprites.end()) { |
| 992 | SpriteID spr = *it; |
| 993 | if (GetSpriteType(spr) == SpriteType::Normal) this->current_sprite = spr; |
| 994 | } |
| 995 | this->SelectAction5Type(); |
| 996 | this->SetDirty(); |
| 997 | break; |
| 998 | } |
| 999 | |
| 1000 | case WID_SA_UP: |
| 1001 | case WID_SA_DOWN: |
| 1002 | case WID_SA_LEFT: |
| 1003 | case WID_SA_RIGHT: { |
| 1004 | /* |
| 1005 | * Yes... this is a hack. |
| 1006 | * |
| 1007 | * No... I don't think it is useful to make this less of a hack. |
| 1008 | * |
| 1009 | * If you want to align sprites, you just need the number. Generally |
| 1010 | * the sprite caches are big enough to not remove the sprite from the |
| 1011 | * cache. If that's not the case, just let the NewGRF developer |
| 1012 | * increase the cache size instead of storing thousands of offsets |
| 1013 | * for the incredibly small chance that it's actually going to be |
| 1014 | * used by someone and the sprite cache isn't big enough for that |
| 1015 | * particular NewGRF developer. |
| 1016 | */ |
| 1017 | Sprite *spr = const_cast<Sprite *>(GetSprite(this->current_sprite, SpriteType::Normal)); |
nothing calls this directly
no test coverage detected