| 10 | namespace Star { |
| 11 | |
| 12 | ModsMenu::ModsMenu() { |
| 13 | auto assets = Root::singleton().assets(); |
| 14 | |
| 15 | GuiReader reader; |
| 16 | reader.registerCallback("linkbutton", bind(&ModsMenu::openLink, this)); |
| 17 | reader.registerCallback("workshopbutton", bind(&ModsMenu::openWorkshop, this)); |
| 18 | reader.construct(assets->json("/interface/modsmenu/modsmenu.config:paneLayout"), this); |
| 19 | |
| 20 | m_assetsSources = assets->assetSources(); |
| 21 | m_modList = fetchChild<ListWidget>("mods.list"); |
| 22 | for (auto const& assetsSource : m_assetsSources) { |
| 23 | auto metadata = assets->assetSourceMetadata(assetsSource); |
| 24 | auto listItem = m_modList->addItem(); |
| 25 | auto modName = listItem->fetchChild<LabelWidget>("name"); |
| 26 | modName->setText(bestModName(metadata, assetsSource)); |
| 27 | if (auto iconImage = metadata.ptr("icon")) { |
| 28 | auto modIcon = listItem->fetchChild<ImageWidget>("icon"); |
| 29 | modIcon->setImage(iconImage->toString()); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | m_modName = findChild<LabelWidget>("modname"); |
| 34 | m_modAuthor = findChild<LabelWidget>("modauthor"); |
| 35 | m_modVersion = findChild<LabelWidget>("modversion"); |
| 36 | m_modPath = findChild<LabelWidget>("modpath"); |
| 37 | m_modDescription = findChild<LabelWidget>("moddescription"); |
| 38 | |
| 39 | m_linkButton = fetchChild<ButtonWidget>("linkbutton"); |
| 40 | m_copyLinkButton = fetchChild<ButtonWidget>("copylinkbutton"); |
| 41 | |
| 42 | auto linkLabel = fetchChild<LabelWidget>("linklabel"); |
| 43 | auto copyLinkLabel = fetchChild<LabelWidget>("copylinklabel"); |
| 44 | auto workshopLinkButton = fetchChild<ButtonWidget>("workshopbutton"); |
| 45 | |
| 46 | auto& guiContext = GuiContext::singleton(); |
| 47 | bool hasDesktopService = (bool)guiContext.applicationController()->desktopService(); |
| 48 | |
| 49 | workshopLinkButton->setEnabled(hasDesktopService); |
| 50 | |
| 51 | m_linkButton->setVisibility(hasDesktopService); |
| 52 | m_copyLinkButton->setVisibility(!hasDesktopService); |
| 53 | |
| 54 | m_linkButton->setEnabled(false); |
| 55 | m_copyLinkButton->setEnabled(false); |
| 56 | |
| 57 | linkLabel->setVisibility(hasDesktopService); |
| 58 | copyLinkLabel->setVisibility(!hasDesktopService); |
| 59 | } |
| 60 | |
| 61 | void ModsMenu::update(float dt) { |
| 62 | Pane::update(dt); |
nothing calls this directly
no test coverage detected