| 59 | } |
| 60 | |
| 61 | void ModsMenu::update(float dt) { |
| 62 | Pane::update(dt); |
| 63 | |
| 64 | size_t selectedItem = m_modList->selectedItem(); |
| 65 | if (selectedItem == NPos) { |
| 66 | m_modName->setText(""); |
| 67 | m_modAuthor->setText(""); |
| 68 | m_modVersion->setText(""); |
| 69 | m_modPath->setText(""); |
| 70 | m_modDescription->setText(""); |
| 71 | |
| 72 | } else { |
| 73 | String assetsSource = m_assetsSources.at(selectedItem); |
| 74 | JsonObject assetsSourceMetadata = Root::singleton().assets()->assetSourceMetadata(assetsSource); |
| 75 | |
| 76 | m_modName->setText(bestModName(assetsSourceMetadata, assetsSource)); |
| 77 | m_modAuthor->setText(assetsSourceMetadata.value("author", "No Author Set").toString()); |
| 78 | m_modVersion->setText(assetsSourceMetadata.value("version", "No Version Set").printString()); |
| 79 | m_modPath->setText(assetsSource); |
| 80 | m_modDescription->setText(assetsSourceMetadata.value("description", "").toString()); |
| 81 | |
| 82 | String link = assetsSourceMetadata.value("link", "").toString(); |
| 83 | |
| 84 | m_linkButton->setEnabled(!link.empty()); |
| 85 | m_copyLinkButton->setEnabled(!link.empty()); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | String ModsMenu::bestModName(JsonObject const& metadata, String const& sourcePath) { |
| 90 | if (auto ptr = metadata.ptr("friendlyName")) |
nothing calls this directly
no test coverage detected