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

Method DrawMainPanelWidget

src/newgrf_debug_gui.cpp:438–528  ·  view source on GitHub ↗

* Helper function to draw the main panel widget. * @param r The rectangle to draw within. */

Source from the content-addressed store, hash-verified

436 * @param r The rectangle to draw within.
437 */
438 void DrawMainPanelWidget(const Rect &r) const
439 {
440 uint index = this->GetFeatureIndex();
441 const NIFeature *nif = GetFeature(this->window_number);
442 const NIHelper &nih = *nif->helper;
443 const void *base = nih.GetInstance(index);
444 const void *base_spec = nih.GetSpec(index);
445
446 uint i = 0;
447 if (!nif->variables.empty()) {
448 this->DrawString(r, i++, "Variables:");
449 for (const NIVariable &niv : nif->variables) {
450 bool avail = true;
451 uint param = HasVariableParameter(niv.var) ? NewGRFInspectWindow::var60params[GetFeatureNum(this->window_number)][niv.var - 0x60] : 0;
452 uint value = nih.Resolve(index, niv.var, param, avail);
453
454 if (!avail) continue;
455
456 if (HasVariableParameter(niv.var)) {
457 this->DrawString(r, i++, fmt::format(" {:02x}[{:02x}]: {:08x} ({})", niv.var, param, value, niv.name));
458 } else {
459 this->DrawString(r, i++, fmt::format(" {:02x}: {:08x} ({})", niv.var, value, niv.name));
460 }
461 }
462 }
463
464 auto psa = nih.GetPSA(index, this->caller_grfid);
465 if (!psa.empty()) {
466 if (nih.PSAWithParameter()) {
467 this->DrawString(r, i++, fmt::format("Persistent storage [{:08X}]:", std::byteswap(this->caller_grfid)));
468 } else {
469 this->DrawString(r, i++, "Persistent storage:");
470 }
471 assert(psa.size() % 4 == 0);
472 for (size_t j = 0; j < psa.size(); j += 4) {
473 this->DrawString(r, i++, fmt::format(" {}: {} {} {} {}", j, psa[j], psa[j + 1], psa[j + 2], psa[j + 3]));
474 }
475 }
476
477 auto badges = nih.GetBadges(index);
478 if (!badges.empty()) {
479 this->DrawString(r, i++, "Badges:");
480 for (const BadgeID &badge_index : badges) {
481 const Badge *badge = GetBadge(badge_index);
482 this->DrawString(r, i++, fmt::format(" {}: {}", StrMakeValid(badge->label), GetString(badge->name)));
483 }
484 }
485
486 if (!nif->properties.empty()) {
487 this->DrawString(r, i++, "Properties:");
488 for (const NIProperty &nip : nif->properties) {
489 uint32_t value = nip.read_proc(base);
490 this->DrawString(r, i++, fmt::format(" {:02x}: {} ({})", nip.prop, this->GetPropertyString(nip, value), nip.name));
491 }
492 }
493
494 if (!nif->callbacks.empty()) {
495 this->DrawString(r, i++, "Callbacks:");

Callers 1

DrawWidgetMethod · 0.95

Calls 15

GetFeatureIndexMethod · 0.95
DrawStringMethod · 0.95
GetPropertyStringMethod · 0.95
GetFeatureFunction · 0.85
GetFeatureNumFunction · 0.85
byteswapFunction · 0.85
GetBadgeFunction · 0.85
StrMakeValidFunction · 0.70
GetStringFunction · 0.70
formatFunction · 0.50
GetInstanceMethod · 0.45
GetSpecMethod · 0.45

Tested by

no test coverage detected