MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / ModsMenu

Method ModsMenu

source/frontend/StarModsMenu.cpp:12–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10namespace Star {
11
12ModsMenu::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
61void ModsMenu::update(float dt) {
62 Pane::update(dt);

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
assetsMethod · 0.80
jsonMethod · 0.80
assetSourcesMethod · 0.80
assetSourceMetadataMethod · 0.80
addItemMethod · 0.80
setImageMethod · 0.80
setVisibilityMethod · 0.80
registerCallbackMethod · 0.45
constructMethod · 0.45
setTextMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected