MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetWidgetString

Method GetWidgetString

src/newgrf_debug_gui.cpp:834–876  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

832 }
833
834 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
835 {
836 const Sprite *spr = GetSprite(this->current_sprite, SpriteType::Normal);
837 switch (widget) {
838 case WID_SA_CAPTION:
839 if (this->act5_type != nullptr) {
840 return GetString(STR_SPRITE_ALIGNER_CAPTION_ACTION5,
841 this->act5_type - GetAction5Types().data(),
842 this->current_sprite - this->act5_type->sprite_base,
843 GetOriginFile(this->current_sprite)->GetSimplifiedFilename(),
844 GetSpriteLocalID(this->current_sprite));
845 }
846 if (this->current_sprite < SPR_OPENTTD_BASE) {
847 return GetString(STR_SPRITE_ALIGNER_CAPTION_ACTIONA,
848 this->current_sprite,
849 GetOriginFile(this->current_sprite)->GetSimplifiedFilename(),
850 GetSpriteLocalID(this->current_sprite));
851 }
852 return GetString(STR_SPRITE_ALIGNER_CAPTION_NO_ACTION,
853 GetOriginFile(this->current_sprite)->GetSimplifiedFilename(),
854 GetSpriteLocalID(this->current_sprite));
855
856 case WID_SA_OFFSETS_ABS:
857 return GetString(STR_SPRITE_ALIGNER_OFFSETS_ABS, UnScaleByZoom(spr->x_offs, SpriteAlignerWindow::zoom), UnScaleByZoom(spr->y_offs, SpriteAlignerWindow::zoom));
858
859 case WID_SA_OFFSETS_REL: {
860 /* Relative offset is new absolute offset - starting absolute offset.
861 * Show 0, 0 as the relative offsets if entry is not in the map (meaning they have not been changed yet).
862 */
863 const auto key_offs_pair = this->offs_start_map.find(this->current_sprite);
864 if (key_offs_pair != this->offs_start_map.end()) {
865 return GetString(STR_SPRITE_ALIGNER_OFFSETS_REL,
866 UnScaleByZoom(spr->x_offs - key_offs_pair->second.first, SpriteAlignerWindow::zoom),
867 UnScaleByZoom(spr->y_offs - key_offs_pair->second.second, SpriteAlignerWindow::zoom));
868 }
869
870 return GetString(STR_SPRITE_ALIGNER_OFFSETS_REL, 0, 0);
871 }
872
873 default:
874 return this->Window::GetWidgetString(widget, stringid);
875 }
876 }
877
878 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
879 {

Callers

nothing calls this directly

Calls 9

GetSpriteFunction · 0.85
GetAction5TypesFunction · 0.85
GetOriginFileFunction · 0.85
GetSpriteLocalIDFunction · 0.85
UnScaleByZoomFunction · 0.85
GetStringFunction · 0.70
dataMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected